Skip to content

Commit a413629

Browse files
critesjoshclaude
andcommitted
Migrate examples to Aztec v3.0.0-devnet.20251212
Update four example projects to use the latest Aztec devnet version: - custom-note: Update contract to use Owned<PrivateSet> pattern, add randomness to CustomNote, use .deliver() for message delivery - account-contract: Update imports from dep::aztec to aztec, use poseidon2_hash, fix TypeScript API for v3 DeployMethod signature - test-wallet-webapp: Update package dependencies - note-send-proof: Major migration from v2 to v3, rewrite contract to use BalanceSet pattern, add postinstall workaround for bb.js native module path issue, update tests to use Jest with yarn All contracts compile and tests pass. Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 848e3ff commit a413629

File tree

22 files changed

+7241
-7343
lines changed

22 files changed

+7241
-7343
lines changed

account-contract/Nargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ compiler_version = ">=1.0.0"
55
type = "contract"
66

77
[dependencies]
8-
aztec = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "v3.0.0-devnet.4", directory = "noir-projects/aztec-nr/aztec" }
9-
poseidon = { tag = "v0.1.1", git = "https://github.com/noir-lang/poseidon" }
8+
aztec = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "v3.0.0-devnet.20251212", directory = "noir-projects/aztec-nr/aztec" }

account-contract/README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const entrypoint = new PasswordAccountEntrypoint(
8888
Compile the Noir contract:
8989

9090
```bash
91-
aztec-nargo compile
91+
aztec compile
9292
```
9393

9494
Install TypeScript dependencies:
@@ -170,18 +170,27 @@ When implementing custom account contracts in Aztec, be aware of these critical
170170
- Failed fee payments will cause the entire transaction to fail
171171
- Consider how users will fund their account contracts with Fee Asset
172172

173+
## Aztec Version Compatibility
174+
175+
This example is compatible with **Aztec v3.0.0-devnet.20251212**.
176+
177+
To set this version:
178+
179+
```bash
180+
aztec-up 3.0.0-devnet.20251212
181+
```
182+
173183
## Dependencies
174184

175185
### Noir Dependencies
176186

177-
- **aztec**: v3.0.0-devnet.4
178-
- **poseidon**: v0.1.1
187+
- **aztec**: v3.0.0-devnet.20251212
179188

180189
### TypeScript Dependencies
181190

182-
- **@aztec/aztec.js**: 3.0.0-devnet.4
183-
- **@aztec/accounts**: 3.0.0-devnet.4
184-
- **@aztec/stdlib**: 3.0.0-devnet.4
191+
- **@aztec/aztec.js**: 3.0.0-devnet.20251212
192+
- **@aztec/accounts**: 3.0.0-devnet.20251212
193+
- **@aztec/stdlib**: 3.0.0-devnet.20251212
185194
- **@aztec/entrypoints**: Included in aztec.js
186195

187196
## Project Structure

account-contract/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
"typescript": "^5.0.0"
1313
},
1414
"dependencies": {
15-
"@aztec/accounts": "3.0.0-devnet.4",
16-
"@aztec/aztec.js": "3.0.0-devnet.4",
17-
"@aztec/foundation": "3.0.0-devnet.4",
18-
"@aztec/noir-contracts.js": "3.0.0-devnet.4",
19-
"@aztec/stdlib": "3.0.0-devnet.4",
20-
"@aztec/test-wallet": "3.0.0-devnet.4",
15+
"@aztec/accounts": "3.0.0-devnet.20251212",
16+
"@aztec/aztec.js": "3.0.0-devnet.20251212",
17+
"@aztec/foundation": "3.0.0-devnet.20251212",
18+
"@aztec/noir-contracts.js": "3.0.0-devnet.20251212",
19+
"@aztec/stdlib": "3.0.0-devnet.20251212",
20+
"@aztec/test-wallet": "3.0.0-devnet.20251212",
2121
"tsx": "^4.20.6"
2222
}
2323
}

account-contract/src/account_actions.nr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
use dep::aztec::context::PrivateContext;
1+
use aztec::context::PrivateContext;
22

