@aztec/aztec 0.0.1-commit.29c6b1a3 → 0.0.1-commit.2c0ee1788

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.
Files changed (148) hide show
  1. package/dest/bin/index.js +7 -3
  2. package/dest/cli/admin_api_key_store.d.ts +45 -0
  3. package/dest/cli/admin_api_key_store.d.ts.map +1 -0
  4. package/dest/cli/admin_api_key_store.js +98 -0
  5. package/dest/cli/aztec_start_action.d.ts +1 -1
  6. package/dest/cli/aztec_start_action.d.ts.map +1 -1
  7. package/dest/cli/aztec_start_action.js +73 -19
  8. package/dest/cli/aztec_start_options.d.ts +2 -2
  9. package/dest/cli/aztec_start_options.d.ts.map +1 -1
  10. package/dest/cli/aztec_start_options.js +38 -15
  11. package/dest/cli/cli.d.ts +1 -1
  12. package/dest/cli/cli.d.ts.map +1 -1
  13. package/dest/cli/cli.js +3 -4
  14. package/dest/cli/cmds/compile.d.ts +4 -0
  15. package/dest/cli/cmds/compile.d.ts.map +1 -0
  16. package/dest/cli/cmds/compile.js +155 -0
  17. package/dest/cli/cmds/profile.d.ts +4 -0
  18. package/dest/cli/cmds/profile.d.ts.map +1 -0
  19. package/dest/cli/cmds/profile.js +8 -0
  20. package/dest/cli/cmds/profile_flamegraph.d.ts +4 -0
  21. package/dest/cli/cmds/profile_flamegraph.d.ts.map +1 -0
  22. package/dest/cli/cmds/profile_flamegraph.js +52 -0
  23. package/dest/cli/cmds/profile_gates.d.ts +4 -0
  24. package/dest/cli/cmds/profile_gates.d.ts.map +1 -0
  25. package/dest/cli/cmds/profile_gates.js +76 -0
  26. package/dest/cli/cmds/profile_utils.d.ts +18 -0
  27. package/dest/cli/cmds/profile_utils.d.ts.map +1 -0
  28. package/dest/cli/cmds/profile_utils.js +50 -0
  29. package/dest/cli/cmds/standby.d.ts +32 -0
  30. package/dest/cli/cmds/standby.d.ts.map +1 -0
  31. package/dest/cli/cmds/standby.js +97 -0
  32. package/dest/cli/cmds/start_archiver.d.ts +2 -2
  33. package/dest/cli/cmds/start_archiver.d.ts.map +1 -1
  34. package/dest/cli/cmds/start_archiver.js +4 -2
  35. package/dest/cli/cmds/start_bot.d.ts +3 -3
  36. package/dest/cli/cmds/start_bot.d.ts.map +1 -1
  37. package/dest/cli/cmds/start_bot.js +9 -5
  38. package/dest/cli/cmds/start_node.d.ts +3 -2
  39. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  40. package/dest/cli/cmds/start_node.js +73 -31
  41. package/dest/cli/cmds/start_p2p_bootstrap.d.ts +2 -2
  42. package/dest/cli/cmds/start_p2p_bootstrap.d.ts.map +1 -1
  43. package/dest/cli/cmds/start_p2p_bootstrap.js +1 -2
  44. package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
  45. package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
  46. package/dest/cli/cmds/start_prover_agent.js +6 -18
  47. package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
  48. package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
  49. package/dest/cli/cmds/start_prover_broker.js +16 -10
  50. package/dest/cli/cmds/start_txe.d.ts +2 -2
  51. package/dest/cli/cmds/start_txe.d.ts.map +1 -1
  52. package/dest/cli/cmds/start_txe.js +4 -3
  53. package/dest/cli/cmds/utils/artifacts.d.ts +21 -0
  54. package/dest/cli/cmds/utils/artifacts.d.ts.map +1 -0
  55. package/dest/cli/cmds/utils/artifacts.js +24 -0
  56. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts +21 -0
  57. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts.map +1 -0
  58. package/dest/cli/cmds/utils/collect_crate_dirs.js +114 -0
  59. package/dest/cli/cmds/utils/needs_recompile.d.ts +10 -0
  60. package/dest/cli/cmds/utils/needs_recompile.d.ts.map +1 -0
  61. package/dest/cli/cmds/utils/needs_recompile.js +90 -0
  62. package/dest/cli/cmds/utils/spawn.d.ts +3 -0
  63. package/dest/cli/cmds/utils/spawn.d.ts.map +1 -0
  64. package/dest/cli/cmds/utils/spawn.js +16 -0
  65. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +4 -0
  66. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -0
  67. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +62 -0
  68. package/dest/cli/util.d.ts +7 -18
  69. package/dest/cli/util.d.ts.map +1 -1
  70. package/dest/cli/util.js +50 -86
  71. package/dest/examples/token.js +6 -6
  72. package/dest/local-network/banana_fpc.js +1 -1
  73. package/dest/local-network/local-network.d.ts +6 -5
  74. package/dest/local-network/local-network.d.ts.map +1 -1
  75. package/dest/local-network/local-network.js +53 -21
  76. package/dest/testing/anvil_test_watcher.d.ts +15 -3
  77. package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
  78. package/dest/testing/anvil_test_watcher.js +85 -22
  79. package/dest/testing/cheat_codes.d.ts +11 -15
  80. package/dest/testing/cheat_codes.d.ts.map +1 -1
  81. package/dest/testing/cheat_codes.js +34 -32
  82. package/dest/testing/epoch_test_settler.d.ts +1 -1
  83. package/dest/testing/epoch_test_settler.d.ts.map +1 -1
  84. package/dest/testing/epoch_test_settler.js +3 -4
  85. package/dest/testing/index.d.ts +3 -2
  86. package/dest/testing/index.d.ts.map +1 -1
  87. package/dest/testing/index.js +1 -0
  88. package/dest/testing/token_allowed_setup.d.ts +7 -0
  89. package/dest/testing/token_allowed_setup.d.ts.map +1 -0
  90. package/dest/testing/token_allowed_setup.js +20 -0
  91. package/package.json +34 -34
  92. package/scripts/add_crate.sh +52 -0
  93. package/scripts/aztec.sh +15 -5
  94. package/scripts/init.sh +23 -19
  95. package/scripts/new.sh +48 -24
  96. package/scripts/setup_workspace.sh +69 -0
  97. package/scripts/templates/blank/contract/Nargo.toml +6 -0
  98. package/scripts/templates/blank/contract/src/main.nr +10 -0
  99. package/scripts/templates/blank/test/Nargo.toml +7 -0
  100. package/scripts/templates/blank/test/src/lib.nr +11 -0
  101. package/scripts/templates/counter/contract/Nargo.toml +7 -0
  102. package/scripts/templates/counter/contract/src/main.nr +48 -0
  103. package/scripts/templates/counter/test/Nargo.toml +7 -0
  104. package/scripts/templates/counter/test/src/lib.nr +32 -0
  105. package/src/bin/index.ts +7 -3
  106. package/src/cli/admin_api_key_store.ts +128 -0
  107. package/src/cli/aztec_start_action.ts +66 -15
  108. package/src/cli/aztec_start_options.ts +47 -19
  109. package/src/cli/cli.ts +3 -4
  110. package/src/cli/cmds/compile.ts +178 -0
  111. package/src/cli/cmds/profile.ts +26 -0
  112. package/src/cli/cmds/profile_flamegraph.ts +64 -0
  113. package/src/cli/cmds/profile_gates.ts +84 -0
  114. package/src/cli/cmds/profile_utils.ts +58 -0
  115. package/src/cli/cmds/standby.ts +132 -0
  116. package/src/cli/cmds/start_archiver.ts +8 -2
  117. package/src/cli/cmds/start_bot.ts +8 -5
  118. package/src/cli/cmds/start_node.ts +83 -35
  119. package/src/cli/cmds/start_p2p_bootstrap.ts +2 -2
  120. package/src/cli/cmds/start_prover_agent.ts +7 -10
  121. package/src/cli/cmds/start_prover_broker.ts +21 -17
  122. package/src/cli/cmds/start_txe.ts +5 -3
  123. package/src/cli/cmds/utils/artifacts.ts +44 -0
  124. package/src/cli/cmds/utils/collect_crate_dirs.ts +118 -0
  125. package/src/cli/cmds/utils/needs_recompile.ts +98 -0
  126. package/src/cli/cmds/utils/spawn.ts +16 -0
  127. package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +77 -0
  128. package/src/cli/util.ts +57 -95
  129. package/src/examples/token.ts +8 -6
  130. package/src/local-network/banana_fpc.ts +1 -1
  131. package/src/local-network/local-network.ts +59 -22
  132. package/src/testing/anvil_test_watcher.ts +95 -20
  133. package/src/testing/cheat_codes.ts +42 -36
  134. package/src/testing/epoch_test_settler.ts +3 -4
  135. package/src/testing/index.ts +2 -1
  136. package/src/testing/token_allowed_setup.ts +19 -0
  137. package/dest/cli/cmds/start_prover_node.d.ts +0 -7
  138. package/dest/cli/cmds/start_prover_node.d.ts.map +0 -1
  139. package/dest/cli/cmds/start_prover_node.js +0 -108
  140. package/dest/cli/release_version.d.ts +0 -2
  141. package/dest/cli/release_version.d.ts.map +0 -1
  142. package/dest/cli/release_version.js +0 -14
  143. package/scripts/compile.sh +0 -44
  144. package/scripts/extract_function.js +0 -47
  145. package/scripts/flamegraph.sh +0 -59
  146. package/scripts/setup_project.sh +0 -31
  147. package/src/cli/cmds/start_prover_node.ts +0 -124
  148. package/src/cli/release_version.ts +0 -21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/aztec",
