@aztec/aztec 0.0.1-commit.85d7d01 → 0.0.1-commit.8655d4a
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/dest/bin/index.js +2 -2
- package/dest/cli/aztec_start_action.d.ts +1 -1
- package/dest/cli/aztec_start_action.d.ts.map +1 -1
- package/dest/cli/aztec_start_action.js +31 -14
- package/dest/cli/aztec_start_options.d.ts +2 -2
- package/dest/cli/aztec_start_options.d.ts.map +1 -1
- package/dest/cli/aztec_start_options.js +16 -17
- package/dest/cli/cli.js +3 -3
- package/dest/cli/cmds/compile.d.ts +1 -1
- package/dest/cli/cmds/compile.d.ts.map +1 -1
- package/dest/cli/cmds/compile.js +15 -9
- package/dest/cli/cmds/profile.d.ts +1 -1
- package/dest/cli/cmds/profile.d.ts.map +1 -1
- package/dest/cli/cmds/profile.js +1 -1
- package/dest/cli/cmds/profile_flamegraph.d.ts +1 -1
- package/dest/cli/cmds/profile_flamegraph.d.ts.map +1 -1
- package/dest/cli/cmds/profile_flamegraph.js +2 -1
- package/dest/cli/cmds/profile_gates.d.ts +2 -2
- package/dest/cli/cmds/profile_gates.d.ts.map +1 -1
- package/dest/cli/cmds/profile_gates.js +23 -4
- package/dest/cli/cmds/standby.d.ts +30 -0
- package/dest/cli/cmds/standby.d.ts.map +1 -0
- package/dest/cli/cmds/standby.js +97 -0
- package/dest/cli/cmds/start_bot.d.ts +1 -1
- package/dest/cli/cmds/start_bot.d.ts.map +1 -1
- package/dest/cli/cmds/start_bot.js +3 -3
- package/dest/cli/cmds/start_node.d.ts +3 -2
- package/dest/cli/cmds/start_node.d.ts.map +1 -1
- package/dest/cli/cmds/start_node.js +28 -40
- package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
- package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_agent.js +5 -17
- package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
- package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_broker.js +22 -13
- package/dest/cli/cmds/start_txe.d.ts +2 -2
- package/dest/cli/cmds/start_txe.d.ts.map +1 -1
- package/dest/cli/cmds/start_txe.js +6 -5
- 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/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/util.d.ts +3 -5
- package/dest/cli/util.d.ts.map +1 -1
- package/dest/cli/util.js +43 -82
- package/dest/examples/token.js +4 -4
- package/dest/local-network/auth_registry.d.ts +4 -0
- package/dest/local-network/auth_registry.d.ts.map +1 -0
- package/dest/local-network/auth_registry.js +15 -0
- package/dest/local-network/banana_fpc.d.ts +1 -1
- package/dest/local-network/banana_fpc.d.ts.map +1 -1
- package/dest/local-network/banana_fpc.js +9 -7
- package/dest/local-network/local-network.d.ts +5 -28
- package/dest/local-network/local-network.d.ts.map +1 -1
- package/dest/local-network/local-network.js +44 -17
- package/dest/testing/anvil_test_watcher.d.ts +15 -3
- package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
- package/dest/testing/anvil_test_watcher.js +68 -14
- package/dest/testing/cheat_codes.d.ts +18 -17
- package/dest/testing/cheat_codes.d.ts.map +1 -1
- package/dest/testing/cheat_codes.js +72 -36
- package/dest/testing/epoch_test_settler.d.ts +1 -1
- package/dest/testing/epoch_test_settler.d.ts.map +1 -1
- package/dest/testing/epoch_test_settler.js +9 -8
- package/dest/testing/index.d.ts +3 -2
- package/dest/testing/index.d.ts.map +1 -1
- package/dest/testing/index.js +1 -0
- package/dest/testing/token_allowed_setup.d.ts +7 -0
- package/dest/testing/token_allowed_setup.d.ts.map +1 -0
- package/dest/testing/token_allowed_setup.js +20 -0
- package/package.json +35 -34
- package/scripts/add_crate.sh +53 -0
- package/scripts/aztec.sh +9 -2
- package/scripts/init.sh +18 -24
- package/scripts/new.sh +45 -22
- package/scripts/setup_workspace.sh +12 -67
- 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 +2 -2
- package/src/cli/aztec_start_action.ts +20 -14
- package/src/cli/aztec_start_options.ts +23 -25
- package/src/cli/cli.ts +3 -3
- package/src/cli/cmds/compile.ts +18 -10
- package/src/cli/cmds/profile.ts +2 -1
- package/src/cli/cmds/profile_flamegraph.ts +2 -1
- package/src/cli/cmds/profile_gates.ts +22 -5
- package/src/cli/cmds/standby.ts +132 -0
- package/src/cli/cmds/start_bot.ts +3 -5
- package/src/cli/cmds/start_node.ts +43 -39
- package/src/cli/cmds/start_prover_agent.ts +5 -8
- package/src/cli/cmds/start_prover_broker.ts +23 -24
- package/src/cli/cmds/start_txe.ts +7 -5
- 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/warn_if_aztec_version_mismatch.ts +76 -0
- package/src/cli/util.ts +47 -80
- package/src/examples/token.ts +6 -4
- package/src/local-network/auth_registry.ts +14 -0
- package/src/local-network/banana_fpc.ts +5 -8
- package/src/local-network/local-network.ts +43 -14
- package/src/testing/anvil_test_watcher.ts +76 -13
- package/src/testing/cheat_codes.ts +92 -39
- package/src/testing/epoch_test_settler.ts +6 -8
- package/src/testing/index.ts +2 -1
- package/src/testing/token_allowed_setup.ts +19 -0
- package/dest/cli/cmds/start_archiver.d.ts +0 -9
- package/dest/cli/cmds/start_archiver.d.ts.map +0 -1
- package/dest/cli/cmds/start_archiver.js +0 -48
- package/dest/cli/release_version.d.ts +0 -2
- package/dest/cli/release_version.d.ts.map +0 -1
- package/dest/cli/release_version.js +0 -14
- package/src/cli/cmds/start_archiver.ts +0 -50
- package/src/cli/release_version.ts +0 -21
|
@@ -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
CHANGED
|
@@ -20,13 +20,20 @@ function aztec {
|
|
|
20
20
|
|
|
21
21
|
case $cmd in
|
|
22
22
|
test)
|
|
23
|
-
|
|
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:"}"
|
|
24
27
|
aztec start --txe --port 8081 &
|
|
25
28
|
server_pid=$!
|
|
26
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
|
|
27
34
|
while ! nc -z 127.0.0.1 8081 &>/dev/null; do sleep 0.2; done
|
|
28
35
|
export NARGO_FOREIGN_CALL_TIMEOUT=300000
|
|
29
|
-
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 "$@"
|
|
30
37
|
;;
|
|
31
38
|
start)
|
|
32
39
|
if [ "${1:-}" == "--local-network" ]; then
|
package/scripts/init.sh
CHANGED
|
@@ -3,43 +3,37 @@ set -euo pipefail
|
|
|
3
3
|
|
|
4
4
|
script_path=$(realpath $(dirname "$0"))
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
cat << 'EOF'
|
|
6
|
+
# Parse arguments
|
|
7
|
+
while [[ $# -gt 0 ]]; do
|
|
8
|
+
case $1 in
|
|
9
|
+
--help|-h)
|
|
10
|
+
cat << 'EOF'
|
|
12
11
|
Aztec Init - Create a new Aztec Noir project in the current directory
|
|
13
12
|
|
|
14
|
-
Usage: aztec init
|
|
13
|
+
Usage: aztec init
|
|
15
14
|
|
|
16
15
|
Options:
|
|
17
|
-
--name <NAME> Name of the package [default: current directory name]
|
|
18
16
|
-h, --help Print help
|
|
19
17
|
|
|
20
18
|
This command creates a new Aztec Noir project in the current directory with
|
|
21
|
-
a workspace containing a contract
|
|
22
|
-
|
|
23
|
-
EOF
|
|
24
|
-
exit 0
|
|
25
|
-
fi
|
|
26
|
-
done
|
|
19
|
+
a workspace containing a Counter contract example with tests. The Counter
|
|
20
|
+
demonstrates private state, private functions, and utility reads.
|
|
27
21
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
name_arg="$2"
|
|
33
|
-
shift 2
|
|
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
|
|
34
26
|
;;
|
|
35
27
|
*)
|
|
36
|
-
|
|
28
|
+
echo "Error: unexpected argument '$1'"
|
|
29
|
+
echo "Usage: aztec init"
|
|
30
|
+
echo "Run 'aztec init --help' for more information"
|
|
31
|
+
exit 1
|
|
37
32
|
;;
|
|
38
33
|
esac
|
|
39
34
|
done
|
|
40
35
|
|
|
41
|
-
|
|
42
|
-
package_name="${name_arg:-$(basename $(pwd))}"
|
|
36
|
+
package_name="$(basename $(pwd))"
|
|
43
37
|
|
|
44
38
|
echo "Initializing Aztec contract project..."
|
|
45
|
-
$script_path/setup_workspace.sh "$package_name"
|
|
39
|
+
$script_path/setup_workspace.sh "$package_name" counter
|
package/scripts/new.sh
CHANGED
|
@@ -3,58 +3,81 @@ set -euo pipefail
|
|
|
3
3
|
|
|
4
4
|
script_path=$(realpath $(dirname "$0"))
|
|
5
5
|
|
|
6
|
-
name_arg=""
|
|
7
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
|
|
12
|
+
Aztec New - Create a new Aztec Noir project or add a contract to an existing workspace
|
|
14
13
|
|
|
15
|
-
Usage: aztec new
|
|
14
|
+
Usage: aztec new <NAME>
|
|
16
15
|
|
|
17
16
|
Arguments:
|
|
18
|
-
<
|
|
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
21
|
-h, --help Print help
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
a
|
|
26
|
-
dependency to both.
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
|
33
37
|
;;
|
|
34
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
|
|
35
45
|
project_path=$1
|
|
36
46
|
shift
|
|
37
|
-
break
|
|
38
47
|
;;
|
|
39
48
|
esac
|
|
40
49
|
done
|
|
41
50
|
|
|
42
51
|
if [ -z "$project_path" ]; then
|
|
43
|
-
echo "Error:
|
|
44
|
-
echo "Usage: aztec new
|
|
52
|
+
echo "Error: NAME argument is required"
|
|
53
|
+
echo "Usage: aztec new <NAME>"
|
|
45
54
|
echo "Run 'aztec new --help' for more information"
|
|
46
55
|
exit 1
|
|
47
56
|
fi
|
|
48
57
|
|
|
49
|
-
|
|
50
|
-
|
|
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"
|
|
51
64
|
exit 1
|
|
52
65
|
fi
|
|
53
66
|
|
|
54
|
-
#
|
|
55
|
-
|
|
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
|
|
56
78
|
|
|
57
|
-
echo "Creating new Aztec contract project at $project_path..."
|
|
58
|
-
mkdir -p "$project_path"
|
|
59
|
-
cd "$project_path"
|
|
60
|
-
$script_path/setup_workspace.sh "$package_name"
|
|
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
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
set -euo pipefail
|
|
3
3
|
|
|
4
4
|
# Creates an Aztec contract workspace with a contract crate and a test crate.
|
|
5
|
-
# Usage: setup_workspace.sh <package_name>
|
|
5
|
+
# Usage: setup_workspace.sh <package_name> <template>
|
|
6
6
|
# Must be called from the workspace root directory.
|
|
7
7
|
|
|
8
8
|
package_name=$1
|
|
9
|
+
template=$2
|
|
10
|
+
script_path=$(realpath $(dirname "$0"))
|
|
9
11
|
|
|
10
12
|
if [ -z "$package_name" ]; then
|
|
11
13
|
echo "Error: package name is required"
|
|
@@ -13,76 +15,19 @@ if [ -z "$package_name" ]; then
|
|
|
13
15
|
fi
|
|
14
16
|
|
|
15
17
|
if [ -f "Nargo.toml" ]; then
|
|
16
|
-
echo "Error: Nargo.toml already exists in the current directory"
|
|
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."
|
|
17
20
|
exit 1
|
|
18
21
|
fi
|
|
19
22
|
|
|
20
|
-
#
|
|
21
|
-
AZTEC_VERSION=$(jq -r '.version' $(dirname $0)/../package.json)
|
|
22
|
-
|
|
23
|
-
# Create workspace root Nargo.toml
|
|
23
|
+
# Create workspace root Nargo.toml with empty members (add_crate.sh will populate)
|
|
24
24
|
cat > Nargo.toml << 'EOF'
|
|
25
25
|
[workspace]
|
|
26
|
-
members = [
|
|
27
|
-
EOF
|
|
28
|
-
|
|
29
|
-
# Create contract crate
|
|
30
|
-
mkdir -p contract/src
|
|
31
|
-
cat > contract/Nargo.toml << CEOF
|
|
32
|
-
[package]
|
|
33
|
-
name = "${package_name}"
|
|
34
|
-
type = "contract"
|
|
35
|
-
|
|
36
|
-
[dependencies]
|
|
37
|
-
aztec = { git="https://github.com/AztecProtocol/aztec-nr", tag="v${AZTEC_VERSION}", directory="aztec" }
|
|
38
|
-
CEOF
|
|
39
|
-
|
|
40
|
-
cat > contract/src/main.nr << 'EOF'
|
|
41
|
-
use aztec::macros::aztec;
|
|
42
|
-
|
|
43
|
-
#[aztec]
|
|
44
|
-
pub contract Main {
|
|
45
|
-
use aztec::macros::functions::{external, initializer};
|
|
46
|
-
|
|
47
|
-
#[initializer]
|
|
48
|
-
#[external("private")]
|
|
49
|
-
fn constructor() {}
|
|
50
|
-
}
|
|
26
|
+
members = []
|
|
51
27
|
EOF
|
|
52
28
|
|
|
53
|
-
# Create
|
|
54
|
-
|
|
55
|
-
cat > test/Nargo.toml << TEOF
|
|
56
|
-
[package]
|
|
57
|
-
name = "${package_name}_test"
|
|
58
|
-
type = "lib"
|
|
59
|
-
|
|
60
|
-
[dependencies]
|
|
61
|
-
aztec = { git="https://github.com/AztecProtocol/aztec-nr", tag="v${AZTEC_VERSION}", directory="aztec" }
|
|
62
|
-
${package_name} = { path = "../contract" }
|
|
63
|
-
TEOF
|
|
64
|
-
|
|
65
|
-
cat > test/src/lib.nr << 'NOIR'
|
|
66
|
-
use aztec::test::helpers::test_environment::TestEnvironment;
|
|
67
|
-
use __PACKAGE_NAME__::Main;
|
|
68
|
-
|
|
69
|
-
#[test]
|
|
70
|
-
unconstrained fn test_constructor() {
|
|
71
|
-
let mut env = TestEnvironment::new();
|
|
72
|
-
let deployer = env.create_light_account();
|
|
73
|
-
|
|
74
|
-
// Deploy the contract with the default constructor:
|
|
75
|
-
let contract_address = env.deploy("@__PACKAGE_NAME__/Main").with_private_initializer(
|
|
76
|
-
deployer,
|
|
77
|
-
Main::interface().constructor(),
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
// Deploy without an initializer:
|
|
81
|
-
let contract_address = env.deploy("@__PACKAGE_NAME__/Main").without_initializer();
|
|
82
|
-
}
|
|
83
|
-
NOIR
|
|
84
|
-
|
|
85
|
-
sed -i "s/__PACKAGE_NAME__/${package_name}/g" test/src/lib.nr
|
|
29
|
+
# Create the first crate pair
|
|
30
|
+
$script_path/add_crate.sh "$package_name" "$template"
|
|
86
31
|
|
|
87
32
|
# Create README
|
|
88
33
|
cat > README.md << REOF
|
|
@@ -96,7 +41,7 @@ An Aztec Noir contract project.
|
|
|
96
41
|
aztec compile
|
|
97
42
|
\`\`\`
|
|
98
43
|
|
|
99
|
-
This compiles
|
|
44
|
+
This compiles all contract crates and outputs artifacts to \`target/\`.
|
|
100
45
|
|
|
101
46
|
## Test
|
|
102
47
|
|
|
@@ -104,7 +49,7 @@ This compiles the contract in \`contract/\` and outputs artifacts to \`target/\`
|
|
|
104
49
|
aztec test
|
|
105
50
|
\`\`\`
|
|
106
51
|
|
|
107
|
-
This runs
|
|
52
|
+
This runs all tests in the workspace.
|
|
108
53
|
|
|
109
54
|
## Generate TypeScript bindings
|
|
110
55
|
|
|
@@ -121,4 +66,4 @@ target/
|
|
|
121
66
|
codegenCache.json
|
|
122
67
|
GEOF
|
|
123
68
|
|
|
124
|
-
echo "Created Aztec contract workspace with crates '${package_name}' and '${package_name}_test'"
|
|
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::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,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,6 +11,7 @@ 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,7 +19,6 @@ import { injectCompileCommand } from '../cli/cmds/compile.js';
|
|
|
18
19
|
import { injectMigrateCommand } from '../cli/cmds/migrate_ha_db.js';
|
|
19
20
|
import { injectProfileCommand } from '../cli/cmds/profile.js';
|
|
20
21
|
import { injectAztecCommands } from '../cli/index.js';
|
|
21
|
-
import { getCliVersion } from '../cli/release_version.js';
|
|
22
22
|
|
|
23
23
|
const NETWORK_FLAG = 'network';
|
|
24
24
|
|
|
@@ -47,7 +47,7 @@ async function main() {
|
|
|
47
47
|
await enrichEnvironmentWithNetworkConfig(networkName);
|
|
48
48
|
enrichEnvironmentWithChainName(networkName);
|
|
49
49
|
|
|
50
|
-
const cliVersion =
|
|
50
|
+
const cliVersion = getPackageVersion();
|
|
51
51
|
let program = new Command('aztec');
|
|
52
52
|
program.description('Aztec command line interface').version(cliVersion).enablePositionalOptions();
|
|
53
53
|
program = injectAztecCommands(program, userLog, debugLogger);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getActiveNetworkName } from '@aztec/foundation/config';
|
|
1
2
|
import {
|
|
2
3
|
type NamespacedApiHandlers,
|
|
3
4
|
createNamespacedSafeJsonRpcServer,
|
|
@@ -6,14 +7,14 @@ import {
|
|
|
6
7
|
} from '@aztec/foundation/json-rpc/server';
|
|
7
8
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
8
9
|
import type { ChainConfig } from '@aztec/stdlib/config';
|
|
9
|
-
import { AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
|
|
10
|
+
import { AztecNodeAdminApiSchema, AztecNodeApiSchema, AztecNodeDebugApiSchema } from '@aztec/stdlib/interfaces/client';
|
|
11
|
+
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
10
12
|
import { getVersioningMiddleware } from '@aztec/stdlib/versioning';
|
|
11
|
-
import { getOtelJsonRpcPropagationMiddleware } from '@aztec/telemetry-client';
|
|
13
|
+
import { getOtelJsonRpcDiagnosticsMiddleware, getOtelJsonRpcPropagationMiddleware } from '@aztec/telemetry-client';
|
|
12
14
|
|
|
13
15
|
import { createLocalNetwork } from '../local-network/index.js';
|
|
14
16
|
import { github, splash } from '../splash.js';
|
|
15
17
|
import { resolveAdminApiKey } from './admin_api_key_store.js';
|
|
16
|
-
import { getCliVersion } from './release_version.js';
|
|
17
18
|
import { extractNamespacedOptions, installSignalHandlers } from './util.js';
|
|
18
19
|
import { getVersions } from './versioning.js';
|
|
19
20
|
|
|
@@ -22,14 +23,13 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
|
|
|
22
23
|
const signalHandlers: Array<() => Promise<void>> = [];
|
|
23
24
|
const services: NamespacedApiHandlers = {};
|
|
24
25
|
const adminServices: NamespacedApiHandlers = {};
|
|
26
|
+
const packageVersion = getPackageVersion();
|
|
25
27
|
let config: ChainConfig | undefined = undefined;
|
|
26
28
|
|
|
27
29
|
if (options.localNetwork) {
|
|
28
|
-
const
|
|
29
|
-
const localNetwork = extractNamespacedOptions(options, 'local-network');
|
|
30
|
-
localNetwork.testAccounts = true;
|
|
30
|
+
const localNetwork = extractNamespacedOptions(options, 'localNetwork');
|
|
31
31
|
userLog(`${splash}\n${github}\n\n`);
|
|
32
|
-
userLog(`Setting up Aztec local network ${
|
|
32
|
+
userLog(`Setting up Aztec local network ${packageVersion}, please stand by...`);
|
|
33
33
|
|
|
34
34
|
const { node, stop } = await createLocalNetwork(
|
|
35
35
|
{
|
|
@@ -49,6 +49,8 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
|
|
|
49
49
|
// Start Node and PXE JSON-RPC server
|
|
50
50
|
signalHandlers.push(stop);
|
|
51
51
|
services.node = [node, AztecNodeApiSchema];
|
|
52
|
+
adminServices.node = [node, AztecNodeAdminApiSchema];
|
|
53
|
+
services.nodeDebug = [node, AztecNodeDebugApiSchema];
|
|
52
54
|
} else {
|
|
53
55
|
// Route --prover-node through startNode
|
|
54
56
|
if (options.proverNode && !options.node) {
|
|
@@ -57,13 +59,14 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
|
|
|
57
59
|
|
|
58
60
|
if (options.node) {
|
|
59
61
|
const { startNode } = await import('./cmds/start_node.js');
|
|
60
|
-
|
|
62
|
+
const networkName = getActiveNetworkName(options.network);
|
|
63
|
+
({ config } = await startNode(options, signalHandlers, services, adminServices, userLog, networkName));
|
|
64
|
+
if (options.nodeDebug && services.node) {
|
|
65
|
+
services.nodeDebug = [services.node[0], AztecNodeDebugApiSchema];
|
|
66
|
+
}
|
|
61
67
|
} else if (options.bot) {
|
|
62
68
|
const { startBot } = await import('./cmds/start_bot.js');
|
|
63
69
|
await startBot(options, signalHandlers, services, userLog);
|
|
64
|
-
} else if (options.archiver) {
|
|
65
|
-
const { startArchiver } = await import('./cmds/start_archiver.js');
|
|
66
|
-
({ config } = await startArchiver(options, signalHandlers, services));
|
|
67
70
|
} else if (options.p2pBootstrap) {
|
|
68
71
|
const { startP2PBootstrap } = await import('./cmds/start_p2p_bootstrap.js');
|
|
69
72
|
({ config } = await startP2PBootstrap(options, signalHandlers, services, userLog));
|
|
@@ -75,7 +78,7 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
|
|
|
75
78
|
await startProverBroker(options, signalHandlers, services, userLog);
|
|
76
79
|
} else if (options.txe) {
|
|
77
80
|
const { startTXE } = await import('./cmds/start_txe.js');
|
|
78
|
-
await startTXE(options, debugLogger);
|
|
81
|
+
await startTXE(options, signalHandlers, debugLogger);
|
|
79
82
|
} else if (options.sequencer) {
|
|
80
83
|
userLog(`Cannot run a standalone sequencer without a node`);
|
|
81
84
|
process.exit(1);
|
|
@@ -87,13 +90,15 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
|
|
|
87
90
|
|
|
88
91
|
installSignalHandlers(debugLogger.info, signalHandlers);
|
|
89
92
|
const versions = getVersions(config);
|
|
93
|
+
const versioningOpts = { packageVersion };
|
|
90
94
|
|
|
91
95
|
// Start the main JSON-RPC server
|
|
92
96
|
if (Object.entries(services).length > 0) {
|
|
93
97
|
const rpcServer = createNamespacedSafeJsonRpcServer(services, {
|
|
98
|
+
diagnostic: getOtelJsonRpcDiagnosticsMiddleware(),
|
|
94
99
|
http200OnError: false,
|
|
95
100
|
log: debugLogger,
|
|
96
|
-
middlewares: [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions)],
|
|
101
|
+
middlewares: [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions, versioningOpts)],
|
|
97
102
|
maxBatchSize: options.rpcMaxBatchSize,
|
|
98
103
|
maxBodySizeBytes: options.rpcMaxBodySize,
|
|
99
104
|
});
|
|
@@ -103,7 +108,7 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
|
|
|
103
108
|
|
|
104
109
|
// If there are any admin services, start a separate JSON-RPC server for them
|
|
105
110
|
if (Object.entries(adminServices).length > 0) {
|
|
106
|
-
const adminMiddlewares = [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions)];
|
|
111
|
+
const adminMiddlewares = [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions, versioningOpts)];
|
|
107
112
|
|
|
108
113
|
// Resolve the admin API key (auto-generated and persisted, or opt-out)
|
|
109
114
|
const apiKeyResolution = await resolveAdminApiKey(
|
|
@@ -122,6 +127,7 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
|
|
|
122
127
|
}
|
|
123
128
|
|
|
124
129
|
const rpcServer = createNamespacedSafeJsonRpcServer(adminServices, {
|
|
130
|
+
diagnostic: getOtelJsonRpcDiagnosticsMiddleware(),
|
|
125
131
|
http200OnError: false,
|
|
126
132
|
log: debugLogger,
|
|
127
133
|
middlewares: adminMiddlewares,
|