-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: aztec-cli unbox "really empty box" #2388
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
01513a9
copy a test contract with same webapp
dan-aztec c43c08f
working but horrible version
dan-aztec ff1df69
add minimal version that deploys
dan-aztec e4af8dd
fix contract call
dan-aztec 58e2732
add blank option
dan-aztec 814a1ea
Merge branch 'master' into dan/really-empty-box
dan-aztec eaf2de9
try to revert some yarn.lock
dan-aztec 5a80782
update yarnbase dockerfile
dan-aztec cc0be2f
revert yarn.lock
dan-aztec 8582c03
Merge branch 'master' into dan/really-empty-box
dan-aztec fd0b8be
pr feedback
dan-aztec 10392a6
readd artifacts
dan-aztec 788c4a0
Merge branch 'master' into dan/really-empty-box
dan-aztec a165a12
Merge branch 'master' into dan/really-empty-box
dan-aztec 11fd01e
pr feedback
dan-aztec 921960b
imports
dan-aztec 626e4bd
Merge branch 'master' into dan/really-empty-box
dan-aztec 1526378
lingering private varname
dan-aztec 7d7476e
Update yarn-project/boxes/blank/README.md
dan-aztec 9090864
small pr feedback
dan-aztec 3f1f4ae
Merge branch 'master' into dan/really-empty-box
dan-aztec File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
module.exports = { | ||
root: true, | ||
env: { browser: true, es2020: true }, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:import/recommended', | ||
'plugin:import/typescript', | ||
'prettier', | ||
], | ||
settings: { | ||
'import/resolver': { | ||
typescript: true, | ||
node: true, | ||
}, | ||
}, | ||
ignorePatterns: ['dist', '.eslintrc.cjs'], | ||
parser: '@typescript-eslint/parser', | ||
plugins: [], | ||
overrides: [ | ||
{ | ||
files: ['*.ts', '*.tsx'], | ||
parserOptions: { | ||
// hacky workaround for CI not having the same tsconfig setup | ||
project: true, | ||
}, | ||
}, | ||
], | ||
rules: { | ||
'@typescript-eslint/explicit-module-boundary-types': 'off', | ||
'@typescript-eslint/no-non-null-assertion': 'off', | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
'@typescript-eslint/no-empty-function': 'off', | ||
'@typescript-eslint/await-thenable': 'error', | ||
'@typescript-eslint/no-floating-promises': 2, | ||
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }], | ||
'require-await': 2, | ||
'no-console': 'warn', | ||
'no-constant-condition': 'off', | ||
camelcase: 2, | ||
'no-restricted-imports': [ | ||
'error', | ||
{ | ||
patterns: [ | ||
{ | ||
group: ['client-dest'], | ||
message: "Fix this absolute garbage import. It's your duty to solve it before it spreads.", | ||
}, | ||
{ | ||
group: ['dest'], | ||
message: 'You should not be importing from a build directory. Did you accidentally do a relative import?', | ||
}, | ||
], | ||
}, | ||
], | ||
'import/no-unresolved': 'error', | ||
'import/no-extraneous-dependencies': 'error', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dest | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"printWidth": 120, | ||
"arrowParens": "avoid" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
This is a minimal [Aztec](https://aztec.network/) Noir smart contract and frontend bootstrapped with [`aztec-cli unbox`](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/cli). It is recommended you use the `aztec-cli unbox blank` command so that the repository is copied with needed modifications from the monorepo subpackage. | ||
|
||
## Setup | ||
|
||
Dependencies can be installed from the root of the package: | ||
|
||
```bash | ||
yarn | ||
yarn install:noir | ||
yarn install:sandbox | ||
``` | ||
|
||
This sandbox requires [Docker](https://www.docker.com/) to be installed _and running_ locally. In the event the image needs updating, you can run `yarn install:sandbox` (see [sandbox docs](https://aztec-docs-dev.netlify.app/dev_docs/getting_started/sandbox) for more information.) | ||
|
||
In addition to the usual javascript dependencies, this project requires `nargo` (package manager) and `noir` (a Domain Specific Language for SNARK proving systems) in addition to `@aztec/aztec-cli`. The former are installed within `yarn install:noir` | ||
|
||
## Getting started | ||
|
||
After `yarn` has run,`yarn start:sandbox` in one terminal will launch a local instance of the Aztec sandbox via Docker Compose and `yarn start:dev` will launch a frontend app for deploying and interacting with an empty Aztec smart contract. | ||
|
||
At this point, [http://localhost:5173](http://localhost:5173) should provide a minimal smart contract frontend. | ||
|
||
This folder should have the following directory structure: | ||
|
||
``` | ||
|— README.md | ||
|— package.json | ||
|— src | ||
index.html | ||
index.ts | ||
|— contracts | ||
|— src | ||
| The Noir smart contract source files are here. | ||
|— main.nr - the cloned noir contract, your starting point | ||
|- interface.nr - autogenerated from main.nr when you compile | ||
|— Nargo.toml [Noir build file, includes Aztec smart contract dependencies] | ||
|— artifacts | ||
| These are both generated from `contracts/` by the compile command | ||
|— blank_contract.json | ||
|— blank.ts | ||
|— tests | ||
| A simple end2end test deploying and testing the minimal contract on a local sandbox | ||
| using the front end helper methods in index.ts | ||
| The test requires the sandbox and anvil to be running (yarn start:sandbox). | ||
|- blank.contract.test.ts | ||
``` | ||
|
||
Most relevant to you is likely `src/contracts/main.nr` (and the build config `src/contracts/Nargo.toml`). This contains the example blank contract logic that the frontend interacts with and is a good place to start writing Noir. | ||
|
||
The `src/artifacts` folder can be re-generated from the command line | ||
|
||
```bash | ||
yarn compile | ||
``` | ||
|
||
This will generate a [Contract ABI](src/artifacts/test_contract.json) and TypeScript class for the [Aztec smart contract](src/contracts/main.nr), which the frontend uses to generate the UI. | ||
|
||
Note: the `compile` command seems to generate a Typescript file which needs a single change - | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is true, we should open an issue and fix the command so that the path can be correctly generated. |
||
|
||
``` | ||
import TestContractAbiJson from 'text_contract.json' assert { type: 'json' }; | ||
// need to update the relative import to | ||
import TestContractAbiJson from './test_contract.json' assert { type: 'json' }; | ||
``` | ||
|
||
After compiling, you can re-deploy the upated noir smart contract from the web UI. The function interaction forms are generated from parsing the ContractABI, so they should update automatically after you recompile. | ||
|
||
## Learn More | ||
|
||
To learn more about Noir Smart Contract development, take a look at the following resources: | ||
|
||
- [Awesome Noir](https://github.com/noir-lang/awesome-noir) - learn about the Noir programming language. | ||
|
||
## Deploy on Aztec3 | ||
|
||
Coming Soon :) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
{ | ||
"name": "blank-contract", | ||
"private": true, | ||
"version": "0.1.0", | ||
"type": "module", | ||
"main": "./dest/index.js", | ||
"scripts": { | ||
"build": "yarn clean && webpack", | ||
"install:noir": "curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash noirup -v aztec", | ||
"install:sandbox": "docker pull aztecprotocol/aztec-sandbox:latest", | ||
"clean": "rm -rf ./dest .tsbuildinfo", | ||
"start": "serve -p 3000 ./dest", | ||
"start:dev": "webpack serve --mode=development", | ||
"start:sandbox": "SANDBOX_VERSION=latest /bin/bash -c \"$(curl -fsSL 'https://sandbox.aztec.network')\" ", | ||
"formatting": "prettier --check ./src && eslint ./src", | ||
"formatting:fix": "prettier -w ./src", | ||
"compile": "aztec-cli compile src/contracts --outdir ../artifacts --typescript ../artifacts", | ||
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --runInBand", | ||
"test:integration": "concurrently -k -s first -c reset,dim -n test,anvil \"yarn test\" \"anvil\"" | ||
}, | ||
"jest": { | ||
"preset": "ts-jest'", | ||
"testEnvironment": "jsdom" | ||
}, | ||
"dependencies": { | ||
"@aztec/aztec-ui": "^0.1.14", | ||
"@aztec/aztec.js": "workspace:^", | ||
"@aztec/circuits.js": "workspace:^", | ||
"@aztec/cli": "workspace:^", | ||
"@aztec/foundation": "workspace:^", | ||
"serve": "^14.2.1" | ||
}, | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^6.0.0", | ||
"@typescript-eslint/parser": "^6.0.0", | ||
"copy-webpack-plugin": "^11.0.0", | ||
"eslint": "^8.45.0", | ||
"eslint-import-resolver-typescript": "^3.5.5", | ||
"eslint-plugin-import": "^2.27.5", | ||
"jest": "^29.6.4", | ||
"prettier": "^3.0.3", | ||
"resolve-typescript-plugin": "^2.0.1", | ||
"stream-browserify": "^3.0.0", | ||
"ts-jest": "^29.1.1", | ||
"ts-loader": "^9.4.4", | ||
"ts-node": "^10.9.1", | ||
"tty-browserify": "^0.0.1", | ||
"typescript": "^5.0.4", | ||
"webpack": "^5.88.2", | ||
"webpack-cli": "^5.1.4", | ||
"webpack-dev-server": "^4.15.1" | ||
}, | ||
"browserslist": { | ||
"production": [ | ||
">0.5%", | ||
"not dead", | ||
"not op_mini all" | ||
], | ||
"development": [ | ||
"last 1 chrome version", | ||
"last 1 firefox version", | ||
"last 1 safari version" | ||
] | ||
}, | ||
"files": [ | ||
"dest", | ||
"src", | ||
"!*.test.*" | ||
], | ||
"types": "./dest/index.d.ts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* Autogenerated file, do not edit! */ | ||
|
||
/* eslint-disable */ | ||
import { | ||
AztecAddress, | ||
CompleteAddress, | ||
ContractBase, | ||
ContractFunctionInteraction, | ||
ContractMethod, | ||
DeployMethod, | ||
FieldLike, | ||
Wallet, | ||
} from '@aztec/aztec.js'; | ||
import { ContractAbi } from '@aztec/foundation/abi'; | ||
import { Point } from '@aztec/foundation/fields'; | ||
import { AztecRPC, PublicKey } from '@aztec/types'; | ||
|
||
import BlankContractAbiJson from './blank_contract.json' assert { type: 'json' }; | ||
|
||
export const BlankContractAbi = BlankContractAbiJson as ContractAbi; | ||
|
||
/** | ||
* Type-safe interface for contract Blank; | ||
*/ | ||
export class BlankContract extends ContractBase { | ||
private constructor( | ||
/** The deployed contract's complete address. */ | ||
completeAddress: CompleteAddress, | ||
/** The wallet. */ | ||
wallet: Wallet, | ||
) { | ||
super(completeAddress, BlankContractAbi, wallet); | ||
} | ||
|
||
/** | ||
* Creates a contract instance. | ||
* @param address - The deployed contract's address. | ||
* @param wallet - The wallet to use when interacting with the contract. | ||
* @returns A promise that resolves to a new Contract instance. | ||
*/ | ||
public static async at( | ||
/** The deployed contract's address. */ | ||
address: AztecAddress, | ||
/** The wallet. */ | ||
wallet: Wallet, | ||
) { | ||
const extendedContractData = await wallet.getExtendedContractData(address); | ||
if (extendedContractData === undefined) { | ||
throw new Error('Contract ' + address.toString() + ' is not deployed'); | ||
} | ||
return new BlankContract(extendedContractData.getCompleteAddress(), wallet); | ||
} | ||
|
||
/** | ||
* Creates a tx to deploy a new instance of this contract. | ||
*/ | ||
public static deploy(rpc: AztecRPC) { | ||
return new DeployMethod<BlankContract>(Point.ZERO, rpc, BlankContractAbi, Array.from(arguments).slice(1)); | ||
} | ||
|
||
/** | ||
* Creates a tx to deploy a new instance of this contract using the specified public key to derive the address. | ||
*/ | ||
public static deployWithPublicKey(rpc: AztecRPC, publicKey: PublicKey) { | ||
return new DeployMethod<BlankContract>(publicKey, rpc, BlankContractAbi, Array.from(arguments).slice(2)); | ||
} | ||
|
||
/** | ||
* Returns this contract's ABI. | ||
*/ | ||
public static get abi(): ContractAbi { | ||
return BlankContractAbi; | ||
} | ||
|
||
/** Type-safe wrappers for the public methods exposed by the contract. */ | ||
public methods!: { | ||
/** getPublicKey(address: field) */ | ||
getPublicKey: ((address: FieldLike) => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>; | ||
}; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The url will change. Remember to update it after official release.