3
- "version": "0.0.1-commit.29c6b1a3",
3
+ "version": "0.0.1-commit.2c0ee1788",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
@@ -28,39 +28,39 @@
28
28
  "../package.common.json"
29
29
  ],
30
30
  "dependencies": {
31
- "@aztec/accounts": "0.0.1-commit.29c6b1a3",
32
- "@aztec/archiver": "0.0.1-commit.29c6b1a3",
33
- "@aztec/aztec-faucet": "0.0.1-commit.29c6b1a3",
34
- "@aztec/aztec-node": "0.0.1-commit.29c6b1a3",
35
- "@aztec/aztec.js": "0.0.1-commit.29c6b1a3",
36
- "@aztec/bb-prover": "0.0.1-commit.29c6b1a3",
37
- "@aztec/bb.js": "0.0.1-commit.29c6b1a3",
38
- "@aztec/blob-client": "0.0.1-commit.29c6b1a3",
39
- "@aztec/bot": "0.0.1-commit.29c6b1a3",
40
- "@aztec/builder": "0.0.1-commit.29c6b1a3",
41
- "@aztec/cli": "0.0.1-commit.29c6b1a3",
42
- "@aztec/constants": "0.0.1-commit.29c6b1a3",
43
- "@aztec/entrypoints": "0.0.1-commit.29c6b1a3",
44
- "@aztec/ethereum": "0.0.1-commit.29c6b1a3",
45
- "@aztec/foundation": "0.0.1-commit.29c6b1a3",
46
- "@aztec/kv-store": "0.0.1-commit.29c6b1a3",
47
- "@aztec/l1-artifacts": "0.0.1-commit.29c6b1a3",
48
- "@aztec/node-lib": "0.0.1-commit.29c6b1a3",
49
- "@aztec/noir-contracts.js": "0.0.1-commit.29c6b1a3",
50
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.29c6b1a3",
51
- "@aztec/p2p": "0.0.1-commit.29c6b1a3",
52
- "@aztec/p2p-bootstrap": "0.0.1-commit.29c6b1a3",
53
- "@aztec/protocol-contracts": "0.0.1-commit.29c6b1a3",
54
- "@aztec/prover-client": "0.0.1-commit.29c6b1a3",
55
- "@aztec/prover-node": "0.0.1-commit.29c6b1a3",
56
- "@aztec/pxe": "0.0.1-commit.29c6b1a3",
57
- "@aztec/sequencer-client": "0.0.1-commit.29c6b1a3",
58
- "@aztec/stdlib": "0.0.1-commit.29c6b1a3",
59
- "@aztec/telemetry-client": "0.0.1-commit.29c6b1a3",
60
- "@aztec/test-wallet": "0.0.1-commit.29c6b1a3",
61
- "@aztec/txe": "0.0.1-commit.29c6b1a3",
62
- "@aztec/validator-ha-signer": "0.0.1-commit.29c6b1a3",
63
- "@aztec/world-state": "0.0.1-commit.29c6b1a3",
31
+ "@aztec/accounts": "0.0.1-commit.2c0ee1788",
32
+ "@aztec/archiver": "0.0.1-commit.2c0ee1788",
33
+ "@aztec/aztec-node": "0.0.1-commit.2c0ee1788",
34
+ "@aztec/aztec.js": "0.0.1-commit.2c0ee1788",
35
+ "@aztec/bb-prover": "0.0.1-commit.2c0ee1788",
36
+ "@aztec/bb.js": "0.0.1-commit.2c0ee1788",
37
+ "@aztec/blob-client": "0.0.1-commit.2c0ee1788",
38
+ "@aztec/bot": "0.0.1-commit.2c0ee1788",
39
+ "@aztec/builder": "0.0.1-commit.2c0ee1788",
40
+ "@aztec/cli": "0.0.1-commit.2c0ee1788",
41
+ "@aztec/constants": "0.0.1-commit.2c0ee1788",
42
+ "@aztec/entrypoints": "0.0.1-commit.2c0ee1788",
43
+ "@aztec/ethereum": "0.0.1-commit.2c0ee1788",
44
+ "@aztec/foundation": "0.0.1-commit.2c0ee1788",
45
+ "@aztec/kv-store": "0.0.1-commit.2c0ee1788",
46
+ "@aztec/l1-artifacts": "0.0.1-commit.2c0ee1788",
47
+ "@aztec/node-lib": "0.0.1-commit.2c0ee1788",
48
+ "@aztec/noir-contracts.js": "0.0.1-commit.2c0ee1788",
49
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.2c0ee1788",
50
+ "@aztec/p2p": "0.0.1-commit.2c0ee1788",
51
+ "@aztec/p2p-bootstrap": "0.0.1-commit.2c0ee1788",
52
+ "@aztec/protocol-contracts": "0.0.1-commit.2c0ee1788",
53
+ "@aztec/prover-client": "0.0.1-commit.2c0ee1788",
54
+ "@aztec/prover-node": "0.0.1-commit.2c0ee1788",
55
+ "@aztec/pxe": "0.0.1-commit.2c0ee1788",
56
+ "@aztec/sequencer-client": "0.0.1-commit.2c0ee1788",
57
+ "@aztec/stdlib": "0.0.1-commit.2c0ee1788",
58
+ "@aztec/telemetry-client": "0.0.1-commit.2c0ee1788",
59
+ "@aztec/txe": "0.0.1-commit.2c0ee1788",
60
+ "@aztec/validator-ha-signer": "0.0.1-commit.2c0ee1788",
61
+ "@aztec/wallets": "0.0.1-commit.2c0ee1788",
62
+ "@aztec/world-state": "0.0.1-commit.2c0ee1788",
63
+ "@iarna/toml": "^2.2.5",
64
64
  "@types/chalk": "^2.2.0",
65
65
  "abitype": "^0.8.11",
66
66
  "chalk": "^5.3.0",
@@ -0,0 +1,52 @@
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
+ find "$contract_dir" "$test_dir" -type f -exec \
41
+ sed -i -e "s/__CRATE_NAME__/${crate_name}/g" -e "s/__AZTEC_VERSION__/${AZTEC_VERSION}/g" {} +
42
+
43
+ # Add members to workspace Nargo.toml
44
+ if grep -q 'members\s*=\s*\[\s*\]' Nargo.toml; then
45
+ # Empty array: members = []
46
+ sed -i "s|members\s*=\s*\[\s*\]|members = [\"${contract_dir}\", \"${test_dir}\"]|" Nargo.toml
47
+ else
48
+ # Non-empty array: add before closing ]
49
+ sed -i "s|\(members\s*=\s*\[.*\)\]|\1, \"${contract_dir}\", \"${test_dir}\"]|" Nargo.toml
50
+ fi
51
+
52
+ echo "Created crates '${contract_dir}' and '${test_dir}'"
package/scripts/aztec.sh CHANGED
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
- shopt -s inherit_errexit
4
3
 
5
4
  # Re-execute using correct version if we have an .aztecrc file.
6
5
  if [ "${AZTEC_VERSIONED:-0}" -eq 0 ] && [ -f .aztecrc ] && command -v aztec-up &>/dev/null; then
@@ -21,13 +20,20 @@ function aztec {
21
20
 
22
21
  case $cmd in
23
22
  test)
24
- export LOG_LEVEL="${LOG_LEVEL:-error}"
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:"}"
25
27
  aztec start --txe --port 8081 &
26
28
  server_pid=$!
27
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
28
34
  while ! nc -z 127.0.0.1 8081 &>/dev/null; do sleep 0.2; done
29
35
  export NARGO_FOREIGN_CALL_TIMEOUT=300000
30
- nargo test --silence-warnings --oracle-resolver http://127.0.0.1:8081 "$@"
36
+ nargo test --silence-warnings --oracle-resolver http://127.0.0.1:8081 --test-threads 16 "$@"
31
37
  ;;
32
38
  start)