3-
use dep::aztec::protocol_types::{
3+
use aztec::protocol_types::{
44
constants::GENERATOR_INDEX__TX_NULLIFIER, hash::poseidon2_hash_with_separator, traits::Hash,
55
};
66

7-
use dep::aztec::authwit::auth::{compute_authwit_message_hash, IS_VALID_SELECTOR};
8-
use dep::aztec::authwit::entrypoint::app::AppPayload;
7+
use aztec::authwit::auth::{compute_authwit_message_hash, IS_VALID_SELECTOR};
8+
use aztec::authwit::entrypoint::app::AppPayload;
99

1010
pub struct AccountActions<Context> {
1111
context: Context,

account-contract/src/main.nr

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use dep::aztec::macros::aztec;
1+
use aztec::macros::aztec;
22

33
mod account_actions;
44

55
#[aztec]
66
pub contract PasswordAccount {
7-
use dep::aztec::{
7+
use aztec::{
88
authwit::{
99
auth::compute_authwit_nullifier,
1010
entrypoint::app::AppPayload,
@@ -16,12 +16,10 @@ pub contract PasswordAccount {
1616
get_nullifier_membership_witness::get_low_nullifier_membership_witness,
1717
notes::{get_sender_for_tags, set_sender_for_tags},
1818
},
19-
protocol_types::address::AztecAddress,
19+
protocol_types::{address::AztecAddress, hash::poseidon2_hash},
2020
state_vars::PublicImmutable,
2121
};
2222

23-
use dep::poseidon;
24-
2523
use crate::account_actions::AccountActions;
2624

2725
#[storage]
@@ -33,7 +31,7 @@ pub contract PasswordAccount {
3331
#[external("private")]
3432
#[initializer]
3533
fn constructor(password: Field) {
36-
let hashed_password = poseidon::poseidon2::Poseidon2::hash([password], 1);
34+
let hashed_password = poseidon2_hash([password]);
3735
self.enqueue_self.set_hashed_password(hashed_password);
3836

3937
// Safety: The sender for tags is only used to compute unconstrained shared secrets for emitting logs.
@@ -88,7 +86,7 @@ pub contract PasswordAccount {
8886

8987
let hashed_password_from_account = storage.hashed_password.read();
9088

91-
let hashed_password = poseidon::poseidon2::Poseidon2::hash([password], 1);
89+
let hashed_password = poseidon2_hash([password]);
9290

9391
hashed_password_from_account == hashed_password
9492
}
@@ -103,7 +101,7 @@ pub contract PasswordAccount {
103101
unconstrained fn lookup_validity(consumer: AztecAddress, inner_hash: Field, password: Field) -> bool {
104102
let hashed_password_from_account = self.storage.hashed_password.read();
105103

106-
let hashed_password = poseidon::poseidon2::Poseidon2::hash([password], 1);
104+
let hashed_password = poseidon2_hash([password]);
107105

108106
let valid_in_private = hashed_password_from_account == hashed_password;
109107

account-contract/ts/deploy-account-contract.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
// import { DeployAccountMethod, DeployAccountOptions } from '@aztec/aztec.js/wallet';
2-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
1+
import { AztecAddress } from '@aztec/aztec.js/addresses';
2+
import { Fr } from '@aztec/aztec.js/fields';
33
import { SponsoredFeePaymentMethod } from '@aztec/aztec.js/fee';
4+
import { Contract, DeployMethod, type DeployOptions } from '@aztec/aztec.js/contracts';
5+
import { createAztecNodeClient } from '@aztec/aztec.js/node';
6+
import { deriveKeys } from '@aztec/aztec.js/keys';
47
import { getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
5-
import { CardGameContract } from '@aztec/noir-contracts.js/CardGame';
68
import { SponsoredFPCContractArtifact } from '@aztec/noir-contracts.js/SponsoredFPC';
79
import { SPONSORED_FPC_SALT } from '@aztec/constants';
8-
import { Fr } from '@aztec/foundation/fields';
910
import { PasswordAccountContract } from './password-account-entrypoint';
10-
import { deriveKeys } from '@aztec/stdlib/keys';
11-
import { Contract, DeployMethod, DeployOptions } from '@aztec/aztec.js/contracts';
1211
import { TestWallet } from '@aztec/test-wallet/server';
13-
import { createAztecNodeClient } from '@aztec/aztec.js/node';
1412

1513
async function getSponsoredPFCContract() {
1614
const instance = await getContractInstanceFromInstantiationParams(
@@ -66,7 +64,7 @@ const accountContractDeployMethod = new DeployMethod(
6664
publicKeys,
6765
wallet,
6866
artifact,
69-
address => Contract.at(address, artifact, wallet),
67+
(instance, wallet) => Contract.at(instance.address, artifact, wallet),
7068
constructorArgs,
7169
constructorName,
7270
)
@@ -78,8 +76,8 @@ console.log(stats);
7876

7977
const deployedAccountContract = await accountContractDeployMethod.send(deployAccountOpts).wait();
8078

81-
await wallet.createAccount({ secret: Fr.random(), contract: passwordAccountContract, salt: Fr.random() });
82-
83-
const cardGameContract = await CardGameContract.deploy(wallet).send({ from: deployedAccountContract.contract.address }).deployed();
79+
console.log('PasswordAccount contract deployed at:', deployedAccountContract.contract.address);
8480

85-
console.log(cardGameContract)
81+
// Create and register an account using the deployed contract
82+
const account = await wallet.createAccount({ secret: Fr.random(), contract: passwordAccountContract, salt: Fr.random() });
83+
console.log('Account registered at:', account.address.toString());

account-contract/ts/password-account-entrypoint.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
import { Fr } from '@aztec/foundation/fields';
2-
import { ContractArtifact, type FunctionAbi, FunctionSelector, encodeArguments, loadContractArtifact } from '@aztec/stdlib/abi';
3-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
1+
import { Fr } from '@aztec/aztec.js/fields';
2+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
3+
import { type ContractArtifact, type FunctionAbi, FunctionSelector, encodeArguments, loadContractArtifact } from '@aztec/stdlib/abi';
44
import type { GasSettings } from '@aztec/stdlib/gas';
5-
import { HashedValues, TxContext, TxExecutionRequest } from '@aztec/stdlib/tx';
6-
7-
import { AuthWitnessProvider, ChainInfo, EntrypointInterface } from '@aztec/entrypoints/interfaces';
8-
import { ExecutionPayload } from '@aztec/entrypoints/payload';
9-
import { EncodedAppEntrypointCalls } from '@aztec/entrypoints/encoding';
10-
import { DefaultAccountEntrypointOptions } from '@aztec/entrypoints/account';
11-
import { AccountContract, AccountInterface } from '@aztec/aztec.js/account';
5+
import { HashedValues, TxContext, TxExecutionRequest, type ExecutionPayload } from '@aztec/stdlib/tx';
126
import { CompleteAddress } from '@aztec/stdlib/contract';
137
import { AuthWitness } from '@aztec/stdlib/auth-witness';
14-
import { NoirCompiledContract } from '@aztec/stdlib/noir';
8+
import type { NoirCompiledContract } from '@aztec/stdlib/noir';
9+
10+
import type { AuthWitnessProvider, ChainInfo, EntrypointInterface } from '@aztec/entrypoints/interfaces';
11+
import { EncodedAppEntrypointCalls } from '@aztec/entrypoints/encoding';
12+
import type { DefaultAccountEntrypointOptions } from '@aztec/entrypoints/account';
13+
import type { AccountContract, AccountInterface } from '@aztec/aztec.js/account';
1514

1615
import PasswordAccountContractJson from '../target/custom_account-PasswordAccount.json' with { type: 'json' };
1716

@@ -81,6 +80,7 @@ export class PasswordAccountEntrypoint implements EntrypointInterface {
8180
functionType: 'private',
8281
isInternal: false,
8382
isStatic: false,
83+
isOnlySelf: false,
8484
parameters: [{"name":"app_payload","type":{"kind":"struct","fields":[{"name":"function_calls","type":{"kind":"array","length":5,"type":{"kind":"struct","fields":[{"name":"args_hash","type":{"kind":"field"}},{"name":"function_selector","type":{"kind":"struct","fields":[{"name":"inner","type":{"kind":"integer","sign":"unsigned","width":32}}],"path":"aztec::protocol_types::abis::function_selector::FunctionSelector"}},{"name":"target_address","type":{"kind":"struct","fields":[{"name":"inner","type":{"kind":"field"}}],"path":"aztec::protocol_types::address::aztec_address::AztecAddress"}},{"name":"is_public","type":{"kind":"boolean"}},{"name":"hide_msg_sender","type":{"kind":"boolean"}},{"name":"is_static","type":{"kind":"boolean"}}],"path":"aztec::authwit::entrypoint::function_call::FunctionCall"}}},{"name":"tx_nonce","type":{"kind":"field"}}],"path":"aztec::authwit::entrypoint::app::AppPayload"},"visibility":"private"},{"name":"fee_payment_method","type":{"kind":"integer","sign":"unsigned","width":8},"visibility":"private"},{"name":"cancellable","type":{"kind":"boolean"},"visibility":"private"},{"name":"password","type":{"kind":"field"},"visibility":"private"}],
8585
returnTypes: [],
8686
errorTypes: {},

0 commit comments

Comments
 (0)