-
Notifications
You must be signed in to change notification settings - Fork 598
refactor: aztec new and init creating 2 crates #20681
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| target/ | ||
| codegenCache.json |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,2 @@ | ||
| [package] | ||
| name = "init" | ||
| type = "contract" | ||
|
|
||
| [dependencies] | ||
| aztec = { path = "../../noir-projects/aztec-nr/aztec" } | ||
| [workspace] | ||
| members = ["contract", "test"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # init | ||
|
|
||
| An Aztec Noir contract project. | ||
|
|
||
| ## Compile | ||
|
|
||
| ```bash | ||
| aztec compile | ||
| ``` | ||
|
|
||
| This compiles the contract in `contract/` and outputs artifacts to `target/`. | ||
|
|
||
| ## Test | ||
|
|
||
| ```bash | ||
| aztec test | ||
| ``` | ||
|
|
||
| This runs the tests in `test/`. | ||
|
|
||
| ## Generate TypeScript bindings | ||
|
|
||
| ```bash | ||
| aztec codegen target -o src/artifacts | ||
| ``` | ||
|
|
||
| This generates TypeScript contract artifacts from the compiled output in `target/` into `src/artifacts/`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| [package] | ||
| name = "init" | ||
| type = "contract" | ||
|
|
||
| [dependencies] | ||
| aztec = { path = "../../../noir-projects/aztec-nr/aztec" } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| use aztec::macros::aztec; | ||
benesjan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| #[aztec] | ||
| pub contract Main { | ||
| use aztec::macros::functions::{external, initializer}; | ||
|
|
||
| #[initializer] | ||
| #[external("private")] | ||
| fn constructor() {} | ||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| [package] | ||
| name = "init_test" | ||
| type = "lib" | ||
|
|
||
| [dependencies] | ||
| aztec = { path = "../../../noir-projects/aztec-nr/aztec" } | ||
| init = { path = "../contract" } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| use aztec::test::helpers::test_environment::TestEnvironment; | ||
| use init::Main; | ||
|
|
||
| #[test] | ||
| unconstrained fn test_constructor() { | ||
| let mut env = TestEnvironment::new(); | ||
| let deployer = env.create_light_account(); | ||
|
|
||
| // Deploy the contract with the default constructor: | ||
| let contract_address = env.deploy("@init/Main").with_private_initializer( | ||
| deployer, | ||
| Main::interface().constructor(), | ||
| ); | ||
|
|
||
| // Deploy without an initializer: | ||
| let contract_address = env.deploy("@init/Main").without_initializer(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -210,24 +210,30 @@ The contract demonstrates several important patterns: | |
|
|
||
| ### Create the Contract Project | ||
|
|
||
| Use `aztec init` to generate the contract project structure: | ||
| Use `aztec new` to generate the contract project structure: | ||
|
|
||
| ```bash | ||
| aztec init --contract contract | ||
| aztec new contract --name ValueNotEqual | ||
| ``` | ||
|
|
||
| This creates: | ||
| This creates a workspace with two crates: | ||
|
|
||
| ```tree | ||
| contract/ | ||
|
Contributor
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. Nit: using
Contributor
Author
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. I don't think |
||
| ├── src/ | ||
| │ └── main.nr # Contract code | ||
| └── Nargo.toml # Contract configuration | ||
| ├── Nargo.toml # Workspace root | ||
| ├── contract/ | ||
| │ ├── src/ | ||
| │ │ └── main.nr # Contract code | ||
| │ └── Nargo.toml # Contract configuration | ||
| └── test/ | ||
| ├── src/ | ||
| │ └── lib.nr # Test code | ||
| └── Nargo.toml # Test configuration | ||
| ``` | ||
|
|
||
| ### Contract Configuration | ||
|
|
||
| Update `contract/Nargo.toml` with the required dependencies: | ||
| Update `contract/contract/Nargo.toml` with the required dependencies: | ||
|
|
||
| ```toml | ||
| [package] | ||
|
|
@@ -240,15 +246,15 @@ aztec = { git = "https://github.com/AztecProtocol/aztec-nr/", tag = "#include_az | |
| bb_proof_verification = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "#include_aztec_version", directory = "barretenberg/noir/bb_proof_verification" } | ||
| ``` | ||
|
|
||
| **Key differences from the circuit's Nargo.toml**: | ||
| **Key differences from the circuit's Nargo.toml** (in `contract/contract/Nargo.toml`): | ||
|
|
||
| - `type = "contract"` (not `"bin"`) | ||
| - Depends on `aztec` for Aztec-specific features | ||
| - Depends on `bb_proof_verification` for `verify_honk_proof` | ||
|
|
||
| ### Contract Structure | ||
|
|
||
| Replace the contents of `contract/src/main.nr` with: | ||
| Replace the contents of `contract/contract/src/main.nr` with: | ||
|
|
||
| #include_code full_contract /docs/examples/contracts/recursive_verification_contract/src/main.nr rust | ||
|
|
||
|
|
@@ -380,7 +386,7 @@ Create the following files in your project root directory. | |
| "name": "recursive-verification-tutorial", | ||
| "type": "module", | ||
| "scripts": { | ||
| "ccc": "cd contract && aztec compile && aztec codegen target -o artifacts", | ||
| "ccc": "cd contract && aztec compile && aztec codegen target -o contract/artifacts", | ||
| "data": "tsx scripts/generate_data.ts", | ||
| "recursion": "tsx scripts/run_recursion.ts" | ||
| }, | ||
|
|
@@ -451,7 +457,7 @@ yarn ccc | |
| This generates: | ||
|
|
||
| - `contract/target/ValueNotEqual.json` - Contract artifact (bytecode, ABI, etc.) | ||
| - `contract/artifacts/ValueNotEqual.ts` - TypeScript class for deploying and interacting with the contract | ||
| - `contract/contract/artifacts/ValueNotEqual.ts` - TypeScript class for deploying and interacting with the contract | ||
|
|
||
| ### Proof Generation Script | ||
|
|
||
|
|
@@ -584,7 +590,7 @@ import { SponsoredFeePaymentMethod } from "@aztec/aztec.js/fee"; | |
| import type { FieldLike } from "@aztec/aztec.js/abi"; | ||
| import { getSponsoredFPCInstance } from "./sponsored_fpc.ts"; | ||
| import { SponsoredFPCContract } from "@aztec/noir-contracts.js/SponsoredFPC"; | ||
| import { ValueNotEqualContract } from "../contract/artifacts/ValueNotEqual"; | ||
| import { ValueNotEqualContract } from "../contract/contract/artifacts/ValueNotEqual"; | ||
| import data from "../data.json"; | ||
| import { EmbeddedWallet } from "@aztec/wallets/embedded"; | ||
| import { AztecAddress } from "@aztec/aztec.js/addresses"; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.