33
39
  if [ "${1:-}" == "--local-network" ]; then
@@ -47,16 +53,20 @@ case $cmd in
47
53
  export ETHEREUM_HOSTS=${ETHEREUM_HOSTS:-"http://127.0.0.1:${ANVIL_PORT}"}
48
54
 
49
55
  anvil --version
50
- anvil --silent &
56
+ anvil --silent --port "$ANVIL_PORT" &
51
57
  anvil_pid=$!
52
58
  trap 'kill $anvil_pid &>/dev/null' EXIT
53
59
  fi
54
60
 
55
61
  aztec start "$@"
56
62
  ;;
57
- compile|new|init|flamegraph)
63
+ new|init)
58
64
  $script_dir/${cmd}.sh "$@"
59
65
  ;;
66
+ flamegraph)
67
+ echo "Warning: 'aztec flamegraph' is deprecated. Use 'aztec profile flamegraph' instead." >&2
68
+ aztec profile flamegraph "$@"
69
+ ;;
60
70
  *)
61
71
  aztec $cmd "$@"
62
72
  ;;
package/scripts/init.sh CHANGED
@@ -1,35 +1,39 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
- NARGO=${NARGO:-nargo}
5
4
  script_path=$(realpath $(dirname "$0"))
6
5
 
7
- for arg in "$@"; do
8
- if [ "$arg" == "--help" ] || [ "$arg" == "-h" ]; then
9
- cat << 'EOF'
6
+ # Parse arguments
7
+ while [[ $# -gt 0 ]]; do
8
+ case $1 in
9
+ --help|-h)
10
+ cat << 'EOF'
10
11
  Aztec Init - Create a new Aztec Noir project in the current directory
11
12
 
12
- Usage: aztec init [OPTIONS]
13
+ Usage: aztec init
13
14
 
14
15
  Options:
15
- --name <NAME> Name of the package [default: current directory name]
16
- --lib Use a library template
17
16
  -h, --help Print help
18
17
 
19
- This command creates a new Aztec Noir project in the current directory using nargo
20
- and automatically adds the Aztec.nr dependency to your Nargo.toml file.
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
21
 
22
+ Use 'aztec new <name>' to create a blank contract project, or to add another
23
+ contract to an existing workspace.
22
24
  EOF
23
- exit 0
24
- fi
25
- if [ "$arg" == "--lib" ]; then
26
- is_contract=0
27
- fi
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
28
34
  done
29
35
 
30
- echo "Initializing Noir project..."
31
- $NARGO init "$@"
36
+ package_name="$(basename $(pwd))"
32
37
 
33
- if [ "${is_contract:-1}" -eq 1 ]; then
34
- $script_path/setup_project.sh
35
- fi
38
+ echo "Initializing Aztec contract project..."
39
+ $script_path/setup_workspace.sh "$package_name" counter
package/scripts/new.sh CHANGED
@@ -1,59 +1,83 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
- NARGO=${NARGO:-nargo}
5
4
  script_path=$(realpath $(dirname "$0"))
6
5
 
7
- type_arg="--contract"
6
+ project_path=""
8
7
 
9
8
  while [[ $# -gt 0 ]]; do
10
9
  case $1 in
11
10
  --help|-h)
12
11
  cat << 'EOF'
13
- Aztec New - Create a new Aztec Noir project in a new directory
12
+ Aztec New - Create a new Aztec Noir project or add a contract to an existing workspace
14
13
 
15
- Usage: aztec new [OPTIONS] <PATH>
14
+ Usage: aztec new <NAME>
16
15
 
17
16
  Arguments:
18
- <PATH> The path to save the new project
17
+ <NAME> The name for the new contract (also used as the directory name when
18
+ creating a new workspace)
19
19
 
20
20
  Options:
21
- --name <NAME> Name of the package [default: package directory name]
22
- --lib Create a library template instead of a contract
23
21
  -h, --help Print help
24
22
 
25
- This command creates a new Aztec Noir project using nargo and automatically
26
- adds the Aztec.nr dependency to your Nargo.toml file.
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.
27
29
  EOF
28
30
  exit 0
29
31
  ;;
30
- --lib)
31
- type_arg="--lib"
32
- shift
33
- ;;
34
- --name)
35
- name_arg="--name $2"
36
- shift 2
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
37
  ;;
