@aztec-labs/aztec 6.0.0-nightly.20260829
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -0
- package/dest/bin/index.d.ts +3 -0
- package/dest/bin/index.d.ts.map +1 -0
- package/dest/bin/index.js +61 -0
- package/dest/cli/admin_api_key_store.d.ts +45 -0
- package/dest/cli/admin_api_key_store.d.ts.map +1 -0
- package/dest/cli/admin_api_key_store.js +98 -0
- package/dest/cli/aztec_start_action.d.ts +3 -0
- package/dest/cli/aztec_start_action.d.ts.map +1 -0
- package/dest/cli/aztec_start_action.js +153 -0
- package/dest/cli/aztec_start_options.d.ts +17 -0
- package/dest/cli/aztec_start_options.d.ts.map +1 -0
- package/dest/cli/aztec_start_options.js +290 -0
- package/dest/cli/cli.d.ts +9 -0
- package/dest/cli/cli.d.ts.map +1 -0
- package/dest/cli/cli.js +37 -0
- package/dest/cli/cmds/compile.d.ts +4 -0
- package/dest/cli/cmds/compile.d.ts.map +1 -0
- package/dest/cli/cmds/compile.js +174 -0
- package/dest/cli/cmds/migrate_ha_db.d.ts +3 -0
- package/dest/cli/cmds/migrate_ha_db.d.ts.map +1 -0
- package/dest/cli/cmds/migrate_ha_db.js +27 -0
- package/dest/cli/cmds/profile.d.ts +4 -0
- package/dest/cli/cmds/profile.d.ts.map +1 -0
- package/dest/cli/cmds/profile.js +8 -0
- package/dest/cli/cmds/profile_flamegraph.d.ts +4 -0
- package/dest/cli/cmds/profile_flamegraph.d.ts.map +1 -0
- package/dest/cli/cmds/profile_flamegraph.js +52 -0
- package/dest/cli/cmds/profile_gates.d.ts +4 -0
- package/dest/cli/cmds/profile_gates.d.ts.map +1 -0
- package/dest/cli/cmds/profile_gates.js +76 -0
- package/dest/cli/cmds/profile_utils.d.ts +18 -0
- package/dest/cli/cmds/profile_utils.d.ts.map +1 -0
- package/dest/cli/cmds/profile_utils.js +50 -0
- package/dest/cli/cmds/prover.d.ts +4 -0
- package/dest/cli/cmds/prover.d.ts.map +1 -0
- package/dest/cli/cmds/prover.js +24 -0
- package/dest/cli/cmds/standby.d.ts +56 -0
- package/dest/cli/cmds/standby.d.ts.map +1 -0
- package/dest/cli/cmds/standby.js +140 -0
- package/dest/cli/cmds/start_bot.d.ts +8 -0
- package/dest/cli/cmds/start_bot.d.ts.map +1 -0
- package/dest/cli/cmds/start_bot.js +53 -0
- package/dest/cli/cmds/start_node.d.ts +8 -0
- package/dest/cli/cmds/start_node.d.ts.map +1 -0
- package/dest/cli/cmds/start_node.js +150 -0
- package/dest/cli/cmds/start_p2p_bootstrap.d.ts +6 -0
- package/dest/cli/cmds/start_p2p_bootstrap.d.ts.map +1 -0
- package/dest/cli/cmds/start_p2p_bootstrap.js +30 -0
- package/dest/cli/cmds/start_prover_agent.d.ts +4 -0
- package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -0
- package/dest/cli/cmds/start_prover_agent.js +58 -0
- package/dest/cli/cmds/start_prover_broker.d.ts +9 -0
- package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -0
- package/dest/cli/cmds/start_prover_broker.js +46 -0
- package/dest/cli/cmds/start_txe.d.ts +3 -0
- package/dest/cli/cmds/start_txe.d.ts.map +1 -0
- package/dest/cli/cmds/start_txe.js +12 -0
- package/dest/cli/cmds/utils/artifacts.d.ts +26 -0
- package/dest/cli/cmds/utils/artifacts.d.ts.map +1 -0
- package/dest/cli/cmds/utils/artifacts.js +24 -0
- package/dest/cli/cmds/utils/collect_crate_dirs.d.ts +21 -0
- package/dest/cli/cmds/utils/collect_crate_dirs.d.ts.map +1 -0
- package/dest/cli/cmds/utils/collect_crate_dirs.js +114 -0
- package/dest/cli/cmds/utils/needs_recompile.d.ts +10 -0
- package/dest/cli/cmds/utils/needs_recompile.d.ts.map +1 -0
- package/dest/cli/cmds/utils/needs_recompile.js +90 -0
- package/dest/cli/cmds/utils/spawn.d.ts +3 -0
- package/dest/cli/cmds/utils/spawn.d.ts.map +1 -0
- package/dest/cli/cmds/utils/spawn.js +16 -0
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +4 -0
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -0
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +61 -0
- package/dest/cli/index.d.ts +2 -0
- package/dest/cli/index.d.ts.map +1 -0
- package/dest/cli/index.js +1 -0
- package/dest/cli/preload_crs.d.ts +3 -0
- package/dest/cli/preload_crs.d.ts.map +1 -0
- package/dest/cli/preload_crs.js +6 -0
- package/dest/cli/util.d.ts +71 -0
- package/dest/cli/util.d.ts.map +1 -0
- package/dest/cli/util.js +261 -0
- package/dest/cli/versioning.d.ts +4 -0
- package/dest/cli/versioning.d.ts.map +1 -0
- package/dest/cli/versioning.js +9 -0
- package/dest/examples/token.d.ts +2 -0
- package/dest/examples/token.d.ts.map +1 -0
- package/dest/examples/token.js +59 -0
- package/dest/examples/util.d.ts +19 -0
- package/dest/examples/util.d.ts.map +1 -0
- package/dest/examples/util.js +30 -0
- package/dest/index.d.ts +2 -0
- package/dest/index.d.ts.map +1 -0
- package/dest/index.js +1 -0
- package/dest/local-network/auth_registry.d.ts +5 -0
- package/dest/local-network/auth_registry.d.ts.map +1 -0
- package/dest/local-network/auth_registry.js +17 -0
- package/dest/local-network/banana_fpc.d.ts +11 -0
- package/dest/local-network/banana_fpc.d.ts.map +1 -0
- package/dest/local-network/banana_fpc.js +81 -0
- package/dest/local-network/index.d.ts +4 -0
- package/dest/local-network/index.d.ts.map +1 -0
- package/dest/local-network/index.js +3 -0
- package/dest/local-network/local-network.d.ts +51 -0
- package/dest/local-network/local-network.d.ts.map +1 -0
- package/dest/local-network/local-network.js +205 -0
- package/dest/local-network/sponsored_fpc.d.ts +5 -0
- package/dest/local-network/sponsored_fpc.d.ts.map +1 -0
- package/dest/local-network/sponsored_fpc.js +18 -0
- package/dest/mnemonic.d.ts +2 -0
- package/dest/mnemonic.d.ts.map +1 -0
- package/dest/mnemonic.js +1 -0
- package/dest/splash.d.ts +3 -0
- package/dest/splash.d.ts.map +1 -0
- package/dest/splash.js +2 -0
- package/dest/testing/cheat_codes.d.ts +37 -0
- package/dest/testing/cheat_codes.d.ts.map +1 -0
- package/dest/testing/cheat_codes.js +36 -0
- package/dest/testing/epoch_test_settler.d.ts +19 -0
- package/dest/testing/epoch_test_settler.d.ts.map +1 -0
- package/dest/testing/epoch_test_settler.js +42 -0
- package/dest/testing/index.d.ts +6 -0
- package/dest/testing/index.d.ts.map +1 -0
- package/dest/testing/index.js +5 -0
- package/dest/testing/local-network.d.ts +51 -0
- package/dest/testing/local-network.d.ts.map +1 -0
- package/dest/testing/local-network.js +60 -0
- package/dest/testing/token_allowed_setup.d.ts +12 -0
- package/dest/testing/token_allowed_setup.d.ts.map +1 -0
- package/dest/testing/token_allowed_setup.js +24 -0
- package/package.json +125 -0
- package/scripts/add_crate.sh +53 -0
- package/scripts/aztec.sh +73 -0
- package/scripts/init.sh +39 -0
- package/scripts/new.sh +83 -0
- package/scripts/setup_workspace.sh +69 -0
- package/scripts/templates/blank/contract/Nargo.toml +6 -0
- package/scripts/templates/blank/contract/src/main.nr +10 -0
- package/scripts/templates/blank/test/Nargo.toml +7 -0
- package/scripts/templates/blank/test/src/lib.nr +11 -0
- package/scripts/templates/counter/contract/Nargo.toml +7 -0
- package/scripts/templates/counter/contract/src/main.nr +48 -0
- package/scripts/templates/counter/test/Nargo.toml +7 -0
- package/scripts/templates/counter/test/src/lib.nr +32 -0
- package/src/bin/index.ts +73 -0
- package/src/cli/admin_api_key_store.ts +127 -0
- package/src/cli/aztec_start_action.ts +173 -0
- package/src/cli/aztec_start_options.ts +333 -0
- package/src/cli/cli.ts +55 -0
- package/src/cli/cmds/compile.ts +205 -0
- package/src/cli/cmds/migrate_ha_db.ts +42 -0
- package/src/cli/cmds/profile.ts +25 -0
- package/src/cli/cmds/profile_flamegraph.ts +64 -0
- package/src/cli/cmds/profile_gates.ts +84 -0
- package/src/cli/cmds/profile_utils.ts +58 -0
- package/src/cli/cmds/prover.ts +41 -0
- package/src/cli/cmds/standby.ts +183 -0
- package/src/cli/cmds/start_bot.ts +78 -0
- package/src/cli/cmds/start_node.ts +199 -0
- package/src/cli/cmds/start_p2p_bootstrap.ts +37 -0
- package/src/cli/cmds/start_prover_agent.ts +77 -0
- package/src/cli/cmds/start_prover_broker.ts +69 -0
- package/src/cli/cmds/start_txe.ts +17 -0
- package/src/cli/cmds/utils/artifacts.ts +49 -0
- package/src/cli/cmds/utils/collect_crate_dirs.ts +118 -0
- package/src/cli/cmds/utils/needs_recompile.ts +98 -0
- package/src/cli/cmds/utils/spawn.ts +16 -0
- package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +75 -0
- package/src/cli/index.ts +1 -0
- package/src/cli/preload_crs.ts +7 -0
- package/src/cli/util.ts +310 -0
- package/src/cli/versioning.ts +13 -0
- package/src/examples/token.ts +77 -0
- package/src/examples/util.ts +42 -0
- package/src/index.ts +6 -0
- package/src/local-network/auth_registry.ts +19 -0
- package/src/local-network/banana_fpc.ts +89 -0
- package/src/local-network/index.ts +7 -0
- package/src/local-network/local-network.ts +254 -0
- package/src/local-network/sponsored_fpc.ts +26 -0
- package/src/mnemonic.ts +1 -0
- package/src/splash.ts +10 -0
- package/src/testing/cheat_codes.ts +48 -0
- package/src/testing/epoch_test_settler.ts +47 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/local-network.ts +96 -0
- package/src/testing/token_allowed_setup.ts +26 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TokenContractArtifact } from '@aztec-labs/noir-contracts.js/Token';
|
|
2
|
+
import { buildAllowedElement } from '@aztec-labs/p2p/msg_validators';
|
|
3
|
+
import { getContractClassFromArtifact } from '@aztec-labs/stdlib/contract';
|
|
4
|
+
/**
|
|
5
|
+
* Returns the allowlist entries needed for FPC-based fee payments, keyed by the contract class of
|
|
6
|
+
* the `artifact` actually deployed as the fee token (defaults to canonical Token). The setup-phase
|
|
7
|
+
* validator matches these entries by class id, so a test deploying the codegen'd TestToken as its
|
|
8
|
+
* fee vehicle must pass `TestTokenContract.artifact` here -- otherwise the FPC fee calls are matched
|
|
9
|
+
* against the wrong class and rejected. Test-only: FPC fee payment with custom tokens won't work on
|
|
10
|
+
* mainnet alpha.
|
|
11
|
+
*/ export async function getTokenAllowedSetupFunctions(artifact = TokenContractArtifact) {
|
|
12
|
+
const tokenClassId = (await getContractClassFromArtifact(artifact)).id;
|
|
13
|
+
const target = {
|
|
14
|
+
classId: tokenClassId
|
|
15
|
+
};
|
|
16
|
+
return Promise.all([
|
|
17
|
+
// needed for private transfers via FPC (transfer_to_public enqueues this)
|
|
18
|
+
buildAllowedElement(artifact, target, '_increase_public_balance', {
|
|
19
|
+
onlySelf: true
|
|
20
|
+
}),
|
|
21
|
+
// needed for public transfers via FPC (fee_entrypoint_public enqueues this)
|
|
22
|
+
buildAllowedElement(artifact, target, 'transfer_in_public')
|
|
23
|
+
]);
|
|
24
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aztec-labs/aztec",
|
|
3
|
+
"version": "6.0.0-nightly.20260829",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./dest/index.js",
|
|
7
|
+
"./testing": "./dest/testing/index.js"
|
|
8
|
+
},
|
|
9
|
+
"bin": "./scripts/aztec.sh",
|
|
10
|
+
"typedocOptions": {
|
|
11
|
+
"entryPoints": [
|
|
12
|
+
"./src/index.ts"
|
|
13
|
+
],
|
|
14
|
+
"name": "Aztec Packages",
|
|
15
|
+
"tsconfig": "./tsconfig.json"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "yarn clean && ../scripts/tsc.sh",
|
|
19
|
+
"start": "node --no-warnings ./dest/bin",
|
|
20
|
+
"start:debug": "node --inspect=0.0.0.0:9221 --no-warnings ./dest/bin",
|
|
21
|
+
"start:local-network": "ETHEREUM_HOSTS=http://0.0.0.0:8545/ && yarn start start --local-network",
|
|
22
|
+
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
23
|
+
"build:dev": "../scripts/tsc.sh --watch",
|
|
24
|
+
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}",
|
|
25
|
+
"run:example:token": "LOG_LEVEL='verbose' node ./dest/examples/token.js"
|
|
26
|
+
},
|
|
27
|
+
"inherits": [
|
|
28
|
+
"../package.common.json"
|
|
29
|
+
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@aztec-labs/accounts": "6.0.0-nightly.20260829",
|
|
32
|
+
"@aztec-labs/archiver": "6.0.0-nightly.20260829",
|
|
33
|
+
"@aztec-labs/aztec-node": "6.0.0-nightly.20260829",
|
|
34
|
+
"@aztec-labs/aztec.js": "6.0.0-nightly.20260829",
|
|
35
|
+
"@aztec-labs/blob-client": "6.0.0-nightly.20260829",
|
|
36
|
+
"@aztec-labs/bot": "6.0.0-nightly.20260829",
|
|
37
|
+
"@aztec-labs/builder": "6.0.0-nightly.20260829",
|
|
38
|
+
"@aztec-labs/cli": "6.0.0-nightly.20260829",
|
|
39
|
+
"@aztec-labs/constants": "6.0.0-nightly.20260829",
|
|
40
|
+
"@aztec-labs/ethereum": "6.0.0-nightly.20260829",
|
|
41
|
+
"@aztec-labs/foundation": "6.0.0-nightly.20260829",
|
|
42
|
+
"@aztec-labs/kv-store": "6.0.0-nightly.20260829",
|
|
43
|
+
"@aztec-labs/node-lib": "6.0.0-nightly.20260829",
|
|
44
|
+
"@aztec-labs/noir-contracts.js": "6.0.0-nightly.20260829",
|
|
45
|
+
"@aztec-labs/noir-protocol-circuits-types": "6.0.0-nightly.20260829",
|
|
46
|
+
"@aztec-labs/p2p": "6.0.0-nightly.20260829",
|
|
47
|
+
"@aztec-labs/protocol-contracts": "6.0.0-nightly.20260829",
|
|
48
|
+
"@aztec-labs/prover-client": "6.0.0-nightly.20260829",
|
|
49
|
+
"@aztec-labs/prover-node": "6.0.0-nightly.20260829",
|
|
50
|
+
"@aztec-labs/pxe": "6.0.0-nightly.20260829",
|
|
51
|
+
"@aztec-labs/sequencer-client": "6.0.0-nightly.20260829",
|
|
52
|
+
"@aztec-labs/standard-contracts": "6.0.0-nightly.20260829",
|
|
53
|
+
"@aztec-labs/stdlib": "6.0.0-nightly.20260829",
|
|
54
|
+
"@aztec-labs/telemetry-client": "6.0.0-nightly.20260829",
|
|
55
|
+
"@aztec-labs/txe": "6.0.0-nightly.20260829",
|
|
56
|
+
"@aztec-labs/validator-ha-signer": "6.0.0-nightly.20260829",
|
|
57
|
+
"@aztec-labs/wallets": "6.0.0-nightly.20260829",
|
|
58
|
+
"@aztec-labs/world-state": "6.0.0-nightly.20260829",
|
|
59
|
+
"@aztec/bb.js": "6.0.0-nightly.20260826",
|
|
60
|
+
"@iarna/toml": "^2.2.5",
|
|
61
|
+
"@types/chalk": "^2.2.0",
|
|
62
|
+
"abitype": "^0.8.11",
|
|
63
|
+
"chalk": "^5.3.0",
|
|
64
|
+
"commander": "^12.1.0",
|
|
65
|
+
"koa": "^2.16.1",
|
|
66
|
+
"koa-router": "^13.1.1",
|
|
67
|
+
"viem": "npm:@aztec/viem@2.38.2"
|
|
68
|
+
},
|
|
69
|
+
"files": [
|
|
70
|
+
"dest",
|
|
71
|
+
"scripts",
|
|
72
|
+
"src",
|
|
73
|
+
"!*.test.*"
|
|
74
|
+
],
|
|
75
|
+
"types": "./dest/index.d.ts",
|
|
76
|
+
"devDependencies": {
|
|
77
|
+
"@jest/globals": "^30.0.0",
|
|
78
|
+
"@types/jest": "^30.0.0",
|
|
79
|
+
"@types/koa": "^2.15.0",
|
|
80
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
81
|
+
"jest": "^30.0.0",
|
|
82
|
+
"ts-node": "^10.9.1",
|
|
83
|
+
"typescript": "^5.3.3"
|
|
84
|
+
},
|
|
85
|
+
"jest": {
|
|
86
|
+
"moduleNameMapper": {
|
|
87
|
+
"^(\\.{1,2}/.*)\\.[cm]?js$": "$1"
|
|
88
|
+
},
|
|
89
|
+
"testRegex": "./src/.*\\.test\\.(js|mjs|ts)$",
|
|
90
|
+
"rootDir": "./src",
|
|
91
|
+
"transform": {
|
|
92
|
+
"^.+\\.tsx?$": [
|
|
93
|
+
"@swc/jest",
|
|
94
|
+
{
|
|
95
|
+
"jsc": {
|
|
96
|
+
"parser": {
|
|
97
|
+
"syntax": "typescript",
|
|
98
|
+
"decorators": true
|
|
99
|
+
},
|
|
100
|
+
"transform": {
|
|
101
|
+
"decoratorVersion": "2022-03"
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
"extensionsToTreatAsEsm": [
|
|
108
|
+
".ts"
|
|
109
|
+
],
|
|
110
|
+
"reporters": [
|
|
111
|
+
"default"
|
|
112
|
+
],
|
|
113
|
+
"testTimeout": 120000,
|
|
114
|
+
"setupFiles": [
|
|
115
|
+
"../../foundation/src/jest/setup.mjs"
|
|
116
|
+
],
|
|
117
|
+
"testEnvironment": "../../foundation/src/jest/env.mjs",
|
|
118
|
+
"setupFilesAfterEnv": [
|
|
119
|
+
"../../foundation/src/jest/setupAfterEnv.mjs"
|
|
120
|
+
]
|
|
121
|
+
},
|
|
122
|
+
"engines": {
|
|
123
|
+
"node": ">=20.10"
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
# Creates a contract+test crate pair and adds them to an existing workspace.
|
|
5
|
+
# Usage: add_crate.sh <crate_name> <template>
|
|
6
|
+
# Must be called from a workspace root that already has Nargo.toml with [workspace].
|
|
7
|
+
|
|
8
|
+
crate_name=$1
|
|
9
|
+
template=$2
|
|
10
|
+
|
|
11
|
+
if [ -z "$crate_name" ]; then
|
|
12
|
+
echo "Error: crate name is required"
|
|
13
|
+
exit 1
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
if [[ "$crate_name" == *"/"* ]] || [[ "$crate_name" == *"\\"* ]]; then
|
|
17
|
+
echo "Error: crate name must not contain path separators"
|
|
18
|
+
exit 1
|
|
19
|
+
fi
|
|
20
|
+
|
|
21
|
+
contract_dir="${crate_name}_contract"
|
|
22
|
+
test_dir="${crate_name}_test"
|
|
23
|
+
|
|
24
|
+
if [ -d "$contract_dir" ]; then
|
|
25
|
+
echo "Error: directory '$contract_dir' already exists"
|
|
26
|
+
exit 1
|
|
27
|
+
fi
|
|
28
|
+
if [ -d "$test_dir" ]; then
|
|
29
|
+
echo "Error: directory '$test_dir' already exists"
|
|
30
|
+
exit 1
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
# Get the actual aztec version for the git tag.
|
|
34
|
+
AZTEC_VERSION=$(jq -r '.version' $(dirname $0)/../package.json)
|
|
35
|
+
TEMPLATE_DIR="$(dirname $0)/templates/$template"
|
|
36
|
+
|
|
37
|
+
# Copy template crates and substitute placeholders
|
|
38
|
+
cp -r "$TEMPLATE_DIR/contract" "$contract_dir"
|
|
39
|
+
cp -r "$TEMPLATE_DIR/test" "$test_dir"
|
|
40
|
+
# Use perl -i for portability across os.
|
|
41
|
+
find "$contract_dir" "$test_dir" -type f -exec \
|
|
42
|
+
perl -i -pe "s/__CRATE_NAME__/${crate_name}/g; s/__AZTEC_VERSION__/${AZTEC_VERSION}/g" {} +
|
|
43
|
+
|
|
44
|
+
# Add members to workspace Nargo.toml
|
|
45
|
+
if grep -q 'members\s*=\s*\[\s*\]' Nargo.toml; then
|
|
46
|
+
# Empty array: members = []
|
|
47
|
+
perl -i -pe "s|members\s*=\s*\[\s*\]|members = [\"${contract_dir}\", \"${test_dir}\"]|" Nargo.toml
|
|
48
|
+
else
|
|
49
|
+
# Non-empty array: add before closing ]
|
|
50
|
+
perl -i -pe "s|(members\s*=\s*\[.*)\]|\1, \"${contract_dir}\", \"${test_dir}\"]|" Nargo.toml
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
echo "Created crates '${contract_dir}' and '${test_dir}'"
|
package/scripts/aztec.sh
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
# Re-execute using correct version if we have an .aztecrc file.
|
|
5
|
+
if [ "${AZTEC_VERSIONED:-0}" -eq 0 ] && [ -f .aztecrc ] && command -v aztec-up &>/dev/null; then
|
|
6
|
+
env_setup=$(aztec-up env)
|
|
7
|
+
eval "$env_setup"
|
|
8
|
+
AZTEC_VERSIONED=1 exec aztec "$@"
|
|
9
|
+
fi
|
|
10
|
+
|
|
11
|
+
cmd=${1:-}
|
|
12
|
+
[ -n "$cmd" ] && shift
|
|
13
|
+
|
|
14
|
+
script_dir="$(dirname "$(realpath "$0")")"
|
|
15
|
+
|
|
16
|
+
function aztec {
|
|
17
|
+
export AZTEC_SHELL_WRAPPER=1
|
|
18
|
+
exec node --no-warnings $script_dir/../dest/bin/index.js "$@"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
case $cmd in
|
|
22
|
+
test)
|
|
23
|
+
# Attempt to compile, no-op if there are no changes
|
|
24
|
+
node --no-warnings "$script_dir/../dest/bin/index.js" compile
|
|
25
|
+
|
|
26
|
+
export LOG_LEVEL="${LOG_LEVEL:-"error;trace:^contract:"}"
|
|
27
|
+
aztec start --txe --port 8081 &
|
|
28
|
+
server_pid=$!
|
|
29
|
+
trap 'kill $server_pid &>/dev/null || true' EXIT
|
|
30
|
+
if ! command -v nc &>/dev/null; then
|
|
31
|
+
echo "Error: 'nc' (netcat) is required but not installed." >&2
|
|
32
|
+
exit 1
|
|
33
|
+
fi
|
|
34
|
+
while ! nc -z 127.0.0.1 8081 &>/dev/null; do sleep 0.2; done
|
|
35
|
+
export NARGO_FOREIGN_CALL_TIMEOUT=300000
|
|
36
|
+
nargo test --silence-warnings --oracle-resolver http://127.0.0.1:8081 "$@"
|
|
37
|
+
;;
|
|
38
|
+
start)
|
|
39
|
+
if [ "${1:-}" == "--local-network" ]; then
|
|
40
|
+
# TODO: Can these just be set in TS?
|
|
41
|
+
export ARCHIVER_POLLING_INTERVAL_MS=500
|
|
42
|
+
export P2P_BLOCK_CHECK_INTERVAL_MS=500
|
|
43
|
+
export SEQ_TX_POLLING_INTERVAL_MS=500
|
|
44
|
+
export WS_BLOCK_CHECK_INTERVAL_MS=500
|
|
45
|
+
export ARCHIVER_VIEM_POLLING_INTERVAL_MS=500
|
|
46
|
+
export TEST_ACCOUNTS=${TEST_ACCOUNTS:-true}
|
|
47
|
+
export LOG_LEVEL=${LOG_LEVEL:-info;silent:sequencer;verbose:debug_log}
|
|
48
|
+
export DEPLOY_AZTEC_CONTRACTS_SALT=${DEPLOY_AZTEC_CONTRACTS_SALT:-$RANDOM}
|
|
49
|
+
|
|
50
|
+
ANVIL_PORT=${ANVIL_PORT:-8545}
|
|
51
|
+
|
|
52
|
+
export L1_CHAIN_ID=${L1_CHAIN_ID:-31337}
|
|
53
|
+
export ETHEREUM_HOSTS=${ETHEREUM_HOSTS:-"http://127.0.0.1:${ANVIL_PORT}"}
|
|
54
|
+
|
|
55
|
+
anvil --version
|
|
56
|
+
anvil --silent --port "$ANVIL_PORT" &
|
|
57
|
+
anvil_pid=$!
|
|
58
|
+
trap 'kill $anvil_pid &>/dev/null' EXIT
|
|
59
|
+
fi
|
|
60
|
+
|
|
61
|
+
aztec start "$@"
|
|
62
|
+
;;
|
|
63
|
+
new|init)
|
|
64
|
+
$script_dir/${cmd}.sh "$@"
|
|
65
|
+
;;
|
|
66
|
+
flamegraph)
|
|
67
|
+
echo "Warning: 'aztec flamegraph' is deprecated. Use 'aztec profile flamegraph' instead." >&2
|
|
68
|
+
aztec profile flamegraph "$@"
|
|
69
|
+
;;
|
|
70
|
+
*)
|
|
71
|
+
aztec $cmd "$@"
|
|
72
|
+
;;
|
|
73
|
+
esac
|
package/scripts/init.sh
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
script_path=$(realpath $(dirname "$0"))
|
|
5
|
+
|
|
6
|
+
# Parse arguments
|
|
7
|
+
while [[ $# -gt 0 ]]; do
|
|
8
|
+
case $1 in
|
|
9
|
+
--help|-h)
|
|
10
|
+
cat << 'EOF'
|
|
11
|
+
Aztec Init - Create a new Aztec Noir project in the current directory
|
|
12
|
+
|
|
13
|
+
Usage: aztec init
|
|
14
|
+
|
|
15
|
+
Options:
|
|
16
|
+
-h, --help Print help
|
|
17
|
+
|
|
18
|
+
This command creates a new Aztec Noir project in the current directory with
|
|
19
|
+
a workspace containing a Counter contract example with tests. The Counter
|
|
20
|
+
demonstrates private state, private functions, and utility reads.
|
|
21
|
+
|
|
22
|
+
Use 'aztec new <name>' to create a blank contract project, or to add another
|
|
23
|
+
contract to an existing workspace.
|
|
24
|
+
EOF
|
|
25
|
+
exit 0
|
|
26
|
+
;;
|
|
27
|
+
*)
|
|
28
|
+
echo "Error: unexpected argument '$1'"
|
|
29
|
+
echo "Usage: aztec init"
|
|
30
|
+
echo "Run 'aztec init --help' for more information"
|
|
31
|
+
exit 1
|
|
32
|
+
;;
|
|
33
|
+
esac
|
|
34
|
+
done
|
|
35
|
+
|
|
36
|
+
package_name="$(basename $(pwd))"
|
|
37
|
+
|
|
38
|
+
echo "Initializing Aztec contract project..."
|
|
39
|
+
$script_path/setup_workspace.sh "$package_name" counter
|
package/scripts/new.sh
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
script_path=$(realpath $(dirname "$0"))
|
|
5
|
+
|
|
6
|
+
project_path=""
|
|
7
|
+
|
|
8
|
+
while [[ $# -gt 0 ]]; do
|
|
9
|
+
case $1 in
|
|
10
|
+
--help|-h)
|
|
11
|
+
cat << 'EOF'
|
|
12
|
+
Aztec New - Create a new Aztec Noir project or add a contract to an existing workspace
|
|
13
|
+
|
|
14
|
+
Usage: aztec new <NAME>
|
|
15
|
+
|
|
16
|
+
Arguments:
|
|
17
|
+
<NAME> The name for the new contract (also used as the directory name when
|
|
18
|
+
creating a new workspace)
|
|
19
|
+
|
|
20
|
+
Options:
|
|
21
|
+
-h, --help Print help
|
|
22
|
+
|
|
23
|
+
When run outside an existing workspace:
|
|
24
|
+
Creates a new directory with a workspace containing a contract crate and a
|
|
25
|
+
test crate, and automatically adds the Aztec.nr dependency to both.
|
|
26
|
+
|
|
27
|
+
When run inside an existing workspace (Nargo.toml with [workspace] exists):
|
|
28
|
+
Adds a new contract crate and test crate to the existing workspace.
|
|
29
|
+
EOF
|
|
30
|
+
exit 0
|
|
31
|
+
;;
|
|
32
|
+
-*)
|
|
33
|
+
echo "Error: unknown option '$1'"
|
|
34
|
+
echo "Usage: aztec new <NAME>"
|
|
35
|
+
echo "Run 'aztec new --help' for more information"
|
|
36
|
+
exit 1
|
|
37
|
+
;;
|
|
38
|
+
*)
|
|
39
|
+
if [ -n "$project_path" ]; then
|
|
40
|
+
echo "Error: unexpected argument '$1'"
|
|
41
|
+
echo "Usage: aztec new <NAME>"
|
|
42
|
+
echo "Run 'aztec new --help' for more information"
|
|
43
|
+
exit 1
|
|
44
|
+
fi
|
|
45
|
+
project_path=$1
|
|
46
|
+
shift
|
|
47
|
+
;;
|
|
48
|
+
esac
|
|
49
|
+
done
|
|
50
|
+
|
|
51
|
+
if [ -z "$project_path" ]; then
|
|
52
|
+
echo "Error: NAME argument is required"
|
|
53
|
+
echo "Usage: aztec new <NAME>"
|
|
54
|
+
echo "Run 'aztec new --help' for more information"
|
|
55
|
+
exit 1
|
|
56
|
+
fi
|
|
57
|
+
|
|
58
|
+
package_name="$(basename $project_path)"
|
|
59
|
+
|
|
60
|
+
# Validate that the name contains only valid Noir identifier characters
|
|
61
|
+
if ! [[ "$package_name" =~ ^[a-zA-Z][a-zA-Z0-9_]*$ ]]; then
|
|
62
|
+
echo "Error: '$package_name' is not a valid contract name"
|
|
63
|
+
echo "Name must start with a letter and contain only letters, digits, and underscores"
|
|
64
|
+
exit 1
|
|
65
|
+
fi
|
|
66
|
+
|
|
67
|
+
# Check if we're inside an existing workspace
|
|
68
|
+
if [ -f "Nargo.toml" ] && grep -q '\[workspace\]' Nargo.toml; then
|
|
69
|
+
# Add crate pair to existing workspace
|
|
70
|
+
echo "Adding contract '$package_name' to existing workspace..."
|
|
71
|
+
$script_path/add_crate.sh "$package_name" blank
|
|
72
|
+
else
|
|
73
|
+
# Create new workspace
|
|
74
|
+
if [ -d "$project_path" ] && [ "$(ls -A $project_path 2>/dev/null)" ]; then
|
|
75
|
+
echo "Error: $project_path already exists and is not empty"
|
|
76
|
+
exit 1
|
|
77
|
+
fi
|
|
78
|
+
|
|
79
|
+
echo "Creating new Aztec contract project at $project_path..."
|
|
80
|
+
mkdir -p "$project_path"
|
|
81
|
+
cd "$project_path"
|
|
82
|
+
$script_path/setup_workspace.sh "$package_name" blank
|
|
83
|
+
fi
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
# Creates an Aztec contract workspace with a contract crate and a test crate.
|
|
5
|
+
# Usage: setup_workspace.sh <package_name> <template>
|
|
6
|
+
# Must be called from the workspace root directory.
|
|
7
|
+
|
|
8
|
+
package_name=$1
|
|
9
|
+
template=$2
|
|
10
|
+
script_path=$(realpath $(dirname "$0"))
|
|
11
|
+
|
|
12
|
+
if [ -z "$package_name" ]; then
|
|
13
|
+
echo "Error: package name is required"
|
|
14
|
+
exit 1
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
if [ -f "Nargo.toml" ]; then
|
|
18
|
+
echo "Error: Nargo.toml already exists in the current directory."
|
|
19
|
+
echo "To add another contract crate to this workspace, use 'aztec new <name>' instead."
|
|
20
|
+
exit 1
|
|
21
|
+
fi
|
|
22
|
+
|
|
23
|
+
# Create workspace root Nargo.toml with empty members (add_crate.sh will populate)
|
|
24
|
+
cat > Nargo.toml << 'EOF'
|
|
25
|
+
[workspace]
|
|
26
|
+
members = []
|
|
27
|
+
EOF
|
|
28
|
+
|
|
29
|
+
# Create the first crate pair
|
|
30
|
+
$script_path/add_crate.sh "$package_name" "$template"
|
|
31
|
+
|
|
32
|
+
# Create README
|
|
33
|
+
cat > README.md << REOF
|
|
34
|
+
# ${package_name}
|
|
35
|
+
|
|
36
|
+
An Aztec Noir contract project.
|
|
37
|
+
|
|
38
|
+
## Compile
|
|
39
|
+
|
|
40
|
+
\`\`\`bash
|
|
41
|
+
aztec compile
|
|
42
|
+
\`\`\`
|
|
43
|
+
|
|
44
|
+
This compiles all contract crates and outputs artifacts to \`target/\`.
|
|
45
|
+
|
|
46
|
+
## Test
|
|
47
|
+
|
|
48
|
+
\`\`\`bash
|
|
49
|
+
aztec test
|
|
50
|
+
\`\`\`
|
|
51
|
+
|
|
52
|
+
This runs all tests in the workspace.
|
|
53
|
+
|
|
54
|
+
## Generate TypeScript bindings
|
|
55
|
+
|
|
56
|
+
\`\`\`bash
|
|
57
|
+
aztec codegen target -o src/artifacts
|
|
58
|
+
\`\`\`
|
|
59
|
+
|
|
60
|
+
This generates TypeScript contract artifacts from the compiled output in \`target/\` into \`src/artifacts/\`.
|
|
61
|
+
REOF
|
|
62
|
+
|
|
63
|
+
# Create .gitignore
|
|
64
|
+
cat > .gitignore << 'GEOF'
|
|
65
|
+
target/
|
|
66
|
+
codegenCache.json
|
|
67
|
+
GEOF
|
|
68
|
+
|
|
69
|
+
echo "Created Aztec contract workspace with crates '${package_name}_contract' and '${package_name}_test'"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
use aztec::test::helpers::test_environment::TestEnvironment;
|
|
2
|
+
use __CRATE_NAME___contract::Main;
|
|
3
|
+
|
|
4
|
+
#[test]
|
|
5
|
+
unconstrained fn test_constructor() {
|
|
6
|
+
let mut env = TestEnvironment::new();
|
|
7
|
+
let deployer = env.create_light_account();
|
|
8
|
+
|
|
9
|
+
let _contract_address = env.deploy("@__CRATE_NAME___contract/Main")
|
|
10
|
+
.with_private_initializer(deployer, Main::interface().constructor());
|
|
11
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "__CRATE_NAME___contract"
|
|
3
|
+
type = "contract"
|
|
4
|
+
|
|
5
|
+
[dependencies]
|
|
6
|
+
aztec = { git="https://github.com/AztecProtocol/aztec-nr", tag="v__AZTEC_VERSION__", directory="aztec" }
|
|
7
|
+
balance_set = { git="https://github.com/AztecProtocol/aztec-nr", tag="v__AZTEC_VERSION__", directory="balance-set" }
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
use aztec::macros::aztec;
|
|
2
|
+
|
|
3
|
+
#[aztec]
|
|
4
|
+
pub contract Counter {
|
|
5
|
+
use aztec::{
|
|
6
|
+
macros::{functions::{external, initializer}, storage::storage},
|
|
7
|
+
messages::delivery::MessageDelivery,
|
|
8
|
+
protocol::address::AztecAddress,
|
|
9
|
+
state_vars::Owned,
|
|
10
|
+
};
|
|
11
|
+
use balance_set::BalanceSet;
|
|
12
|
+
|
|
13
|
+
#[storage]
|
|
14
|
+
struct Storage<Context> {
|
|
15
|
+
// Each owner has their own counter, stored as private encrypted notes.
|
|
16
|
+
// Owned: dictates who will receive the encrypted notes.
|
|
17
|
+
// BalanceSet: manages the underlying notes, providing add/sub/balance_of.
|
|
18
|
+
counters: Owned<BalanceSet<Context>, Context>,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Sets the owner's counter to an initial value.
|
|
22
|
+
//
|
|
23
|
+
// #[external("private")]: executes on the user's device, inputs are hidden from everyone.
|
|
24
|
+
#[initializer]
|
|
25
|
+
#[external("private")]
|
|
26
|
+
fn constructor(initial_value: u128, owner: AztecAddress) {
|
|
27
|
+
// Delivers the note to the recipient onchain.
|
|
28
|
+
// Without delivery, the recipient can't find or decrypt the note.
|
|
29
|
+
self.storage.counters.at(owner).add(initial_value).deliver(
|
|
30
|
+
MessageDelivery::onchain_unconstrained(),
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Adds 1 to the owner's counter.
|
|
35
|
+
#[external("private")]
|
|
36
|
+
fn increment(owner: AztecAddress) {
|
|
37
|
+
self.storage.counters.at(owner).add(1).deliver(MessageDelivery::onchain_unconstrained());
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Returns the current value of the owner's counter.
|
|
41
|
+
//
|
|
42
|
+
// #[external("utility")]: runs off-chain, no transaction created, no cost.
|
|
43
|
+
// Only the owner can decrypt and read their own counter.
|
|
44
|
+
#[external("utility")]
|
|
45
|
+
unconstrained fn get_counter(owner: AztecAddress) -> u128 {
|
|
46
|
+
self.storage.counters.at(owner).balance_of()
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
use aztec::{protocol::address::AztecAddress, test::helpers::test_environment::TestEnvironment};
|
|
2
|
+
use __CRATE_NAME___contract::Counter;
|
|
3
|
+
|
|
4
|
+
unconstrained fn setup(initial_value: u128) -> (TestEnvironment, AztecAddress, AztecAddress) {
|
|
5
|
+
let mut env = TestEnvironment::new();
|
|
6
|
+
let owner = env.create_light_account();
|
|
7
|
+
|
|
8
|
+
let contract_address = env.deploy("@__CRATE_NAME___contract/Counter")
|
|
9
|
+
.with_private_initializer(owner, Counter::interface().constructor(initial_value, owner));
|
|
10
|
+
|
|
11
|
+
(env, contract_address, owner)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
#[test]
|
|
15
|
+
unconstrained fn test_constructor() {
|
|
16
|
+
let initial_value = 5;
|
|
17
|
+
let (env, contract_address, owner) = setup(initial_value);
|
|
18
|
+
|
|
19
|
+
let counter = env.execute_utility(Counter::at(contract_address).get_counter(owner));
|
|
20
|
+
assert_eq(counter, initial_value);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#[test]
|
|
24
|
+
unconstrained fn test_increment() {
|
|
25
|
+
let initial_value = 5;
|
|
26
|
+
let (mut env, contract_address, owner) = setup(initial_value);
|
|
27
|
+
|
|
28
|
+
env.call_private(owner, Counter::at(contract_address).increment(owner));
|
|
29
|
+
|
|
30
|
+
let counter = env.execute_utility(Counter::at(contract_address).get_counter(owner));
|
|
31
|
+
assert_eq(counter, initial_value + 1);
|
|
32
|
+
}
|