38
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
39
45
  project_path=$1
40
46
  shift
41
- break
42
47
  ;;
43
48
  esac
44
49
  done
45
50
 
46
51
  if [ -z "$project_path" ]; then
47
- echo "Error: PATH argument is required"
48
- echo "Usage: aztec new [OPTIONS] <PATH>"
52
+ echo "Error: NAME argument is required"
53
+ echo "Usage: aztec new <NAME>"
49
54
  echo "Run 'aztec new --help' for more information"
50
55
  exit 1
51
56
  fi
52
57
 
53
- echo "Creating new Noir project at $project_path..."
54
- $NARGO new $type_arg ${name_arg:-} $project_path
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
55
78
 
56
- if [ "$type_arg" == "--contract" ]; then
57
- cd $project_path
58
- $script_path/setup_project.sh
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
59
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,6 @@
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" }
@@ -0,0 +1,10 @@
1
+ use aztec::macros::aztec;
2
+
3
+ #[aztec]
4
+ pub contract Main {
5
+ use aztec::macros::functions::{external, initializer};
6
+
7
+ #[initializer]
8
+ #[external("private")]
9
+ fn constructor() {}
10
+ }
@@ -0,0 +1,7 @@
1
+ [package]
2
+ name = "__CRATE_NAME___test"
3
+ type = "lib"
4
+
5
+ [dependencies]
6
+ aztec = { git="https://github.com/AztecProtocol/aztec-nr", tag="v__AZTEC_VERSION__", directory="aztec" }
7
+ __CRATE_NAME___contract = { path = "../__CRATE_NAME___contract" }
@@ -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::message_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 with provable correctness.
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_CONSTRAINED,
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_CONSTRAINED);
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,7 @@
1
+ [package]
2
+ name = "__CRATE_NAME___test"
3
+ type = "lib"
4
+
5
+ [dependencies]
6
+ aztec = { git="https://github.com/AztecProtocol/aztec-nr", tag="v__AZTEC_VERSION__", directory="aztec" }
7
+ __CRATE_NAME___contract = { path = "../__CRATE_NAME___contract" }
@@ -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
+ }
package/src/bin/index.ts CHANGED
@@ -11,12 +11,14 @@ import { injectCommands as injectMiscCommands } from '@aztec/cli/misc';
11
11
  import { injectCommands as injectValidatorKeysCommands } from '@aztec/cli/validator_keys';
12
12
  import { getActiveNetworkName } from '@aztec/foundation/config';
13
13
  import { createConsoleLogger, createLogger } from '@aztec/foundation/log';
14
+ import { getPackageVersion } from '@aztec/stdlib/update-checker';
14
15
 
15
16
  import { Command } from 'commander';
16
17
 
18
+ import { injectCompileCommand } from '../cli/cmds/compile.js';
17
19
  import { injectMigrateCommand } from '../cli/cmds/migrate_ha_db.js';
20
+ import { injectProfileCommand } from '../cli/cmds/profile.js';
18
21
  import { injectAztecCommands } from '../cli/index.js';
19
- import { getCliVersion } from '../cli/release_version.js';
20
22
 
21
23
  const NETWORK_FLAG = 'network';
22
24
 
@@ -45,9 +47,9 @@ async function main() {
45
47
  await enrichEnvironmentWithNetworkConfig(networkName);
46
48
  enrichEnvironmentWithChainName(networkName);
47
49
 
48
- const cliVersion = getCliVersion();
50
+ const cliVersion = getPackageVersion() ?? 'unknown';
49
51
  let program = new Command('aztec');
50
- program.description('Aztec command line interface').version(cliVersion);
52
+ program.description('Aztec command line interface').version(cliVersion).enablePositionalOptions();
51
53
  program = injectAztecCommands(program, userLog, debugLogger);
52
54
  program = injectBuilderCommands(program);
53
55
  program = injectContractCommands(program, userLog, debugLogger);
@@ -56,6 +58,8 @@ async function main() {
56
58
  program = injectAztecNodeCommands(program, userLog, debugLogger);
57
59
  program = injectMiscCommands(program, userLog);
58
60
  program = injectValidatorKeysCommands(program, userLog);
61
+ program = injectCompileCommand(program, userLog);
62
+ program = injectProfileCommand(program, userLog);
59
63
  program = injectMigrateCommand(program, userLog);
60
64
 
61
65
  await program.parseAsync(process.argv);