diff --git a/Makefile b/Makefile index 965aca159722..065fcc43871b 100644 --- a/Makefile +++ b/Makefile @@ -301,7 +301,6 @@ aztec-nr: noir bb-cpp-native noir-projects-txe-tests: $(call test,$@,noir-projects/aztec-nr) $(call test,$@,noir-projects/noir-contracts) - $(call test,$@,noir-projects/noir-contracts-comp-failures) # Noir Projects - Aggregate target (builds all sub-projects) noir-projects: noir-protocol-circuits mock-protocol-circuits noir-contracts aztec-nr diff --git a/cspell.json b/cspell.json index 9766afc1ea5a..f792d7920a47 100644 --- a/cspell.json +++ b/cspell.json @@ -71,6 +71,7 @@ "cimg", "ciphertext", "ciphertexts", + "clippy", "clonedeep", "clonedeepwith", "cmd", @@ -171,6 +172,7 @@ "includable", "incrementation", "indexeddb", + "INSTA", "interruptible", "IPFS", "isequal", @@ -367,8 +369,8 @@ "unfinalized", "uniquified", "uniquify", - "unlinkability", "unkonstrained", + "unlinkability", "unnullify", "unpadded", "unprefixed", diff --git a/noir-projects/bootstrap.sh b/noir-projects/bootstrap.sh index 9bd80aeea54a..006f75495900 100755 --- a/noir-projects/bootstrap.sh +++ b/noir-projects/bootstrap.sh @@ -26,7 +26,7 @@ function build { } function test_cmds { - parallel -k ./{}/bootstrap.sh test_cmds ::: noir-protocol-circuits noir-contracts aztec-nr noir-contracts-comp-failures + parallel -k ./{}/bootstrap.sh test_cmds ::: noir-protocol-circuits noir-contracts aztec-nr contract-snapshots } function test { diff --git a/noir-projects/contract-snapshots/.gitignore b/noir-projects/contract-snapshots/.gitignore new file mode 100644 index 000000000000..ab3f4c8d559c --- /dev/null +++ b/noir-projects/contract-snapshots/.gitignore @@ -0,0 +1 @@ +/**/target/ diff --git a/noir-projects/contract-snapshots/Cargo.lock b/noir-projects/contract-snapshots/Cargo.lock new file mode 100644 index 000000000000..255d09d74e94 --- /dev/null +++ b/noir-projects/contract-snapshots/Cargo.lock @@ -0,0 +1,483 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "anyhow" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" + +[[package]] +name = "bitflags" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3" + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "console" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d64e8af5551369d19cf50138de61f1c42074ab970f74e99be916646777f8fc87" +dependencies = [ + "encode_unicode", + "libc", + "windows-sys", +] + +[[package]] +name = "contract-snapshots" +version = "0.1.0" +dependencies = [ + "insta", +] + +[[package]] +name = "encode_unicode" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "fastrand" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f1f227452a390804cdb637b74a86990f2a7d7ba4b7d5693aac9b4dd6defd8d6" + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "getrandom" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", + "wasip3", +] + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + +[[package]] +name = "indexmap" +version = "2.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" +dependencies = [ + "equivalent", + "hashbrown 0.17.0", + "serde", + "serde_core", +] + +[[package]] +name = "insta" +version = "1.47.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4a6248eb93a4401ed2f37dfe8ea592d3cf05b7cf4f8efa867b6895af7e094e" +dependencies = [ + "console", + "once_cell", + "similar", + "tempfile", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + +[[package]] +name = "libc" +version = "0.2.186" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "log" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" + +[[package]] +name = "memchr" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn", +] + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rustix" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "similar" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa" + +[[package]] +name = "syn" +version = "2.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom", + "once_cell", + "rustix", + "windows-sys", +] + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "wasip2" +version = "1.0.3+wasi-0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6" +dependencies = [ + "wit-bindgen 0.57.1", +] + +[[package]] +name = "wasip3" +version = "0.4.0+wasi-0.3.0-rc-2026-01-06" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" +dependencies = [ + "wit-bindgen 0.51.0", +] + +[[package]] +name = "wasm-encoder" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +dependencies = [ + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" +dependencies = [ + "anyhow", + "indexmap", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasmparser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +dependencies = [ + "bitflags", + "hashbrown 0.15.5", + "indexmap", + "semver", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "wit-bindgen" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" +dependencies = [ + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + +[[package]] +name = "wit-bindgen-core" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" +dependencies = [ + "anyhow", + "heck", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "prettyplease", + "syn", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" +dependencies = [ + "anyhow", + "prettyplease", + "proc-macro2", + "quote", + "syn", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" +dependencies = [ + "anyhow", + "bitflags", + "indexmap", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/noir-projects/contract-snapshots/Cargo.toml b/noir-projects/contract-snapshots/Cargo.toml new file mode 100644 index 000000000000..1fc3e8e0f3b4 --- /dev/null +++ b/noir-projects/contract-snapshots/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "contract-snapshots" +version = "0.1.0" +edition = "2024" +publish = false + +[lib] +path = "src/lib.rs" + +[[test]] +name = "snapshots" +path = "tests/snapshots.rs" +harness = true + +[dev-dependencies] +insta = "1" diff --git a/noir-projects/contract-snapshots/README.md b/noir-projects/contract-snapshots/README.md new file mode 100644 index 000000000000..fb8614eeb502 --- /dev/null +++ b/noir-projects/contract-snapshots/README.md @@ -0,0 +1,59 @@ +## Noir Contract Snapshots + +`cargo insta` snapshot tests for noir contracts. Two test categories live here: + +- **`expand/`** — runs `nargo expand` on a curated set of aztec-nr contracts (mirrors what CI benchmarks already exercise) and snapshots the expanded source. Surface for catching macro regressions that pass typechecking but silently change generated code. +- **`compile_failure/`** — drives `nargo compile` on intentionally invalid aztec-nr contracts and snapshots the full stderr. + +### Layout + +``` +Cargo.toml +build.rs # generates one #[test] per case at build time +tests/ + snapshots.rs # run_compile_failure / run_expand helpers + snapshots/ + compile_failure//*.snap # committed + expand//*.snap # committed +test_programs/ + compile_failure//{Nargo.toml,src/main.nr} +``` + +`expand` cases are *not* duplicated under `test_programs/`. They live in their canonical home under `noir-contracts/contracts/{app,test}/` and are referenced by relative path from `build.rs` (`EXPAND_CASES`). + +### Prerequisites + +`nargo` must be built. From the repo root: + +```sh +(cd noir && ./bootstrap.sh) +``` + +By default the test harness looks for `nargo` at `../../noir/noir-repo/target/release/nargo`. Override with `NARGO=/path/to/nargo cargo test`. + +### Running + +```sh +cargo test # run all snapshot tests +cargo test --test snapshots compile_failure # run one module +cargo test --test snapshots test_token # run one test (substring match) +``` + +### Updating snapshots + +Failing assertions write `.snap.new` siblings. Review them by reading the file, or use the review UI: + +```sh +cargo insta review # interactive, recommended +cargo insta accept # accept all pending snapshots +cargo insta test --accept # run + accept in one step (needed + # when the .snap doesn't exist yet) +``` + +CI rejects `INSTA_UPDATE`; any drift must be resolved locally and committed. + +### Adding a case + +`expand`: append `(name, relative_path)` to `EXPAND_CASES` in `build.rs`, then `cargo insta test --accept`. + +`compile_failure`: drop a contract under `test_programs/compile_failure//` (`Nargo.toml` + `src/main.nr`), then `cargo insta test --accept`. Case directory names must use `_`, not `-`. diff --git a/noir-projects/contract-snapshots/bootstrap.sh b/noir-projects/contract-snapshots/bootstrap.sh new file mode 100755 index 000000000000..f4ae19760903 --- /dev/null +++ b/noir-projects/contract-snapshots/bootstrap.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +source $(git rev-parse --show-toplevel)/ci3/source_bootstrap + +# nargo binary path relative to the crate root (this directory) +export NARGO=${NARGO:-../../noir/noir-repo/target/release/nargo} + +# Build the snapshot test binaries (compiles build.rs codegen too) and run Rust lints. +function build { + echo_header "contract-snapshots build" + denoise "cargo build --tests" + denoise "cargo fmt --check" + denoise "cargo clippy --all-targets" +} + +# Run the snapshot tests. CI rejects INSTA_UPDATE so any drift between +# committed snapshots and reality must be resolved intentionally by a developer. +function test { + echo_header "contract-snapshots test" + if [ "${CI:-0}" = "1" ] && [ -n "${INSTA_UPDATE:-}" ] && [ "${INSTA_UPDATE}" != "no" ]; then + echo "INSTA_UPDATE is not permitted in CI. Run 'cargo insta accept' locally and commit." >&2 + exit 1 + fi + INSTA_UPDATE=no cargo test --quiet +} + +function test_cmds { + if [ "${TARGET_BRANCH:-}" = "merge-train/fairies" ]; then + hash=disabled-cache + else + hash=$(hash_str \ + $(../../noir/bootstrap.sh hash) \ + $(cache_content_hash \ + ^noir-projects/contract-snapshots \ + ^noir-projects/noir-contracts/contracts/app \ + ^noir-projects/noir-contracts/contracts/test \ + ^noir-projects/aztec-nr)) + fi + echo "$hash ./noir-projects/contract-snapshots/bootstrap.sh test" +} + +case "$cmd" in + *) + default_cmd_handler "$@" + ;; +esac diff --git a/noir-projects/contract-snapshots/build.rs b/noir-projects/contract-snapshots/build.rs new file mode 100644 index 000000000000..22949c8a6e68 --- /dev/null +++ b/noir-projects/contract-snapshots/build.rs @@ -0,0 +1,110 @@ +use std::env; +use std::fs::{self, File}; +use std::io::Write; +use std::path::{Path, PathBuf}; + +/// Contracts whose `nargo expand` output is snapshotted. The set is kept +/// aligned with the contracts already exercised by CI benchmarks so that +/// macro-induced diffs and benchmark deltas show up on the same review. +/// +/// To add a case: append an entry here and run +/// `cargo insta test --accept -p contract-snapshots`. +const EXPAND_CASES: &[(&str, &str)] = &[ + ( + "token_contract", + "../noir-contracts/contracts/app/token_contract", + ), + ( + "amm_contract", + "../noir-contracts/contracts/app/amm_contract", + ), + ( + "storage_proof_test_contract", + "../noir-contracts/contracts/test/storage_proof_test_contract", + ), + ( + "avm_test_contract", + "../noir-contracts/contracts/test/avm_test_contract", + ), + ( + "avm_gadgets_test_contract", + "../noir-contracts/contracts/test/avm_gadgets_test_contract", + ), +]; + +fn main() { + let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); + let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); + let dest = out_dir.join("tests.rs"); + let mut f = File::create(&dest).unwrap(); + + println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rerun-if-changed=test_programs"); + for (_, rel) in EXPAND_CASES { + let abs = manifest_dir.join(rel); + println!("cargo:rerun-if-changed={}", abs.display()); + } + + write_dir_scanned_module( + &mut f, + &manifest_dir, + "compile_failure", + "run_compile_failure", + ); + write_dir_scanned_module( + &mut f, + &manifest_dir, + "compile_success", + "run_compile_success", + ); + write_expand_module(&mut f, &manifest_dir); +} + +fn write_dir_scanned_module(f: &mut File, manifest_dir: &Path, module: &str, helper: &str) { + let test_dir = manifest_dir.join(format!("test_programs/{module}")); + let mut cases: Vec<(String, PathBuf)> = fs::read_dir(&test_dir) + .unwrap_or_else(|e| { + panic!("could not read {}: {e}", test_dir.display()); + }) + .filter_map(Result::ok) + .filter(|e| e.path().is_dir() && e.path().join("Nargo.toml").exists()) + .map(|e| (e.file_name().into_string().unwrap(), e.path())) + .collect(); + cases.sort_by(|a, b| a.0.cmp(&b.0)); + + writeln!(f, "mod {module} {{").unwrap(); + for (name, path) in cases { + if name.contains('-') { + panic!("{module} case '{name}' must use '_' instead of '-'"); + } + writeln!( + f, + " #[test]\n fn test_{name}() {{\n super::{helper}(\"{name}\", std::path::PathBuf::from(r\"{path}\"));\n }}", + name = name, + path = path.display() + ) + .unwrap(); + } + writeln!(f, "}}").unwrap(); +} + +fn write_expand_module(f: &mut File, manifest_dir: &Path) { + writeln!(f, "mod expand {{").unwrap(); + for (name, rel) in EXPAND_CASES { + let path = manifest_dir.join(rel); + if !path.join("Nargo.toml").exists() { + panic!( + "expand case '{name}' has no Nargo.toml at {}", + path.display() + ); + } + writeln!( + f, + " #[test]\n fn test_{name}() {{\n super::run_expand(\"{name}\", std::path::PathBuf::from(r\"{path}\"));\n }}", + name = name, + path = path.display() + ) + .unwrap(); + } + writeln!(f, "}}").unwrap(); +} diff --git a/noir-projects/contract-snapshots/src/lib.rs b/noir-projects/contract-snapshots/src/lib.rs new file mode 100644 index 000000000000..ee7fc1b5c1f7 --- /dev/null +++ b/noir-projects/contract-snapshots/src/lib.rs @@ -0,0 +1,2 @@ +// This crate exists only to host integration tests under `tests/`. +// See `tests/snapshots.rs` and `build.rs` for the snapshot harness. diff --git a/noir-projects/noir-contracts-comp-failures/contracts/allow_phase_change_on_non_external_fn/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/allow_phase_change_on_non_external_fn/Nargo.toml similarity index 68% rename from noir-projects/noir-contracts-comp-failures/contracts/allow_phase_change_on_non_external_fn/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/allow_phase_change_on_non_external_fn/Nargo.toml index d2f5cfdc1eab..da4774a995f2 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/allow_phase_change_on_non_external_fn/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/allow_phase_change_on_non_external_fn/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/allow_phase_change_on_non_external_fn/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/allow_phase_change_on_non_external_fn/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/allow_phase_change_on_non_external_fn/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/allow_phase_change_on_non_external_fn/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/allow_phase_change_on_utility_fn/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/allow_phase_change_on_utility_fn/Nargo.toml similarity index 67% rename from noir-projects/noir-contracts-comp-failures/contracts/allow_phase_change_on_utility_fn/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/allow_phase_change_on_utility_fn/Nargo.toml index b3882cc6718e..67924e498857 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/allow_phase_change_on_utility_fn/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/allow_phase_change_on_utility_fn/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/allow_phase_change_on_utility_fn/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/allow_phase_change_on_utility_fn/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/allow_phase_change_on_utility_fn/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/allow_phase_change_on_utility_fn/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/authorization_selector_collision/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/authorization_selector_collision/Nargo.toml similarity index 67% rename from noir-projects/noir-contracts-comp-failures/contracts/authorization_selector_collision/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/authorization_selector_collision/Nargo.toml index 40ed4eabd259..1f269b35f385 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/authorization_selector_collision/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/authorization_selector_collision/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/authorization_selector_collision/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/authorization_selector_collision/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/authorization_selector_collision/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/authorization_selector_collision/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_from_wrong_type/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_from_wrong_type/Nargo.toml similarity index 67% rename from noir-projects/noir-contracts-comp-failures/contracts/authorize_once_from_wrong_type/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_from_wrong_type/Nargo.toml index 7130df19571a..26dc88d27a96 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_from_wrong_type/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_from_wrong_type/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_from_wrong_type/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_from_wrong_type/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/authorize_once_from_wrong_type/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_from_wrong_type/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_missing_from_param/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_missing_from_param/Nargo.toml similarity index 68% rename from noir-projects/noir-contracts-comp-failures/contracts/authorize_once_missing_from_param/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_missing_from_param/Nargo.toml index e3c0421eff43..59aafcbdb88d 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_missing_from_param/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_missing_from_param/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_missing_from_param/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_missing_from_param/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/authorize_once_missing_from_param/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_missing_from_param/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_missing_nonce_param/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_missing_nonce_param/Nargo.toml similarity index 68% rename from noir-projects/noir-contracts-comp-failures/contracts/authorize_once_missing_nonce_param/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_missing_nonce_param/Nargo.toml index 35c56f6dc0ef..ff272f0651e4 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_missing_nonce_param/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_missing_nonce_param/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_missing_nonce_param/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_missing_nonce_param/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/authorize_once_missing_nonce_param/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_missing_nonce_param/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_nonce_wrong_type/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_nonce_wrong_type/Nargo.toml similarity index 67% rename from noir-projects/noir-contracts-comp-failures/contracts/authorize_once_nonce_wrong_type/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_nonce_wrong_type/Nargo.toml index ba1ea98efb15..3ee987f8d6ad 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_nonce_wrong_type/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_nonce_wrong_type/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_nonce_wrong_type/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_nonce_wrong_type/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/authorize_once_nonce_wrong_type/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_nonce_wrong_type/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_on_non_external_fn/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_on_non_external_fn/Nargo.toml similarity index 68% rename from noir-projects/noir-contracts-comp-failures/contracts/authorize_once_on_non_external_fn/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_on_non_external_fn/Nargo.toml index 31296f301ec6..e58946a6d681 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_on_non_external_fn/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_on_non_external_fn/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_on_non_external_fn/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_on_non_external_fn/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/authorize_once_on_non_external_fn/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_on_non_external_fn/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_on_utility_fn/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_on_utility_fn/Nargo.toml similarity index 66% rename from noir-projects/noir-contracts-comp-failures/contracts/authorize_once_on_utility_fn/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_on_utility_fn/Nargo.toml index ac377a90737c..ecc202de402f 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_on_utility_fn/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_on_utility_fn/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_on_utility_fn/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_on_utility_fn/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/authorize_once_on_utility_fn/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/authorize_once_on_utility_fn/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/aztec_macro_too_many_args/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/aztec_macro_too_many_args/Nargo.toml similarity index 66% rename from noir-projects/noir-contracts-comp-failures/contracts/aztec_macro_too_many_args/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/aztec_macro_too_many_args/Nargo.toml index 291f3c46342c..7b828f3c6b14 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/aztec_macro_too_many_args/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/aztec_macro_too_many_args/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/aztec_macro_too_many_args/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/aztec_macro_too_many_args/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/aztec_macro_too_many_args/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/aztec_macro_too_many_args/src/main.nr diff --git a/noir-projects/contract-snapshots/test_programs/compile_failure/bob_token/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/bob_token/Nargo.toml new file mode 100644 index 000000000000..906fff22a0eb --- /dev/null +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/bob_token/Nargo.toml @@ -0,0 +1,8 @@ +[package] +name = "bob_token" +type = "contract" +authors = [""] + +[dependencies] +aztec = { path = "../../../../aztec-nr/aztec" } +balance_set = { path = "../../../../aztec-nr/balance-set" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/bob_token/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/bob_token/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/bob_token/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/bob_token/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/duplicate_storage/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/duplicate_storage/Nargo.toml similarity index 70% rename from noir-projects/noir-contracts-comp-failures/contracts/duplicate_storage/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/duplicate_storage/Nargo.toml index 9a28991054e9..1d0b0ee4ebed 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/duplicate_storage/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/duplicate_storage/Nargo.toml @@ -5,4 +5,4 @@ compiler_version = ">=0.25.0" type = "contract" [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/duplicate_storage/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/duplicate_storage/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/duplicate_storage/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/duplicate_storage/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/event_selector_collision/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/event_selector_collision/Nargo.toml similarity index 71% rename from noir-projects/noir-contracts-comp-failures/contracts/event_selector_collision/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/event_selector_collision/Nargo.toml index 1ba8876ac6c4..5a93463ca0e9 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/event_selector_collision/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/event_selector_collision/Nargo.toml @@ -5,4 +5,4 @@ compiler_version = ">=0.25.0" type = "contract" [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/event_selector_collision/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/event_selector_collision/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/event_selector_collision/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/event_selector_collision/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/external_and_internal_together/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/external_and_internal_together/Nargo.toml similarity index 67% rename from noir-projects/noir-contracts-comp-failures/contracts/external_and_internal_together/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/external_and_internal_together/Nargo.toml index 8f052fb53c2c..1eae6b6af3c8 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/external_and_internal_together/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/external_and_internal_together/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/external_and_internal_together/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/external_and_internal_together/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/external_and_internal_together/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/external_and_internal_together/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/incorrect_storage_struct_name/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/incorrect_storage_struct_name/Nargo.toml similarity index 72% rename from noir-projects/noir-contracts-comp-failures/contracts/incorrect_storage_struct_name/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/incorrect_storage_struct_name/Nargo.toml index 68a469c38437..86f7c26acbc0 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/incorrect_storage_struct_name/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/incorrect_storage_struct_name/Nargo.toml @@ -5,4 +5,4 @@ compiler_version = ">=0.25.0" type = "contract" [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/incorrect_storage_struct_name/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/incorrect_storage_struct_name/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/incorrect_storage_struct_name/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/incorrect_storage_struct_name/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/initializer_on_non_external_fn/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/initializer_on_non_external_fn/Nargo.toml similarity index 67% rename from noir-projects/noir-contracts-comp-failures/contracts/initializer_on_non_external_fn/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/initializer_on_non_external_fn/Nargo.toml index d9076ac44554..14405987b386 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/initializer_on_non_external_fn/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/initializer_on_non_external_fn/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/initializer_on_non_external_fn/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/initializer_on_non_external_fn/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/initializer_on_non_external_fn/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/initializer_on_non_external_fn/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/initializer_on_utility_fn/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/initializer_on_utility_fn/Nargo.toml similarity index 66% rename from noir-projects/noir-contracts-comp-failures/contracts/initializer_on_utility_fn/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/initializer_on_utility_fn/Nargo.toml index 5849c6d94ea0..70a86d6d1ba3 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/initializer_on_utility_fn/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/initializer_on_utility_fn/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/initializer_on_utility_fn/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/initializer_on_utility_fn/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/initializer_on_utility_fn/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/initializer_on_utility_fn/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/invalid_event/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/invalid_event/Nargo.toml similarity index 70% rename from noir-projects/noir-contracts-comp-failures/contracts/invalid_event/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/invalid_event/Nargo.toml index fd5c446ab345..7004854044c4 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/invalid_event/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/invalid_event/Nargo.toml @@ -5,4 +5,4 @@ compiler_version = ">=0.25.0" type = "contract" [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/invalid_event/src/invalid_event.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/invalid_event/src/invalid_event.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/invalid_event/src/invalid_event.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/invalid_event/src/invalid_event.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/invalid_event/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/invalid_event/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/invalid_event/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/invalid_event/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/invalid_external_function_type/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/invalid_external_function_type/Nargo.toml similarity index 72% rename from noir-projects/noir-contracts-comp-failures/contracts/invalid_external_function_type/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/invalid_external_function_type/Nargo.toml index 7e8025f4774d..fe12bc8fb0b1 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/invalid_external_function_type/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/invalid_external_function_type/Nargo.toml @@ -5,4 +5,4 @@ compiler_version = ">=0.25.0" type = "contract" [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/invalid_external_function_type/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/invalid_external_function_type/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/invalid_external_function_type/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/invalid_external_function_type/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/invalid_internal_function_type/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/invalid_internal_function_type/Nargo.toml similarity index 67% rename from noir-projects/noir-contracts-comp-failures/contracts/invalid_internal_function_type/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/invalid_internal_function_type/Nargo.toml index 0d007ec76ca0..23b910e04b73 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/invalid_internal_function_type/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/invalid_internal_function_type/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/invalid_internal_function_type/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/invalid_internal_function_type/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/invalid_internal_function_type/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/invalid_internal_function_type/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/invalid_note/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/invalid_note/Nargo.toml similarity index 69% rename from noir-projects/noir-contracts-comp-failures/contracts/invalid_note/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/invalid_note/Nargo.toml index a94a89957382..f17604c48746 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/invalid_note/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/invalid_note/Nargo.toml @@ -5,4 +5,4 @@ compiler_version = ">=0.25.0" type = "contract" [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/invalid_note/src/invalid_note.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/invalid_note/src/invalid_note.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/invalid_note/src/invalid_note.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/invalid_note/src/invalid_note.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/invalid_note/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/invalid_note/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/invalid_note/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/invalid_note/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/marked_private_unconstrained/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/marked_private_unconstrained/Nargo.toml similarity index 67% rename from noir-projects/noir-contracts-comp-failures/contracts/marked_private_unconstrained/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/marked_private_unconstrained/Nargo.toml index f72f5810797a..4c0448e82d09 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/marked_private_unconstrained/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/marked_private_unconstrained/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } \ No newline at end of file +aztec = { path = "../../../../aztec-nr/aztec" } \ No newline at end of file diff --git a/noir-projects/noir-contracts-comp-failures/contracts/marked_private_unconstrained/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/marked_private_unconstrained/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/marked_private_unconstrained/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/marked_private_unconstrained/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/marked_public_unconstrained/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/marked_public_unconstrained/Nargo.toml similarity index 66% rename from noir-projects/noir-contracts-comp-failures/contracts/marked_public_unconstrained/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/marked_public_unconstrained/Nargo.toml index b77dd5e5b4a7..01d1135d3b57 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/marked_public_unconstrained/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/marked_public_unconstrained/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/marked_public_unconstrained/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/marked_public_unconstrained/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/marked_public_unconstrained/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/marked_public_unconstrained/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/noinitcheck_on_non_external_fn/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/noinitcheck_on_non_external_fn/Nargo.toml similarity index 67% rename from noir-projects/noir-contracts-comp-failures/contracts/noinitcheck_on_non_external_fn/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/noinitcheck_on_non_external_fn/Nargo.toml index 14327850fecb..a6ac1090fa28 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/noinitcheck_on_non_external_fn/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/noinitcheck_on_non_external_fn/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/noinitcheck_on_non_external_fn/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/noinitcheck_on_non_external_fn/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/noinitcheck_on_non_external_fn/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/noinitcheck_on_non_external_fn/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/noinitcheck_on_utility_fn/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/noinitcheck_on_utility_fn/Nargo.toml similarity index 66% rename from noir-projects/noir-contracts-comp-failures/contracts/noinitcheck_on_utility_fn/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/noinitcheck_on_utility_fn/Nargo.toml index de8971626ad0..0638ade66b1f 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/noinitcheck_on_utility_fn/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/noinitcheck_on_utility_fn/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/noinitcheck_on_utility_fn/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/noinitcheck_on_utility_fn/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/noinitcheck_on_utility_fn/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/noinitcheck_on_utility_fn/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/noinitcheck_without_initializer/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/noinitcheck_without_initializer/Nargo.toml similarity index 67% rename from noir-projects/noir-contracts-comp-failures/contracts/noinitcheck_without_initializer/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/noinitcheck_without_initializer/Nargo.toml index b6785b52010e..e4977f869e05 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/noinitcheck_without_initializer/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/noinitcheck_without_initializer/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/noinitcheck_without_initializer/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/noinitcheck_without_initializer/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/noinitcheck_without_initializer/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/noinitcheck_without_initializer/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/non_deserializable/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/non_deserializable/Nargo.toml similarity index 70% rename from noir-projects/noir-contracts-comp-failures/contracts/non_deserializable/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/non_deserializable/Nargo.toml index 5914769cb4d6..f3dcc8cfe2e6 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/non_deserializable/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/non_deserializable/Nargo.toml @@ -5,4 +5,4 @@ compiler_version = ">=0.25.0" type = "contract" [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/non_deserializable/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/non_deserializable/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/non_deserializable/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/non_deserializable/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/non_serializable/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/non_serializable/Nargo.toml similarity index 70% rename from noir-projects/noir-contracts-comp-failures/contracts/non_serializable/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/non_serializable/Nargo.toml index 61dd673b2bd3..cdab1cef9a69 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/non_serializable/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/non_serializable/Nargo.toml @@ -5,4 +5,4 @@ compiler_version = ">=0.25.0" type = "contract" [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/non_serializable/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/non_serializable/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/non_serializable/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/non_serializable/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/only_self_on_non_external_fn/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/only_self_on_non_external_fn/Nargo.toml similarity index 66% rename from noir-projects/noir-contracts-comp-failures/contracts/only_self_on_non_external_fn/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/only_self_on_non_external_fn/Nargo.toml index 286bc46ee0af..72dda38ed4e6 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/only_self_on_non_external_fn/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/only_self_on_non_external_fn/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/only_self_on_non_external_fn/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/only_self_on_non_external_fn/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/only_self_on_non_external_fn/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/only_self_on_non_external_fn/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/only_self_on_utility_fn/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/only_self_on_utility_fn/Nargo.toml similarity index 65% rename from noir-projects/noir-contracts-comp-failures/contracts/only_self_on_utility_fn/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/only_self_on_utility_fn/Nargo.toml index 4560f50a26e3..f8be0fd46638 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/only_self_on_utility_fn/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/only_self_on_utility_fn/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/only_self_on_utility_fn/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/only_self_on_utility_fn/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/only_self_on_utility_fn/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/only_self_on_utility_fn/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_private_external_fn_call/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_direct_private_external_fn_call/Nargo.toml similarity index 74% rename from noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_private_external_fn_call/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_direct_private_external_fn_call/Nargo.toml index 35ab8ec6157d..6eed4a585ff7 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_private_external_fn_call/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_direct_private_external_fn_call/Nargo.toml @@ -5,4 +5,4 @@ compiler_version = ">=0.25.0" type = "contract" [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_private_external_fn_call/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_direct_private_external_fn_call/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_private_external_fn_call/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_direct_private_external_fn_call/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_private_internal_fn_call/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_direct_private_internal_fn_call/Nargo.toml similarity index 74% rename from noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_private_internal_fn_call/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_direct_private_internal_fn_call/Nargo.toml index f1ad725a4ce8..436b4ee2e970 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_private_internal_fn_call/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_direct_private_internal_fn_call/Nargo.toml @@ -5,4 +5,4 @@ compiler_version = ">=0.25.0" type = "contract" [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_private_internal_fn_call/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_direct_private_internal_fn_call/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_private_internal_fn_call/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_direct_private_internal_fn_call/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_public_external_fn_call/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_direct_public_external_fn_call/Nargo.toml similarity index 74% rename from noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_public_external_fn_call/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_direct_public_external_fn_call/Nargo.toml index a7ce32c176e5..ec3e23bb13da 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_public_external_fn_call/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_direct_public_external_fn_call/Nargo.toml @@ -5,4 +5,4 @@ compiler_version = ">=0.25.0" type = "contract" [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_public_external_fn_call/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_direct_public_external_fn_call/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_public_external_fn_call/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_direct_public_external_fn_call/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_public_internal_fn_call/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_direct_public_internal_fn_call/Nargo.toml similarity index 74% rename from noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_public_internal_fn_call/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_direct_public_internal_fn_call/Nargo.toml index f740d59f6626..84a37e697ef4 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_public_internal_fn_call/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_direct_public_internal_fn_call/Nargo.toml @@ -5,4 +5,4 @@ compiler_version = ">=0.25.0" type = "contract" [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_public_internal_fn_call/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_direct_public_internal_fn_call/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_public_internal_fn_call/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_direct_public_internal_fn_call/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_utility_external_fn_call/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_direct_utility_external_fn_call/Nargo.toml similarity index 74% rename from noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_utility_external_fn_call/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_direct_utility_external_fn_call/Nargo.toml index 261086647ccd..f56dc5fb2456 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_utility_external_fn_call/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_direct_utility_external_fn_call/Nargo.toml @@ -5,4 +5,4 @@ compiler_version = ">=0.25.0" type = "contract" [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_utility_external_fn_call/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_direct_utility_external_fn_call/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_utility_external_fn_call/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_direct_utility_external_fn_call/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_private_call/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_incorrectly_performed_private_call/Nargo.toml similarity index 74% rename from noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_private_call/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_incorrectly_performed_private_call/Nargo.toml index a40cc7085669..64f73d29257e 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_private_call/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_incorrectly_performed_private_call/Nargo.toml @@ -5,4 +5,4 @@ compiler_version = ">=0.25.0" type = "contract" [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_private_call/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_incorrectly_performed_private_call/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_private_call/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_incorrectly_performed_private_call/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_private_static_call/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_incorrectly_performed_private_static_call/Nargo.toml similarity index 75% rename from noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_private_static_call/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_incorrectly_performed_private_static_call/Nargo.toml index 7f0978672f74..96d0dc5861ba 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_private_static_call/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_incorrectly_performed_private_static_call/Nargo.toml @@ -5,5 +5,5 @@ compiler_version = ">=0.25.0" type = "contract" [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_private_static_call/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_incorrectly_performed_private_static_call/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_private_static_call/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_incorrectly_performed_private_static_call/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_public_call/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_incorrectly_performed_public_call/Nargo.toml similarity index 74% rename from noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_public_call/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_incorrectly_performed_public_call/Nargo.toml index 82418ccd25ca..ae1de16b581c 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_public_call/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_incorrectly_performed_public_call/Nargo.toml @@ -5,5 +5,5 @@ compiler_version = ">=0.25.0" type = "contract" [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_public_call/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_incorrectly_performed_public_call/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_public_call/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_incorrectly_performed_public_call/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_public_static_call/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_incorrectly_performed_public_static_call/Nargo.toml similarity index 75% rename from noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_public_static_call/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_incorrectly_performed_public_static_call/Nargo.toml index 0bcb6a7437d8..69528a9afa01 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_public_static_call/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_incorrectly_performed_public_static_call/Nargo.toml @@ -5,5 +5,5 @@ compiler_version = ">=0.25.0" type = "contract" [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_public_static_call/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_incorrectly_performed_public_static_call/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_public_static_call/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_incorrectly_performed_public_static_call/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_non_state_var_in_storage/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_non_state_var_in_storage/Nargo.toml similarity index 73% rename from noir-projects/noir-contracts-comp-failures/contracts/panic_on_non_state_var_in_storage/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_non_state_var_in_storage/Nargo.toml index 84c1a3f7fff7..ce8727023340 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_non_state_var_in_storage/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_non_state_var_in_storage/Nargo.toml @@ -5,4 +5,4 @@ compiler_version = ">=0.25.0" type = "contract" [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_non_state_var_in_storage/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_non_state_var_in_storage/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/panic_on_non_state_var_in_storage/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_non_state_var_in_storage/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_owned_state_var_in_storage/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_owned_state_var_in_storage/Nargo.toml similarity index 73% rename from noir-projects/noir-contracts-comp-failures/contracts/panic_on_owned_state_var_in_storage/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_owned_state_var_in_storage/Nargo.toml index 597dc861fd55..cabcfcb6cdd5 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_owned_state_var_in_storage/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_owned_state_var_in_storage/Nargo.toml @@ -5,4 +5,4 @@ compiler_version = ">=0.25.0" type = "contract" [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_owned_state_var_in_storage/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_owned_state_var_in_storage/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/panic_on_owned_state_var_in_storage/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/panic_on_owned_state_var_in_storage/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/pub_private_external_fn/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/pub_private_external_fn/Nargo.toml similarity index 65% rename from noir-projects/noir-contracts-comp-failures/contracts/pub_private_external_fn/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/pub_private_external_fn/Nargo.toml index cc1650303414..431efaa8d4b3 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/pub_private_external_fn/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/pub_private_external_fn/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/pub_private_external_fn/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/pub_private_external_fn/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/pub_private_external_fn/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/pub_private_external_fn/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/pub_public_external_fn/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/pub_public_external_fn/Nargo.toml similarity index 65% rename from noir-projects/noir-contracts-comp-failures/contracts/pub_public_external_fn/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/pub_public_external_fn/Nargo.toml index 7953452634e6..1863966a4d4b 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/pub_public_external_fn/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/pub_public_external_fn/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/pub_public_external_fn/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/pub_public_external_fn/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/pub_public_external_fn/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/pub_public_external_fn/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/pub_utility_external_fn/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/pub_utility_external_fn/Nargo.toml similarity index 65% rename from noir-projects/noir-contracts-comp-failures/contracts/pub_utility_external_fn/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/pub_utility_external_fn/Nargo.toml index 6e878c49849c..94a7e823a84b 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/pub_utility_external_fn/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/pub_utility_external_fn/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/pub_utility_external_fn/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/pub_utility_external_fn/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/pub_utility_external_fn/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/pub_utility_external_fn/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/public_allow_phase_change/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/public_allow_phase_change/Nargo.toml similarity index 66% rename from noir-projects/noir-contracts-comp-failures/contracts/public_allow_phase_change/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/public_allow_phase_change/Nargo.toml index 0d19a888079a..fcc5e3960242 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/public_allow_phase_change/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/public_allow_phase_change/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/public_allow_phase_change/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/public_allow_phase_change/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/public_allow_phase_change/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/public_allow_phase_change/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/public_function_selector_collision/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/public_function_selector_collision/Nargo.toml similarity index 73% rename from noir-projects/noir-contracts-comp-failures/contracts/public_function_selector_collision/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/public_function_selector_collision/Nargo.toml index fc464e417620..7bd2e4a7abca 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/public_function_selector_collision/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/public_function_selector_collision/Nargo.toml @@ -5,4 +5,4 @@ compiler_version = ">=0.25.0" type = "contract" [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/public_function_selector_collision/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/public_function_selector_collision/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/public_function_selector_collision/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/public_function_selector_collision/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/reserved_emit_public_init_nullifier/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/reserved_emit_public_init_nullifier/Nargo.toml similarity index 68% rename from noir-projects/noir-contracts-comp-failures/contracts/reserved_emit_public_init_nullifier/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/reserved_emit_public_init_nullifier/Nargo.toml index 7a20f71d024d..3fb10af0c6af 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/reserved_emit_public_init_nullifier/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/reserved_emit_public_init_nullifier/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/reserved_emit_public_init_nullifier/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/reserved_emit_public_init_nullifier/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/reserved_emit_public_init_nullifier/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/reserved_emit_public_init_nullifier/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/reserved_public_dispatch/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/reserved_public_dispatch/Nargo.toml similarity index 65% rename from noir-projects/noir-contracts-comp-failures/contracts/reserved_public_dispatch/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/reserved_public_dispatch/Nargo.toml index a15aff4abcac..f875ce7c8202 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/reserved_public_dispatch/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/reserved_public_dispatch/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/reserved_public_dispatch/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/reserved_public_dispatch/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/reserved_public_dispatch/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/reserved_public_dispatch/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/unmacroified_function_in_contract/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/unmacroified_function_in_contract/Nargo.toml similarity index 68% rename from noir-projects/noir-contracts-comp-failures/contracts/unmacroified_function_in_contract/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/unmacroified_function_in_contract/Nargo.toml index 20537523e403..d4a297a56c34 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/unmacroified_function_in_contract/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/unmacroified_function_in_contract/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/unmacroified_function_in_contract/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/unmacroified_function_in_contract/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/unmacroified_function_in_contract/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/unmacroified_function_in_contract/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/user_defined_offchain_receive/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/user_defined_offchain_receive/Nargo.toml similarity index 67% rename from noir-projects/noir-contracts-comp-failures/contracts/user_defined_offchain_receive/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/user_defined_offchain_receive/Nargo.toml index e9269ae24e7a..0c1533e2caeb 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/user_defined_offchain_receive/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/user_defined_offchain_receive/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/user_defined_offchain_receive/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/user_defined_offchain_receive/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/user_defined_offchain_receive/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/user_defined_offchain_receive/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/utility_not_unconstrained/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/utility_not_unconstrained/Nargo.toml similarity index 66% rename from noir-projects/noir-contracts-comp-failures/contracts/utility_not_unconstrained/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/utility_not_unconstrained/Nargo.toml index 323d48fb2edc..8d2ada72c96a 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/utility_not_unconstrained/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/utility_not_unconstrained/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/utility_not_unconstrained/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/utility_not_unconstrained/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/utility_not_unconstrained/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/utility_not_unconstrained/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/view_on_non_external_fn/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/view_on_non_external_fn/Nargo.toml similarity index 65% rename from noir-projects/noir-contracts-comp-failures/contracts/view_on_non_external_fn/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/view_on_non_external_fn/Nargo.toml index 3461ff6d5fe4..5ab0d2b3adfb 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/view_on_non_external_fn/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/view_on_non_external_fn/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/view_on_non_external_fn/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/view_on_non_external_fn/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/view_on_non_external_fn/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/view_on_non_external_fn/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/view_on_utility_fn/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_failure/view_on_utility_fn/Nargo.toml similarity index 64% rename from noir-projects/noir-contracts-comp-failures/contracts/view_on_utility_fn/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_failure/view_on_utility_fn/Nargo.toml index c4845c37358f..7da9cd25bdaf 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/view_on_utility_fn/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_failure/view_on_utility_fn/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/view_on_utility_fn/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_failure/view_on_utility_fn/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/view_on_utility_fn/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_failure/view_on_utility_fn/src/main.nr diff --git a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_before_external/Nargo.toml b/noir-projects/contract-snapshots/test_programs/compile_success/authorize_once_before_external/Nargo.toml similarity index 67% rename from noir-projects/noir-contracts-comp-failures/contracts/authorize_once_before_external/Nargo.toml rename to noir-projects/contract-snapshots/test_programs/compile_success/authorize_once_before_external/Nargo.toml index f29f5d173b46..a2b023bb7165 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_before_external/Nargo.toml +++ b/noir-projects/contract-snapshots/test_programs/compile_success/authorize_once_before_external/Nargo.toml @@ -4,4 +4,4 @@ type = "contract" authors = [""] [dependencies] -aztec = { path = "../../../aztec-nr/aztec" } +aztec = { path = "../../../../aztec-nr/aztec" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_before_external/src/main.nr b/noir-projects/contract-snapshots/test_programs/compile_success/authorize_once_before_external/src/main.nr similarity index 100% rename from noir-projects/noir-contracts-comp-failures/contracts/authorize_once_before_external/src/main.nr rename to noir-projects/contract-snapshots/test_programs/compile_success/authorize_once_before_external/src/main.nr diff --git a/noir-projects/contract-snapshots/tests/snapshots.rs b/noir-projects/contract-snapshots/tests/snapshots.rs new file mode 100644 index 000000000000..f89ef8a41e71 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots.rs @@ -0,0 +1,107 @@ +use std::path::{Path, PathBuf}; +use std::process::Command; + +fn manifest_dir() -> PathBuf { + PathBuf::from(env!("CARGO_MANIFEST_DIR")) +} + +/// `noir-projects/contract-snapshots/` -> repo root. +fn repo_root() -> PathBuf { + manifest_dir() + .parent() + .unwrap() + .parent() + .unwrap() + .to_path_buf() +} + +fn nargo_path() -> PathBuf { + let raw = std::env::var("NARGO") + .map(PathBuf::from) + .unwrap_or_else(|_| manifest_dir().join("../../noir/noir-repo/target/release/nargo")); + if raw.is_absolute() { + raw + } else { + manifest_dir().join(raw) + } +} + +fn nargo(dir: &Path) -> Command { + let mut cmd = Command::new(nargo_path()); + cmd.current_dir(dir); + cmd +} + +/// Scrubs nargo stderr before snapshotting: +/// +/// 1. Drops `Waiting for lock on git dependencies cache...` lines that nargo +/// emits when concurrent test invocations contend on its git-deps cache. +/// 2. Replaces the absolute repo prefix with `` so call-stack lines +/// pointing into `aztec-nr/aztec/src/macros/...` are stable across machines. +fn scrub_stderr(s: String) -> String { + let prefix = format!("{}/", repo_root().display()); + s.lines() + .filter(|l| !l.contains("Waiting for lock")) + .map(|l| l.replace(&prefix, "/")) + .collect::>() + .join("\n") +} + +/// Asserts `nargo compile` fails for `dir` and snapshots scrubbed stderr +fn run_compile_failure(name: &str, dir: PathBuf) { + let out = nargo(&dir) + .args(["compile", "--silence-warnings"]) + .output() + .unwrap_or_else(|e| panic!("could not invoke nargo at {:?}: {e}", nargo_path())); + assert!( + !out.status.success(), + "{name} unexpectedly compiled successfully" + ); + let stderr = scrub_stderr(String::from_utf8(out.stderr).expect("nargo stderr should be utf-8")); + insta::with_settings!({ snapshot_path => format!("snapshots/compile_failure/{name}") }, { + insta::assert_snapshot!("stderr", stderr); + }); +} + +/// Asserts `nargo compile` succeeds for `dir` and snapshots stderr +/// (typically empty, but captures any warnings nargo emits despite +/// `--silence-warnings`). Used for contracts that exist purely to track a +/// regression. If the test ever starts failing, the case must be moved to +/// `compile_failure/`. +fn run_compile_success(name: &str, dir: PathBuf) { + let out = nargo(&dir) + .args(["compile", "--silence-warnings"]) + .output() + .unwrap_or_else(|e| panic!("could not invoke nargo at {:?}: {e}", nargo_path())); + if !out.status.success() { + panic!( + "{name} unexpectedly failed to compile:\n--- stderr ---\n{}", + String::from_utf8_lossy(&out.stderr) + ); + } + let stderr = scrub_stderr(String::from_utf8(out.stderr).expect("nargo stderr should be utf-8")); + insta::with_settings!({ snapshot_path => format!("snapshots/compile_success/{name}") }, { + insta::assert_snapshot!("stderr", stderr); + }); +} + +/// Runs `nargo expand` in `dir` and snapshots stdout verbatim. The expanded +/// source has no path references, so no scrubbing is needed. +fn run_expand(name: &str, dir: PathBuf) { + let out = nargo(&dir) + .arg("expand") + .output() + .unwrap_or_else(|e| panic!("could not invoke nargo at {:?}: {e}", nargo_path())); + if !out.status.success() { + panic!( + "{name} expand failed:\n--- stderr ---\n{}", + String::from_utf8_lossy(&out.stderr) + ); + } + let stdout = String::from_utf8(out.stdout).expect("nargo stdout should be utf-8"); + insta::with_settings!({ snapshot_path => format!("snapshots/expand/{name}") }, { + insta::assert_snapshot!("expanded", stdout); + }); +} + +include!(concat!(env!("OUT_DIR"), "/tests.rs")); diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/allow_phase_change_on_non_external_fn/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/allow_phase_change_on_non_external_fn/snapshots__stderr.snap new file mode 100644 index 000000000000..4ba03004fab3 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/allow_phase_change_on_non_external_fn/snapshots__stderr.snap @@ -0,0 +1,17 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: The #[allow_phase_change] attribute can only be applied to #[external("private")] functions - foo is not + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:11:5 + 2: allow_phase_change + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:166:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/allow_phase_change_on_utility_fn/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/allow_phase_change_on_utility_fn/snapshots__stderr.snap new file mode 100644 index 000000000000..8d21b0bec8f5 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/allow_phase_change_on_utility_fn/snapshots__stderr.snap @@ -0,0 +1,19 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: The #[allow_phase_change] attribute cannot be applied to #[external("utility")] functions - foo + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:9:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:355:9 + 3: assert_valid_utility + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:505:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorization_selector_collision/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorization_selector_collision/snapshots__stderr.snap new file mode 100644 index 000000000000..de4879598429 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorization_selector_collision/snapshots__stderr.snap @@ -0,0 +1,67 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: Trait crate::authwit::authorization_interface::AuthorizationInterface not found + ┌─ /noir-projects/aztec-nr/aztec/src/macros/authorization.nr:36:43 + │ +36 │ let authorization_interface = quote { crate::authwit::authorization_interface::AuthorizationInterface }; + │ --------------------------------------------------------------- + │ + ┌─ src/main.nr:24:5 + │ +24 │ #[authorization] + │ ---------------- While running this function attribute + │ + +error: Could not resolve 'authwit' in path + ┌─ /noir-projects/aztec-nr/aztec/src/macros/authorization.nr:37:54 + │ +37 │ let authorization_selector_type = quote { crate::authwit::AuthorizationSelector }; + │ ------- + │ + ┌─ src/main.nr:24:5 + │ +24 │ #[authorization] + │ ---------------- While running this function attribute + │ + +error: check_trait_impl_where_clause_matches_trait_where_clause: missing trait ID + ┌─ /noir-projects/aztec-nr/aztec/src/macros/authorization.nr:23:16 + │ +23 │ let name = s.name(); + │ -------- + │ + ┌─ src/main.nr:24:5 + │ +24 │ #[authorization] + │ ---------------- While running this function attribute + │ + +error: check_trait_impl_method_matches_declaration: missing trait impl + ┌─ /noir-projects/aztec-nr/aztec/src/macros/authorization.nr:42:16 + │ +42 │ fn get_authorization_selector(self) -> $authorization_selector_type { + │ -------------------------- + │ + ┌─ src/main.nr:24:5 + │ +24 │ #[authorization] + │ ---------------- While running this function attribute + │ + +error: Selector collision detected between authorizations 'EventCollision8370082250' and 'EventCollision' + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: AuthorizationSelectorCollision::#[authorization] + at src/main.nr:27:5 + 2: authorization + at /noir-projects/aztec-nr/aztec/src/macros/authorization.nr:65:5 + 3: register_authorization + at /noir-projects/aztec-nr/aztec/src/macros/authorization.nr:15:9 + +Aborting due to 5 previous errors diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_from_wrong_type/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_from_wrong_type/snapshots__stderr.snap new file mode 100644 index 000000000000..d41d90c9c38b --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_from_wrong_type/snapshots__stderr.snap @@ -0,0 +1,27 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: Argument from in function foo must be of type AztecAddress, but is of type Field + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: #[aztec] + at src/main.nr:4:1 + 2: aztec + at /noir-projects/aztec-nr/aztec/src/macros/aztec.nr:97:21 + 3: process_functions + at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr:46:9 + 4: [T]::map + at std/vector.nr:67:33 + 5: process_functions + at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr:46:41 + 6: generate_public_external + at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/public.nr:97:9 + 7: create_authorize_once_check + at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/helpers.nr:72:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_missing_from_param/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_missing_from_param/snapshots__stderr.snap new file mode 100644 index 000000000000..83939084f7a4 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_missing_from_param/snapshots__stderr.snap @@ -0,0 +1,27 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: Function foo does not have a from parameter. Please specify which one to use in #[authorize_once("...", "authwit_nonce")] + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: #[aztec] + at src/main.nr:4:1 + 2: aztec + at /noir-projects/aztec-nr/aztec/src/macros/aztec.nr:97:21 + 3: process_functions + at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr:46:9 + 4: [T]::map + at std/vector.nr:67:33 + 5: process_functions + at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr:46:41 + 6: generate_public_external + at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/public.nr:97:9 + 7: create_authorize_once_check + at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/helpers.nr:67:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_missing_nonce_param/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_missing_nonce_param/snapshots__stderr.snap new file mode 100644 index 000000000000..b0a19e34e8cc --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_missing_nonce_param/snapshots__stderr.snap @@ -0,0 +1,27 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: Function foo does not have a authwit_nonce. Please specify which one to use in #[authorize_once("from", "...")] + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: #[aztec] + at src/main.nr:4:1 + 2: aztec + at /noir-projects/aztec-nr/aztec/src/macros/aztec.nr:97:21 + 3: process_functions + at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr:46:9 + 4: [T]::map + at std/vector.nr:67:33 + 5: process_functions + at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr:46:41 + 6: generate_public_external + at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/public.nr:97:9 + 7: create_authorize_once_check + at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/helpers.nr:81:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_nonce_wrong_type/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_nonce_wrong_type/snapshots__stderr.snap new file mode 100644 index 000000000000..d2e4063624a2 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_nonce_wrong_type/snapshots__stderr.snap @@ -0,0 +1,27 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: Argument authwit_nonce in function foo must be of type Field, but is of type u64 + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: #[aztec] + at src/main.nr:4:1 + 2: aztec + at /noir-projects/aztec-nr/aztec/src/macros/aztec.nr:97:21 + 3: process_functions + at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr:46:9 + 4: [T]::map + at std/vector.nr:67:33 + 5: process_functions + at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr:46:41 + 6: generate_public_external + at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/public.nr:97:9 + 7: create_authorize_once_check + at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/helpers.nr:86:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_on_non_external_fn/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_on_non_external_fn/snapshots__stderr.snap new file mode 100644 index 000000000000..856129ff8810 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_on_non_external_fn/snapshots__stderr.snap @@ -0,0 +1,17 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: The #[authorize_once] attribute can only be applied to #[external("private")] or #[external("public")] functions - foo is neither + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:14:5 + 2: authorize_once + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:320:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_on_utility_fn/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_on_utility_fn/snapshots__stderr.snap new file mode 100644 index 000000000000..8272342aa1d6 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_on_utility_fn/snapshots__stderr.snap @@ -0,0 +1,19 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: The #[authorize_once] attribute cannot be applied to #[external("utility")] functions - foo + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:12:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:355:9 + 3: assert_valid_utility + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:470:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/aztec_macro_too_many_args/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/aztec_macro_too_many_args/snapshots__stderr.snap new file mode 100644 index 000000000000..e7043b21b324 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/aztec_macro_too_many_args/snapshots__stderr.snap @@ -0,0 +1,17 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: #[aztec] expects 0 or 1 arguments, got 2 + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: #[aztec] + at src/main.nr:4:1 + 2: aztec + at /noir-projects/aztec-nr/aztec/src/macros/aztec.nr:89:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/bob_token/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/bob_token/snapshots__stderr.snap new file mode 100644 index 000000000000..48141769333e --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/bob_token/snapshots__stderr.snap @@ -0,0 +1,304 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: The #[internal] attribute cannot be applied to external functions - transfer_public is marked as both #[external] and #[internal("public")] + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:53:5 + 2: internal + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:375:9 + +error: A function marked as #[external("private")] or #[internal("private")] must not have public Noir visibility - transfer_private's visibility is 'pub' + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:85:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:349:9 + 3: assert_valid_private + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:398:9 + +error: The #[view] attribute can only be applied to #[external("private")] or #[external("public")] functions - _assert_is_owner is neither + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:107:5 + 2: view + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:283:9 + +error: #[external("private")] or #[internal("private")] functions must not be unconstrained - mint_private is + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:113:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:349:9 + 3: assert_valid_private + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:405:9 + +error: Function _assert_is_owner must be marked as either #[external(...)], #[internal(...)], or #[test] + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: #[aztec] + at src/main.nr:18:1 + 2: aztec + at /noir-projects/aztec-nr/aztec/src/macros/aztec.nr:93:5 + 3: check_each_fn_macroified + at /noir-projects/aztec-nr/aztec/src/macros/aztec.nr:295:13 + +error: cannot find `self` in this scope + ┌─ src/main.nr:41:9 + │ +41 │ self.storage.owner.write(self.msg_sender()); + │ ---- not found in this scope + │ + +error: cannot find `self` in this scope + ┌─ src/main.nr:46:19 + │ +46 │ assert_eq(self.msg_sender(), self.storage.owner.read(), "Only owner can mint"); + │ ---- not found in this scope + │ + +error: cannot find `self` in this scope + ┌─ src/main.nr:46:38 + │ +46 │ assert_eq(self.msg_sender(), self.storage.owner.read(), "Only owner can mint"); + │ ---- not found in this scope + │ + +error: cannot find `self` in this scope + ┌─ src/main.nr:47:31 + │ +47 │ let current_balance = self.storage.public_balances.at(employee).read(); + │ ---- not found in this scope + │ + +error: cannot find `self` in this scope + ┌─ src/main.nr:48:9 + │ +48 │ self.storage.public_balances.at(employee).write(current_balance + amount); + │ ---- not found in this scope + │ + +error: cannot find `self` in this scope + ┌─ src/main.nr:55:22 + │ +55 │ let sender = self.msg_sender(); + │ ---- not found in this scope + │ + +error: cannot find `self` in this scope + ┌─ src/main.nr:56:30 + │ +56 │ let sender_balance = self.storage.public_balances.at(sender).read(); + │ ---- not found in this scope + │ + +error: cannot find `self` in this scope + ┌─ src/main.nr:57:9 + │ +57 │ self.storage.public_balances.at(sender).write(sender_balance - amount); + │ ---- not found in this scope + │ + +error: cannot find `self` in this scope + ┌─ src/main.nr:58:33 + │ +58 │ let recipient_balance = self.storage.public_balances.at(to).read(); + │ ---- not found in this scope + │ + +error: cannot find `self` in this scope + ┌─ src/main.nr:59:9 + │ +59 │ self.storage.public_balances.at(to).write(recipient_balance + amount); + │ ---- not found in this scope + │ + +error: cannot find `self` in this scope + ┌─ src/main.nr:64:19 + │ +64 │ assert_eq(self.msg_sender(), self.storage.owner.read(), "Only current owner"); + │ ---- not found in this scope + │ + +error: cannot find `self` in this scope + ┌─ src/main.nr:64:38 + │ +64 │ assert_eq(self.msg_sender(), self.storage.owner.read(), "Only current owner"); + │ ---- not found in this scope + │ + +error: cannot find `self` in this scope + ┌─ src/main.nr:65:9 + │ +65 │ self.storage.owner.write(new_owner); + │ ---- not found in this scope + │ + +error: cannot find `self` in this scope + ┌─ src/main.nr:70:22 + │ +70 │ let sender = self.msg_sender(); + │ ---- not found in this scope + │ + +error: cannot find `self` in this scope + ┌─ src/main.nr:71:9 + │ +71 │ self.enqueue_self._deduct_public_balance(sender, amount); + │ ---- not found in this scope + │ + +error: cannot find `self` in this scope + ┌─ src/main.nr:72:9 + │ +72 │ self.storage.private_balances.at(sender).add(amount).deliver( + │ ---- not found in this scope + │ + +error: cannot find `self` in this scope + ┌─ src/main.nr:80:23 + │ +80 │ let balance = self.storage.public_balances.at(owner).read(); + │ ---- not found in this scope + │ + +error: cannot find `self` in this scope + ┌─ src/main.nr:81:9 + │ +81 │ self.storage.public_balances.at(owner).write(balance - amount); + │ ---- not found in this scope + │ + +error: cannot find `self` in this scope + ┌─ src/main.nr:87:22 + │ +87 │ let sender = self.msg_sender(); + │ ---- not found in this scope + │ + +error: cannot find `self` in this scope + ┌─ src/main.nr:88:9 + │ +88 │ self.storage.private_balances.at(sender).sub(amount).deliver( + │ ---- not found in this scope + │ + +error: cannot find `self` in this scope + ┌─ src/main.nr:91:9 + │ +91 │ self.storage.private_balances.at(to).add(amount).deliver( + │ ---- not found in this scope + │ + +error: missing pub keyword on return type of function private_balance_of + ┌─ src/main.nr:97:65 + │ +97 │ unconstrained fn private_balance_of(owner: AztecAddress) -> u128 { + │ ---- missing pub on return type + │ + = The `pub` keyword is mandatory for the entry-point function return type because the verifier cannot retrieve private witness and thus the function will not be able to return a 'priv' value + +error: cannot find `self` in this scope + ┌─ src/main.nr:98:9 + │ +98 │ self.storage.private_balances.at(owner).balance_of() + │ ---- not found in this scope + │ + +error: missing pub keyword on return type of function public_balance_of + ┌─ src/main.nr:102:64 + │ +102 │ unconstrained fn public_balance_of(owner: AztecAddress) -> u128 { + │ ---- missing pub on return type + │ + = The `pub` keyword is mandatory for the entry-point function return type because the verifier cannot retrieve private witness and thus the function will not be able to return a 'priv' value + +error: cannot find `self` in this scope + ┌─ src/main.nr:103:9 + │ +103 │ self.storage.public_balances.at(owner).read() + │ ---- not found in this scope + │ + +error: cannot find `self` in this scope + ┌─ src/main.nr:109:28 + │ +109 │ assert_eq(address, self.storage.owner.read(), "Only owner"); + │ ---- not found in this scope + │ + +error: cannot find `self` in this scope + ┌─ src/main.nr:115:9 + │ +115 │ self.enqueue_self._assert_is_owner(self.msg_sender()); + │ ---- not found in this scope + │ + +error: cannot find `self` in this scope + ┌─ src/main.nr:116:9 + │ +116 │ self.storage.private_balances.at(employee).add(amount).deliver( + │ ---- not found in this scope + │ + +error: cannot find `self` in this scope + ┌─ src/main.nr:123:22 + │ +123 │ let sender = self.msg_sender(); + │ ---- not found in this scope + │ + +error: cannot find `self` in this scope + ┌─ src/main.nr:124:9 + │ +124 │ self.storage.private_balances.at(sender).sub(amount).deliver( + │ ---- not found in this scope + │ + +error: cannot find `self` in this scope + ┌─ src/main.nr:127:9 + │ +127 │ self.enqueue_self._credit_public_balance(sender, amount); + │ ---- not found in this scope + │ + +error: cannot find `self` in this scope + ┌─ src/main.nr:133:23 + │ +133 │ let balance = self.storage.public_balances.at(owner).read(); + │ ---- not found in this scope + │ + +error: cannot find `self` in this scope + ┌─ src/main.nr:134:9 + │ +134 │ self.storage.public_balances.at(owner).write(balance + amount); + │ ---- not found in this scope + │ + +Aborting due to 38 previous errors diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/duplicate_storage/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/duplicate_storage/snapshots__stderr.snap new file mode 100644 index 000000000000..d6afbfc40656 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/duplicate_storage/snapshots__stderr.snap @@ -0,0 +1,17 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: The #[storage] macro can only be applied to a struct with name 'Storage', got 'Storage2' instead. + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: DuplicateStorage::#[storage] + at src/main.nr:10:5 + 2: storage + at /noir-projects/aztec-nr/aztec/src/macros/storage.nr:23:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/event_selector_collision/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/event_selector_collision/snapshots__stderr.snap new file mode 100644 index 000000000000..1d7d038f0b81 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/event_selector_collision/snapshots__stderr.snap @@ -0,0 +1,19 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: Event selector collision detected between events 'EventCollision8370082250' and 'EventCollision' + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: EventSelectorCollision::#[event] + at src/main.nr:10:5 + 2: event + at /noir-projects/aztec-nr/aztec/src/macros/events.nr:56:5 + 3: register_event_selector + at /noir-projects/aztec-nr/aztec/src/macros/events.nr:38:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/external_and_internal_together/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/external_and_internal_together/snapshots__stderr.snap new file mode 100644 index 000000000000..4e66449009a9 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/external_and_internal_together/snapshots__stderr.snap @@ -0,0 +1,17 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: The #[internal] attribute cannot be applied to external functions - foo is marked as both #[external] and #[internal("private")] + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:9:5 + 2: internal + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:375:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/incorrect_storage_struct_name/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/incorrect_storage_struct_name/snapshots__stderr.snap new file mode 100644 index 000000000000..03ab1c2355a0 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/incorrect_storage_struct_name/snapshots__stderr.snap @@ -0,0 +1,17 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: The #[storage] macro can only be applied to a struct with name 'Storage', got 'Storage2' instead. + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: IncorrectStorageStructName::#[storage] + at src/main.nr:8:5 + 2: storage + at /noir-projects/aztec-nr/aztec/src/macros/storage.nr:23:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/initializer_on_non_external_fn/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/initializer_on_non_external_fn/snapshots__stderr.snap new file mode 100644 index 000000000000..eadf7d5ff548 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/initializer_on_non_external_fn/snapshots__stderr.snap @@ -0,0 +1,17 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: The #[initializer] attribute can only be applied to #[external("private")] or #[external("public")] functions - foo is neither + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:11:5 + 2: initializer + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:100:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/initializer_on_utility_fn/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/initializer_on_utility_fn/snapshots__stderr.snap new file mode 100644 index 000000000000..22ddb085c680 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/initializer_on_utility_fn/snapshots__stderr.snap @@ -0,0 +1,19 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: The #[initializer] attribute cannot be applied to #[external("utility")] functions - foo + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:9:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:355:9 + 3: assert_valid_utility + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:491:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/invalid_event/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/invalid_event/snapshots__stderr.snap new file mode 100644 index 000000000000..83b77125cd5c --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/invalid_event/snapshots__stderr.snap @@ -0,0 +1,24 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: event's serialized length exceeds the maximum allowed for private events + ┌─ /noir-projects/aztec-nr/aztec/src/messages/logs/event.nr:30:5 + │ +30 │ ╭ std::static_assert( +31 │ │ ::N <= MAX_EVENT_SERIALIZED_LEN, +32 │ │ "event's serialized length exceeds the maximum allowed for private events", +33 │ │ ); + │ ╰─────' + │ + = Call stack: + 1: remove_constraints + at /noir-projects/aztec-nr/aztec/src/utils/remove_constraints.nr:4:5 + 2: do_private_message_delivery + at /noir-projects/aztec-nr/aztec/src/messages/message_delivery.nr:222:28 + 3: EventMessage::deliver_to + at /noir-projects/aztec-nr/aztec/src/event/event_message.nr:57:16 + 4: encode_private_event_message + at /noir-projects/aztec-nr/aztec/src/messages/logs/event.nr:30:5 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/invalid_external_function_type/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/invalid_external_function_type/snapshots__stderr.snap new file mode 100644 index 000000000000..35d786263891 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/invalid_external_function_type/snapshots__stderr.snap @@ -0,0 +1,17 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: Function 'invalid_external_function_type' is marked as #[external("invalid")], but 'invalid' is not a valid external function type. External functions must be one of 'private', 'public' or 'utility' + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:7:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:359:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/invalid_internal_function_type/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/invalid_internal_function_type/snapshots__stderr.snap new file mode 100644 index 000000000000..a5d6a01dfe97 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/invalid_internal_function_type/snapshots__stderr.snap @@ -0,0 +1,17 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: Function 'foo' is marked as #[internal("utility")], but 'utility' is not a valid internal function type. Internal functions must be one of 'private', 'public' + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:8:5 + 2: internal + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:388:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/invalid_note/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/invalid_note/snapshots__stderr.snap new file mode 100644 index 000000000000..278bb9319a40 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/invalid_note/snapshots__stderr.snap @@ -0,0 +1,35 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: InvalidNote has a packed length of 9 fields, which exceeds the maximum allowed length of 8 fields. See https://docs.aztec.network/errors/4 + ┌─ /noir-projects/aztec-nr/aztec/src/macros/notes.nr:52:17 + │ +52 │ std::static_assert(note_packed_len <= $max_note_packed_len, f"{note_type_name} has a packed length of {note_packed_len} fields, which exceeds the maximum allowed length of {max_note_packed_len} fields. See https://docs.aztec.network/errors/4"); + │ --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + │ + = Call stack: + 1: generate_sync_state + at /noir-projects/aztec-nr/aztec/src/macros/aztec.nr:240:13 + 2: do_sync_state + at /noir-projects/aztec-nr/aztec/src/messages/discovery/mod.nr:130:5 + 3: EphemeralArray::for_each + at /noir-projects/aztec-nr/aztec/src/ephemeral/mod.nr:99:13 + 4: do_sync_state + at /noir-projects/aztec-nr/aztec/src/messages/discovery/mod.nr:139:13 + 5: process_message_ciphertext + at /noir-projects/aztec-nr/aztec/src/messages/discovery/process_message.nr:41:9 + 6: process_message_plaintext + at /noir-projects/aztec-nr/aztec/src/messages/discovery/process_message.nr:76:13 + 7: process_private_note_msg + at /noir-projects/aztec-nr/aztec/src/messages/discovery/private_notes.nr:27:9 + 8: attempt_note_discovery + at /noir-projects/aztec-nr/aztec/src/messages/discovery/private_notes.nr:64:28 + 9: attempt_note_nonce_discovery + at /noir-projects/aztec-nr/aztec/src/messages/discovery/nonce_discovery.nr:46:27 + 10: generate_contract_library_method_compute_note_hash + at /noir-projects/aztec-nr/aztec/src/macros/aztec/compute_note_hash_and_nullifier.nr:107:53 + 11: generate_note_type_impl + at /noir-projects/aztec-nr/aztec/src/macros/notes.nr:52:17 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/marked_private_unconstrained/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/marked_private_unconstrained/snapshots__stderr.snap new file mode 100644 index 000000000000..637b06f4e3f9 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/marked_private_unconstrained/snapshots__stderr.snap @@ -0,0 +1,19 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: #[external("private")] or #[internal("private")] functions must not be unconstrained - unconstrained_private_function is + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:11:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:349:9 + 3: assert_valid_private + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:405:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/marked_public_unconstrained/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/marked_public_unconstrained/snapshots__stderr.snap new file mode 100644 index 000000000000..f1f2b5c72bd8 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/marked_public_unconstrained/snapshots__stderr.snap @@ -0,0 +1,19 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: #[external("public")] or #[internal("public")] functions must not be unconstrained - unconstrained_public_function is + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:11:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:352:9 + 3: assert_valid_public + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:422:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/noinitcheck_on_non_external_fn/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/noinitcheck_on_non_external_fn/snapshots__stderr.snap new file mode 100644 index 000000000000..d776325d7ef9 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/noinitcheck_on_non_external_fn/snapshots__stderr.snap @@ -0,0 +1,17 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: The #[noinitcheck] attribute can only be applied to #[external("private")] or #[external("public")] functions - foo is neither + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:11:5 + 2: noinitcheck + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:128:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/noinitcheck_on_utility_fn/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/noinitcheck_on_utility_fn/snapshots__stderr.snap new file mode 100644 index 000000000000..c04d0958d0af --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/noinitcheck_on_utility_fn/snapshots__stderr.snap @@ -0,0 +1,19 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: The #[noinitcheck] attribute cannot be applied to #[external("utility")] functions - foo + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:16:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:355:9 + 3: assert_valid_utility + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:498:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/noinitcheck_without_initializer/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/noinitcheck_without_initializer/snapshots__stderr.snap new file mode 100644 index 000000000000..431529c017a6 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/noinitcheck_without_initializer/snapshots__stderr.snap @@ -0,0 +1,17 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: The #[noinitcheck] attribute is unnecessary for contracts with no #[initializer] functions + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:8:5 + 2: noinitcheck + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:134:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/non_deserializable/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/non_deserializable/snapshots__stderr.snap new file mode 100644 index 000000000000..df59b3f78c18 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/non_deserializable/snapshots__stderr.snap @@ -0,0 +1,77 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: Contract function 'bad_private_return' returns a value of type NotDeserializable, which does not implement the Deserialize trait. Add #[derive(Deserialize)] to NotDeserializable's declaration. + ┌─ /noir-projects/aztec-nr/aztec/src/macros/utils.nr:169:13 + │ +169 │ return_type.implements(deserialize_constraint), + │ ---------------------------------------------- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:15:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:345:5 + +error: Parameter '_p' of contract function 'bad_private_param' has type NotDeserializable, which does not implement the Deserialize trait. Add #[derive(Deserialize)] to NotDeserializable's declaration. + ┌─ /noir-projects/aztec-nr/aztec/src/macros/utils.nr:188:13 + │ +188 │ param_type.implements(deserialize_constraint), + │ --------------------------------------------- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:20:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:346:5 + +error: Contract function 'bad_public_return' returns a value of type NotDeserializable, which does not implement the Deserialize trait. Add #[derive(Deserialize)] to NotDeserializable's declaration. + ┌─ /noir-projects/aztec-nr/aztec/src/macros/utils.nr:169:13 + │ +169 │ return_type.implements(deserialize_constraint), + │ ---------------------------------------------- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:23:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:345:5 + +error: Parameter '_p' of contract function 'bad_public_param' has type NotDeserializable, which does not implement the Deserialize trait. Add #[derive(Deserialize)] to NotDeserializable's declaration. + ┌─ /noir-projects/aztec-nr/aztec/src/macros/utils.nr:188:13 + │ +188 │ param_type.implements(deserialize_constraint), + │ --------------------------------------------- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:28:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:346:5 + +error: Contract function 'bad_utility_return' returns a value of type NotDeserializable, which does not implement the Deserialize trait. Add #[derive(Deserialize)] to NotDeserializable's declaration. + ┌─ /noir-projects/aztec-nr/aztec/src/macros/utils.nr:169:13 + │ +169 │ return_type.implements(deserialize_constraint), + │ ---------------------------------------------- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:31:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:345:5 + +error: Parameter '_p' of contract function 'bad_utility_param' has type NotDeserializable, which does not implement the Deserialize trait. Add #[derive(Deserialize)] to NotDeserializable's declaration. + ┌─ /noir-projects/aztec-nr/aztec/src/macros/utils.nr:188:13 + │ +188 │ param_type.implements(deserialize_constraint), + │ --------------------------------------------- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:36:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:346:5 + +Aborting due to 6 previous errors diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/non_serializable/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/non_serializable/snapshots__stderr.snap new file mode 100644 index 000000000000..62ec3c61e351 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/non_serializable/snapshots__stderr.snap @@ -0,0 +1,77 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: Contract function 'bad_private_return' returns a value of type NotSerializable, which does not implement the Serialize trait. Add #[derive(Serialize)] to NotSerializable's declaration. + ┌─ /noir-projects/aztec-nr/aztec/src/macros/utils.nr:164:13 + │ +164 │ return_type.implements(serialize_constraint), + │ -------------------------------------------- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:15:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:345:5 + +error: Parameter '_p' of contract function 'bad_private_param' has type NotSerializable, which does not implement the Serialize trait. Add #[derive(Serialize)] to NotSerializable's declaration. + ┌─ /noir-projects/aztec-nr/aztec/src/macros/utils.nr:183:13 + │ +183 │ param_type.implements(serialize_constraint), + │ ------------------------------------------- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:20:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:346:5 + +error: Contract function 'bad_public_return' returns a value of type NotSerializable, which does not implement the Serialize trait. Add #[derive(Serialize)] to NotSerializable's declaration. + ┌─ /noir-projects/aztec-nr/aztec/src/macros/utils.nr:164:13 + │ +164 │ return_type.implements(serialize_constraint), + │ -------------------------------------------- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:23:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:345:5 + +error: Parameter '_p' of contract function 'bad_public_param' has type NotSerializable, which does not implement the Serialize trait. Add #[derive(Serialize)] to NotSerializable's declaration. + ┌─ /noir-projects/aztec-nr/aztec/src/macros/utils.nr:183:13 + │ +183 │ param_type.implements(serialize_constraint), + │ ------------------------------------------- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:28:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:346:5 + +error: Contract function 'bad_utility_return' returns a value of type NotSerializable, which does not implement the Serialize trait. Add #[derive(Serialize)] to NotSerializable's declaration. + ┌─ /noir-projects/aztec-nr/aztec/src/macros/utils.nr:164:13 + │ +164 │ return_type.implements(serialize_constraint), + │ -------------------------------------------- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:31:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:345:5 + +error: Parameter '_p' of contract function 'bad_utility_param' has type NotSerializable, which does not implement the Serialize trait. Add #[derive(Serialize)] to NotSerializable's declaration. + ┌─ /noir-projects/aztec-nr/aztec/src/macros/utils.nr:183:13 + │ +183 │ param_type.implements(serialize_constraint), + │ ------------------------------------------- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:36:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:346:5 + +Aborting due to 6 previous errors diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/only_self_on_non_external_fn/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/only_self_on_non_external_fn/snapshots__stderr.snap new file mode 100644 index 000000000000..58b9830a8cea --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/only_self_on_non_external_fn/snapshots__stderr.snap @@ -0,0 +1,17 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: The #[only_self] attribute can only be applied to #[external("private")] or #[external("public")] functions - foo is neither + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:11:5 + 2: only_self + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:244:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/only_self_on_utility_fn/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/only_self_on_utility_fn/snapshots__stderr.snap new file mode 100644 index 000000000000..aacfd01f46e0 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/only_self_on_utility_fn/snapshots__stderr.snap @@ -0,0 +1,19 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: The #[only_self] attribute cannot be applied to #[external("utility")] functions - foo + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:9:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:355:9 + 3: assert_valid_utility + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:477:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_direct_private_external_fn_call/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_direct_private_external_fn_call/snapshots__stderr.snap new file mode 100644 index 000000000000..1eee416fbe05 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_direct_private_external_fn_call/snapshots__stderr.snap @@ -0,0 +1,15 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: Direct invocation of private functions is not supported. You attempted to call arbitrary_external_function. See https://docs.aztec.network/errors/6 + ┌─ src/main.nr:3:1 + │ + 3 │ #[aztec] + │ -------- While running this function attribute + · +12 │ arbitrary_external_function(); + │ --------------------------- `arbitrary_external_function` has been deprecated + │ + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_direct_private_internal_fn_call/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_direct_private_internal_fn_call/snapshots__stderr.snap new file mode 100644 index 000000000000..829db1680a75 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_direct_private_internal_fn_call/snapshots__stderr.snap @@ -0,0 +1,15 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: Direct invocation of private internal functions is not supported. You attempted to call arbitrary_private_function. See https://docs.aztec.network/errors/6 + ┌─ src/main.nr:3:1 + │ + 3 │ #[aztec] + │ -------- While running this function attribute + · +12 │ arbitrary_private_function(); + │ -------------------------- `arbitrary_private_function` has been deprecated + │ + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_direct_public_external_fn_call/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_direct_public_external_fn_call/snapshots__stderr.snap new file mode 100644 index 000000000000..51cef068790f --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_direct_public_external_fn_call/snapshots__stderr.snap @@ -0,0 +1,15 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: Direct invocation of public functions is not supported. You attempted to call arbitrary_external_function. See https://docs.aztec.network/errors/6 + ┌─ src/main.nr:3:1 + │ + 3 │ #[aztec] + │ -------- While running this function attribute + · +12 │ arbitrary_external_function(); + │ --------------------------- `arbitrary_external_function` has been deprecated + │ + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_direct_public_internal_fn_call/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_direct_public_internal_fn_call/snapshots__stderr.snap new file mode 100644 index 000000000000..5709ee3cb74b --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_direct_public_internal_fn_call/snapshots__stderr.snap @@ -0,0 +1,15 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: Direct invocation of public internal functions is not supported. You attempted to call arbitrary_public_function. See https://docs.aztec.network/errors/6 + ┌─ src/main.nr:3:1 + │ + 3 │ #[aztec] + │ -------- While running this function attribute + · +12 │ arbitrary_public_function(); + │ ------------------------- `arbitrary_public_function` has been deprecated + │ + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_direct_utility_external_fn_call/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_direct_utility_external_fn_call/snapshots__stderr.snap new file mode 100644 index 000000000000..252accac8f0f --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_direct_utility_external_fn_call/snapshots__stderr.snap @@ -0,0 +1,15 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: Direct invocation of utility functions is not supported. You attempted to call arbitrary_external_function. See https://docs.aztec.network/errors/6 + ┌─ src/main.nr:3:1 + │ + 3 │ #[aztec] + │ -------- While running this function attribute + · +12 │ arbitrary_external_function(); + │ --------------------------- `arbitrary_external_function` has been deprecated + │ + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_incorrectly_performed_private_call/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_incorrectly_performed_private_call/snapshots__stderr.snap new file mode 100644 index 000000000000..de1c268866c5 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_incorrectly_performed_private_call/snapshots__stderr.snap @@ -0,0 +1,25 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: Could not resolve 'ZERO' in path + ┌─ src/main.nr:3:1 + │ +3 │ #[aztec] + │ -------- While running this function attribute + · +9 │ PanicOnIncorrectlyPerformedPrivateCall::at(AztecAddress::ZERO).arbitrary_external_function(); + │ ---- + │ + +error: Your private call needs to be passed into the `self.call(...)` method to be executed (e.g. `self.call(MyContract::at(address).my_private_function(...args))` + ┌─ src/main.nr:3:1 + │ +3 │ #[aztec] + │ -------- While running this function attribute + · +9 │ PanicOnIncorrectlyPerformedPrivateCall::at(AztecAddress::ZERO).arbitrary_external_function(); + │ -------------------------------------------------------------------------------------------- Unused expression result of type PrivateCall<27, 0, ()> which must be used + │ + +Aborting due to 2 previous errors diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_incorrectly_performed_private_static_call/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_incorrectly_performed_private_static_call/snapshots__stderr.snap new file mode 100644 index 000000000000..7bd6bfee98f3 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_incorrectly_performed_private_static_call/snapshots__stderr.snap @@ -0,0 +1,26 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: Could not resolve 'ZERO' in path + ┌─ src/main.nr:3:1 + │ + 3 │ #[aztec] + │ -------- While running this function attribute + · +18 │ PanicOnIncorrectlyPerformedPrivateStaticCall::at(AztecAddress::ZERO) + │ ---- + │ + +error: Your private static call needs to be passed into the `self.view(...)` method to be executed (e.g. `self.view(MyContract::at(address).my_private_static_function(...args))` + ┌─ src/main.nr:3:1 + │ + 3 │ #[aztec] + │ -------- While running this function attribute + · +18 │ ╭ PanicOnIncorrectlyPerformedPrivateStaticCall::at(AztecAddress::ZERO) +19 │ │ .arbitrary_view_function(); + │ ╰──────────────────────────────────────' Unused expression result of type PrivateStaticCall<23, 0, Field> which must be used + │ + +Aborting due to 2 previous errors diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_incorrectly_performed_public_call/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_incorrectly_performed_public_call/snapshots__stderr.snap new file mode 100644 index 000000000000..3361a44915c4 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_incorrectly_performed_public_call/snapshots__stderr.snap @@ -0,0 +1,25 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: Could not resolve 'ZERO' in path + ┌─ src/main.nr:3:1 + │ + 3 │ #[aztec] + │ -------- While running this function attribute + · +12 │ PanicOnIncorrectlyPerformedPublicCall::at(AztecAddress::ZERO).arbitrary_public_function(); + │ ---- + │ + +error: Your public call needs to be passed into the `self.call(...)`, `self.enqueue(...)` or `self.enqueue_incognito(...)` method to be executed (e.g. `self.call(MyContract::at(address).my_public_function(...args))` + ┌─ src/main.nr:3:1 + │ + 3 │ #[aztec] + │ -------- While running this function attribute + · +12 │ PanicOnIncorrectlyPerformedPublicCall::at(AztecAddress::ZERO).arbitrary_public_function(); + │ ----------------------------------------------------------------------------------------- Unused expression result of type PublicCall<25, 0, ()> which must be used + │ + +Aborting due to 2 previous errors diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_incorrectly_performed_public_static_call/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_incorrectly_performed_public_static_call/snapshots__stderr.snap new file mode 100644 index 000000000000..b426ebb70c1c --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_incorrectly_performed_public_static_call/snapshots__stderr.snap @@ -0,0 +1,26 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: Could not resolve 'ZERO' in path + ┌─ src/main.nr:3:1 + │ + 3 │ #[aztec] + │ -------- While running this function attribute + · +18 │ PanicOnIncorrectlyPerformedPublicStaticCall::at(AztecAddress::ZERO) + │ ---- + │ + +error: Your public static call needs to be passed into the `self.view(...)`, `self.enqueue_view(...)` or `self.enqueue_view_incognito(...)` method to be executed (e.g. `self.view(MyContract::at(address).my_public_static_function(...args))` + ┌─ src/main.nr:3:1 + │ + 3 │ #[aztec] + │ -------- While running this function attribute + · +18 │ ╭ PanicOnIncorrectlyPerformedPublicStaticCall::at(AztecAddress::ZERO) +19 │ │ .arbitrary_public_static_function(); + │ ╰───────────────────────────────────────────────' Unused expression result of type PublicStaticCall<32, 0, Field> which must be used + │ + +Aborting due to 2 previous errors diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_non_state_var_in_storage/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_non_state_var_in_storage/snapshots__stderr.snap new file mode 100644 index 000000000000..3a141f8feda1 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_non_state_var_in_storage/snapshots__stderr.snap @@ -0,0 +1,41 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: Type NonStateVar does not implement StateVariable and hence cannot be placed in Storage struct. + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: PanicOnNonStateVarInStorage::#[storage] + at src/main.nr:12:5 + 2: storage + at /noir-projects/aztec-nr/aztec/src/macros/storage.nr:54:13 + +error: Could not resolve 'init' in path + ┌─ /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/private.nr:35:36 + │ +35 │ let storage = Storage::init(&mut context); + │ ---- + │ + ┌─ src/main.nr:4:1 + │ + 4 │ #[aztec] + │ -------- While running this function attribute + │ + +error: Type annotation needed + ┌─ /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/private.nr:61:56 + │ +61 │ aztec::contract_self::ContractSelfPrivate::new(&mut context, storage, call_self, enqueue_self, call_self_static, enqueue_self_static, internal, utility) + │ --- Could not determine the type of the generic argument `Storage` declared on the struct `ContractSelfPrivate` + │ + ┌─ src/main.nr:4:1 + │ + 4 │ #[aztec] + │ -------- While running this function attribute + │ + +Aborting due to 3 previous errors diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_owned_state_var_in_storage/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_owned_state_var_in_storage/snapshots__stderr.snap new file mode 100644 index 000000000000..f7c7c14166a5 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/panic_on_owned_state_var_in_storage/snapshots__stderr.snap @@ -0,0 +1,41 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: Type PrivateImmutable implements OwnedStateVariable and hence cannot be placed in Storage struct without being wrapped in Owned. Wrap the type in Owned<..., Context>. + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: PanicOnOwnedStateVarInStorage::#[storage] + at src/main.nr:8:5 + 2: storage + at /noir-projects/aztec-nr/aztec/src/macros/storage.nr:49:17 + +error: Could not resolve 'init' in path + ┌─ /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/private.nr:35:36 + │ +35 │ let storage = Storage::init(&mut context); + │ ---- + │ + ┌─ src/main.nr:4:1 + │ + 4 │ #[aztec] + │ -------- While running this function attribute + │ + +error: Type annotation needed + ┌─ /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/private.nr:61:56 + │ +61 │ aztec::contract_self::ContractSelfPrivate::new(&mut context, storage, call_self, enqueue_self, call_self_static, enqueue_self_static, internal, utility) + │ --- Could not determine the type of the generic argument `Storage` declared on the struct `ContractSelfPrivate` + │ + ┌─ src/main.nr:4:1 + │ + 4 │ #[aztec] + │ -------- While running this function attribute + │ + +Aborting due to 3 previous errors diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/pub_private_external_fn/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/pub_private_external_fn/snapshots__stderr.snap new file mode 100644 index 000000000000..a0e08ce30faf --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/pub_private_external_fn/snapshots__stderr.snap @@ -0,0 +1,19 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: A function marked as #[external("private")] or #[internal("private")] must not have public Noir visibility - foo's visibility is 'pub' + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:8:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:349:9 + 3: assert_valid_private + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:398:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/pub_public_external_fn/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/pub_public_external_fn/snapshots__stderr.snap new file mode 100644 index 000000000000..7fc4c600b3bd --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/pub_public_external_fn/snapshots__stderr.snap @@ -0,0 +1,19 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: A function marked as #[external("public")] or #[internal("public")] must not have public Noir visibility - foo's visibility is 'pub' + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:8:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:352:9 + 3: assert_valid_public + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:415:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/pub_utility_external_fn/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/pub_utility_external_fn/snapshots__stderr.snap new file mode 100644 index 000000000000..676a28b3f0f7 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/pub_utility_external_fn/snapshots__stderr.snap @@ -0,0 +1,19 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: A function marked as #[external("utility")] must not have public Noir visibility - foo's visibility is 'pub' + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:8:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:355:9 + 3: assert_valid_utility + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:451:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/public_allow_phase_change/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/public_allow_phase_change/snapshots__stderr.snap new file mode 100644 index 000000000000..8466367d1039 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/public_allow_phase_change/snapshots__stderr.snap @@ -0,0 +1,19 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: The #[allow_phase_change] attribute cannot be applied to #[external("public")] functions - foo + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:9:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:352:9 + 3: assert_valid_public + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:429:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/public_function_selector_collision/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/public_function_selector_collision/snapshots__stderr.snap new file mode 100644 index 000000000000..5e1f5985c358 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/public_function_selector_collision/snapshots__stderr.snap @@ -0,0 +1,23 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: Public function selector collision detected between functions 'fn_selector_collision_1442740381' and 'fn_selector_collision' + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: #[aztec] + at src/main.nr:4:1 + 2: aztec + at /noir-projects/aztec-nr/aztec/src/macros/aztec.nr:145:27 + 3: generate_public_dispatch + at /noir-projects/aztec-nr/aztec/src/macros/dispatch.nr:20:19 + 4: [T]::map + at std/vector.nr:67:33 + 5: generate_public_dispatch + at /noir-projects/aztec-nr/aztec/src/macros/dispatch.nr:32:13 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/reserved_emit_public_init_nullifier/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/reserved_emit_public_init_nullifier/snapshots__stderr.snap new file mode 100644 index 000000000000..7ddaf938517a --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/reserved_emit_public_init_nullifier/snapshots__stderr.snap @@ -0,0 +1,19 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: Function name '__emit_public_init_nullifier' is reserved for internal use + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:9:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:352:9 + 3: assert_valid_public + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:435:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/reserved_public_dispatch/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/reserved_public_dispatch/snapshots__stderr.snap new file mode 100644 index 000000000000..523b8cf5c4a4 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/reserved_public_dispatch/snapshots__stderr.snap @@ -0,0 +1,19 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: Function name 'public_dispatch' is reserved for internal use + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:9:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:352:9 + 3: assert_valid_public + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:441:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/unmacroified_function_in_contract/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/unmacroified_function_in_contract/snapshots__stderr.snap new file mode 100644 index 000000000000..d96287947c14 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/unmacroified_function_in_contract/snapshots__stderr.snap @@ -0,0 +1,19 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: Function foo must be marked as either #[external(...)], #[internal(...)], or #[test] + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: #[aztec] + at src/main.nr:4:1 + 2: aztec + at /noir-projects/aztec-nr/aztec/src/macros/aztec.nr:93:5 + 3: check_each_fn_macroified + at /noir-projects/aztec-nr/aztec/src/macros/aztec.nr:295:13 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/user_defined_offchain_receive/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/user_defined_offchain_receive/snapshots__stderr.snap new file mode 100644 index 000000000000..75565319fd2a --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/user_defined_offchain_receive/snapshots__stderr.snap @@ -0,0 +1,17 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: User-defined 'offchain_receive' is not allowed. The function is auto-injected by the #[aztec] macro. See https://docs.aztec.network/errors/7 + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: #[aztec] + at src/main.nr:4:1 + 2: aztec + at /noir-projects/aztec-nr/aztec/src/macros/aztec.nr:138:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/utility_not_unconstrained/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/utility_not_unconstrained/snapshots__stderr.snap new file mode 100644 index 000000000000..2d724bb3ad5d --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/utility_not_unconstrained/snapshots__stderr.snap @@ -0,0 +1,19 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: #[external("utility")] must be unconstrained - constrained_utility_function isn't + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:8:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:355:9 + 3: assert_valid_utility + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:458:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/view_on_non_external_fn/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/view_on_non_external_fn/snapshots__stderr.snap new file mode 100644 index 000000000000..e034afbf1b3b --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/view_on_non_external_fn/snapshots__stderr.snap @@ -0,0 +1,17 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: The #[view] attribute can only be applied to #[external("private")] or #[external("public")] functions - foo is neither + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:11:5 + 2: view + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:283:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/view_on_utility_fn/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/view_on_utility_fn/snapshots__stderr.snap new file mode 100644 index 000000000000..f2ae6c5e785b --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/view_on_utility_fn/snapshots__stderr.snap @@ -0,0 +1,19 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- +error: The #[view] attribute cannot be applied to #[external("utility")] functions - foo + ┌─ std/panic.nr:8:12 + │ +8 │ assert(false, message); + │ ----- Assertion failed + │ + = Call stack: + 1: ? + at src/main.nr:9:5 + 2: external + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:355:9 + 3: assert_valid_utility + at /noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr:484:9 + +Aborting due to 1 previous error diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_success/authorize_once_before_external/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_success/authorize_once_before_external/snapshots__stderr.snap new file mode 100644 index 000000000000..f0834d0b50ea --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_success/authorize_once_before_external/snapshots__stderr.snap @@ -0,0 +1,5 @@ +--- +source: tests/snapshots.rs +expression: stderr +--- + diff --git a/noir-projects/contract-snapshots/tests/snapshots/expand/amm_contract/snapshots__expanded.snap b/noir-projects/contract-snapshots/tests/snapshots/expand/amm_contract/snapshots__expanded.snap new file mode 100644 index 000000000000..1253e48c4746 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/expand/amm_contract/snapshots__expanded.snap @@ -0,0 +1,2920 @@ +--- +source: tests/snapshots.rs +expression: stdout +--- +use aztec::macros::aztec; +use aztec::macros::aztec; + +mod config { + use std::meta::derive; + use aztec::protocol::address::AztecAddress; + use aztec::protocol::traits::Deserialize; + use aztec::protocol::traits::Packable; + use aztec::protocol::traits::Serialize; + + /// We store the tokens of the pool in a struct such that to load it from PublicImmutable asserts only a single + /// merkle proof. + pub struct Config { + pub token0: AztecAddress, + pub token1: AztecAddress, + pub liquidity_token: AztecAddress, + } + + impl Eq for Config { + fn eq(_self: Self, _other: Self) -> bool { + ((_self.token0 == _other.token0) & (_self.token1 == _other.token1)) & (_self.liquidity_token == _other.liquidity_token) + } + } + + impl Packable for Config { + let N: u32 = 3; + + #[inline_always] + fn pack(self) -> [Field; 3] { + let mut result: [Field; 3] = [0_Field; 3]; + let mut offset: u32 = 0_u32; + let packed_member: [Field; 1] = self.token0.pack(); + let packed_member_len: u32 = ::N; + for i in 0_u32..packed_member_len { + { + let i_0: u32 = i + offset; + result[i_0] = packed_member[i]; + } + }; + offset = offset + packed_member_len; + let packed_member: [Field; 1] = self.token1.pack(); + let packed_member_len: u32 = ::N; + for i in 0_u32..packed_member_len { + { + let i_1: u32 = i + offset; + result[i_1] = packed_member[i]; + } + }; + offset = offset + packed_member_len; + let packed_member: [Field; 1] = self.liquidity_token.pack(); + let packed_member_len: u32 = ::N; + for i in 0_u32..packed_member_len { + { + let i_2: u32 = i + offset; + result[i_2] = packed_member[i]; + } + }; + offset = offset + packed_member_len; + result + } + + #[inline_always] + fn unpack(packed: [Field; 3]) -> Self { + let mut offset: u32 = 0_u32; + let mut member_fields: [Field; 1] = [0_Field; 1]; + for i in 0_u32..::N { + member_fields[i] = packed[i + offset]; + }; + let token0: AztecAddress = ::unpack(member_fields); + offset = offset + ::N; + let mut member_fields: [Field; 1] = [0_Field; 1]; + for i in 0_u32..::N { + member_fields[i] = packed[i + offset]; + }; + let token1: AztecAddress = ::unpack(member_fields); + offset = offset + ::N; + let mut member_fields: [Field; 1] = [0_Field; 1]; + for i in 0_u32..::N { + member_fields[i] = packed[i + offset]; + }; + let liquidity_token: AztecAddress = ::unpack(member_fields); + offset = offset + ::N; + Self { token0: token0, token1: token1, liquidity_token: liquidity_token} + } + } + + impl Serialize for Config { + let N: u32 = 3; + + fn serialize(self) -> [Field; 3] { + let mut writer: aztec::protocol::utils::writer::Writer<3> = aztec::protocol::utils::writer::Writer::<3>::new(); + self.stream_serialize(&mut writer); + writer.finish() + } + + #[inline_always] + fn stream_serialize(self, writer: &mut aztec::protocol::utils::writer::Writer) { + self.token0.stream_serialize(writer); + self.token1.stream_serialize(writer); + self.liquidity_token.stream_serialize(writer); + } + } + + impl Deserialize for Config { + let N: u32 = 3; + + fn deserialize(fields: [Field; 3]) -> Self { + let mut reader: aztec::protocol::utils::reader::Reader<3> = aztec::protocol::utils::reader::Reader::<3>::new(fields); + let result: Self = Self::stream_deserialize(&mut reader); + reader.finish(); + result + } + + #[inline_always] + fn stream_deserialize(reader: &mut aztec::protocol::utils::reader::Reader) -> Self { + let token0: AztecAddress = ::stream_deserialize(reader); + let token1: AztecAddress = ::stream_deserialize(reader); + let liquidity_token: AztecAddress = ::stream_deserialize(reader); + Self { token0: token0, token1: token1, liquidity_token: liquidity_token} + } + } +} + +mod lib { + /// Given an input amount of an asset and pair balances, returns the maximum output amount of the other asset. + pub fn get_amount_out(amount_in: u128, balance_in: u128, balance_out: u128) -> u128 { + assert(amount_in > (0_Field as u128), "INSUFFICIENT_INPUT_AMOUNT"); + assert((balance_in > (0_Field as u128)) & (balance_out > (0_Field as u128)), "INSUFFICIENT_LIQUIDITY"); + let amount_in_with_fee: u128 = amount_in * (997_Field as u128); + let numerator: u128 = amount_in_with_fee * balance_out; + let denominator: u128 = (balance_in * (1000_Field as u128)) + amount_in_with_fee; + numerator / denominator + } + + /// Given an output amount of an asset and pair balances, returns a required input amount of the other asset. + pub fn get_amount_in(amount_out: u128, balance_in: u128, balance_out: u128) -> u128 { + assert(amount_out > (0_Field as u128), "INSUFFICIENT_OUTPUT_AMOUNT"); + assert((balance_in > (0_Field as u128)) & (balance_out > (0_Field as u128)), "INSUFFICIENT_LIQUIDITY"); + let numerator: u128 = (balance_in * amount_out) * (1000_Field as u128); + let denominator: u128 = (balance_out - amount_out) * (997_Field as u128); + (numerator / denominator) + (1_Field as u128) + } + + /// Given the desired amounts and balances of token0 and token1 returns the optimal amount of token0 and token1 to be + /// added to the pool. + pub fn get_amounts_to_add(amount0_max: u128, amount1_max: u128, amount0_min: u128, amount1_min: u128, balance0: u128, balance1: u128) -> (u128, u128) { + if (balance0 == (0_Field as u128)) | (balance1 == (0_Field as u128)) { + (amount0_max, amount1_max) + } else { + let amount1_equivalent: u128 = get_equivalent_amount(amount0_max, balance0, balance1); + if amount1_equivalent <= amount1_max { + assert(amount1_equivalent >= amount1_min, "AMOUNT_1_BELOW_MINIMUM"); + (amount0_max, amount1_equivalent) + } else { + let amount0_equivalent: u128 = get_equivalent_amount(amount1_max, balance1, balance0); + assert(amount0_equivalent <= amount0_max); + assert(amount0_equivalent >= amount0_min, "AMOUNT_0_BELOW_MINIMUM"); + (amount0_equivalent, amount1_max) + } + } + } + + /// Returns the amount of tokens to return to a liquidity provider when they remove liquidity from the pool. + pub fn get_amounts_on_remove(to_burn: u128, total_supply: u128, balance0: u128, balance1: u128) -> (u128, u128) { + ((to_burn * balance0) / total_supply, (to_burn * balance1) / total_supply) + } + + /// Given some amount of an asset and pair balances, returns an equivalent amount of the other asset. Tokens should be + /// added and removed from the Pool respecting this ratio. + fn get_equivalent_amount(amount0: u128, balance0: u128, balance1: u128) -> u128 { + assert((balance0 > (0_Field as u128)) & (balance1 > (0_Field as u128)), "INSUFFICIENT_LIQUIDITY"); + (amount0 * balance1) / balance0 + } +} + +/// ## Overview +/// This contract demonstrates how to implement an **Automated Market Maker (AMM)** that maintains **public state** +/// while still achieving **identity privacy**. However, it does **not provide function privacy**: +/// - Anyone can observe **what actions** were performed. +/// - All amounts involved are visible, but **who** performed the action remains private. +/// +/// Unlike most Ethereum AMMs, the AMM contract is not itself the token that tracks participation of liquidity +/// providers, mostly due to Noir lacking inheritance as a feature. Instead, the AMM is expected to have mint and burn +/// permission over an external token contract. +/// +/// **Note:** +/// This is purely a demonstration. The **Aztec team** does not consider this the optimal design for building a DEX. +/// +/// ## Reentrancy Guard Considerations +/// +/// ### 1. Private Functions: +/// Reentrancy protection is typically necessary if entering an intermediate state that is only valid when +/// the action completes uninterrupted. This follows the **Checks-Effects-Interactions** pattern. +/// +/// - In this contract, **private functions** do not introduce intermediate states. +/// - All operations will be fully executed in **public** without needing intermediate checks. +/// +/// ### 2. Public Functions: +/// No **reentrancy guard** is required for public functions because: +/// - All public functions are marked as **internal** with a **single callsite** - from a private function. +/// - Public functions **cannot call private functions**, eliminating the risk of reentering into them from private. +/// - Since public functions are internal-only, **external contracts cannot access them**, ensuring no external +/// contract can trigger a reentrant call. This eliminates the following attack vector: +/// `AMM.private_fn --> AMM.public_fn --> ExternalContract.fn --> AMM.public_fn`. +pub contract AMM { + use crate::config::Config; + use crate::lib::get_amount_in; + use crate::lib::get_amount_out; + use crate::lib::get_amounts_on_remove; + use crate::lib::get_amounts_to_add; + use aztec::macros::functions::external; + use aztec::macros::functions::initializer; + use aztec::macros::functions::only_self; + use aztec::macros::storage::storage; + use aztec::protocol::address::AztecAddress; + use aztec::state_vars::PublicImmutable; + use token::Token; + use uint_note::PartialUintNote; + + struct Storage { + config: PublicImmutable, + } + + impl Storage { + fn init(context: Context) -> Self { + Self { config: as aztec::state_vars::StateVariable<4, Context>>::new(context, 1_Field)} + } + } + + /// Amount of liquidity which gets locked when liquidity is provided for the first time. Its purpose is to prevent + /// the pool from ever emptying which could lead to undefined behavior. + pub global MINIMUM_LIQUIDITY: u128 = 1000; + + /// We set it to 99 times the minimum liquidity. That way the first LP gets 99% of the value of their deposit. + pub global INITIAL_LIQUIDITY: u128 = 99000; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call constructor. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn constructor(token0: AztecAddress, token1: AztecAddress, liquidity_token: AztecAddress); + + /// Privately adds liquidity to the pool. This function receives the minimum and maximum number of tokens the caller + /// is willing to add, in order to account for changing market conditions, and will try to add as many tokens as + /// possible. + /// + /// `authwit_nonce` can be any non-zero value, as it's only used to isolate token transfer authwits to this + /// specific call. + /// + /// The identity of the liquidity provider is not revealed, but the action and amounts are. + #[deprecated(deny, "Direct invocation of private functions is not supported. You attempted to call add_liquidity. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn add_liquidity(amount0_max: u128, amount1_max: u128, amount0_min: u128, amount1_min: u128, authwit_nonce: Field); + + #[abi(storage)] + pub global STORAGE_LAYOUT_AMM: StorageLayout<3> = StorageLayout::<3> { + contract_name: "AMM", + fields: StorageLayoutFields { + config: aztec::state_vars::Storable { + slot: 0x01, + }, + }, + }; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call _add_liquidity. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn _add_liquidity(config: Config, refund_token0_partial_note: PartialUintNote, refund_token1_partial_note: PartialUintNote, liquidity_partial_note: PartialUintNote, amount0_max: u128, amount1_max: u128, amount0_min: u128, amount1_min: u128); + + /// Privately removes liquidity from the pool. This function receives how many liquidity tokens to burn, and the + /// minimum number of tokens the caller is willing to receive, in order to account for changing market conditions. + /// + /// `authwit_nonce` can be any non-zero value, as it's only used to isolate token transfer authwits to this + /// specific call. + /// + /// The identity of the liquidity provider is not revealed, but the action and amounts are. + #[deprecated(deny, "Direct invocation of private functions is not supported. You attempted to call remove_liquidity. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn remove_liquidity(liquidity: u128, amount0_min: u128, amount1_min: u128, authwit_nonce: Field); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call _remove_liquidity. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn _remove_liquidity(config: Config, liquidity: u128, token0_partial_note: PartialUintNote, token1_partial_note: PartialUintNote, amount0_min: u128, amount1_min: u128); + + /// Privately swaps `amount_in` `token_in` tokens for at least `amount_out_mint` `token_out` tokens with the pool. + /// + /// `authwit_nonce` can be any non-zero value, as it's only used to isolate token transfer authwits to this + /// specific call. + /// + /// The identity of the swapper is not revealed, but the action and amounts are. + #[deprecated(deny, "Direct invocation of private functions is not supported. You attempted to call swap_exact_tokens_for_tokens. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn swap_exact_tokens_for_tokens(token_in: AztecAddress, token_out: AztecAddress, amount_in: u128, amount_out_min: u128, authwit_nonce: Field); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call _swap_exact_tokens_for_tokens. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn _swap_exact_tokens_for_tokens(token_in: AztecAddress, token_out: AztecAddress, amount_in: u128, amount_out_min: u128, token_out_partial_note: PartialUintNote); + + /// Privately swaps at most `amount_in_max` `token_in` tokens for `amount_out` `token_out` tokens with the pool. + /// + /// `authwit_nonce` can be any non-zero value, as it's only used to isolate token transfer authwits to this + /// specific call. + /// + /// The identity of the swapper is not revealed, but the action and amounts are. + #[deprecated(deny, "Direct invocation of private functions is not supported. You attempted to call swap_tokens_for_exact_tokens. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn swap_tokens_for_exact_tokens(token_in: AztecAddress, token_out: AztecAddress, amount_out: u128, amount_in_max: u128, authwit_nonce: Field); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call _swap_tokens_for_exact_tokens. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn _swap_tokens_for_exact_tokens(token_in: AztecAddress, token_out: AztecAddress, amount_in_max: u128, amount_out: u128, change_token_in_partial_note: PartialUintNote, token_out_partial_note: PartialUintNote); + + #[deprecated(deny, "Direct invocation of utility functions is not supported. You attempted to call get_amount_out_for_exact_in. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + unconstrained fn get_amount_out_for_exact_in(balance_in: u128, balance_out: u128, amount_in: u128) -> u128; + + #[deprecated(deny, "Direct invocation of utility functions is not supported. You attempted to call get_amount_in_for_exact_out. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + unconstrained fn get_amount_in_for_exact_out(balance_in: u128, balance_out: u128, amount_out: u128) -> u128; + + /// Unpacks an array into a note corresponding to `note_type_id` and then computes its note hash (non-siloed) and inner nullifier (non-siloed) assuming the note has been inserted into the note hash tree with `note_nonce`. + /// + /// This function is automatically injected by the `#[aztec]` macro. + #[contract_library_method] + #[allow(dead_code)] + unconstrained fn _compute_note_hash_and_nullifier(packed_note: BoundedVec, owner: AztecAddress, storage_slot: Field, note_type_id: Field, contract_address: AztecAddress, randomness: Field, note_nonce: Field) -> Option { + _compute_note_hash(packed_note, owner, storage_slot, note_type_id, contract_address, randomness).map(|note_hash: Field| -> aztec::messages::discovery::NoteHashAndNullifier { + let siloed_note_hash: Field = aztec::protocol::hash::compute_siloed_note_hash(contract_address, note_hash); + let unique_note_hash: Field = aztec::protocol::hash::compute_unique_note_hash(note_nonce, siloed_note_hash); + let inner_nullifier: Option = _compute_note_nullifier(unique_note_hash, packed_note, owner, storage_slot, note_type_id, contract_address, randomness); + aztec::messages::discovery::NoteHashAndNullifier { note_hash: note_hash, inner_nullifier: inner_nullifier} + }) + } + + /// Unpacks an array into a note corresponding to `note_type_id` and then computes its note hash (non-siloed). + /// + /// The signature of this function notably matches the `aztec::messages::discovery::ComputeNoteHash` type, and so it can be used to call functions from that module such as `do_sync_state` and `attempt_note_discovery`. + /// + /// This function is automatically injected by the `#[aztec]` macro. + #[contract_library_method] + unconstrained fn _compute_note_hash(packed_note: BoundedVec, owner: AztecAddress, storage_slot: Field, note_type_id: Field, _contract_address: AztecAddress, randomness: Field) -> Option { + if note_type_id == ::get_id() { + let expected_len: u32 = ::N; + let actual_len: u32 = packed_note.len(); + if actual_len != expected_len { + (|args: [Field; 3]| aztec::oracle::logging::warn_log_format("[aztec-nr] Packed note length mismatch for note type id {0}: expected {1} fields, got {2}. Skipping note.", args))([note_type_id, expected_len as Field, actual_len as Field]); + Option::::none() + } else { + let note: uint_note::UintNote = ::unpack(aztec::utils::array::subarray::subarray(packed_note.storage(), 0_u32)); + Option::::some(::compute_note_hash(note, owner, storage_slot, randomness)) + } + } else { + (|args: [Field; 1]| aztec::oracle::logging::warn_log_format("[aztec-nr] Unknown note type id {0}. Skipping note.", args))([note_type_id]); + Option::::none() + } + } + + /// Computes a note's inner nullifier (non-siloed) given its unique note hash, preimage and extra data. + /// + /// The signature of this function notably matches the `aztec::messages::discovery::ComputeNoteNullifier` type, and so it can be used to call functions from that module such as `do_sync_state` and `attempt_note_discovery`. + /// + /// This function is automatically injected by the `#[aztec]` macro. + #[contract_library_method] + unconstrained fn _compute_note_nullifier(unique_note_hash: Field, packed_note: BoundedVec, owner: AztecAddress, _storage_slot: Field, note_type_id: Field, _contract_address: AztecAddress, _randomness: Field) -> Option { + if note_type_id == ::get_id() { + let expected_len: u32 = ::N; + let actual_len: u32 = packed_note.len(); + if actual_len != expected_len { + (|args: [Field; 3]| aztec::oracle::logging::warn_log_format("[aztec-nr] Packed note length mismatch for note type id {0}: expected {1} fields, got {2}. Skipping note.", args))([note_type_id, expected_len as Field, actual_len as Field]); + Option::::none() + } else { + let note: uint_note::UintNote = ::unpack(aztec::utils::array::subarray::subarray(packed_note.storage(), 0_u32)); + ::compute_nullifier_unconstrained(note, owner, unique_note_hash) + } + } else { + (|args: [Field; 1]| aztec::oracle::logging::warn_log_format("[aztec-nr] Unknown note type id {0}. Skipping note.", args))([note_type_id]); + Option::::none() + } + } + + /// Receives offchain messages into this contract's offchain inbox for subsequent processing. + /// + /// Each message is routed to the inbox scoped to its `recipient` field. + /// + /// For more details, see `aztec::messages::processing::offchain::receive`. + /// + /// This function is automatically injected by the `#[aztec]` macro. + unconstrained fn offchain_receive(messages: BoundedVec) { + let address: AztecAddress = aztec::context::UtilityContext::new().this_address(); + aztec::messages::processing::offchain::receive(address, messages); + } + + pub struct AMM { + pub target_contract: AztecAddress, + } + + impl AMM { + pub fn storage_layout() -> StorageLayoutFields { + STORAGE_LAYOUT_AMM.fields + } + + pub fn at(addr: AztecAddress) -> Self { + Self { target_contract: addr} + } + + pub fn interface() -> Self { + Self { target_contract: AztecAddress::zero()} + } + + pub fn constructor(self, token0: AztecAddress, token1: AztecAddress, liquidity_token: AztecAddress) -> aztec::context::calls::PublicCall<11, 3, ()> { + let mut serialized_params: [Field; 3] = [0_Field; 3]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(token0); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(token1); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(liquidity_token); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2287085075_Field); + aztec::context::calls::PublicCall::<11, 3, ()>::new(self.target_contract, selector, "constructor", serialized_params) + } + + pub fn add_liquidity(self, amount0_max: u128, amount1_max: u128, amount0_min: u128, amount1_min: u128, authwit_nonce: Field) -> aztec::context::calls::PrivateCall<13, 5, ()> { + let mut serialized_params: [Field; 5] = [0_Field; 5]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(amount0_max); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount1_max); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount0_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount1_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_4: u32 = i + offset; + serialized_params[i_4] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3734879327_Field); + aztec::context::calls::PrivateCall::<13, 5, ()>::new(self.target_contract, selector, "add_liquidity", serialized_params) + } + + pub fn swap_exact_tokens_for_tokens(self, token_in: AztecAddress, token_out: AztecAddress, amount_in: u128, amount_out_min: u128, authwit_nonce: Field) -> aztec::context::calls::PrivateCall<28, 5, ()> { + let mut serialized_params: [Field; 5] = [0_Field; 5]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(token_in); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(token_out); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount_in); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount_out_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_4: u32 = i + offset; + serialized_params[i_4] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2960373586_Field); + aztec::context::calls::PrivateCall::<28, 5, ()>::new(self.target_contract, selector, "swap_exact_tokens_for_tokens", serialized_params) + } + + pub fn _swap_tokens_for_exact_tokens(self, token_in: AztecAddress, token_out: AztecAddress, amount_in_max: u128, amount_out: u128, change_token_in_partial_note: PartialUintNote, token_out_partial_note: PartialUintNote) -> aztec::context::calls::PublicCall<29, 6, ()> { + let mut serialized_params: [Field; 6] = [0_Field; 6]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(token_in); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(token_out); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount_in_max); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount_out); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(change_token_in_partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_4: u32 = i + offset; + serialized_params[i_4] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(token_out_partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_5: u32 = i + offset; + serialized_params[i_5] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3156435103_Field); + aztec::context::calls::PublicCall::<29, 6, ()>::new(self.target_contract, selector, "_swap_tokens_for_exact_tokens", serialized_params) + } + + pub fn _swap_exact_tokens_for_tokens(self, token_in: AztecAddress, token_out: AztecAddress, amount_in: u128, amount_out_min: u128, token_out_partial_note: PartialUintNote) -> aztec::context::calls::PublicCall<29, 5, ()> { + let mut serialized_params: [Field; 5] = [0_Field; 5]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(token_in); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(token_out); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount_in); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount_out_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(token_out_partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_4: u32 = i + offset; + serialized_params[i_4] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1918288610_Field); + aztec::context::calls::PublicCall::<29, 5, ()>::new(self.target_contract, selector, "_swap_exact_tokens_for_tokens", serialized_params) + } + + pub fn _remove_liquidity(self, config: Config, liquidity: u128, token0_partial_note: PartialUintNote, token1_partial_note: PartialUintNote, amount0_min: u128, amount1_min: u128) -> aztec::context::calls::PublicCall<17, 8, ()> { + let mut serialized_params: [Field; 8] = [0_Field; 8]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 3] = >::serialize(config); + let serialized_member_len: u32 = >::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(liquidity); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(token0_partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(token1_partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount0_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_4: u32 = i + offset; + serialized_params[i_4] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount1_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_5: u32 = i + offset; + serialized_params[i_5] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2270402407_Field); + aztec::context::calls::PublicCall::<17, 8, ()>::new(self.target_contract, selector, "_remove_liquidity", serialized_params) + } + + pub fn _add_liquidity(self, config: Config, refund_token0_partial_note: PartialUintNote, refund_token1_partial_note: PartialUintNote, liquidity_partial_note: PartialUintNote, amount0_max: u128, amount1_max: u128, amount0_min: u128, amount1_min: u128) -> aztec::context::calls::PublicCall<14, 10, ()> { + let mut serialized_params: [Field; 10] = [0_Field; 10]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 3] = >::serialize(config); + let serialized_member_len: u32 = >::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(refund_token0_partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(refund_token1_partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(liquidity_partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount0_max); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_4: u32 = i + offset; + serialized_params[i_4] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount1_max); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_5: u32 = i + offset; + serialized_params[i_5] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount0_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_6: u32 = i + offset; + serialized_params[i_6] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount1_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_7: u32 = i + offset; + serialized_params[i_7] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1909103841_Field); + aztec::context::calls::PublicCall::<14, 10, ()>::new(self.target_contract, selector, "_add_liquidity", serialized_params) + } + + pub fn remove_liquidity(self, liquidity: u128, amount0_min: u128, amount1_min: u128, authwit_nonce: Field) -> aztec::context::calls::PrivateCall<16, 4, ()> { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(liquidity); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount0_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount1_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1221183968_Field); + aztec::context::calls::PrivateCall::<16, 4, ()>::new(self.target_contract, selector, "remove_liquidity", serialized_params) + } + + pub fn swap_tokens_for_exact_tokens(self, token_in: AztecAddress, token_out: AztecAddress, amount_out: u128, amount_in_max: u128, authwit_nonce: Field) -> aztec::context::calls::PrivateCall<28, 5, ()> { + let mut serialized_params: [Field; 5] = [0_Field; 5]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(token_in); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(token_out); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount_out); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount_in_max); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_4: u32 = i + offset; + serialized_params[i_4] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2620890703_Field); + aztec::context::calls::PrivateCall::<28, 5, ()>::new(self.target_contract, selector, "swap_tokens_for_exact_tokens", serialized_params) + } + + pub fn get_amount_out_for_exact_in(self, balance_in: u128, balance_out: u128, amount_in: u128) -> aztec::context::calls::UtilityCall<27, 3, u128> { + let mut serialized_params: [Field; 3] = [0_Field; 3]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(balance_in); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(balance_out); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount_in); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(58321933_Field); + aztec::context::calls::UtilityCall::<27, 3, u128>::new(self.target_contract, selector, "get_amount_out_for_exact_in", serialized_params) + } + + pub fn get_amount_in_for_exact_out(self, balance_in: u128, balance_out: u128, amount_out: u128) -> aztec::context::calls::UtilityCall<27, 3, u128> { + let mut serialized_params: [Field; 3] = [0_Field; 3]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(balance_in); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(balance_out); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount_out); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(4155151179_Field); + aztec::context::calls::UtilityCall::<27, 3, u128>::new(self.target_contract, selector, "get_amount_in_for_exact_out", serialized_params) + } + + pub fn offchain_receive(self, messages: BoundedVec) -> aztec::context::calls::UtilityCall<16, 321, ()> { + let serialized_params: [Field; 321] = as aztec::protocol::traits::Serialize>::serialize(messages); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1396850735_Field); + aztec::context::calls::UtilityCall::<16, 321, ()>::new(self.target_contract, selector, "offchain_receive", serialized_params) + } + } + + #[contract_library_method] + pub fn storage_layout() -> StorageLayoutFields { + STORAGE_LAYOUT_AMM.fields + } + + #[contract_library_method] + pub fn at(addr: AztecAddress) -> AMM { + AMM { target_contract: addr} + } + + #[contract_library_method] + pub fn interface() -> AMM { + AMM { target_contract: AztecAddress::zero()} + } + + pub struct sync_state_parameters { + pub scope: AztecAddress, + } + + #[abi(functions)] + pub struct sync_state_abi { + parameters: sync_state_parameters, + } + + unconstrained fn sync_state(scope: AztecAddress) { + let address: AztecAddress = aztec::context::UtilityContext::new().this_address(); + aztec::messages::discovery::do_sync_state(address, _compute_note_hash, _compute_note_nullifier, Option::>::none(), Option:: aztec::ephemeral::EphemeralArray>::some(aztec::messages::processing::offchain::sync_inbox), scope); + } + + pub struct offchain_receive_parameters { + pub messages: BoundedVec, + } + + #[abi(functions)] + pub struct offchain_receive_abi { + parameters: offchain_receive_parameters, + } + + pub struct CallSelf { + pub address: AztecAddress, + pub context: Context, + } + + impl CallSelf { + pub fn _remove_liquidity(self, config: Config, liquidity: u128, token0_partial_note: PartialUintNote, token1_partial_note: PartialUintNote, amount0_min: u128, amount1_min: u128) { + let mut serialized_params: [Field; 8] = [0_Field; 8]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 3] = >::serialize(config); + let serialized_member_len: u32 = >::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(liquidity); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(token0_partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(token1_partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount0_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_4: u32 = i + offset; + serialized_params[i_4] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount1_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_5: u32 = i + offset; + serialized_params[i_5] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2270402407_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<17, 8, ()>::new(self.address, selector, "_remove_liquidity", serialized_params).call(self.context) + } + } + + pub fn _add_liquidity(self, config: Config, refund_token0_partial_note: PartialUintNote, refund_token1_partial_note: PartialUintNote, liquidity_partial_note: PartialUintNote, amount0_max: u128, amount1_max: u128, amount0_min: u128, amount1_min: u128) { + let mut serialized_params: [Field; 10] = [0_Field; 10]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 3] = >::serialize(config); + let serialized_member_len: u32 = >::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(refund_token0_partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(refund_token1_partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(liquidity_partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount0_max); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_4: u32 = i + offset; + serialized_params[i_4] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount1_max); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_5: u32 = i + offset; + serialized_params[i_5] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount0_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_6: u32 = i + offset; + serialized_params[i_6] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount1_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_7: u32 = i + offset; + serialized_params[i_7] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1909103841_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<14, 10, ()>::new(self.address, selector, "_add_liquidity", serialized_params).call(self.context) + } + } + + pub fn constructor(self, token0: AztecAddress, token1: AztecAddress, liquidity_token: AztecAddress) { + let mut serialized_params: [Field; 3] = [0_Field; 3]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(token0); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(token1); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(liquidity_token); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2287085075_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<11, 3, ()>::new(self.address, selector, "constructor", serialized_params).call(self.context) + } + } + + pub fn _swap_tokens_for_exact_tokens(self, token_in: AztecAddress, token_out: AztecAddress, amount_in_max: u128, amount_out: u128, change_token_in_partial_note: PartialUintNote, token_out_partial_note: PartialUintNote) { + let mut serialized_params: [Field; 6] = [0_Field; 6]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(token_in); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(token_out); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount_in_max); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount_out); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(change_token_in_partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_4: u32 = i + offset; + serialized_params[i_4] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(token_out_partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_5: u32 = i + offset; + serialized_params[i_5] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3156435103_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<29, 6, ()>::new(self.address, selector, "_swap_tokens_for_exact_tokens", serialized_params).call(self.context) + } + } + + pub fn _swap_exact_tokens_for_tokens(self, token_in: AztecAddress, token_out: AztecAddress, amount_in: u128, amount_out_min: u128, token_out_partial_note: PartialUintNote) { + let mut serialized_params: [Field; 5] = [0_Field; 5]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(token_in); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(token_out); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount_in); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount_out_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(token_out_partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_4: u32 = i + offset; + serialized_params[i_4] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1918288610_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<29, 5, ()>::new(self.address, selector, "_swap_exact_tokens_for_tokens", serialized_params).call(self.context) + } + } + } + + impl CallSelf<&mut aztec::context::PrivateContext> { + pub fn remove_liquidity(self, liquidity: u128, amount0_min: u128, amount1_min: u128, authwit_nonce: Field) { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(liquidity); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount0_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount1_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1221183968_Field); + let args_hash: Field = aztec::hash::hash_args(serialized_params); + aztec::oracle::execution_cache::store(serialized_params, args_hash); + let returns_hash: aztec::context::ReturnsHash = self.context.call_private_function_with_args_hash(self.address, selector, args_hash, false); + returns_hash.get_preimage() + } + + pub fn add_liquidity(self, amount0_max: u128, amount1_max: u128, amount0_min: u128, amount1_min: u128, authwit_nonce: Field) { + let mut serialized_params: [Field; 5] = [0_Field; 5]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(amount0_max); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount1_max); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount0_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount1_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_4: u32 = i + offset; + serialized_params[i_4] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3734879327_Field); + let args_hash: Field = aztec::hash::hash_args(serialized_params); + aztec::oracle::execution_cache::store(serialized_params, args_hash); + let returns_hash: aztec::context::ReturnsHash = self.context.call_private_function_with_args_hash(self.address, selector, args_hash, false); + returns_hash.get_preimage() + } + + pub fn swap_tokens_for_exact_tokens(self, token_in: AztecAddress, token_out: AztecAddress, amount_out: u128, amount_in_max: u128, authwit_nonce: Field) { + let mut serialized_params: [Field; 5] = [0_Field; 5]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(token_in); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(token_out); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount_out); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount_in_max); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_4: u32 = i + offset; + serialized_params[i_4] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2620890703_Field); + let args_hash: Field = aztec::hash::hash_args(serialized_params); + aztec::oracle::execution_cache::store(serialized_params, args_hash); + let returns_hash: aztec::context::ReturnsHash = self.context.call_private_function_with_args_hash(self.address, selector, args_hash, false); + returns_hash.get_preimage() + } + + pub fn swap_exact_tokens_for_tokens(self, token_in: AztecAddress, token_out: AztecAddress, amount_in: u128, amount_out_min: u128, authwit_nonce: Field) { + let mut serialized_params: [Field; 5] = [0_Field; 5]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(token_in); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(token_out); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount_in); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount_out_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_4: u32 = i + offset; + serialized_params[i_4] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2960373586_Field); + let args_hash: Field = aztec::hash::hash_args(serialized_params); + aztec::oracle::execution_cache::store(serialized_params, args_hash); + let returns_hash: aztec::context::ReturnsHash = self.context.call_private_function_with_args_hash(self.address, selector, args_hash, false); + returns_hash.get_preimage() + } + } + + pub struct CallSelfStatic { + pub address: AztecAddress, + pub context: Context, + } + + pub struct EnqueueSelf { + pub address: AztecAddress, + pub context: Context, + } + + impl EnqueueSelf<&mut aztec::context::PrivateContext> { + pub fn _remove_liquidity(self, config: Config, liquidity: u128, token0_partial_note: PartialUintNote, token1_partial_note: PartialUintNote, amount0_min: u128, amount1_min: u128) { + let mut serialized_params: [Field; 8] = [0_Field; 8]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 3] = >::serialize(config); + let serialized_member_len: u32 = >::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(liquidity); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(token0_partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(token1_partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount0_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_4: u32 = i + offset; + serialized_params[i_4] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount1_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_5: u32 = i + offset; + serialized_params[i_5] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2270402407_Field); + let calldata: [Field; 1 + 8] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn _swap_tokens_for_exact_tokens(self, token_in: AztecAddress, token_out: AztecAddress, amount_in_max: u128, amount_out: u128, change_token_in_partial_note: PartialUintNote, token_out_partial_note: PartialUintNote) { + let mut serialized_params: [Field; 6] = [0_Field; 6]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(token_in); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(token_out); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount_in_max); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount_out); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(change_token_in_partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_4: u32 = i + offset; + serialized_params[i_4] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(token_out_partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_5: u32 = i + offset; + serialized_params[i_5] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3156435103_Field); + let calldata: [Field; 1 + 6] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn _add_liquidity(self, config: Config, refund_token0_partial_note: PartialUintNote, refund_token1_partial_note: PartialUintNote, liquidity_partial_note: PartialUintNote, amount0_max: u128, amount1_max: u128, amount0_min: u128, amount1_min: u128) { + let mut serialized_params: [Field; 10] = [0_Field; 10]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 3] = >::serialize(config); + let serialized_member_len: u32 = >::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(refund_token0_partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(refund_token1_partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(liquidity_partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount0_max); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_4: u32 = i + offset; + serialized_params[i_4] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount1_max); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_5: u32 = i + offset; + serialized_params[i_5] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount0_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_6: u32 = i + offset; + serialized_params[i_6] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount1_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_7: u32 = i + offset; + serialized_params[i_7] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1909103841_Field); + let calldata: [Field; 1 + 10] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn _swap_exact_tokens_for_tokens(self, token_in: AztecAddress, token_out: AztecAddress, amount_in: u128, amount_out_min: u128, token_out_partial_note: PartialUintNote) { + let mut serialized_params: [Field; 5] = [0_Field; 5]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(token_in); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(token_out); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount_in); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount_out_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(token_out_partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_4: u32 = i + offset; + serialized_params[i_4] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1918288610_Field); + let calldata: [Field; 1 + 5] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn constructor(self, token0: AztecAddress, token1: AztecAddress, liquidity_token: AztecAddress) { + let mut serialized_params: [Field; 3] = [0_Field; 3]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(token0); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(token1); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(liquidity_token); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2287085075_Field); + let calldata: [Field; 1 + 3] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + } + + pub struct EnqueueSelfStatic { + pub address: AztecAddress, + pub context: Context, + } + + pub struct CallSelfUtility { + pub address: AztecAddress, + } + + impl CallSelfUtility { + pub unconstrained fn get_amount_out_for_exact_in(self, balance_in: u128, balance_out: u128, amount_in: u128) -> u128 { + let mut serialized_params: [Field; 3] = [0_Field; 3]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(balance_in); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(balance_out); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount_in); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(58321933_Field); + let returns: [Field; 1] = aztec::oracle::call_utility_function::call_utility_function(self.address, selector, serialized_params); + ::deserialize(returns) + } + + pub unconstrained fn get_amount_in_for_exact_out(self, balance_in: u128, balance_out: u128, amount_out: u128) -> u128 { + let mut serialized_params: [Field; 3] = [0_Field; 3]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(balance_in); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(balance_out); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount_out); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(4155151179_Field); + let returns: [Field; 1] = aztec::oracle::call_utility_function::call_utility_function(self.address, selector, serialized_params); + ::deserialize(returns) + } + } + + pub struct CallInternal { + pub context: Context, + } + + pub unconstrained fn public_dispatch(selector: Field) { + if selector == 2287085075_Field { + let input_calldata: [Field; 3] = aztec::oracle::avm::calldata_copy(1_u32, (::N + ::N) + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<3> = aztec::protocol::utils::reader::Reader::<3>::new(input_calldata); + let arg0: AztecAddress = ::stream_deserialize(&mut reader); + let arg1: AztecAddress = ::stream_deserialize(&mut reader); + let arg2: AztecAddress = ::stream_deserialize(&mut reader); + __aztec_nr_internals__constructor(arg0, arg1, arg2); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 1909103841_Field { + let input_calldata: [Field; 10] = aztec::oracle::avm::calldata_copy(1_u32, ((((((>::N + ::N) + ::N) + ::N) + ::N) + ::N) + ::N) + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<10> = aztec::protocol::utils::reader::Reader::<10>::new(input_calldata); + let arg0: Config = >::stream_deserialize(&mut reader); + let arg1: PartialUintNote = ::stream_deserialize(&mut reader); + let arg2: PartialUintNote = ::stream_deserialize(&mut reader); + let arg3: PartialUintNote = ::stream_deserialize(&mut reader); + let arg4: u128 = ::stream_deserialize(&mut reader); + let arg5: u128 = ::stream_deserialize(&mut reader); + let arg6: u128 = ::stream_deserialize(&mut reader); + let arg7: u128 = ::stream_deserialize(&mut reader); + __aztec_nr_internals___add_liquidity(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 2270402407_Field { + let input_calldata: [Field; 8] = aztec::oracle::avm::calldata_copy(1_u32, ((((>::N + ::N) + ::N) + ::N) + ::N) + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<8> = aztec::protocol::utils::reader::Reader::<8>::new(input_calldata); + let arg0: Config = >::stream_deserialize(&mut reader); + let arg1: u128 = ::stream_deserialize(&mut reader); + let arg2: PartialUintNote = ::stream_deserialize(&mut reader); + let arg3: PartialUintNote = ::stream_deserialize(&mut reader); + let arg4: u128 = ::stream_deserialize(&mut reader); + let arg5: u128 = ::stream_deserialize(&mut reader); + __aztec_nr_internals___remove_liquidity(arg0, arg1, arg2, arg3, arg4, arg5); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 1918288610_Field { + let input_calldata: [Field; 5] = aztec::oracle::avm::calldata_copy(1_u32, (((::N + ::N) + ::N) + ::N) + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<5> = aztec::protocol::utils::reader::Reader::<5>::new(input_calldata); + let arg0: AztecAddress = ::stream_deserialize(&mut reader); + let arg1: AztecAddress = ::stream_deserialize(&mut reader); + let arg2: u128 = ::stream_deserialize(&mut reader); + let arg3: u128 = ::stream_deserialize(&mut reader); + let arg4: PartialUintNote = ::stream_deserialize(&mut reader); + __aztec_nr_internals___swap_exact_tokens_for_tokens(arg0, arg1, arg2, arg3, arg4); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 3156435103_Field { + let input_calldata: [Field; 6] = aztec::oracle::avm::calldata_copy(1_u32, ((((::N + ::N) + ::N) + ::N) + ::N) + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<6> = aztec::protocol::utils::reader::Reader::<6>::new(input_calldata); + let arg0: AztecAddress = ::stream_deserialize(&mut reader); + let arg1: AztecAddress = ::stream_deserialize(&mut reader); + let arg2: u128 = ::stream_deserialize(&mut reader); + let arg3: u128 = ::stream_deserialize(&mut reader); + let arg4: PartialUintNote = ::stream_deserialize(&mut reader); + let arg5: PartialUintNote = ::stream_deserialize(&mut reader); + __aztec_nr_internals___swap_tokens_for_exact_tokens(arg0, arg1, arg2, arg3, arg4, arg5); + aztec::oracle::avm::avm_return([].as_slice()); + }; + panic(f"Unknown selector {selector}") + } + + pub struct _add_liquidity_parameters { + pub config: Config, + pub refund_token0_partial_note: PartialUintNote, + pub refund_token1_partial_note: PartialUintNote, + pub liquidity_partial_note: PartialUintNote, + pub amount0_max: u128, + pub amount1_max: u128, + pub amount0_min: u128, + pub amount1_min: u128, + } + + pub struct _remove_liquidity_parameters { + pub config: Config, + pub liquidity: u128, + pub token0_partial_note: PartialUintNote, + pub token1_partial_note: PartialUintNote, + pub amount0_min: u128, + pub amount1_min: u128, + } + + pub struct _swap_exact_tokens_for_tokens_parameters { + pub token_in: AztecAddress, + pub token_out: AztecAddress, + pub amount_in: u128, + pub amount_out_min: u128, + pub token_out_partial_note: PartialUintNote, + } + + pub struct _swap_tokens_for_exact_tokens_parameters { + pub token_in: AztecAddress, + pub token_out: AztecAddress, + pub amount_in_max: u128, + pub amount_out: u128, + pub change_token_in_partial_note: PartialUintNote, + pub token_out_partial_note: PartialUintNote, + } + + pub struct add_liquidity_parameters { + pub amount0_max: u128, + pub amount1_max: u128, + pub amount0_min: u128, + pub amount1_min: u128, + pub authwit_nonce: Field, + } + + pub struct constructor_parameters { + pub token0: AztecAddress, + pub token1: AztecAddress, + pub liquidity_token: AztecAddress, + } + + pub struct get_amount_in_for_exact_out_parameters { + pub balance_in: u128, + pub balance_out: u128, + pub amount_out: u128, + } + + pub struct get_amount_out_for_exact_in_parameters { + pub balance_in: u128, + pub balance_out: u128, + pub amount_in: u128, + } + + pub struct remove_liquidity_parameters { + pub liquidity: u128, + pub amount0_min: u128, + pub amount1_min: u128, + pub authwit_nonce: Field, + } + + pub struct swap_exact_tokens_for_tokens_parameters { + pub token_in: AztecAddress, + pub token_out: AztecAddress, + pub amount_in: u128, + pub amount_out_min: u128, + pub authwit_nonce: Field, + } + + pub struct swap_tokens_for_exact_tokens_parameters { + pub token_in: AztecAddress, + pub token_out: AztecAddress, + pub amount_out: u128, + pub amount_in_max: u128, + pub authwit_nonce: Field, + } + + #[abi(functions)] + pub struct _add_liquidity_abi { + parameters: _add_liquidity_parameters, + } + + #[abi(functions)] + pub struct _remove_liquidity_abi { + parameters: _remove_liquidity_parameters, + } + + #[abi(functions)] + pub struct _swap_exact_tokens_for_tokens_abi { + parameters: _swap_exact_tokens_for_tokens_parameters, + } + + #[abi(functions)] + pub struct _swap_tokens_for_exact_tokens_abi { + parameters: _swap_tokens_for_exact_tokens_parameters, + } + + #[abi(functions)] + pub struct add_liquidity_abi { + parameters: add_liquidity_parameters, + } + + #[abi(functions)] + pub struct constructor_abi { + parameters: constructor_parameters, + } + + #[abi(functions)] + pub struct get_amount_in_for_exact_out_abi { + parameters: get_amount_in_for_exact_out_parameters, + return_type: u128, + } + + #[abi(functions)] + pub struct get_amount_out_for_exact_in_abi { + parameters: get_amount_out_for_exact_in_parameters, + return_type: u128, + } + + #[abi(functions)] + pub struct remove_liquidity_abi { + parameters: remove_liquidity_parameters, + } + + #[abi(functions)] + pub struct swap_exact_tokens_for_tokens_abi { + parameters: swap_exact_tokens_for_tokens_parameters, + } + + #[abi(functions)] + pub struct swap_tokens_for_exact_tokens_abi { + parameters: swap_tokens_for_exact_tokens_parameters, + } + + fn __aztec_nr_internals__add_liquidity(inputs: aztec::context::inputs::PrivateContextInputs, amount0_max: u128, amount1_max: u128, amount0_min: u128, amount1_min: u128, authwit_nonce: Field) -> return_data aztec::protocol::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs { + aztec::oracle::version::assert_compatible_oracle_version(); + let mut self: aztec::contract_self::contract_self_private::ContractSelfPrivate, CallSelf<&mut aztec::context::PrivateContext>, EnqueueSelf<&mut aztec::context::PrivateContext>, CallSelfStatic<&mut aztec::context::PrivateContext>, EnqueueSelfStatic<&mut aztec::context::PrivateContext>, CallInternal<&mut aztec::context::PrivateContext>, CallSelfUtility> = { + let mut serialized_params: [Field; 5] = [0_Field; 5]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(amount0_max); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount1_max); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount0_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount1_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_4: u32 = i + offset; + serialized_params[i_4] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let args_hash: Field = aztec::hash::hash_args(serialized_params); + let mut context: aztec::context::PrivateContext = aztec::context::PrivateContext::new(inputs, args_hash); + let storage: Storage<&mut aztec::context::PrivateContext> = Storage::<&mut aztec::context::PrivateContext>::init(&mut context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf<&mut aztec::context::PrivateContext> = CallSelf::<&mut aztec::context::PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self: EnqueueSelf<&mut aztec::context::PrivateContext> = EnqueueSelf::<&mut aztec::context::PrivateContext> { address: self_address, context: &mut context}; + let call_self_static: CallSelfStatic<&mut aztec::context::PrivateContext> = CallSelfStatic::<&mut aztec::context::PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self_static: EnqueueSelfStatic<&mut aztec::context::PrivateContext> = EnqueueSelfStatic::<&mut aztec::context::PrivateContext> { address: self_address, context: &mut context}; + let internal: CallInternal<&mut aztec::context::PrivateContext> = CallInternal::<&mut aztec::context::PrivateContext> { context: &mut context}; + let call_self_utility: CallSelfUtility = CallSelfUtility { address: self_address}; + let utility: aztec::contract_self::contract_self_private::PrivateUtilityCalls = aztec::contract_self::contract_self_private::PrivateUtilityCalls:: { call_self: call_self_utility}; + aztec::contract_self::contract_self_private::ContractSelfPrivate::, CallSelf<&mut aztec::context::PrivateContext>, EnqueueSelf<&mut aztec::context::PrivateContext>, CallSelfStatic<&mut aztec::context::PrivateContext>, EnqueueSelfStatic<&mut aztec::context::PrivateContext>, CallInternal<&mut aztec::context::PrivateContext>, CallSelfUtility>::new(&mut context, storage, call_self, enqueue_self, call_self_static, enqueue_self_static, internal, utility) + }; + let within_revertible_phase: bool = self.context.in_revertible_phase(); + aztec::macros::functions::initialization_utils::assert_is_initialized_private(self.context); + assert((amount0_min < amount0_max) | (amount0_min == amount0_max), "INCORRECT_TOKEN0_LIMITS"); + assert((amount1_min < amount1_max) | (amount1_min == amount1_max), "INCORRECT_TOKEN1_LIMITS"); + assert(((0_Field as u128) < amount0_max) & ((0_Field as u128) < amount1_max), "INSUFFICIENT_INPUT_AMOUNTS"); + let config: Config = self.storage.config.read(); + let token0: Token::Token = Token::at(config.token0); + let token1: Token::Token = Token::at(config.token1); + let liquidity_token: Token::Token = Token::at(config.liquidity_token); + let sender: AztecAddress = self.msg_sender(); + let refund_token0_partial_note: PartialUintNote = self.call(token0.transfer_to_public_and_prepare_private_balance_increase(sender, self.address, amount0_max, authwit_nonce)); + let refund_token1_partial_note: PartialUintNote = self.call(token1.transfer_to_public_and_prepare_private_balance_increase(sender, self.address, amount1_max, authwit_nonce)); + let liquidity_partial_note: PartialUintNote = self.call(liquidity_token.prepare_private_balance_increase(sender)); + self.enqueue_self._add_liquidity(config, refund_token0_partial_note, refund_token1_partial_note, liquidity_partial_note, amount0_max, amount1_max, amount0_min, amount1_min); + assert(within_revertible_phase == self.context.in_revertible_phase(), f"Phase change detected on function with phase check. If this is expected, use #[allow_phase_change]"); + self.context.finish() + } + + fn __aztec_nr_internals__remove_liquidity(inputs: aztec::context::inputs::PrivateContextInputs, liquidity: u128, amount0_min: u128, amount1_min: u128, authwit_nonce: Field) -> return_data aztec::protocol::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs { + aztec::oracle::version::assert_compatible_oracle_version(); + let mut self: aztec::contract_self::contract_self_private::ContractSelfPrivate, CallSelf<&mut aztec::context::PrivateContext>, EnqueueSelf<&mut aztec::context::PrivateContext>, CallSelfStatic<&mut aztec::context::PrivateContext>, EnqueueSelfStatic<&mut aztec::context::PrivateContext>, CallInternal<&mut aztec::context::PrivateContext>, CallSelfUtility> = { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(liquidity); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount0_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount1_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let args_hash: Field = aztec::hash::hash_args(serialized_params); + let mut context: aztec::context::PrivateContext = aztec::context::PrivateContext::new(inputs, args_hash); + let storage: Storage<&mut aztec::context::PrivateContext> = Storage::<&mut aztec::context::PrivateContext>::init(&mut context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf<&mut aztec::context::PrivateContext> = CallSelf::<&mut aztec::context::PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self: EnqueueSelf<&mut aztec::context::PrivateContext> = EnqueueSelf::<&mut aztec::context::PrivateContext> { address: self_address, context: &mut context}; + let call_self_static: CallSelfStatic<&mut aztec::context::PrivateContext> = CallSelfStatic::<&mut aztec::context::PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self_static: EnqueueSelfStatic<&mut aztec::context::PrivateContext> = EnqueueSelfStatic::<&mut aztec::context::PrivateContext> { address: self_address, context: &mut context}; + let internal: CallInternal<&mut aztec::context::PrivateContext> = CallInternal::<&mut aztec::context::PrivateContext> { context: &mut context}; + let call_self_utility: CallSelfUtility = CallSelfUtility { address: self_address}; + let utility: aztec::contract_self::contract_self_private::PrivateUtilityCalls = aztec::contract_self::contract_self_private::PrivateUtilityCalls:: { call_self: call_self_utility}; + aztec::contract_self::contract_self_private::ContractSelfPrivate::, CallSelf<&mut aztec::context::PrivateContext>, EnqueueSelf<&mut aztec::context::PrivateContext>, CallSelfStatic<&mut aztec::context::PrivateContext>, EnqueueSelfStatic<&mut aztec::context::PrivateContext>, CallInternal<&mut aztec::context::PrivateContext>, CallSelfUtility>::new(&mut context, storage, call_self, enqueue_self, call_self_static, enqueue_self_static, internal, utility) + }; + let within_revertible_phase: bool = self.context.in_revertible_phase(); + aztec::macros::functions::initialization_utils::assert_is_initialized_private(self.context); + let config: Config = self.storage.config.read(); + let liquidity_token: Token::Token = Token::at(config.liquidity_token); + let token0: Token::Token = Token::at(config.token0); + let token1: Token::Token = Token::at(config.token1); + let sender: AztecAddress = self.msg_sender(); + self.call(liquidity_token.transfer_to_public(sender, self.address, liquidity, authwit_nonce)); + let token0_partial_note: PartialUintNote = self.call(token0.prepare_private_balance_increase(sender)); + let token1_partial_note: PartialUintNote = self.call(token1.prepare_private_balance_increase(sender)); + self.enqueue_self._remove_liquidity(config, liquidity, token0_partial_note, token1_partial_note, amount0_min, amount1_min); + assert(within_revertible_phase == self.context.in_revertible_phase(), f"Phase change detected on function with phase check. If this is expected, use #[allow_phase_change]"); + self.context.finish() + } + + fn __aztec_nr_internals__swap_exact_tokens_for_tokens(inputs: aztec::context::inputs::PrivateContextInputs, token_in: AztecAddress, token_out: AztecAddress, amount_in: u128, amount_out_min: u128, authwit_nonce: Field) -> return_data aztec::protocol::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs { + aztec::oracle::version::assert_compatible_oracle_version(); + let mut self: aztec::contract_self::contract_self_private::ContractSelfPrivate, CallSelf<&mut aztec::context::PrivateContext>, EnqueueSelf<&mut aztec::context::PrivateContext>, CallSelfStatic<&mut aztec::context::PrivateContext>, EnqueueSelfStatic<&mut aztec::context::PrivateContext>, CallInternal<&mut aztec::context::PrivateContext>, CallSelfUtility> = { + let mut serialized_params: [Field; 5] = [0_Field; 5]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(token_in); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(token_out); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount_in); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount_out_min); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_4: u32 = i + offset; + serialized_params[i_4] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let args_hash: Field = aztec::hash::hash_args(serialized_params); + let mut context: aztec::context::PrivateContext = aztec::context::PrivateContext::new(inputs, args_hash); + let storage: Storage<&mut aztec::context::PrivateContext> = Storage::<&mut aztec::context::PrivateContext>::init(&mut context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf<&mut aztec::context::PrivateContext> = CallSelf::<&mut aztec::context::PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self: EnqueueSelf<&mut aztec::context::PrivateContext> = EnqueueSelf::<&mut aztec::context::PrivateContext> { address: self_address, context: &mut context}; + let call_self_static: CallSelfStatic<&mut aztec::context::PrivateContext> = CallSelfStatic::<&mut aztec::context::PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self_static: EnqueueSelfStatic<&mut aztec::context::PrivateContext> = EnqueueSelfStatic::<&mut aztec::context::PrivateContext> { address: self_address, context: &mut context}; + let internal: CallInternal<&mut aztec::context::PrivateContext> = CallInternal::<&mut aztec::context::PrivateContext> { context: &mut context}; + let call_self_utility: CallSelfUtility = CallSelfUtility { address: self_address}; + let utility: aztec::contract_self::contract_self_private::PrivateUtilityCalls = aztec::contract_self::contract_self_private::PrivateUtilityCalls:: { call_self: call_self_utility}; + aztec::contract_self::contract_self_private::ContractSelfPrivate::, CallSelf<&mut aztec::context::PrivateContext>, EnqueueSelf<&mut aztec::context::PrivateContext>, CallSelfStatic<&mut aztec::context::PrivateContext>, EnqueueSelfStatic<&mut aztec::context::PrivateContext>, CallInternal<&mut aztec::context::PrivateContext>, CallSelfUtility>::new(&mut context, storage, call_self, enqueue_self, call_self_static, enqueue_self_static, internal, utility) + }; + let within_revertible_phase: bool = self.context.in_revertible_phase(); + aztec::macros::functions::initialization_utils::assert_is_initialized_private(self.context); + let config: Config = self.storage.config.read(); + assert((token_in == config.token0) | (token_in == config.token1), "TOKEN_IN_IS_INVALID"); + assert((token_out == config.token0) | (token_out == config.token1), "TOKEN_OUT_IS_INVALID"); + assert(token_in != token_out, "SAME_TOKEN_SWAP"); + let sender: AztecAddress = self.msg_sender(); + self.call(Token::at(token_in).transfer_to_public(sender, self.address, amount_in, authwit_nonce)); + let token_out_partial_note: PartialUintNote = self.call(Token::at(token_out).prepare_private_balance_increase(sender)); + self.enqueue_self._swap_exact_tokens_for_tokens(token_in, token_out, amount_in, amount_out_min, token_out_partial_note); + assert(within_revertible_phase == self.context.in_revertible_phase(), f"Phase change detected on function with phase check. If this is expected, use #[allow_phase_change]"); + self.context.finish() + } + + fn __aztec_nr_internals__swap_tokens_for_exact_tokens(inputs: aztec::context::inputs::PrivateContextInputs, token_in: AztecAddress, token_out: AztecAddress, amount_out: u128, amount_in_max: u128, authwit_nonce: Field) -> return_data aztec::protocol::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs { + aztec::oracle::version::assert_compatible_oracle_version(); + let mut self: aztec::contract_self::contract_self_private::ContractSelfPrivate, CallSelf<&mut aztec::context::PrivateContext>, EnqueueSelf<&mut aztec::context::PrivateContext>, CallSelfStatic<&mut aztec::context::PrivateContext>, EnqueueSelfStatic<&mut aztec::context::PrivateContext>, CallInternal<&mut aztec::context::PrivateContext>, CallSelfUtility> = { + let mut serialized_params: [Field; 5] = [0_Field; 5]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(token_in); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(token_out); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount_out); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount_in_max); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_4: u32 = i + offset; + serialized_params[i_4] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let args_hash: Field = aztec::hash::hash_args(serialized_params); + let mut context: aztec::context::PrivateContext = aztec::context::PrivateContext::new(inputs, args_hash); + let storage: Storage<&mut aztec::context::PrivateContext> = Storage::<&mut aztec::context::PrivateContext>::init(&mut context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf<&mut aztec::context::PrivateContext> = CallSelf::<&mut aztec::context::PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self: EnqueueSelf<&mut aztec::context::PrivateContext> = EnqueueSelf::<&mut aztec::context::PrivateContext> { address: self_address, context: &mut context}; + let call_self_static: CallSelfStatic<&mut aztec::context::PrivateContext> = CallSelfStatic::<&mut aztec::context::PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self_static: EnqueueSelfStatic<&mut aztec::context::PrivateContext> = EnqueueSelfStatic::<&mut aztec::context::PrivateContext> { address: self_address, context: &mut context}; + let internal: CallInternal<&mut aztec::context::PrivateContext> = CallInternal::<&mut aztec::context::PrivateContext> { context: &mut context}; + let call_self_utility: CallSelfUtility = CallSelfUtility { address: self_address}; + let utility: aztec::contract_self::contract_self_private::PrivateUtilityCalls = aztec::contract_self::contract_self_private::PrivateUtilityCalls:: { call_self: call_self_utility}; + aztec::contract_self::contract_self_private::ContractSelfPrivate::, CallSelf<&mut aztec::context::PrivateContext>, EnqueueSelf<&mut aztec::context::PrivateContext>, CallSelfStatic<&mut aztec::context::PrivateContext>, EnqueueSelfStatic<&mut aztec::context::PrivateContext>, CallInternal<&mut aztec::context::PrivateContext>, CallSelfUtility>::new(&mut context, storage, call_self, enqueue_self, call_self_static, enqueue_self_static, internal, utility) + }; + let within_revertible_phase: bool = self.context.in_revertible_phase(); + aztec::macros::functions::initialization_utils::assert_is_initialized_private(self.context); + let config: Config = self.storage.config.read(); + assert((token_in == config.token0) | (token_in == config.token1), "TOKEN_IN_IS_INVALID"); + assert((token_out == config.token0) | (token_out == config.token1), "TOKEN_OUT_IS_INVALID"); + assert(token_in != token_out, "SAME_TOKEN_SWAP"); + let sender: AztecAddress = self.msg_sender(); + let change_token_in_partial_note: PartialUintNote = self.call(Token::at(token_in).transfer_to_public_and_prepare_private_balance_increase(sender, self.address, amount_in_max, authwit_nonce)); + let token_out_partial_note: PartialUintNote = self.call(Token::at(token_out).prepare_private_balance_increase(sender)); + self.enqueue_self._swap_tokens_for_exact_tokens(token_in, token_out, amount_in_max, amount_out, change_token_in_partial_note, token_out_partial_note); + assert(within_revertible_phase == self.context.in_revertible_phase(), f"Phase change detected on function with phase check. If this is expected, use #[allow_phase_change]"); + self.context.finish() + } + + unconstrained fn __aztec_nr_internals___add_liquidity(config: Config, refund_token0_partial_note: PartialUintNote, refund_token1_partial_note: PartialUintNote, liquidity_partial_note: PartialUintNote, amount0_max: u128, amount1_max: u128, amount0_min: u128, amount1_min: u128) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 10] = aztec::oracle::avm::calldata_copy(1_u32, ((((((>::N + ::N) + ::N) + ::N) + ::N) + ::N) + ::N) + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + assert(self.msg_sender() == self.address, "Function _add_liquidity can only be called by the same contract"); + { + let token0: Token::Token = Token::at(config.token0); + let token1: Token::Token = Token::at(config.token1); + let liquidity_token: Token::Token = Token::at(config.liquidity_token); + let balance0_plus_amount0_max: u128 = self.view(token0.balance_of_public(self.address)); + let balance0: u128 = balance0_plus_amount0_max - amount0_max; + let balance1_plus_amount1_max: u128 = self.view(token1.balance_of_public(self.address)); + let balance1: u128 = balance1_plus_amount1_max - amount1_max; + let (amount0, amount1): (u128, u128) = get_amounts_to_add(amount0_max, amount1_max, amount0_min, amount1_min, balance0, balance1); + let refund_amount_token0: u128 = amount0_max - amount0; + let refund_amount_token1: u128 = amount1_max - amount1; + if refund_amount_token0 > (0_Field as u128) { + self.call(token0.finalize_transfer_to_private(refund_amount_token0, refund_token0_partial_note)); + }; + if refund_amount_token1 > (0_Field as u128) { + self.call(token1.finalize_transfer_to_private(refund_amount_token1, refund_token1_partial_note)); + }; + let total_supply: u128 = self.view(liquidity_token.total_supply()); + let liquidity_amount: u128 = if total_supply != (0_Field as u128) { + std::cmp::min((amount0 * total_supply) / balance0, (amount1 * total_supply) / balance1) + } else { + liquidity_token.mint_to_public(AztecAddress::zero(), MINIMUM_LIQUIDITY).call(self.context); + INITIAL_LIQUIDITY + }; + assert(liquidity_amount > (0_Field as u128), "INSUFFICIENT_LIQUIDITY_MINTED"); + liquidity_token.finalize_mint_to_private(liquidity_amount, liquidity_partial_note).call(self.context); + } + } + + unconstrained fn __aztec_nr_internals___remove_liquidity(config: Config, liquidity: u128, token0_partial_note: PartialUintNote, token1_partial_note: PartialUintNote, amount0_min: u128, amount1_min: u128) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 8] = aztec::oracle::avm::calldata_copy(1_u32, ((((>::N + ::N) + ::N) + ::N) + ::N) + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + assert(self.msg_sender() == self.address, "Function _remove_liquidity can only be called by the same contract"); + { + let token0: Token::Token = Token::at(config.token0); + let token1: Token::Token = Token::at(config.token1); + let liquidity_token: Token::Token = Token::at(config.liquidity_token); + let balance0: u128 = self.view(token0.balance_of_public(self.address)); + let balance1: u128 = self.view(token1.balance_of_public(self.address)); + let total_supply: u128 = self.view(liquidity_token.total_supply()); + let (amount0, amount1): (u128, u128) = get_amounts_on_remove(liquidity, total_supply, balance0, balance1); + assert(amount0 >= amount0_min, "INSUFFICIENT_0_AMOUNT"); + assert(amount1 >= amount1_min, "INSUFFICIENT_1_AMOUNT"); + self.call(liquidity_token.burn_public(self.address, liquidity, 0_Field)); + self.call(token0.finalize_transfer_to_private(amount0, token0_partial_note)); + self.call(token1.finalize_transfer_to_private(amount1, token1_partial_note)); + } + } + + unconstrained fn __aztec_nr_internals___swap_exact_tokens_for_tokens(token_in: AztecAddress, token_out: AztecAddress, amount_in: u128, amount_out_min: u128, token_out_partial_note: PartialUintNote) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 5] = aztec::oracle::avm::calldata_copy(1_u32, (((::N + ::N) + ::N) + ::N) + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + assert(self.msg_sender() == self.address, "Function _swap_exact_tokens_for_tokens can only be called by the same contract"); + { + let balance_in_plus_amount_in: u128 = self.view(Token::at(token_in).balance_of_public(self.address)); + let balance_in: u128 = balance_in_plus_amount_in - amount_in; + let balance_out: u128 = self.view(Token::at(token_out).balance_of_public(self.address)); + let amount_out: u128 = get_amount_out(amount_in, balance_in, balance_out); + assert(amount_out >= amount_out_min, "INSUFFICIENT_OUTPUT_AMOUNT"); + Token::at(token_out).finalize_transfer_to_private(amount_out, token_out_partial_note).call(self.context); + } + } + + unconstrained fn __aztec_nr_internals___swap_tokens_for_exact_tokens(token_in: AztecAddress, token_out: AztecAddress, amount_in_max: u128, amount_out: u128, change_token_in_partial_note: PartialUintNote, token_out_partial_note: PartialUintNote) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 6] = aztec::oracle::avm::calldata_copy(1_u32, ((((::N + ::N) + ::N) + ::N) + ::N) + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + assert(self.msg_sender() == self.address, "Function _swap_tokens_for_exact_tokens can only be called by the same contract"); + { + let balance_in_plus_amount_in_max: u128 = self.view(Token::at(token_in).balance_of_public(self.address)); + let balance_in: u128 = balance_in_plus_amount_in_max - amount_in_max; + let balance_out: u128 = self.view(Token::at(token_out).balance_of_public(self.address)); + let amount_in: u128 = get_amount_in(amount_out, balance_in, balance_out); + assert(amount_in <= amount_in_max, "INSUFFICIENT_OUTPUT_AMOUNT"); + let change: u128 = amount_in_max - amount_in; + if change > (0_Field as u128) { + self.call(Token::at(token_in).finalize_transfer_to_private(change, change_token_in_partial_note)); + }; + Token::at(token_out).finalize_transfer_to_private(amount_out, token_out_partial_note).call(self.context); + } + } + + unconstrained fn __aztec_nr_internals__constructor(token0: AztecAddress, token1: AztecAddress, liquidity_token: AztecAddress) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 3] = aztec::oracle::avm::calldata_copy(1_u32, (::N + ::N) + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + aztec::macros::functions::initialization_utils::assert_initialization_matches_address_preimage_public(self.context); + { + self.storage.config.initialize(Config { token0: token0, token1: token1, liquidity_token: liquidity_token}); + }; + aztec::macros::functions::initialization_utils::mark_as_initialized_from_public_initializer(self.context); + } + + unconstrained fn __aztec_nr_internals__get_amount_in_for_exact_out(balance_in: u128, balance_out: u128, amount_out: u128) -> pub u128 { + aztec::oracle::version::assert_compatible_oracle_version(); + let mut self: aztec::contract_self::contract_self_utility::ContractSelfUtility, CallSelfUtility> = { + let context: aztec::context::UtilityContext = aztec::context::UtilityContext::new(); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelfUtility = CallSelfUtility { address: self_address}; + aztec::contract_self::contract_self_utility::ContractSelfUtility::, CallSelfUtility>::new(context, storage, call_self) + }; + aztec::macros::functions::initialization_utils::assert_is_initialized_utility(self.context); + { + get_amount_in(amount_out, balance_in, balance_out) + } + } + + unconstrained fn __aztec_nr_internals__get_amount_out_for_exact_in(balance_in: u128, balance_out: u128, amount_in: u128) -> pub u128 { + aztec::oracle::version::assert_compatible_oracle_version(); + let mut self: aztec::contract_self::contract_self_utility::ContractSelfUtility, CallSelfUtility> = { + let context: aztec::context::UtilityContext = aztec::context::UtilityContext::new(); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelfUtility = CallSelfUtility { address: self_address}; + aztec::contract_self::contract_self_utility::ContractSelfUtility::, CallSelfUtility>::new(context, storage, call_self) + }; + aztec::macros::functions::initialization_utils::assert_is_initialized_utility(self.context); + { + get_amount_out(amount_in, balance_in, balance_out) + } + } + + pub struct StorageLayoutFields { + pub config: aztec::state_vars::Storable, + } + + pub struct StorageLayout { + pub contract_name: str, + pub fields: StorageLayoutFields, + } +} + +mod test { + mod test { + use crate::AMM; + use super::utils::add_liquidity; + use super::utils::remove_liquidity; + use super::utils::setup; + use aztec::protocol::address::AztecAddress; + use aztec::protocol::traits::FromField; + use aztec::test::helpers::authwit::add_private_authwit_from_call; + use token::Token; + + global AUTHWIT_NONCE: Field = 0x01; + + global DEFAULT_AMOUNT_0_MIN: u128 = 0; + + global DEFAULT_AMOUNT_1_MIN: u128 = 0; + + #[test] + unconstrained fn add_liquidity_twice_and_remove_liquidity() { + let (mut env, amm_address, token0_address, token1_address, liquidity_token_address, minter): (aztec::test::helpers::test_environment::TestEnvironment, AztecAddress, AztecAddress, AztecAddress, AztecAddress, AztecAddress) = setup(); + let liquidity_provider_1: AztecAddress = env.create_contract_account(); + let liquidity_provider_2: AztecAddress = env.create_contract_account(); + let token0: Token::Token = Token::at(token0_address); + let token1: Token::Token = Token::at(token1_address); + let liquidity_token: Token::Token = Token::at(liquidity_token_address); + let initial_amount0: u128 = 1000_Field as u128; + let initial_amount1: u128 = 2000_Field as u128; + add_liquidity(env, amm_address, token0_address, token1_address, minter, liquidity_provider_1, initial_amount0, initial_amount1, DEFAULT_AMOUNT_0_MIN, DEFAULT_AMOUNT_1_MIN); + let initial_liquidity_token_supply: u128 = env.view_public(liquidity_token.total_supply()); + assert(initial_liquidity_token_supply == (AMM::MINIMUM_LIQUIDITY + AMM::INITIAL_LIQUIDITY)); + let expected_amount_0_in: u128 = initial_amount0 / 2_u128; + let expected_amount_1_in: u128 = initial_amount1 / 2_u128; + let expected_refund_amount1: u128 = 200_Field as u128; + let amount1_max: u128 = expected_amount_1_in + expected_refund_amount1; + add_liquidity(env, amm_address, token0_address, token1_address, minter, liquidity_provider_2, expected_amount_0_in, amount1_max, DEFAULT_AMOUNT_0_MIN, DEFAULT_AMOUNT_1_MIN); + assert(env.view_public(token0.balance_of_public(amm_address)) == (initial_amount0 + expected_amount_0_in)); + assert(env.view_public(token1.balance_of_public(amm_address)) == (initial_amount1 + expected_amount_1_in)); + assert(env.execute_utility(token0.balance_of_private(liquidity_provider_2)) == 0_u128); + assert(env.execute_utility(token1.balance_of_private(liquidity_provider_2)) == expected_refund_amount1); + let expected_liquidity_tokens: u128 = (expected_amount_0_in * initial_liquidity_token_supply) / initial_amount0; + assert(env.execute_utility(liquidity_token.balance_of_private(liquidity_provider_2)) == expected_liquidity_tokens); + let liquidity_to_remove: u128 = AMM::INITIAL_LIQUIDITY / 2_u128; + let amount0_min: u128 = 400_Field as u128; + let amount1_min: u128 = 800_Field as u128; + remove_liquidity(env, amm_address, liquidity_token_address, liquidity_provider_1, liquidity_to_remove, amount0_min, amount1_min); + let expected_token0_back: u128 = (liquidity_to_remove * initial_amount0) / initial_liquidity_token_supply; + let expected_token1_back: u128 = (liquidity_to_remove * initial_amount1) / initial_liquidity_token_supply; + assert(env.execute_utility(token0.balance_of_private(liquidity_provider_1)) == expected_token0_back); + assert(env.execute_utility(token1.balance_of_private(liquidity_provider_1)) == expected_token1_back); + assert(env.execute_utility(liquidity_token.balance_of_private(liquidity_provider_1)) == (AMM::INITIAL_LIQUIDITY / 2_u128)); + } + + #[test] + unconstrained fn swap_exact_tokens_for_tokens() { + let (mut env, amm_address, token0_address, token1_address, _liquidity_token_address, minter): (aztec::test::helpers::test_environment::TestEnvironment, AztecAddress, AztecAddress, AztecAddress, AztecAddress, AztecAddress) = setup(); + let liquidity_provider: AztecAddress = env.create_contract_account(); + let swapper: AztecAddress = env.create_contract_account(); + let token0: Token::Token = Token::at(token0_address); + let token1: Token::Token = Token::at(token1_address); + let amm: AMM::AMM = AMM::at(amm_address); + let liquidity_amount0: u128 = 10000_Field as u128; + let liquidity_amount1: u128 = 20000_Field as u128; + add_liquidity(env, amm_address, token0_address, token1_address, minter, liquidity_provider, liquidity_amount0, liquidity_amount1, DEFAULT_AMOUNT_0_MIN, DEFAULT_AMOUNT_1_MIN); + let amount_in: u128 = 1000_Field as u128; + let amount_out_min: u128 = 1800_Field as u128; + env.call_private(minter, token0.mint_to_private(swapper, amount_in)); + add_private_authwit_from_call(env, swapper, amm_address, token0.transfer_to_public(swapper, amm_address, amount_in, AUTHWIT_NONCE)); + env.call_private(swapper, amm.swap_exact_tokens_for_tokens(token0_address, token1_address, amount_in, amount_out_min, AUTHWIT_NONCE)); + assert(env.execute_utility(token0.balance_of_private(swapper)) == 0_u128); + assert(env.execute_utility(token1.balance_of_private(swapper)) >= amount_out_min); + } + + #[test] + unconstrained fn swap_tokens_for_exact_tokens() { + let (mut env, amm_address, token0_address, token1_address, _liquidity_token_address, minter): (aztec::test::helpers::test_environment::TestEnvironment, AztecAddress, AztecAddress, AztecAddress, AztecAddress, AztecAddress) = setup(); + let liquidity_provider: AztecAddress = env.create_contract_account(); + let swapper: AztecAddress = env.create_contract_account(); + let token0: Token::Token = Token::at(token0_address); + let token1: Token::Token = Token::at(token1_address); + let amm: AMM::AMM = AMM::at(amm_address); + let liquidity_amount0: u128 = 10000_Field as u128; + let liquidity_amount1: u128 = 20000_Field as u128; + add_liquidity(env, amm_address, token0_address, token1_address, minter, liquidity_provider, liquidity_amount0, liquidity_amount1, DEFAULT_AMOUNT_0_MIN, DEFAULT_AMOUNT_1_MIN); + let amount_out: u128 = 1000_Field as u128; + let amount_in_max: u128 = 600_Field as u128; + env.call_private(minter, token0.mint_to_private(swapper, amount_in_max)); + let transfer_call: aztec::context::calls::PrivateCall<55, 4, uint_note::PartialUintNote> = token0.transfer_to_public_and_prepare_private_balance_increase(swapper, amm_address, amount_in_max, AUTHWIT_NONCE); + add_private_authwit_from_call(env, swapper, amm_address, transfer_call); + env.call_private(swapper, amm.swap_tokens_for_exact_tokens(token0_address, token1_address, amount_out, amount_in_max, AUTHWIT_NONCE)); + assert(env.execute_utility(token1.balance_of_private(swapper)) == amount_out); + let swapper_token0_balance: u128 = env.execute_utility(token0.balance_of_private(swapper)); + assert(swapper_token0_balance > 0_u128); + assert(swapper_token0_balance < amount_in_max); + } + + #[test(should_fail_with = "INCORRECT_TOKEN0_LIMITS")] + unconstrained fn add_liquidity_incorrect_token0_limits() { + let (mut env, amm_address, _token0_address, _token1_address, _liquidity_token_address, _minter): (aztec::test::helpers::test_environment::TestEnvironment, AztecAddress, AztecAddress, AztecAddress, AztecAddress, AztecAddress) = setup(); + let liquidity_provider: AztecAddress = env.create_contract_account(); + let amm: AMM::AMM = AMM::at(amm_address); + let amount0_max: u128 = 500_Field as u128; + let amount1_max: u128 = 1000_Field as u128; + let amount0_min: u128 = 600_Field as u128; + let amount1_min: u128 = 500_Field as u128; + env.call_private(liquidity_provider, amm.add_liquidity(amount0_max, amount1_max, amount0_min, amount1_min, AUTHWIT_NONCE)); + } + + #[test(should_fail_with = "INCORRECT_TOKEN1_LIMITS")] + unconstrained fn add_liquidity_incorrect_token1_limits() { + let (mut env, amm_address, _token0_address, _token1_address, _liquidity_token_address, _minter): (aztec::test::helpers::test_environment::TestEnvironment, AztecAddress, AztecAddress, AztecAddress, AztecAddress, AztecAddress) = setup(); + let liquidity_provider: AztecAddress = env.create_contract_account(); + let amm: AMM::AMM = AMM::at(amm_address); + let amount0_max: u128 = 500_Field as u128; + let amount1_max: u128 = 1000_Field as u128; + let amount0_min: u128 = 400_Field as u128; + let amount1_min: u128 = 1100_Field as u128; + env.call_private(liquidity_provider, amm.add_liquidity(amount0_max, amount1_max, amount0_min, amount1_min, AUTHWIT_NONCE)); + } + + #[test(should_fail_with = "INSUFFICIENT_INPUT_AMOUNTS")] + unconstrained fn add_liquidity_zero_amount0_max() { + let (mut env, amm_address, _token0_address, _token1_address, _liquidity_token_address, _minter): (aztec::test::helpers::test_environment::TestEnvironment, AztecAddress, AztecAddress, AztecAddress, AztecAddress, AztecAddress) = setup(); + let liquidity_provider: AztecAddress = env.create_contract_account(); + let amm: AMM::AMM = AMM::at(amm_address); + let amount0_max: u128 = 0_Field as u128; + let amount1_max: u128 = 1000_Field as u128; + let amount0_min: u128 = 0_Field as u128; + let amount1_min: u128 = 500_Field as u128; + env.call_private(liquidity_provider, amm.add_liquidity(amount0_max, amount1_max, amount0_min, amount1_min, AUTHWIT_NONCE)); + } + + #[test(should_fail_with = "INSUFFICIENT_INPUT_AMOUNTS")] + unconstrained fn add_liquidity_zero_amount1_max() { + let (mut env, amm_address, _token0_address, _token1_address, _liquidity_token_address, _minter): (aztec::test::helpers::test_environment::TestEnvironment, AztecAddress, AztecAddress, AztecAddress, AztecAddress, AztecAddress) = setup(); + let liquidity_provider: AztecAddress = env.create_contract_account(); + let amm: AMM::AMM = AMM::at(amm_address); + let amount0_max: u128 = 1000_Field as u128; + let amount1_max: u128 = 0_Field as u128; + let amount0_min: u128 = 500_Field as u128; + let amount1_min: u128 = 0_Field as u128; + env.call_private(liquidity_provider, amm.add_liquidity(amount0_max, amount1_max, amount0_min, amount1_min, AUTHWIT_NONCE)); + } + + #[test(should_fail_with = "TOKEN_IN_IS_INVALID")] + unconstrained fn swap_exact_tokens_invalid_token_in() { + let (mut env, amm_address, _token0_address, token1_address, _liquidity_token_address, _minter): (aztec::test::helpers::test_environment::TestEnvironment, AztecAddress, AztecAddress, AztecAddress, AztecAddress, AztecAddress) = setup(); + let swapper: AztecAddress = env.create_contract_account(); + let amm: AMM::AMM = AMM::at(amm_address); + let invalid_token: AztecAddress = AztecAddress::from_field(999_Field); + let amount_in: u128 = 1000_Field as u128; + let amount_out_min: u128 = 900_Field as u128; + env.call_private(swapper, amm.swap_exact_tokens_for_tokens(invalid_token, token1_address, amount_in, amount_out_min, AUTHWIT_NONCE)); + } + + #[test(should_fail_with = "TOKEN_OUT_IS_INVALID")] + unconstrained fn swap_exact_tokens_invalid_token_out() { + let (mut env, amm_address, token0_address, _token1_address, _liquidity_token_address, _minter): (aztec::test::helpers::test_environment::TestEnvironment, AztecAddress, AztecAddress, AztecAddress, AztecAddress, AztecAddress) = setup(); + let swapper: AztecAddress = env.create_contract_account(); + let amm: AMM::AMM = AMM::at(amm_address); + let invalid_token: AztecAddress = AztecAddress::from_field(999_Field); + let amount_in: u128 = 1000_Field as u128; + let amount_out_min: u128 = 900_Field as u128; + env.call_private(swapper, amm.swap_exact_tokens_for_tokens(token0_address, invalid_token, amount_in, amount_out_min, AUTHWIT_NONCE)); + } + + #[test(should_fail_with = "SAME_TOKEN_SWAP")] + unconstrained fn swap_exact_tokens_same_tokens() { + let (mut env, amm_address, token0_address, _token1_address, _liquidity_token_address, _minter): (aztec::test::helpers::test_environment::TestEnvironment, AztecAddress, AztecAddress, AztecAddress, AztecAddress, AztecAddress) = setup(); + let swapper: AztecAddress = env.create_contract_account(); + let amm: AMM::AMM = AMM::at(amm_address); + let amount_in: u128 = 1000_Field as u128; + let amount_out_min: u128 = 900_Field as u128; + env.call_private(swapper, amm.swap_exact_tokens_for_tokens(token0_address, token0_address, amount_in, amount_out_min, AUTHWIT_NONCE)); + } + + #[test(should_fail_with = "TOKEN_IN_IS_INVALID")] + unconstrained fn swap_tokens_for_exact_invalid_token_in() { + let (mut env, amm_address, _token0_address, token1_address, _liquidity_token_address, _minter): (aztec::test::helpers::test_environment::TestEnvironment, AztecAddress, AztecAddress, AztecAddress, AztecAddress, AztecAddress) = setup(); + let swapper: AztecAddress = env.create_contract_account(); + let amm: AMM::AMM = AMM::at(amm_address); + let invalid_token: AztecAddress = AztecAddress::from_field(999_Field); + let amount_out: u128 = 1000_Field as u128; + let amount_in_max: u128 = 1200_Field as u128; + env.call_private(swapper, amm.swap_tokens_for_exact_tokens(invalid_token, token1_address, amount_out, amount_in_max, AUTHWIT_NONCE)); + } + + #[test(should_fail_with = "TOKEN_OUT_IS_INVALID")] + unconstrained fn swap_tokens_for_exact_invalid_token_out() { + let (mut env, amm_address, token0_address, _token1_address, _liquidity_token_address, _minter): (aztec::test::helpers::test_environment::TestEnvironment, AztecAddress, AztecAddress, AztecAddress, AztecAddress, AztecAddress) = setup(); + let swapper: AztecAddress = env.create_contract_account(); + let amm: AMM::AMM = AMM::at(amm_address); + let invalid_token: AztecAddress = AztecAddress::from_field(999_Field); + let amount_out: u128 = 1000_Field as u128; + let amount_in_max: u128 = 1200_Field as u128; + env.call_private(swapper, amm.swap_tokens_for_exact_tokens(token0_address, invalid_token, amount_out, amount_in_max, AUTHWIT_NONCE)); + } + + #[test(should_fail_with = "SAME_TOKEN_SWAP")] + unconstrained fn swap_tokens_for_exact_same_tokens() { + let (mut env, amm_address, token0_address, _token1_address, _liquidity_token_address, _minter): (aztec::test::helpers::test_environment::TestEnvironment, AztecAddress, AztecAddress, AztecAddress, AztecAddress, AztecAddress) = setup(); + let swapper: AztecAddress = env.create_contract_account(); + let amm: AMM::AMM = AMM::at(amm_address); + let amount_out: u128 = 1000_Field as u128; + let amount_in_max: u128 = 1200_Field as u128; + env.call_private(swapper, amm.swap_tokens_for_exact_tokens(token0_address, token0_address, amount_out, amount_in_max, AUTHWIT_NONCE)); + } + + #[test(should_fail_with = "INSUFFICIENT_LIQUIDITY_MINTED")] + unconstrained fn add_liquidity_insufficient_liquidity_minted() { + let (mut env, amm_address, token0_address, token1_address, _liquidity_token_address, minter): (aztec::test::helpers::test_environment::TestEnvironment, AztecAddress, AztecAddress, AztecAddress, AztecAddress, AztecAddress) = setup(); + let liquidity_provider_1: AztecAddress = env.create_contract_account(); + let liquidity_provider_2: AztecAddress = env.create_contract_account(); + let initial_amount0: u128 = 100000000_Field as u128; + let initial_amount1: u128 = 200000000_Field as u128; + add_liquidity(env, amm_address, token0_address, token1_address, minter, liquidity_provider_1, initial_amount0, initial_amount1, DEFAULT_AMOUNT_0_MIN, DEFAULT_AMOUNT_1_MIN); + let tiny_amount0: u128 = 1_Field as u128; + let tiny_amount1: u128 = 2_Field as u128; + add_liquidity(env, amm_address, token0_address, token1_address, minter, liquidity_provider_2, tiny_amount0, tiny_amount1, DEFAULT_AMOUNT_0_MIN, DEFAULT_AMOUNT_1_MIN); + } + + #[test(should_fail_with = "INSUFFICIENT_0_AMOUNT")] + unconstrained fn remove_liquidity_insufficient_amount0() { + let (mut env, amm_address, token0_address, token1_address, liquidity_token_address, minter): (aztec::test::helpers::test_environment::TestEnvironment, AztecAddress, AztecAddress, AztecAddress, AztecAddress, AztecAddress) = setup(); + let liquidity_provider: AztecAddress = env.create_contract_account(); + let amount0: u128 = 1000_Field as u128; + let amount1: u128 = 2000_Field as u128; + add_liquidity(env, amm_address, token0_address, token1_address, minter, liquidity_provider, amount0, amount1, DEFAULT_AMOUNT_0_MIN, DEFAULT_AMOUNT_1_MIN); + let liquidity_to_remove: u128 = AMM::INITIAL_LIQUIDITY / 2_u128; + let amount0_min: u128 = 10000_Field as u128; + let amount1_min: u128 = 800_Field as u128; + remove_liquidity(env, amm_address, liquidity_token_address, liquidity_provider, liquidity_to_remove, amount0_min, amount1_min); + } + + #[test(should_fail_with = "INSUFFICIENT_1_AMOUNT")] + unconstrained fn remove_liquidity_insufficient_amount1() { + let (mut env, amm_address, token0_address, token1_address, liquidity_token_address, minter): (aztec::test::helpers::test_environment::TestEnvironment, AztecAddress, AztecAddress, AztecAddress, AztecAddress, AztecAddress) = setup(); + let liquidity_provider: AztecAddress = env.create_contract_account(); + let amount0: u128 = 1000_Field as u128; + let amount1: u128 = 2000_Field as u128; + add_liquidity(env, amm_address, token0_address, token1_address, minter, liquidity_provider, amount0, amount1, DEFAULT_AMOUNT_0_MIN, DEFAULT_AMOUNT_1_MIN); + let liquidity_to_remove: u128 = AMM::INITIAL_LIQUIDITY / 2_u128; + let amount0_min: u128 = 400_Field as u128; + let amount1_min: u128 = 20000_Field as u128; + remove_liquidity(env, amm_address, liquidity_token_address, liquidity_provider, liquidity_to_remove, amount0_min, amount1_min); + } + } + + pub(crate) mod utils { + use crate::AMM; + use aztec::protocol::address::AztecAddress; + use aztec::test::helpers::authwit::add_private_authwit_from_call; + use aztec::test::helpers::test_environment::TestEnvironment; + use token::Token; + + global AUTHWIT_NONCE: Field = 0x01; + + pub(crate) unconstrained fn setup() -> (TestEnvironment, AztecAddress, AztecAddress, AztecAddress, AztecAddress, AztecAddress) { + let mut env: TestEnvironment = TestEnvironment::new(); + let admin: AztecAddress = env.create_contract_account(); + let token0_initializer: aztec::context::calls::PublicCall<11, 64, ()> = Token::interface().constructor(admin, "Token00000000000000000000000000", "TK00000000000000000000000000000", 18_u8); + let token0_address: AztecAddress = env.deploy("@token_contract/Token").with_public_initializer(admin, token0_initializer); + let token1_initializer: aztec::context::calls::PublicCall<11, 64, ()> = Token::interface().constructor(admin, "Token11111111111111111111111111", "TK11111111111111111111111111111", 18_u8); + let token1_address: AztecAddress = env.deploy("@token_contract/Token").with_public_initializer(admin, token1_initializer); + let liquidity_token_initializer: aztec::context::calls::PublicCall<11, 64, ()> = Token::interface().constructor(admin, "LiquidityToken00000000000000000", "LT00000000000000000000000000000", 18_u8); + let liquidity_token_address: AztecAddress = env.deploy("@token_contract/Token").with_public_initializer(admin, liquidity_token_initializer); + let amm_initializer: aztec::context::calls::PublicCall<11, 3, ()> = AMM::interface().constructor(token0_address, token1_address, liquidity_token_address); + let amm_address: AztecAddress = env.deploy("AMM").with_public_initializer(admin, amm_initializer); + env.call_public(admin, Token::at(liquidity_token_address).set_minter(amm_address, true)); + let minter: AztecAddress = admin; + (env, amm_address, token0_address, token1_address, liquidity_token_address, minter) + } + + pub(crate) unconstrained fn add_liquidity(env: TestEnvironment, amm_address: AztecAddress, token0_address: AztecAddress, token1_address: AztecAddress, minter: AztecAddress, liquidity_provider: AztecAddress, amount0_max: u128, amount1_max: u128, amount0_min: u128, amount1_min: u128) { + let token0: Token::Token = Token::at(token0_address); + let token1: Token::Token = Token::at(token1_address); + let amm: AMM::AMM = AMM::at(amm_address); + env.call_private(minter, token0.mint_to_private(liquidity_provider, amount0_max)); + env.call_private(minter, token1.mint_to_private(liquidity_provider, amount1_max)); + let transfer0_call: aztec::context::calls::PrivateCall<55, 4, uint_note::PartialUintNote> = token0.transfer_to_public_and_prepare_private_balance_increase(liquidity_provider, amm_address, amount0_max, AUTHWIT_NONCE); + add_private_authwit_from_call(env, liquidity_provider, amm_address, transfer0_call); + let transfer1_call: aztec::context::calls::PrivateCall<55, 4, uint_note::PartialUintNote> = token1.transfer_to_public_and_prepare_private_balance_increase(liquidity_provider, amm_address, amount1_max, AUTHWIT_NONCE); + add_private_authwit_from_call(env, liquidity_provider, amm_address, transfer1_call); + env.call_private(liquidity_provider, amm.add_liquidity(amount0_max, amount1_max, amount0_min, amount1_min, AUTHWIT_NONCE)); + } + + pub(crate) unconstrained fn remove_liquidity(env: TestEnvironment, amm_address: AztecAddress, liquidity_token_address: AztecAddress, liquidity_provider: AztecAddress, liquidity_amount: u128, amount0_min: u128, amount1_min: u128) { + let liquidity_token: Token::Token = Token::at(liquidity_token_address); + let amm: AMM::AMM = AMM::at(amm_address); + let transfer_liquidity_call: aztec::context::calls::PrivateCall<18, 4, ()> = liquidity_token.transfer_to_public(liquidity_provider, amm_address, liquidity_amount, AUTHWIT_NONCE); + add_private_authwit_from_call(env, liquidity_provider, amm_address, transfer_liquidity_call); + env.call_private(liquidity_provider, amm.remove_liquidity(liquidity_amount, amount0_min, amount1_min, AUTHWIT_NONCE)); + } + } +} + +// Warning: the generated code has syntax errors diff --git a/noir-projects/contract-snapshots/tests/snapshots/expand/avm_gadgets_test_contract/snapshots__expanded.snap b/noir-projects/contract-snapshots/tests/snapshots/expand/avm_gadgets_test_contract/snapshots__expanded.snap new file mode 100644 index 000000000000..2f36a53d539e --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/expand/avm_gadgets_test_contract/snapshots__expanded.snap @@ -0,0 +1,1655 @@ +--- +source: tests/snapshots.rs +expression: stdout +--- +use aztec::macros::aztec; +use aztec::macros::aztec; + +contract AvmGadgetsTest { + use aztec::macros::functions::external; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call keccak_hash. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn keccak_hash(data: [u8; 10]) -> [u8; 32]; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call keccak_hash_300. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn keccak_hash_300(data: [u8; 300]) -> [u8; 32]; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call keccak_hash_1400. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn keccak_hash_1400(data: [u8; 1400]) -> [u8; 32]; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call keccak_f1600. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn keccak_f1600(data: [u64; 25]) -> [u64; 25]; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call poseidon2_hash. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn poseidon2_hash(data: [Field; 10]) -> Field; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call poseidon2_hash_1000fields. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn poseidon2_hash_1000fields(data: [Field; 1000]) -> Field; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call sha256_hash_10. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn sha256_hash_10(data: [u8; 10]) -> [u8; 32]; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call sha256_hash_20. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn sha256_hash_20(data: [u8; 20]) -> [u8; 32]; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call sha256_hash_30. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn sha256_hash_30(data: [u8; 30]) -> [u8; 32]; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call sha256_hash_40. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn sha256_hash_40(data: [u8; 40]) -> [u8; 32]; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call sha256_hash_50. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn sha256_hash_50(data: [u8; 50]) -> [u8; 32]; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call sha256_hash_60. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn sha256_hash_60(data: [u8; 60]) -> [u8; 32]; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call sha256_hash_70. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn sha256_hash_70(data: [u8; 70]) -> [u8; 32]; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call sha256_hash_80. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn sha256_hash_80(data: [u8; 80]) -> [u8; 32]; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call sha256_hash_90. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn sha256_hash_90(data: [u8; 90]) -> [u8; 32]; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call sha256_hash_100. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn sha256_hash_100(data: [u8; 100]) -> [u8; 32]; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call sha256_hash_255. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn sha256_hash_255(data: [u8; 255]) -> [u8; 32]; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call sha256_hash_256. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn sha256_hash_256(data: [u8; 256]) -> [u8; 32]; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call sha256_hash_511. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn sha256_hash_511(data: [u8; 511]) -> [u8; 32]; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call sha256_hash_512. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn sha256_hash_512(data: [u8; 512]) -> [u8; 32]; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call sha256_hash_1024. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn sha256_hash_1024(data: [u8; 1024]) -> [u8; 32]; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call sha256_hash_1536. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn sha256_hash_1536(data: [u8; 1536]) -> [u8; 32]; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call pedersen_hash. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn pedersen_hash(data: [Field; 10]) -> Field; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call pedersen_hash_with_index. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn pedersen_hash_with_index(data: [Field; 10]) -> Field; + + /// Unpacks an array into a note corresponding to `note_type_id` and then computes its note hash (non-siloed) and inner nullifier (non-siloed) assuming the note has been inserted into the note hash tree with `note_nonce`. + /// + /// This function is automatically injected by the `#[aztec]` macro. + #[contract_library_method] + #[allow(dead_code)] + unconstrained fn _compute_note_hash_and_nullifier(packed_note: BoundedVec, owner: aztec::protocol::address::AztecAddress, storage_slot: Field, note_type_id: Field, contract_address: aztec::protocol::address::AztecAddress, randomness: Field, note_nonce: Field) -> Option { + _compute_note_hash(packed_note, owner, storage_slot, note_type_id, contract_address, randomness).map(|note_hash: Field| -> aztec::messages::discovery::NoteHashAndNullifier { + let siloed_note_hash: Field = aztec::protocol::hash::compute_siloed_note_hash(contract_address, note_hash); + let unique_note_hash: Field = aztec::protocol::hash::compute_unique_note_hash(note_nonce, siloed_note_hash); + let inner_nullifier: Option = _compute_note_nullifier(unique_note_hash, packed_note, owner, storage_slot, note_type_id, contract_address, randomness); + aztec::messages::discovery::NoteHashAndNullifier { note_hash: note_hash, inner_nullifier: inner_nullifier} + }) + } + + /// This contract does not use private notes, so this function should never be called as it will unconditionally fail. + /// + /// This function is automatically injected by the `#[aztec]` macro. + #[contract_library_method] + unconstrained fn _compute_note_hash(_packed_note: BoundedVec, _owner: aztec::protocol::address::AztecAddress, _storage_slot: Field, _note_type_id: Field, _contract_address: aztec::protocol::address::AztecAddress, _randomness: Field) -> Option { + panic(f"This contract does not use private notes") + } + + /// This contract does not use private notes, so this function should never be called as it will unconditionally fail. + /// + /// This function is automatically injected by the `#[aztec]` macro. + #[contract_library_method] + unconstrained fn _compute_note_nullifier(_unique_note_hash: Field, _packed_note: BoundedVec, _owner: aztec::protocol::address::AztecAddress, _storage_slot: Field, _note_type_id: Field, _contract_address: aztec::protocol::address::AztecAddress, _randomness: Field) -> Option { + panic(f"This contract does not use private notes") + } + + /// Receives offchain messages into this contract's offchain inbox for subsequent processing. + /// + /// Each message is routed to the inbox scoped to its `recipient` field. + /// + /// For more details, see `aztec::messages::processing::offchain::receive`. + /// + /// This function is automatically injected by the `#[aztec]` macro. + unconstrained fn offchain_receive(messages: BoundedVec) { + let address: aztec::protocol::address::AztecAddress = aztec::context::UtilityContext::new().this_address(); + aztec::messages::processing::offchain::receive(address, messages); + } + + pub struct AvmGadgetsTest { + pub target_contract: aztec::protocol::address::AztecAddress, + } + + impl AvmGadgetsTest { + pub fn at(addr: aztec::protocol::address::AztecAddress) -> Self { + Self { target_contract: addr} + } + + pub fn interface() -> Self { + Self { target_contract: aztec::protocol::address::AztecAddress::zero()} + } + + pub fn sha256_hash_1536(self, data: [u8; 1536]) -> aztec::context::calls::PublicCall<16, 1536, [u8; 32]> { + let serialized_params: [Field; 1536] = <[u8; 1536] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(373006257_Field); + aztec::context::calls::PublicCall::<16, 1536, [u8; 32]>::new(self.target_contract, selector, "sha256_hash_1536", serialized_params) + } + + pub fn pedersen_hash_with_index(self, data: [Field; 10]) -> aztec::context::calls::PublicCall<24, 10, Field> { + let serialized_params: [Field; 10] = <[Field; 10] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3265405934_Field); + aztec::context::calls::PublicCall::<24, 10, Field>::new(self.target_contract, selector, "pedersen_hash_with_index", serialized_params) + } + + pub fn keccak_hash(self, data: [u8; 10]) -> aztec::context::calls::PublicCall<11, 10, [u8; 32]> { + let serialized_params: [Field; 10] = <[u8; 10] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1352369823_Field); + aztec::context::calls::PublicCall::<11, 10, [u8; 32]>::new(self.target_contract, selector, "keccak_hash", serialized_params) + } + + pub fn sha256_hash_511(self, data: [u8; 511]) -> aztec::context::calls::PublicCall<15, 511, [u8; 32]> { + let serialized_params: [Field; 511] = <[u8; 511] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(797967809_Field); + aztec::context::calls::PublicCall::<15, 511, [u8; 32]>::new(self.target_contract, selector, "sha256_hash_511", serialized_params) + } + + pub fn sha256_hash_100(self, data: [u8; 100]) -> aztec::context::calls::PublicCall<15, 100, [u8; 32]> { + let serialized_params: [Field; 100] = <[u8; 100] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2074027672_Field); + aztec::context::calls::PublicCall::<15, 100, [u8; 32]>::new(self.target_contract, selector, "sha256_hash_100", serialized_params) + } + + pub fn sha256_hash_80(self, data: [u8; 80]) -> aztec::context::calls::PublicCall<14, 80, [u8; 32]> { + let serialized_params: [Field; 80] = <[u8; 80] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(4268069756_Field); + aztec::context::calls::PublicCall::<14, 80, [u8; 32]>::new(self.target_contract, selector, "sha256_hash_80", serialized_params) + } + + pub fn pedersen_hash(self, data: [Field; 10]) -> aztec::context::calls::PublicCall<13, 10, Field> { + let serialized_params: [Field; 10] = <[Field; 10] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2669406607_Field); + aztec::context::calls::PublicCall::<13, 10, Field>::new(self.target_contract, selector, "pedersen_hash", serialized_params) + } + + pub fn sha256_hash_20(self, data: [u8; 20]) -> aztec::context::calls::PublicCall<14, 20, [u8; 32]> { + let serialized_params: [Field; 20] = <[u8; 20] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2926274626_Field); + aztec::context::calls::PublicCall::<14, 20, [u8; 32]>::new(self.target_contract, selector, "sha256_hash_20", serialized_params) + } + + pub fn poseidon2_hash(self, data: [Field; 10]) -> aztec::context::calls::PublicCall<14, 10, Field> { + let serialized_params: [Field; 10] = <[Field; 10] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3724082008_Field); + aztec::context::calls::PublicCall::<14, 10, Field>::new(self.target_contract, selector, "poseidon2_hash", serialized_params) + } + + pub fn sha256_hash_512(self, data: [u8; 512]) -> aztec::context::calls::PublicCall<15, 512, [u8; 32]> { + let serialized_params: [Field; 512] = <[u8; 512] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2560938307_Field); + aztec::context::calls::PublicCall::<15, 512, [u8; 32]>::new(self.target_contract, selector, "sha256_hash_512", serialized_params) + } + + pub fn keccak_f1600(self, data: [u64; 25]) -> aztec::context::calls::PublicCall<12, 25, [u64; 25]> { + let serialized_params: [Field; 25] = <[u64; 25] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1867977279_Field); + aztec::context::calls::PublicCall::<12, 25, [u64; 25]>::new(self.target_contract, selector, "keccak_f1600", serialized_params) + } + + pub fn sha256_hash_30(self, data: [u8; 30]) -> aztec::context::calls::PublicCall<14, 30, [u8; 32]> { + let serialized_params: [Field; 30] = <[u8; 30] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3609677267_Field); + aztec::context::calls::PublicCall::<14, 30, [u8; 32]>::new(self.target_contract, selector, "sha256_hash_30", serialized_params) + } + + pub fn sha256_hash_50(self, data: [u8; 50]) -> aztec::context::calls::PublicCall<14, 50, [u8; 32]> { + let serialized_params: [Field; 50] = <[u8; 50] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(256881939_Field); + aztec::context::calls::PublicCall::<14, 50, [u8; 32]>::new(self.target_contract, selector, "sha256_hash_50", serialized_params) + } + + pub fn sha256_hash_60(self, data: [u8; 60]) -> aztec::context::calls::PublicCall<14, 60, [u8; 32]> { + let serialized_params: [Field; 60] = <[u8; 60] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2495458303_Field); + aztec::context::calls::PublicCall::<14, 60, [u8; 32]>::new(self.target_contract, selector, "sha256_hash_60", serialized_params) + } + + pub fn poseidon2_hash_1000fields(self, data: [Field; 1000]) -> aztec::context::calls::PublicCall<25, 1000, Field> { + let serialized_params: [Field; 1000] = <[Field; 1000] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(278602445_Field); + aztec::context::calls::PublicCall::<25, 1000, Field>::new(self.target_contract, selector, "poseidon2_hash_1000fields", serialized_params) + } + + pub fn sha256_hash_70(self, data: [u8; 70]) -> aztec::context::calls::PublicCall<14, 70, [u8; 32]> { + let serialized_params: [Field; 70] = <[u8; 70] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2200074453_Field); + aztec::context::calls::PublicCall::<14, 70, [u8; 32]>::new(self.target_contract, selector, "sha256_hash_70", serialized_params) + } + + pub fn sha256_hash_90(self, data: [u8; 90]) -> aztec::context::calls::PublicCall<14, 90, [u8; 32]> { + let serialized_params: [Field; 90] = <[u8; 90] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(799349905_Field); + aztec::context::calls::PublicCall::<14, 90, [u8; 32]>::new(self.target_contract, selector, "sha256_hash_90", serialized_params) + } + + pub fn sha256_hash_40(self, data: [u8; 40]) -> aztec::context::calls::PublicCall<14, 40, [u8; 32]> { + let serialized_params: [Field; 40] = <[u8; 40] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(900925045_Field); + aztec::context::calls::PublicCall::<14, 40, [u8; 32]>::new(self.target_contract, selector, "sha256_hash_40", serialized_params) + } + + pub fn sha256_hash_10(self, data: [u8; 10]) -> aztec::context::calls::PublicCall<14, 10, [u8; 32]> { + let serialized_params: [Field; 10] = <[u8; 10] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3545543018_Field); + aztec::context::calls::PublicCall::<14, 10, [u8; 32]>::new(self.target_contract, selector, "sha256_hash_10", serialized_params) + } + + pub fn sha256_hash_1024(self, data: [u8; 1024]) -> aztec::context::calls::PublicCall<16, 1024, [u8; 32]> { + let serialized_params: [Field; 1024] = <[u8; 1024] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2235915052_Field); + aztec::context::calls::PublicCall::<16, 1024, [u8; 32]>::new(self.target_contract, selector, "sha256_hash_1024", serialized_params) + } + + pub fn sha256_hash_255(self, data: [u8; 255]) -> aztec::context::calls::PublicCall<15, 255, [u8; 32]> { + let serialized_params: [Field; 255] = <[u8; 255] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3548859530_Field); + aztec::context::calls::PublicCall::<15, 255, [u8; 32]>::new(self.target_contract, selector, "sha256_hash_255", serialized_params) + } + + pub fn sha256_hash_256(self, data: [u8; 256]) -> aztec::context::calls::PublicCall<15, 256, [u8; 32]> { + let serialized_params: [Field; 256] = <[u8; 256] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3409224101_Field); + aztec::context::calls::PublicCall::<15, 256, [u8; 32]>::new(self.target_contract, selector, "sha256_hash_256", serialized_params) + } + + pub fn keccak_hash_1400(self, data: [u8; 1400]) -> aztec::context::calls::PublicCall<16, 1400, [u8; 32]> { + let serialized_params: [Field; 1400] = <[u8; 1400] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(372001522_Field); + aztec::context::calls::PublicCall::<16, 1400, [u8; 32]>::new(self.target_contract, selector, "keccak_hash_1400", serialized_params) + } + + pub fn keccak_hash_300(self, data: [u8; 300]) -> aztec::context::calls::PublicCall<15, 300, [u8; 32]> { + let serialized_params: [Field; 300] = <[u8; 300] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3065624740_Field); + aztec::context::calls::PublicCall::<15, 300, [u8; 32]>::new(self.target_contract, selector, "keccak_hash_300", serialized_params) + } + + pub fn offchain_receive(self, messages: BoundedVec) -> aztec::context::calls::UtilityCall<16, 321, ()> { + let serialized_params: [Field; 321] = as aztec::protocol::traits::Serialize>::serialize(messages); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1396850735_Field); + aztec::context::calls::UtilityCall::<16, 321, ()>::new(self.target_contract, selector, "offchain_receive", serialized_params) + } + } + + #[contract_library_method] + pub fn at(addr: aztec::protocol::address::AztecAddress) -> AvmGadgetsTest { + AvmGadgetsTest { target_contract: addr} + } + + #[contract_library_method] + pub fn interface() -> AvmGadgetsTest { + AvmGadgetsTest { target_contract: aztec::protocol::address::AztecAddress::zero()} + } + + pub struct sync_state_parameters { + pub scope: aztec::protocol::address::AztecAddress, + } + + #[abi(functions)] + pub struct sync_state_abi { + parameters: sync_state_parameters, + } + + unconstrained fn sync_state(scope: aztec::protocol::address::AztecAddress) { + let address: aztec::protocol::address::AztecAddress = aztec::context::UtilityContext::new().this_address(); + aztec::messages::discovery::do_sync_state(address, _compute_note_hash, _compute_note_nullifier, Option::>::none(), Option:: aztec::ephemeral::EphemeralArray>::some(aztec::messages::processing::offchain::sync_inbox), scope); + } + + pub struct offchain_receive_parameters { + pub messages: BoundedVec, + } + + #[abi(functions)] + pub struct offchain_receive_abi { + parameters: offchain_receive_parameters, + } + + pub struct CallSelf { + pub address: aztec::protocol::address::AztecAddress, + pub context: Context, + } + + impl CallSelf { + pub fn sha256_hash_1536(self, data: [u8; 1536]) -> [u8; 32] { + let serialized_params: [Field; 1536 * 1] = <[u8; 1536] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(373006257_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<16, 1536 * 1, [u8; 32]>::new(self.address, selector, "sha256_hash_1536", serialized_params).call(self.context) + } + } + + pub fn pedersen_hash_with_index(self, data: [Field; 10]) -> Field { + let serialized_params: [Field; 10 * 1] = <[Field; 10] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3265405934_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<24, 10 * 1, Field>::new(self.address, selector, "pedersen_hash_with_index", serialized_params).call(self.context) + } + } + + pub fn keccak_hash(self, data: [u8; 10]) -> [u8; 32] { + let serialized_params: [Field; 10 * 1] = <[u8; 10] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1352369823_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<11, 10 * 1, [u8; 32]>::new(self.address, selector, "keccak_hash", serialized_params).call(self.context) + } + } + + pub fn sha256_hash_511(self, data: [u8; 511]) -> [u8; 32] { + let serialized_params: [Field; 511 * 1] = <[u8; 511] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(797967809_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<15, 511 * 1, [u8; 32]>::new(self.address, selector, "sha256_hash_511", serialized_params).call(self.context) + } + } + + pub fn sha256_hash_100(self, data: [u8; 100]) -> [u8; 32] { + let serialized_params: [Field; 100 * 1] = <[u8; 100] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2074027672_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<15, 100 * 1, [u8; 32]>::new(self.address, selector, "sha256_hash_100", serialized_params).call(self.context) + } + } + + pub fn sha256_hash_80(self, data: [u8; 80]) -> [u8; 32] { + let serialized_params: [Field; 80 * 1] = <[u8; 80] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(4268069756_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<14, 80 * 1, [u8; 32]>::new(self.address, selector, "sha256_hash_80", serialized_params).call(self.context) + } + } + + pub fn pedersen_hash(self, data: [Field; 10]) -> Field { + let serialized_params: [Field; 10 * 1] = <[Field; 10] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2669406607_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<13, 10 * 1, Field>::new(self.address, selector, "pedersen_hash", serialized_params).call(self.context) + } + } + + pub fn sha256_hash_20(self, data: [u8; 20]) -> [u8; 32] { + let serialized_params: [Field; 20 * 1] = <[u8; 20] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2926274626_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<14, 20 * 1, [u8; 32]>::new(self.address, selector, "sha256_hash_20", serialized_params).call(self.context) + } + } + + pub fn poseidon2_hash(self, data: [Field; 10]) -> Field { + let serialized_params: [Field; 10 * 1] = <[Field; 10] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3724082008_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<14, 10 * 1, Field>::new(self.address, selector, "poseidon2_hash", serialized_params).call(self.context) + } + } + + pub fn sha256_hash_512(self, data: [u8; 512]) -> [u8; 32] { + let serialized_params: [Field; 512 * 1] = <[u8; 512] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2560938307_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<15, 512 * 1, [u8; 32]>::new(self.address, selector, "sha256_hash_512", serialized_params).call(self.context) + } + } + + pub fn keccak_f1600(self, data: [u64; 25]) -> [u64; 25] { + let serialized_params: [Field; 25 * 1] = <[u64; 25] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1867977279_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<12, 25 * 1, [u64; 25]>::new(self.address, selector, "keccak_f1600", serialized_params).call(self.context) + } + } + + pub fn sha256_hash_30(self, data: [u8; 30]) -> [u8; 32] { + let serialized_params: [Field; 30 * 1] = <[u8; 30] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3609677267_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<14, 30 * 1, [u8; 32]>::new(self.address, selector, "sha256_hash_30", serialized_params).call(self.context) + } + } + + pub fn sha256_hash_50(self, data: [u8; 50]) -> [u8; 32] { + let serialized_params: [Field; 50 * 1] = <[u8; 50] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(256881939_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<14, 50 * 1, [u8; 32]>::new(self.address, selector, "sha256_hash_50", serialized_params).call(self.context) + } + } + + pub fn sha256_hash_60(self, data: [u8; 60]) -> [u8; 32] { + let serialized_params: [Field; 60 * 1] = <[u8; 60] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2495458303_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<14, 60 * 1, [u8; 32]>::new(self.address, selector, "sha256_hash_60", serialized_params).call(self.context) + } + } + + pub fn poseidon2_hash_1000fields(self, data: [Field; 1000]) -> Field { + let serialized_params: [Field; 1000 * 1] = <[Field; 1000] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(278602445_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<25, 1000 * 1, Field>::new(self.address, selector, "poseidon2_hash_1000fields", serialized_params).call(self.context) + } + } + + pub fn sha256_hash_70(self, data: [u8; 70]) -> [u8; 32] { + let serialized_params: [Field; 70 * 1] = <[u8; 70] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2200074453_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<14, 70 * 1, [u8; 32]>::new(self.address, selector, "sha256_hash_70", serialized_params).call(self.context) + } + } + + pub fn sha256_hash_90(self, data: [u8; 90]) -> [u8; 32] { + let serialized_params: [Field; 90 * 1] = <[u8; 90] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(799349905_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<14, 90 * 1, [u8; 32]>::new(self.address, selector, "sha256_hash_90", serialized_params).call(self.context) + } + } + + pub fn sha256_hash_40(self, data: [u8; 40]) -> [u8; 32] { + let serialized_params: [Field; 40 * 1] = <[u8; 40] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(900925045_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<14, 40 * 1, [u8; 32]>::new(self.address, selector, "sha256_hash_40", serialized_params).call(self.context) + } + } + + pub fn sha256_hash_10(self, data: [u8; 10]) -> [u8; 32] { + let serialized_params: [Field; 10 * 1] = <[u8; 10] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3545543018_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<14, 10 * 1, [u8; 32]>::new(self.address, selector, "sha256_hash_10", serialized_params).call(self.context) + } + } + + pub fn sha256_hash_1024(self, data: [u8; 1024]) -> [u8; 32] { + let serialized_params: [Field; 1024 * 1] = <[u8; 1024] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2235915052_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<16, 1024 * 1, [u8; 32]>::new(self.address, selector, "sha256_hash_1024", serialized_params).call(self.context) + } + } + + pub fn sha256_hash_255(self, data: [u8; 255]) -> [u8; 32] { + let serialized_params: [Field; 255 * 1] = <[u8; 255] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3548859530_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<15, 255 * 1, [u8; 32]>::new(self.address, selector, "sha256_hash_255", serialized_params).call(self.context) + } + } + + pub fn sha256_hash_256(self, data: [u8; 256]) -> [u8; 32] { + let serialized_params: [Field; 256 * 1] = <[u8; 256] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3409224101_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<15, 256 * 1, [u8; 32]>::new(self.address, selector, "sha256_hash_256", serialized_params).call(self.context) + } + } + + pub fn keccak_hash_1400(self, data: [u8; 1400]) -> [u8; 32] { + let serialized_params: [Field; 1400 * 1] = <[u8; 1400] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(372001522_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<16, 1400 * 1, [u8; 32]>::new(self.address, selector, "keccak_hash_1400", serialized_params).call(self.context) + } + } + + pub fn keccak_hash_300(self, data: [u8; 300]) -> [u8; 32] { + let serialized_params: [Field; 300 * 1] = <[u8; 300] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3065624740_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<15, 300 * 1, [u8; 32]>::new(self.address, selector, "keccak_hash_300", serialized_params).call(self.context) + } + } + } + + pub struct CallSelfStatic { + pub address: aztec::protocol::address::AztecAddress, + pub context: Context, + } + + pub struct EnqueueSelf { + pub address: aztec::protocol::address::AztecAddress, + pub context: Context, + } + + impl EnqueueSelf<&mut aztec::context::PrivateContext> { + pub fn sha256_hash_1536(self, data: [u8; 1536]) { + let serialized_params: [Field; 1536 * 1] = <[u8; 1536] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(373006257_Field); + let calldata: [Field; 1 + (1536 * 1)] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn pedersen_hash_with_index(self, data: [Field; 10]) { + let serialized_params: [Field; 10 * 1] = <[Field; 10] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3265405934_Field); + let calldata: [Field; 1 + (10 * 1)] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn keccak_hash(self, data: [u8; 10]) { + let serialized_params: [Field; 10 * 1] = <[u8; 10] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1352369823_Field); + let calldata: [Field; 1 + (10 * 1)] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn sha256_hash_511(self, data: [u8; 511]) { + let serialized_params: [Field; 511 * 1] = <[u8; 511] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(797967809_Field); + let calldata: [Field; 1 + (511 * 1)] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn sha256_hash_100(self, data: [u8; 100]) { + let serialized_params: [Field; 100 * 1] = <[u8; 100] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2074027672_Field); + let calldata: [Field; 1 + (100 * 1)] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn sha256_hash_80(self, data: [u8; 80]) { + let serialized_params: [Field; 80 * 1] = <[u8; 80] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(4268069756_Field); + let calldata: [Field; 1 + (80 * 1)] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn pedersen_hash(self, data: [Field; 10]) { + let serialized_params: [Field; 10 * 1] = <[Field; 10] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2669406607_Field); + let calldata: [Field; 1 + (10 * 1)] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn sha256_hash_20(self, data: [u8; 20]) { + let serialized_params: [Field; 20 * 1] = <[u8; 20] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2926274626_Field); + let calldata: [Field; 1 + (20 * 1)] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn poseidon2_hash(self, data: [Field; 10]) { + let serialized_params: [Field; 10 * 1] = <[Field; 10] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3724082008_Field); + let calldata: [Field; 1 + (10 * 1)] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn sha256_hash_512(self, data: [u8; 512]) { + let serialized_params: [Field; 512 * 1] = <[u8; 512] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2560938307_Field); + let calldata: [Field; 1 + (512 * 1)] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn keccak_f1600(self, data: [u64; 25]) { + let serialized_params: [Field; 25 * 1] = <[u64; 25] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1867977279_Field); + let calldata: [Field; 1 + (25 * 1)] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn sha256_hash_30(self, data: [u8; 30]) { + let serialized_params: [Field; 30 * 1] = <[u8; 30] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3609677267_Field); + let calldata: [Field; 1 + (30 * 1)] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn sha256_hash_50(self, data: [u8; 50]) { + let serialized_params: [Field; 50 * 1] = <[u8; 50] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(256881939_Field); + let calldata: [Field; 1 + (50 * 1)] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn sha256_hash_60(self, data: [u8; 60]) { + let serialized_params: [Field; 60 * 1] = <[u8; 60] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2495458303_Field); + let calldata: [Field; 1 + (60 * 1)] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn poseidon2_hash_1000fields(self, data: [Field; 1000]) { + let serialized_params: [Field; 1000 * 1] = <[Field; 1000] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(278602445_Field); + let calldata: [Field; 1 + (1000 * 1)] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn sha256_hash_70(self, data: [u8; 70]) { + let serialized_params: [Field; 70 * 1] = <[u8; 70] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2200074453_Field); + let calldata: [Field; 1 + (70 * 1)] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn sha256_hash_90(self, data: [u8; 90]) { + let serialized_params: [Field; 90 * 1] = <[u8; 90] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(799349905_Field); + let calldata: [Field; 1 + (90 * 1)] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn sha256_hash_40(self, data: [u8; 40]) { + let serialized_params: [Field; 40 * 1] = <[u8; 40] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(900925045_Field); + let calldata: [Field; 1 + (40 * 1)] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn sha256_hash_10(self, data: [u8; 10]) { + let serialized_params: [Field; 10 * 1] = <[u8; 10] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3545543018_Field); + let calldata: [Field; 1 + (10 * 1)] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn sha256_hash_1024(self, data: [u8; 1024]) { + let serialized_params: [Field; 1024 * 1] = <[u8; 1024] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2235915052_Field); + let calldata: [Field; 1 + (1024 * 1)] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn sha256_hash_255(self, data: [u8; 255]) { + let serialized_params: [Field; 255 * 1] = <[u8; 255] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3548859530_Field); + let calldata: [Field; 1 + (255 * 1)] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn sha256_hash_256(self, data: [u8; 256]) { + let serialized_params: [Field; 256 * 1] = <[u8; 256] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3409224101_Field); + let calldata: [Field; 1 + (256 * 1)] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn keccak_hash_1400(self, data: [u8; 1400]) { + let serialized_params: [Field; 1400 * 1] = <[u8; 1400] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(372001522_Field); + let calldata: [Field; 1 + (1400 * 1)] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn keccak_hash_300(self, data: [u8; 300]) { + let serialized_params: [Field; 300 * 1] = <[u8; 300] as aztec::protocol::traits::Serialize>::serialize(data); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3065624740_Field); + let calldata: [Field; 1 + (300 * 1)] = [::to_field(selector)].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + } + + pub struct EnqueueSelfStatic { + pub address: aztec::protocol::address::AztecAddress, + pub context: Context, + } + + pub struct CallSelfUtility { + pub address: aztec::protocol::address::AztecAddress, + } + + pub struct CallInternal { + pub context: Context, + } + + pub unconstrained fn public_dispatch(selector: Field) { + if selector == 1352369823_Field { + let input_calldata: [Field; 10 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 10] as aztec::protocol::traits::Serialize>::N); + let mut reader: aztec::protocol::utils::reader::Reader<10 * 1> = aztec::protocol::utils::reader::Reader::<10 * 1>::new(input_calldata); + let arg0: [u8; 10] = <[u8; 10] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let return_value: [Field; 32 * 1] = <[u8; 32] as aztec::protocol::traits::Serialize>::serialize(__aztec_nr_internals__keccak_hash(arg0)); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 3065624740_Field { + let input_calldata: [Field; 300 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 300] as aztec::protocol::traits::Serialize>::N); + let mut reader: aztec::protocol::utils::reader::Reader<300 * 1> = aztec::protocol::utils::reader::Reader::<300 * 1>::new(input_calldata); + let arg0: [u8; 300] = <[u8; 300] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let return_value: [Field; 32 * 1] = <[u8; 32] as aztec::protocol::traits::Serialize>::serialize(__aztec_nr_internals__keccak_hash_300(arg0)); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 372001522_Field { + let input_calldata: [Field; 1400 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 1400] as aztec::protocol::traits::Serialize>::N); + let mut reader: aztec::protocol::utils::reader::Reader<1400 * 1> = aztec::protocol::utils::reader::Reader::<1400 * 1>::new(input_calldata); + let arg0: [u8; 1400] = <[u8; 1400] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let return_value: [Field; 32 * 1] = <[u8; 32] as aztec::protocol::traits::Serialize>::serialize(__aztec_nr_internals__keccak_hash_1400(arg0)); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 1867977279_Field { + let input_calldata: [Field; 25 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u64; 25] as aztec::protocol::traits::Serialize>::N); + let mut reader: aztec::protocol::utils::reader::Reader<25 * 1> = aztec::protocol::utils::reader::Reader::<25 * 1>::new(input_calldata); + let arg0: [u64; 25] = <[u64; 25] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let return_value: [Field; 25 * 1] = <[u64; 25] as aztec::protocol::traits::Serialize>::serialize(__aztec_nr_internals__keccak_f1600(arg0)); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 3724082008_Field { + let input_calldata: [Field; 10 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[Field; 10] as aztec::protocol::traits::Serialize>::N); + let mut reader: aztec::protocol::utils::reader::Reader<10 * 1> = aztec::protocol::utils::reader::Reader::<10 * 1>::new(input_calldata); + let arg0: [Field; 10] = <[Field; 10] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let return_value: [Field; 1] = ::serialize(__aztec_nr_internals__poseidon2_hash(arg0)); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 278602445_Field { + let input_calldata: [Field; 1000 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[Field; 1000] as aztec::protocol::traits::Serialize>::N); + let mut reader: aztec::protocol::utils::reader::Reader<1000 * 1> = aztec::protocol::utils::reader::Reader::<1000 * 1>::new(input_calldata); + let arg0: [Field; 1000] = <[Field; 1000] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let return_value: [Field; 1] = ::serialize(__aztec_nr_internals__poseidon2_hash_1000fields(arg0)); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 3545543018_Field { + let input_calldata: [Field; 10 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 10] as aztec::protocol::traits::Serialize>::N); + let mut reader: aztec::protocol::utils::reader::Reader<10 * 1> = aztec::protocol::utils::reader::Reader::<10 * 1>::new(input_calldata); + let arg0: [u8; 10] = <[u8; 10] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let return_value: [Field; 32 * 1] = <[u8; 32] as aztec::protocol::traits::Serialize>::serialize(__aztec_nr_internals__sha256_hash_10(arg0)); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 2926274626_Field { + let input_calldata: [Field; 20 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 20] as aztec::protocol::traits::Serialize>::N); + let mut reader: aztec::protocol::utils::reader::Reader<20 * 1> = aztec::protocol::utils::reader::Reader::<20 * 1>::new(input_calldata); + let arg0: [u8; 20] = <[u8; 20] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let return_value: [Field; 32 * 1] = <[u8; 32] as aztec::protocol::traits::Serialize>::serialize(__aztec_nr_internals__sha256_hash_20(arg0)); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 3609677267_Field { + let input_calldata: [Field; 30 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 30] as aztec::protocol::traits::Serialize>::N); + let mut reader: aztec::protocol::utils::reader::Reader<30 * 1> = aztec::protocol::utils::reader::Reader::<30 * 1>::new(input_calldata); + let arg0: [u8; 30] = <[u8; 30] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let return_value: [Field; 32 * 1] = <[u8; 32] as aztec::protocol::traits::Serialize>::serialize(__aztec_nr_internals__sha256_hash_30(arg0)); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 900925045_Field { + let input_calldata: [Field; 40 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 40] as aztec::protocol::traits::Serialize>::N); + let mut reader: aztec::protocol::utils::reader::Reader<40 * 1> = aztec::protocol::utils::reader::Reader::<40 * 1>::new(input_calldata); + let arg0: [u8; 40] = <[u8; 40] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let return_value: [Field; 32 * 1] = <[u8; 32] as aztec::protocol::traits::Serialize>::serialize(__aztec_nr_internals__sha256_hash_40(arg0)); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 256881939_Field { + let input_calldata: [Field; 50 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 50] as aztec::protocol::traits::Serialize>::N); + let mut reader: aztec::protocol::utils::reader::Reader<50 * 1> = aztec::protocol::utils::reader::Reader::<50 * 1>::new(input_calldata); + let arg0: [u8; 50] = <[u8; 50] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let return_value: [Field; 32 * 1] = <[u8; 32] as aztec::protocol::traits::Serialize>::serialize(__aztec_nr_internals__sha256_hash_50(arg0)); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 2495458303_Field { + let input_calldata: [Field; 60 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 60] as aztec::protocol::traits::Serialize>::N); + let mut reader: aztec::protocol::utils::reader::Reader<60 * 1> = aztec::protocol::utils::reader::Reader::<60 * 1>::new(input_calldata); + let arg0: [u8; 60] = <[u8; 60] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let return_value: [Field; 32 * 1] = <[u8; 32] as aztec::protocol::traits::Serialize>::serialize(__aztec_nr_internals__sha256_hash_60(arg0)); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 2200074453_Field { + let input_calldata: [Field; 70 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 70] as aztec::protocol::traits::Serialize>::N); + let mut reader: aztec::protocol::utils::reader::Reader<70 * 1> = aztec::protocol::utils::reader::Reader::<70 * 1>::new(input_calldata); + let arg0: [u8; 70] = <[u8; 70] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let return_value: [Field; 32 * 1] = <[u8; 32] as aztec::protocol::traits::Serialize>::serialize(__aztec_nr_internals__sha256_hash_70(arg0)); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 4268069756_Field { + let input_calldata: [Field; 80 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 80] as aztec::protocol::traits::Serialize>::N); + let mut reader: aztec::protocol::utils::reader::Reader<80 * 1> = aztec::protocol::utils::reader::Reader::<80 * 1>::new(input_calldata); + let arg0: [u8; 80] = <[u8; 80] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let return_value: [Field; 32 * 1] = <[u8; 32] as aztec::protocol::traits::Serialize>::serialize(__aztec_nr_internals__sha256_hash_80(arg0)); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 799349905_Field { + let input_calldata: [Field; 90 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 90] as aztec::protocol::traits::Serialize>::N); + let mut reader: aztec::protocol::utils::reader::Reader<90 * 1> = aztec::protocol::utils::reader::Reader::<90 * 1>::new(input_calldata); + let arg0: [u8; 90] = <[u8; 90] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let return_value: [Field; 32 * 1] = <[u8; 32] as aztec::protocol::traits::Serialize>::serialize(__aztec_nr_internals__sha256_hash_90(arg0)); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 2074027672_Field { + let input_calldata: [Field; 100 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 100] as aztec::protocol::traits::Serialize>::N); + let mut reader: aztec::protocol::utils::reader::Reader<100 * 1> = aztec::protocol::utils::reader::Reader::<100 * 1>::new(input_calldata); + let arg0: [u8; 100] = <[u8; 100] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let return_value: [Field; 32 * 1] = <[u8; 32] as aztec::protocol::traits::Serialize>::serialize(__aztec_nr_internals__sha256_hash_100(arg0)); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 3548859530_Field { + let input_calldata: [Field; 255 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 255] as aztec::protocol::traits::Serialize>::N); + let mut reader: aztec::protocol::utils::reader::Reader<255 * 1> = aztec::protocol::utils::reader::Reader::<255 * 1>::new(input_calldata); + let arg0: [u8; 255] = <[u8; 255] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let return_value: [Field; 32 * 1] = <[u8; 32] as aztec::protocol::traits::Serialize>::serialize(__aztec_nr_internals__sha256_hash_255(arg0)); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 3409224101_Field { + let input_calldata: [Field; 256 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 256] as aztec::protocol::traits::Serialize>::N); + let mut reader: aztec::protocol::utils::reader::Reader<256 * 1> = aztec::protocol::utils::reader::Reader::<256 * 1>::new(input_calldata); + let arg0: [u8; 256] = <[u8; 256] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let return_value: [Field; 32 * 1] = <[u8; 32] as aztec::protocol::traits::Serialize>::serialize(__aztec_nr_internals__sha256_hash_256(arg0)); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 797967809_Field { + let input_calldata: [Field; 511 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 511] as aztec::protocol::traits::Serialize>::N); + let mut reader: aztec::protocol::utils::reader::Reader<511 * 1> = aztec::protocol::utils::reader::Reader::<511 * 1>::new(input_calldata); + let arg0: [u8; 511] = <[u8; 511] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let return_value: [Field; 32 * 1] = <[u8; 32] as aztec::protocol::traits::Serialize>::serialize(__aztec_nr_internals__sha256_hash_511(arg0)); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 2560938307_Field { + let input_calldata: [Field; 512 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 512] as aztec::protocol::traits::Serialize>::N); + let mut reader: aztec::protocol::utils::reader::Reader<512 * 1> = aztec::protocol::utils::reader::Reader::<512 * 1>::new(input_calldata); + let arg0: [u8; 512] = <[u8; 512] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let return_value: [Field; 32 * 1] = <[u8; 32] as aztec::protocol::traits::Serialize>::serialize(__aztec_nr_internals__sha256_hash_512(arg0)); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 2235915052_Field { + let input_calldata: [Field; 1024 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 1024] as aztec::protocol::traits::Serialize>::N); + let mut reader: aztec::protocol::utils::reader::Reader<1024 * 1> = aztec::protocol::utils::reader::Reader::<1024 * 1>::new(input_calldata); + let arg0: [u8; 1024] = <[u8; 1024] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let return_value: [Field; 32 * 1] = <[u8; 32] as aztec::protocol::traits::Serialize>::serialize(__aztec_nr_internals__sha256_hash_1024(arg0)); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 373006257_Field { + let input_calldata: [Field; 1536 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 1536] as aztec::protocol::traits::Serialize>::N); + let mut reader: aztec::protocol::utils::reader::Reader<1536 * 1> = aztec::protocol::utils::reader::Reader::<1536 * 1>::new(input_calldata); + let arg0: [u8; 1536] = <[u8; 1536] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let return_value: [Field; 32 * 1] = <[u8; 32] as aztec::protocol::traits::Serialize>::serialize(__aztec_nr_internals__sha256_hash_1536(arg0)); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 2669406607_Field { + let input_calldata: [Field; 10 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[Field; 10] as aztec::protocol::traits::Serialize>::N); + let mut reader: aztec::protocol::utils::reader::Reader<10 * 1> = aztec::protocol::utils::reader::Reader::<10 * 1>::new(input_calldata); + let arg0: [Field; 10] = <[Field; 10] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let return_value: [Field; 1] = ::serialize(__aztec_nr_internals__pedersen_hash(arg0)); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 3265405934_Field { + let input_calldata: [Field; 10 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[Field; 10] as aztec::protocol::traits::Serialize>::N); + let mut reader: aztec::protocol::utils::reader::Reader<10 * 1> = aztec::protocol::utils::reader::Reader::<10 * 1>::new(input_calldata); + let arg0: [Field; 10] = <[Field; 10] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let return_value: [Field; 1] = ::serialize(__aztec_nr_internals__pedersen_hash_with_index(arg0)); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + panic(f"Unknown selector {selector}") + } + + pub struct keccak_f1600_parameters { + pub data: [u64; 25], + } + + pub struct keccak_hash_1400_parameters { + pub data: [u8; 1400], + } + + pub struct keccak_hash_300_parameters { + pub data: [u8; 300], + } + + pub struct keccak_hash_parameters { + pub data: [u8; 10], + } + + pub struct pedersen_hash_parameters { + pub data: [Field; 10], + } + + pub struct pedersen_hash_with_index_parameters { + pub data: [Field; 10], + } + + pub struct poseidon2_hash_1000fields_parameters { + pub data: [Field; 1000], + } + + pub struct poseidon2_hash_parameters { + pub data: [Field; 10], + } + + pub struct sha256_hash_100_parameters { + pub data: [u8; 100], + } + + pub struct sha256_hash_1024_parameters { + pub data: [u8; 1024], + } + + pub struct sha256_hash_10_parameters { + pub data: [u8; 10], + } + + pub struct sha256_hash_1536_parameters { + pub data: [u8; 1536], + } + + pub struct sha256_hash_20_parameters { + pub data: [u8; 20], + } + + pub struct sha256_hash_255_parameters { + pub data: [u8; 255], + } + + pub struct sha256_hash_256_parameters { + pub data: [u8; 256], + } + + pub struct sha256_hash_30_parameters { + pub data: [u8; 30], + } + + pub struct sha256_hash_40_parameters { + pub data: [u8; 40], + } + + pub struct sha256_hash_50_parameters { + pub data: [u8; 50], + } + + pub struct sha256_hash_511_parameters { + pub data: [u8; 511], + } + + pub struct sha256_hash_512_parameters { + pub data: [u8; 512], + } + + pub struct sha256_hash_60_parameters { + pub data: [u8; 60], + } + + pub struct sha256_hash_70_parameters { + pub data: [u8; 70], + } + + pub struct sha256_hash_80_parameters { + pub data: [u8; 80], + } + + pub struct sha256_hash_90_parameters { + pub data: [u8; 90], + } + + #[abi(functions)] + pub struct keccak_f1600_abi { + parameters: keccak_f1600_parameters, + return_type: [u64; 25], + } + + #[abi(functions)] + pub struct keccak_hash_1400_abi { + parameters: keccak_hash_1400_parameters, + return_type: [u8; 32], + } + + #[abi(functions)] + pub struct keccak_hash_300_abi { + parameters: keccak_hash_300_parameters, + return_type: [u8; 32], + } + + #[abi(functions)] + pub struct keccak_hash_abi { + parameters: keccak_hash_parameters, + return_type: [u8; 32], + } + + #[abi(functions)] + pub struct pedersen_hash_abi { + parameters: pedersen_hash_parameters, + return_type: Field, + } + + #[abi(functions)] + pub struct pedersen_hash_with_index_abi { + parameters: pedersen_hash_with_index_parameters, + return_type: Field, + } + + #[abi(functions)] + pub struct poseidon2_hash_1000fields_abi { + parameters: poseidon2_hash_1000fields_parameters, + return_type: Field, + } + + #[abi(functions)] + pub struct poseidon2_hash_abi { + parameters: poseidon2_hash_parameters, + return_type: Field, + } + + #[abi(functions)] + pub struct sha256_hash_100_abi { + parameters: sha256_hash_100_parameters, + return_type: [u8; 32], + } + + #[abi(functions)] + pub struct sha256_hash_1024_abi { + parameters: sha256_hash_1024_parameters, + return_type: [u8; 32], + } + + #[abi(functions)] + pub struct sha256_hash_10_abi { + parameters: sha256_hash_10_parameters, + return_type: [u8; 32], + } + + #[abi(functions)] + pub struct sha256_hash_1536_abi { + parameters: sha256_hash_1536_parameters, + return_type: [u8; 32], + } + + #[abi(functions)] + pub struct sha256_hash_20_abi { + parameters: sha256_hash_20_parameters, + return_type: [u8; 32], + } + + #[abi(functions)] + pub struct sha256_hash_255_abi { + parameters: sha256_hash_255_parameters, + return_type: [u8; 32], + } + + #[abi(functions)] + pub struct sha256_hash_256_abi { + parameters: sha256_hash_256_parameters, + return_type: [u8; 32], + } + + #[abi(functions)] + pub struct sha256_hash_30_abi { + parameters: sha256_hash_30_parameters, + return_type: [u8; 32], + } + + #[abi(functions)] + pub struct sha256_hash_40_abi { + parameters: sha256_hash_40_parameters, + return_type: [u8; 32], + } + + #[abi(functions)] + pub struct sha256_hash_50_abi { + parameters: sha256_hash_50_parameters, + return_type: [u8; 32], + } + + #[abi(functions)] + pub struct sha256_hash_511_abi { + parameters: sha256_hash_511_parameters, + return_type: [u8; 32], + } + + #[abi(functions)] + pub struct sha256_hash_512_abi { + parameters: sha256_hash_512_parameters, + return_type: [u8; 32], + } + + #[abi(functions)] + pub struct sha256_hash_60_abi { + parameters: sha256_hash_60_parameters, + return_type: [u8; 32], + } + + #[abi(functions)] + pub struct sha256_hash_70_abi { + parameters: sha256_hash_70_parameters, + return_type: [u8; 32], + } + + #[abi(functions)] + pub struct sha256_hash_80_abi { + parameters: sha256_hash_80_parameters, + return_type: [u8; 32], + } + + #[abi(functions)] + pub struct sha256_hash_90_abi { + parameters: sha256_hash_90_parameters, + return_type: [u8; 32], + } + + unconstrained fn __aztec_nr_internals__keccak_f1600(data: [u64; 25]) -> pub [u64; 25] { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 25 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u64; 25] as aztec::protocol::traits::Serialize>::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: () = (); + let self_address: aztec::protocol::address::AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + std::hash::keccakf1600(data) + } + } + + unconstrained fn __aztec_nr_internals__keccak_hash(data: [u8; 10]) -> pub [u8; 32] { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 10 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 10] as aztec::protocol::traits::Serialize>::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: () = (); + let self_address: aztec::protocol::address::AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + keccak256::keccak256(data, data.len()) + } + } + + unconstrained fn __aztec_nr_internals__keccak_hash_1400(data: [u8; 1400]) -> pub [u8; 32] { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 1400 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 1400] as aztec::protocol::traits::Serialize>::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: () = (); + let self_address: aztec::protocol::address::AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + keccak256::keccak256(data, data.len()) + } + } + + unconstrained fn __aztec_nr_internals__keccak_hash_300(data: [u8; 300]) -> pub [u8; 32] { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 300 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 300] as aztec::protocol::traits::Serialize>::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: () = (); + let self_address: aztec::protocol::address::AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + keccak256::keccak256(data, data.len()) + } + } + + unconstrained fn __aztec_nr_internals__pedersen_hash(data: [Field; 10]) -> pub Field { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 10 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[Field; 10] as aztec::protocol::traits::Serialize>::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: () = (); + let self_address: aztec::protocol::address::AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + std::hash::pedersen_hash(data) + } + } + + unconstrained fn __aztec_nr_internals__pedersen_hash_with_index(data: [Field; 10]) -> pub Field { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 10 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[Field; 10] as aztec::protocol::traits::Serialize>::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: () = (); + let self_address: aztec::protocol::address::AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + std::hash::pedersen_hash_with_separator(data, 20_u32) + } + } + + unconstrained fn __aztec_nr_internals__poseidon2_hash(data: [Field; 10]) -> pub Field { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 10 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[Field; 10] as aztec::protocol::traits::Serialize>::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: () = (); + let self_address: aztec::protocol::address::AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + poseidon::poseidon2::Poseidon2::hash(data, data.len()) + } + } + + unconstrained fn __aztec_nr_internals__poseidon2_hash_1000fields(data: [Field; 1000]) -> pub Field { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 1000 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[Field; 1000] as aztec::protocol::traits::Serialize>::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: () = (); + let self_address: aztec::protocol::address::AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + poseidon::poseidon2::Poseidon2::hash(data, data.len()) + } + } + + unconstrained fn __aztec_nr_internals__sha256_hash_10(data: [u8; 10]) -> pub [u8; 32] { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 10 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 10] as aztec::protocol::traits::Serialize>::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: () = (); + let self_address: aztec::protocol::address::AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + sha256::sha256_var(data, data.len()) + } + } + + unconstrained fn __aztec_nr_internals__sha256_hash_100(data: [u8; 100]) -> pub [u8; 32] { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 100 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 100] as aztec::protocol::traits::Serialize>::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: () = (); + let self_address: aztec::protocol::address::AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + sha256::sha256_var(data, data.len()) + } + } + + unconstrained fn __aztec_nr_internals__sha256_hash_1024(data: [u8; 1024]) -> pub [u8; 32] { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 1024 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 1024] as aztec::protocol::traits::Serialize>::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: () = (); + let self_address: aztec::protocol::address::AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + sha256::sha256_var(data, data.len()) + } + } + + unconstrained fn __aztec_nr_internals__sha256_hash_1536(data: [u8; 1536]) -> pub [u8; 32] { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 1536 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 1536] as aztec::protocol::traits::Serialize>::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: () = (); + let self_address: aztec::protocol::address::AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + sha256::sha256_var(data, data.len()) + } + } + + unconstrained fn __aztec_nr_internals__sha256_hash_20(data: [u8; 20]) -> pub [u8; 32] { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 20 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 20] as aztec::protocol::traits::Serialize>::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: () = (); + let self_address: aztec::protocol::address::AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + sha256::sha256_var(data, data.len()) + } + } + + unconstrained fn __aztec_nr_internals__sha256_hash_255(data: [u8; 255]) -> pub [u8; 32] { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 255 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 255] as aztec::protocol::traits::Serialize>::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: () = (); + let self_address: aztec::protocol::address::AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + sha256::sha256_var(data, data.len()) + } + } + + unconstrained fn __aztec_nr_internals__sha256_hash_256(data: [u8; 256]) -> pub [u8; 32] { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 256 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 256] as aztec::protocol::traits::Serialize>::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: () = (); + let self_address: aztec::protocol::address::AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + sha256::sha256_var(data, data.len()) + } + } + + unconstrained fn __aztec_nr_internals__sha256_hash_30(data: [u8; 30]) -> pub [u8; 32] { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 30 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 30] as aztec::protocol::traits::Serialize>::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: () = (); + let self_address: aztec::protocol::address::AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + sha256::sha256_var(data, data.len()) + } + } + + unconstrained fn __aztec_nr_internals__sha256_hash_40(data: [u8; 40]) -> pub [u8; 32] { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 40 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 40] as aztec::protocol::traits::Serialize>::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: () = (); + let self_address: aztec::protocol::address::AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + sha256::sha256_var(data, data.len()) + } + } + + unconstrained fn __aztec_nr_internals__sha256_hash_50(data: [u8; 50]) -> pub [u8; 32] { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 50 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 50] as aztec::protocol::traits::Serialize>::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: () = (); + let self_address: aztec::protocol::address::AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + sha256::sha256_var(data, data.len()) + } + } + + unconstrained fn __aztec_nr_internals__sha256_hash_511(data: [u8; 511]) -> pub [u8; 32] { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 511 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 511] as aztec::protocol::traits::Serialize>::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: () = (); + let self_address: aztec::protocol::address::AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + sha256::sha256_var(data, data.len()) + } + } + + unconstrained fn __aztec_nr_internals__sha256_hash_512(data: [u8; 512]) -> pub [u8; 32] { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 512 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 512] as aztec::protocol::traits::Serialize>::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: () = (); + let self_address: aztec::protocol::address::AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + sha256::sha256_var(data, data.len()) + } + } + + unconstrained fn __aztec_nr_internals__sha256_hash_60(data: [u8; 60]) -> pub [u8; 32] { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 60 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 60] as aztec::protocol::traits::Serialize>::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: () = (); + let self_address: aztec::protocol::address::AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + sha256::sha256_var(data, data.len()) + } + } + + unconstrained fn __aztec_nr_internals__sha256_hash_70(data: [u8; 70]) -> pub [u8; 32] { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 70 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 70] as aztec::protocol::traits::Serialize>::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: () = (); + let self_address: aztec::protocol::address::AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + sha256::sha256_var(data, data.len()) + } + } + + unconstrained fn __aztec_nr_internals__sha256_hash_80(data: [u8; 80]) -> pub [u8; 32] { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 80 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 80] as aztec::protocol::traits::Serialize>::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: () = (); + let self_address: aztec::protocol::address::AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + sha256::sha256_var(data, data.len()) + } + } + + unconstrained fn __aztec_nr_internals__sha256_hash_90(data: [u8; 90]) -> pub [u8; 32] { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 90 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 90] as aztec::protocol::traits::Serialize>::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: () = (); + let self_address: aztec::protocol::address::AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + sha256::sha256_var(data, data.len()) + } + } +} + +// Warning: the generated code has syntax errors diff --git a/noir-projects/contract-snapshots/tests/snapshots/expand/avm_test_contract/snapshots__expanded.snap b/noir-projects/contract-snapshots/tests/snapshots/expand/avm_test_contract/snapshots__expanded.snap new file mode 100644 index 000000000000..7b88b9531a0c --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/expand/avm_test_contract/snapshots__expanded.snap @@ -0,0 +1,7788 @@ +--- +source: tests/snapshots.rs +expression: stdout +--- +use aztec::macros::aztec; +use aztec::macros::aztec; + +mod fake_avm_oracle { + use aztec::protocol::address::AztecAddress; + + pub unconstrained fn call(l2_gas_allocation: u32, da_gas_allocation: u32, address: AztecAddress, args: [Field; N]) { + call_opcode(l2_gas_allocation, da_gas_allocation, address, N, args) + } + + pub unconstrained fn success_copy() -> bool { + success_copy_opcode() + } + + pub unconstrained fn returndata_size() -> u32 { + returndata_size_opcode() + } + + pub unconstrained fn returndata_copy(rdoffset: u32, copy_size: u32) -> [Field] { + returndata_copy_opcode(rdoffset, copy_size) + } + + pub unconstrained fn avm_return(returndata: [Field]) { + return_opcode(returndata) + } + + pub unconstrained fn revert(revertdata: [Field]) { + revert_opcode(revertdata) + } + + #[oracle(aztec_avm_call)] + unconstrained fn call_opcode(l2_gas_allocation: u32, da_gas_allocation: u32, address: AztecAddress, length: u32, args: [Field; N]) {} + + #[oracle(aztec_avm_successCopy)] + unconstrained fn success_copy_opcode() -> bool {} + + #[oracle(aztec_avm_returndataSize)] + unconstrained fn returndata_size_opcode() -> u32 {} + + #[oracle(aztec_avm_returndataCopy)] + unconstrained fn returndata_copy_opcode(rdoffset: u32, copy_size: u32) -> [Field] {} + + #[oracle(aztec_avm_return)] + unconstrained fn return_opcode(returndata: [Field]) {} + + #[oracle(aztec_avm_revert)] + unconstrained fn revert_opcode(revertdata: [Field]) {} +} + +pub contract AvmTest { + use crate::note::Note; + use crate::fake_avm_oracle::avm_return; + use crate::fake_avm_oracle::call; + use crate::fake_avm_oracle::returndata_copy; + use crate::fake_avm_oracle::returndata_size; + use crate::fake_avm_oracle::revert; + use crate::fake_avm_oracle::success_copy; + use aztec::context::gas::GasOpts; + use aztec::macros::functions::external; + use aztec::macros::functions::view; + use aztec::macros::storage::storage; + use aztec::oracle::get_contract_instance::get_contract_instance_class_id_avm; + use aztec::oracle::get_contract_instance::get_contract_instance_deployer_avm; + use aztec::oracle::get_contract_instance::get_contract_instance_initialization_hash_avm; + use aztec::protocol::abis::function_selector::FunctionSelector; + use aztec::protocol::address::AztecAddress; + use aztec::protocol::address::EthAddress; + use aztec::protocol::point::Point; + use std::embedded_curve_ops::EmbeddedCurveScalar as Scalar; + use aztec::protocol::constants::CANONICAL_AUTH_REGISTRY_ADDRESS; + use aztec::protocol::constants::CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS; + use aztec::protocol::constants::FEE_JUICE_ADDRESS; + use aztec::protocol::constants::GRUMPKIN_ONE_X; + use aztec::protocol::constants::GRUMPKIN_ONE_Y; + use aztec::protocol::constants::MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS; + use aztec::protocol::contract_class_id::ContractClassId; + use aztec::protocol::storage::map::derive_storage_slot_in_map; + use aztec::protocol::traits::Empty; + use aztec::protocol::traits::FromField; + use aztec::protocol::traits::ToField; + use aztec::protocol::traits::Serialize; + use aztec::state_vars::Map; + use aztec::state_vars::PublicMutable; + use aztec::state_vars::StateVariable; + use compressed_string::CompressedString; + use std::embedded_curve_ops::multi_scalar_mul; + use auth_contract::AuthRegistry; + use aztec::context::PublicContext; + use fee_juice::FeeJuice; + use instance_contract::ContractInstanceRegistry; + use std::ops::Add; + + global big_field_128_bits: Field = 0x1234567890abcdef1234567890abcdef; + + global big_field_136_bits: Field = 0x991234567890abcdef1234567890abcdef; + + global big_field_254_bits: Field = 0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef; + + struct Storage { + single: PublicMutable, + list: PublicMutable, + map: Map, Context>, + } + + impl Storage { + fn init(context: Context) -> Self { + Self { single: as StateVariable<1, Context>>::new(context, 1_Field), list: as StateVariable<2, Context>>::new(context, 2_Field), map: , Context> as StateVariable<1, Context>>::new(context, 4_Field)} + } + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call set_storage_single. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn set_storage_single(a: Field); + + #[contract_library_method] + fn _set_storage_single(storage: Storage, a: Field) { + storage.single.write(a); + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call read_storage_single. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn read_storage_single() -> Field; + + #[contract_library_method] + fn _read_storage_single(storage: Storage) -> Field { + storage.single.read() + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call read_assert_storage_single. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn read_assert_storage_single(a: Field); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call set_read_storage_single. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn set_read_storage_single(a: Field) -> pub Field; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call set_storage_list. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn set_storage_list(a: Field, b: Field); + + #[contract_library_method] + fn _set_storage_list(storage: Storage, a: Field, b: Field) { + storage.list.write(Note { a: a, b: b}); + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call read_storage_list. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn read_storage_list() -> [Field; 2]; + + #[contract_library_method] + fn _read_storage_list(storage: Storage) -> [Field; 2] { + let note: Note = storage.list.read(); + note.serialize() + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call set_storage_map. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn set_storage_map(to: AztecAddress, amount: u32) -> Field; + + #[contract_library_method] + fn _set_storage_map(storage: Storage, to: AztecAddress, amount: u32) -> Field { + storage.map.at(to).write(amount); + derive_storage_slot_in_map(storage.map.get_storage_slot(), to) + } + + #[abi(storage)] + pub global STORAGE_LAYOUT_AvmTest: StorageLayout<7> = StorageLayout::<7> { + contract_name: "AvmTest", + fields: StorageLayoutFields { + single: aztec::state_vars::Storable { + slot: 0x01, + }, + list: aztec::state_vars::Storable { + slot: 0x02, + }, + map: aztec::state_vars::Storable { + slot: 0x04, + }, + }, + }; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call add_storage_map. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn add_storage_map(to: AztecAddress, amount: u32) -> Field; + + #[contract_library_method] + fn _add_storage_map(storage: Storage, to: AztecAddress, amount: u32) -> Field { + let new_balance: u32 = storage.map.at(to).read().add(amount); + storage.map.at(to).write(new_balance); + derive_storage_slot_in_map(storage.map.get_storage_slot(), to) + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call read_storage_map. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn read_storage_map(address: AztecAddress) -> u32; + + #[contract_library_method] + fn _read_storage_map(storage: Storage, address: AztecAddress) -> u32 { + storage.map.at(address).read() + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call add_args_return. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn add_args_return(arg_a: Field, arg_b: Field) -> Field; + + #[contract_library_method] + unconstrained fn add(lhs: Field, rhs: Field) -> Field { + lhs + rhs + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call set_opcode_u8. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn set_opcode_u8() -> u8; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call set_opcode_u8_view. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn set_opcode_u8_view() -> u8; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call set_opcode_u32. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn set_opcode_u32() -> u32; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call set_opcode_u64. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn set_opcode_u64() -> u64; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call set_opcode_small_field. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn set_opcode_small_field() -> Field; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call set_opcode_big_field. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn set_opcode_big_field() -> Field; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call set_opcode_really_big_field. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn set_opcode_really_big_field() -> Field; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call add_u128. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn add_u128(a: u128, b: u128) -> u128; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call modulo2. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn modulo2(a: u64) -> u64; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call elliptic_curve_add. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn elliptic_curve_add(lhs: Point, rhs: Point) -> Point; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call elliptic_curve_add_and_double. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn elliptic_curve_add_and_double() -> Point; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call variable_base_msm. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn variable_base_msm(scalar_lo: Field, scalar_hi: Field, scalar2_lo: Field, scalar2_hi: Field) -> Point; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call pedersen_commit. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn pedersen_commit(x: Field, y: Field) -> Point; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call conditional_move. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn conditional_move(x: [Field; 1], y: [Field; 1], b: bool) -> [Field; 1]; + + #[contract_library_method] + fn bitwise_ops(x: u32, y: u32) -> u32 { + let mut result: u32 = x & y; + result = result | x; + result = result >> (x % 32_u32); + result = result << (y % 32_u32); + result ^ y + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call u128_addition_overflow. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn u128_addition_overflow() -> u128; + + #[contract_library_method] + fn integer_division(x: u8, y: u8) -> u8 { + x / y + } + + #[contract_library_method] + fn field_division(x: Field, y: Field) -> Field { + x / y + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call to_le_bytes. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn to_le_bytes(input: Field) -> [u8; 10]; + + #[contract_library_method] + fn _to_le_bytes(input: Field) -> [u8; 10] { + input.to_le_bytes() + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call to_le_bits. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn to_le_bits(input: Field) -> [bool; 16]; + + #[contract_library_method] + fn _to_le_bits(input: Field) -> [bool; 16] { + input.to_le_bits() + } + + #[contract_library_method] + fn inner_helper_with_failed_assertion() { + let not_true: bool = false; + assert(not_true == true, "This assertion should fail!"); + } + + #[contract_library_method] + fn helper_with_failed_assertion() { + inner_helper_with_failed_assertion(); + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call assertion_failure. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn assertion_failure(); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call external_call_to_assertion_failure. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn external_call_to_assertion_failure(); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call divide_by_zero. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn divide_by_zero(denominator: u8) -> u8; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call external_call_to_divide_by_zero. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn external_call_to_divide_by_zero(); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call external_call_to_divide_by_zero_recovers. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn external_call_to_divide_by_zero_recovers(); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call debug_logging. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn debug_logging(); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call assert_same. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn assert_same(arg_a: Field, arg_b: Field) -> pub Field; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call assert_calldata_copy. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn assert_calldata_copy(args: [Field; 3], with_selector: bool); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call assert_calldata_copy_large. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn assert_calldata_copy_large(args: [Field; 300], with_selector: bool); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call returndata_copy_oracle. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn returndata_copy_oracle(); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call return_oracle. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn return_oracle() -> [Field; 3]; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call revert_oracle. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn revert_oracle() -> [Field; 3]; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call test_get_contract_instance. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn test_get_contract_instance(address: AztecAddress); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call test_get_contract_instance_matches. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn test_get_contract_instance_matches(address: AztecAddress, expected_deployer: AztecAddress, expected_class_id: ContractClassId, expected_initialization_hash: Field); + + #[contract_library_method] + fn _test_get_contract_instance_matches(address: AztecAddress, expected_deployer: AztecAddress, expected_class_id: ContractClassId, expected_initialization_hash: Field) { + let deployer: Option = get_contract_instance_deployer_avm(address); + let class_id: Option = get_contract_instance_class_id_avm(address); + let initialization_hash: Option = get_contract_instance_initialization_hash_avm(address); + assert(deployer.is_some(), "Contract instance not found when getting DEPLOYER!"); + assert(class_id.is_some(), "Contract instance not found when getting CLASS_ID!"); + assert(initialization_hash.is_some(), "Contract instance not found when getting INIT_HASH!"); + assert(deployer.unwrap().eq(expected_deployer)); + assert(class_id.unwrap().eq(expected_class_id)); + assert(initialization_hash.unwrap().eq(expected_initialization_hash)); + aztec::oracle::logging::debug_log("Get Contract Instance Protocol Contract Instance"); + let fee_juice_class_id: Option = get_contract_instance_class_id_avm(FEE_JUICE_ADDRESS); + assert(fee_juice_class_id.is_some(), "Protocol Contract instance not found when getting CLASS_ID!"); + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call get_address. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn get_address() -> AztecAddress; + + #[contract_library_method] + fn _get_address(address: AztecAddress) -> AztecAddress { + address + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call get_sender. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn get_sender() -> AztecAddress; + + #[contract_library_method] + fn _get_sender(context: PublicContext) -> AztecAddress { + context.maybe_msg_sender().unwrap() + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call get_transaction_fee. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn get_transaction_fee() -> Field; + + #[contract_library_method] + fn _get_transaction_fee(context: PublicContext) -> Field { + context.transaction_fee() + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call get_chain_id. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn get_chain_id() -> Field; + + #[contract_library_method] + fn _get_chain_id(context: PublicContext) -> Field { + context.chain_id() + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call get_version. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn get_version() -> Field; + + #[contract_library_method] + fn _get_version(context: PublicContext) -> Field { + context.version() + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call get_block_number. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn get_block_number() -> u32; + + #[contract_library_method] + fn _get_block_number(context: PublicContext) -> u32 { + context.block_number() + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call get_timestamp. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn get_timestamp() -> u64; + + #[contract_library_method] + fn _get_timestamp(context: PublicContext) -> u64 { + context.timestamp() + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call get_fee_per_l2_gas. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn get_fee_per_l2_gas() -> u128; + + #[contract_library_method] + fn _get_fee_per_l2_gas(context: PublicContext) -> u128 { + context.min_fee_per_l2_gas() + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call get_fee_per_da_gas. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn get_fee_per_da_gas() -> u128; + + #[contract_library_method] + fn _get_fee_per_da_gas(context: PublicContext) -> u128 { + context.min_fee_per_da_gas() + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call get_l2_gas_left. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn get_l2_gas_left() -> u32; + + #[contract_library_method] + fn _get_l2_gas_left(context: PublicContext) -> u32 { + context.l2_gas_left() + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call get_da_gas_left. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn get_da_gas_left() -> u32; + + #[contract_library_method] + fn _get_da_gas_left(context: PublicContext) -> u32 { + context.da_gas_left() + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call get_args_hash. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn get_args_hash(_a: u8, _fields: [Field; 3]) -> Field; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call emit_public_log. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn emit_public_log(); + + #[contract_library_method] + fn _emit_public_log(context: PublicContext) { + context.emit_public_log_unsafe(0_Field, [10_Field, 20_Field, 30_Field]); + context.emit_public_log_unsafe(0_Field, "Hello, world!"); + let s: CompressedString<2, 44> = CompressedString::<2, 44>::from_string("A long time ago, in a galaxy far far away..."); + context.emit_public_log_unsafe(0_Field, s); + context.emit_public_log_unsafe(0_Field, [1_Field, 2_Field, 3_Field, 4_Field, 5_Field, 6_Field, 7_Field, 8_Field, 9_Field, 10_Field, 11_Field, 12_Field, 13_Field, 14_Field, 15_Field, 16_Field, 17_Field, 18_Field, 19_Field, 20_Field, 21_Field, 22_Field, 23_Field, 24_Field, 25_Field, 26_Field, 27_Field, 28_Field, 29_Field, 30_Field, 31_Field, 32_Field, 33_Field, 34_Field, 35_Field, 36_Field, 37_Field, 38_Field, 39_Field, 40_Field, 41_Field, 42_Field]); + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call note_hash_exists. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn note_hash_exists(note_hash: Field, leaf_index: u64) -> bool; + + #[contract_library_method] + fn _note_hash_exists(context: PublicContext, note_hash: Field, leaf_index: u64) -> bool { + context.note_hash_exists(note_hash, leaf_index) + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call new_note_hash. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn new_note_hash(note_hash: Field); + + #[contract_library_method] + fn _new_note_hash(context: PublicContext, note_hash: Field) { + context.push_note_hash(note_hash); + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call new_nullifier. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn new_nullifier(nullifier: Field); + + #[contract_library_method] + fn _new_nullifier(context: PublicContext, nullifier: Field) { + context.push_nullifier(nullifier); + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call n_storage_writes. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn n_storage_writes(num: u32); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call n_new_note_hashes. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn n_new_note_hashes(num: u32); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call n_new_nullifiers. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn n_new_nullifiers(num: u32); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call n_new_l2_to_l1_msgs. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn n_new_l2_to_l1_msgs(num: u32); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call raw_l2_to_l1_msg. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn raw_l2_to_l1_msg(recipient: EthAddress, content: Field); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call n_new_public_logs. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn n_new_public_logs(num: u32); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call nullifier_exists. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn nullifier_exists(nullifier: Field) -> bool; + + #[contract_library_method] + fn _nullifier_exists(context: PublicContext, address: AztecAddress, nullifier: Field) -> bool { + context.nullifier_exists_unsafe(nullifier, address) + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call assert_nullifier_exists. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn assert_nullifier_exists(nullifier: Field); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call emit_nullifier_and_check. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn emit_nullifier_and_check(nullifier: Field); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call nullifier_collision. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn nullifier_collision(nullifier: Field); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call l1_to_l2_msg_exists. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn l1_to_l2_msg_exists(msg_hash: Field, msg_leaf_index: Field) -> bool; + + #[contract_library_method] + fn _l1_to_l2_msg_exists(context: PublicContext, msg_hash: Field, msg_leaf_index: Field) -> bool { + context.l1_to_l2_msg_exists(msg_hash, msg_leaf_index) + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call send_l2_to_l1_msg. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn send_l2_to_l1_msg(recipient: EthAddress, content: Field); + + #[contract_library_method] + fn _send_l2_to_l1_msg(context: PublicContext, recipient: EthAddress, content: Field) { + context.message_portal(recipient, content) + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call nested_call_to_nothing. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn nested_call_to_nothing(); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call nested_call_to_nothing_recovers. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn nested_call_to_nothing_recovers(); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call nested_call_to_add_with_gas. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn nested_call_to_add_with_gas(arg_a: Field, arg_b: Field, l2_gas: u32, da_gas: u32) -> pub Field; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call nested_call_to_add. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn nested_call_to_add(arg_a: Field, arg_b: Field) -> pub Field; + + #[contract_library_method] + unconstrained fn _nested_call_to_add(context: PublicContext, address: AztecAddress, arg_a: Field, arg_b: Field) -> Field { + AvmTest::at(address).add_args_return(arg_a, arg_b).call(context) + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call nested_call_to_add_n_times_different_addresses. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn nested_call_to_add_n_times_different_addresses(addrs: [AztecAddress; 23]); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call nested_static_call_to_add. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn nested_static_call_to_add(arg_a: Field, arg_b: Field) -> pub Field; + + #[contract_library_method] + unconstrained fn _nested_static_call_to_add(context: PublicContext, address: AztecAddress, arg_a: Field, arg_b: Field) -> Field { + let selector: FunctionSelector = FunctionSelector { inner: 2858633377_u32}; + context.static_call_public_function(address, selector, [arg_a, arg_b], GasOpts::default())[0_u32] + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call nested_static_call_to_set_storage. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn nested_static_call_to_set_storage(); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call create_same_nullifier_in_nested_call. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn create_same_nullifier_in_nested_call(nestedAddress: AztecAddress, nullifier: Field); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call create_different_nullifier_in_nested_call. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn create_different_nullifier_in_nested_call(nestedAddress: AztecAddress, nullifier: Field); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call nested_call_to_assert_same. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn nested_call_to_assert_same(arg_a: Field, arg_b: Field) -> pub Field; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call fn_w_large_calldata. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn fn_w_large_calldata(_arr: [Field; 300]) -> pub Field; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call nested_call_large_calldata. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn nested_call_large_calldata(arr: [Field; 300]) -> pub Field; + + #[deprecated(deny, "Direct invocation of private functions is not supported. You attempted to call enqueue_public_from_private. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn enqueue_public_from_private(); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call call_fee_juice. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn call_fee_juice(); + + #[contract_library_method] + unconstrained fn _call_fee_juice(context: PublicContext, address: AztecAddress) { + let _: u128 = FeeJuice::at(FEE_JUICE_ADDRESS).balance_of_public(address).view(context); + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call call_auth_registry. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn call_auth_registry(); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call call_instance_registry. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn call_instance_registry(); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call bulk_testing. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn bulk_testing(args_field: [Field; 10], args_u8: [u8; 10], get_instance_for_address: AztecAddress, expected_deployer: AztecAddress, expected_class_id: ContractClassId, expected_initialization_hash: Field, skip_strictly_limited_side_effects: bool); + + /// Unpacks an array into a note corresponding to `note_type_id` and then computes its note hash (non-siloed) and inner nullifier (non-siloed) assuming the note has been inserted into the note hash tree with `note_nonce`. + /// + /// This function is automatically injected by the `#[aztec]` macro. + #[contract_library_method] + #[allow(dead_code)] + unconstrained fn _compute_note_hash_and_nullifier(packed_note: BoundedVec, owner: AztecAddress, storage_slot: Field, note_type_id: Field, contract_address: AztecAddress, randomness: Field, note_nonce: Field) -> Option { + _compute_note_hash(packed_note, owner, storage_slot, note_type_id, contract_address, randomness).map(|note_hash: Field| -> aztec::messages::discovery::NoteHashAndNullifier { + let siloed_note_hash: Field = aztec::protocol::hash::compute_siloed_note_hash(contract_address, note_hash); + let unique_note_hash: Field = aztec::protocol::hash::compute_unique_note_hash(note_nonce, siloed_note_hash); + let inner_nullifier: Option = _compute_note_nullifier(unique_note_hash, packed_note, owner, storage_slot, note_type_id, contract_address, randomness); + aztec::messages::discovery::NoteHashAndNullifier { note_hash: note_hash, inner_nullifier: inner_nullifier} + }) + } + + /// This contract does not use private notes, so this function should never be called as it will unconditionally fail. + /// + /// This function is automatically injected by the `#[aztec]` macro. + #[contract_library_method] + unconstrained fn _compute_note_hash(_packed_note: BoundedVec, _owner: AztecAddress, _storage_slot: Field, _note_type_id: Field, _contract_address: AztecAddress, _randomness: Field) -> Option { + panic(f"This contract does not use private notes") + } + + /// This contract does not use private notes, so this function should never be called as it will unconditionally fail. + /// + /// This function is automatically injected by the `#[aztec]` macro. + #[contract_library_method] + unconstrained fn _compute_note_nullifier(_unique_note_hash: Field, _packed_note: BoundedVec, _owner: AztecAddress, _storage_slot: Field, _note_type_id: Field, _contract_address: AztecAddress, _randomness: Field) -> Option { + panic(f"This contract does not use private notes") + } + + /// Receives offchain messages into this contract's offchain inbox for subsequent processing. + /// + /// Each message is routed to the inbox scoped to its `recipient` field. + /// + /// For more details, see `aztec::messages::processing::offchain::receive`. + /// + /// This function is automatically injected by the `#[aztec]` macro. + unconstrained fn offchain_receive(messages: BoundedVec) { + let address: AztecAddress = aztec::context::UtilityContext::new().this_address(); + aztec::messages::processing::offchain::receive(address, messages); + } + + pub struct AvmTest { + pub target_contract: AztecAddress, + } + + impl AvmTest { + pub fn storage_layout() -> StorageLayoutFields { + STORAGE_LAYOUT_AvmTest.fields + } + + pub fn at(addr: AztecAddress) -> Self { + Self { target_contract: addr} + } + + pub fn interface() -> Self { + Self { target_contract: AztecAddress::zero()} + } + + pub fn assert_calldata_copy(self, args: [Field; 3], with_selector: bool) -> aztec::context::calls::PublicCall<20, 4, ()> { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 3 * 1] = args.serialize(); + let serialized_member_len: u32 = <[Field; 3] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = with_selector.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(3853740100_Field); + aztec::context::calls::PublicCall::<20, 4, ()>::new(self.target_contract, selector, "assert_calldata_copy", serialized_params) + } + + pub fn get_chain_id(self) -> aztec::context::calls::PublicCall<12, 0, Field> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(1458572288_Field); + aztec::context::calls::PublicCall::<12, 0, Field>::new(self.target_contract, selector, "get_chain_id", serialized_params) + } + + pub fn get_args_hash(self, _a: u8, _fields: [Field; 3]) -> aztec::context::calls::PublicCall<13, 4, Field> { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = _a.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 3 * 1] = _fields.serialize(); + let serialized_member_len: u32 = <[Field; 3] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(1608415988_Field); + aztec::context::calls::PublicCall::<13, 4, Field>::new(self.target_contract, selector, "get_args_hash", serialized_params) + } + + pub fn external_call_to_divide_by_zero(self) -> aztec::context::calls::PublicCall<31, 0, ()> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(3880450065_Field); + aztec::context::calls::PublicCall::<31, 0, ()>::new(self.target_contract, selector, "external_call_to_divide_by_zero", serialized_params) + } + + pub fn n_new_nullifiers(self, num: u32) -> aztec::context::calls::PublicCall<16, 1, ()> { + let serialized_params: [Field; 1] = num.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(592684400_Field); + aztec::context::calls::PublicCall::<16, 1, ()>::new(self.target_contract, selector, "n_new_nullifiers", serialized_params) + } + + pub fn new_note_hash(self, note_hash: Field) -> aztec::context::calls::PublicCall<13, 1, ()> { + let serialized_params: [Field; 1] = note_hash.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(1524332459_Field); + aztec::context::calls::PublicCall::<13, 1, ()>::new(self.target_contract, selector, "new_note_hash", serialized_params) + } + + pub fn nullifier_collision(self, nullifier: Field) -> aztec::context::calls::PublicCall<19, 1, ()> { + let serialized_params: [Field; 1] = nullifier.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2417179850_Field); + aztec::context::calls::PublicCall::<19, 1, ()>::new(self.target_contract, selector, "nullifier_collision", serialized_params) + } + + pub fn get_l2_gas_left(self) -> aztec::context::calls::PublicCall<15, 0, u32> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(1635524210_Field); + aztec::context::calls::PublicCall::<15, 0, u32>::new(self.target_contract, selector, "get_l2_gas_left", serialized_params) + } + + pub fn l1_to_l2_msg_exists(self, msg_hash: Field, msg_leaf_index: Field) -> aztec::context::calls::PublicCall<19, 2, bool> { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = msg_hash.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = msg_leaf_index.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(3972971575_Field); + aztec::context::calls::PublicCall::<19, 2, bool>::new(self.target_contract, selector, "l1_to_l2_msg_exists", serialized_params) + } + + pub fn add_storage_map(self, to: AztecAddress, amount: u32) -> aztec::context::calls::PublicCall<15, 2, Field> { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = to.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = amount.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(2606877757_Field); + aztec::context::calls::PublicCall::<15, 2, Field>::new(self.target_contract, selector, "add_storage_map", serialized_params) + } + + pub fn bulk_testing(self, args_field: [Field; 10], args_u8: [u8; 10], get_instance_for_address: AztecAddress, expected_deployer: AztecAddress, expected_class_id: ContractClassId, expected_initialization_hash: Field, skip_strictly_limited_side_effects: bool) -> aztec::context::calls::PublicCall<12, 25, ()> { + let mut serialized_params: [Field; 25] = [0_Field; 25]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 10 * 1] = args_field.serialize(); + let serialized_member_len: u32 = <[Field; 10] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 10 * 1] = args_u8.serialize(); + let serialized_member_len: u32 = <[u8; 10] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = get_instance_for_address.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = expected_deployer.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = expected_class_id.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_4: u32 = i + offset; + serialized_params[i_4] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = expected_initialization_hash.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_5: u32 = i + offset; + serialized_params[i_5] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = skip_strictly_limited_side_effects.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_6: u32 = i + offset; + serialized_params[i_6] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(43639379_Field); + aztec::context::calls::PublicCall::<12, 25, ()>::new(self.target_contract, selector, "bulk_testing", serialized_params) + } + + pub fn variable_base_msm(self, scalar_lo: Field, scalar_hi: Field, scalar2_lo: Field, scalar2_hi: Field) -> aztec::context::calls::PublicCall<17, 4, Point> { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = scalar_lo.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = scalar_hi.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = scalar2_lo.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = scalar2_hi.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(2931784034_Field); + aztec::context::calls::PublicCall::<17, 4, Point>::new(self.target_contract, selector, "variable_base_msm", serialized_params) + } + + pub fn add_args_return(self, arg_a: Field, arg_b: Field) -> aztec::context::calls::PublicCall<15, 2, Field> { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = arg_a.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = arg_b.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(2858633377_Field); + aztec::context::calls::PublicCall::<15, 2, Field>::new(self.target_contract, selector, "add_args_return", serialized_params) + } + + pub fn test_get_contract_instance_matches(self, address: AztecAddress, expected_deployer: AztecAddress, expected_class_id: ContractClassId, expected_initialization_hash: Field) -> aztec::context::calls::PublicCall<34, 4, ()> { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = address.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = expected_deployer.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = expected_class_id.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = expected_initialization_hash.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(2723912183_Field); + aztec::context::calls::PublicCall::<34, 4, ()>::new(self.target_contract, selector, "test_get_contract_instance_matches", serialized_params) + } + + pub fn get_sender(self) -> aztec::context::calls::PublicCall<10, 0, AztecAddress> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(301170519_Field); + aztec::context::calls::PublicCall::<10, 0, AztecAddress>::new(self.target_contract, selector, "get_sender", serialized_params) + } + + pub fn n_new_l2_to_l1_msgs(self, num: u32) -> aztec::context::calls::PublicCall<19, 1, ()> { + let serialized_params: [Field; 1] = num.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(3921925917_Field); + aztec::context::calls::PublicCall::<19, 1, ()>::new(self.target_contract, selector, "n_new_l2_to_l1_msgs", serialized_params) + } + + pub fn set_storage_list(self, a: Field, b: Field) -> aztec::context::calls::PublicCall<16, 2, ()> { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = a.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = b.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(1745164739_Field); + aztec::context::calls::PublicCall::<16, 2, ()>::new(self.target_contract, selector, "set_storage_list", serialized_params) + } + + pub fn pedersen_commit(self, x: Field, y: Field) -> aztec::context::calls::PublicCall<15, 2, Point> { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = x.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = y.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(2484465428_Field); + aztec::context::calls::PublicCall::<15, 2, Point>::new(self.target_contract, selector, "pedersen_commit", serialized_params) + } + + pub fn nullifier_exists(self, nullifier: Field) -> aztec::context::calls::PublicCall<16, 1, bool> { + let serialized_params: [Field; 1] = nullifier.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2051407563_Field); + aztec::context::calls::PublicCall::<16, 1, bool>::new(self.target_contract, selector, "nullifier_exists", serialized_params) + } + + pub fn read_storage_list(self) -> aztec::context::calls::PublicCall<17, 0, [Field; 2]> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(1727615163_Field); + aztec::context::calls::PublicCall::<17, 0, [Field; 2]>::new(self.target_contract, selector, "read_storage_list", serialized_params) + } + + pub fn emit_nullifier_and_check(self, nullifier: Field) -> aztec::context::calls::PublicCall<24, 1, ()> { + let serialized_params: [Field; 1] = nullifier.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2367487025_Field); + aztec::context::calls::PublicCall::<24, 1, ()>::new(self.target_contract, selector, "emit_nullifier_and_check", serialized_params) + } + + pub fn assert_same(self, arg_a: Field, arg_b: Field) -> aztec::context::calls::PublicCall<11, 2, Field> { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = arg_a.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = arg_b.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(290442984_Field); + aztec::context::calls::PublicCall::<11, 2, Field>::new(self.target_contract, selector, "assert_same", serialized_params) + } + + pub fn get_fee_per_da_gas(self) -> aztec::context::calls::PublicCall<18, 0, u128> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(514475538_Field); + aztec::context::calls::PublicCall::<18, 0, u128>::new(self.target_contract, selector, "get_fee_per_da_gas", serialized_params) + } + + pub fn modulo2(self, a: u64) -> aztec::context::calls::PublicCall<7, 1, u64> { + let serialized_params: [Field; 1] = a.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(222531562_Field); + aztec::context::calls::PublicCall::<7, 1, u64>::new(self.target_contract, selector, "modulo2", serialized_params) + } + + pub fn nested_static_call_to_add(self, arg_a: Field, arg_b: Field) -> aztec::context::calls::PublicCall<25, 2, Field> { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = arg_a.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = arg_b.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(1362946309_Field); + aztec::context::calls::PublicCall::<25, 2, Field>::new(self.target_contract, selector, "nested_static_call_to_add", serialized_params) + } + + pub fn to_le_bits(self, input: Field) -> aztec::context::calls::PublicCall<10, 1, [bool; 16]> { + let serialized_params: [Field; 1] = input.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2961959597_Field); + aztec::context::calls::PublicCall::<10, 1, [bool; 16]>::new(self.target_contract, selector, "to_le_bits", serialized_params) + } + + pub fn call_auth_registry(self) -> aztec::context::calls::PublicCall<18, 0, ()> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(1225767423_Field); + aztec::context::calls::PublicCall::<18, 0, ()>::new(self.target_contract, selector, "call_auth_registry", serialized_params) + } + + pub fn set_opcode_u64(self) -> aztec::context::calls::PublicCall<14, 0, u64> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(1435480431_Field); + aztec::context::calls::PublicCall::<14, 0, u64>::new(self.target_contract, selector, "set_opcode_u64", serialized_params) + } + + pub fn return_oracle(self) -> aztec::context::calls::PublicCall<13, 0, [Field; 3]> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(3794636397_Field); + aztec::context::calls::PublicCall::<13, 0, [Field; 3]>::new(self.target_contract, selector, "return_oracle", serialized_params) + } + + pub fn test_get_contract_instance(self, address: AztecAddress) -> aztec::context::calls::PublicCall<26, 1, ()> { + let serialized_params: [Field; 1] = address.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2488367864_Field); + aztec::context::calls::PublicCall::<26, 1, ()>::new(self.target_contract, selector, "test_get_contract_instance", serialized_params) + } + + pub fn get_timestamp(self) -> aztec::context::calls::PublicCall<13, 0, u64> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(448989811_Field); + aztec::context::calls::PublicCall::<13, 0, u64>::new(self.target_contract, selector, "get_timestamp", serialized_params) + } + + pub fn to_le_bytes(self, input: Field) -> aztec::context::calls::PublicCall<11, 1, [u8; 10]> { + let serialized_params: [Field; 1] = input.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(1975931334_Field); + aztec::context::calls::PublicCall::<11, 1, [u8; 10]>::new(self.target_contract, selector, "to_le_bytes", serialized_params) + } + + pub fn external_call_to_assertion_failure(self) -> aztec::context::calls::PublicCall<34, 0, ()> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(294808228_Field); + aztec::context::calls::PublicCall::<34, 0, ()>::new(self.target_contract, selector, "external_call_to_assertion_failure", serialized_params) + } + + pub fn divide_by_zero(self, denominator: u8) -> aztec::context::calls::PublicCall<14, 1, u8> { + let serialized_params: [Field; 1] = denominator.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(815932481_Field); + aztec::context::calls::PublicCall::<14, 1, u8>::new(self.target_contract, selector, "divide_by_zero", serialized_params) + } + + pub fn emit_public_log(self) -> aztec::context::calls::PublicCall<15, 0, ()> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(2033426724_Field); + aztec::context::calls::PublicCall::<15, 0, ()>::new(self.target_contract, selector, "emit_public_log", serialized_params) + } + + pub fn new_nullifier(self, nullifier: Field) -> aztec::context::calls::PublicCall<13, 1, ()> { + let serialized_params: [Field; 1] = nullifier.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(3648851082_Field); + aztec::context::calls::PublicCall::<13, 1, ()>::new(self.target_contract, selector, "new_nullifier", serialized_params) + } + + pub fn raw_l2_to_l1_msg(self, recipient: EthAddress, content: Field) -> aztec::context::calls::PublicCall<16, 2, ()> { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = recipient.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = content.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(3409962923_Field); + aztec::context::calls::PublicCall::<16, 2, ()>::new(self.target_contract, selector, "raw_l2_to_l1_msg", serialized_params) + } + + pub fn nested_call_to_nothing_recovers(self) -> aztec::context::calls::PublicCall<31, 0, ()> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(1843532057_Field); + aztec::context::calls::PublicCall::<31, 0, ()>::new(self.target_contract, selector, "nested_call_to_nothing_recovers", serialized_params) + } + + pub fn assert_calldata_copy_large(self, args: [Field; 300], with_selector: bool) -> aztec::context::calls::PublicCall<26, 301, ()> { + let mut serialized_params: [Field; 301] = [0_Field; 301]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 300 * 1] = args.serialize(); + let serialized_member_len: u32 = <[Field; 300] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = with_selector.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(2293565755_Field); + aztec::context::calls::PublicCall::<26, 301, ()>::new(self.target_contract, selector, "assert_calldata_copy_large", serialized_params) + } + + pub fn set_opcode_really_big_field(self) -> aztec::context::calls::PublicCall<27, 0, Field> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(4095821182_Field); + aztec::context::calls::PublicCall::<27, 0, Field>::new(self.target_contract, selector, "set_opcode_really_big_field", serialized_params) + } + + pub fn enqueue_public_from_private(self) -> aztec::context::calls::PrivateCall<27, 0, ()> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(2771384488_Field); + aztec::context::calls::PrivateCall::<27, 0, ()>::new(self.target_contract, selector, "enqueue_public_from_private", serialized_params) + } + + pub fn elliptic_curve_add(self, lhs: Point, rhs: Point) -> aztec::context::calls::PublicCall<18, 6, Point> { + let mut serialized_params: [Field; 6] = [0_Field; 6]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 3] = lhs.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 3] = rhs.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(1700026912_Field); + aztec::context::calls::PublicCall::<18, 6, Point>::new(self.target_contract, selector, "elliptic_curve_add", serialized_params) + } + + pub fn set_read_storage_single(self, a: Field) -> aztec::context::calls::PublicCall<23, 1, Field> { + let serialized_params: [Field; 1] = a.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(1932358992_Field); + aztec::context::calls::PublicCall::<23, 1, Field>::new(self.target_contract, selector, "set_read_storage_single", serialized_params) + } + + pub fn returndata_copy_oracle(self) -> aztec::context::calls::PublicCall<22, 0, ()> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(4172530660_Field); + aztec::context::calls::PublicCall::<22, 0, ()>::new(self.target_contract, selector, "returndata_copy_oracle", serialized_params) + } + + pub fn conditional_move(self, x: [Field; 1], y: [Field; 1], b: bool) -> aztec::context::calls::PublicCall<16, 3, [Field; 1]> { + let mut serialized_params: [Field; 3] = [0_Field; 3]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1 * 1] = x.serialize(); + let serialized_member_len: u32 = <[Field; 1] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1 * 1] = y.serialize(); + let serialized_member_len: u32 = <[Field; 1] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = b.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(2633971407_Field); + aztec::context::calls::PublicCall::<16, 3, [Field; 1]>::new(self.target_contract, selector, "conditional_move", serialized_params) + } + + pub fn set_opcode_small_field(self) -> aztec::context::calls::PublicCall<22, 0, Field> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(3464175345_Field); + aztec::context::calls::PublicCall::<22, 0, Field>::new(self.target_contract, selector, "set_opcode_small_field", serialized_params) + } + + pub fn n_new_public_logs(self, num: u32) -> aztec::context::calls::PublicCall<17, 1, ()> { + let serialized_params: [Field; 1] = num.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2907114368_Field); + aztec::context::calls::PublicCall::<17, 1, ()>::new(self.target_contract, selector, "n_new_public_logs", serialized_params) + } + + pub fn nested_call_to_nothing(self) -> aztec::context::calls::PublicCall<22, 0, ()> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(1183868090_Field); + aztec::context::calls::PublicCall::<22, 0, ()>::new(self.target_contract, selector, "nested_call_to_nothing", serialized_params) + } + + pub fn nested_call_to_add_with_gas(self, arg_a: Field, arg_b: Field, l2_gas: u32, da_gas: u32) -> aztec::context::calls::PublicCall<27, 4, Field> { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = arg_a.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = arg_b.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = l2_gas.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = da_gas.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(3561659563_Field); + aztec::context::calls::PublicCall::<27, 4, Field>::new(self.target_contract, selector, "nested_call_to_add_with_gas", serialized_params) + } + + pub fn create_different_nullifier_in_nested_call(self, nestedAddress: AztecAddress, nullifier: Field) -> aztec::context::calls::PublicCall<41, 2, ()> { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = nestedAddress.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = nullifier.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(1630216043_Field); + aztec::context::calls::PublicCall::<41, 2, ()>::new(self.target_contract, selector, "create_different_nullifier_in_nested_call", serialized_params) + } + + pub fn call_fee_juice(self) -> aztec::context::calls::PublicCall<14, 0, ()> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(2734888597_Field); + aztec::context::calls::PublicCall::<14, 0, ()>::new(self.target_contract, selector, "call_fee_juice", serialized_params) + } + + pub fn get_transaction_fee(self) -> aztec::context::calls::PublicCall<19, 0, Field> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(2524054657_Field); + aztec::context::calls::PublicCall::<19, 0, Field>::new(self.target_contract, selector, "get_transaction_fee", serialized_params) + } + + pub fn get_da_gas_left(self) -> aztec::context::calls::PublicCall<15, 0, u32> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(2319460898_Field); + aztec::context::calls::PublicCall::<15, 0, u32>::new(self.target_contract, selector, "get_da_gas_left", serialized_params) + } + + pub fn read_storage_single(self) -> aztec::context::calls::PublicCall<19, 0, Field> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(3140392744_Field); + aztec::context::calls::PublicCall::<19, 0, Field>::new(self.target_contract, selector, "read_storage_single", serialized_params) + } + + pub fn set_opcode_u8_view(self) -> aztec::context::calls::PublicStaticCall<18, 0, u8> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(643109956_Field); + aztec::context::calls::PublicStaticCall::<18, 0, u8>::new(self.target_contract, selector, "set_opcode_u8_view", serialized_params) + } + + pub fn assert_nullifier_exists(self, nullifier: Field) -> aztec::context::calls::PublicCall<23, 1, ()> { + let serialized_params: [Field; 1] = nullifier.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2810255355_Field); + aztec::context::calls::PublicCall::<23, 1, ()>::new(self.target_contract, selector, "assert_nullifier_exists", serialized_params) + } + + pub fn assertion_failure(self) -> aztec::context::calls::PublicCall<17, 0, ()> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(3276887878_Field); + aztec::context::calls::PublicCall::<17, 0, ()>::new(self.target_contract, selector, "assertion_failure", serialized_params) + } + + pub fn debug_logging(self) -> aztec::context::calls::PublicCall<13, 0, ()> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(3667472301_Field); + aztec::context::calls::PublicCall::<13, 0, ()>::new(self.target_contract, selector, "debug_logging", serialized_params) + } + + pub fn nested_call_large_calldata(self, arr: [Field; 300]) -> aztec::context::calls::PublicCall<26, 300, Field> { + let serialized_params: [Field; 300] = arr.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(14812432_Field); + aztec::context::calls::PublicCall::<26, 300, Field>::new(self.target_contract, selector, "nested_call_large_calldata", serialized_params) + } + + pub fn external_call_to_divide_by_zero_recovers(self) -> aztec::context::calls::PublicCall<40, 0, ()> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(2245930342_Field); + aztec::context::calls::PublicCall::<40, 0, ()>::new(self.target_contract, selector, "external_call_to_divide_by_zero_recovers", serialized_params) + } + + pub fn set_opcode_u32(self) -> aztec::context::calls::PublicCall<14, 0, u32> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(4045556597_Field); + aztec::context::calls::PublicCall::<14, 0, u32>::new(self.target_contract, selector, "set_opcode_u32", serialized_params) + } + + pub fn call_instance_registry(self) -> aztec::context::calls::PublicCall<22, 0, ()> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(2336742722_Field); + aztec::context::calls::PublicCall::<22, 0, ()>::new(self.target_contract, selector, "call_instance_registry", serialized_params) + } + + pub fn set_storage_single(self, a: Field) -> aztec::context::calls::PublicCall<18, 1, ()> { + let serialized_params: [Field; 1] = a.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2230419055_Field); + aztec::context::calls::PublicCall::<18, 1, ()>::new(self.target_contract, selector, "set_storage_single", serialized_params) + } + + pub fn nested_call_to_add(self, arg_a: Field, arg_b: Field) -> aztec::context::calls::PublicCall<18, 2, Field> { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = arg_a.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = arg_b.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(94115833_Field); + aztec::context::calls::PublicCall::<18, 2, Field>::new(self.target_contract, selector, "nested_call_to_add", serialized_params) + } + + pub fn revert_oracle(self) -> aztec::context::calls::PublicCall<13, 0, [Field; 3]> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(4147614534_Field); + aztec::context::calls::PublicCall::<13, 0, [Field; 3]>::new(self.target_contract, selector, "revert_oracle", serialized_params) + } + + pub fn send_l2_to_l1_msg(self, recipient: EthAddress, content: Field) -> aztec::context::calls::PublicCall<17, 2, ()> { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = recipient.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = content.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(2709402942_Field); + aztec::context::calls::PublicCall::<17, 2, ()>::new(self.target_contract, selector, "send_l2_to_l1_msg", serialized_params) + } + + pub fn note_hash_exists(self, note_hash: Field, leaf_index: u64) -> aztec::context::calls::PublicCall<16, 2, bool> { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = note_hash.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = leaf_index.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(671085844_Field); + aztec::context::calls::PublicCall::<16, 2, bool>::new(self.target_contract, selector, "note_hash_exists", serialized_params) + } + + pub fn read_storage_map(self, address: AztecAddress) -> aztec::context::calls::PublicCall<16, 1, u32> { + let serialized_params: [Field; 1] = address.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(711888726_Field); + aztec::context::calls::PublicCall::<16, 1, u32>::new(self.target_contract, selector, "read_storage_map", serialized_params) + } + + pub fn read_assert_storage_single(self, a: Field) -> aztec::context::calls::PublicCall<26, 1, ()> { + let serialized_params: [Field; 1] = a.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(1067389427_Field); + aztec::context::calls::PublicCall::<26, 1, ()>::new(self.target_contract, selector, "read_assert_storage_single", serialized_params) + } + + pub fn elliptic_curve_add_and_double(self) -> aztec::context::calls::PublicCall<29, 0, Point> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(1891218722_Field); + aztec::context::calls::PublicCall::<29, 0, Point>::new(self.target_contract, selector, "elliptic_curve_add_and_double", serialized_params) + } + + pub fn get_block_number(self) -> aztec::context::calls::PublicCall<16, 0, u32> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(3223336515_Field); + aztec::context::calls::PublicCall::<16, 0, u32>::new(self.target_contract, selector, "get_block_number", serialized_params) + } + + pub fn nested_call_to_assert_same(self, arg_a: Field, arg_b: Field) -> aztec::context::calls::PublicCall<26, 2, Field> { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = arg_a.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = arg_b.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(1563037608_Field); + aztec::context::calls::PublicCall::<26, 2, Field>::new(self.target_contract, selector, "nested_call_to_assert_same", serialized_params) + } + + pub fn fn_w_large_calldata(self, _arr: [Field; 300]) -> aztec::context::calls::PublicCall<19, 300, Field> { + let serialized_params: [Field; 300] = _arr.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(3786762676_Field); + aztec::context::calls::PublicCall::<19, 300, Field>::new(self.target_contract, selector, "fn_w_large_calldata", serialized_params) + } + + pub fn get_address(self) -> aztec::context::calls::PublicCall<11, 0, AztecAddress> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(1968200506_Field); + aztec::context::calls::PublicCall::<11, 0, AztecAddress>::new(self.target_contract, selector, "get_address", serialized_params) + } + + pub fn set_storage_map(self, to: AztecAddress, amount: u32) -> aztec::context::calls::PublicCall<15, 2, Field> { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = to.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = amount.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(1756672898_Field); + aztec::context::calls::PublicCall::<15, 2, Field>::new(self.target_contract, selector, "set_storage_map", serialized_params) + } + + pub fn get_version(self) -> aztec::context::calls::PublicCall<11, 0, Field> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(421038220_Field); + aztec::context::calls::PublicCall::<11, 0, Field>::new(self.target_contract, selector, "get_version", serialized_params) + } + + pub fn nested_static_call_to_set_storage(self) -> aztec::context::calls::PublicCall<33, 0, ()> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(3861896907_Field); + aztec::context::calls::PublicCall::<33, 0, ()>::new(self.target_contract, selector, "nested_static_call_to_set_storage", serialized_params) + } + + pub fn create_same_nullifier_in_nested_call(self, nestedAddress: AztecAddress, nullifier: Field) -> aztec::context::calls::PublicCall<36, 2, ()> { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = nestedAddress.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = nullifier.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(1050471208_Field); + aztec::context::calls::PublicCall::<36, 2, ()>::new(self.target_contract, selector, "create_same_nullifier_in_nested_call", serialized_params) + } + + pub fn set_opcode_big_field(self) -> aztec::context::calls::PublicCall<20, 0, Field> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(497423715_Field); + aztec::context::calls::PublicCall::<20, 0, Field>::new(self.target_contract, selector, "set_opcode_big_field", serialized_params) + } + + pub fn u128_addition_overflow(self) -> aztec::context::calls::PublicCall<22, 0, u128> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(2520497807_Field); + aztec::context::calls::PublicCall::<22, 0, u128>::new(self.target_contract, selector, "u128_addition_overflow", serialized_params) + } + + pub fn add_u128(self, a: u128, b: u128) -> aztec::context::calls::PublicCall<8, 2, u128> { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = a.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = b.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(1408352185_Field); + aztec::context::calls::PublicCall::<8, 2, u128>::new(self.target_contract, selector, "add_u128", serialized_params) + } + + pub fn get_fee_per_l2_gas(self) -> aztec::context::calls::PublicCall<18, 0, u128> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(323255525_Field); + aztec::context::calls::PublicCall::<18, 0, u128>::new(self.target_contract, selector, "get_fee_per_l2_gas", serialized_params) + } + + pub fn n_storage_writes(self, num: u32) -> aztec::context::calls::PublicCall<16, 1, ()> { + let serialized_params: [Field; 1] = num.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2323221248_Field); + aztec::context::calls::PublicCall::<16, 1, ()>::new(self.target_contract, selector, "n_storage_writes", serialized_params) + } + + pub fn set_opcode_u8(self) -> aztec::context::calls::PublicCall<13, 0, u8> { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(3068438800_Field); + aztec::context::calls::PublicCall::<13, 0, u8>::new(self.target_contract, selector, "set_opcode_u8", serialized_params) + } + + pub fn n_new_note_hashes(self, num: u32) -> aztec::context::calls::PublicCall<17, 1, ()> { + let serialized_params: [Field; 1] = num.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(1938641640_Field); + aztec::context::calls::PublicCall::<17, 1, ()>::new(self.target_contract, selector, "n_new_note_hashes", serialized_params) + } + + pub fn nested_call_to_add_n_times_different_addresses(self, addrs: [AztecAddress; 23]) -> aztec::context::calls::PublicCall<46, 23, ()> { + let serialized_params: [Field; 23] = addrs.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2936248969_Field); + aztec::context::calls::PublicCall::<46, 23, ()>::new(self.target_contract, selector, "nested_call_to_add_n_times_different_addresses", serialized_params) + } + + pub fn offchain_receive(self, messages: BoundedVec) -> aztec::context::calls::UtilityCall<16, 321, ()> { + let serialized_params: [Field; 321] = messages.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(1396850735_Field); + aztec::context::calls::UtilityCall::<16, 321, ()>::new(self.target_contract, selector, "offchain_receive", serialized_params) + } + } + + #[contract_library_method] + pub fn storage_layout() -> StorageLayoutFields { + STORAGE_LAYOUT_AvmTest.fields + } + + #[contract_library_method] + pub fn at(addr: AztecAddress) -> AvmTest { + AvmTest { target_contract: addr} + } + + #[contract_library_method] + pub fn interface() -> AvmTest { + AvmTest { target_contract: AztecAddress::zero()} + } + + pub struct sync_state_parameters { + pub scope: AztecAddress, + } + + #[abi(functions)] + pub struct sync_state_abi { + parameters: sync_state_parameters, + } + + unconstrained fn sync_state(scope: AztecAddress) { + let address: AztecAddress = aztec::context::UtilityContext::new().this_address(); + aztec::messages::discovery::do_sync_state(address, _compute_note_hash, _compute_note_nullifier, Option::>::none(), Option:: aztec::ephemeral::EphemeralArray>::some(aztec::messages::processing::offchain::sync_inbox), scope); + } + + pub struct offchain_receive_parameters { + pub messages: BoundedVec, + } + + #[abi(functions)] + pub struct offchain_receive_abi { + parameters: offchain_receive_parameters, + } + + pub struct CallSelf { + pub address: AztecAddress, + pub context: Context, + } + + impl CallSelf { + pub fn assert_calldata_copy(self, args: [Field; 3], with_selector: bool) { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 3 * 1] = args.serialize(); + let serialized_member_len: u32 = <[Field; 3] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = with_selector.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(3853740100_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<20, 4, ()>::new(self.address, selector, "assert_calldata_copy", serialized_params).call(self.context) + } + } + + pub fn get_chain_id(self) -> Field { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(1458572288_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<12, 0, Field>::new(self.address, selector, "get_chain_id", serialized_params).call(self.context) + } + } + + pub fn get_args_hash(self, _a: u8, _fields: [Field; 3]) -> Field { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = _a.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 3 * 1] = _fields.serialize(); + let serialized_member_len: u32 = <[Field; 3] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(1608415988_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<13, 4, Field>::new(self.address, selector, "get_args_hash", serialized_params).call(self.context) + } + } + + pub fn external_call_to_divide_by_zero(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(3880450065_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<31, 0, ()>::new(self.address, selector, "external_call_to_divide_by_zero", serialized_params).call(self.context) + } + } + + pub fn n_new_nullifiers(self, num: u32) { + let serialized_params: [Field; 1] = num.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(592684400_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<16, 1, ()>::new(self.address, selector, "n_new_nullifiers", serialized_params).call(self.context) + } + } + + pub fn new_note_hash(self, note_hash: Field) { + let serialized_params: [Field; 1] = note_hash.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(1524332459_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<13, 1, ()>::new(self.address, selector, "new_note_hash", serialized_params).call(self.context) + } + } + + pub fn nullifier_collision(self, nullifier: Field) { + let serialized_params: [Field; 1] = nullifier.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2417179850_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<19, 1, ()>::new(self.address, selector, "nullifier_collision", serialized_params).call(self.context) + } + } + + pub fn get_l2_gas_left(self) -> u32 { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(1635524210_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<15, 0, u32>::new(self.address, selector, "get_l2_gas_left", serialized_params).call(self.context) + } + } + + pub fn l1_to_l2_msg_exists(self, msg_hash: Field, msg_leaf_index: Field) -> bool { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = msg_hash.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = msg_leaf_index.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(3972971575_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<19, 2, bool>::new(self.address, selector, "l1_to_l2_msg_exists", serialized_params).call(self.context) + } + } + + pub fn add_storage_map(self, to: AztecAddress, amount: u32) -> Field { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = to.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = amount.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(2606877757_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<15, 2, Field>::new(self.address, selector, "add_storage_map", serialized_params).call(self.context) + } + } + + pub fn bulk_testing(self, args_field: [Field; 10], args_u8: [u8; 10], get_instance_for_address: AztecAddress, expected_deployer: AztecAddress, expected_class_id: ContractClassId, expected_initialization_hash: Field, skip_strictly_limited_side_effects: bool) { + let mut serialized_params: [Field; 25] = [0_Field; 25]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 10 * 1] = args_field.serialize(); + let serialized_member_len: u32 = <[Field; 10] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 10 * 1] = args_u8.serialize(); + let serialized_member_len: u32 = <[u8; 10] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = get_instance_for_address.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = expected_deployer.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = expected_class_id.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_4: u32 = i + offset; + serialized_params[i_4] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = expected_initialization_hash.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_5: u32 = i + offset; + serialized_params[i_5] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = skip_strictly_limited_side_effects.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_6: u32 = i + offset; + serialized_params[i_6] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(43639379_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<12, 25, ()>::new(self.address, selector, "bulk_testing", serialized_params).call(self.context) + } + } + + pub fn add_args_return(self, arg_a: Field, arg_b: Field) -> Field { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = arg_a.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = arg_b.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(2858633377_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<15, 2, Field>::new(self.address, selector, "add_args_return", serialized_params).call(self.context) + } + } + + pub fn variable_base_msm(self, scalar_lo: Field, scalar_hi: Field, scalar2_lo: Field, scalar2_hi: Field) -> Point { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = scalar_lo.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = scalar_hi.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = scalar2_lo.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = scalar2_hi.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(2931784034_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<17, 4, Point>::new(self.address, selector, "variable_base_msm", serialized_params).call(self.context) + } + } + + pub fn test_get_contract_instance_matches(self, address: AztecAddress, expected_deployer: AztecAddress, expected_class_id: ContractClassId, expected_initialization_hash: Field) { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = address.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = expected_deployer.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = expected_class_id.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = expected_initialization_hash.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(2723912183_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<34, 4, ()>::new(self.address, selector, "test_get_contract_instance_matches", serialized_params).call(self.context) + } + } + + pub fn get_sender(self) -> AztecAddress { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(301170519_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<10, 0, AztecAddress>::new(self.address, selector, "get_sender", serialized_params).call(self.context) + } + } + + pub fn n_new_l2_to_l1_msgs(self, num: u32) { + let serialized_params: [Field; 1] = num.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(3921925917_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<19, 1, ()>::new(self.address, selector, "n_new_l2_to_l1_msgs", serialized_params).call(self.context) + } + } + + pub fn set_storage_list(self, a: Field, b: Field) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = a.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = b.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(1745164739_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<16, 2, ()>::new(self.address, selector, "set_storage_list", serialized_params).call(self.context) + } + } + + pub fn pedersen_commit(self, x: Field, y: Field) -> Point { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = x.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = y.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(2484465428_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<15, 2, Point>::new(self.address, selector, "pedersen_commit", serialized_params).call(self.context) + } + } + + pub fn nullifier_exists(self, nullifier: Field) -> bool { + let serialized_params: [Field; 1] = nullifier.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2051407563_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<16, 1, bool>::new(self.address, selector, "nullifier_exists", serialized_params).call(self.context) + } + } + + pub fn read_storage_list(self) -> [Field; 2] { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(1727615163_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<17, 0, [Field; 2]>::new(self.address, selector, "read_storage_list", serialized_params).call(self.context) + } + } + + pub fn emit_nullifier_and_check(self, nullifier: Field) { + let serialized_params: [Field; 1] = nullifier.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2367487025_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<24, 1, ()>::new(self.address, selector, "emit_nullifier_and_check", serialized_params).call(self.context) + } + } + + pub fn assert_same(self, arg_a: Field, arg_b: Field) -> Field { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = arg_a.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = arg_b.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(290442984_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<11, 2, Field>::new(self.address, selector, "assert_same", serialized_params).call(self.context) + } + } + + pub fn get_fee_per_da_gas(self) -> u128 { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(514475538_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<18, 0, u128>::new(self.address, selector, "get_fee_per_da_gas", serialized_params).call(self.context) + } + } + + pub fn modulo2(self, a: u64) -> u64 { + let serialized_params: [Field; 1] = a.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(222531562_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<7, 1, u64>::new(self.address, selector, "modulo2", serialized_params).call(self.context) + } + } + + pub fn nested_static_call_to_add(self, arg_a: Field, arg_b: Field) -> Field { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = arg_a.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = arg_b.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(1362946309_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<25, 2, Field>::new(self.address, selector, "nested_static_call_to_add", serialized_params).call(self.context) + } + } + + pub fn to_le_bits(self, input: Field) -> [bool; 16] { + let serialized_params: [Field; 1] = input.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2961959597_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<10, 1, [bool; 16]>::new(self.address, selector, "to_le_bits", serialized_params).call(self.context) + } + } + + pub fn call_auth_registry(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(1225767423_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<18, 0, ()>::new(self.address, selector, "call_auth_registry", serialized_params).call(self.context) + } + } + + pub fn set_opcode_u64(self) -> u64 { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(1435480431_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<14, 0, u64>::new(self.address, selector, "set_opcode_u64", serialized_params).call(self.context) + } + } + + pub fn return_oracle(self) -> [Field; 3] { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(3794636397_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<13, 0, [Field; 3]>::new(self.address, selector, "return_oracle", serialized_params).call(self.context) + } + } + + pub fn test_get_contract_instance(self, address: AztecAddress) { + let serialized_params: [Field; 1] = address.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2488367864_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<26, 1, ()>::new(self.address, selector, "test_get_contract_instance", serialized_params).call(self.context) + } + } + + pub fn get_timestamp(self) -> u64 { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(448989811_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<13, 0, u64>::new(self.address, selector, "get_timestamp", serialized_params).call(self.context) + } + } + + pub fn to_le_bytes(self, input: Field) -> [u8; 10] { + let serialized_params: [Field; 1] = input.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(1975931334_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<11, 1, [u8; 10]>::new(self.address, selector, "to_le_bytes", serialized_params).call(self.context) + } + } + + pub fn external_call_to_assertion_failure(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(294808228_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<34, 0, ()>::new(self.address, selector, "external_call_to_assertion_failure", serialized_params).call(self.context) + } + } + + pub fn new_nullifier(self, nullifier: Field) { + let serialized_params: [Field; 1] = nullifier.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(3648851082_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<13, 1, ()>::new(self.address, selector, "new_nullifier", serialized_params).call(self.context) + } + } + + pub fn divide_by_zero(self, denominator: u8) -> u8 { + let serialized_params: [Field; 1] = denominator.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(815932481_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<14, 1, u8>::new(self.address, selector, "divide_by_zero", serialized_params).call(self.context) + } + } + + pub fn emit_public_log(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(2033426724_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<15, 0, ()>::new(self.address, selector, "emit_public_log", serialized_params).call(self.context) + } + } + + pub fn raw_l2_to_l1_msg(self, recipient: EthAddress, content: Field) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = recipient.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = content.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(3409962923_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<16, 2, ()>::new(self.address, selector, "raw_l2_to_l1_msg", serialized_params).call(self.context) + } + } + + pub fn nested_call_to_nothing_recovers(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(1843532057_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<31, 0, ()>::new(self.address, selector, "nested_call_to_nothing_recovers", serialized_params).call(self.context) + } + } + + pub fn assert_calldata_copy_large(self, args: [Field; 300], with_selector: bool) { + let mut serialized_params: [Field; 301] = [0_Field; 301]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 300 * 1] = args.serialize(); + let serialized_member_len: u32 = <[Field; 300] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = with_selector.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(2293565755_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<26, 301, ()>::new(self.address, selector, "assert_calldata_copy_large", serialized_params).call(self.context) + } + } + + pub fn set_opcode_really_big_field(self) -> Field { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(4095821182_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<27, 0, Field>::new(self.address, selector, "set_opcode_really_big_field", serialized_params).call(self.context) + } + } + + pub fn elliptic_curve_add(self, lhs: Point, rhs: Point) -> Point { + let mut serialized_params: [Field; 6] = [0_Field; 6]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 3] = lhs.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 3] = rhs.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(1700026912_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<18, 6, Point>::new(self.address, selector, "elliptic_curve_add", serialized_params).call(self.context) + } + } + + pub fn returndata_copy_oracle(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(4172530660_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<22, 0, ()>::new(self.address, selector, "returndata_copy_oracle", serialized_params).call(self.context) + } + } + + pub fn set_read_storage_single(self, a: Field) -> Field { + let serialized_params: [Field; 1] = a.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(1932358992_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<23, 1, Field>::new(self.address, selector, "set_read_storage_single", serialized_params).call(self.context) + } + } + + pub fn n_new_public_logs(self, num: u32) { + let serialized_params: [Field; 1] = num.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2907114368_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<17, 1, ()>::new(self.address, selector, "n_new_public_logs", serialized_params).call(self.context) + } + } + + pub fn conditional_move(self, x: [Field; 1], y: [Field; 1], b: bool) -> [Field; 1] { + let mut serialized_params: [Field; 3] = [0_Field; 3]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1 * 1] = x.serialize(); + let serialized_member_len: u32 = <[Field; 1] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1 * 1] = y.serialize(); + let serialized_member_len: u32 = <[Field; 1] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = b.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(2633971407_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<16, 3, [Field; 1]>::new(self.address, selector, "conditional_move", serialized_params).call(self.context) + } + } + + pub fn set_opcode_small_field(self) -> Field { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(3464175345_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<22, 0, Field>::new(self.address, selector, "set_opcode_small_field", serialized_params).call(self.context) + } + } + + pub fn nested_call_to_nothing(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(1183868090_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<22, 0, ()>::new(self.address, selector, "nested_call_to_nothing", serialized_params).call(self.context) + } + } + + pub fn nested_call_to_add_with_gas(self, arg_a: Field, arg_b: Field, l2_gas: u32, da_gas: u32) -> Field { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = arg_a.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = arg_b.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = l2_gas.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = da_gas.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(3561659563_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<27, 4, Field>::new(self.address, selector, "nested_call_to_add_with_gas", serialized_params).call(self.context) + } + } + + pub fn create_different_nullifier_in_nested_call(self, nestedAddress: AztecAddress, nullifier: Field) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = nestedAddress.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = nullifier.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(1630216043_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<41, 2, ()>::new(self.address, selector, "create_different_nullifier_in_nested_call", serialized_params).call(self.context) + } + } + + pub fn call_fee_juice(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(2734888597_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<14, 0, ()>::new(self.address, selector, "call_fee_juice", serialized_params).call(self.context) + } + } + + pub fn get_da_gas_left(self) -> u32 { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(2319460898_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<15, 0, u32>::new(self.address, selector, "get_da_gas_left", serialized_params).call(self.context) + } + } + + pub fn get_transaction_fee(self) -> Field { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(2524054657_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<19, 0, Field>::new(self.address, selector, "get_transaction_fee", serialized_params).call(self.context) + } + } + + pub fn read_storage_single(self) -> Field { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(3140392744_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<19, 0, Field>::new(self.address, selector, "read_storage_single", serialized_params).call(self.context) + } + } + + pub fn assert_nullifier_exists(self, nullifier: Field) { + let serialized_params: [Field; 1] = nullifier.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2810255355_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<23, 1, ()>::new(self.address, selector, "assert_nullifier_exists", serialized_params).call(self.context) + } + } + + pub fn assertion_failure(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(3276887878_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<17, 0, ()>::new(self.address, selector, "assertion_failure", serialized_params).call(self.context) + } + } + + pub fn debug_logging(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(3667472301_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<13, 0, ()>::new(self.address, selector, "debug_logging", serialized_params).call(self.context) + } + } + + pub fn nested_call_large_calldata(self, arr: [Field; 300]) -> Field { + let serialized_params: [Field; 300 * 1] = arr.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(14812432_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<26, 300 * 1, Field>::new(self.address, selector, "nested_call_large_calldata", serialized_params).call(self.context) + } + } + + pub fn external_call_to_divide_by_zero_recovers(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(2245930342_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<40, 0, ()>::new(self.address, selector, "external_call_to_divide_by_zero_recovers", serialized_params).call(self.context) + } + } + + pub fn set_opcode_u32(self) -> u32 { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(4045556597_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<14, 0, u32>::new(self.address, selector, "set_opcode_u32", serialized_params).call(self.context) + } + } + + pub fn call_instance_registry(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(2336742722_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<22, 0, ()>::new(self.address, selector, "call_instance_registry", serialized_params).call(self.context) + } + } + + pub fn set_storage_single(self, a: Field) { + let serialized_params: [Field; 1] = a.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2230419055_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<18, 1, ()>::new(self.address, selector, "set_storage_single", serialized_params).call(self.context) + } + } + + pub fn nested_call_to_add(self, arg_a: Field, arg_b: Field) -> Field { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = arg_a.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = arg_b.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(94115833_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<18, 2, Field>::new(self.address, selector, "nested_call_to_add", serialized_params).call(self.context) + } + } + + pub fn revert_oracle(self) -> [Field; 3] { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(4147614534_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<13, 0, [Field; 3]>::new(self.address, selector, "revert_oracle", serialized_params).call(self.context) + } + } + + pub fn send_l2_to_l1_msg(self, recipient: EthAddress, content: Field) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = recipient.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = content.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(2709402942_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<17, 2, ()>::new(self.address, selector, "send_l2_to_l1_msg", serialized_params).call(self.context) + } + } + + pub fn note_hash_exists(self, note_hash: Field, leaf_index: u64) -> bool { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = note_hash.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = leaf_index.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(671085844_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<16, 2, bool>::new(self.address, selector, "note_hash_exists", serialized_params).call(self.context) + } + } + + pub fn read_storage_map(self, address: AztecAddress) -> u32 { + let serialized_params: [Field; 1] = address.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(711888726_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<16, 1, u32>::new(self.address, selector, "read_storage_map", serialized_params).call(self.context) + } + } + + pub fn elliptic_curve_add_and_double(self) -> Point { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(1891218722_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<29, 0, Point>::new(self.address, selector, "elliptic_curve_add_and_double", serialized_params).call(self.context) + } + } + + pub fn read_assert_storage_single(self, a: Field) { + let serialized_params: [Field; 1] = a.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(1067389427_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<26, 1, ()>::new(self.address, selector, "read_assert_storage_single", serialized_params).call(self.context) + } + } + + pub fn get_block_number(self) -> u32 { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(3223336515_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<16, 0, u32>::new(self.address, selector, "get_block_number", serialized_params).call(self.context) + } + } + + pub fn nested_call_to_assert_same(self, arg_a: Field, arg_b: Field) -> Field { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = arg_a.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = arg_b.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(1563037608_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<26, 2, Field>::new(self.address, selector, "nested_call_to_assert_same", serialized_params).call(self.context) + } + } + + pub fn fn_w_large_calldata(self, _arr: [Field; 300]) -> Field { + let serialized_params: [Field; 300 * 1] = _arr.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(3786762676_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<19, 300 * 1, Field>::new(self.address, selector, "fn_w_large_calldata", serialized_params).call(self.context) + } + } + + pub fn get_address(self) -> AztecAddress { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(1968200506_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<11, 0, AztecAddress>::new(self.address, selector, "get_address", serialized_params).call(self.context) + } + } + + pub fn set_storage_map(self, to: AztecAddress, amount: u32) -> Field { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = to.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = amount.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(1756672898_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<15, 2, Field>::new(self.address, selector, "set_storage_map", serialized_params).call(self.context) + } + } + + pub fn get_version(self) -> Field { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(421038220_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<11, 0, Field>::new(self.address, selector, "get_version", serialized_params).call(self.context) + } + } + + pub fn nested_static_call_to_set_storage(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(3861896907_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<33, 0, ()>::new(self.address, selector, "nested_static_call_to_set_storage", serialized_params).call(self.context) + } + } + + pub fn create_same_nullifier_in_nested_call(self, nestedAddress: AztecAddress, nullifier: Field) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = nestedAddress.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = nullifier.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(1050471208_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<36, 2, ()>::new(self.address, selector, "create_same_nullifier_in_nested_call", serialized_params).call(self.context) + } + } + + pub fn set_opcode_big_field(self) -> Field { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(497423715_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<20, 0, Field>::new(self.address, selector, "set_opcode_big_field", serialized_params).call(self.context) + } + } + + pub fn u128_addition_overflow(self) -> u128 { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(2520497807_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<22, 0, u128>::new(self.address, selector, "u128_addition_overflow", serialized_params).call(self.context) + } + } + + pub fn add_u128(self, a: u128, b: u128) -> u128 { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = a.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = b.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(1408352185_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<8, 2, u128>::new(self.address, selector, "add_u128", serialized_params).call(self.context) + } + } + + pub fn get_fee_per_l2_gas(self) -> u128 { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(323255525_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<18, 0, u128>::new(self.address, selector, "get_fee_per_l2_gas", serialized_params).call(self.context) + } + } + + pub fn n_storage_writes(self, num: u32) { + let serialized_params: [Field; 1] = num.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2323221248_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<16, 1, ()>::new(self.address, selector, "n_storage_writes", serialized_params).call(self.context) + } + } + + pub fn set_opcode_u8(self) -> u8 { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(3068438800_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<13, 0, u8>::new(self.address, selector, "set_opcode_u8", serialized_params).call(self.context) + } + } + + pub fn n_new_note_hashes(self, num: u32) { + let serialized_params: [Field; 1] = num.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(1938641640_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<17, 1, ()>::new(self.address, selector, "n_new_note_hashes", serialized_params).call(self.context) + } + } + + pub fn nested_call_to_add_n_times_different_addresses(self, addrs: [AztecAddress; 23]) { + let serialized_params: [Field; 23 * 1] = addrs.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2936248969_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<46, 23 * 1, ()>::new(self.address, selector, "nested_call_to_add_n_times_different_addresses", serialized_params).call(self.context) + } + } + } + + impl CallSelf<&mut aztec::context::PrivateContext> { + pub fn enqueue_public_from_private(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(2771384488_Field); + let args_hash: Field = aztec::hash::hash_args(serialized_params); + aztec::oracle::execution_cache::store(serialized_params, args_hash); + let returns_hash: aztec::context::ReturnsHash = self.context.call_private_function_with_args_hash(self.address, selector, args_hash, false); + returns_hash.get_preimage() + } + } + + pub struct CallSelfStatic { + pub address: AztecAddress, + pub context: Context, + } + + impl CallSelfStatic { + pub fn set_opcode_u8_view(self) -> u8 { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(643109956_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicStaticCall::<18, 0, u8>::new(self.address, selector, "set_opcode_u8_view", serialized_params).view(self.context) + } + } + } + + pub struct EnqueueSelf { + pub address: AztecAddress, + pub context: Context, + } + + impl EnqueueSelf<&mut aztec::context::PrivateContext> { + pub fn assert_calldata_copy(self, args: [Field; 3], with_selector: bool) { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 3 * 1] = args.serialize(); + let serialized_member_len: u32 = <[Field; 3] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = with_selector.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(3853740100_Field); + let calldata: [Field; 1 + 4] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn get_chain_id(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(1458572288_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn get_args_hash(self, _a: u8, _fields: [Field; 3]) { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = _a.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 3 * 1] = _fields.serialize(); + let serialized_member_len: u32 = <[Field; 3] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(1608415988_Field); + let calldata: [Field; 1 + 4] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn external_call_to_divide_by_zero(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(3880450065_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn n_new_nullifiers(self, num: u32) { + let serialized_params: [Field; 1] = num.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(592684400_Field); + let calldata: [Field; 1 + 1] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn new_note_hash(self, note_hash: Field) { + let serialized_params: [Field; 1] = note_hash.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(1524332459_Field); + let calldata: [Field; 1 + 1] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn nullifier_collision(self, nullifier: Field) { + let serialized_params: [Field; 1] = nullifier.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2417179850_Field); + let calldata: [Field; 1 + 1] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn get_l2_gas_left(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(1635524210_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn l1_to_l2_msg_exists(self, msg_hash: Field, msg_leaf_index: Field) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = msg_hash.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = msg_leaf_index.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(3972971575_Field); + let calldata: [Field; 1 + 2] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn add_storage_map(self, to: AztecAddress, amount: u32) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = to.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = amount.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(2606877757_Field); + let calldata: [Field; 1 + 2] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn bulk_testing(self, args_field: [Field; 10], args_u8: [u8; 10], get_instance_for_address: AztecAddress, expected_deployer: AztecAddress, expected_class_id: ContractClassId, expected_initialization_hash: Field, skip_strictly_limited_side_effects: bool) { + let mut serialized_params: [Field; 25] = [0_Field; 25]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 10 * 1] = args_field.serialize(); + let serialized_member_len: u32 = <[Field; 10] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 10 * 1] = args_u8.serialize(); + let serialized_member_len: u32 = <[u8; 10] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = get_instance_for_address.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = expected_deployer.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = expected_class_id.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_4: u32 = i + offset; + serialized_params[i_4] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = expected_initialization_hash.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_5: u32 = i + offset; + serialized_params[i_5] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = skip_strictly_limited_side_effects.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_6: u32 = i + offset; + serialized_params[i_6] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(43639379_Field); + let calldata: [Field; 1 + 25] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn add_args_return(self, arg_a: Field, arg_b: Field) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = arg_a.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = arg_b.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(2858633377_Field); + let calldata: [Field; 1 + 2] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn variable_base_msm(self, scalar_lo: Field, scalar_hi: Field, scalar2_lo: Field, scalar2_hi: Field) { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = scalar_lo.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = scalar_hi.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = scalar2_lo.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = scalar2_hi.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(2931784034_Field); + let calldata: [Field; 1 + 4] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn test_get_contract_instance_matches(self, address: AztecAddress, expected_deployer: AztecAddress, expected_class_id: ContractClassId, expected_initialization_hash: Field) { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = address.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = expected_deployer.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = expected_class_id.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = expected_initialization_hash.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(2723912183_Field); + let calldata: [Field; 1 + 4] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn get_sender(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(301170519_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn n_new_l2_to_l1_msgs(self, num: u32) { + let serialized_params: [Field; 1] = num.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(3921925917_Field); + let calldata: [Field; 1 + 1] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn set_storage_list(self, a: Field, b: Field) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = a.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = b.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(1745164739_Field); + let calldata: [Field; 1 + 2] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn pedersen_commit(self, x: Field, y: Field) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = x.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = y.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(2484465428_Field); + let calldata: [Field; 1 + 2] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn nullifier_exists(self, nullifier: Field) { + let serialized_params: [Field; 1] = nullifier.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2051407563_Field); + let calldata: [Field; 1 + 1] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn read_storage_list(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(1727615163_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn emit_nullifier_and_check(self, nullifier: Field) { + let serialized_params: [Field; 1] = nullifier.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2367487025_Field); + let calldata: [Field; 1 + 1] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn assert_same(self, arg_a: Field, arg_b: Field) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = arg_a.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = arg_b.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(290442984_Field); + let calldata: [Field; 1 + 2] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn get_fee_per_da_gas(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(514475538_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn modulo2(self, a: u64) { + let serialized_params: [Field; 1] = a.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(222531562_Field); + let calldata: [Field; 1 + 1] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn nested_static_call_to_add(self, arg_a: Field, arg_b: Field) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = arg_a.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = arg_b.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(1362946309_Field); + let calldata: [Field; 1 + 2] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn to_le_bits(self, input: Field) { + let serialized_params: [Field; 1] = input.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2961959597_Field); + let calldata: [Field; 1 + 1] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn call_auth_registry(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(1225767423_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn set_opcode_u64(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(1435480431_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn return_oracle(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(3794636397_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn test_get_contract_instance(self, address: AztecAddress) { + let serialized_params: [Field; 1] = address.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2488367864_Field); + let calldata: [Field; 1 + 1] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn get_timestamp(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(448989811_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn to_le_bytes(self, input: Field) { + let serialized_params: [Field; 1] = input.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(1975931334_Field); + let calldata: [Field; 1 + 1] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn external_call_to_assertion_failure(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(294808228_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn new_nullifier(self, nullifier: Field) { + let serialized_params: [Field; 1] = nullifier.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(3648851082_Field); + let calldata: [Field; 1 + 1] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn divide_by_zero(self, denominator: u8) { + let serialized_params: [Field; 1] = denominator.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(815932481_Field); + let calldata: [Field; 1 + 1] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn emit_public_log(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(2033426724_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn raw_l2_to_l1_msg(self, recipient: EthAddress, content: Field) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = recipient.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = content.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(3409962923_Field); + let calldata: [Field; 1 + 2] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn nested_call_to_nothing_recovers(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(1843532057_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn assert_calldata_copy_large(self, args: [Field; 300], with_selector: bool) { + let mut serialized_params: [Field; 301] = [0_Field; 301]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 300 * 1] = args.serialize(); + let serialized_member_len: u32 = <[Field; 300] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = with_selector.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(2293565755_Field); + let calldata: [Field; 1 + 301] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn set_opcode_really_big_field(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(4095821182_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn elliptic_curve_add(self, lhs: Point, rhs: Point) { + let mut serialized_params: [Field; 6] = [0_Field; 6]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 3] = lhs.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 3] = rhs.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(1700026912_Field); + let calldata: [Field; 1 + 6] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn returndata_copy_oracle(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(4172530660_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn set_read_storage_single(self, a: Field) { + let serialized_params: [Field; 1] = a.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(1932358992_Field); + let calldata: [Field; 1 + 1] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn n_new_public_logs(self, num: u32) { + let serialized_params: [Field; 1] = num.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2907114368_Field); + let calldata: [Field; 1 + 1] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn conditional_move(self, x: [Field; 1], y: [Field; 1], b: bool) { + let mut serialized_params: [Field; 3] = [0_Field; 3]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1 * 1] = x.serialize(); + let serialized_member_len: u32 = <[Field; 1] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1 * 1] = y.serialize(); + let serialized_member_len: u32 = <[Field; 1] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = b.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(2633971407_Field); + let calldata: [Field; 1 + 3] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn set_opcode_small_field(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(3464175345_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn nested_call_to_nothing(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(1183868090_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn nested_call_to_add_with_gas(self, arg_a: Field, arg_b: Field, l2_gas: u32, da_gas: u32) { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = arg_a.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = arg_b.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = l2_gas.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = da_gas.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(3561659563_Field); + let calldata: [Field; 1 + 4] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn create_different_nullifier_in_nested_call(self, nestedAddress: AztecAddress, nullifier: Field) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = nestedAddress.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = nullifier.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(1630216043_Field); + let calldata: [Field; 1 + 2] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn call_fee_juice(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(2734888597_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn get_da_gas_left(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(2319460898_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn get_transaction_fee(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(2524054657_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn read_storage_single(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(3140392744_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn assert_nullifier_exists(self, nullifier: Field) { + let serialized_params: [Field; 1] = nullifier.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2810255355_Field); + let calldata: [Field; 1 + 1] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn assertion_failure(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(3276887878_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn debug_logging(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(3667472301_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn nested_call_large_calldata(self, arr: [Field; 300]) { + let serialized_params: [Field; 300 * 1] = arr.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(14812432_Field); + let calldata: [Field; 1 + (300 * 1)] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn external_call_to_divide_by_zero_recovers(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(2245930342_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn set_opcode_u32(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(4045556597_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn call_instance_registry(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(2336742722_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn set_storage_single(self, a: Field) { + let serialized_params: [Field; 1] = a.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2230419055_Field); + let calldata: [Field; 1 + 1] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn nested_call_to_add(self, arg_a: Field, arg_b: Field) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = arg_a.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = arg_b.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(94115833_Field); + let calldata: [Field; 1 + 2] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn revert_oracle(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(4147614534_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn send_l2_to_l1_msg(self, recipient: EthAddress, content: Field) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = recipient.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = content.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(2709402942_Field); + let calldata: [Field; 1 + 2] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn note_hash_exists(self, note_hash: Field, leaf_index: u64) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = note_hash.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = leaf_index.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(671085844_Field); + let calldata: [Field; 1 + 2] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn read_storage_map(self, address: AztecAddress) { + let serialized_params: [Field; 1] = address.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(711888726_Field); + let calldata: [Field; 1 + 1] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn elliptic_curve_add_and_double(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(1891218722_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn read_assert_storage_single(self, a: Field) { + let serialized_params: [Field; 1] = a.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(1067389427_Field); + let calldata: [Field; 1 + 1] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn get_block_number(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(3223336515_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn nested_call_to_assert_same(self, arg_a: Field, arg_b: Field) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = arg_a.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = arg_b.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(1563037608_Field); + let calldata: [Field; 1 + 2] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn fn_w_large_calldata(self, _arr: [Field; 300]) { + let serialized_params: [Field; 300 * 1] = _arr.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(3786762676_Field); + let calldata: [Field; 1 + (300 * 1)] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn get_address(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(1968200506_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn set_storage_map(self, to: AztecAddress, amount: u32) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = to.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = amount.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(1756672898_Field); + let calldata: [Field; 1 + 2] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn get_version(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(421038220_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn nested_static_call_to_set_storage(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(3861896907_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn create_same_nullifier_in_nested_call(self, nestedAddress: AztecAddress, nullifier: Field) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = nestedAddress.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = nullifier.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(1050471208_Field); + let calldata: [Field; 1 + 2] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn set_opcode_big_field(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(497423715_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn u128_addition_overflow(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(2520497807_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn add_u128(self, a: u128, b: u128) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = a.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = b.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: FunctionSelector = FunctionSelector::from_field(1408352185_Field); + let calldata: [Field; 1 + 2] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn get_fee_per_l2_gas(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(323255525_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn n_storage_writes(self, num: u32) { + let serialized_params: [Field; 1] = num.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2323221248_Field); + let calldata: [Field; 1 + 1] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn set_opcode_u8(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(3068438800_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn n_new_note_hashes(self, num: u32) { + let serialized_params: [Field; 1] = num.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(1938641640_Field); + let calldata: [Field; 1 + 1] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn nested_call_to_add_n_times_different_addresses(self, addrs: [AztecAddress; 23]) { + let serialized_params: [Field; 23 * 1] = addrs.serialize(); + let selector: FunctionSelector = FunctionSelector::from_field(2936248969_Field); + let calldata: [Field; 1 + (23 * 1)] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + } + + pub struct EnqueueSelfStatic { + pub address: AztecAddress, + pub context: Context, + } + + impl EnqueueSelfStatic<&mut aztec::context::PrivateContext> { + pub fn set_opcode_u8_view(self) { + let serialized_params: [Field; 0] = []; + let selector: FunctionSelector = FunctionSelector::from_field(643109956_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, true, false); + } + } + + pub struct CallSelfUtility { + pub address: AztecAddress, + } + + pub struct CallInternal { + pub context: Context, + } + + pub unconstrained fn public_dispatch(selector: Field) { + if selector == 2230419055_Field { + let input_calldata: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + let mut reader: aztec::protocol::utils::reader::Reader<1> = aztec::protocol::utils::reader::Reader::<1>::new(input_calldata); + let arg0: Field = ::stream_deserialize(&mut reader); + __aztec_nr_internals__set_storage_single(arg0); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 3140392744_Field { + let return_value: [Field; 1] = __aztec_nr_internals__read_storage_single().serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 1067389427_Field { + let input_calldata: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + let mut reader: aztec::protocol::utils::reader::Reader<1> = aztec::protocol::utils::reader::Reader::<1>::new(input_calldata); + let arg0: Field = ::stream_deserialize(&mut reader); + __aztec_nr_internals__read_assert_storage_single(arg0); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 1932358992_Field { + let input_calldata: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + let mut reader: aztec::protocol::utils::reader::Reader<1> = aztec::protocol::utils::reader::Reader::<1>::new(input_calldata); + let arg0: Field = ::stream_deserialize(&mut reader); + let return_value: [Field; 1] = __aztec_nr_internals__set_read_storage_single(arg0).serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 1745164739_Field { + let input_calldata: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<2> = aztec::protocol::utils::reader::Reader::<2>::new(input_calldata); + let arg0: Field = ::stream_deserialize(&mut reader); + let arg1: Field = ::stream_deserialize(&mut reader); + __aztec_nr_internals__set_storage_list(arg0, arg1); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 1727615163_Field { + let return_value: [Field; 2 * 1] = __aztec_nr_internals__read_storage_list().serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 1756672898_Field { + let input_calldata: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<2> = aztec::protocol::utils::reader::Reader::<2>::new(input_calldata); + let arg0: AztecAddress = ::stream_deserialize(&mut reader); + let arg1: u32 = ::stream_deserialize(&mut reader); + let return_value: [Field; 1] = __aztec_nr_internals__set_storage_map(arg0, arg1).serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 2606877757_Field { + let input_calldata: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<2> = aztec::protocol::utils::reader::Reader::<2>::new(input_calldata); + let arg0: AztecAddress = ::stream_deserialize(&mut reader); + let arg1: u32 = ::stream_deserialize(&mut reader); + let return_value: [Field; 1] = __aztec_nr_internals__add_storage_map(arg0, arg1).serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 711888726_Field { + let input_calldata: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + let mut reader: aztec::protocol::utils::reader::Reader<1> = aztec::protocol::utils::reader::Reader::<1>::new(input_calldata); + let arg0: AztecAddress = ::stream_deserialize(&mut reader); + let return_value: [Field; 1] = __aztec_nr_internals__read_storage_map(arg0).serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 2858633377_Field { + let input_calldata: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<2> = aztec::protocol::utils::reader::Reader::<2>::new(input_calldata); + let arg0: Field = ::stream_deserialize(&mut reader); + let arg1: Field = ::stream_deserialize(&mut reader); + let return_value: [Field; 1] = __aztec_nr_internals__add_args_return(arg0, arg1).serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 3068438800_Field { + let return_value: [Field; 1] = __aztec_nr_internals__set_opcode_u8().serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 643109956_Field { + let return_value: [Field; 1] = __aztec_nr_internals__set_opcode_u8_view().serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 4045556597_Field { + let return_value: [Field; 1] = __aztec_nr_internals__set_opcode_u32().serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 1435480431_Field { + let return_value: [Field; 1] = __aztec_nr_internals__set_opcode_u64().serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 3464175345_Field { + let return_value: [Field; 1] = __aztec_nr_internals__set_opcode_small_field().serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 497423715_Field { + let return_value: [Field; 1] = __aztec_nr_internals__set_opcode_big_field().serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 4095821182_Field { + let return_value: [Field; 1] = __aztec_nr_internals__set_opcode_really_big_field().serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 1408352185_Field { + let input_calldata: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<2> = aztec::protocol::utils::reader::Reader::<2>::new(input_calldata); + let arg0: u128 = ::stream_deserialize(&mut reader); + let arg1: u128 = ::stream_deserialize(&mut reader); + let return_value: [Field; 1] = __aztec_nr_internals__add_u128(arg0, arg1).serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 222531562_Field { + let input_calldata: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + let mut reader: aztec::protocol::utils::reader::Reader<1> = aztec::protocol::utils::reader::Reader::<1>::new(input_calldata); + let arg0: u64 = ::stream_deserialize(&mut reader); + let return_value: [Field; 1] = __aztec_nr_internals__modulo2(arg0).serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 1700026912_Field { + let input_calldata: [Field; 6] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<6> = aztec::protocol::utils::reader::Reader::<6>::new(input_calldata); + let arg0: Point = ::stream_deserialize(&mut reader); + let arg1: Point = ::stream_deserialize(&mut reader); + let return_value: [Field; 3] = __aztec_nr_internals__elliptic_curve_add(arg0, arg1).serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 1891218722_Field { + let return_value: [Field; 3] = __aztec_nr_internals__elliptic_curve_add_and_double().serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 2931784034_Field { + let input_calldata: [Field; 4] = aztec::oracle::avm::calldata_copy(1_u32, ((::N + ::N) + ::N) + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<4> = aztec::protocol::utils::reader::Reader::<4>::new(input_calldata); + let arg0: Field = ::stream_deserialize(&mut reader); + let arg1: Field = ::stream_deserialize(&mut reader); + let arg2: Field = ::stream_deserialize(&mut reader); + let arg3: Field = ::stream_deserialize(&mut reader); + let return_value: [Field; 3] = __aztec_nr_internals__variable_base_msm(arg0, arg1, arg2, arg3).serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 2484465428_Field { + let input_calldata: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<2> = aztec::protocol::utils::reader::Reader::<2>::new(input_calldata); + let arg0: Field = ::stream_deserialize(&mut reader); + let arg1: Field = ::stream_deserialize(&mut reader); + let return_value: [Field; 3] = __aztec_nr_internals__pedersen_commit(arg0, arg1).serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 2633971407_Field { + let input_calldata: [Field; 3] = aztec::oracle::avm::calldata_copy(1_u32, (<[Field; 1] as Serialize>::N + <[Field; 1] as Serialize>::N) + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<3> = aztec::protocol::utils::reader::Reader::<3>::new(input_calldata); + let arg0: [Field; 1] = <[Field; 1] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let arg1: [Field; 1] = <[Field; 1] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let arg2: bool = ::stream_deserialize(&mut reader); + let return_value: [Field; 1 * 1] = __aztec_nr_internals__conditional_move(arg0, arg1, arg2).serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 2520497807_Field { + let return_value: [Field; 1] = __aztec_nr_internals__u128_addition_overflow().serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 1975931334_Field { + let input_calldata: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + let mut reader: aztec::protocol::utils::reader::Reader<1> = aztec::protocol::utils::reader::Reader::<1>::new(input_calldata); + let arg0: Field = ::stream_deserialize(&mut reader); + let return_value: [Field; 10 * 1] = __aztec_nr_internals__to_le_bytes(arg0).serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 2961959597_Field { + let input_calldata: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + let mut reader: aztec::protocol::utils::reader::Reader<1> = aztec::protocol::utils::reader::Reader::<1>::new(input_calldata); + let arg0: Field = ::stream_deserialize(&mut reader); + let return_value: [Field; 16 * 1] = __aztec_nr_internals__to_le_bits(arg0).serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 3276887878_Field { + __aztec_nr_internals__assertion_failure(); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 294808228_Field { + __aztec_nr_internals__external_call_to_assertion_failure(); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 815932481_Field { + let input_calldata: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + let mut reader: aztec::protocol::utils::reader::Reader<1> = aztec::protocol::utils::reader::Reader::<1>::new(input_calldata); + let arg0: u8 = ::stream_deserialize(&mut reader); + let return_value: [Field; 1] = __aztec_nr_internals__divide_by_zero(arg0).serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 3880450065_Field { + __aztec_nr_internals__external_call_to_divide_by_zero(); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 2245930342_Field { + __aztec_nr_internals__external_call_to_divide_by_zero_recovers(); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 3667472301_Field { + __aztec_nr_internals__debug_logging(); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 290442984_Field { + let input_calldata: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<2> = aztec::protocol::utils::reader::Reader::<2>::new(input_calldata); + let arg0: Field = ::stream_deserialize(&mut reader); + let arg1: Field = ::stream_deserialize(&mut reader); + let return_value: [Field; 1] = __aztec_nr_internals__assert_same(arg0, arg1).serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 3853740100_Field { + let input_calldata: [Field; 4] = aztec::oracle::avm::calldata_copy(1_u32, <[Field; 3] as Serialize>::N + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<4> = aztec::protocol::utils::reader::Reader::<4>::new(input_calldata); + let arg0: [Field; 3] = <[Field; 3] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let arg1: bool = ::stream_deserialize(&mut reader); + __aztec_nr_internals__assert_calldata_copy(arg0, arg1); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 2293565755_Field { + let input_calldata: [Field; 301] = aztec::oracle::avm::calldata_copy(1_u32, <[Field; 300] as Serialize>::N + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<301> = aztec::protocol::utils::reader::Reader::<301>::new(input_calldata); + let arg0: [Field; 300] = <[Field; 300] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let arg1: bool = ::stream_deserialize(&mut reader); + __aztec_nr_internals__assert_calldata_copy_large(arg0, arg1); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 4172530660_Field { + __aztec_nr_internals__returndata_copy_oracle(); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 3794636397_Field { + let return_value: [Field; 3 * 1] = __aztec_nr_internals__return_oracle().serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 4147614534_Field { + let return_value: [Field; 3 * 1] = __aztec_nr_internals__revert_oracle().serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 2488367864_Field { + let input_calldata: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + let mut reader: aztec::protocol::utils::reader::Reader<1> = aztec::protocol::utils::reader::Reader::<1>::new(input_calldata); + let arg0: AztecAddress = ::stream_deserialize(&mut reader); + __aztec_nr_internals__test_get_contract_instance(arg0); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 2723912183_Field { + let input_calldata: [Field; 4] = aztec::oracle::avm::calldata_copy(1_u32, ((::N + ::N) + ::N) + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<4> = aztec::protocol::utils::reader::Reader::<4>::new(input_calldata); + let arg0: AztecAddress = ::stream_deserialize(&mut reader); + let arg1: AztecAddress = ::stream_deserialize(&mut reader); + let arg2: ContractClassId = ::stream_deserialize(&mut reader); + let arg3: Field = ::stream_deserialize(&mut reader); + __aztec_nr_internals__test_get_contract_instance_matches(arg0, arg1, arg2, arg3); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 1968200506_Field { + let return_value: [Field; 1] = __aztec_nr_internals__get_address().serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 301170519_Field { + let return_value: [Field; 1] = __aztec_nr_internals__get_sender().serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 2524054657_Field { + let return_value: [Field; 1] = __aztec_nr_internals__get_transaction_fee().serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 1458572288_Field { + let return_value: [Field; 1] = __aztec_nr_internals__get_chain_id().serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 421038220_Field { + let return_value: [Field; 1] = __aztec_nr_internals__get_version().serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 3223336515_Field { + let return_value: [Field; 1] = __aztec_nr_internals__get_block_number().serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 448989811_Field { + let return_value: [Field; 1] = __aztec_nr_internals__get_timestamp().serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 323255525_Field { + let return_value: [Field; 1] = __aztec_nr_internals__get_fee_per_l2_gas().serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 514475538_Field { + let return_value: [Field; 1] = __aztec_nr_internals__get_fee_per_da_gas().serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 1635524210_Field { + let return_value: [Field; 1] = __aztec_nr_internals__get_l2_gas_left().serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 2319460898_Field { + let return_value: [Field; 1] = __aztec_nr_internals__get_da_gas_left().serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 1608415988_Field { + let input_calldata: [Field; 4] = aztec::oracle::avm::calldata_copy(1_u32, ::N + <[Field; 3] as Serialize>::N); + let mut reader: aztec::protocol::utils::reader::Reader<4> = aztec::protocol::utils::reader::Reader::<4>::new(input_calldata); + let arg0: u8 = ::stream_deserialize(&mut reader); + let arg1: [Field; 3] = <[Field; 3] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let return_value: [Field; 1] = __aztec_nr_internals__get_args_hash(arg0, arg1).serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 2033426724_Field { + __aztec_nr_internals__emit_public_log(); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 671085844_Field { + let input_calldata: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<2> = aztec::protocol::utils::reader::Reader::<2>::new(input_calldata); + let arg0: Field = ::stream_deserialize(&mut reader); + let arg1: u64 = ::stream_deserialize(&mut reader); + let return_value: [Field; 1] = __aztec_nr_internals__note_hash_exists(arg0, arg1).serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 1524332459_Field { + let input_calldata: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + let mut reader: aztec::protocol::utils::reader::Reader<1> = aztec::protocol::utils::reader::Reader::<1>::new(input_calldata); + let arg0: Field = ::stream_deserialize(&mut reader); + __aztec_nr_internals__new_note_hash(arg0); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 3648851082_Field { + let input_calldata: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + let mut reader: aztec::protocol::utils::reader::Reader<1> = aztec::protocol::utils::reader::Reader::<1>::new(input_calldata); + let arg0: Field = ::stream_deserialize(&mut reader); + __aztec_nr_internals__new_nullifier(arg0); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 2323221248_Field { + let input_calldata: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + let mut reader: aztec::protocol::utils::reader::Reader<1> = aztec::protocol::utils::reader::Reader::<1>::new(input_calldata); + let arg0: u32 = ::stream_deserialize(&mut reader); + __aztec_nr_internals__n_storage_writes(arg0); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 1938641640_Field { + let input_calldata: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + let mut reader: aztec::protocol::utils::reader::Reader<1> = aztec::protocol::utils::reader::Reader::<1>::new(input_calldata); + let arg0: u32 = ::stream_deserialize(&mut reader); + __aztec_nr_internals__n_new_note_hashes(arg0); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 592684400_Field { + let input_calldata: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + let mut reader: aztec::protocol::utils::reader::Reader<1> = aztec::protocol::utils::reader::Reader::<1>::new(input_calldata); + let arg0: u32 = ::stream_deserialize(&mut reader); + __aztec_nr_internals__n_new_nullifiers(arg0); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 3921925917_Field { + let input_calldata: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + let mut reader: aztec::protocol::utils::reader::Reader<1> = aztec::protocol::utils::reader::Reader::<1>::new(input_calldata); + let arg0: u32 = ::stream_deserialize(&mut reader); + __aztec_nr_internals__n_new_l2_to_l1_msgs(arg0); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 3409962923_Field { + let input_calldata: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<2> = aztec::protocol::utils::reader::Reader::<2>::new(input_calldata); + let arg0: EthAddress = ::stream_deserialize(&mut reader); + let arg1: Field = ::stream_deserialize(&mut reader); + __aztec_nr_internals__raw_l2_to_l1_msg(arg0, arg1); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 2907114368_Field { + let input_calldata: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + let mut reader: aztec::protocol::utils::reader::Reader<1> = aztec::protocol::utils::reader::Reader::<1>::new(input_calldata); + let arg0: u32 = ::stream_deserialize(&mut reader); + __aztec_nr_internals__n_new_public_logs(arg0); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 2051407563_Field { + let input_calldata: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + let mut reader: aztec::protocol::utils::reader::Reader<1> = aztec::protocol::utils::reader::Reader::<1>::new(input_calldata); + let arg0: Field = ::stream_deserialize(&mut reader); + let return_value: [Field; 1] = __aztec_nr_internals__nullifier_exists(arg0).serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 2810255355_Field { + let input_calldata: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + let mut reader: aztec::protocol::utils::reader::Reader<1> = aztec::protocol::utils::reader::Reader::<1>::new(input_calldata); + let arg0: Field = ::stream_deserialize(&mut reader); + __aztec_nr_internals__assert_nullifier_exists(arg0); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 2367487025_Field { + let input_calldata: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + let mut reader: aztec::protocol::utils::reader::Reader<1> = aztec::protocol::utils::reader::Reader::<1>::new(input_calldata); + let arg0: Field = ::stream_deserialize(&mut reader); + __aztec_nr_internals__emit_nullifier_and_check(arg0); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 2417179850_Field { + let input_calldata: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + let mut reader: aztec::protocol::utils::reader::Reader<1> = aztec::protocol::utils::reader::Reader::<1>::new(input_calldata); + let arg0: Field = ::stream_deserialize(&mut reader); + __aztec_nr_internals__nullifier_collision(arg0); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 3972971575_Field { + let input_calldata: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<2> = aztec::protocol::utils::reader::Reader::<2>::new(input_calldata); + let arg0: Field = ::stream_deserialize(&mut reader); + let arg1: Field = ::stream_deserialize(&mut reader); + let return_value: [Field; 1] = __aztec_nr_internals__l1_to_l2_msg_exists(arg0, arg1).serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 2709402942_Field { + let input_calldata: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<2> = aztec::protocol::utils::reader::Reader::<2>::new(input_calldata); + let arg0: EthAddress = ::stream_deserialize(&mut reader); + let arg1: Field = ::stream_deserialize(&mut reader); + __aztec_nr_internals__send_l2_to_l1_msg(arg0, arg1); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 1183868090_Field { + __aztec_nr_internals__nested_call_to_nothing(); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 1843532057_Field { + __aztec_nr_internals__nested_call_to_nothing_recovers(); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 3561659563_Field { + let input_calldata: [Field; 4] = aztec::oracle::avm::calldata_copy(1_u32, ((::N + ::N) + ::N) + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<4> = aztec::protocol::utils::reader::Reader::<4>::new(input_calldata); + let arg0: Field = ::stream_deserialize(&mut reader); + let arg1: Field = ::stream_deserialize(&mut reader); + let arg2: u32 = ::stream_deserialize(&mut reader); + let arg3: u32 = ::stream_deserialize(&mut reader); + let return_value: [Field; 1] = __aztec_nr_internals__nested_call_to_add_with_gas(arg0, arg1, arg2, arg3).serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 94115833_Field { + let input_calldata: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<2> = aztec::protocol::utils::reader::Reader::<2>::new(input_calldata); + let arg0: Field = ::stream_deserialize(&mut reader); + let arg1: Field = ::stream_deserialize(&mut reader); + let return_value: [Field; 1] = __aztec_nr_internals__nested_call_to_add(arg0, arg1).serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 2936248969_Field { + let input_calldata: [Field; 23 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[AztecAddress; 23] as Serialize>::N); + let mut reader: aztec::protocol::utils::reader::Reader<23 * 1> = aztec::protocol::utils::reader::Reader::<23 * 1>::new(input_calldata); + let arg0: [AztecAddress; 23] = <[AztecAddress; 23] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + __aztec_nr_internals__nested_call_to_add_n_times_different_addresses(arg0); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 1362946309_Field { + let input_calldata: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<2> = aztec::protocol::utils::reader::Reader::<2>::new(input_calldata); + let arg0: Field = ::stream_deserialize(&mut reader); + let arg1: Field = ::stream_deserialize(&mut reader); + let return_value: [Field; 1] = __aztec_nr_internals__nested_static_call_to_add(arg0, arg1).serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 3861896907_Field { + __aztec_nr_internals__nested_static_call_to_set_storage(); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 1050471208_Field { + let input_calldata: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<2> = aztec::protocol::utils::reader::Reader::<2>::new(input_calldata); + let arg0: AztecAddress = ::stream_deserialize(&mut reader); + let arg1: Field = ::stream_deserialize(&mut reader); + __aztec_nr_internals__create_same_nullifier_in_nested_call(arg0, arg1); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 1630216043_Field { + let input_calldata: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<2> = aztec::protocol::utils::reader::Reader::<2>::new(input_calldata); + let arg0: AztecAddress = ::stream_deserialize(&mut reader); + let arg1: Field = ::stream_deserialize(&mut reader); + __aztec_nr_internals__create_different_nullifier_in_nested_call(arg0, arg1); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 1563037608_Field { + let input_calldata: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<2> = aztec::protocol::utils::reader::Reader::<2>::new(input_calldata); + let arg0: Field = ::stream_deserialize(&mut reader); + let arg1: Field = ::stream_deserialize(&mut reader); + let return_value: [Field; 1] = __aztec_nr_internals__nested_call_to_assert_same(arg0, arg1).serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 3786762676_Field { + let input_calldata: [Field; 300 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[Field; 300] as Serialize>::N); + let mut reader: aztec::protocol::utils::reader::Reader<300 * 1> = aztec::protocol::utils::reader::Reader::<300 * 1>::new(input_calldata); + let arg0: [Field; 300] = <[Field; 300] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let return_value: [Field; 1] = __aztec_nr_internals__fn_w_large_calldata(arg0).serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 14812432_Field { + let input_calldata: [Field; 300 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[Field; 300] as Serialize>::N); + let mut reader: aztec::protocol::utils::reader::Reader<300 * 1> = aztec::protocol::utils::reader::Reader::<300 * 1>::new(input_calldata); + let arg0: [Field; 300] = <[Field; 300] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let return_value: [Field; 1] = __aztec_nr_internals__nested_call_large_calldata(arg0).serialize(); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 2734888597_Field { + __aztec_nr_internals__call_fee_juice(); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 1225767423_Field { + __aztec_nr_internals__call_auth_registry(); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 2336742722_Field { + __aztec_nr_internals__call_instance_registry(); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 43639379_Field { + let input_calldata: [Field; 25] = aztec::oracle::avm::calldata_copy(1_u32, (((((<[Field; 10] as Serialize>::N + <[u8; 10] as Serialize>::N) + ::N) + ::N) + ::N) + ::N) + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<25> = aztec::protocol::utils::reader::Reader::<25>::new(input_calldata); + let arg0: [Field; 10] = <[Field; 10] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let arg1: [u8; 10] = <[u8; 10] as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let arg2: AztecAddress = ::stream_deserialize(&mut reader); + let arg3: AztecAddress = ::stream_deserialize(&mut reader); + let arg4: ContractClassId = ::stream_deserialize(&mut reader); + let arg5: Field = ::stream_deserialize(&mut reader); + let arg6: bool = ::stream_deserialize(&mut reader); + __aztec_nr_internals__bulk_testing(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + aztec::oracle::avm::avm_return([].as_slice()); + }; + panic(f"Unknown selector {selector}") + } + + pub struct add_args_return_parameters { + pub arg_a: Field, + pub arg_b: Field, + } + + pub struct add_storage_map_parameters { + pub to: AztecAddress, + pub amount: u32, + } + + pub struct add_u128_parameters { + pub a: u128, + pub b: u128, + } + + pub struct assert_calldata_copy_large_parameters { + pub args: [Field; 300], + pub with_selector: bool, + } + + pub struct assert_calldata_copy_parameters { + pub args: [Field; 3], + pub with_selector: bool, + } + + pub struct assert_nullifier_exists_parameters { + pub nullifier: Field, + } + + pub struct assert_same_parameters { + pub arg_a: Field, + pub arg_b: Field, + } + + pub struct assertion_failure_parameters { + } + + pub struct bulk_testing_parameters { + pub args_field: [Field; 10], + pub args_u8: [u8; 10], + pub get_instance_for_address: AztecAddress, + pub expected_deployer: AztecAddress, + pub expected_class_id: ContractClassId, + pub expected_initialization_hash: Field, + pub skip_strictly_limited_side_effects: bool, + } + + pub struct call_auth_registry_parameters { + } + + pub struct call_fee_juice_parameters { + } + + pub struct call_instance_registry_parameters { + } + + pub struct conditional_move_parameters { + pub x: [Field; 1], + pub y: [Field; 1], + pub b: bool, + } + + pub struct create_different_nullifier_in_nested_call_parameters { + pub nestedAddress: AztecAddress, + pub nullifier: Field, + } + + pub struct create_same_nullifier_in_nested_call_parameters { + pub nestedAddress: AztecAddress, + pub nullifier: Field, + } + + pub struct debug_logging_parameters { + } + + pub struct divide_by_zero_parameters { + pub denominator: u8, + } + + pub struct elliptic_curve_add_and_double_parameters { + } + + pub struct elliptic_curve_add_parameters { + pub lhs: Point, + pub rhs: Point, + } + + pub struct emit_nullifier_and_check_parameters { + pub nullifier: Field, + } + + pub struct emit_public_log_parameters { + } + + pub struct enqueue_public_from_private_parameters { + } + + pub struct external_call_to_assertion_failure_parameters { + } + + pub struct external_call_to_divide_by_zero_parameters { + } + + pub struct external_call_to_divide_by_zero_recovers_parameters { + } + + pub struct fn_w_large_calldata_parameters { + pub _arr: [Field; 300], + } + + pub struct get_address_parameters { + } + + pub struct get_args_hash_parameters { + pub _a: u8, + pub _fields: [Field; 3], + } + + pub struct get_block_number_parameters { + } + + pub struct get_chain_id_parameters { + } + + pub struct get_da_gas_left_parameters { + } + + pub struct get_fee_per_da_gas_parameters { + } + + pub struct get_fee_per_l2_gas_parameters { + } + + pub struct get_l2_gas_left_parameters { + } + + pub struct get_sender_parameters { + } + + pub struct get_timestamp_parameters { + } + + pub struct get_transaction_fee_parameters { + } + + pub struct get_version_parameters { + } + + pub struct l1_to_l2_msg_exists_parameters { + pub msg_hash: Field, + pub msg_leaf_index: Field, + } + + pub struct modulo2_parameters { + pub a: u64, + } + + pub struct n_new_l2_to_l1_msgs_parameters { + pub num: u32, + } + + pub struct n_new_note_hashes_parameters { + pub num: u32, + } + + pub struct n_new_nullifiers_parameters { + pub num: u32, + } + + pub struct n_new_public_logs_parameters { + pub num: u32, + } + + pub struct n_storage_writes_parameters { + pub num: u32, + } + + pub struct nested_call_large_calldata_parameters { + pub arr: [Field; 300], + } + + pub struct nested_call_to_add_n_times_different_addresses_parameters { + pub addrs: [AztecAddress; 23], + } + + pub struct nested_call_to_add_parameters { + pub arg_a: Field, + pub arg_b: Field, + } + + pub struct nested_call_to_add_with_gas_parameters { + pub arg_a: Field, + pub arg_b: Field, + pub l2_gas: u32, + pub da_gas: u32, + } + + pub struct nested_call_to_assert_same_parameters { + pub arg_a: Field, + pub arg_b: Field, + } + + pub struct nested_call_to_nothing_parameters { + } + + pub struct nested_call_to_nothing_recovers_parameters { + } + + pub struct nested_static_call_to_add_parameters { + pub arg_a: Field, + pub arg_b: Field, + } + + pub struct nested_static_call_to_set_storage_parameters { + } + + pub struct new_note_hash_parameters { + pub note_hash: Field, + } + + pub struct new_nullifier_parameters { + pub nullifier: Field, + } + + pub struct note_hash_exists_parameters { + pub note_hash: Field, + pub leaf_index: u64, + } + + pub struct nullifier_collision_parameters { + pub nullifier: Field, + } + + pub struct nullifier_exists_parameters { + pub nullifier: Field, + } + + pub struct pedersen_commit_parameters { + pub x: Field, + pub y: Field, + } + + pub struct raw_l2_to_l1_msg_parameters { + pub recipient: EthAddress, + pub content: Field, + } + + pub struct read_assert_storage_single_parameters { + pub a: Field, + } + + pub struct read_storage_list_parameters { + } + + pub struct read_storage_map_parameters { + pub address: AztecAddress, + } + + pub struct read_storage_single_parameters { + } + + pub struct return_oracle_parameters { + } + + pub struct returndata_copy_oracle_parameters { + } + + pub struct revert_oracle_parameters { + } + + pub struct send_l2_to_l1_msg_parameters { + pub recipient: EthAddress, + pub content: Field, + } + + pub struct set_opcode_big_field_parameters { + } + + pub struct set_opcode_really_big_field_parameters { + } + + pub struct set_opcode_small_field_parameters { + } + + pub struct set_opcode_u32_parameters { + } + + pub struct set_opcode_u64_parameters { + } + + pub struct set_opcode_u8_parameters { + } + + pub struct set_opcode_u8_view_parameters { + } + + pub struct set_read_storage_single_parameters { + pub a: Field, + } + + pub struct set_storage_list_parameters { + pub a: Field, + pub b: Field, + } + + pub struct set_storage_map_parameters { + pub to: AztecAddress, + pub amount: u32, + } + + pub struct set_storage_single_parameters { + pub a: Field, + } + + pub struct test_get_contract_instance_matches_parameters { + pub address: AztecAddress, + pub expected_deployer: AztecAddress, + pub expected_class_id: ContractClassId, + pub expected_initialization_hash: Field, + } + + pub struct test_get_contract_instance_parameters { + pub address: AztecAddress, + } + + pub struct to_le_bits_parameters { + pub input: Field, + } + + pub struct to_le_bytes_parameters { + pub input: Field, + } + + pub struct u128_addition_overflow_parameters { + } + + pub struct variable_base_msm_parameters { + pub scalar_lo: Field, + pub scalar_hi: Field, + pub scalar2_lo: Field, + pub scalar2_hi: Field, + } + + #[abi(functions)] + pub struct add_args_return_abi { + parameters: add_args_return_parameters, + return_type: Field, + } + + #[abi(functions)] + pub struct add_storage_map_abi { + parameters: add_storage_map_parameters, + return_type: Field, + } + + #[abi(functions)] + pub struct add_u128_abi { + parameters: add_u128_parameters, + return_type: u128, + } + + #[abi(functions)] + pub struct assert_calldata_copy_abi { + parameters: assert_calldata_copy_parameters, + } + + #[abi(functions)] + pub struct assert_calldata_copy_large_abi { + parameters: assert_calldata_copy_large_parameters, + } + + #[abi(functions)] + pub struct assert_nullifier_exists_abi { + parameters: assert_nullifier_exists_parameters, + } + + #[abi(functions)] + pub struct assert_same_abi { + parameters: assert_same_parameters, + return_type: Field, + } + + #[abi(functions)] + pub struct assertion_failure_abi { + parameters: assertion_failure_parameters, + } + + #[abi(functions)] + pub struct bulk_testing_abi { + parameters: bulk_testing_parameters, + } + + #[abi(functions)] + pub struct call_auth_registry_abi { + parameters: call_auth_registry_parameters, + } + + #[abi(functions)] + pub struct call_fee_juice_abi { + parameters: call_fee_juice_parameters, + } + + #[abi(functions)] + pub struct call_instance_registry_abi { + parameters: call_instance_registry_parameters, + } + + #[abi(functions)] + pub struct conditional_move_abi { + parameters: conditional_move_parameters, + return_type: [Field; 1], + } + + #[abi(functions)] + pub struct create_different_nullifier_in_nested_call_abi { + parameters: create_different_nullifier_in_nested_call_parameters, + } + + #[abi(functions)] + pub struct create_same_nullifier_in_nested_call_abi { + parameters: create_same_nullifier_in_nested_call_parameters, + } + + #[abi(functions)] + pub struct debug_logging_abi { + parameters: debug_logging_parameters, + } + + #[abi(functions)] + pub struct divide_by_zero_abi { + parameters: divide_by_zero_parameters, + return_type: u8, + } + + #[abi(functions)] + pub struct elliptic_curve_add_abi { + parameters: elliptic_curve_add_parameters, + return_type: Point, + } + + #[abi(functions)] + pub struct elliptic_curve_add_and_double_abi { + parameters: elliptic_curve_add_and_double_parameters, + return_type: Point, + } + + #[abi(functions)] + pub struct emit_nullifier_and_check_abi { + parameters: emit_nullifier_and_check_parameters, + } + + #[abi(functions)] + pub struct emit_public_log_abi { + parameters: emit_public_log_parameters, + } + + #[abi(functions)] + pub struct enqueue_public_from_private_abi { + parameters: enqueue_public_from_private_parameters, + } + + #[abi(functions)] + pub struct external_call_to_assertion_failure_abi { + parameters: external_call_to_assertion_failure_parameters, + } + + #[abi(functions)] + pub struct external_call_to_divide_by_zero_abi { + parameters: external_call_to_divide_by_zero_parameters, + } + + #[abi(functions)] + pub struct external_call_to_divide_by_zero_recovers_abi { + parameters: external_call_to_divide_by_zero_recovers_parameters, + } + + #[abi(functions)] + pub struct fn_w_large_calldata_abi { + parameters: fn_w_large_calldata_parameters, + return_type: Field, + } + + #[abi(functions)] + pub struct get_address_abi { + parameters: get_address_parameters, + return_type: AztecAddress, + } + + #[abi(functions)] + pub struct get_args_hash_abi { + parameters: get_args_hash_parameters, + return_type: Field, + } + + #[abi(functions)] + pub struct get_block_number_abi { + parameters: get_block_number_parameters, + return_type: u32, + } + + #[abi(functions)] + pub struct get_chain_id_abi { + parameters: get_chain_id_parameters, + return_type: Field, + } + + #[abi(functions)] + pub struct get_da_gas_left_abi { + parameters: get_da_gas_left_parameters, + return_type: u32, + } + + #[abi(functions)] + pub struct get_fee_per_da_gas_abi { + parameters: get_fee_per_da_gas_parameters, + return_type: u128, + } + + #[abi(functions)] + pub struct get_fee_per_l2_gas_abi { + parameters: get_fee_per_l2_gas_parameters, + return_type: u128, + } + + #[abi(functions)] + pub struct get_l2_gas_left_abi { + parameters: get_l2_gas_left_parameters, + return_type: u32, + } + + #[abi(functions)] + pub struct get_sender_abi { + parameters: get_sender_parameters, + return_type: AztecAddress, + } + + #[abi(functions)] + pub struct get_timestamp_abi { + parameters: get_timestamp_parameters, + return_type: u64, + } + + #[abi(functions)] + pub struct get_transaction_fee_abi { + parameters: get_transaction_fee_parameters, + return_type: Field, + } + + #[abi(functions)] + pub struct get_version_abi { + parameters: get_version_parameters, + return_type: Field, + } + + #[abi(functions)] + pub struct l1_to_l2_msg_exists_abi { + parameters: l1_to_l2_msg_exists_parameters, + return_type: bool, + } + + #[abi(functions)] + pub struct modulo2_abi { + parameters: modulo2_parameters, + return_type: u64, + } + + #[abi(functions)] + pub struct n_new_l2_to_l1_msgs_abi { + parameters: n_new_l2_to_l1_msgs_parameters, + } + + #[abi(functions)] + pub struct n_new_note_hashes_abi { + parameters: n_new_note_hashes_parameters, + } + + #[abi(functions)] + pub struct n_new_nullifiers_abi { + parameters: n_new_nullifiers_parameters, + } + + #[abi(functions)] + pub struct n_new_public_logs_abi { + parameters: n_new_public_logs_parameters, + } + + #[abi(functions)] + pub struct n_storage_writes_abi { + parameters: n_storage_writes_parameters, + } + + #[abi(functions)] + pub struct nested_call_large_calldata_abi { + parameters: nested_call_large_calldata_parameters, + return_type: Field, + } + + #[abi(functions)] + pub struct nested_call_to_add_abi { + parameters: nested_call_to_add_parameters, + return_type: Field, + } + + #[abi(functions)] + pub struct nested_call_to_add_n_times_different_addresses_abi { + parameters: nested_call_to_add_n_times_different_addresses_parameters, + } + + #[abi(functions)] + pub struct nested_call_to_add_with_gas_abi { + parameters: nested_call_to_add_with_gas_parameters, + return_type: Field, + } + + #[abi(functions)] + pub struct nested_call_to_assert_same_abi { + parameters: nested_call_to_assert_same_parameters, + return_type: Field, + } + + #[abi(functions)] + pub struct nested_call_to_nothing_abi { + parameters: nested_call_to_nothing_parameters, + } + + #[abi(functions)] + pub struct nested_call_to_nothing_recovers_abi { + parameters: nested_call_to_nothing_recovers_parameters, + } + + #[abi(functions)] + pub struct nested_static_call_to_add_abi { + parameters: nested_static_call_to_add_parameters, + return_type: Field, + } + + #[abi(functions)] + pub struct nested_static_call_to_set_storage_abi { + parameters: nested_static_call_to_set_storage_parameters, + } + + #[abi(functions)] + pub struct new_note_hash_abi { + parameters: new_note_hash_parameters, + } + + #[abi(functions)] + pub struct new_nullifier_abi { + parameters: new_nullifier_parameters, + } + + #[abi(functions)] + pub struct note_hash_exists_abi { + parameters: note_hash_exists_parameters, + return_type: bool, + } + + #[abi(functions)] + pub struct nullifier_collision_abi { + parameters: nullifier_collision_parameters, + } + + #[abi(functions)] + pub struct nullifier_exists_abi { + parameters: nullifier_exists_parameters, + return_type: bool, + } + + #[abi(functions)] + pub struct pedersen_commit_abi { + parameters: pedersen_commit_parameters, + return_type: Point, + } + + #[abi(functions)] + pub struct raw_l2_to_l1_msg_abi { + parameters: raw_l2_to_l1_msg_parameters, + } + + #[abi(functions)] + pub struct read_assert_storage_single_abi { + parameters: read_assert_storage_single_parameters, + } + + #[abi(functions)] + pub struct read_storage_list_abi { + parameters: read_storage_list_parameters, + return_type: [Field; 2], + } + + #[abi(functions)] + pub struct read_storage_map_abi { + parameters: read_storage_map_parameters, + return_type: u32, + } + + #[abi(functions)] + pub struct read_storage_single_abi { + parameters: read_storage_single_parameters, + return_type: Field, + } + + #[abi(functions)] + pub struct return_oracle_abi { + parameters: return_oracle_parameters, + return_type: [Field; 3], + } + + #[abi(functions)] + pub struct returndata_copy_oracle_abi { + parameters: returndata_copy_oracle_parameters, + } + + #[abi(functions)] + pub struct revert_oracle_abi { + parameters: revert_oracle_parameters, + return_type: [Field; 3], + } + + #[abi(functions)] + pub struct send_l2_to_l1_msg_abi { + parameters: send_l2_to_l1_msg_parameters, + } + + #[abi(functions)] + pub struct set_opcode_big_field_abi { + parameters: set_opcode_big_field_parameters, + return_type: Field, + } + + #[abi(functions)] + pub struct set_opcode_really_big_field_abi { + parameters: set_opcode_really_big_field_parameters, + return_type: Field, + } + + #[abi(functions)] + pub struct set_opcode_small_field_abi { + parameters: set_opcode_small_field_parameters, + return_type: Field, + } + + #[abi(functions)] + pub struct set_opcode_u32_abi { + parameters: set_opcode_u32_parameters, + return_type: u32, + } + + #[abi(functions)] + pub struct set_opcode_u64_abi { + parameters: set_opcode_u64_parameters, + return_type: u64, + } + + #[abi(functions)] + pub struct set_opcode_u8_abi { + parameters: set_opcode_u8_parameters, + return_type: u8, + } + + #[abi(functions)] + pub struct set_opcode_u8_view_abi { + parameters: set_opcode_u8_view_parameters, + return_type: u8, + } + + #[abi(functions)] + pub struct set_read_storage_single_abi { + parameters: set_read_storage_single_parameters, + return_type: Field, + } + + #[abi(functions)] + pub struct set_storage_list_abi { + parameters: set_storage_list_parameters, + } + + #[abi(functions)] + pub struct set_storage_map_abi { + parameters: set_storage_map_parameters, + return_type: Field, + } + + #[abi(functions)] + pub struct set_storage_single_abi { + parameters: set_storage_single_parameters, + } + + #[abi(functions)] + pub struct test_get_contract_instance_abi { + parameters: test_get_contract_instance_parameters, + } + + #[abi(functions)] + pub struct test_get_contract_instance_matches_abi { + parameters: test_get_contract_instance_matches_parameters, + } + + #[abi(functions)] + pub struct to_le_bits_abi { + parameters: to_le_bits_parameters, + return_type: [bool; 16], + } + + #[abi(functions)] + pub struct to_le_bytes_abi { + parameters: to_le_bytes_parameters, + return_type: [u8; 10], + } + + #[abi(functions)] + pub struct u128_addition_overflow_abi { + parameters: u128_addition_overflow_parameters, + return_type: u128, + } + + #[abi(functions)] + pub struct variable_base_msm_abi { + parameters: variable_base_msm_parameters, + return_type: Point, + } + + fn __aztec_nr_internals__enqueue_public_from_private(inputs: aztec::context::inputs::PrivateContextInputs) -> return_data aztec::protocol::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs { + aztec::oracle::version::assert_compatible_oracle_version(); + let mut self: aztec::contract_self::contract_self_private::ContractSelfPrivate, CallSelf<&mut aztec::context::PrivateContext>, EnqueueSelf<&mut aztec::context::PrivateContext>, CallSelfStatic<&mut aztec::context::PrivateContext>, EnqueueSelfStatic<&mut aztec::context::PrivateContext>, CallInternal<&mut aztec::context::PrivateContext>, CallSelfUtility> = { + let serialized_params: [Field; 0] = []; + let args_hash: Field = aztec::hash::hash_args(serialized_params); + let mut context: aztec::context::PrivateContext = aztec::context::PrivateContext::new(inputs, args_hash); + let storage: Storage<&mut aztec::context::PrivateContext> = Storage::<&mut aztec::context::PrivateContext>::init(&mut context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf<&mut aztec::context::PrivateContext> = CallSelf::<&mut aztec::context::PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self: EnqueueSelf<&mut aztec::context::PrivateContext> = EnqueueSelf::<&mut aztec::context::PrivateContext> { address: self_address, context: &mut context}; + let call_self_static: CallSelfStatic<&mut aztec::context::PrivateContext> = CallSelfStatic::<&mut aztec::context::PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self_static: EnqueueSelfStatic<&mut aztec::context::PrivateContext> = EnqueueSelfStatic::<&mut aztec::context::PrivateContext> { address: self_address, context: &mut context}; + let internal: CallInternal<&mut aztec::context::PrivateContext> = CallInternal::<&mut aztec::context::PrivateContext> { context: &mut context}; + let call_self_utility: CallSelfUtility = CallSelfUtility { address: self_address}; + let utility: aztec::contract_self::contract_self_private::PrivateUtilityCalls = aztec::contract_self::contract_self_private::PrivateUtilityCalls:: { call_self: call_self_utility}; + aztec::contract_self::contract_self_private::ContractSelfPrivate::, CallSelf<&mut aztec::context::PrivateContext>, EnqueueSelf<&mut aztec::context::PrivateContext>, CallSelfStatic<&mut aztec::context::PrivateContext>, EnqueueSelfStatic<&mut aztec::context::PrivateContext>, CallInternal<&mut aztec::context::PrivateContext>, CallSelfUtility>::new(&mut context, storage, call_self, enqueue_self, call_self_static, enqueue_self_static, internal, utility) + }; + let within_revertible_phase: bool = self.context.in_revertible_phase(); + self.enqueue_self_static.set_opcode_u8_view(); + self.enqueue_self.set_read_storage_single(5_Field); + assert(within_revertible_phase == self.context.in_revertible_phase(), f"Phase change detected on function with phase check. If this is expected, use #[allow_phase_change]"); + self.context.finish() + } + + unconstrained fn __aztec_nr_internals__add_args_return(arg_a: Field, arg_b: Field) -> pub Field { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + add(arg_a, arg_b) + } + } + + unconstrained fn __aztec_nr_internals__add_storage_map(to: AztecAddress, amount: u32) -> pub Field { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _add_storage_map(self.storage, to, amount) + } + } + + unconstrained fn __aztec_nr_internals__add_u128(a: u128, b: u128) -> pub u128 { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + a + b + } + } + + unconstrained fn __aztec_nr_internals__assert_calldata_copy(args: [Field; 3], with_selector: bool) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 4] = aztec::oracle::avm::calldata_copy(1_u32, <[Field; 3] as Serialize>::N + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + let offset: u32 = with_selector as u32; + let cd: [Field; 3] = aztec::oracle::avm::calldata_copy(offset, 3_u32); + assert(cd == args, "Calldata copy failed"); + } + } + + unconstrained fn __aztec_nr_internals__assert_calldata_copy_large(args: [Field; 300], with_selector: bool) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 301] = aztec::oracle::avm::calldata_copy(1_u32, <[Field; 300] as Serialize>::N + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + let offset: u32 = with_selector as u32; + let cd: [Field; 300] = aztec::oracle::avm::calldata_copy(offset, 300_u32); + assert(cd == args, "Calldata copy failed"); + } + } + + unconstrained fn __aztec_nr_internals__assert_nullifier_exists(nullifier: Field) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + assert(self.context.nullifier_exists_unsafe(nullifier, self.address), "Nullifier doesn't exist!"); + } + } + + unconstrained fn __aztec_nr_internals__assert_same(arg_a: Field, arg_b: Field) -> pub Field { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + assert(arg_a == arg_b, "Values are not equal"); + 1_Field + } + } + + unconstrained fn __aztec_nr_internals__assertion_failure() { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + helper_with_failed_assertion() + } + } + + unconstrained fn __aztec_nr_internals__bulk_testing(args_field: [Field; 10], args_u8: [u8; 10], get_instance_for_address: AztecAddress, expected_deployer: AztecAddress, expected_class_id: ContractClassId, expected_initialization_hash: Field, skip_strictly_limited_side_effects: bool) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 25] = aztec::oracle::avm::calldata_copy(1_u32, (((((<[Field; 10] as Serialize>::N + <[u8; 10] as Serialize>::N) + ::N) + ::N) + ::N) + ::N) + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + aztec::oracle::logging::debug_log("biwise_ops"); + let num: u32 = self.context.block_number(); + let _: u32 = bitwise_ops(num, num); + aztec::oracle::logging::debug_log("set_storage_single"); + _set_storage_single(self.storage, 30_Field); + aztec::oracle::logging::debug_log("set_storage_list"); + _set_storage_list(self.storage, 40_Field, 50_Field); + aztec::oracle::logging::debug_log("read_storage_list"); + let _: Field = _set_storage_map(self.storage, self.address, 60_u32); + aztec::oracle::logging::debug_log("add_storage_map"); + let _: Field = _add_storage_map(self.storage, self.address, 10_u32); + aztec::oracle::logging::debug_log("read_storage_map"); + let _: u32 = _read_storage_map(self.storage, self.address); + aztec::oracle::logging::debug_log("keccak_hash"); + let _: [u8; 32] = keccak256::keccak256(args_u8, args_u8.len()); + aztec::oracle::logging::debug_log("sha256_hash"); + let _: [u8; 32] = sha256::sha256_var(args_u8, args_u8.len()); + aztec::oracle::logging::debug_log("poseidon2_hash"); + let _: Field = poseidon::poseidon2::Poseidon2::hash(args_field, args_field.len()); + aztec::oracle::logging::debug_log("pedersen_hash"); + let _: Field = std::hash::pedersen_hash(args_field); + aztec::oracle::logging::debug_log("pedersen_hash_with_index"); + let _: Field = std::hash::pedersen_hash_with_separator(args_field, 20_u32); + aztec::oracle::logging::debug_log("integer_division"); + let _: u8 = integer_division(args_u8[0_u32], args_u8[1_u32]); + aztec::oracle::logging::debug_log("field_division"); + let _: Field = field_division(args_field[0_u32], args_field[1_u32]); + aztec::oracle::logging::debug_log("test_get_contract_instance"); + _test_get_contract_instance_matches(get_instance_for_address, expected_deployer, expected_class_id, expected_initialization_hash); + aztec::oracle::logging::debug_log("get_address"); + let _: AztecAddress = _get_address(self.address); + aztec::oracle::logging::debug_log("get_sender"); + let _: AztecAddress = _get_sender(self.context); + aztec::oracle::logging::debug_log("get_transaction_fee"); + let _: Field = _get_transaction_fee(self.context); + aztec::oracle::logging::debug_log("get_chain_id"); + let _: Field = _get_chain_id(self.context); + aztec::oracle::logging::debug_log("get_version"); + let _: Field = _get_version(self.context); + aztec::oracle::logging::debug_log("get_block_number"); + let _: u32 = _get_block_number(self.context); + aztec::oracle::logging::debug_log("get_timestamp"); + let _: u64 = _get_timestamp(self.context); + aztec::oracle::logging::debug_log("get_fee_per_l2_gas"); + let _: u128 = _get_fee_per_l2_gas(self.context); + aztec::oracle::logging::debug_log("get_fee_per_da_gas"); + let _: u128 = _get_fee_per_da_gas(self.context); + aztec::oracle::logging::debug_log("get_l2_gas_left"); + let _: u32 = _get_l2_gas_left(self.context); + aztec::oracle::logging::debug_log("get_da_gas_left"); + let _: u32 = _get_da_gas_left(self.context); + if !skip_strictly_limited_side_effects { + aztec::oracle::logging::debug_log("emit_public_log"); + _emit_public_log(self.context); + }; + aztec::oracle::logging::debug_log("note_hash_exists"); + let _: bool = _note_hash_exists(self.context, 1_Field, 2_u64); + aztec::oracle::logging::debug_log("new_note_hash"); + _new_note_hash(self.context, 1_Field); + aztec::oracle::logging::debug_log("new_nullifier"); + _new_nullifier(self.context, args_field[0_u32]); + aztec::oracle::logging::debug_log("nullifier_exists"); + let _: bool = _nullifier_exists(self.context, self.address, 1_Field); + aztec::oracle::logging::debug_log("l1_to_l2_msg_exists"); + let _: bool = _l1_to_l2_msg_exists(self.context, 1_Field, 2_Field); + if !skip_strictly_limited_side_effects { + aztec::oracle::logging::debug_log("send_l2_to_l1_msg"); + _send_l2_to_l1_msg(self.context, EthAddress::from_field(8224_Field), 1_Field); + }; + aztec::oracle::logging::debug_log("storage_read_and_write"); + _set_storage_single(self.storage, _read_storage_single(self.storage)); + aztec::oracle::logging::debug_log("nested_call_to_add"); + let _: Field = _nested_call_to_add(self.context, self.address, 1_Field, 2_Field); + aztec::oracle::logging::debug_log("nested_static_call_to_add"); + let _: Field = _nested_static_call_to_add(self.context, self.address, 1_Field, 2_Field); + aztec::oracle::logging::debug_log("nested_call_to_protocol_contract"); + _call_fee_juice(self.context, self.address); + aztec::oracle::logging::debug_log("to_le_bytes"); + let first_byte: u8 = _to_le_bytes(args_field[0_u32])[0_u32]; + assert(first_byte != 0_u8); + aztec::oracle::logging::debug_log("to_le_bits"); + let first_bit: bool = _to_le_bits(args_field[0_u32])[0_u32]; + assert(first_bit); + } + } + + unconstrained fn __aztec_nr_internals__call_auth_registry() { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + let _: bool = AuthRegistry::at(CANONICAL_AUTH_REGISTRY_ADDRESS).is_reject_all(self.address).view(self.context); + } + } + + unconstrained fn __aztec_nr_internals__call_fee_juice() { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _call_fee_juice(self.context, self.address); + } + } + + unconstrained fn __aztec_nr_internals__call_instance_registry() { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + let _: u64 = self.view(ContractInstanceRegistry::at(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS).get_update_delay()); + } + } + + unconstrained fn __aztec_nr_internals__conditional_move(x: [Field; 1], y: [Field; 1], b: bool) -> pub [Field; 1] { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 3] = aztec::oracle::avm::calldata_copy(1_u32, (<[Field; 1] as Serialize>::N + <[Field; 1] as Serialize>::N) + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + if b { + x + } else { + y + } + } + } + + unconstrained fn __aztec_nr_internals__create_different_nullifier_in_nested_call(nestedAddress: AztecAddress, nullifier: Field) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + self.context.push_nullifier(nullifier); + self.call(AvmTest::at(nestedAddress).new_nullifier(nullifier + 1_Field)); + } + } + + unconstrained fn __aztec_nr_internals__create_same_nullifier_in_nested_call(nestedAddress: AztecAddress, nullifier: Field) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + self.context.push_nullifier(nullifier); + self.call(AvmTest::at(nestedAddress).new_nullifier(nullifier)); + } + } + + unconstrained fn __aztec_nr_internals__debug_logging() { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + aztec::oracle::logging::debug_log("just text"); + aztec::oracle::logging::debug_log_format("second: {1}", [1_Field, 2_Field, 3_Field, 4_Field]); + aztec::oracle::logging::debug_log_format("whole array: {}", [1_Field, 2_Field, 3_Field, 4_Field]); + aztec::oracle::logging::debug_log("tabs and newlines\n\t- first\n\t- second"); + aztec::oracle::logging::fatal_log("fatal error"); + aztec::oracle::logging::trace_log_format("trace format: {}", [1_Field, 3_Field, 3_Field, 7_Field]); + } + } + + unconstrained fn __aztec_nr_internals__divide_by_zero(denominator: u8) -> pub u8 { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + 1_u8 / denominator + } + } + + unconstrained fn __aztec_nr_internals__elliptic_curve_add(lhs: Point, rhs: Point) -> pub Point { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 6] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + lhs + rhs + } + } + + unconstrained fn __aztec_nr_internals__elliptic_curve_add_and_double() -> pub Point { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + let g: Point = Point { x: GRUMPKIN_ONE_X, y: GRUMPKIN_ONE_Y, is_infinite: false}; + let doubled: Point = g + g; + let added: Point = g + doubled; + added + } + } + + unconstrained fn __aztec_nr_internals__emit_nullifier_and_check(nullifier: Field) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + self.context.push_nullifier(nullifier); + let exists: bool = self.context.nullifier_exists_unsafe(nullifier, self.address); + assert(exists, "Nullifier was just created, but its existence wasn't detected!"); + } + } + + unconstrained fn __aztec_nr_internals__emit_public_log() { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _emit_public_log(self.context); + } + } + + unconstrained fn __aztec_nr_internals__external_call_to_assertion_failure() { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + self.call_self.assertion_failure(); + } + } + + unconstrained fn __aztec_nr_internals__external_call_to_divide_by_zero() { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + let _: u8 = self.call_self.divide_by_zero(0_u8); + } + } + + unconstrained fn __aztec_nr_internals__external_call_to_divide_by_zero_recovers() { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + let l2_gas_left: u32 = self.context.l2_gas_left(); + let da_gas_left: u32 = self.context.da_gas_left(); + let selector: FunctionSelector = FunctionSelector::from_signature("divide_by_zero(u8)"); + call(l2_gas_left - 200000_u32, da_gas_left - 200000_u32, self.address, [selector.to_field(), 0_Field]); + let success: bool = success_copy(); + assert(!success, "Nested CALL instruction should return failure on exceptional halt"); + assert(returndata_size() == 0_u32, "Returndata should be empty when nested call exceptionally halts"); + } + } + + unconstrained fn __aztec_nr_internals__fn_w_large_calldata(_arr: [Field; 300]) -> pub Field { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 300 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[Field; 300] as Serialize>::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + 5_Field + } + } + + unconstrained fn __aztec_nr_internals__get_address() -> pub AztecAddress { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _get_address(self.address) + } + } + + unconstrained fn __aztec_nr_internals__get_args_hash(_a: u8, _fields: [Field; 3]) -> pub Field { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 4] = aztec::oracle::avm::calldata_copy(1_u32, ::N + <[Field; 3] as Serialize>::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + self.context.get_args_hash() + } + } + + unconstrained fn __aztec_nr_internals__get_block_number() -> pub u32 { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _get_block_number(self.context) + } + } + + unconstrained fn __aztec_nr_internals__get_chain_id() -> pub Field { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _get_chain_id(self.context) + } + } + + unconstrained fn __aztec_nr_internals__get_da_gas_left() -> pub u32 { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _get_da_gas_left(self.context) + } + } + + unconstrained fn __aztec_nr_internals__get_fee_per_da_gas() -> pub u128 { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _get_fee_per_da_gas(self.context) + } + } + + unconstrained fn __aztec_nr_internals__get_fee_per_l2_gas() -> pub u128 { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _get_fee_per_l2_gas(self.context) + } + } + + unconstrained fn __aztec_nr_internals__get_l2_gas_left() -> pub u32 { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _get_l2_gas_left(self.context) + } + } + + unconstrained fn __aztec_nr_internals__get_sender() -> pub AztecAddress { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _get_sender(self.context) + } + } + + unconstrained fn __aztec_nr_internals__get_timestamp() -> pub u64 { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _get_timestamp(self.context) + } + } + + unconstrained fn __aztec_nr_internals__get_transaction_fee() -> pub Field { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _get_transaction_fee(self.context) + } + } + + unconstrained fn __aztec_nr_internals__get_version() -> pub Field { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _get_version(self.context) + } + } + + unconstrained fn __aztec_nr_internals__l1_to_l2_msg_exists(msg_hash: Field, msg_leaf_index: Field) -> pub bool { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _l1_to_l2_msg_exists(self.context, msg_hash, msg_leaf_index) + } + } + + unconstrained fn __aztec_nr_internals__modulo2(a: u64) -> pub u64 { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + a % 2_u64 + } + } + + unconstrained fn __aztec_nr_internals__n_new_l2_to_l1_msgs(num: u32) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + for i in 0_u32..num { + self.context.message_portal(EthAddress::from_field(i as Field), i as Field) + } + } + } + + unconstrained fn __aztec_nr_internals__n_new_note_hashes(num: u32) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + for i in 0_u32..num { + self.context.push_note_hash(i as Field); + } + } + } + + unconstrained fn __aztec_nr_internals__n_new_nullifiers(num: u32) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + for i in 0_u32..num { + self.context.push_nullifier(i as Field); + } + } + } + + unconstrained fn __aztec_nr_internals__n_new_public_logs(num: u32) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + for i in 0_u32..num { + self.context.emit_public_log_unsafe(0_Field, [i as Field]); + } + } + } + + unconstrained fn __aztec_nr_internals__n_storage_writes(num: u32) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + for i in 0_u32..num { + self.storage.map.at(AztecAddress::from_field(i as Field)).write(i); + } + } + } + + unconstrained fn __aztec_nr_internals__nested_call_large_calldata(arr: [Field; 300]) -> pub Field { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 300 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[Field; 300] as Serialize>::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + self.call_self.fn_w_large_calldata(arr) + } + } + + unconstrained fn __aztec_nr_internals__nested_call_to_add(arg_a: Field, arg_b: Field) -> pub Field { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _nested_call_to_add(self.context, self.address, arg_a, arg_b) + } + } + + unconstrained fn __aztec_nr_internals__nested_call_to_add_n_times_different_addresses(addrs: [AztecAddress; 23]) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 23 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[AztecAddress; 23] as Serialize>::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + for i in 0_u32..MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS + 2_u32 { + let addr: AztecAddress = addrs[i]; + if addr != AztecAddress::empty() { + let _: Field = self.call(AvmTest::at(addr).add_args_return(1_Field, 2_Field)); + } + } + } + } + + unconstrained fn __aztec_nr_internals__nested_call_to_add_with_gas(arg_a: Field, arg_b: Field, l2_gas: u32, da_gas: u32) -> pub Field { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 4] = aztec::oracle::avm::calldata_copy(1_u32, ((::N + ::N) + ::N) + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + self.call(AvmTest::at(self.address).add_args_return(arg_a, arg_b).with_gas(GasOpts::new(l2_gas, da_gas))) + } + } + + unconstrained fn __aztec_nr_internals__nested_call_to_assert_same(arg_a: Field, arg_b: Field) -> pub Field { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + self.call_self.assert_same(arg_a, arg_b) + } + } + + unconstrained fn __aztec_nr_internals__nested_call_to_nothing() { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + let garbageAddress: AztecAddress = AztecAddress::from_field(42_Field); + self.call(AvmTest::at(garbageAddress).nested_call_to_nothing()) + } + } + + unconstrained fn __aztec_nr_internals__nested_call_to_nothing_recovers() { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + let garbageAddress: AztecAddress = AztecAddress::from_field(42_Field); + call(1_u32, 1_u32, garbageAddress, []); + let success: bool = success_copy(); + assert(!success, "Nested CALL instruction should return failure if target contract does not exist"); + } + } + + unconstrained fn __aztec_nr_internals__nested_static_call_to_add(arg_a: Field, arg_b: Field) -> pub Field { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _nested_static_call_to_add(self.context, self.address, arg_a, arg_b) + } + } + + unconstrained fn __aztec_nr_internals__nested_static_call_to_set_storage() { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + let selector: FunctionSelector = FunctionSelector { inner: 2230419055_u32}; + let args: [Field; 1] = [20_Field as Field]; + let _: [Field] = self.context.static_call_public_function(self.address, selector, args, GasOpts::default()); + } + } + + unconstrained fn __aztec_nr_internals__new_note_hash(note_hash: Field) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _new_note_hash(self.context, note_hash); + } + } + + unconstrained fn __aztec_nr_internals__new_nullifier(nullifier: Field) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _new_nullifier(self.context, nullifier); + } + } + + unconstrained fn __aztec_nr_internals__note_hash_exists(note_hash: Field, leaf_index: u64) -> pub bool { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _note_hash_exists(self.context, note_hash, leaf_index) + } + } + + unconstrained fn __aztec_nr_internals__nullifier_collision(nullifier: Field) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + self.context.push_nullifier(nullifier); + self.context.push_nullifier(nullifier); + } + } + + unconstrained fn __aztec_nr_internals__nullifier_exists(nullifier: Field) -> pub bool { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _nullifier_exists(self.context, self.address, nullifier) + } + } + + unconstrained fn __aztec_nr_internals__pedersen_commit(x: Field, y: Field) -> pub Point { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + let commitment: std::embedded_curve_ops::EmbeddedCurvePoint = std::hash::pedersen_commitment_with_separator([x, y], 20_u32); + commitment.into() + } + } + + unconstrained fn __aztec_nr_internals__raw_l2_to_l1_msg(recipient: EthAddress, content: Field) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + self.context.message_portal(recipient, content) + } + } + + unconstrained fn __aztec_nr_internals__read_assert_storage_single(a: Field) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + assert(a == self.storage.single.read(), "Storage value does not match input"); + } + } + + unconstrained fn __aztec_nr_internals__read_storage_list() -> pub [Field; 2] { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _read_storage_list(self.storage) + } + } + + unconstrained fn __aztec_nr_internals__read_storage_map(address: AztecAddress) -> pub u32 { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _read_storage_map(self.storage, address) + } + } + + unconstrained fn __aztec_nr_internals__read_storage_single() -> pub Field { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _read_storage_single(self.storage) + } + } + + unconstrained fn __aztec_nr_internals__return_oracle() -> pub [Field; 3] { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + avm_return([1_Field, 2_Field, 3_Field].as_slice()); + [4_Field, 5_Field, 6_Field] + } + } + + unconstrained fn __aztec_nr_internals__returndata_copy_oracle() { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + let _: [Field; 3] = self.call_self.return_oracle(); + let returndatasize: u32 = returndata_size(); + let returndata: [Field] = returndata_copy(0_u32, returndatasize); + assert(returndata == @[1_Field, 2_Field, 3_Field], "Returndata copy failed"); + } + } + + unconstrained fn __aztec_nr_internals__revert_oracle() -> pub [Field; 3] { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + revert([1_Field, 2_Field, 3_Field].as_slice()); + [4_Field, 5_Field, 6_Field] + } + } + + unconstrained fn __aztec_nr_internals__send_l2_to_l1_msg(recipient: EthAddress, content: Field) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _send_l2_to_l1_msg(self.context, recipient, content); + } + } + + unconstrained fn __aztec_nr_internals__set_opcode_big_field() -> pub Field { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + big_field_136_bits + } + } + + unconstrained fn __aztec_nr_internals__set_opcode_really_big_field() -> pub Field { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + big_field_254_bits + } + } + + unconstrained fn __aztec_nr_internals__set_opcode_small_field() -> pub Field { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + big_field_128_bits + } + } + + unconstrained fn __aztec_nr_internals__set_opcode_u32() -> pub u32 { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + 1_u32 << 30_u32 + } + } + + unconstrained fn __aztec_nr_internals__set_opcode_u64() -> pub u64 { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + 1_u64 << 60_u64 + } + } + + unconstrained fn __aztec_nr_internals__set_opcode_u8() -> pub u8 { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + 8_u8 + } + } + + unconstrained fn __aztec_nr_internals__set_opcode_u8_view() -> pub u8 { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + assert(self.context.is_static_call(), "Function set_opcode_u8_view can only be called statically"); + { + 8_u8 + } + } + + unconstrained fn __aztec_nr_internals__set_read_storage_single(a: Field) -> pub Field { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + self.storage.single.write(a); + self.storage.single.read() + } + } + + unconstrained fn __aztec_nr_internals__set_storage_list(a: Field, b: Field) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _set_storage_list(self.storage, a, b); + } + } + + unconstrained fn __aztec_nr_internals__set_storage_map(to: AztecAddress, amount: u32) -> pub Field { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _set_storage_map(self.storage, to, amount) + } + } + + unconstrained fn __aztec_nr_internals__set_storage_single(a: Field) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _set_storage_single(self.storage, a); + } + } + + unconstrained fn __aztec_nr_internals__test_get_contract_instance(address: AztecAddress) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + let deployer: Option = get_contract_instance_deployer_avm(address); + let class_id: Option = get_contract_instance_class_id_avm(address); + let initialization_hash: Option = get_contract_instance_initialization_hash_avm(address); + assert(deployer.is_some(), "Contract instance not found when getting DEPLOYER!"); + assert(class_id.is_some(), "Contract instance not found when getting CLASS_ID!"); + assert(initialization_hash.is_some(), "Contract instance not found when getting INIT_HASH!"); + assert(deployer.unwrap().eq(AztecAddress::from_field(1110_Field))); + assert(class_id.unwrap().eq(ContractClassId::from_field(1929_Field))); + assert(initialization_hash.unwrap() == 1052946_Field); + } + } + + unconstrained fn __aztec_nr_internals__test_get_contract_instance_matches(address: AztecAddress, expected_deployer: AztecAddress, expected_class_id: ContractClassId, expected_initialization_hash: Field) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 4] = aztec::oracle::avm::calldata_copy(1_u32, ((::N + ::N) + ::N) + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _test_get_contract_instance_matches(address, expected_deployer, expected_class_id, expected_initialization_hash); + } + } + + unconstrained fn __aztec_nr_internals__to_le_bits(input: Field) -> pub [bool; 16] { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _to_le_bits(input) + } + } + + unconstrained fn __aztec_nr_internals__to_le_bytes(input: Field) -> pub [u8; 10] { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + _to_le_bytes(input) + } + } + + unconstrained fn __aztec_nr_internals__u128_addition_overflow() -> pub u128 { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + let max_u128: u128 = 340282366920938463463374607431768211455_u128; + let one: u128 = 1_u128; + max_u128 + one + } + } + + unconstrained fn __aztec_nr_internals__variable_base_msm(scalar_lo: Field, scalar_hi: Field, scalar2_lo: Field, scalar2_hi: Field) -> pub Point { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; 4] = aztec::oracle::avm::calldata_copy(1_u32, ((::N + ::N) + ::N) + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + let g: Point = Point { x: GRUMPKIN_ONE_X, y: GRUMPKIN_ONE_Y, is_infinite: false}; + let triple_g: std::embedded_curve_ops::EmbeddedCurvePoint = multi_scalar_mul([g.to_embedded(), g.to_embedded()], [Scalar { lo: scalar_lo, hi: scalar_hi}, Scalar { lo: scalar2_lo, hi: scalar2_hi}]); + triple_g.into() + } + } + + pub struct StorageLayoutFields { + pub single: aztec::state_vars::Storable, + pub list: aztec::state_vars::Storable, + pub map: aztec::state_vars::Storable, + } + + pub struct StorageLayout { + pub contract_name: str, + pub fields: StorageLayoutFields, + } +} + +mod note { + use std::meta::derive; + use aztec::protocol::traits::Deserialize; + use aztec::protocol::traits::Packable; + use aztec::protocol::traits::Serialize; + + pub struct Note { + pub a: Field, + pub b: Field, + } + + impl Packable for Note { + let N: u32 = 2; + + #[inline_always] + fn pack(self) -> [Field; 2] { + let mut result: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let packed_member: [Field; 1] = self.a.pack(); + let packed_member_len: u32 = ::N; + for i in 0_u32..packed_member_len { + { + let i_0: u32 = i + offset; + result[i_0] = packed_member[i]; + } + }; + offset = offset + packed_member_len; + let packed_member: [Field; 1] = self.b.pack(); + let packed_member_len: u32 = ::N; + for i in 0_u32..packed_member_len { + { + let i_1: u32 = i + offset; + result[i_1] = packed_member[i]; + } + }; + offset = offset + packed_member_len; + result + } + + #[inline_always] + fn unpack(packed: [Field; 2]) -> Self { + let mut offset: u32 = 0_u32; + let mut member_fields: [Field; 1] = [0_Field; 1]; + for i in 0_u32..::N { + member_fields[i] = packed[i + offset]; + }; + let a: Field = ::unpack(member_fields); + offset = offset + ::N; + let mut member_fields: [Field; 1] = [0_Field; 1]; + for i in 0_u32..::N { + member_fields[i] = packed[i + offset]; + }; + let b: Field = ::unpack(member_fields); + offset = offset + ::N; + Self { a: a, b: b} + } + } + + impl Serialize for Note { + let N: u32 = 2; + + fn serialize(self) -> [Field; 2] { + let mut writer: aztec::protocol::utils::writer::Writer<2> = aztec::protocol::utils::writer::Writer::<2>::new(); + self.stream_serialize(&mut writer); + writer.finish() + } + + #[inline_always] + fn stream_serialize(self, writer: &mut aztec::protocol::utils::writer::Writer) { + self.a.stream_serialize(writer); + self.b.stream_serialize(writer); + } + } + + impl Deserialize for Note { + let N: u32 = 2; + + fn deserialize(fields: [Field; 2]) -> Self { + let mut reader: aztec::protocol::utils::reader::Reader<2> = aztec::protocol::utils::reader::Reader::<2>::new(fields); + let result: Self = Self::stream_deserialize(&mut reader); + reader.finish(); + result + } + + #[inline_always] + fn stream_deserialize(reader: &mut aztec::protocol::utils::reader::Reader) -> Self { + let a: Field = ::stream_deserialize(reader); + let b: Field = ::stream_deserialize(reader); + Self { a: a, b: b} + } + } +} + +// Warning: the generated code has syntax errors diff --git a/noir-projects/contract-snapshots/tests/snapshots/expand/storage_proof_test_contract/snapshots__expanded.snap b/noir-projects/contract-snapshots/tests/snapshots/expand/storage_proof_test_contract/snapshots__expanded.snap new file mode 100644 index 000000000000..0bb78f0095c8 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/expand/storage_proof_test_contract/snapshots__expanded.snap @@ -0,0 +1,2146 @@ +--- +source: tests/snapshots.rs +expression: stdout +--- +use aztec::macros::aztec; +use aztec::macros::aztec; + +contract StorageProofTest { + use crate::storage_proofs::account_hash::compute_account_hash; + use crate::storage_proofs::keccak::keccak256; + use crate::storage_proofs::keccak::KeccakHasher; + use crate::storage_proofs::path_verification::verify_path_section; + use crate::storage_proofs::slot_hash::compute_slot_hash; + use crate::storage_proofs::types::Account; + use crate::storage_proofs::types::Node; + use crate::storage_proofs::types::StorageSlot; + use crate::storage_proofs::utils::to_nibbles; + use aztec::context::calls::PrivateCall; + use aztec::macros::functions::external; + use aztec::macros::functions::internal; + use aztec::macros::functions::only_self; + use aztec::macros::functions::view; + use aztec::oracle::capsules; + use aztec::protocol::address::AztecAddress; + use aztec::protocol::address::EthAddress; + use aztec::protocol::hash::poseidon2_hash; + use aztec::protocol::traits::Deserialize; + use aztec::protocol::traits::Serialize; + use aztec::protocol::traits::ToField; + + global MAX_ACCOUNT_PROOF_LENGTH: u32 = 15; + + global NUM_NODES_VERIFIED_PER_CALL: u32 = 3; + + global ACCOUNT_CAPSULE_KEY_SEPARATOR: u32 = 100; + + global ACCOUNT_PROOF_CAPSULE_KEY_SEPARATOR: u32 = 101; + + global STORAGE_PROOF_CAPSULE_KEY_SEPARATOR: u32 = 102; + + global STORAGE_PROOF_NODE_CAPSULE_KEY_SEPARATOR: u32 = 103; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call account_proof. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn account_proof(account: Account, root: [u64; 4], nodes: [Node; 15], node_length: u32); + + #[deprecated(deny, "Direct invocation of private functions is not supported. You attempted to call storage_proof. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn storage_proof(address: EthAddress, slot_key: [u8; 32], slot_contents: StorageSlot, eth_storage_root: [u64; 4]); + + #[deprecated(deny, "Direct invocation of private functions is not supported. You attempted to call verify_storage_proof_path_recursively. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn verify_storage_proof_path_recursively(num_processed_nodes: u32, num_total_nodes: u32, start_nibble_index: u32, parent_hash: [u64; 4], storage_trie_key_nibbles: [u8; 64], storage_proof_capsule_key: Field) -> ([u64; 4], u32); + + #[no_predicates] + #[contract_library_method] + fn call_verify_storage_proof_path_recursively(this_address: AztecAddress, num_processed_nodes: u32, num_total_nodes: u32, start_nibble_index: u32, parent_hash: [u64; 4], storage_trie_key_nibbles: [u8; 64], storage_proof_capsule_key: Field) -> PrivateCall<37, 72, ([u64; 4], u32)> { + StorageProofTest::at(this_address).verify_storage_proof_path_recursively(num_processed_nodes, num_total_nodes, start_nibble_index, parent_hash, storage_trie_key_nibbles, storage_proof_capsule_key) + } + + #[contract_library_method] + fn compute_address_capsule_key(eth_storage_root: [u64; 4], address: EthAddress) -> Field { + poseidon2_hash((ACCOUNT_CAPSULE_KEY_SEPARATOR, eth_storage_root, address).serialize()) + } + + #[contract_library_method] + fn compute_account_proof_capsule_key(address_capsule_key: Field) -> Field { + poseidon2_hash((ACCOUNT_PROOF_CAPSULE_KEY_SEPARATOR, address_capsule_key).serialize()) + } + + #[contract_library_method] + fn compute_storage_proof_capsule_key(address_capsule_key: Field, slot_key: [u8; 32]) -> Field { + poseidon2_hash((STORAGE_PROOF_CAPSULE_KEY_SEPARATOR, address_capsule_key, slot_key).serialize()) + } + + #[contract_library_method] + fn compute_node_capsule_key(storage_proof_capsule_key: Field, index: u32) -> Field { + poseidon2_hash((STORAGE_PROOF_NODE_CAPSULE_KEY_SEPARATOR, storage_proof_capsule_key, index).serialize()) + } + + /// Unpacks an array into a note corresponding to `note_type_id` and then computes its note hash (non-siloed) and inner nullifier (non-siloed) assuming the note has been inserted into the note hash tree with `note_nonce`. + /// + /// This function is automatically injected by the `#[aztec]` macro. + #[contract_library_method] + #[allow(dead_code)] + unconstrained fn _compute_note_hash_and_nullifier(packed_note: BoundedVec, owner: AztecAddress, storage_slot: Field, note_type_id: Field, contract_address: AztecAddress, randomness: Field, note_nonce: Field) -> Option { + _compute_note_hash(packed_note, owner, storage_slot, note_type_id, contract_address, randomness).map(|note_hash: Field| -> aztec::messages::discovery::NoteHashAndNullifier { + let siloed_note_hash: Field = aztec::protocol::hash::compute_siloed_note_hash(contract_address, note_hash); + let unique_note_hash: Field = aztec::protocol::hash::compute_unique_note_hash(note_nonce, siloed_note_hash); + let inner_nullifier: Option = _compute_note_nullifier(unique_note_hash, packed_note, owner, storage_slot, note_type_id, contract_address, randomness); + aztec::messages::discovery::NoteHashAndNullifier { note_hash: note_hash, inner_nullifier: inner_nullifier} + }) + } + + /// This contract does not use private notes, so this function should never be called as it will unconditionally fail. + /// + /// This function is automatically injected by the `#[aztec]` macro. + #[contract_library_method] + unconstrained fn _compute_note_hash(_packed_note: BoundedVec, _owner: AztecAddress, _storage_slot: Field, _note_type_id: Field, _contract_address: AztecAddress, _randomness: Field) -> Option { + panic(f"This contract does not use private notes") + } + + /// This contract does not use private notes, so this function should never be called as it will unconditionally fail. + /// + /// This function is automatically injected by the `#[aztec]` macro. + #[contract_library_method] + unconstrained fn _compute_note_nullifier(_unique_note_hash: Field, _packed_note: BoundedVec, _owner: AztecAddress, _storage_slot: Field, _note_type_id: Field, _contract_address: AztecAddress, _randomness: Field) -> Option { + panic(f"This contract does not use private notes") + } + + /// Receives offchain messages into this contract's offchain inbox for subsequent processing. + /// + /// Each message is routed to the inbox scoped to its `recipient` field. + /// + /// For more details, see `aztec::messages::processing::offchain::receive`. + /// + /// This function is automatically injected by the `#[aztec]` macro. + unconstrained fn offchain_receive(messages: BoundedVec) { + let address: AztecAddress = aztec::context::UtilityContext::new().this_address(); + aztec::messages::processing::offchain::receive(address, messages); + } + + pub struct StorageProofTest { + pub target_contract: AztecAddress, + } + + impl StorageProofTest { + pub fn at(addr: AztecAddress) -> Self { + Self { target_contract: addr} + } + + pub fn interface() -> Self { + Self { target_contract: AztecAddress::zero()} + } + + pub fn verify_storage_proof_path_recursively(self, num_processed_nodes: u32, num_total_nodes: u32, start_nibble_index: u32, parent_hash: [u64; 4], storage_trie_key_nibbles: [u8; 64], storage_proof_capsule_key: Field) -> PrivateCall<37, 72, ([u64; 4], u32)> { + let mut serialized_params: [Field; 72] = [0_Field; 72]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = num_processed_nodes.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = num_total_nodes.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = start_nibble_index.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 4 * 1] = parent_hash.serialize(); + let serialized_member_len: u32 = <[u64; 4] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 64 * 1] = storage_trie_key_nibbles.serialize(); + let serialized_member_len: u32 = <[u8; 64] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_4: u32 = i + offset; + serialized_params[i_4] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = storage_proof_capsule_key.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_5: u32 = i + offset; + serialized_params[i_5] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2237949917_Field); + PrivateCall::<37, 72, ([u64; 4], u32)>::new(self.target_contract, selector, "verify_storage_proof_path_recursively", serialized_params) + } + + pub fn storage_proof(self, address: EthAddress, slot_key: [u8; 32], slot_contents: StorageSlot, eth_storage_root: [u64; 4]) -> PrivateCall<13, 70, ()> { + let mut serialized_params: [Field; 70] = [0_Field; 70]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = address.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 32 * 1] = slot_key.serialize(); + let serialized_member_len: u32 = <[u8; 32] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 33] = slot_contents.serialize(); + let serialized_member_len: u32 = >::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 4 * 1] = eth_storage_root.serialize(); + let serialized_member_len: u32 = <[u64; 4] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2067008734_Field); + PrivateCall::<13, 70, ()>::new(self.target_contract, selector, "storage_proof", serialized_params) + } + + pub fn account_proof(self, account: Account, root: [u64; 4], nodes: [Node; 15], node_length: u32) -> aztec::context::calls::PublicStaticCall<13, 1290, ()> { + let mut serialized_params: [Field; 1290] = [0_Field; 1290]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 70] = account.serialize(); + let serialized_member_len: u32 = >::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 4 * 1] = root.serialize(); + let serialized_member_len: u32 = <[u64; 4] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 15 * 81] = nodes.serialize(); + let serialized_member_len: u32 = <[Node; 15] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = node_length.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(693284113_Field); + aztec::context::calls::PublicStaticCall::<13, 1290, ()>::new(self.target_contract, selector, "account_proof", serialized_params) + } + + pub fn offchain_receive(self, messages: BoundedVec) -> aztec::context::calls::UtilityCall<16, 321, ()> { + let serialized_params: [Field; 321] = messages.serialize(); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1396850735_Field); + aztec::context::calls::UtilityCall::<16, 321, ()>::new(self.target_contract, selector, "offchain_receive", serialized_params) + } + } + + #[contract_library_method] + pub fn at(addr: AztecAddress) -> StorageProofTest { + StorageProofTest { target_contract: addr} + } + + #[contract_library_method] + pub fn interface() -> StorageProofTest { + StorageProofTest { target_contract: AztecAddress::zero()} + } + + pub struct sync_state_parameters { + pub scope: AztecAddress, + } + + #[abi(functions)] + pub struct sync_state_abi { + parameters: sync_state_parameters, + } + + unconstrained fn sync_state(scope: AztecAddress) { + let address: AztecAddress = aztec::context::UtilityContext::new().this_address(); + aztec::messages::discovery::do_sync_state(address, _compute_note_hash, _compute_note_nullifier, Option::>::none(), Option:: aztec::ephemeral::EphemeralArray>::some(aztec::messages::processing::offchain::sync_inbox), scope); + } + + pub struct offchain_receive_parameters { + pub messages: BoundedVec, + } + + #[abi(functions)] + pub struct offchain_receive_abi { + parameters: offchain_receive_parameters, + } + + pub struct CallSelf { + pub address: AztecAddress, + pub context: Context, + } + + impl CallSelf<&mut aztec::context::PrivateContext> { + pub fn storage_proof(self, address: EthAddress, slot_key: [u8; 32], slot_contents: StorageSlot, eth_storage_root: [u64; 4]) { + let mut serialized_params: [Field; 70] = [0_Field; 70]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = address.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 32 * 1] = slot_key.serialize(); + let serialized_member_len: u32 = <[u8; 32] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 33] = slot_contents.serialize(); + let serialized_member_len: u32 = >::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 4 * 1] = eth_storage_root.serialize(); + let serialized_member_len: u32 = <[u64; 4] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2067008734_Field); + let args_hash: Field = aztec::hash::hash_args(serialized_params); + aztec::oracle::execution_cache::store(serialized_params, args_hash); + let returns_hash: aztec::context::ReturnsHash = self.context.call_private_function_with_args_hash(self.address, selector, args_hash, false); + returns_hash.get_preimage() + } + + pub fn verify_storage_proof_path_recursively(self, num_processed_nodes: u32, num_total_nodes: u32, start_nibble_index: u32, parent_hash: [u64; 4], storage_trie_key_nibbles: [u8; 64], storage_proof_capsule_key: Field) -> ([u64; 4], u32) { + let mut serialized_params: [Field; 72] = [0_Field; 72]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = num_processed_nodes.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = num_total_nodes.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = start_nibble_index.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 4 * 1] = parent_hash.serialize(); + let serialized_member_len: u32 = <[u64; 4] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 64 * 1] = storage_trie_key_nibbles.serialize(); + let serialized_member_len: u32 = <[u8; 64] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_4: u32 = i + offset; + serialized_params[i_4] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = storage_proof_capsule_key.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_5: u32 = i + offset; + serialized_params[i_5] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2237949917_Field); + let args_hash: Field = aztec::hash::hash_args(serialized_params); + aztec::oracle::execution_cache::store(serialized_params, args_hash); + let returns_hash: aztec::context::ReturnsHash = self.context.call_private_function_with_args_hash(self.address, selector, args_hash, false); + returns_hash.get_preimage() + } + } + + pub struct CallSelfStatic { + pub address: AztecAddress, + pub context: Context, + } + + impl CallSelfStatic { + pub fn account_proof(self, account: Account, root: [u64; 4], nodes: [Node; 15], node_length: u32) { + let mut serialized_params: [Field; 1290] = [0_Field; 1290]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 70] = account.serialize(); + let serialized_member_len: u32 = >::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 4 * 1] = root.serialize(); + let serialized_member_len: u32 = <[u64; 4] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 15 * 81] = nodes.serialize(); + let serialized_member_len: u32 = <[Node; 15] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = node_length.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(693284113_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicStaticCall::<13, 1290, ()>::new(self.address, selector, "account_proof", serialized_params).view(self.context) + } + } + } + + pub struct EnqueueSelf { + pub address: AztecAddress, + pub context: Context, + } + + pub struct EnqueueSelfStatic { + pub address: AztecAddress, + pub context: Context, + } + + impl EnqueueSelfStatic<&mut aztec::context::PrivateContext> { + pub fn account_proof(self, account: Account, root: [u64; 4], nodes: [Node; 15], node_length: u32) { + let mut serialized_params: [Field; 1290] = [0_Field; 1290]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 70] = account.serialize(); + let serialized_member_len: u32 = >::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 4 * 1] = root.serialize(); + let serialized_member_len: u32 = <[u64; 4] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 15 * 81] = nodes.serialize(); + let serialized_member_len: u32 = <[Node; 15] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = node_length.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(693284113_Field); + let calldata: [Field; 1 + 1290] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, true, false); + } + } + + pub struct CallSelfUtility { + pub address: AztecAddress, + } + + pub struct CallInternal { + pub context: Context, + } + + pub unconstrained fn public_dispatch(selector: Field) { + if selector == 693284113_Field { + let input_calldata: [Field; 1290] = aztec::oracle::avm::calldata_copy(1_u32, ((>::N + <[u64; 4] as Serialize>::N) + <[Node; 15] as Serialize>::N) + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<1290> = aztec::protocol::utils::reader::Reader::<1290>::new(input_calldata); + let arg0: Account = >::stream_deserialize(&mut reader); + let arg1: [u64; 4] = <[u64; 4] as Deserialize>::stream_deserialize(&mut reader); + let arg2: [Node; 15] = <[Node; 15] as Deserialize>::stream_deserialize(&mut reader); + let arg3: u32 = ::stream_deserialize(&mut reader); + __aztec_nr_internals__account_proof(arg0, arg1, arg2, arg3); + aztec::oracle::avm::avm_return([].as_slice()); + }; + panic(f"Unknown selector {selector}") + } + + pub struct account_proof_parameters { + pub account: Account, + pub root: [u64; 4], + pub nodes: [Node; 15], + pub node_length: u32, + } + + pub struct storage_proof_parameters { + pub address: EthAddress, + pub slot_key: [u8; 32], + pub slot_contents: StorageSlot, + pub eth_storage_root: [u64; 4], + } + + pub struct verify_storage_proof_path_recursively_parameters { + pub num_processed_nodes: u32, + pub num_total_nodes: u32, + pub start_nibble_index: u32, + pub parent_hash: [u64; 4], + pub storage_trie_key_nibbles: [u8; 64], + pub storage_proof_capsule_key: Field, + } + + #[abi(functions)] + pub struct account_proof_abi { + parameters: account_proof_parameters, + } + + #[abi(functions)] + pub struct storage_proof_abi { + parameters: storage_proof_parameters, + } + + #[abi(functions)] + pub struct verify_storage_proof_path_recursively_abi { + parameters: verify_storage_proof_path_recursively_parameters, + return_type: ([u64; 4], u32), + } + + fn __aztec_nr_internals__storage_proof(inputs: aztec::context::inputs::PrivateContextInputs, address: EthAddress, slot_key: [u8; 32], slot_contents: StorageSlot, eth_storage_root: [u64; 4]) -> return_data aztec::protocol::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs { + aztec::oracle::version::assert_compatible_oracle_version(); + let mut self: aztec::contract_self::contract_self_private::ContractSelfPrivate<(), CallSelf<&mut aztec::context::PrivateContext>, EnqueueSelf<&mut aztec::context::PrivateContext>, CallSelfStatic<&mut aztec::context::PrivateContext>, EnqueueSelfStatic<&mut aztec::context::PrivateContext>, CallInternal<&mut aztec::context::PrivateContext>, CallSelfUtility> = { + let mut serialized_params: [Field; 70] = [0_Field; 70]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = address.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 32 * 1] = slot_key.serialize(); + let serialized_member_len: u32 = <[u8; 32] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 33] = slot_contents.serialize(); + let serialized_member_len: u32 = >::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 4 * 1] = eth_storage_root.serialize(); + let serialized_member_len: u32 = <[u64; 4] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let args_hash: Field = aztec::hash::hash_args(serialized_params); + let mut context: aztec::context::PrivateContext = aztec::context::PrivateContext::new(inputs, args_hash); + let storage: () = (); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf<&mut aztec::context::PrivateContext> = CallSelf::<&mut aztec::context::PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self: EnqueueSelf<&mut aztec::context::PrivateContext> = EnqueueSelf::<&mut aztec::context::PrivateContext> { address: self_address, context: &mut context}; + let call_self_static: CallSelfStatic<&mut aztec::context::PrivateContext> = CallSelfStatic::<&mut aztec::context::PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self_static: EnqueueSelfStatic<&mut aztec::context::PrivateContext> = EnqueueSelfStatic::<&mut aztec::context::PrivateContext> { address: self_address, context: &mut context}; + let internal: CallInternal<&mut aztec::context::PrivateContext> = CallInternal::<&mut aztec::context::PrivateContext> { context: &mut context}; + let call_self_utility: CallSelfUtility = CallSelfUtility { address: self_address}; + let utility: aztec::contract_self::contract_self_private::PrivateUtilityCalls = aztec::contract_self::contract_self_private::PrivateUtilityCalls:: { call_self: call_self_utility}; + aztec::contract_self::contract_self_private::ContractSelfPrivate::<(), CallSelf<&mut aztec::context::PrivateContext>, EnqueueSelf<&mut aztec::context::PrivateContext>, CallSelfStatic<&mut aztec::context::PrivateContext>, EnqueueSelfStatic<&mut aztec::context::PrivateContext>, CallInternal<&mut aztec::context::PrivateContext>, CallSelfUtility>::new(&mut context, storage, call_self, enqueue_self, call_self_static, enqueue_self_static, internal, utility) + }; + let within_revertible_phase: bool = self.context.in_revertible_phase(); + let address_capsule_key: Field = compute_address_capsule_key(eth_storage_root, address); + // Safety: comment added by `nargo expand` + let hinted_account: Account = unsafe { + Account::deserialize(capsules::load(self.address, address_capsule_key, AztecAddress::zero()).unwrap()) + }; + assert(hinted_account.address == address.to_field().to_be_bytes::<20>()); + let account_proof_capsule_key: Field = compute_account_proof_capsule_key(address_capsule_key); + // Safety: comment added by `nargo expand` + let (hinted_account_proof_length, hinted_nodes): (u32, [Node; 15]) = unsafe { + <(u32, [Node; 15]) as Deserialize>::deserialize(capsules::load(self.address, account_proof_capsule_key, AztecAddress::zero()).unwrap()) + }; + self.enqueue_self_static.account_proof(hinted_account, eth_storage_root, hinted_nodes, hinted_account_proof_length); + let storage_proof_capsule_key: Field = compute_storage_proof_capsule_key(address_capsule_key, slot_key); + // Safety: comment added by `nargo expand` + let hinted_storage_proof_length: u32 = unsafe { + u32::deserialize(capsules::load(self.address, storage_proof_capsule_key, AztecAddress::zero()).unwrap()) + }; + assert(hinted_storage_proof_length > 0_u32, "Storage proof length must be greater than 0"); + let storage_trie_key: [u8; 32] = keccak256(slot_key, 32_u32); + let (slot_leaf_hash, slot_nibble_index): ([u64; 4], u32) = call_verify_storage_proof_path_recursively(self.address, 0_u32, hinted_storage_proof_length, 0_u32, hinted_account.storage_hash, to_nibbles(storage_trie_key), storage_proof_capsule_key).call(self.context); + assert(slot_leaf_hash == compute_slot_hash(slot_contents, slot_nibble_index, storage_trie_key)); + assert(within_revertible_phase == self.context.in_revertible_phase(), f"Phase change detected on function with phase check. If this is expected, use #[allow_phase_change]"); + self.context.finish() + } + + fn __aztec_nr_internals__verify_storage_proof_path_recursively(inputs: aztec::context::inputs::PrivateContextInputs, num_processed_nodes: u32, num_total_nodes: u32, start_nibble_index: u32, parent_hash: [u64; 4], storage_trie_key_nibbles: [u8; 64], storage_proof_capsule_key: Field) -> return_data aztec::protocol::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs { + aztec::oracle::version::assert_compatible_oracle_version(); + let mut self: aztec::contract_self::contract_self_private::ContractSelfPrivate<(), CallSelf<&mut aztec::context::PrivateContext>, EnqueueSelf<&mut aztec::context::PrivateContext>, CallSelfStatic<&mut aztec::context::PrivateContext>, EnqueueSelfStatic<&mut aztec::context::PrivateContext>, CallInternal<&mut aztec::context::PrivateContext>, CallSelfUtility> = { + let mut serialized_params: [Field; 72] = [0_Field; 72]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = num_processed_nodes.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = num_total_nodes.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = start_nibble_index.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 4 * 1] = parent_hash.serialize(); + let serialized_member_len: u32 = <[u64; 4] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 64 * 1] = storage_trie_key_nibbles.serialize(); + let serialized_member_len: u32 = <[u8; 64] as Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_4: u32 = i + offset; + serialized_params[i_4] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = storage_proof_capsule_key.serialize(); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_5: u32 = i + offset; + serialized_params[i_5] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let args_hash: Field = aztec::hash::hash_args(serialized_params); + let mut context: aztec::context::PrivateContext = aztec::context::PrivateContext::new(inputs, args_hash); + let storage: () = (); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf<&mut aztec::context::PrivateContext> = CallSelf::<&mut aztec::context::PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self: EnqueueSelf<&mut aztec::context::PrivateContext> = EnqueueSelf::<&mut aztec::context::PrivateContext> { address: self_address, context: &mut context}; + let call_self_static: CallSelfStatic<&mut aztec::context::PrivateContext> = CallSelfStatic::<&mut aztec::context::PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self_static: EnqueueSelfStatic<&mut aztec::context::PrivateContext> = EnqueueSelfStatic::<&mut aztec::context::PrivateContext> { address: self_address, context: &mut context}; + let internal: CallInternal<&mut aztec::context::PrivateContext> = CallInternal::<&mut aztec::context::PrivateContext> { context: &mut context}; + let call_self_utility: CallSelfUtility = CallSelfUtility { address: self_address}; + let utility: aztec::contract_self::contract_self_private::PrivateUtilityCalls = aztec::contract_self::contract_self_private::PrivateUtilityCalls:: { call_self: call_self_utility}; + aztec::contract_self::contract_self_private::ContractSelfPrivate::<(), CallSelf<&mut aztec::context::PrivateContext>, EnqueueSelf<&mut aztec::context::PrivateContext>, CallSelfStatic<&mut aztec::context::PrivateContext>, EnqueueSelfStatic<&mut aztec::context::PrivateContext>, CallInternal<&mut aztec::context::PrivateContext>, CallSelfUtility>::new(&mut context, storage, call_self, enqueue_self, call_self_static, enqueue_self_static, internal, utility) + }; + let within_revertible_phase: bool = self.context.in_revertible_phase(); + assert(self.msg_sender() == self.address, "Function verify_storage_proof_path_recursively can only be called by the same contract"); + let mut hinted_nodes: [Node; 3] = std::mem::zeroed(); + let num_nodes_remaining: u32 = num_total_nodes - num_processed_nodes; + let num_nodes_to_process: u32 = if num_nodes_remaining > NUM_NODES_VERIFIED_PER_CALL { + NUM_NODES_VERIFIED_PER_CALL + } else { + num_nodes_remaining + }; + for i in 0_u32..NUM_NODES_VERIFIED_PER_CALL { + let node_capsule_key: Field = compute_node_capsule_key(storage_proof_capsule_key, num_processed_nodes + i); + if i < num_nodes_to_process { + // Safety: comment added by `nargo expand` + hinted_nodes[i] = unsafe { + Node::deserialize(capsules::load(self.address, node_capsule_key, AztecAddress::zero()).unwrap()) + }; + } + }; + let (child_hash, end_nibble_index): ([u64; 4], u32) = verify_path_section(hinted_nodes, num_nodes_to_process, start_nibble_index, parent_hash, storage_trie_key_nibbles); + let new_num_processed_nodes: u32 = num_processed_nodes + num_nodes_to_process; + let macro__returned__values: ([u64; 4], u32) = if new_num_processed_nodes == num_total_nodes { + (child_hash, end_nibble_index) + } else { + call_verify_storage_proof_path_recursively(self.address, new_num_processed_nodes, num_total_nodes, end_nibble_index, child_hash, storage_trie_key_nibbles, storage_proof_capsule_key).call(self.context) + }; + let serialized_params: [Field; (4 * 1) + 1] = macro__returned__values.serialize(); + self.context.set_return_hash(serialized_params); + assert(within_revertible_phase == self.context.in_revertible_phase(), f"Phase change detected on function with phase check. If this is expected, use #[allow_phase_change]"); + self.context.finish() + } + + unconstrained fn __aztec_nr_internals__account_proof(account: Account, root: [u64; 4], nodes: [Node; 15], node_length: u32) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 1290] = aztec::oracle::avm::calldata_copy(1_u32, ((>::N + <[u64; 4] as Serialize>::N) + <[Node; 15] as Serialize>::N) + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: () = (); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + assert(self.context.is_static_call(), "Function account_proof can only be called statically"); + { + let trie_key: [u8; 32] = KeccakHasher::hash_bytes(account.address, 20_u32); + let (leaf_hash, new_index): ([u64; 4], u32) = verify_path_section(nodes, node_length, 0_u32, root, to_nibbles(trie_key)); + assert(leaf_hash == compute_account_hash(account, new_index, trie_key)); + } + } +} + +mod storage_proofs { + pub mod account_hash { + use super::bytes_sink::BytesChecker; + use super::bytes_sink::BytesSink; + use super::bytes_sink::BytesWriter; + use super::keccak::keccak256_limbs; + use super::keccak::KeccakHasher; + use super::types::Account; + use super::utils::get_low_nibble; + use super::utils::get_rlp_length; + use super::utils::runtime_loop; + use super::utils::unroll_loop; + + global ACCOUNT_RLP_MAX_LENGTH: u32 = 147; + + #[inline_always] + fn rlp_encode_to_sink(account: Account, start_nibble_idx: u32, trie_key: [u8; 32], sink: &mut S) where S: BytesSink { + let mut current_nibble_idx: u32 = start_nibble_idx; + let first_key_byte: u8 = if (current_nibble_idx % 2_u32) == 0_u32 { + 32_u8 + } else { + let first_byte: u8 = trie_key[(current_nibble_idx / 2_u32) as u32]; + current_nibble_idx = current_nibble_idx + 1_u32; + 48_u8 + get_low_nibble(first_byte) + }; + let key_length: u8 = (32_u8 - ((current_nibble_idx as u8) / 2_u8)) + 1_u8; + let leaf_key_rlp_length: u8 = get_rlp_length(first_key_byte, key_length); + assert(account.nonce_length <= 8_u8); + let leaf_value_rlp_data_length: u8 = ((get_rlp_length(account.balance[0_u32], account.balance_length) + get_rlp_length(account.nonce[0_u32], account.nonce_length)) + 33_u8) + 33_u8; + let leaf_rlp_total_length: u8 = ((leaf_key_rlp_length + leaf_value_rlp_data_length) + 2_u8) + 2_u8; + sink.add_byte(248_u8); + sink.add_byte(leaf_rlp_total_length); + if (key_length == 1_u8) & (first_key_byte <= 127_u8) { + sink.add_byte(first_key_byte); + } else { + sink.add_byte(128_u8 + key_length); + sink.add_byte(first_key_byte); + let start_byte_idx: u32 = current_nibble_idx / 2_u32; + let end_byte_idx: u32 = start_byte_idx + ((key_length - 1_u8) as u32); + { + assert(start_byte_idx <= end_byte_idx); + assert(end_byte_idx <= trie_key.len()); + if std::runtime::is_unconstrained() { + for i in start_byte_idx..end_byte_idx { + sink.add_byte(trie_key[i]); + () + } + } else { + for i in 0_u32..trie_key.len() { + if (i >= start_byte_idx) & (i < end_byte_idx) { + sink.add_byte(trie_key[i]); + () + } + } + } + }; + }; + sink.add_byte(184_u8); + sink.add_byte(leaf_value_rlp_data_length + 2_u8); + sink.add_byte(248_u8); + sink.add_byte(leaf_value_rlp_data_length); + if account.nonce_length == 0_u8 { + sink.add_byte(128_u8); + } else if (account.nonce_length == 1_u8) & (account.nonce[0_u32] <= 127_u8) { + sink.add_byte(account.nonce[0_u32]); + } else { + sink.add_byte(128_u8 + account.nonce_length); + { + assert(0_u32 <= (account.nonce_length as u32)); + assert((account.nonce_length as u32) <= 32_u32); + if std::runtime::is_unconstrained() { + for i in 0_u32..account.nonce_length as u32 { + sink.add_byte(account.nonce[i]); + () + } + } else { + for i in 0_u32..32_u32 { + if (i >= 0_u32) & (i < (account.nonce_length as u32)) { + sink.add_byte(account.nonce[i]); + () + } + } + } + }; + }; + if account.balance_length == 0_u8 { + sink.add_byte(128_u8); + } else if (account.balance_length == 1_u8) & (account.balance[0_u32] <= 127_u8) { + sink.add_byte(account.balance[0_u32]); + } else { + sink.add_byte(128_u8 + account.balance_length); + { + assert(0_u32 <= (account.balance_length as u32)); + assert((account.balance_length as u32) <= 32_u32); + if std::runtime::is_unconstrained() { + for i in 0_u32..account.balance_length as u32 { + sink.add_byte(account.balance[i]); + () + } + } else { + for i in 0_u32..32_u32 { + if (i >= 0_u32) & (i < (account.balance_length as u32)) { + sink.add_byte(account.balance[i]); + () + } + } + } + }; + }; + sink.add_byte(160_u8); + { + sink.add_u64(account.storage_hash[0_u32]); + sink.add_u64(account.storage_hash[1_u32]); + sink.add_u64(account.storage_hash[2_u32]); + sink.add_u64(account.storage_hash[3_u32]); + }; + sink.add_byte(160_u8); + { + sink.add_u64(account.code_hash[0_u32]); + sink.add_u64(account.code_hash[1_u32]); + sink.add_u64(account.code_hash[2_u32]); + sink.add_u64(account.code_hash[3_u32]); + }; + } + + unconstrained fn rlp_encode_unconstrained(account: Account, start_nibble_idx: u32, trie_key: [u8; 32]) -> ([u8; 147], u32) { + let mut writer: BytesWriter<147> = BytesWriter::<147>::new(); + rlp_encode_to_sink(account, start_nibble_idx, trie_key, &mut writer); + writer.finish() + } + + pub fn compute_account_hash(account: Account, start_nibble_idx: u32, trie_key: [u8; 32]) -> [u64; 4] { + if std::runtime::is_unconstrained() { + let mut hasher: KeccakHasher = KeccakHasher::new(); + rlp_encode_to_sink(account, start_nibble_idx, trie_key, &mut hasher); + hasher.finish_to_limbs() + } else { + // Safety: comment added by `nargo expand` + let (bytes, length): ([u8; 147], u32) = unsafe { + rlp_encode_unconstrained(account, start_nibble_idx, trie_key) + }; + let mut checker: BytesChecker<147> = BytesChecker::<147>::new(bytes, length); + rlp_encode_to_sink(account, start_nibble_idx, trie_key, &mut checker); + checker.finish(); + keccak256_limbs(bytes, length) + } + } + } + + pub mod branch_hash { + use super::bytes_sink::BytesChecker; + use super::bytes_sink::BytesSink; + use super::bytes_sink::BytesWriter; + use super::keccak::keccak256_limbs; + use super::keccak::KeccakHasher; + use super::types::Node; + use super::utils::unroll_loop; + + global BRANCH_RLP_MAX_LENGTH: u32 = 532; + + #[inline_always] + fn compute_rlp_length(node: Node) -> u16 { + let mut len: u16 = 0_u16; + { + if node.row_exist[0_u32] { + len = len + 33_u16; + } else { + len = len + 1_u16; + }; + if node.row_exist[1_u32] { + len = len + 33_u16; + } else { + len = len + 1_u16; + }; + if node.row_exist[2_u32] { + len = len + 33_u16; + } else { + len = len + 1_u16; + }; + if node.row_exist[3_u32] { + len = len + 33_u16; + } else { + len = len + 1_u16; + }; + if node.row_exist[4_u32] { + len = len + 33_u16; + } else { + len = len + 1_u16; + }; + if node.row_exist[5_u32] { + len = len + 33_u16; + } else { + len = len + 1_u16; + }; + if node.row_exist[6_u32] { + len = len + 33_u16; + } else { + len = len + 1_u16; + }; + if node.row_exist[7_u32] { + len = len + 33_u16; + } else { + len = len + 1_u16; + }; + if node.row_exist[8_u32] { + len = len + 33_u16; + } else { + len = len + 1_u16; + }; + if node.row_exist[9_u32] { + len = len + 33_u16; + } else { + len = len + 1_u16; + }; + if node.row_exist[10_u32] { + len = len + 33_u16; + } else { + len = len + 1_u16; + }; + if node.row_exist[11_u32] { + len = len + 33_u16; + } else { + len = len + 1_u16; + }; + if node.row_exist[12_u32] { + len = len + 33_u16; + } else { + len = len + 1_u16; + }; + if node.row_exist[13_u32] { + len = len + 33_u16; + } else { + len = len + 1_u16; + }; + if node.row_exist[14_u32] { + len = len + 33_u16; + } else { + len = len + 1_u16; + }; + if node.row_exist[15_u32] { + len = len + 33_u16; + } else { + len = len + 1_u16; + } + }; + len = len + 1_u16; + len + } + + #[inline_always] + fn rlp_encode_to_sink(node: Node, sink: &mut S) where S: BytesSink { + let len: u16 = compute_rlp_length(node); + if len <= 55_u16 { + sink.add_byte(192_u8 + (len as u8)); + } else if len <= 255_u16 { + sink.add_byte(248_u8); + sink.add_byte(len as u8); + } else { + sink.add_byte(249_u8); + sink.add_byte((len >> 8_u16) as u8); + sink.add_byte((len & 255_u16) as u8); + }; + { + if node.row_exist[0_u32] { + sink.add_byte(160_u8); + sink.add_u64(node.rows[0_u32][0_u32]); + sink.add_u64(node.rows[0_u32][1_u32]); + sink.add_u64(node.rows[0_u32][2_u32]); + sink.add_u64(node.rows[0_u32][3_u32]); + } else { + sink.add_byte(128_u8); + }; + if node.row_exist[1_u32] { + sink.add_byte(160_u8); + sink.add_u64(node.rows[1_u32][0_u32]); + sink.add_u64(node.rows[1_u32][1_u32]); + sink.add_u64(node.rows[1_u32][2_u32]); + sink.add_u64(node.rows[1_u32][3_u32]); + } else { + sink.add_byte(128_u8); + }; + if node.row_exist[2_u32] { + sink.add_byte(160_u8); + sink.add_u64(node.rows[2_u32][0_u32]); + sink.add_u64(node.rows[2_u32][1_u32]); + sink.add_u64(node.rows[2_u32][2_u32]); + sink.add_u64(node.rows[2_u32][3_u32]); + } else { + sink.add_byte(128_u8); + }; + if node.row_exist[3_u32] { + sink.add_byte(160_u8); + sink.add_u64(node.rows[3_u32][0_u32]); + sink.add_u64(node.rows[3_u32][1_u32]); + sink.add_u64(node.rows[3_u32][2_u32]); + sink.add_u64(node.rows[3_u32][3_u32]); + } else { + sink.add_byte(128_u8); + }; + if node.row_exist[4_u32] { + sink.add_byte(160_u8); + sink.add_u64(node.rows[4_u32][0_u32]); + sink.add_u64(node.rows[4_u32][1_u32]); + sink.add_u64(node.rows[4_u32][2_u32]); + sink.add_u64(node.rows[4_u32][3_u32]); + } else { + sink.add_byte(128_u8); + }; + if node.row_exist[5_u32] { + sink.add_byte(160_u8); + sink.add_u64(node.rows[5_u32][0_u32]); + sink.add_u64(node.rows[5_u32][1_u32]); + sink.add_u64(node.rows[5_u32][2_u32]); + sink.add_u64(node.rows[5_u32][3_u32]); + } else { + sink.add_byte(128_u8); + }; + if node.row_exist[6_u32] { + sink.add_byte(160_u8); + sink.add_u64(node.rows[6_u32][0_u32]); + sink.add_u64(node.rows[6_u32][1_u32]); + sink.add_u64(node.rows[6_u32][2_u32]); + sink.add_u64(node.rows[6_u32][3_u32]); + } else { + sink.add_byte(128_u8); + }; + if node.row_exist[7_u32] { + sink.add_byte(160_u8); + sink.add_u64(node.rows[7_u32][0_u32]); + sink.add_u64(node.rows[7_u32][1_u32]); + sink.add_u64(node.rows[7_u32][2_u32]); + sink.add_u64(node.rows[7_u32][3_u32]); + } else { + sink.add_byte(128_u8); + }; + if node.row_exist[8_u32] { + sink.add_byte(160_u8); + sink.add_u64(node.rows[8_u32][0_u32]); + sink.add_u64(node.rows[8_u32][1_u32]); + sink.add_u64(node.rows[8_u32][2_u32]); + sink.add_u64(node.rows[8_u32][3_u32]); + } else { + sink.add_byte(128_u8); + }; + if node.row_exist[9_u32] { + sink.add_byte(160_u8); + sink.add_u64(node.rows[9_u32][0_u32]); + sink.add_u64(node.rows[9_u32][1_u32]); + sink.add_u64(node.rows[9_u32][2_u32]); + sink.add_u64(node.rows[9_u32][3_u32]); + } else { + sink.add_byte(128_u8); + }; + if node.row_exist[10_u32] { + sink.add_byte(160_u8); + sink.add_u64(node.rows[10_u32][0_u32]); + sink.add_u64(node.rows[10_u32][1_u32]); + sink.add_u64(node.rows[10_u32][2_u32]); + sink.add_u64(node.rows[10_u32][3_u32]); + } else { + sink.add_byte(128_u8); + }; + if node.row_exist[11_u32] { + sink.add_byte(160_u8); + sink.add_u64(node.rows[11_u32][0_u32]); + sink.add_u64(node.rows[11_u32][1_u32]); + sink.add_u64(node.rows[11_u32][2_u32]); + sink.add_u64(node.rows[11_u32][3_u32]); + } else { + sink.add_byte(128_u8); + }; + if node.row_exist[12_u32] { + sink.add_byte(160_u8); + sink.add_u64(node.rows[12_u32][0_u32]); + sink.add_u64(node.rows[12_u32][1_u32]); + sink.add_u64(node.rows[12_u32][2_u32]); + sink.add_u64(node.rows[12_u32][3_u32]); + } else { + sink.add_byte(128_u8); + }; + if node.row_exist[13_u32] { + sink.add_byte(160_u8); + sink.add_u64(node.rows[13_u32][0_u32]); + sink.add_u64(node.rows[13_u32][1_u32]); + sink.add_u64(node.rows[13_u32][2_u32]); + sink.add_u64(node.rows[13_u32][3_u32]); + } else { + sink.add_byte(128_u8); + }; + if node.row_exist[14_u32] { + sink.add_byte(160_u8); + sink.add_u64(node.rows[14_u32][0_u32]); + sink.add_u64(node.rows[14_u32][1_u32]); + sink.add_u64(node.rows[14_u32][2_u32]); + sink.add_u64(node.rows[14_u32][3_u32]); + } else { + sink.add_byte(128_u8); + }; + if node.row_exist[15_u32] { + sink.add_byte(160_u8); + sink.add_u64(node.rows[15_u32][0_u32]); + sink.add_u64(node.rows[15_u32][1_u32]); + sink.add_u64(node.rows[15_u32][2_u32]); + sink.add_u64(node.rows[15_u32][3_u32]); + } else { + sink.add_byte(128_u8); + } + }; + sink.add_byte(128_u8); + } + + unconstrained fn rlp_encode_unconstrained(node: Node) -> ([u8; 532], u32) { + let mut writer: BytesWriter<532> = BytesWriter::<532>::new(); + rlp_encode_to_sink(node, &mut writer); + writer.finish() + } + + pub fn rlp_and_hash_branch_node(node: Node) -> [u64; 4] { + if std::runtime::is_unconstrained() { + let mut hasher: KeccakHasher = KeccakHasher::new(); + rlp_encode_to_sink(node, &mut hasher); + hasher.finish_to_limbs() + } else { + // Safety: comment added by `nargo expand` + let (bytes, length): ([u8; 532], u32) = unsafe { + rlp_encode_unconstrained(node) + }; + let mut checker: BytesChecker<532> = BytesChecker::<532>::new(bytes, length); + rlp_encode_to_sink(node, &mut checker); + checker.finish(); + keccak256_limbs(bytes, length) + } + } + } + + pub mod bytes_sink { + use super::keccak::KeccakHasher; + + pub trait BytesSink { + fn add_byte(&mut self, byte: u8); + + fn add_u64(&mut self, value: u64); + } + + /// Writes bytes to an array. + pub struct BytesWriter { + bytes: [u8; N], + index: u32, + } + + impl BytesWriter { + pub fn new() -> Self { + Self { bytes: [0_u8; N], index: 0_u32} + } + + pub fn finish(self) -> ([u8; N], u32) { + (self.bytes, self.index) + } + } + + impl BytesSink for BytesWriter { + fn add_byte(&mut self, byte: u8) { + self.bytes[self.index] = byte; + self.index = self.index + 1_u32; + } + + fn add_u64(&mut self, mut value: u64) { + for _ in 0_u32..8_u32 { + self.add_byte(value as u8); + value = value >> 8_u64; + } + } + } + + /// Checks that a given array matches the expected bytes written, up to a given length. + pub struct BytesChecker { + bytes: [u8; N], + index: u32, + expected_length: u32, + } + + impl BytesChecker { + pub fn new(bytes: [u8; N], expected_length: u32) -> Self { + Self { bytes: bytes, index: 0_u32, expected_length: expected_length} + } + + pub fn finish(self) { + assert(self.index == self.expected_length); + } + } + + impl BytesSink for BytesChecker { + fn add_byte(&mut self, byte: u8) { + assert(self.bytes[self.index] == byte); + self.index = self.index + 1_u32; + } + + fn add_u64(&mut self, mut value: u64) { + for _ in 0_u32..8_u32 { + self.add_byte(value as u8); + value = value >> 8_u64; + } + } + } + } + + pub mod extension_hash { + use super::bytes_sink::BytesChecker; + use super::bytes_sink::BytesSink; + use super::bytes_sink::BytesWriter; + use super::keccak::keccak256_limbs; + use super::keccak::KeccakHasher; + use super::types::ExtensionHeader; + use super::types::Node; + use super::utils::unroll_loop; + + global EXTENSION_RLP_MAX_LENGTH: u32 = 68; + + #[inline_always] + fn rlp_encode_to_sink(node: Node, header: ExtensionHeader, sink: &mut S) where S: BytesSink { + let extension_length_size: u8 = header.extension_length + 1_u8; + let rlp_data_length: u8 = (extension_length_size + 33_u8) + ((extension_length_size != 1_u8) as u8); + if rlp_data_length > 55_u8 { + sink.add_byte(248_u8); + sink.add_byte(rlp_data_length); + } else { + sink.add_byte(192_u8 + rlp_data_length); + }; + if extension_length_size != 1_u8 { + sink.add_byte(128_u8 + extension_length_size); + }; + sink.add_byte(((header.is_odd as u8) << 4_u8) + header.first_nibble); + { + if (0_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 0_u32)); + }; + if (1_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 1_u32)); + }; + if (2_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 2_u32)); + }; + if (3_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 3_u32)); + }; + if (4_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 4_u32)); + }; + if (5_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 5_u32)); + }; + if (6_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 6_u32)); + }; + if (7_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 7_u32)); + }; + if (8_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 8_u32)); + }; + if (9_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 9_u32)); + }; + if (10_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 10_u32)); + }; + if (11_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 11_u32)); + }; + if (12_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 12_u32)); + }; + if (13_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 13_u32)); + }; + if (14_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 14_u32)); + }; + if (15_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 15_u32)); + }; + if (16_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 16_u32)); + }; + if (17_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 17_u32)); + }; + if (18_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 18_u32)); + }; + if (19_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 19_u32)); + }; + if (20_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 20_u32)); + }; + if (21_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 21_u32)); + }; + if (22_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 22_u32)); + }; + if (23_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 23_u32)); + }; + if (24_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 24_u32)); + }; + if (25_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 25_u32)); + }; + if (26_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 26_u32)); + }; + if (27_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 27_u32)); + }; + if (28_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 28_u32)); + }; + if (29_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 29_u32)); + }; + if (30_u32 as u8) < header.extension_length { + sink.add_byte(node.get_row_byte(1_u32, 30_u32)); + } + }; + sink.add_byte(160_u8); + { + sink.add_u64(node.rows[2_u32][0_u32]); + sink.add_u64(node.rows[2_u32][1_u32]); + sink.add_u64(node.rows[2_u32][2_u32]); + sink.add_u64(node.rows[2_u32][3_u32]); + }; + } + + unconstrained fn rlp_encode_unconstrained(node: Node, header: ExtensionHeader) -> ([u8; 68], u32) { + let mut writer: BytesWriter<68> = BytesWriter::<68>::new(); + rlp_encode_to_sink(node, header, &mut writer); + writer.finish() + } + + pub fn rlp_and_hash_extension_node(node: Node, header: ExtensionHeader) -> [u64; 4] { + if std::runtime::is_unconstrained() { + let mut hasher: KeccakHasher = KeccakHasher::new(); + rlp_encode_to_sink(node, header, &mut hasher); + hasher.finish_to_limbs() + } else { + // Safety: comment added by `nargo expand` + let (bytes, length): ([u8; 68], u32) = unsafe { + rlp_encode_unconstrained(node, header) + }; + let mut checker: BytesChecker<68> = BytesChecker::<68>::new(bytes, length); + rlp_encode_to_sink(node, header, &mut checker); + checker.finish(); + keccak256_limbs(bytes, length) + } + } + } + + pub mod keccak { + use keccak256::keccak256 as keccak256lib; + use keccak256::keccak256 as keccak256lib; + use std::hash::keccakf1600; + + global BLOCK_SIZE_IN_BYTES: u32 = 136; + + global WORD_SIZE: u32 = 8; + + global LIMBS_PER_BLOCK: u32 = 17; + + global NUM_KECCAK_LANES: u32 = 25; + + pub struct KeccakHasher { + state: [u64; 25], + limb_index_to_write: u32, + current_limb: u64, + current_limb_shift: u64, + } + + impl KeccakHasher { + pub fn new() -> Self { + Self { state: [0_u64; 25], limb_index_to_write: 0_u32, current_limb: 0_u64, current_limb_shift: 0_u64} + } + + pub fn hash_bytes(bytes: [u8; N], length: u32) -> [u8; 32] { + let mut hasher: Self = Self::new(); + for i in 0_u32..length { + hasher.add_byte(bytes[i]); + }; + hasher.finish() + } + + pub fn hash_bytes_to_limbs(bytes: [u8; N], length: u32) -> [u64; 4] { + let mut hasher: Self = Self::new(); + for i in 0_u32..length { + hasher.add_byte(bytes[i]); + }; + hasher.finish_to_limbs() + } + + pub fn add_byte(&mut self, byte: u8) { + let byte_as_u64: u64 = byte as u64; + let shifted_byte: u64 = byte_as_u64 << self.current_limb_shift; + self.current_limb = self.current_limb + shifted_byte; + if self.current_limb_shift == 56_u64 { + self.finish_limb(); + } else { + self.current_limb_shift = self.current_limb_shift + 8_u64; + } + } + + pub fn add_u64(&mut self, value: u64) { + if self.current_limb_shift == 0_u64 { + self.current_limb = value; + self.finish_limb(); + } else { + let shift: u64 = self.current_limb_shift; + self.current_limb = self.current_limb + (value << shift); + self.finish_limb(); + self.current_limb = value >> (64_u64 - shift); + self.current_limb_shift = shift; + } + } + + #[inline_always] + fn finish_limb(&mut self) { + self.state[self.limb_index_to_write] = self.state[self.limb_index_to_write] ^ self.current_limb; + self.current_limb_shift = 0_u64; + self.current_limb = 0_u64; + if self.limb_index_to_write == (LIMBS_PER_BLOCK - 1_u32) { + self.finish_block(); + } else { + self.limb_index_to_write = self.limb_index_to_write + 1_u32; + } + } + + #[inline_always] + fn finish_block(&mut self) { + self.state = keccakf1600(self.state); + self.limb_index_to_write = 0_u32; + } + + #[inline_always] + fn apply_padding(&mut self) { + self.state[self.limb_index_to_write] = self.state[self.limb_index_to_write] ^ (self.current_limb + (1_u64 << self.current_limb_shift)); + { + let i_0: u32 = LIMBS_PER_BLOCK - 1_u32; + self.state[i_0] = self.state[LIMBS_PER_BLOCK - 1_u32] ^ (128_u64 << 56_u64); + } + } + + pub fn finish_to_limbs(mut self) -> [u64; 4] { + self.apply_padding(); + self.finish_block(); + [self.state[0_u32], self.state[1_u32], self.state[2_u32], self.state[3_u32]] + } + + pub fn finish(mut self) -> [u8; 32] { + self.apply_padding(); + self.finish_block(); + let mut result: [u8; 32] = [0_u8; 32]; + for i in 0_u32..4_u32 { + let lane: Field = self.state[i] as Field; + let lane_le: [u8; 8] = lane.to_be_bytes(); + for j in 0_u32..8_u32 { + { + let i_0: u32 = (8_u32 * i) + j; + result[i_0] = lane_le[7_u32 - j]; + } + } + }; + result + } + } + + impl super::bytes_sink::BytesSink for KeccakHasher { + fn add_byte(&mut self, byte: u8) { + self.add_byte(byte); + } + + fn add_u64(&mut self, mut value: u64) { + self.add_u64(value); + } + } + + pub fn keccak256(input: [u8; N], message_size: u32) -> [u8; 32] { + keccak256lib(input, message_size) + } + + pub fn keccak256_limbs(input: [u8; N], message_size: u32) -> [u64; 4] { + let bytes: [u8; 32] = keccak256lib(input, message_size); + bytes_to_u64(bytes) + } + + fn bytes_to_u64(bytes: [u8; N]) -> [u64; K] { + std::static_assert((K * 8_u32) == N, "Invalid number of u64s for given number of bytes"); + let mut result: [u64; K] = [0_u64; K]; + for i in 0_u32..K { + let mut value: u64 = 0_u64; + for j in 0_u32..8_u32 { + let byte: u8 = bytes[(i * 8_u32) + j]; + value = value + ((byte as u64) << ((8_u32 * j) as u64)); + }; + result[i] = value; + }; + result + } + } + + pub mod path_verification { + use super::branch_hash; + use super::extension_hash; + use super::types::Node; + use super::utils::runtime_loop; + + pub fn verify_path_section(nodes: [Node; MAX_PATH_LENGTH], node_length: u32, start_trie_key_index: u32, mut parent: [u64; 4], trie_key_nibbles: [u8; 64]) -> ([u64; 4], u32) { + let mut current_nibble_idx: u32 = start_trie_key_index; + { + assert(0_u32 <= node_length); + assert(node_length <= MAX_PATH_LENGTH); + if std::runtime::is_unconstrained() { + for i in 0_u32..node_length { + let node: Node = nodes[i]; + if node.is_branch_node() { + let hash: [u64; 4] = branch_hash::rlp_and_hash_branch_node(node); + assert(hash == parent); + let index: u32 = trie_key_nibbles[current_nibble_idx] as u32; + parent = node.rows[index]; + current_nibble_idx = current_nibble_idx + 1_u32; + } else if node.is_extension_node() { + let header: super::types::ExtensionHeader = node.extract_extension_header(); + let hash: [u64; 4] = extension_hash::rlp_and_hash_extension_node(node, header); + assert(hash == parent); + if header.is_odd { + assert(trie_key_nibbles[current_nibble_idx] == header.first_nibble); + current_nibble_idx = current_nibble_idx + 1_u32; + }; + { + assert(0_u32 <= (header.extension_length as u32)); + assert((header.extension_length as u32) <= 32_u32); + if std::runtime::is_unconstrained() { + for j in 0_u32..header.extension_length as u32 { + let high_key_nibble: u8 = trie_key_nibbles[current_nibble_idx]; + let low_key_nibble: u8 = trie_key_nibbles[current_nibble_idx + 1_u32]; + let key_byte: u8 = (high_key_nibble << 4_u8) + low_key_nibble; + current_nibble_idx = current_nibble_idx + 2_u32; + let extension_byte: u8 = node.get_row_byte(1_u32, j); + assert(key_byte == extension_byte); + () + } + } else { + for j in 0_u32..32_u32 { + if (j >= 0_u32) & (j < (header.extension_length as u32)) { + let high_key_nibble: u8 = trie_key_nibbles[current_nibble_idx]; + let low_key_nibble: u8 = trie_key_nibbles[current_nibble_idx + 1_u32]; + let key_byte: u8 = (high_key_nibble << 4_u8) + low_key_nibble; + current_nibble_idx = current_nibble_idx + 2_u32; + let extension_byte: u8 = node.get_row_byte(1_u32, j); + assert(key_byte == extension_byte); + () + } + } + } + }; + parent = node.rows[2_u32]; + } else { + assert(false); + }; + () + } + } else { + for i in 0_u32..MAX_PATH_LENGTH { + if (i >= 0_u32) & (i < node_length) { + let node: Node = nodes[i]; + if node.is_branch_node() { + let hash: [u64; 4] = branch_hash::rlp_and_hash_branch_node(node); + assert(hash == parent); + let index: u32 = trie_key_nibbles[current_nibble_idx] as u32; + parent = node.rows[index]; + current_nibble_idx = current_nibble_idx + 1_u32; + } else if node.is_extension_node() { + let header: super::types::ExtensionHeader = node.extract_extension_header(); + let hash: [u64; 4] = extension_hash::rlp_and_hash_extension_node(node, header); + assert(hash == parent); + if header.is_odd { + assert(trie_key_nibbles[current_nibble_idx] == header.first_nibble); + current_nibble_idx = current_nibble_idx + 1_u32; + }; + { + assert(0_u32 <= (header.extension_length as u32)); + assert((header.extension_length as u32) <= 32_u32); + if std::runtime::is_unconstrained() { + for j in 0_u32..header.extension_length as u32 { + let high_key_nibble: u8 = trie_key_nibbles[current_nibble_idx]; + let low_key_nibble: u8 = trie_key_nibbles[current_nibble_idx + 1_u32]; + let key_byte: u8 = (high_key_nibble << 4_u8) + low_key_nibble; + current_nibble_idx = current_nibble_idx + 2_u32; + let extension_byte: u8 = node.get_row_byte(1_u32, j); + assert(key_byte == extension_byte); + () + } + } else { + for j in 0_u32..32_u32 { + if (j >= 0_u32) & (j < (header.extension_length as u32)) { + let high_key_nibble: u8 = trie_key_nibbles[current_nibble_idx]; + let low_key_nibble: u8 = trie_key_nibbles[current_nibble_idx + 1_u32]; + let key_byte: u8 = (high_key_nibble << 4_u8) + low_key_nibble; + current_nibble_idx = current_nibble_idx + 2_u32; + let extension_byte: u8 = node.get_row_byte(1_u32, j); + assert(key_byte == extension_byte); + () + } + } + } + }; + parent = node.rows[2_u32]; + } else { + assert(false); + }; + () + } + } + } + }; + (parent, current_nibble_idx) + } + } + + pub mod slot_hash { + use super::bytes_sink::BytesChecker; + use super::bytes_sink::BytesSink; + use super::bytes_sink::BytesWriter; + use super::keccak::keccak256_limbs; + use super::keccak::KeccakHasher; + use super::types::StorageSlot; + use super::utils::get_low_nibble; + use super::utils::get_rlp_length; + use super::utils::runtime_loop; + + global SLOT_RLP_MAX_LENGTH: u32 = 69; + + #[inline_always] + fn rlp_encode_to_sink(slot: StorageSlot, start_nibble_idx: u32, trie_key: [u8; 32], sink: &mut S) where S: BytesSink { + let mut current_nibble_idx: u32 = start_nibble_idx; + let first_key_byte: u8 = if (current_nibble_idx % 2_u32) == 0_u32 { + 32_u8 + } else { + let first_byte: u8 = trie_key[(current_nibble_idx / 2_u32) as u32]; + current_nibble_idx = current_nibble_idx + 1_u32; + 48_u8 + get_low_nibble(first_byte) + }; + let key_length: u8 = (32_u8 - ((current_nibble_idx as u8) / 2_u8)) + 1_u8; + let leaf_key_rlp_length: u8 = get_rlp_length(first_key_byte, key_length); + assert(slot.value_length <= 32_u8); + let inner_rlp_length: u8 = get_rlp_length(slot.value[0_u32], slot.value_length); + let inner_first_byte: u8 = if slot.value_length == 0_u8 { + 128_u8 + } else if (slot.value_length == 1_u8) & (slot.value[0_u32] <= 127_u8) { + slot.value[0_u32] + } else { + 128_u8 + slot.value_length + }; + let outer_rlp_length: u8 = get_rlp_length(inner_first_byte, inner_rlp_length); + let leaf_rlp_total_length: u8 = leaf_key_rlp_length + outer_rlp_length; + if leaf_rlp_total_length <= 55_u8 { + sink.add_byte(192_u8 + leaf_rlp_total_length); + } else { + sink.add_byte(248_u8); + sink.add_byte(leaf_rlp_total_length); + }; + if (key_length == 1_u8) & (first_key_byte <= 127_u8) { + sink.add_byte(first_key_byte); + } else { + sink.add_byte(128_u8 + key_length); + sink.add_byte(first_key_byte); + let start_byte_idx: u32 = current_nibble_idx / 2_u32; + let end_byte_idx: u32 = start_byte_idx + ((key_length - 1_u8) as u32); + { + assert(start_byte_idx <= end_byte_idx); + assert(end_byte_idx <= trie_key.len()); + if std::runtime::is_unconstrained() { + for i in start_byte_idx..end_byte_idx { + sink.add_byte(trie_key[i]); + () + } + } else { + for i in 0_u32..trie_key.len() { + if (i >= start_byte_idx) & (i < end_byte_idx) { + sink.add_byte(trie_key[i]); + () + } + } + } + }; + }; + if (inner_rlp_length == 1_u8) & (inner_first_byte <= 127_u8) { + } else { + sink.add_byte(128_u8 + inner_rlp_length); + }; + if slot.value_length == 0_u8 { + sink.add_byte(128_u8); + } else if (slot.value_length == 1_u8) & (slot.value[0_u32] <= 127_u8) { + sink.add_byte(slot.value[0_u32]); + } else { + sink.add_byte(128_u8 + slot.value_length); + { + assert(0_u32 <= (slot.value_length as u32)); + assert((slot.value_length as u32) <= 32_u32); + if std::runtime::is_unconstrained() { + for i in 0_u32..slot.value_length as u32 { + sink.add_byte(slot.value[i]); + () + } + } else { + for i in 0_u32..32_u32 { + if (i >= 0_u32) & (i < (slot.value_length as u32)) { + sink.add_byte(slot.value[i]); + () + } + } + } + }; + } + } + + unconstrained fn rlp_encode_unconstrained(slot: StorageSlot, start_nibble_idx: u32, trie_key: [u8; 32]) -> ([u8; 69], u32) { + let mut writer: BytesWriter<69> = BytesWriter::<69>::new(); + rlp_encode_to_sink(slot, start_nibble_idx, trie_key, &mut writer); + writer.finish() + } + + pub fn compute_slot_hash(slot: StorageSlot, start_nibble_idx: u32, trie_key: [u8; 32]) -> [u64; 4] { + if std::runtime::is_unconstrained() { + let mut hasher: KeccakHasher = KeccakHasher::new(); + rlp_encode_to_sink(slot, start_nibble_idx, trie_key, &mut hasher); + hasher.finish_to_limbs() + } else { + // Safety: comment added by `nargo expand` + let (bytes, length): ([u8; 69], u32) = unsafe { + rlp_encode_unconstrained(slot, start_nibble_idx, trie_key) + }; + let mut checker: BytesChecker<69> = BytesChecker::<69>::new(bytes, length); + rlp_encode_to_sink(slot, start_nibble_idx, trie_key, &mut checker); + checker.finish(); + keccak256_limbs(bytes, length) + } + } + } + + pub mod types { + use super::utils::get_low_nibble; + use aztec::protocol::traits::Deserialize; + use aztec::protocol::traits::Serialize; + + pub struct ExtensionHeader { + pub is_odd: bool, + pub first_nibble: u8, + pub extension_length: u8, + } + + pub struct Node { + pub rows: [[u64; 4]; 16], + pub row_exist: [bool; 16], + pub node_type: u8, + } + + impl Node { + #[inline_always] + pub fn is_branch_node(self) -> bool { + self.node_type == 0_u8 + } + + #[inline_always] + pub fn is_extension_node(self) -> bool { + self.node_type == 1_u8 + } + + #[inline_always] + pub fn get_row_byte(self, row: u32, byte_index: u32) -> u8 { + let limb_index: u32 = byte_index / 8_u32; + let shift: u64 = ((byte_index % 8_u32) * 8_u32) as u64; + (self.rows[row][limb_index] >> shift) as u8 + } + + pub fn extract_extension_header(self) -> ExtensionHeader { + let is_odd: bool = self.rows[0_u32][0_u32] != 0_u64; + let first_nibble: u8 = if is_odd { + get_low_nibble(self.rows[0_u32][1_u32] as u8) + } else { + 0_u8 + }; + let extension_length: u8 = self.rows[0_u32][2_u32] as u8; + ExtensionHeader { is_odd: is_odd, first_nibble: first_nibble, extension_length: extension_length} + } + } + + impl Serialize for Node { + let N: u32 = 81; + + fn serialize(self) -> [Field; 81] { + let mut writer: aztec::protocol::utils::writer::Writer<81> = aztec::protocol::utils::writer::Writer::<81>::new(); + self.stream_serialize(&mut writer); + writer.finish() + } + + #[inline_always] + fn stream_serialize(self, writer: &mut aztec::protocol::utils::writer::Writer) { + self.rows.stream_serialize(writer); + self.row_exist.stream_serialize(writer); + self.node_type.stream_serialize(writer); + } + } + + impl Deserialize for Node { + let N: u32 = 81; + + fn deserialize(fields: [Field; 81]) -> Self { + let mut reader: aztec::protocol::utils::reader::Reader<81> = aztec::protocol::utils::reader::Reader::<81>::new(fields); + let result: Self = Self::stream_deserialize(&mut reader); + reader.finish(); + result + } + + #[inline_always] + fn stream_deserialize(reader: &mut aztec::protocol::utils::reader::Reader) -> Self { + let rows: [[u64; 4]; 16] = <[[u64; 4]; 16] as Deserialize>::stream_deserialize(reader); + let row_exist: [bool; 16] = <[bool; 16] as Deserialize>::stream_deserialize(reader); + let node_type: u8 = ::stream_deserialize(reader); + Self { rows: rows, row_exist: row_exist, node_type: node_type} + } + } + + pub struct Account { + pub nonce: [u8; 8], + pub balance: [u8; 32], + pub address: [u8; 20], + pub nonce_length: u8, + pub balance_length: u8, + pub storage_hash: [u64; 4], + pub code_hash: [u64; 4], + } + + impl Serialize for Account { + let N: u32 = 70; + + fn serialize(self) -> [Field; 70] { + let mut writer: aztec::protocol::utils::writer::Writer<70> = aztec::protocol::utils::writer::Writer::<70>::new(); + self.stream_serialize(&mut writer); + writer.finish() + } + + #[inline_always] + fn stream_serialize(self, writer: &mut aztec::protocol::utils::writer::Writer) { + self.nonce.stream_serialize(writer); + self.balance.stream_serialize(writer); + self.address.stream_serialize(writer); + self.nonce_length.stream_serialize(writer); + self.balance_length.stream_serialize(writer); + self.storage_hash.stream_serialize(writer); + self.code_hash.stream_serialize(writer); + } + } + + impl Deserialize for Account { + let N: u32 = 70; + + fn deserialize(fields: [Field; 70]) -> Self { + let mut reader: aztec::protocol::utils::reader::Reader<70> = aztec::protocol::utils::reader::Reader::<70>::new(fields); + let result: Self = Self::stream_deserialize(&mut reader); + reader.finish(); + result + } + + #[inline_always] + fn stream_deserialize(reader: &mut aztec::protocol::utils::reader::Reader) -> Self { + let nonce: [u8; 8] = <[u8; 8] as Deserialize>::stream_deserialize(reader); + let balance: [u8; 32] = <[u8; 32] as Deserialize>::stream_deserialize(reader); + let address: [u8; 20] = <[u8; 20] as Deserialize>::stream_deserialize(reader); + let nonce_length: u8 = ::stream_deserialize(reader); + let balance_length: u8 = ::stream_deserialize(reader); + let storage_hash: [u64; 4] = <[u64; 4] as Deserialize>::stream_deserialize(reader); + let code_hash: [u64; 4] = <[u64; 4] as Deserialize>::stream_deserialize(reader); + Self { nonce: nonce, balance: balance, address: address, nonce_length: nonce_length, balance_length: balance_length, storage_hash: storage_hash, code_hash: code_hash} + } + } + + pub struct StorageSlot { + pub value: [u8; 32], + pub value_length: u8, + } + + impl Serialize for StorageSlot { + let N: u32 = 33; + + fn serialize(self) -> [Field; 33] { + let mut writer: aztec::protocol::utils::writer::Writer<33> = aztec::protocol::utils::writer::Writer::<33>::new(); + self.stream_serialize(&mut writer); + writer.finish() + } + + #[inline_always] + fn stream_serialize(self, writer: &mut aztec::protocol::utils::writer::Writer) { + self.value.stream_serialize(writer); + self.value_length.stream_serialize(writer); + } + } + + impl Deserialize for StorageSlot { + let N: u32 = 33; + + fn deserialize(fields: [Field; 33]) -> Self { + let mut reader: aztec::protocol::utils::reader::Reader<33> = aztec::protocol::utils::reader::Reader::<33>::new(fields); + let result: Self = Self::stream_deserialize(&mut reader); + reader.finish(); + result + } + + #[inline_always] + fn stream_deserialize(reader: &mut aztec::protocol::utils::reader::Reader) -> Self { + let value: [u8; 32] = <[u8; 32] as Deserialize>::stream_deserialize(reader); + let value_length: u8 = ::stream_deserialize(reader); + Self { value: value, value_length: value_length} + } + } + } + + pub mod utils { + use std::static_assert; + + /// Unrolls a loop at comptime + pub comptime fn unroll_loop(start: u32, end: u32, body: fn(u32) -> Quoted) -> Quoted { + let mut iterations: [Quoted] = @[]; + for i in start..end { + iterations = iterations.push_back(body(i)); + }; + iterations.join(quote { }) + } + + /// Creates a loop that: + /// - In ACIR: iterates from 0 to upper bound, and conditions body on index >= start_variable & index < end_variable + /// - In BRILLIG: iterates from start_variable to end_variable + pub comptime fn runtime_loop(iterator: Quoted, start_variable: Quoted, end_variable: Quoted, upper_bound: Quoted, body: Quoted) -> Quoted { + quote { + assert($start_variable <= $end_variable); + assert($end_variable <= $upper_bound); + if std::runtime::is_unconstrained() { + for $iterator in $start_variable..$end_variable { + $body() + } + } else { + for $iterator in 0..$upper_bound { + if $iterator >= $start_variable & $iterator < $end_variable { + $body() + } + } + } + } + } + + pub fn balance_to_field(balance: [u8; 32], balance_length: u8) -> Field { + let mut result: Field = 0_Field; + { + assert(0_u32 <= (balance_length as u32)); + assert((balance_length as u32) <= 32_u32); + if std::runtime::is_unconstrained() { + for i in 0_u32..balance_length as u32 { + result = result * 256_Field; + result = result + (balance[i] as Field); + () + } + } else { + for i in 0_u32..32_u32 { + if (i >= 0_u32) & (i < (balance_length as u32)) { + result = result * 256_Field; + result = result + (balance[i] as Field); + () + } + } + } + }; + result + } + + pub fn to_nibbles(bytes: [u8; N]) -> [u8; K] { + static_assert((N * 2_u32) == K, "Nibble amount should be double the byte amount"); + let mut nibbles: [u8; K] = [0_u8; K]; + for i in 0_u32..N { + let byte: u8 = bytes[i]; + { + let i_0: u32 = i * 2_u32; + nibbles[i_0] = byte >> 4_u8; + }; + { + let i_1: u32 = (i * 2_u32) + 1_u32; + nibbles[i_1] = (byte << 4_u8) >> 4_u8; + } + }; + nibbles + } + + #[inline_always] + pub fn get_low_nibble(byte: u8) -> u8 { + (byte << 4_u8) >> 4_u8 + } + + #[inline_always] + pub fn get_high_nibble(byte: u8) -> u8 { + byte >> 4_u8 + } + + pub fn get_rlp_length(first_elem: u8, length: u8) -> u8 { + let mut rlp_length: u8 = 0_u8; + if length == 0_u8 { + rlp_length = 1_u8; + } else if length == 1_u8 { + if first_elem <= 127_u8 { + rlp_length = 1_u8; + } else { + rlp_length = 2_u8; + } + } else { + rlp_length = 1_u8 + length; + }; + rlp_length + } + } +} + +// Warning: the generated code has syntax errors diff --git a/noir-projects/contract-snapshots/tests/snapshots/expand/token_contract/snapshots__expanded.snap b/noir-projects/contract-snapshots/tests/snapshots/expand/token_contract/snapshots__expanded.snap new file mode 100644 index 000000000000..ca20d6e6efd9 --- /dev/null +++ b/noir-projects/contract-snapshots/tests/snapshots/expand/token_contract/snapshots__expanded.snap @@ -0,0 +1,4965 @@ +--- +source: tests/snapshots.rs +expression: stdout +--- +use aztec::macros::aztec; +use aztec::macros::aztec; + +pub contract Token { + use std::ops::Add; + use std::ops::Sub; + use compressed_string::FieldCompressedString; + use aztec::authwit::auth::compute_authwit_nullifier; + use aztec::context::calls::PrivateCall; + use aztec::context::PrivateContext; + use aztec::macros::events::event; + use aztec::macros::functions::authorize_once; + use aztec::macros::functions::external; + use aztec::macros::functions::initializer; + use aztec::macros::functions::internal; + use aztec::macros::functions::only_self; + use aztec::macros::functions::view; + use aztec::macros::storage::storage; + use aztec::messages::message_delivery::MessageDelivery; + use aztec::protocol::address::AztecAddress; + use aztec::protocol::traits::ToField; + use aztec::state_vars::Map; + use aztec::state_vars::Owned; + use aztec::state_vars::PublicImmutable; + use aztec::state_vars::PublicMutable; + use aztec::state_vars::StateVariable; + use uint_note::PartialUintNote; + use uint_note::UintNote; + use balance_set::BalanceSet; + + global INITIAL_TRANSFER_CALL_MAX_NOTES: u32 = 2; + + global RECURSIVE_TRANSFER_CALL_MAX_NOTES: u32 = 8; + + #[abi(events)] + struct Transfer { + from: AztecAddress, + to: AztecAddress, + amount: u128, + } + + impl aztec::event::event_interface::EventInterface for Transfer { + fn get_event_type_id() -> aztec::event::EventSelector { + ::from_field(1889634638_Field) + } + } + + impl aztec::protocol::traits::Serialize for Transfer { + let N: u32 = 3; + + fn serialize(self) -> [Field; 3] { + let mut writer: aztec::protocol::utils::writer::Writer<3> = aztec::protocol::utils::writer::Writer::<3>::new(); + >::stream_serialize(self, &mut writer); + writer.finish() + } + + #[inline_always] + fn stream_serialize(self, writer: &mut aztec::protocol::utils::writer::Writer) { + ::stream_serialize(self.from, writer); + ::stream_serialize(self.to, writer); + ::stream_serialize(self.amount, writer); + } + } + + struct Storage { + admin: PublicMutable, + minters: Map, Context>, + balances: Owned, Context>, + total_supply: PublicMutable, + public_balances: Map, Context>, + symbol: PublicImmutable, + name: PublicImmutable, + decimals: PublicImmutable, + } + + impl Storage { + fn init(context: Context) -> Self { + Self { admin: as StateVariable<1, Context>>::new(context, 1_Field), minters: , Context> as StateVariable<1, Context>>::new(context, 2_Field), balances: , Context> as StateVariable<1, Context>>::new(context, 3_Field), total_supply: as StateVariable<1, Context>>::new(context, 4_Field), public_balances: , Context> as StateVariable<1, Context>>::new(context, 5_Field), symbol: as StateVariable<2, Context>>::new(context, 6_Field), name: as StateVariable<2, Context>>::new(context, 8_Field), decimals: as StateVariable<2, Context>>::new(context, 10_Field)} + } + } + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call constructor. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn constructor(admin: AztecAddress, name: str<31>, symbol: str<31>, decimals: u8); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call set_admin. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn set_admin(new_admin: AztecAddress); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call public_get_name. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn public_get_name() -> FieldCompressedString; + + #[deprecated(deny, "Direct invocation of private functions is not supported. You attempted to call private_get_name. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn private_get_name() -> FieldCompressedString; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call public_get_symbol. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn public_get_symbol() -> pub FieldCompressedString; + + #[deprecated(deny, "Direct invocation of private functions is not supported. You attempted to call private_get_symbol. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn private_get_symbol() -> pub FieldCompressedString; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call public_get_decimals. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn public_get_decimals() -> pub u8; + + #[abi(storage)] + pub global STORAGE_LAYOUT_Token: StorageLayout<5> = StorageLayout::<5> { + contract_name: "Token", + fields: StorageLayoutFields { + decimals: aztec::state_vars::Storable { + slot: 0x0a, + }, + symbol: aztec::state_vars::Storable { + slot: 0x06, + }, + total_supply: aztec::state_vars::Storable { + slot: 0x04, + }, + minters: aztec::state_vars::Storable { + slot: 0x02, + }, + public_balances: aztec::state_vars::Storable { + slot: 0x05, + }, + admin: aztec::state_vars::Storable { + slot: 0x01, + }, + name: aztec::state_vars::Storable { + slot: 0x08, + }, + balances: aztec::state_vars::Storable { + slot: 0x03, + }, + }, + }; + + #[deprecated(deny, "Direct invocation of private functions is not supported. You attempted to call private_get_decimals. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn private_get_decimals() -> pub u8; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call get_admin. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn get_admin() -> Field; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call is_minter. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn is_minter(minter: AztecAddress) -> bool; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call total_supply. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn total_supply() -> u128; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call balance_of_public. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn balance_of_public(owner: AztecAddress) -> u128; + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call set_minter. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn set_minter(minter: AztecAddress, approve: bool); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call mint_to_public. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn mint_to_public(to: AztecAddress, amount: u128); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call transfer_in_public. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn transfer_in_public(from: AztecAddress, to: AztecAddress, amount: u128, authwit_nonce: Field); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call burn_public. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn burn_public(from: AztecAddress, amount: u128, authwit_nonce: Field); + + #[deprecated(deny, "Direct invocation of private functions is not supported. You attempted to call transfer_to_public. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn transfer_to_public(from: AztecAddress, to: AztecAddress, amount: u128, authwit_nonce: Field); + + /// Transfers tokens from private balance of `from` to public balance of `to` and prepares a partial note for + /// receiving change for `from`. + /// + /// This is an optimization that combines two operations into one to reduce contract calls: + /// 1. Transfers `amount` tokens from `from`'s private balance to `to`'s public balance + /// 2. Creates a partial note that can later be used to receive change back to `from`'s private balance + /// + /// This pattern is useful when interacting with contracts that: + /// - Receive tokens from a user's private balance + /// - Need to wait until public execution to determine how many tokens to return (e.g. AMM, FPC) + /// - Will return tokens to the user's private balance + /// + /// The contract can use the returned partial note to complete the transfer back to private + /// once the final amount is known during public execution. + #[deprecated(deny, "Direct invocation of private functions is not supported. You attempted to call transfer_to_public_and_prepare_private_balance_increase. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn transfer_to_public_and_prepare_private_balance_increase(from: AztecAddress, to: AztecAddress, amount: u128, authwit_nonce: Field) -> PartialUintNote; + + #[deprecated(deny, "Direct invocation of private functions is not supported. You attempted to call transfer. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn transfer(to: AztecAddress, amount: u128); + + #[deprecated(deny, "Direct invocation of private internal functions is not supported. You attempted to call subtract_balance. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn subtract_balance(account: AztecAddress, amount: u128, max_notes: u32) -> u128; + + #[no_predicates] + #[contract_library_method] + fn compute_recurse_subtract_balance_call(context: PrivateContext, account: AztecAddress, remaining: u128) -> PrivateCall<25, 2, u128> { + Token::at(context.this_address())._recurse_subtract_balance(account, remaining) + } + + #[deprecated(deny, "Direct invocation of private functions is not supported. You attempted to call _recurse_subtract_balance. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn _recurse_subtract_balance(account: AztecAddress, amount: u128) -> u128; + + /// Cancel a private authentication witness. + /// @param inner_hash The inner hash of the authwit to cancel. + #[deprecated(deny, "Direct invocation of private functions is not supported. You attempted to call cancel_authwit. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn cancel_authwit(inner_hash: Field); + + #[deprecated(deny, "Direct invocation of private functions is not supported. You attempted to call transfer_in_private. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn transfer_in_private(from: AztecAddress, to: AztecAddress, amount: u128, authwit_nonce: Field); + + /// Mirrors `transfer_in_private` but delivers the resulting notes via offchain messages. + /// + /// Offchain messages are returned to the caller as encrypted payloads. The sender is responsible for getting the + /// recipient's note to them (typically by encoding it into a link, QR code, or direct message). The recipient + /// ingests it by calling `offchain_receive` on their environment. + /// + /// A `Transfer` event is also emitted to be delivered offchain. + #[deprecated(deny, "Direct invocation of private functions is not supported. You attempted to call transfer_in_private_with_offchain_delivery. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn transfer_in_private_with_offchain_delivery(from: AztecAddress, to: AztecAddress, amount: u128, authwit_nonce: Field); + + #[deprecated(deny, "Direct invocation of private functions is not supported. You attempted to call burn_private. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn burn_private(from: AztecAddress, amount: u128, authwit_nonce: Field); + + #[deprecated(deny, "Direct invocation of private functions is not supported. You attempted to call transfer_to_private. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn transfer_to_private(to: AztecAddress, amount: u128); + + /// Prepares an increase of private balance of `to` (partial note). The increase needs to be finalized by calling + /// some of the finalization functions (`finalize_transfer_to_private`, `finalize_mint_to_private`) with the + /// returned partial note. + #[deprecated(deny, "Direct invocation of private functions is not supported. You attempted to call prepare_private_balance_increase. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn prepare_private_balance_increase(to: AztecAddress) -> PartialUintNote; + + /// This function exists separately from `prepare_private_balance_increase` solely as an optimization as it allows + /// us to have it inlined in the `transfer_to_private` function which results in one fewer kernel iteration. Note + /// that in this case we don't pass `completer` as an argument to this function because in all the callsites we + /// want to use the message sender as the completer anyway. + #[deprecated(deny, "Direct invocation of private internal functions is not supported. You attempted to call _prepare_private_balance_increase. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn _prepare_private_balance_increase(to: AztecAddress) -> PartialUintNote; + + /// Finalizes a transfer of token `amount` from public balance of `msg_sender` to a private balance of `to`. + /// The transfer must be prepared by calling `prepare_private_balance_increase` from `msg_sender` account and + /// the resulting `partial_note` must be passed as an argument to this function. + /// + /// Note that this contract does not protect against a `partial_note` being used multiple times and it is up to + /// the caller of this function to ensure that it doesn't happen. If the same `partial_note` is used multiple + /// times, the token `amount` would most likely get lost (the partial note log processing functionality would fail + /// to find the pending partial note when trying to complete it). + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call finalize_transfer_to_private. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn finalize_transfer_to_private(amount: u128, partial_note: PartialUintNote); + + /// Finalizes a transfer of token `amount` from private balance of `from` to a private balance of `to`. + /// The transfer must be prepared by calling `prepare_private_balance_increase` from `from` account and + /// the resulting `partial_note` must be passed as an argument to this function. + /// + /// Note that this contract does not protect against a `partial_note` being used multiple times and it is up to + /// the caller of this function to ensure that it doesn't happen. If the same `partial_note` is used multiple + /// times, the token `amount` would most likely get lost (the partial note log processing functionality would fail + /// to find the pending partial note when trying to complete it). + #[deprecated(deny, "Direct invocation of private functions is not supported. You attempted to call finalize_transfer_to_private_from_private. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn finalize_transfer_to_private_from_private(from: AztecAddress, partial_note: PartialUintNote, amount: u128, authwit_nonce: Field); + + /// This is a wrapper around `_finalize_transfer_to_private` placed here so that a call + /// to `_finalize_transfer_to_private` can be enqueued. Called unsafe as it does not check `from_and_completer` + /// (this has to be done in the calling function). + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call _finalize_transfer_to_private_unsafe. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn _finalize_transfer_to_private_unsafe(from_and_completer: AztecAddress, amount: u128, partial_note: PartialUintNote); + + #[deprecated(deny, "Direct invocation of public internal functions is not supported. You attempted to call _finalize_transfer_to_private. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn _finalize_transfer_to_private(from_and_completer: AztecAddress, amount: u128, partial_note: PartialUintNote); + + /// Mints token `amount` to a private balance of `to`. Message sender has to have minter permissions (checked + /// in the enqueued call). + #[deprecated(deny, "Direct invocation of private functions is not supported. You attempted to call mint_to_private. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn mint_to_private(to: AztecAddress, amount: u128); + + /// Finalizes a mint of token `amount` to a private balance of `to`. The mint must be prepared by calling + /// `prepare_private_balance_increase` first and the resulting + /// `partial_note` must be passed as an argument to this function. + /// + /// Note: This function is only an optimization as it could be replaced by a combination of `mint_to_public` + /// and `finalize_transfer_to_private`. It is however used very commonly so it makes sense to optimize it + /// (e.g. used during token bridging, in AMM liquidity token etc.). + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call finalize_mint_to_private. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn finalize_mint_to_private(amount: u128, partial_note: PartialUintNote); + + /// This is a wrapper around `_finalize_mint_to_private` placed here so that a call + /// to `_finalize_mint_to_private` can be enqueued. Called unsafe as it does not check `minter_and_completer` (this + /// has to be done in the calling function). + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call _finalize_mint_to_private_unsafe. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn _finalize_mint_to_private_unsafe(minter_and_completer: AztecAddress, amount: u128, partial_note: PartialUintNote); + + #[deprecated(deny, "Direct invocation of public internal functions is not supported. You attempted to call _finalize_mint_to_private. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn _finalize_mint_to_private(completer: AztecAddress, amount: u128, partial_note: PartialUintNote); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call _increase_public_balance. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn _increase_public_balance(to: AztecAddress, amount: u128); + + #[deprecated(deny, "Direct invocation of public functions is not supported. You attempted to call _reduce_total_supply. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + fn _reduce_total_supply(amount: u128); + + #[deprecated(deny, "Direct invocation of utility functions is not supported. You attempted to call balance_of_private. See https://docs.aztec.network/errors/6")] + #[contract_library_method] + unconstrained fn balance_of_private(owner: AztecAddress) -> u128; + + /// Unpacks an array into a note corresponding to `note_type_id` and then computes its note hash (non-siloed) and inner nullifier (non-siloed) assuming the note has been inserted into the note hash tree with `note_nonce`. + /// + /// This function is automatically injected by the `#[aztec]` macro. + #[contract_library_method] + #[allow(dead_code)] + unconstrained fn _compute_note_hash_and_nullifier(packed_note: BoundedVec, owner: AztecAddress, storage_slot: Field, note_type_id: Field, contract_address: AztecAddress, randomness: Field, note_nonce: Field) -> Option { + _compute_note_hash(packed_note, owner, storage_slot, note_type_id, contract_address, randomness).map(|note_hash: Field| -> aztec::messages::discovery::NoteHashAndNullifier { + let siloed_note_hash: Field = aztec::protocol::hash::compute_siloed_note_hash(contract_address, note_hash); + let unique_note_hash: Field = aztec::protocol::hash::compute_unique_note_hash(note_nonce, siloed_note_hash); + let inner_nullifier: Option = _compute_note_nullifier(unique_note_hash, packed_note, owner, storage_slot, note_type_id, contract_address, randomness); + aztec::messages::discovery::NoteHashAndNullifier { note_hash: note_hash, inner_nullifier: inner_nullifier} + }) + } + + /// Unpacks an array into a note corresponding to `note_type_id` and then computes its note hash (non-siloed). + /// + /// The signature of this function notably matches the `aztec::messages::discovery::ComputeNoteHash` type, and so it can be used to call functions from that module such as `do_sync_state` and `attempt_note_discovery`. + /// + /// This function is automatically injected by the `#[aztec]` macro. + #[contract_library_method] + unconstrained fn _compute_note_hash(packed_note: BoundedVec, owner: AztecAddress, storage_slot: Field, note_type_id: Field, _contract_address: AztecAddress, randomness: Field) -> Option { + if note_type_id == ::get_id() { + let expected_len: u32 = ::N; + let actual_len: u32 = packed_note.len(); + if actual_len != expected_len { + (|args: [Field; 3]| aztec::oracle::logging::warn_log_format("[aztec-nr] Packed note length mismatch for note type id {0}: expected {1} fields, got {2}. Skipping note.", args))([note_type_id, expected_len as Field, actual_len as Field]); + Option::::none() + } else { + let note: UintNote = ::unpack(aztec::utils::array::subarray::subarray(packed_note.storage(), 0_u32)); + Option::::some(::compute_note_hash(note, owner, storage_slot, randomness)) + } + } else { + (|args: [Field; 1]| aztec::oracle::logging::warn_log_format("[aztec-nr] Unknown note type id {0}. Skipping note.", args))([note_type_id]); + Option::::none() + } + } + + /// Computes a note's inner nullifier (non-siloed) given its unique note hash, preimage and extra data. + /// + /// The signature of this function notably matches the `aztec::messages::discovery::ComputeNoteNullifier` type, and so it can be used to call functions from that module such as `do_sync_state` and `attempt_note_discovery`. + /// + /// This function is automatically injected by the `#[aztec]` macro. + #[contract_library_method] + unconstrained fn _compute_note_nullifier(unique_note_hash: Field, packed_note: BoundedVec, owner: AztecAddress, _storage_slot: Field, note_type_id: Field, _contract_address: AztecAddress, _randomness: Field) -> Option { + if note_type_id == ::get_id() { + let expected_len: u32 = ::N; + let actual_len: u32 = packed_note.len(); + if actual_len != expected_len { + (|args: [Field; 3]| aztec::oracle::logging::warn_log_format("[aztec-nr] Packed note length mismatch for note type id {0}: expected {1} fields, got {2}. Skipping note.", args))([note_type_id, expected_len as Field, actual_len as Field]); + Option::::none() + } else { + let note: UintNote = ::unpack(aztec::utils::array::subarray::subarray(packed_note.storage(), 0_u32)); + ::compute_nullifier_unconstrained(note, owner, unique_note_hash) + } + } else { + (|args: [Field; 1]| aztec::oracle::logging::warn_log_format("[aztec-nr] Unknown note type id {0}. Skipping note.", args))([note_type_id]); + Option::::none() + } + } + + /// Receives offchain messages into this contract's offchain inbox for subsequent processing. + /// + /// Each message is routed to the inbox scoped to its `recipient` field. + /// + /// For more details, see `aztec::messages::processing::offchain::receive`. + /// + /// This function is automatically injected by the `#[aztec]` macro. + unconstrained fn offchain_receive(messages: BoundedVec) { + let address: AztecAddress = aztec::context::UtilityContext::new().this_address(); + aztec::messages::processing::offchain::receive(address, messages); + } + + pub struct Token { + pub target_contract: AztecAddress, + } + + impl Token { + pub fn storage_layout() -> StorageLayoutFields { + STORAGE_LAYOUT_Token.fields + } + + pub fn at(addr: AztecAddress) -> Self { + Self { target_contract: addr} + } + + pub fn interface() -> Self { + Self { target_contract: AztecAddress::zero()} + } + + pub fn burn_public(self, from: AztecAddress, amount: u128, authwit_nonce: Field) -> aztec::context::calls::PublicCall<11, 3, ()> { + let mut serialized_params: [Field; 3] = [0_Field; 3]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(from); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3323048133_Field); + aztec::context::calls::PublicCall::<11, 3, ()>::new(self.target_contract, selector, "burn_public", serialized_params) + } + + pub fn transfer(self, to: AztecAddress, amount: u128) -> PrivateCall<8, 2, ()> { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1968158567_Field); + PrivateCall::<8, 2, ()>::new(self.target_contract, selector, "transfer", serialized_params) + } + + pub fn finalize_transfer_to_private_from_private(self, from: AztecAddress, partial_note: PartialUintNote, amount: u128, authwit_nonce: Field) -> PrivateCall<41, 4, ()> { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(from); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(4221842038_Field); + PrivateCall::<41, 4, ()>::new(self.target_contract, selector, "finalize_transfer_to_private_from_private", serialized_params) + } + + pub fn mint_to_public(self, to: AztecAddress, amount: u128) -> aztec::context::calls::PublicCall<14, 2, ()> { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1159421870_Field); + aztec::context::calls::PublicCall::<14, 2, ()>::new(self.target_contract, selector, "mint_to_public", serialized_params) + } + + pub fn is_minter(self, minter: AztecAddress) -> aztec::context::calls::PublicStaticCall<9, 1, bool> { + let serialized_params: [Field; 1] = ::serialize(minter); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3315237398_Field); + aztec::context::calls::PublicStaticCall::<9, 1, bool>::new(self.target_contract, selector, "is_minter", serialized_params) + } + + pub fn cancel_authwit(self, inner_hash: Field) -> PrivateCall<14, 1, ()> { + let serialized_params: [Field; 1] = ::serialize(inner_hash); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3755840242_Field); + PrivateCall::<14, 1, ()>::new(self.target_contract, selector, "cancel_authwit", serialized_params) + } + + pub fn set_admin(self, new_admin: AztecAddress) -> aztec::context::calls::PublicCall<9, 1, ()> { + let serialized_params: [Field; 1] = ::serialize(new_admin); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2519591682_Field); + aztec::context::calls::PublicCall::<9, 1, ()>::new(self.target_contract, selector, "set_admin", serialized_params) + } + + pub fn total_supply(self) -> aztec::context::calls::PublicStaticCall<12, 0, u128> { + let serialized_params: [Field; 0] = []; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2379449068_Field); + aztec::context::calls::PublicStaticCall::<12, 0, u128>::new(self.target_contract, selector, "total_supply", serialized_params) + } + + pub fn private_get_decimals(self) -> aztec::context::calls::PrivateStaticCall<20, 0, u8> { + let serialized_params: [Field; 0] = []; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2520508119_Field); + aztec::context::calls::PrivateStaticCall::<20, 0, u8>::new(self.target_contract, selector, "private_get_decimals", serialized_params) + } + + pub fn get_admin(self) -> aztec::context::calls::PublicStaticCall<9, 0, Field> { + let serialized_params: [Field; 0] = []; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(722579866_Field); + aztec::context::calls::PublicStaticCall::<9, 0, Field>::new(self.target_contract, selector, "get_admin", serialized_params) + } + + pub fn transfer_to_public(self, from: AztecAddress, to: AztecAddress, amount: u128, authwit_nonce: Field) -> PrivateCall<18, 4, ()> { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(from); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3880081865_Field); + PrivateCall::<18, 4, ()>::new(self.target_contract, selector, "transfer_to_public", serialized_params) + } + + pub fn transfer_in_private_with_offchain_delivery(self, from: AztecAddress, to: AztecAddress, amount: u128, authwit_nonce: Field) -> PrivateCall<42, 4, ()> { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(from); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2994585803_Field); + PrivateCall::<42, 4, ()>::new(self.target_contract, selector, "transfer_in_private_with_offchain_delivery", serialized_params) + } + + pub fn mint_to_private(self, to: AztecAddress, amount: u128) -> PrivateCall<15, 2, ()> { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(4177019161_Field); + PrivateCall::<15, 2, ()>::new(self.target_contract, selector, "mint_to_private", serialized_params) + } + + pub fn transfer_to_private(self, to: AztecAddress, amount: u128) -> PrivateCall<19, 2, ()> { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2306181952_Field); + PrivateCall::<19, 2, ()>::new(self.target_contract, selector, "transfer_to_private", serialized_params) + } + + pub fn public_get_name(self) -> aztec::context::calls::PublicStaticCall<15, 0, FieldCompressedString> { + let serialized_params: [Field; 0] = []; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3367753652_Field); + aztec::context::calls::PublicStaticCall::<15, 0, FieldCompressedString>::new(self.target_contract, selector, "public_get_name", serialized_params) + } + + pub fn _recurse_subtract_balance(self, account: AztecAddress, amount: u128) -> PrivateCall<25, 2, u128> { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(account); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1536394406_Field); + PrivateCall::<25, 2, u128>::new(self.target_contract, selector, "_recurse_subtract_balance", serialized_params) + } + + pub fn _finalize_transfer_to_private_unsafe(self, from_and_completer: AztecAddress, amount: u128, partial_note: PartialUintNote) -> aztec::context::calls::PublicCall<36, 3, ()> { + let mut serialized_params: [Field; 3] = [0_Field; 3]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(from_and_completer); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1930102437_Field); + aztec::context::calls::PublicCall::<36, 3, ()>::new(self.target_contract, selector, "_finalize_transfer_to_private_unsafe", serialized_params) + } + + pub fn constructor(self, admin: AztecAddress, name: str<31>, symbol: str<31>, decimals: u8) -> aztec::context::calls::PublicCall<11, 64, ()> { + let mut serialized_params: [Field; 64] = [0_Field; 64]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(admin); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 31] = as aztec::protocol::traits::Serialize>::serialize(name); + let serialized_member_len: u32 = as aztec::protocol::traits::Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 31] = as aztec::protocol::traits::Serialize>::serialize(symbol); + let serialized_member_len: u32 = as aztec::protocol::traits::Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(decimals); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1578322623_Field); + aztec::context::calls::PublicCall::<11, 64, ()>::new(self.target_contract, selector, "constructor", serialized_params) + } + + pub fn finalize_transfer_to_private(self, amount: u128, partial_note: PartialUintNote) -> aztec::context::calls::PublicCall<28, 2, ()> { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2599745508_Field); + aztec::context::calls::PublicCall::<28, 2, ()>::new(self.target_contract, selector, "finalize_transfer_to_private", serialized_params) + } + + pub fn finalize_mint_to_private(self, amount: u128, partial_note: PartialUintNote) -> aztec::context::calls::PublicCall<24, 2, ()> { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1065137297_Field); + aztec::context::calls::PublicCall::<24, 2, ()>::new(self.target_contract, selector, "finalize_mint_to_private", serialized_params) + } + + pub fn _reduce_total_supply(self, amount: u128) -> aztec::context::calls::PublicCall<20, 1, ()> { + let serialized_params: [Field; 1] = ::serialize(amount); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2253390209_Field); + aztec::context::calls::PublicCall::<20, 1, ()>::new(self.target_contract, selector, "_reduce_total_supply", serialized_params) + } + + pub fn transfer_in_public(self, from: AztecAddress, to: AztecAddress, amount: u128, authwit_nonce: Field) -> aztec::context::calls::PublicCall<18, 4, ()> { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(from); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2359186546_Field); + aztec::context::calls::PublicCall::<18, 4, ()>::new(self.target_contract, selector, "transfer_in_public", serialized_params) + } + + pub fn prepare_private_balance_increase(self, to: AztecAddress) -> PrivateCall<32, 1, PartialUintNote> { + let serialized_params: [Field; 1] = ::serialize(to); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1824243228_Field); + PrivateCall::<32, 1, PartialUintNote>::new(self.target_contract, selector, "prepare_private_balance_increase", serialized_params) + } + + pub fn transfer_to_public_and_prepare_private_balance_increase(self, from: AztecAddress, to: AztecAddress, amount: u128, authwit_nonce: Field) -> PrivateCall<55, 4, PartialUintNote> { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(from); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2936463891_Field); + PrivateCall::<55, 4, PartialUintNote>::new(self.target_contract, selector, "transfer_to_public_and_prepare_private_balance_increase", serialized_params) + } + + pub fn balance_of_public(self, owner: AztecAddress) -> aztec::context::calls::PublicStaticCall<17, 1, u128> { + let serialized_params: [Field; 1] = ::serialize(owner); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(4286138866_Field); + aztec::context::calls::PublicStaticCall::<17, 1, u128>::new(self.target_contract, selector, "balance_of_public", serialized_params) + } + + pub fn set_minter(self, minter: AztecAddress, approve: bool) -> aztec::context::calls::PublicCall<10, 2, ()> { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(minter); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(approve); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1957439757_Field); + aztec::context::calls::PublicCall::<10, 2, ()>::new(self.target_contract, selector, "set_minter", serialized_params) + } + + pub fn _finalize_mint_to_private_unsafe(self, minter_and_completer: AztecAddress, amount: u128, partial_note: PartialUintNote) -> aztec::context::calls::PublicCall<32, 3, ()> { + let mut serialized_params: [Field; 3] = [0_Field; 3]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(minter_and_completer); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(4058507562_Field); + aztec::context::calls::PublicCall::<32, 3, ()>::new(self.target_contract, selector, "_finalize_mint_to_private_unsafe", serialized_params) + } + + pub fn private_get_symbol(self) -> aztec::context::calls::PrivateStaticCall<18, 0, FieldCompressedString> { + let serialized_params: [Field; 0] = []; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1295669651_Field); + aztec::context::calls::PrivateStaticCall::<18, 0, FieldCompressedString>::new(self.target_contract, selector, "private_get_symbol", serialized_params) + } + + pub fn private_get_name(self) -> aztec::context::calls::PrivateStaticCall<16, 0, FieldCompressedString> { + let serialized_params: [Field; 0] = []; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3516522363_Field); + aztec::context::calls::PrivateStaticCall::<16, 0, FieldCompressedString>::new(self.target_contract, selector, "private_get_name", serialized_params) + } + + pub fn transfer_in_private(self, from: AztecAddress, to: AztecAddress, amount: u128, authwit_nonce: Field) -> PrivateCall<19, 4, ()> { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(from); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3610465468_Field); + PrivateCall::<19, 4, ()>::new(self.target_contract, selector, "transfer_in_private", serialized_params) + } + + pub fn public_get_decimals(self) -> aztec::context::calls::PublicStaticCall<19, 0, u8> { + let serialized_params: [Field; 0] = []; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1613003496_Field); + aztec::context::calls::PublicStaticCall::<19, 0, u8>::new(self.target_contract, selector, "public_get_decimals", serialized_params) + } + + pub fn burn_private(self, from: AztecAddress, amount: u128, authwit_nonce: Field) -> PrivateCall<12, 3, ()> { + let mut serialized_params: [Field; 3] = [0_Field; 3]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(from); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3263360377_Field); + PrivateCall::<12, 3, ()>::new(self.target_contract, selector, "burn_private", serialized_params) + } + + pub fn _increase_public_balance(self, to: AztecAddress, amount: u128) -> aztec::context::calls::PublicCall<24, 2, ()> { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3891283455_Field); + aztec::context::calls::PublicCall::<24, 2, ()>::new(self.target_contract, selector, "_increase_public_balance", serialized_params) + } + + pub fn public_get_symbol(self) -> aztec::context::calls::PublicStaticCall<17, 0, FieldCompressedString> { + let serialized_params: [Field; 0] = []; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3454394185_Field); + aztec::context::calls::PublicStaticCall::<17, 0, FieldCompressedString>::new(self.target_contract, selector, "public_get_symbol", serialized_params) + } + + pub fn balance_of_private(self, owner: AztecAddress) -> aztec::context::calls::UtilityCall<18, 1, u128> { + let serialized_params: [Field; 1] = ::serialize(owner); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1131770492_Field); + aztec::context::calls::UtilityCall::<18, 1, u128>::new(self.target_contract, selector, "balance_of_private", serialized_params) + } + + pub fn offchain_receive(self, messages: BoundedVec) -> aztec::context::calls::UtilityCall<16, 321, ()> { + let serialized_params: [Field; 321] = as aztec::protocol::traits::Serialize>::serialize(messages); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1396850735_Field); + aztec::context::calls::UtilityCall::<16, 321, ()>::new(self.target_contract, selector, "offchain_receive", serialized_params) + } + } + + #[contract_library_method] + pub fn storage_layout() -> StorageLayoutFields { + STORAGE_LAYOUT_Token.fields + } + + #[contract_library_method] + pub fn at(addr: AztecAddress) -> Token { + Token { target_contract: addr} + } + + #[contract_library_method] + pub fn interface() -> Token { + Token { target_contract: AztecAddress::zero()} + } + + pub struct sync_state_parameters { + pub scope: AztecAddress, + } + + #[abi(functions)] + pub struct sync_state_abi { + parameters: sync_state_parameters, + } + + unconstrained fn sync_state(scope: AztecAddress) { + let address: AztecAddress = aztec::context::UtilityContext::new().this_address(); + aztec::messages::discovery::do_sync_state(address, _compute_note_hash, _compute_note_nullifier, Option::>::none(), Option:: aztec::ephemeral::EphemeralArray>::some(aztec::messages::processing::offchain::sync_inbox), scope); + } + + pub struct offchain_receive_parameters { + pub messages: BoundedVec, + } + + #[abi(functions)] + pub struct offchain_receive_abi { + parameters: offchain_receive_parameters, + } + + pub struct CallSelf { + pub address: AztecAddress, + pub context: Context, + } + + impl CallSelf { + pub fn burn_public(self, from: AztecAddress, amount: u128, authwit_nonce: Field) { + let mut serialized_params: [Field; 3] = [0_Field; 3]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(from); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3323048133_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<11, 3, ()>::new(self.address, selector, "burn_public", serialized_params).call(self.context) + } + } + + pub fn _finalize_transfer_to_private_unsafe(self, from_and_completer: AztecAddress, amount: u128, partial_note: PartialUintNote) { + let mut serialized_params: [Field; 3] = [0_Field; 3]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(from_and_completer); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1930102437_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<36, 3, ()>::new(self.address, selector, "_finalize_transfer_to_private_unsafe", serialized_params).call(self.context) + } + } + + pub fn constructor(self, admin: AztecAddress, name: str<31>, symbol: str<31>, decimals: u8) { + let mut serialized_params: [Field; 64] = [0_Field; 64]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(admin); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 31] = as aztec::protocol::traits::Serialize>::serialize(name); + let serialized_member_len: u32 = as aztec::protocol::traits::Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 31] = as aztec::protocol::traits::Serialize>::serialize(symbol); + let serialized_member_len: u32 = as aztec::protocol::traits::Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(decimals); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1578322623_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<11, 64, ()>::new(self.address, selector, "constructor", serialized_params).call(self.context) + } + } + + pub fn mint_to_public(self, to: AztecAddress, amount: u128) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1159421870_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<14, 2, ()>::new(self.address, selector, "mint_to_public", serialized_params).call(self.context) + } + } + + pub fn finalize_transfer_to_private(self, amount: u128, partial_note: PartialUintNote) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2599745508_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<28, 2, ()>::new(self.address, selector, "finalize_transfer_to_private", serialized_params).call(self.context) + } + } + + pub fn finalize_mint_to_private(self, amount: u128, partial_note: PartialUintNote) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1065137297_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<24, 2, ()>::new(self.address, selector, "finalize_mint_to_private", serialized_params).call(self.context) + } + } + + pub fn transfer_in_public(self, from: AztecAddress, to: AztecAddress, amount: u128, authwit_nonce: Field) { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(from); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2359186546_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<18, 4, ()>::new(self.address, selector, "transfer_in_public", serialized_params).call(self.context) + } + } + + pub fn _reduce_total_supply(self, amount: u128) { + let serialized_params: [Field; 1] = ::serialize(amount); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2253390209_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<20, 1, ()>::new(self.address, selector, "_reduce_total_supply", serialized_params).call(self.context) + } + } + + pub fn set_admin(self, new_admin: AztecAddress) { + let serialized_params: [Field; 1] = ::serialize(new_admin); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2519591682_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<9, 1, ()>::new(self.address, selector, "set_admin", serialized_params).call(self.context) + } + } + + pub fn set_minter(self, minter: AztecAddress, approve: bool) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(minter); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(approve); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1957439757_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<10, 2, ()>::new(self.address, selector, "set_minter", serialized_params).call(self.context) + } + } + + pub fn _finalize_mint_to_private_unsafe(self, minter_and_completer: AztecAddress, amount: u128, partial_note: PartialUintNote) { + let mut serialized_params: [Field; 3] = [0_Field; 3]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(minter_and_completer); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(4058507562_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<32, 3, ()>::new(self.address, selector, "_finalize_mint_to_private_unsafe", serialized_params).call(self.context) + } + } + + pub fn _increase_public_balance(self, to: AztecAddress, amount: u128) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3891283455_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicCall::<24, 2, ()>::new(self.address, selector, "_increase_public_balance", serialized_params).call(self.context) + } + } + } + + impl CallSelf<&mut PrivateContext> { + pub fn _recurse_subtract_balance(self, account: AztecAddress, amount: u128) -> u128 { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(account); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1536394406_Field); + let args_hash: Field = aztec::hash::hash_args(serialized_params); + aztec::oracle::execution_cache::store(serialized_params, args_hash); + let returns_hash: aztec::context::ReturnsHash = self.context.call_private_function_with_args_hash(self.address, selector, args_hash, false); + returns_hash.get_preimage() + } + + pub fn transfer(self, to: AztecAddress, amount: u128) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1968158567_Field); + let args_hash: Field = aztec::hash::hash_args(serialized_params); + aztec::oracle::execution_cache::store(serialized_params, args_hash); + let returns_hash: aztec::context::ReturnsHash = self.context.call_private_function_with_args_hash(self.address, selector, args_hash, false); + returns_hash.get_preimage() + } + + pub fn finalize_transfer_to_private_from_private(self, from: AztecAddress, partial_note: PartialUintNote, amount: u128, authwit_nonce: Field) { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(from); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(4221842038_Field); + let args_hash: Field = aztec::hash::hash_args(serialized_params); + aztec::oracle::execution_cache::store(serialized_params, args_hash); + let returns_hash: aztec::context::ReturnsHash = self.context.call_private_function_with_args_hash(self.address, selector, args_hash, false); + returns_hash.get_preimage() + } + + pub fn prepare_private_balance_increase(self, to: AztecAddress) -> PartialUintNote { + let serialized_params: [Field; 1] = ::serialize(to); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1824243228_Field); + let args_hash: Field = aztec::hash::hash_args(serialized_params); + aztec::oracle::execution_cache::store(serialized_params, args_hash); + let returns_hash: aztec::context::ReturnsHash = self.context.call_private_function_with_args_hash(self.address, selector, args_hash, false); + returns_hash.get_preimage() + } + + pub fn transfer_to_public_and_prepare_private_balance_increase(self, from: AztecAddress, to: AztecAddress, amount: u128, authwit_nonce: Field) -> PartialUintNote { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(from); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2936463891_Field); + let args_hash: Field = aztec::hash::hash_args(serialized_params); + aztec::oracle::execution_cache::store(serialized_params, args_hash); + let returns_hash: aztec::context::ReturnsHash = self.context.call_private_function_with_args_hash(self.address, selector, args_hash, false); + returns_hash.get_preimage() + } + + pub fn cancel_authwit(self, inner_hash: Field) { + let serialized_params: [Field; 1] = ::serialize(inner_hash); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3755840242_Field); + let args_hash: Field = aztec::hash::hash_args(serialized_params); + aztec::oracle::execution_cache::store(serialized_params, args_hash); + let returns_hash: aztec::context::ReturnsHash = self.context.call_private_function_with_args_hash(self.address, selector, args_hash, false); + returns_hash.get_preimage() + } + + pub fn transfer_in_private(self, from: AztecAddress, to: AztecAddress, amount: u128, authwit_nonce: Field) { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(from); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3610465468_Field); + let args_hash: Field = aztec::hash::hash_args(serialized_params); + aztec::oracle::execution_cache::store(serialized_params, args_hash); + let returns_hash: aztec::context::ReturnsHash = self.context.call_private_function_with_args_hash(self.address, selector, args_hash, false); + returns_hash.get_preimage() + } + + pub fn burn_private(self, from: AztecAddress, amount: u128, authwit_nonce: Field) { + let mut serialized_params: [Field; 3] = [0_Field; 3]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(from); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3263360377_Field); + let args_hash: Field = aztec::hash::hash_args(serialized_params); + aztec::oracle::execution_cache::store(serialized_params, args_hash); + let returns_hash: aztec::context::ReturnsHash = self.context.call_private_function_with_args_hash(self.address, selector, args_hash, false); + returns_hash.get_preimage() + } + + pub fn transfer_to_public(self, from: AztecAddress, to: AztecAddress, amount: u128, authwit_nonce: Field) { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(from); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3880081865_Field); + let args_hash: Field = aztec::hash::hash_args(serialized_params); + aztec::oracle::execution_cache::store(serialized_params, args_hash); + let returns_hash: aztec::context::ReturnsHash = self.context.call_private_function_with_args_hash(self.address, selector, args_hash, false); + returns_hash.get_preimage() + } + + pub fn transfer_in_private_with_offchain_delivery(self, from: AztecAddress, to: AztecAddress, amount: u128, authwit_nonce: Field) { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(from); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2994585803_Field); + let args_hash: Field = aztec::hash::hash_args(serialized_params); + aztec::oracle::execution_cache::store(serialized_params, args_hash); + let returns_hash: aztec::context::ReturnsHash = self.context.call_private_function_with_args_hash(self.address, selector, args_hash, false); + returns_hash.get_preimage() + } + + pub fn mint_to_private(self, to: AztecAddress, amount: u128) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(4177019161_Field); + let args_hash: Field = aztec::hash::hash_args(serialized_params); + aztec::oracle::execution_cache::store(serialized_params, args_hash); + let returns_hash: aztec::context::ReturnsHash = self.context.call_private_function_with_args_hash(self.address, selector, args_hash, false); + returns_hash.get_preimage() + } + + pub fn transfer_to_private(self, to: AztecAddress, amount: u128) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2306181952_Field); + let args_hash: Field = aztec::hash::hash_args(serialized_params); + aztec::oracle::execution_cache::store(serialized_params, args_hash); + let returns_hash: aztec::context::ReturnsHash = self.context.call_private_function_with_args_hash(self.address, selector, args_hash, false); + returns_hash.get_preimage() + } + } + + pub struct CallSelfStatic { + pub address: AztecAddress, + pub context: Context, + } + + impl CallSelfStatic { + pub fn balance_of_public(self, owner: AztecAddress) -> u128 { + let serialized_params: [Field; 1] = ::serialize(owner); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(4286138866_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicStaticCall::<17, 1, u128>::new(self.address, selector, "balance_of_public", serialized_params).view(self.context) + } + } + + pub fn total_supply(self) -> u128 { + let serialized_params: [Field; 0] = []; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2379449068_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicStaticCall::<12, 0, u128>::new(self.address, selector, "total_supply", serialized_params).view(self.context) + } + } + + pub fn public_get_name(self) -> FieldCompressedString { + let serialized_params: [Field; 0] = []; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3367753652_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicStaticCall::<15, 0, FieldCompressedString>::new(self.address, selector, "public_get_name", serialized_params).view(self.context) + } + } + + pub fn public_get_decimals(self) -> u8 { + let serialized_params: [Field; 0] = []; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1613003496_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicStaticCall::<19, 0, u8>::new(self.address, selector, "public_get_decimals", serialized_params).view(self.context) + } + } + + pub fn get_admin(self) -> Field { + let serialized_params: [Field; 0] = []; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(722579866_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicStaticCall::<9, 0, Field>::new(self.address, selector, "get_admin", serialized_params).view(self.context) + } + } + + pub fn public_get_symbol(self) -> FieldCompressedString { + let serialized_params: [Field; 0] = []; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3454394185_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicStaticCall::<17, 0, FieldCompressedString>::new(self.address, selector, "public_get_symbol", serialized_params).view(self.context) + } + } + + pub fn is_minter(self, minter: AztecAddress) -> bool { + let serialized_params: [Field; 1] = ::serialize(minter); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3315237398_Field); + // Safety: comment added by `nargo expand` + unsafe { + aztec::context::calls::PublicStaticCall::<9, 1, bool>::new(self.address, selector, "is_minter", serialized_params).view(self.context) + } + } + } + + impl CallSelfStatic<&mut PrivateContext> { + pub fn private_get_name(self) -> FieldCompressedString { + let serialized_params: [Field; 0] = []; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3516522363_Field); + let args_hash: Field = aztec::hash::hash_args(serialized_params); + aztec::oracle::execution_cache::store(serialized_params, args_hash); + let returns_hash: aztec::context::ReturnsHash = self.context.call_private_function_with_args_hash(self.address, selector, args_hash, true); + returns_hash.get_preimage() + } + + pub fn private_get_symbol(self) -> FieldCompressedString { + let serialized_params: [Field; 0] = []; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1295669651_Field); + let args_hash: Field = aztec::hash::hash_args(serialized_params); + aztec::oracle::execution_cache::store(serialized_params, args_hash); + let returns_hash: aztec::context::ReturnsHash = self.context.call_private_function_with_args_hash(self.address, selector, args_hash, true); + returns_hash.get_preimage() + } + + pub fn private_get_decimals(self) -> u8 { + let serialized_params: [Field; 0] = []; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2520508119_Field); + let args_hash: Field = aztec::hash::hash_args(serialized_params); + aztec::oracle::execution_cache::store(serialized_params, args_hash); + let returns_hash: aztec::context::ReturnsHash = self.context.call_private_function_with_args_hash(self.address, selector, args_hash, true); + returns_hash.get_preimage() + } + } + + pub struct EnqueueSelf { + pub address: AztecAddress, + pub context: Context, + } + + impl EnqueueSelf<&mut PrivateContext> { + pub fn set_minter(self, minter: AztecAddress, approve: bool) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(minter); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(approve); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1957439757_Field); + let calldata: [Field; 1 + 2] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn burn_public(self, from: AztecAddress, amount: u128, authwit_nonce: Field) { + let mut serialized_params: [Field; 3] = [0_Field; 3]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(from); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3323048133_Field); + let calldata: [Field; 1 + 3] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn _finalize_transfer_to_private_unsafe(self, from_and_completer: AztecAddress, amount: u128, partial_note: PartialUintNote) { + let mut serialized_params: [Field; 3] = [0_Field; 3]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(from_and_completer); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1930102437_Field); + let calldata: [Field; 1 + 3] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn _finalize_mint_to_private_unsafe(self, minter_and_completer: AztecAddress, amount: u128, partial_note: PartialUintNote) { + let mut serialized_params: [Field; 3] = [0_Field; 3]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(minter_and_completer); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(4058507562_Field); + let calldata: [Field; 1 + 3] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn mint_to_public(self, to: AztecAddress, amount: u128) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1159421870_Field); + let calldata: [Field; 1 + 2] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn finalize_transfer_to_private(self, amount: u128, partial_note: PartialUintNote) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2599745508_Field); + let calldata: [Field; 1 + 2] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn constructor(self, admin: AztecAddress, name: str<31>, symbol: str<31>, decimals: u8) { + let mut serialized_params: [Field; 64] = [0_Field; 64]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(admin); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 31] = as aztec::protocol::traits::Serialize>::serialize(name); + let serialized_member_len: u32 = as aztec::protocol::traits::Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 31] = as aztec::protocol::traits::Serialize>::serialize(symbol); + let serialized_member_len: u32 = as aztec::protocol::traits::Serialize>::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(decimals); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1578322623_Field); + let calldata: [Field; 1 + 64] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn finalize_mint_to_private(self, amount: u128, partial_note: PartialUintNote) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1065137297_Field); + let calldata: [Field; 1 + 2] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn _increase_public_balance(self, to: AztecAddress, amount: u128) { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3891283455_Field); + let calldata: [Field; 1 + 2] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn transfer_in_public(self, from: AztecAddress, to: AztecAddress, amount: u128, authwit_nonce: Field) { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(from); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2359186546_Field); + let calldata: [Field; 1 + 4] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn _reduce_total_supply(self, amount: u128) { + let serialized_params: [Field; 1] = ::serialize(amount); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2253390209_Field); + let calldata: [Field; 1 + 1] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + + pub fn set_admin(self, new_admin: AztecAddress) { + let serialized_params: [Field; 1] = ::serialize(new_admin); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2519591682_Field); + let calldata: [Field; 1 + 1] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, false, false); + } + } + + pub struct EnqueueSelfStatic { + pub address: AztecAddress, + pub context: Context, + } + + impl EnqueueSelfStatic<&mut PrivateContext> { + pub fn public_get_name(self) { + let serialized_params: [Field; 0] = []; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3367753652_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, true, false); + } + + pub fn public_get_decimals(self) { + let serialized_params: [Field; 0] = []; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1613003496_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, true, false); + } + + pub fn get_admin(self) { + let serialized_params: [Field; 0] = []; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(722579866_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, true, false); + } + + pub fn balance_of_public(self, owner: AztecAddress) { + let serialized_params: [Field; 1] = ::serialize(owner); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(4286138866_Field); + let calldata: [Field; 1 + 1] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, true, false); + } + + pub fn total_supply(self) { + let serialized_params: [Field; 0] = []; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(2379449068_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, true, false); + } + + pub fn public_get_symbol(self) { + let serialized_params: [Field; 0] = []; + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3454394185_Field); + let calldata: [Field; 1 + 0] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, true, false); + } + + pub fn is_minter(self, minter: AztecAddress) { + let serialized_params: [Field; 1] = ::serialize(minter); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(3315237398_Field); + let calldata: [Field; 1 + 1] = [selector.to_field()].concat(serialized_params); + let calldata_hash: Field = aztec::hash::hash_calldata_array(calldata); + aztec::oracle::execution_cache::store(calldata, calldata_hash); + self.context.call_public_function_with_calldata_hash(self.address, calldata_hash, true, false); + } + } + + pub struct CallSelfUtility { + pub address: AztecAddress, + } + + impl CallSelfUtility { + pub unconstrained fn balance_of_private(self, owner: AztecAddress) -> u128 { + let serialized_params: [Field; 1] = ::serialize(owner); + let selector: aztec::protocol::abis::function_selector::FunctionSelector = ::from_field(1131770492_Field); + let returns: [Field; 1] = aztec::oracle::call_utility_function::call_utility_function(self.address, selector, serialized_params); + ::deserialize(returns) + } + } + + pub struct CallInternal { + pub context: Context, + } + + impl CallInternal { + pub unconstrained fn _finalize_mint_to_private(self, completer: AztecAddress, amount: u128, partial_note: PartialUintNote) { + __aztec_nr_internals___finalize_mint_to_private(self.context, completer, amount, partial_note) + } + + pub unconstrained fn _finalize_transfer_to_private(self, from_and_completer: AztecAddress, amount: u128, partial_note: PartialUintNote) { + __aztec_nr_internals___finalize_transfer_to_private(self.context, from_and_completer, amount, partial_note) + } + } + + impl CallInternal<&mut PrivateContext> { + pub fn subtract_balance(self, account: AztecAddress, amount: u128, max_notes: u32) -> u128 { + __aztec_nr_internals__subtract_balance(self.context, account, amount, max_notes) + } + + pub fn _prepare_private_balance_increase(self, to: AztecAddress) -> PartialUintNote { + __aztec_nr_internals___prepare_private_balance_increase(self.context, to) + } + } + + pub unconstrained fn public_dispatch(selector: Field) { + if selector == 1578322623_Field { + let input_calldata: [Field; 64] = aztec::oracle::avm::calldata_copy(1_u32, ((::N + as aztec::protocol::traits::Serialize>::N) + as aztec::protocol::traits::Serialize>::N) + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<64> = aztec::protocol::utils::reader::Reader::<64>::new(input_calldata); + let arg0: AztecAddress = ::stream_deserialize(&mut reader); + let arg1: str<31> = as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let arg2: str<31> = as aztec::protocol::traits::Deserialize>::stream_deserialize(&mut reader); + let arg3: u8 = ::stream_deserialize(&mut reader); + __aztec_nr_internals__constructor(arg0, arg1, arg2, arg3); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 2519591682_Field { + let input_calldata: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + let mut reader: aztec::protocol::utils::reader::Reader<1> = aztec::protocol::utils::reader::Reader::<1>::new(input_calldata); + let arg0: AztecAddress = ::stream_deserialize(&mut reader); + __aztec_nr_internals__set_admin(arg0); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 3367753652_Field { + let return_value: [Field; 1] = ::serialize(__aztec_nr_internals__public_get_name()); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 3454394185_Field { + let return_value: [Field; 1] = ::serialize(__aztec_nr_internals__public_get_symbol()); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 1613003496_Field { + let return_value: [Field; 1] = ::serialize(__aztec_nr_internals__public_get_decimals()); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 722579866_Field { + let return_value: [Field; 1] = ::serialize(__aztec_nr_internals__get_admin()); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 3315237398_Field { + let input_calldata: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + let mut reader: aztec::protocol::utils::reader::Reader<1> = aztec::protocol::utils::reader::Reader::<1>::new(input_calldata); + let arg0: AztecAddress = ::stream_deserialize(&mut reader); + let return_value: [Field; 1] = ::serialize(__aztec_nr_internals__is_minter(arg0)); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 2379449068_Field { + let return_value: [Field; 1] = ::serialize(__aztec_nr_internals__total_supply()); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 4286138866_Field { + let input_calldata: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + let mut reader: aztec::protocol::utils::reader::Reader<1> = aztec::protocol::utils::reader::Reader::<1>::new(input_calldata); + let arg0: AztecAddress = ::stream_deserialize(&mut reader); + let return_value: [Field; 1] = ::serialize(__aztec_nr_internals__balance_of_public(arg0)); + aztec::oracle::avm::avm_return(return_value.as_vector()); + }; + if selector == 1957439757_Field { + let input_calldata: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<2> = aztec::protocol::utils::reader::Reader::<2>::new(input_calldata); + let arg0: AztecAddress = ::stream_deserialize(&mut reader); + let arg1: bool = ::stream_deserialize(&mut reader); + __aztec_nr_internals__set_minter(arg0, arg1); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 1159421870_Field { + let input_calldata: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<2> = aztec::protocol::utils::reader::Reader::<2>::new(input_calldata); + let arg0: AztecAddress = ::stream_deserialize(&mut reader); + let arg1: u128 = ::stream_deserialize(&mut reader); + __aztec_nr_internals__mint_to_public(arg0, arg1); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 2359186546_Field { + let input_calldata: [Field; 4] = aztec::oracle::avm::calldata_copy(1_u32, ((::N + ::N) + ::N) + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<4> = aztec::protocol::utils::reader::Reader::<4>::new(input_calldata); + let arg0: AztecAddress = ::stream_deserialize(&mut reader); + let arg1: AztecAddress = ::stream_deserialize(&mut reader); + let arg2: u128 = ::stream_deserialize(&mut reader); + let arg3: Field = ::stream_deserialize(&mut reader); + __aztec_nr_internals__transfer_in_public(arg0, arg1, arg2, arg3); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 3323048133_Field { + let input_calldata: [Field; 3] = aztec::oracle::avm::calldata_copy(1_u32, (::N + ::N) + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<3> = aztec::protocol::utils::reader::Reader::<3>::new(input_calldata); + let arg0: AztecAddress = ::stream_deserialize(&mut reader); + let arg1: u128 = ::stream_deserialize(&mut reader); + let arg2: Field = ::stream_deserialize(&mut reader); + __aztec_nr_internals__burn_public(arg0, arg1, arg2); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 2599745508_Field { + let input_calldata: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<2> = aztec::protocol::utils::reader::Reader::<2>::new(input_calldata); + let arg0: u128 = ::stream_deserialize(&mut reader); + let arg1: PartialUintNote = ::stream_deserialize(&mut reader); + __aztec_nr_internals__finalize_transfer_to_private(arg0, arg1); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 1930102437_Field { + let input_calldata: [Field; 3] = aztec::oracle::avm::calldata_copy(1_u32, (::N + ::N) + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<3> = aztec::protocol::utils::reader::Reader::<3>::new(input_calldata); + let arg0: AztecAddress = ::stream_deserialize(&mut reader); + let arg1: u128 = ::stream_deserialize(&mut reader); + let arg2: PartialUintNote = ::stream_deserialize(&mut reader); + __aztec_nr_internals___finalize_transfer_to_private_unsafe(arg0, arg1, arg2); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 1065137297_Field { + let input_calldata: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<2> = aztec::protocol::utils::reader::Reader::<2>::new(input_calldata); + let arg0: u128 = ::stream_deserialize(&mut reader); + let arg1: PartialUintNote = ::stream_deserialize(&mut reader); + __aztec_nr_internals__finalize_mint_to_private(arg0, arg1); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 4058507562_Field { + let input_calldata: [Field; 3] = aztec::oracle::avm::calldata_copy(1_u32, (::N + ::N) + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<3> = aztec::protocol::utils::reader::Reader::<3>::new(input_calldata); + let arg0: AztecAddress = ::stream_deserialize(&mut reader); + let arg1: u128 = ::stream_deserialize(&mut reader); + let arg2: PartialUintNote = ::stream_deserialize(&mut reader); + __aztec_nr_internals___finalize_mint_to_private_unsafe(arg0, arg1, arg2); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 3891283455_Field { + let input_calldata: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + let mut reader: aztec::protocol::utils::reader::Reader<2> = aztec::protocol::utils::reader::Reader::<2>::new(input_calldata); + let arg0: AztecAddress = ::stream_deserialize(&mut reader); + let arg1: u128 = ::stream_deserialize(&mut reader); + __aztec_nr_internals___increase_public_balance(arg0, arg1); + aztec::oracle::avm::avm_return([].as_slice()); + }; + if selector == 2253390209_Field { + let input_calldata: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + let mut reader: aztec::protocol::utils::reader::Reader<1> = aztec::protocol::utils::reader::Reader::<1>::new(input_calldata); + let arg0: u128 = ::stream_deserialize(&mut reader); + __aztec_nr_internals___reduce_total_supply(arg0); + aztec::oracle::avm::avm_return([].as_slice()); + }; + panic(f"Unknown selector {selector}") + } + + pub struct _finalize_mint_to_private_unsafe_parameters { + pub minter_and_completer: AztecAddress, + pub amount: u128, + pub partial_note: PartialUintNote, + } + + pub struct _finalize_transfer_to_private_unsafe_parameters { + pub from_and_completer: AztecAddress, + pub amount: u128, + pub partial_note: PartialUintNote, + } + + pub struct _increase_public_balance_parameters { + pub to: AztecAddress, + pub amount: u128, + } + + pub struct _recurse_subtract_balance_parameters { + pub account: AztecAddress, + pub amount: u128, + } + + pub struct _reduce_total_supply_parameters { + pub amount: u128, + } + + pub struct balance_of_private_parameters { + pub owner: AztecAddress, + } + + pub struct balance_of_public_parameters { + pub owner: AztecAddress, + } + + pub struct burn_private_parameters { + pub from: AztecAddress, + pub amount: u128, + pub authwit_nonce: Field, + } + + pub struct burn_public_parameters { + pub from: AztecAddress, + pub amount: u128, + pub authwit_nonce: Field, + } + + pub struct cancel_authwit_parameters { + pub inner_hash: Field, + } + + pub struct constructor_parameters { + pub admin: AztecAddress, + pub name: str<31>, + pub symbol: str<31>, + pub decimals: u8, + } + + pub struct finalize_mint_to_private_parameters { + pub amount: u128, + pub partial_note: PartialUintNote, + } + + pub struct finalize_transfer_to_private_from_private_parameters { + pub from: AztecAddress, + pub partial_note: PartialUintNote, + pub amount: u128, + pub authwit_nonce: Field, + } + + pub struct finalize_transfer_to_private_parameters { + pub amount: u128, + pub partial_note: PartialUintNote, + } + + pub struct get_admin_parameters { + } + + pub struct is_minter_parameters { + pub minter: AztecAddress, + } + + pub struct mint_to_private_parameters { + pub to: AztecAddress, + pub amount: u128, + } + + pub struct mint_to_public_parameters { + pub to: AztecAddress, + pub amount: u128, + } + + pub struct prepare_private_balance_increase_parameters { + pub to: AztecAddress, + } + + pub struct private_get_decimals_parameters { + } + + pub struct private_get_name_parameters { + } + + pub struct private_get_symbol_parameters { + } + + pub struct public_get_decimals_parameters { + } + + pub struct public_get_name_parameters { + } + + pub struct public_get_symbol_parameters { + } + + pub struct set_admin_parameters { + pub new_admin: AztecAddress, + } + + pub struct set_minter_parameters { + pub minter: AztecAddress, + pub approve: bool, + } + + pub struct total_supply_parameters { + } + + pub struct transfer_in_private_parameters { + pub from: AztecAddress, + pub to: AztecAddress, + pub amount: u128, + pub authwit_nonce: Field, + } + + pub struct transfer_in_private_with_offchain_delivery_parameters { + pub from: AztecAddress, + pub to: AztecAddress, + pub amount: u128, + pub authwit_nonce: Field, + } + + pub struct transfer_in_public_parameters { + pub from: AztecAddress, + pub to: AztecAddress, + pub amount: u128, + pub authwit_nonce: Field, + } + + pub struct transfer_parameters { + pub to: AztecAddress, + pub amount: u128, + } + + pub struct transfer_to_private_parameters { + pub to: AztecAddress, + pub amount: u128, + } + + pub struct transfer_to_public_and_prepare_private_balance_increase_parameters { + pub from: AztecAddress, + pub to: AztecAddress, + pub amount: u128, + pub authwit_nonce: Field, + } + + pub struct transfer_to_public_parameters { + pub from: AztecAddress, + pub to: AztecAddress, + pub amount: u128, + pub authwit_nonce: Field, + } + + #[abi(functions)] + pub struct _finalize_mint_to_private_unsafe_abi { + parameters: _finalize_mint_to_private_unsafe_parameters, + } + + #[abi(functions)] + pub struct _finalize_transfer_to_private_unsafe_abi { + parameters: _finalize_transfer_to_private_unsafe_parameters, + } + + #[abi(functions)] + pub struct _increase_public_balance_abi { + parameters: _increase_public_balance_parameters, + } + + #[abi(functions)] + pub struct _recurse_subtract_balance_abi { + parameters: _recurse_subtract_balance_parameters, + return_type: u128, + } + + #[abi(functions)] + pub struct _reduce_total_supply_abi { + parameters: _reduce_total_supply_parameters, + } + + #[abi(functions)] + pub struct balance_of_private_abi { + parameters: balance_of_private_parameters, + return_type: u128, + } + + #[abi(functions)] + pub struct balance_of_public_abi { + parameters: balance_of_public_parameters, + return_type: u128, + } + + #[abi(functions)] + pub struct burn_private_abi { + parameters: burn_private_parameters, + } + + #[abi(functions)] + pub struct burn_public_abi { + parameters: burn_public_parameters, + } + + #[abi(functions)] + pub struct cancel_authwit_abi { + parameters: cancel_authwit_parameters, + } + + #[abi(functions)] + pub struct constructor_abi { + parameters: constructor_parameters, + } + + #[abi(functions)] + pub struct finalize_mint_to_private_abi { + parameters: finalize_mint_to_private_parameters, + } + + #[abi(functions)] + pub struct finalize_transfer_to_private_abi { + parameters: finalize_transfer_to_private_parameters, + } + + #[abi(functions)] + pub struct finalize_transfer_to_private_from_private_abi { + parameters: finalize_transfer_to_private_from_private_parameters, + } + + #[abi(functions)] + pub struct get_admin_abi { + parameters: get_admin_parameters, + return_type: Field, + } + + #[abi(functions)] + pub struct is_minter_abi { + parameters: is_minter_parameters, + return_type: bool, + } + + #[abi(functions)] + pub struct mint_to_private_abi { + parameters: mint_to_private_parameters, + } + + #[abi(functions)] + pub struct mint_to_public_abi { + parameters: mint_to_public_parameters, + } + + #[abi(functions)] + pub struct prepare_private_balance_increase_abi { + parameters: prepare_private_balance_increase_parameters, + return_type: PartialUintNote, + } + + #[abi(functions)] + pub struct private_get_decimals_abi { + parameters: private_get_decimals_parameters, + return_type: u8, + } + + #[abi(functions)] + pub struct private_get_name_abi { + parameters: private_get_name_parameters, + return_type: FieldCompressedString, + } + + #[abi(functions)] + pub struct private_get_symbol_abi { + parameters: private_get_symbol_parameters, + return_type: FieldCompressedString, + } + + #[abi(functions)] + pub struct public_get_decimals_abi { + parameters: public_get_decimals_parameters, + return_type: u8, + } + + #[abi(functions)] + pub struct public_get_name_abi { + parameters: public_get_name_parameters, + return_type: FieldCompressedString, + } + + #[abi(functions)] + pub struct public_get_symbol_abi { + parameters: public_get_symbol_parameters, + return_type: FieldCompressedString, + } + + #[abi(functions)] + pub struct set_admin_abi { + parameters: set_admin_parameters, + } + + #[abi(functions)] + pub struct set_minter_abi { + parameters: set_minter_parameters, + } + + #[abi(functions)] + pub struct total_supply_abi { + parameters: total_supply_parameters, + return_type: u128, + } + + #[abi(functions)] + pub struct transfer_abi { + parameters: transfer_parameters, + } + + #[abi(functions)] + pub struct transfer_in_private_abi { + parameters: transfer_in_private_parameters, + } + + #[abi(functions)] + pub struct transfer_in_private_with_offchain_delivery_abi { + parameters: transfer_in_private_with_offchain_delivery_parameters, + } + + #[abi(functions)] + pub struct transfer_in_public_abi { + parameters: transfer_in_public_parameters, + } + + #[abi(functions)] + pub struct transfer_to_private_abi { + parameters: transfer_to_private_parameters, + } + + #[abi(functions)] + pub struct transfer_to_public_abi { + parameters: transfer_to_public_parameters, + } + + #[abi(functions)] + pub struct transfer_to_public_and_prepare_private_balance_increase_abi { + parameters: transfer_to_public_and_prepare_private_balance_increase_parameters, + return_type: PartialUintNote, + } + + fn __aztec_nr_internals___recurse_subtract_balance(inputs: aztec::context::inputs::PrivateContextInputs, account: AztecAddress, amount: u128) -> return_data aztec::protocol::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs { + aztec::oracle::version::assert_compatible_oracle_version(); + let mut self: aztec::contract_self::contract_self_private::ContractSelfPrivate, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility> = { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(account); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let args_hash: Field = aztec::hash::hash_args(serialized_params); + let mut context: PrivateContext = PrivateContext::new(inputs, args_hash); + let storage: Storage<&mut PrivateContext> = Storage::<&mut PrivateContext>::init(&mut context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf<&mut PrivateContext> = CallSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self: EnqueueSelf<&mut PrivateContext> = EnqueueSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let call_self_static: CallSelfStatic<&mut PrivateContext> = CallSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self_static: EnqueueSelfStatic<&mut PrivateContext> = EnqueueSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let internal: CallInternal<&mut PrivateContext> = CallInternal::<&mut PrivateContext> { context: &mut context}; + let call_self_utility: CallSelfUtility = CallSelfUtility { address: self_address}; + let utility: aztec::contract_self::contract_self_private::PrivateUtilityCalls = aztec::contract_self::contract_self_private::PrivateUtilityCalls:: { call_self: call_self_utility}; + aztec::contract_self::contract_self_private::ContractSelfPrivate::, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility>::new(&mut context, storage, call_self, enqueue_self, call_self_static, enqueue_self_static, internal, utility) + }; + let within_revertible_phase: bool = self.context.in_revertible_phase(); + assert(self.msg_sender() == self.address, "Function _recurse_subtract_balance can only be called by the same contract"); + let macro__returned__values: u128 = self.internal.subtract_balance(account, amount, RECURSIVE_TRANSFER_CALL_MAX_NOTES); + let serialized_params: [Field; 1] = ::serialize(macro__returned__values); + self.context.set_return_hash(serialized_params); + assert(within_revertible_phase == self.context.in_revertible_phase(), f"Phase change detected on function with phase check. If this is expected, use #[allow_phase_change]"); + self.context.finish() + } + + fn __aztec_nr_internals__burn_private(inputs: aztec::context::inputs::PrivateContextInputs, from: AztecAddress, amount: u128, authwit_nonce: Field) -> return_data aztec::protocol::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs { + aztec::oracle::version::assert_compatible_oracle_version(); + let mut self: aztec::contract_self::contract_self_private::ContractSelfPrivate, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility> = { + let mut serialized_params: [Field; 3] = [0_Field; 3]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(from); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let args_hash: Field = aztec::hash::hash_args(serialized_params); + let mut context: PrivateContext = PrivateContext::new(inputs, args_hash); + let storage: Storage<&mut PrivateContext> = Storage::<&mut PrivateContext>::init(&mut context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf<&mut PrivateContext> = CallSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self: EnqueueSelf<&mut PrivateContext> = EnqueueSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let call_self_static: CallSelfStatic<&mut PrivateContext> = CallSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self_static: EnqueueSelfStatic<&mut PrivateContext> = EnqueueSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let internal: CallInternal<&mut PrivateContext> = CallInternal::<&mut PrivateContext> { context: &mut context}; + let call_self_utility: CallSelfUtility = CallSelfUtility { address: self_address}; + let utility: aztec::contract_self::contract_self_private::PrivateUtilityCalls = aztec::contract_self::contract_self_private::PrivateUtilityCalls:: { call_self: call_self_utility}; + aztec::contract_self::contract_self_private::ContractSelfPrivate::, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility>::new(&mut context, storage, call_self, enqueue_self, call_self_static, enqueue_self_static, internal, utility) + }; + let within_revertible_phase: bool = self.context.in_revertible_phase(); + aztec::macros::functions::initialization_utils::assert_is_initialized_private(self.context); + if !from.eq(self.msg_sender()) { + aztec::authwit::auth::assert_current_call_valid_authwit::<3>(self.context, from); + } else { + assert(authwit_nonce == 0_Field, "Invalid authwit nonce. When 'from' and 'msg_sender' are the same, 'authwit_nonce' must be zero"); + }; + self.storage.balances.at(from).sub(amount).deliver(MessageDelivery.ONCHAIN_CONSTRAINED); + self.enqueue_self._reduce_total_supply(amount); + assert(within_revertible_phase == self.context.in_revertible_phase(), f"Phase change detected on function with phase check. If this is expected, use #[allow_phase_change]"); + self.context.finish() + } + + fn __aztec_nr_internals__cancel_authwit(inputs: aztec::context::inputs::PrivateContextInputs, inner_hash: Field) -> return_data aztec::protocol::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs { + aztec::oracle::version::assert_compatible_oracle_version(); + let mut self: aztec::contract_self::contract_self_private::ContractSelfPrivate, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility> = { + let serialized_params: [Field; 1] = ::serialize(inner_hash); + let args_hash: Field = aztec::hash::hash_args(serialized_params); + let mut context: PrivateContext = PrivateContext::new(inputs, args_hash); + let storage: Storage<&mut PrivateContext> = Storage::<&mut PrivateContext>::init(&mut context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf<&mut PrivateContext> = CallSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self: EnqueueSelf<&mut PrivateContext> = EnqueueSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let call_self_static: CallSelfStatic<&mut PrivateContext> = CallSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self_static: EnqueueSelfStatic<&mut PrivateContext> = EnqueueSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let internal: CallInternal<&mut PrivateContext> = CallInternal::<&mut PrivateContext> { context: &mut context}; + let call_self_utility: CallSelfUtility = CallSelfUtility { address: self_address}; + let utility: aztec::contract_self::contract_self_private::PrivateUtilityCalls = aztec::contract_self::contract_self_private::PrivateUtilityCalls:: { call_self: call_self_utility}; + aztec::contract_self::contract_self_private::ContractSelfPrivate::, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility>::new(&mut context, storage, call_self, enqueue_self, call_self_static, enqueue_self_static, internal, utility) + }; + let within_revertible_phase: bool = self.context.in_revertible_phase(); + aztec::macros::functions::initialization_utils::assert_is_initialized_private(self.context); + let on_behalf_of: AztecAddress = self.msg_sender(); + let nullifier: Field = compute_authwit_nullifier(on_behalf_of, inner_hash); + self.context.push_nullifier(nullifier); + assert(within_revertible_phase == self.context.in_revertible_phase(), f"Phase change detected on function with phase check. If this is expected, use #[allow_phase_change]"); + self.context.finish() + } + + fn __aztec_nr_internals__finalize_transfer_to_private_from_private(inputs: aztec::context::inputs::PrivateContextInputs, from: AztecAddress, partial_note: PartialUintNote, amount: u128, authwit_nonce: Field) -> return_data aztec::protocol::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs { + aztec::oracle::version::assert_compatible_oracle_version(); + let mut self: aztec::contract_self::contract_self_private::ContractSelfPrivate, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility> = { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(from); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(partial_note); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let args_hash: Field = aztec::hash::hash_args(serialized_params); + let mut context: PrivateContext = PrivateContext::new(inputs, args_hash); + let storage: Storage<&mut PrivateContext> = Storage::<&mut PrivateContext>::init(&mut context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf<&mut PrivateContext> = CallSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self: EnqueueSelf<&mut PrivateContext> = EnqueueSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let call_self_static: CallSelfStatic<&mut PrivateContext> = CallSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self_static: EnqueueSelfStatic<&mut PrivateContext> = EnqueueSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let internal: CallInternal<&mut PrivateContext> = CallInternal::<&mut PrivateContext> { context: &mut context}; + let call_self_utility: CallSelfUtility = CallSelfUtility { address: self_address}; + let utility: aztec::contract_self::contract_self_private::PrivateUtilityCalls = aztec::contract_self::contract_self_private::PrivateUtilityCalls:: { call_self: call_self_utility}; + aztec::contract_self::contract_self_private::ContractSelfPrivate::, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility>::new(&mut context, storage, call_self, enqueue_self, call_self_static, enqueue_self_static, internal, utility) + }; + let within_revertible_phase: bool = self.context.in_revertible_phase(); + aztec::macros::functions::initialization_utils::assert_is_initialized_private(self.context); + if !from.eq(self.msg_sender()) { + aztec::authwit::auth::assert_current_call_valid_authwit::<4>(self.context, from); + } else { + assert(authwit_nonce == 0_Field, "Invalid authwit nonce. When 'from' and 'msg_sender' are the same, 'authwit_nonce' must be zero"); + }; + self.storage.balances.at(from).sub(amount).deliver(MessageDelivery.ONCHAIN_CONSTRAINED); + partial_note.complete_from_private(self.context, self.msg_sender(), self.storage.balances.get_storage_slot(), amount); + assert(within_revertible_phase == self.context.in_revertible_phase(), f"Phase change detected on function with phase check. If this is expected, use #[allow_phase_change]"); + self.context.finish() + } + + fn __aztec_nr_internals__mint_to_private(inputs: aztec::context::inputs::PrivateContextInputs, to: AztecAddress, amount: u128) -> return_data aztec::protocol::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs { + aztec::oracle::version::assert_compatible_oracle_version(); + let mut self: aztec::contract_self::contract_self_private::ContractSelfPrivate, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility> = { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let args_hash: Field = aztec::hash::hash_args(serialized_params); + let mut context: PrivateContext = PrivateContext::new(inputs, args_hash); + let storage: Storage<&mut PrivateContext> = Storage::<&mut PrivateContext>::init(&mut context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf<&mut PrivateContext> = CallSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self: EnqueueSelf<&mut PrivateContext> = EnqueueSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let call_self_static: CallSelfStatic<&mut PrivateContext> = CallSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self_static: EnqueueSelfStatic<&mut PrivateContext> = EnqueueSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let internal: CallInternal<&mut PrivateContext> = CallInternal::<&mut PrivateContext> { context: &mut context}; + let call_self_utility: CallSelfUtility = CallSelfUtility { address: self_address}; + let utility: aztec::contract_self::contract_self_private::PrivateUtilityCalls = aztec::contract_self::contract_self_private::PrivateUtilityCalls:: { call_self: call_self_utility}; + aztec::contract_self::contract_self_private::ContractSelfPrivate::, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility>::new(&mut context, storage, call_self, enqueue_self, call_self_static, enqueue_self_static, internal, utility) + }; + let within_revertible_phase: bool = self.context.in_revertible_phase(); + aztec::macros::functions::initialization_utils::assert_is_initialized_private(self.context); + let partial_note: PartialUintNote = self.internal._prepare_private_balance_increase(to); + self.enqueue_self._finalize_mint_to_private_unsafe(self.msg_sender(), amount, partial_note); + assert(within_revertible_phase == self.context.in_revertible_phase(), f"Phase change detected on function with phase check. If this is expected, use #[allow_phase_change]"); + self.context.finish() + } + + fn __aztec_nr_internals__prepare_private_balance_increase(inputs: aztec::context::inputs::PrivateContextInputs, to: AztecAddress) -> return_data aztec::protocol::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs { + aztec::oracle::version::assert_compatible_oracle_version(); + let mut self: aztec::contract_self::contract_self_private::ContractSelfPrivate, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility> = { + let serialized_params: [Field; 1] = ::serialize(to); + let args_hash: Field = aztec::hash::hash_args(serialized_params); + let mut context: PrivateContext = PrivateContext::new(inputs, args_hash); + let storage: Storage<&mut PrivateContext> = Storage::<&mut PrivateContext>::init(&mut context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf<&mut PrivateContext> = CallSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self: EnqueueSelf<&mut PrivateContext> = EnqueueSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let call_self_static: CallSelfStatic<&mut PrivateContext> = CallSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self_static: EnqueueSelfStatic<&mut PrivateContext> = EnqueueSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let internal: CallInternal<&mut PrivateContext> = CallInternal::<&mut PrivateContext> { context: &mut context}; + let call_self_utility: CallSelfUtility = CallSelfUtility { address: self_address}; + let utility: aztec::contract_self::contract_self_private::PrivateUtilityCalls = aztec::contract_self::contract_self_private::PrivateUtilityCalls:: { call_self: call_self_utility}; + aztec::contract_self::contract_self_private::ContractSelfPrivate::, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility>::new(&mut context, storage, call_self, enqueue_self, call_self_static, enqueue_self_static, internal, utility) + }; + let within_revertible_phase: bool = self.context.in_revertible_phase(); + aztec::macros::functions::initialization_utils::assert_is_initialized_private(self.context); + let macro__returned__values: PartialUintNote = self.internal._prepare_private_balance_increase(to); + let serialized_params: [Field; 1] = ::serialize(macro__returned__values); + self.context.set_return_hash(serialized_params); + assert(within_revertible_phase == self.context.in_revertible_phase(), f"Phase change detected on function with phase check. If this is expected, use #[allow_phase_change]"); + self.context.finish() + } + + fn __aztec_nr_internals__private_get_decimals(inputs: aztec::context::inputs::PrivateContextInputs) -> return_data aztec::protocol::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs { + aztec::oracle::version::assert_compatible_oracle_version(); + let mut self: aztec::contract_self::contract_self_private::ContractSelfPrivate, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility> = { + let serialized_params: [Field; 0] = []; + let args_hash: Field = aztec::hash::hash_args(serialized_params); + let mut context: PrivateContext = PrivateContext::new(inputs, args_hash); + let storage: Storage<&mut PrivateContext> = Storage::<&mut PrivateContext>::init(&mut context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf<&mut PrivateContext> = CallSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self: EnqueueSelf<&mut PrivateContext> = EnqueueSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let call_self_static: CallSelfStatic<&mut PrivateContext> = CallSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self_static: EnqueueSelfStatic<&mut PrivateContext> = EnqueueSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let internal: CallInternal<&mut PrivateContext> = CallInternal::<&mut PrivateContext> { context: &mut context}; + let call_self_utility: CallSelfUtility = CallSelfUtility { address: self_address}; + let utility: aztec::contract_self::contract_self_private::PrivateUtilityCalls = aztec::contract_self::contract_self_private::PrivateUtilityCalls:: { call_self: call_self_utility}; + aztec::contract_self::contract_self_private::ContractSelfPrivate::, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility>::new(&mut context, storage, call_self, enqueue_self, call_self_static, enqueue_self_static, internal, utility) + }; + let within_revertible_phase: bool = self.context.in_revertible_phase(); + aztec::macros::functions::initialization_utils::assert_is_initialized_private(self.context); + assert(self.context.inputs.call_context.is_static_call, "Function private_get_decimals can only be called statically"); + let macro__returned__values: u8 = self.storage.decimals.read(); + let serialized_params: [Field; 1] = ::serialize(macro__returned__values); + self.context.set_return_hash(serialized_params); + assert(within_revertible_phase == self.context.in_revertible_phase(), f"Phase change detected on function with phase check. If this is expected, use #[allow_phase_change]"); + self.context.finish() + } + + fn __aztec_nr_internals__private_get_name(inputs: aztec::context::inputs::PrivateContextInputs) -> return_data aztec::protocol::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs { + aztec::oracle::version::assert_compatible_oracle_version(); + let mut self: aztec::contract_self::contract_self_private::ContractSelfPrivate, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility> = { + let serialized_params: [Field; 0] = []; + let args_hash: Field = aztec::hash::hash_args(serialized_params); + let mut context: PrivateContext = PrivateContext::new(inputs, args_hash); + let storage: Storage<&mut PrivateContext> = Storage::<&mut PrivateContext>::init(&mut context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf<&mut PrivateContext> = CallSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self: EnqueueSelf<&mut PrivateContext> = EnqueueSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let call_self_static: CallSelfStatic<&mut PrivateContext> = CallSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self_static: EnqueueSelfStatic<&mut PrivateContext> = EnqueueSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let internal: CallInternal<&mut PrivateContext> = CallInternal::<&mut PrivateContext> { context: &mut context}; + let call_self_utility: CallSelfUtility = CallSelfUtility { address: self_address}; + let utility: aztec::contract_self::contract_self_private::PrivateUtilityCalls = aztec::contract_self::contract_self_private::PrivateUtilityCalls:: { call_self: call_self_utility}; + aztec::contract_self::contract_self_private::ContractSelfPrivate::, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility>::new(&mut context, storage, call_self, enqueue_self, call_self_static, enqueue_self_static, internal, utility) + }; + let within_revertible_phase: bool = self.context.in_revertible_phase(); + aztec::macros::functions::initialization_utils::assert_is_initialized_private(self.context); + assert(self.context.inputs.call_context.is_static_call, "Function private_get_name can only be called statically"); + let macro__returned__values: FieldCompressedString = self.storage.name.read(); + let serialized_params: [Field; 1] = ::serialize(macro__returned__values); + self.context.set_return_hash(serialized_params); + assert(within_revertible_phase == self.context.in_revertible_phase(), f"Phase change detected on function with phase check. If this is expected, use #[allow_phase_change]"); + self.context.finish() + } + + fn __aztec_nr_internals__private_get_symbol(inputs: aztec::context::inputs::PrivateContextInputs) -> return_data aztec::protocol::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs { + aztec::oracle::version::assert_compatible_oracle_version(); + let mut self: aztec::contract_self::contract_self_private::ContractSelfPrivate, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility> = { + let serialized_params: [Field; 0] = []; + let args_hash: Field = aztec::hash::hash_args(serialized_params); + let mut context: PrivateContext = PrivateContext::new(inputs, args_hash); + let storage: Storage<&mut PrivateContext> = Storage::<&mut PrivateContext>::init(&mut context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf<&mut PrivateContext> = CallSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self: EnqueueSelf<&mut PrivateContext> = EnqueueSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let call_self_static: CallSelfStatic<&mut PrivateContext> = CallSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self_static: EnqueueSelfStatic<&mut PrivateContext> = EnqueueSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let internal: CallInternal<&mut PrivateContext> = CallInternal::<&mut PrivateContext> { context: &mut context}; + let call_self_utility: CallSelfUtility = CallSelfUtility { address: self_address}; + let utility: aztec::contract_self::contract_self_private::PrivateUtilityCalls = aztec::contract_self::contract_self_private::PrivateUtilityCalls:: { call_self: call_self_utility}; + aztec::contract_self::contract_self_private::ContractSelfPrivate::, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility>::new(&mut context, storage, call_self, enqueue_self, call_self_static, enqueue_self_static, internal, utility) + }; + let within_revertible_phase: bool = self.context.in_revertible_phase(); + aztec::macros::functions::initialization_utils::assert_is_initialized_private(self.context); + assert(self.context.inputs.call_context.is_static_call, "Function private_get_symbol can only be called statically"); + let macro__returned__values: FieldCompressedString = self.storage.symbol.read(); + let serialized_params: [Field; 1] = ::serialize(macro__returned__values); + self.context.set_return_hash(serialized_params); + assert(within_revertible_phase == self.context.in_revertible_phase(), f"Phase change detected on function with phase check. If this is expected, use #[allow_phase_change]"); + self.context.finish() + } + + fn __aztec_nr_internals__transfer(inputs: aztec::context::inputs::PrivateContextInputs, to: AztecAddress, amount: u128) -> return_data aztec::protocol::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs { + aztec::oracle::version::assert_compatible_oracle_version(); + let mut self: aztec::contract_self::contract_self_private::ContractSelfPrivate, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility> = { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let args_hash: Field = aztec::hash::hash_args(serialized_params); + let mut context: PrivateContext = PrivateContext::new(inputs, args_hash); + let storage: Storage<&mut PrivateContext> = Storage::<&mut PrivateContext>::init(&mut context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf<&mut PrivateContext> = CallSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self: EnqueueSelf<&mut PrivateContext> = EnqueueSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let call_self_static: CallSelfStatic<&mut PrivateContext> = CallSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self_static: EnqueueSelfStatic<&mut PrivateContext> = EnqueueSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let internal: CallInternal<&mut PrivateContext> = CallInternal::<&mut PrivateContext> { context: &mut context}; + let call_self_utility: CallSelfUtility = CallSelfUtility { address: self_address}; + let utility: aztec::contract_self::contract_self_private::PrivateUtilityCalls = aztec::contract_self::contract_self_private::PrivateUtilityCalls:: { call_self: call_self_utility}; + aztec::contract_self::contract_self_private::ContractSelfPrivate::, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility>::new(&mut context, storage, call_self, enqueue_self, call_self_static, enqueue_self_static, internal, utility) + }; + let within_revertible_phase: bool = self.context.in_revertible_phase(); + aztec::macros::functions::initialization_utils::assert_is_initialized_private(self.context); + let from: AztecAddress = self.msg_sender(); + let change: u128 = self.internal.subtract_balance(from, amount, INITIAL_TRANSFER_CALL_MAX_NOTES); + self.storage.balances.at(from).add(change).deliver(MessageDelivery.ONCHAIN_UNCONSTRAINED); + self.storage.balances.at(to).add(amount).deliver(MessageDelivery.ONCHAIN_UNCONSTRAINED); + self.emit(Transfer { from: from, to: to, amount: amount}).deliver_to(to, MessageDelivery.ONCHAIN_UNCONSTRAINED); + assert(within_revertible_phase == self.context.in_revertible_phase(), f"Phase change detected on function with phase check. If this is expected, use #[allow_phase_change]"); + self.context.finish() + } + + fn __aztec_nr_internals__transfer_in_private(inputs: aztec::context::inputs::PrivateContextInputs, from: AztecAddress, to: AztecAddress, amount: u128, authwit_nonce: Field) -> return_data aztec::protocol::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs { + aztec::oracle::version::assert_compatible_oracle_version(); + let mut self: aztec::contract_self::contract_self_private::ContractSelfPrivate, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility> = { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(from); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let args_hash: Field = aztec::hash::hash_args(serialized_params); + let mut context: PrivateContext = PrivateContext::new(inputs, args_hash); + let storage: Storage<&mut PrivateContext> = Storage::<&mut PrivateContext>::init(&mut context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf<&mut PrivateContext> = CallSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self: EnqueueSelf<&mut PrivateContext> = EnqueueSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let call_self_static: CallSelfStatic<&mut PrivateContext> = CallSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self_static: EnqueueSelfStatic<&mut PrivateContext> = EnqueueSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let internal: CallInternal<&mut PrivateContext> = CallInternal::<&mut PrivateContext> { context: &mut context}; + let call_self_utility: CallSelfUtility = CallSelfUtility { address: self_address}; + let utility: aztec::contract_self::contract_self_private::PrivateUtilityCalls = aztec::contract_self::contract_self_private::PrivateUtilityCalls:: { call_self: call_self_utility}; + aztec::contract_self::contract_self_private::ContractSelfPrivate::, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility>::new(&mut context, storage, call_self, enqueue_self, call_self_static, enqueue_self_static, internal, utility) + }; + let within_revertible_phase: bool = self.context.in_revertible_phase(); + aztec::macros::functions::initialization_utils::assert_is_initialized_private(self.context); + if !from.eq(self.msg_sender()) { + aztec::authwit::auth::assert_current_call_valid_authwit::<4>(self.context, from); + } else { + assert(authwit_nonce == 0_Field, "Invalid authwit nonce. When 'from' and 'msg_sender' are the same, 'authwit_nonce' must be zero"); + }; + self.storage.balances.at(from).sub(amount).deliver(MessageDelivery.ONCHAIN_CONSTRAINED); + self.storage.balances.at(to).add(amount).deliver(MessageDelivery.ONCHAIN_CONSTRAINED); + assert(within_revertible_phase == self.context.in_revertible_phase(), f"Phase change detected on function with phase check. If this is expected, use #[allow_phase_change]"); + self.context.finish() + } + + fn __aztec_nr_internals__transfer_in_private_with_offchain_delivery(inputs: aztec::context::inputs::PrivateContextInputs, from: AztecAddress, to: AztecAddress, amount: u128, authwit_nonce: Field) -> return_data aztec::protocol::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs { + aztec::oracle::version::assert_compatible_oracle_version(); + let mut self: aztec::contract_self::contract_self_private::ContractSelfPrivate, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility> = { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(from); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let args_hash: Field = aztec::hash::hash_args(serialized_params); + let mut context: PrivateContext = PrivateContext::new(inputs, args_hash); + let storage: Storage<&mut PrivateContext> = Storage::<&mut PrivateContext>::init(&mut context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf<&mut PrivateContext> = CallSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self: EnqueueSelf<&mut PrivateContext> = EnqueueSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let call_self_static: CallSelfStatic<&mut PrivateContext> = CallSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self_static: EnqueueSelfStatic<&mut PrivateContext> = EnqueueSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let internal: CallInternal<&mut PrivateContext> = CallInternal::<&mut PrivateContext> { context: &mut context}; + let call_self_utility: CallSelfUtility = CallSelfUtility { address: self_address}; + let utility: aztec::contract_self::contract_self_private::PrivateUtilityCalls = aztec::contract_self::contract_self_private::PrivateUtilityCalls:: { call_self: call_self_utility}; + aztec::contract_self::contract_self_private::ContractSelfPrivate::, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility>::new(&mut context, storage, call_self, enqueue_self, call_self_static, enqueue_self_static, internal, utility) + }; + let within_revertible_phase: bool = self.context.in_revertible_phase(); + aztec::macros::functions::initialization_utils::assert_is_initialized_private(self.context); + if !from.eq(self.msg_sender()) { + aztec::authwit::auth::assert_current_call_valid_authwit::<4>(self.context, from); + } else { + assert(authwit_nonce == 0_Field, "Invalid authwit nonce. When 'from' and 'msg_sender' are the same, 'authwit_nonce' must be zero"); + }; + self.storage.balances.at(from).sub(amount).deliver(MessageDelivery.OFFCHAIN); + self.storage.balances.at(to).add(amount).deliver(MessageDelivery.OFFCHAIN); + self.emit(Transfer { from: from, to: to, amount: amount}).deliver_to(to, MessageDelivery.OFFCHAIN); + assert(within_revertible_phase == self.context.in_revertible_phase(), f"Phase change detected on function with phase check. If this is expected, use #[allow_phase_change]"); + self.context.finish() + } + + fn __aztec_nr_internals__transfer_to_private(inputs: aztec::context::inputs::PrivateContextInputs, to: AztecAddress, amount: u128) -> return_data aztec::protocol::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs { + aztec::oracle::version::assert_compatible_oracle_version(); + let mut self: aztec::contract_self::contract_self_private::ContractSelfPrivate, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility> = { + let mut serialized_params: [Field; 2] = [0_Field; 2]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let args_hash: Field = aztec::hash::hash_args(serialized_params); + let mut context: PrivateContext = PrivateContext::new(inputs, args_hash); + let storage: Storage<&mut PrivateContext> = Storage::<&mut PrivateContext>::init(&mut context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf<&mut PrivateContext> = CallSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self: EnqueueSelf<&mut PrivateContext> = EnqueueSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let call_self_static: CallSelfStatic<&mut PrivateContext> = CallSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self_static: EnqueueSelfStatic<&mut PrivateContext> = EnqueueSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let internal: CallInternal<&mut PrivateContext> = CallInternal::<&mut PrivateContext> { context: &mut context}; + let call_self_utility: CallSelfUtility = CallSelfUtility { address: self_address}; + let utility: aztec::contract_self::contract_self_private::PrivateUtilityCalls = aztec::contract_self::contract_self_private::PrivateUtilityCalls:: { call_self: call_self_utility}; + aztec::contract_self::contract_self_private::ContractSelfPrivate::, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility>::new(&mut context, storage, call_self, enqueue_self, call_self_static, enqueue_self_static, internal, utility) + }; + let within_revertible_phase: bool = self.context.in_revertible_phase(); + aztec::macros::functions::initialization_utils::assert_is_initialized_private(self.context); + let from: AztecAddress = self.msg_sender(); + let partial_note: PartialUintNote = self.internal._prepare_private_balance_increase(to); + self.enqueue_self._finalize_transfer_to_private_unsafe(from, amount, partial_note); + assert(within_revertible_phase == self.context.in_revertible_phase(), f"Phase change detected on function with phase check. If this is expected, use #[allow_phase_change]"); + self.context.finish() + } + + fn __aztec_nr_internals__transfer_to_public(inputs: aztec::context::inputs::PrivateContextInputs, from: AztecAddress, to: AztecAddress, amount: u128, authwit_nonce: Field) -> return_data aztec::protocol::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs { + aztec::oracle::version::assert_compatible_oracle_version(); + let mut self: aztec::contract_self::contract_self_private::ContractSelfPrivate, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility> = { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(from); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let args_hash: Field = aztec::hash::hash_args(serialized_params); + let mut context: PrivateContext = PrivateContext::new(inputs, args_hash); + let storage: Storage<&mut PrivateContext> = Storage::<&mut PrivateContext>::init(&mut context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf<&mut PrivateContext> = CallSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self: EnqueueSelf<&mut PrivateContext> = EnqueueSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let call_self_static: CallSelfStatic<&mut PrivateContext> = CallSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self_static: EnqueueSelfStatic<&mut PrivateContext> = EnqueueSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let internal: CallInternal<&mut PrivateContext> = CallInternal::<&mut PrivateContext> { context: &mut context}; + let call_self_utility: CallSelfUtility = CallSelfUtility { address: self_address}; + let utility: aztec::contract_self::contract_self_private::PrivateUtilityCalls = aztec::contract_self::contract_self_private::PrivateUtilityCalls:: { call_self: call_self_utility}; + aztec::contract_self::contract_self_private::ContractSelfPrivate::, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility>::new(&mut context, storage, call_self, enqueue_self, call_self_static, enqueue_self_static, internal, utility) + }; + let within_revertible_phase: bool = self.context.in_revertible_phase(); + aztec::macros::functions::initialization_utils::assert_is_initialized_private(self.context); + if !from.eq(self.msg_sender()) { + aztec::authwit::auth::assert_current_call_valid_authwit::<4>(self.context, from); + } else { + assert(authwit_nonce == 0_Field, "Invalid authwit nonce. When 'from' and 'msg_sender' are the same, 'authwit_nonce' must be zero"); + }; + self.storage.balances.at(from).sub(amount).deliver(MessageDelivery.ONCHAIN_CONSTRAINED); + self.enqueue_self._increase_public_balance(to, amount); + assert(within_revertible_phase == self.context.in_revertible_phase(), f"Phase change detected on function with phase check. If this is expected, use #[allow_phase_change]"); + self.context.finish() + } + + fn __aztec_nr_internals__transfer_to_public_and_prepare_private_balance_increase(inputs: aztec::context::inputs::PrivateContextInputs, from: AztecAddress, to: AztecAddress, amount: u128, authwit_nonce: Field) -> return_data aztec::protocol::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs { + aztec::oracle::version::assert_compatible_oracle_version(); + let mut self: aztec::contract_self::contract_self_private::ContractSelfPrivate, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility> = { + let mut serialized_params: [Field; 4] = [0_Field; 4]; + let mut offset: u32 = 0_u32; + let serialized_member: [Field; 1] = ::serialize(from); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_0: u32 = i + offset; + serialized_params[i_0] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(to); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_1: u32 = i + offset; + serialized_params[i_1] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(amount); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_2: u32 = i + offset; + serialized_params[i_2] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let serialized_member: [Field; 1] = ::serialize(authwit_nonce); + let serialized_member_len: u32 = ::N; + for i in 0_u32..serialized_member_len { + { + let i_3: u32 = i + offset; + serialized_params[i_3] = serialized_member[i]; + } + }; + offset = offset + serialized_member_len; + let args_hash: Field = aztec::hash::hash_args(serialized_params); + let mut context: PrivateContext = PrivateContext::new(inputs, args_hash); + let storage: Storage<&mut PrivateContext> = Storage::<&mut PrivateContext>::init(&mut context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf<&mut PrivateContext> = CallSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self: EnqueueSelf<&mut PrivateContext> = EnqueueSelf::<&mut PrivateContext> { address: self_address, context: &mut context}; + let call_self_static: CallSelfStatic<&mut PrivateContext> = CallSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let enqueue_self_static: EnqueueSelfStatic<&mut PrivateContext> = EnqueueSelfStatic::<&mut PrivateContext> { address: self_address, context: &mut context}; + let internal: CallInternal<&mut PrivateContext> = CallInternal::<&mut PrivateContext> { context: &mut context}; + let call_self_utility: CallSelfUtility = CallSelfUtility { address: self_address}; + let utility: aztec::contract_self::contract_self_private::PrivateUtilityCalls = aztec::contract_self::contract_self_private::PrivateUtilityCalls:: { call_self: call_self_utility}; + aztec::contract_self::contract_self_private::ContractSelfPrivate::, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility>::new(&mut context, storage, call_self, enqueue_self, call_self_static, enqueue_self_static, internal, utility) + }; + let within_revertible_phase: bool = self.context.in_revertible_phase(); + aztec::macros::functions::initialization_utils::assert_is_initialized_private(self.context); + if !from.eq(self.msg_sender()) { + aztec::authwit::auth::assert_current_call_valid_authwit::<4>(self.context, from); + } else { + assert(authwit_nonce == 0_Field, "Invalid authwit nonce. When 'from' and 'msg_sender' are the same, 'authwit_nonce' must be zero"); + }; + self.storage.balances.at(from).sub(amount).deliver(MessageDelivery.ONCHAIN_CONSTRAINED); + self.enqueue_self._increase_public_balance(to, amount); + let macro__returned__values: PartialUintNote = self.internal._prepare_private_balance_increase(from); + let serialized_params: [Field; 1] = ::serialize(macro__returned__values); + self.context.set_return_hash(serialized_params); + assert(within_revertible_phase == self.context.in_revertible_phase(), f"Phase change detected on function with phase check. If this is expected, use #[allow_phase_change]"); + self.context.finish() + } + + unconstrained fn __aztec_nr_internals___finalize_mint_to_private_unsafe(minter_and_completer: AztecAddress, amount: u128, partial_note: PartialUintNote) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 3] = aztec::oracle::avm::calldata_copy(1_u32, (::N + ::N) + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + assert(self.msg_sender() == self.address, "Function _finalize_mint_to_private_unsafe can only be called by the same contract"); + { + assert(self.storage.minters.at(minter_and_completer).read(), "caller is not minter"); + self.internal._finalize_mint_to_private(minter_and_completer, amount, partial_note); + } + } + + unconstrained fn __aztec_nr_internals___finalize_transfer_to_private_unsafe(from_and_completer: AztecAddress, amount: u128, partial_note: PartialUintNote) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 3] = aztec::oracle::avm::calldata_copy(1_u32, (::N + ::N) + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + assert(self.msg_sender() == self.address, "Function _finalize_transfer_to_private_unsafe can only be called by the same contract"); + { + self.internal._finalize_transfer_to_private(from_and_completer, amount, partial_note); + } + } + + unconstrained fn __aztec_nr_internals___increase_public_balance(to: AztecAddress, amount: u128) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + assert(self.msg_sender() == self.address, "Function _increase_public_balance can only be called by the same contract"); + { + let to_balance: PublicMutable = self.storage.public_balances.at(to); + let new_balance: u128 = to_balance.read().add(amount); + to_balance.write(new_balance); + } + } + + unconstrained fn __aztec_nr_internals___reduce_total_supply(amount: u128) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + assert(self.msg_sender() == self.address, "Function _reduce_total_supply can only be called by the same contract"); + { + let new_supply: u128 = self.storage.total_supply.read().sub(amount); + self.storage.total_supply.write(new_supply); + } + } + + unconstrained fn __aztec_nr_internals__balance_of_public(owner: AztecAddress) -> pub u128 { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); + assert(self.context.is_static_call(), "Function balance_of_public can only be called statically"); + { + self.storage.public_balances.at(owner).read() + } + } + + unconstrained fn __aztec_nr_internals__burn_public(from: AztecAddress, amount: u128, authwit_nonce: Field) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 3] = aztec::oracle::avm::calldata_copy(1_u32, (::N + ::N) + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); + if !from.eq(self.msg_sender()) { + aztec::authwit::auth::assert_current_call_valid_authwit_public(self.context, from); + } else { + assert(authwit_nonce == 0_Field, "Invalid authwit nonce. When 'from' and 'msg_sender' are the same, 'authwit_nonce' must be zero"); + }; + { + let from_balance: u128 = self.storage.public_balances.at(from).read().sub(amount); + self.storage.public_balances.at(from).write(from_balance); + let new_supply: u128 = self.storage.total_supply.read().sub(amount); + self.storage.total_supply.write(new_supply); + } + } + + unconstrained fn __aztec_nr_internals__constructor(admin: AztecAddress, name: str<31>, symbol: str<31>, decimals: u8) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 64] = aztec::oracle::avm::calldata_copy(1_u32, ((::N + as aztec::protocol::traits::Serialize>::N) + as aztec::protocol::traits::Serialize>::N) + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + aztec::macros::functions::initialization_utils::assert_initialization_matches_address_preimage_public(self.context); + { + assert(!admin.is_zero(), "invalid admin"); + self.storage.admin.write(admin); + self.storage.minters.at(admin).write(true); + self.storage.name.initialize(FieldCompressedString::from_string(name)); + self.storage.symbol.initialize(FieldCompressedString::from_string(symbol)); + self.storage.decimals.initialize(decimals); + }; + aztec::macros::functions::initialization_utils::mark_as_initialized_from_public_initializer(self.context); + } + + unconstrained fn __aztec_nr_internals__finalize_mint_to_private(amount: u128, partial_note: PartialUintNote) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); + { + let minter_and_completer: AztecAddress = self.msg_sender(); + assert(self.storage.minters.at(minter_and_completer).read(), "caller is not minter"); + self.internal._finalize_mint_to_private(minter_and_completer, amount, partial_note); + } + } + + unconstrained fn __aztec_nr_internals__finalize_transfer_to_private(amount: u128, partial_note: PartialUintNote) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); + { + let from_and_completer: AztecAddress = self.msg_sender(); + self.internal._finalize_transfer_to_private(from_and_completer, amount, partial_note); + } + } + + unconstrained fn __aztec_nr_internals__get_admin() -> pub Field { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); + assert(self.context.is_static_call(), "Function get_admin can only be called statically"); + { + self.storage.admin.read().to_field() + } + } + + unconstrained fn __aztec_nr_internals__is_minter(minter: AztecAddress) -> pub bool { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); + assert(self.context.is_static_call(), "Function is_minter can only be called statically"); + { + self.storage.minters.at(minter).read() + } + } + + unconstrained fn __aztec_nr_internals__mint_to_public(to: AztecAddress, amount: u128) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); + { + assert(self.storage.minters.at(self.msg_sender()).read(), "caller is not minter"); + let new_balance: u128 = self.storage.public_balances.at(to).read().add(amount); + let supply: u128 = self.storage.total_supply.read().add(amount); + self.storage.public_balances.at(to).write(new_balance); + self.storage.total_supply.write(supply); + } + } + + unconstrained fn __aztec_nr_internals__public_get_decimals() -> pub u8 { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); + assert(self.context.is_static_call(), "Function public_get_decimals can only be called statically"); + { + self.storage.decimals.read() + } + } + + unconstrained fn __aztec_nr_internals__public_get_name() -> pub FieldCompressedString { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); + assert(self.context.is_static_call(), "Function public_get_name can only be called statically"); + { + self.storage.name.read() + } + } + + unconstrained fn __aztec_nr_internals__public_get_symbol() -> pub FieldCompressedString { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); + assert(self.context.is_static_call(), "Function public_get_symbol can only be called statically"); + { + self.storage.symbol.read() + } + } + + unconstrained fn __aztec_nr_internals__set_admin(new_admin: AztecAddress) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); + { + assert(self.storage.admin.read().eq(self.msg_sender()), "caller is not admin"); + self.storage.admin.write(new_admin); + } + } + + unconstrained fn __aztec_nr_internals__set_minter(minter: AztecAddress, approve: bool) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); + { + assert(self.storage.admin.read().eq(self.msg_sender()), "caller is not admin"); + self.storage.minters.at(minter).write(approve); + } + } + + unconstrained fn __aztec_nr_internals__total_supply() -> pub u128 { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); + assert(self.context.is_static_call(), "Function total_supply can only be called statically"); + { + self.storage.total_supply.read() + } + } + + unconstrained fn __aztec_nr_internals__transfer_in_public(from: AztecAddress, to: AztecAddress, amount: u128, authwit_nonce: Field) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; 4] = aztec::oracle::avm::calldata_copy(1_u32, ((::N + ::N) + ::N) + ::N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); + if !from.eq(self.msg_sender()) { + aztec::authwit::auth::assert_current_call_valid_authwit_public(self.context, from); + } else { + assert(authwit_nonce == 0_Field, "Invalid authwit nonce. When 'from' and 'msg_sender' are the same, 'authwit_nonce' must be zero"); + }; + { + let from_balance: u128 = self.storage.public_balances.at(from).read().sub(amount); + self.storage.public_balances.at(from).write(from_balance); + let to_balance: u128 = self.storage.public_balances.at(to).read().add(amount); + self.storage.public_balances.at(to).write(to_balance); + } + } + + unconstrained fn __aztec_nr_internals__balance_of_private(owner: AztecAddress) -> pub u128 { + aztec::oracle::version::assert_compatible_oracle_version(); + let mut self: aztec::contract_self::contract_self_utility::ContractSelfUtility, CallSelfUtility> = { + let context: aztec::context::UtilityContext = aztec::context::UtilityContext::new(); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelfUtility = CallSelfUtility { address: self_address}; + aztec::contract_self::contract_self_utility::ContractSelfUtility::, CallSelfUtility>::new(context, storage, call_self) + }; + aztec::macros::functions::initialization_utils::assert_is_initialized_utility(self.context); + { + self.storage.balances.at(owner).balance_of() + } + } + + #[contract_library_method] + fn __aztec_nr_internals___prepare_private_balance_increase(context: &mut PrivateContext, to: AztecAddress) -> PartialUintNote { + let mut self: aztec::contract_self::contract_self_private::ContractSelfPrivate, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility> = { + let storage: Storage<&mut PrivateContext> = Storage::<&mut PrivateContext>::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf<&mut PrivateContext> = CallSelf::<&mut PrivateContext> { address: self_address, context: context}; + let enqueue_self: EnqueueSelf<&mut PrivateContext> = EnqueueSelf::<&mut PrivateContext> { address: self_address, context: context}; + let call_self_static: CallSelfStatic<&mut PrivateContext> = CallSelfStatic::<&mut PrivateContext> { address: self_address, context: context}; + let enqueue_self_static: EnqueueSelfStatic<&mut PrivateContext> = EnqueueSelfStatic::<&mut PrivateContext> { address: self_address, context: context}; + let internal: CallInternal<&mut PrivateContext> = CallInternal::<&mut PrivateContext> { context: context}; + let call_self_utility: CallSelfUtility = CallSelfUtility { address: self_address}; + let utility: aztec::contract_self::contract_self_private::PrivateUtilityCalls = aztec::contract_self::contract_self_private::PrivateUtilityCalls:: { call_self: call_self_utility}; + aztec::contract_self::contract_self_private::ContractSelfPrivate::, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility>::new(context, storage, call_self, enqueue_self, call_self_static, enqueue_self_static, internal, utility) + }; + { + let partial_note: PartialUintNote = UintNote::partial(to, self.context, to, self.msg_sender()); + partial_note + } + } + + #[contract_library_method] + fn __aztec_nr_internals__subtract_balance(context: &mut PrivateContext, account: AztecAddress, amount: u128, max_notes: u32) -> u128 { + let mut self: aztec::contract_self::contract_self_private::ContractSelfPrivate, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility> = { + let storage: Storage<&mut PrivateContext> = Storage::<&mut PrivateContext>::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf<&mut PrivateContext> = CallSelf::<&mut PrivateContext> { address: self_address, context: context}; + let enqueue_self: EnqueueSelf<&mut PrivateContext> = EnqueueSelf::<&mut PrivateContext> { address: self_address, context: context}; + let call_self_static: CallSelfStatic<&mut PrivateContext> = CallSelfStatic::<&mut PrivateContext> { address: self_address, context: context}; + let enqueue_self_static: EnqueueSelfStatic<&mut PrivateContext> = EnqueueSelfStatic::<&mut PrivateContext> { address: self_address, context: context}; + let internal: CallInternal<&mut PrivateContext> = CallInternal::<&mut PrivateContext> { context: context}; + let call_self_utility: CallSelfUtility = CallSelfUtility { address: self_address}; + let utility: aztec::contract_self::contract_self_private::PrivateUtilityCalls = aztec::contract_self::contract_self_private::PrivateUtilityCalls:: { call_self: call_self_utility}; + aztec::contract_self::contract_self_private::ContractSelfPrivate::, CallSelf<&mut PrivateContext>, EnqueueSelf<&mut PrivateContext>, CallSelfStatic<&mut PrivateContext>, EnqueueSelfStatic<&mut PrivateContext>, CallInternal<&mut PrivateContext>, CallSelfUtility>::new(context, storage, call_self, enqueue_self, call_self_static, enqueue_self_static, internal, utility) + }; + { + let subtracted: u128 = self.storage.balances.at(account).try_sub(amount, max_notes); + assert(subtracted > (0_Field as u128), "Balance too low"); + if subtracted >= amount { + subtracted - amount + } else { + let remaining: u128 = amount - subtracted; + compute_recurse_subtract_balance_call(*context, account, remaining).call(context) + } + } + } + + #[contract_library_method] + unconstrained fn __aztec_nr_internals___finalize_mint_to_private(context: aztec::context::PublicContext, completer: AztecAddress, amount: u128, partial_note: PartialUintNote) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + let supply: u128 = self.storage.total_supply.read().add(amount); + self.storage.total_supply.write(supply); + partial_note.complete(self.context, completer, self.storage.balances.get_storage_slot(), amount); + } + } + + #[contract_library_method] + unconstrained fn __aztec_nr_internals___finalize_transfer_to_private(context: aztec::context::PublicContext, from_and_completer: AztecAddress, amount: u128, partial_note: PartialUintNote) { + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + }; + { + let balance_storage: PublicMutable = self.storage.public_balances.at(from_and_completer); + let from_balance: u128 = balance_storage.read().sub(amount); + balance_storage.write(from_balance); + partial_note.complete(self.context, from_and_completer, self.storage.balances.get_storage_slot(), amount); + } + } + + pub struct StorageLayoutFields { + pub admin: aztec::state_vars::Storable, + pub minters: aztec::state_vars::Storable, + pub balances: aztec::state_vars::Storable, + pub total_supply: aztec::state_vars::Storable, + pub public_balances: aztec::state_vars::Storable, + pub symbol: aztec::state_vars::Storable, + pub name: aztec::state_vars::Storable, + pub decimals: aztec::state_vars::Storable, + } + + pub struct StorageLayout { + pub contract_name: str, + pub fields: StorageLayoutFields, + } +} + +mod test { + pub mod access_control { + use super::utils; + use crate::Token; + use aztec::protocol::traits::ToField; + + #[test] + unconstrained fn access_control() { + let (env, token_contract_address, owner, new_admin): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress) = utils::setup(false); + let token: Token::Token = Token::at(token_contract_address); + env.call_public(owner, token.set_admin(new_admin)); + assert(env.view_public(token.get_admin()) == new_admin.to_field()); + assert(!env.view_public(token.is_minter(new_admin))); + env.call_public(new_admin, token.set_minter(new_admin, true)); + assert(env.view_public(token.is_minter(new_admin))); + env.call_public(new_admin, token.set_minter(new_admin, false)); + assert(!env.view_public(token.is_minter(new_admin))); + } + + #[test(should_fail_with = "caller is not admin")] + unconstrained fn set_admin_requires_admin_caller() { + let (env, token_contract_address, _, other): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress) = utils::setup(false); + let token: Token::Token = Token::at(token_contract_address); + env.call_public(other, token.set_admin(other)); + } + + #[test(should_fail_with = "caller is not admin")] + unconstrained fn set_minter_requires_admin_caller() { + let (env, token_contract_address, _, other): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress) = utils::setup(false); + let token: Token::Token = Token::at(token_contract_address); + env.call_public(other, token.set_minter(other, true)); + } + } + + pub mod burn_private { + use super::utils; + use crate::Token; + use aztec::test::helpers::authwit::add_private_authwit_from_call; + use generic_proxy_contract::GenericProxy; + + global AUTHWIT_NONCE: Field = 0x07; + + #[test] + unconstrained fn burn_private_on_behalf_of_self() { + let (env, token_contract_address, owner, _, mint_amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_private(false); + let burn_amount: u128 = mint_amount / (10_Field as u128); + env.call_private(owner, Token::at(token_contract_address).burn_private(owner, burn_amount, 0_Field)); + utils::check_private_balance(env, token_contract_address, owner, mint_amount - burn_amount); + } + + #[test] + unconstrained fn burn_private_on_behalf_of_other() { + let (env, token_contract_address, owner, _, mint_amount, proxy): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128, aztec::protocol::address::AztecAddress) = utils::setup_and_mint_to_private_with_proxy(); + let burn_amount: u128 = mint_amount / (10_Field as u128); + let burn_call: aztec::context::calls::PrivateCall<12, 3, ()> = Token::at(token_contract_address).burn_private(owner, burn_amount, AUTHWIT_NONCE); + add_private_authwit_from_call(env, owner, proxy, burn_call); + env.call_private(owner, GenericProxy::at(proxy).forward_private_3(burn_call.target_contract, burn_call.selector, burn_call.args)); + utils::check_private_balance(env, token_contract_address, owner, mint_amount - burn_amount); + } + + #[test(should_fail_with = "Balance too low")] + unconstrained fn burn_private_failure_more_than_balance() { + let (env, token_contract_address, owner, _, mint_amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_public(false); + let burn_amount: u128 = mint_amount * (10_Field as u128); + env.call_private(owner, Token::at(token_contract_address).burn_private(owner, burn_amount, 0_Field)); + } + + #[test(should_fail_with = "Assertion failed: Invalid authwit nonce. When 'from' and 'msg_sender' are the same, 'authwit_nonce' must be zero")] + unconstrained fn burn_private_failure_on_behalf_of_self_non_zero_nonce() { + let (env, token_contract_address, owner, _, mint_amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_public(false); + let burn_amount: u128 = mint_amount; + env.call_private(owner, Token::at(token_contract_address).burn_private(owner, burn_amount, 1_Field)); + } + + #[test(should_fail_with = "Balance too low")] + unconstrained fn burn_private_failure_on_behalf_of_other_more_than_balance() { + let (env, token_contract_address, owner, _, mint_amount, proxy): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128, aztec::protocol::address::AztecAddress) = utils::setup_and_mint_to_public_with_proxy(); + let burn_amount: u128 = mint_amount * (10_Field as u128); + let burn_call: aztec::context::calls::PrivateCall<12, 3, ()> = Token::at(token_contract_address).burn_private(owner, burn_amount, AUTHWIT_NONCE); + add_private_authwit_from_call(env, owner, proxy, burn_call); + env.call_private(owner, GenericProxy::at(proxy).forward_private_3(burn_call.target_contract, burn_call.selector, burn_call.args)); + } + + #[test(should_fail_with = "Unknown auth witness for message hash")] + unconstrained fn burn_private_failure_on_behalf_of_other_without_approval() { + let (env, token_contract_address, owner, _, mint_amount, proxy): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128, aztec::protocol::address::AztecAddress) = utils::setup_and_mint_to_public_with_proxy(); + let burn_amount: u128 = mint_amount / (10_Field as u128); + let burn_call: aztec::context::calls::PrivateCall<12, 3, ()> = Token::at(token_contract_address).burn_private(owner, burn_amount, AUTHWIT_NONCE); + env.call_private(owner, GenericProxy::at(proxy).forward_private_3(burn_call.target_contract, burn_call.selector, burn_call.args)); + } + + #[test(should_fail_with = "Unknown auth witness for message hash")] + unconstrained fn burn_private_failure_on_behalf_of_other_wrong_designated_caller() { + let (env, token_contract_address, owner, _, mint_amount, proxy): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128, aztec::protocol::address::AztecAddress) = utils::setup_and_mint_to_public_with_proxy(); + let burn_amount: u128 = mint_amount / (10_Field as u128); + let burn_call: aztec::context::calls::PrivateCall<12, 3, ()> = Token::at(token_contract_address).burn_private(owner, burn_amount, AUTHWIT_NONCE); + add_private_authwit_from_call(env, owner, owner, burn_call); + env.call_private(owner, GenericProxy::at(proxy).forward_private_3(burn_call.target_contract, burn_call.selector, burn_call.args)); + } + } + + pub mod burn_public { + use super::utils; + use crate::Token; + use aztec::oracle::random::random; + use aztec::test::helpers::authwit::add_public_authwit_from_call; + + #[test] + unconstrained fn burn_public_success() { + let (env, token_contract_address, owner, _, mint_amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_public(false); + let burn_amount: u128 = mint_amount / (10_Field as u128); + env.call_public(owner, Token::at(token_contract_address).burn_public(owner, burn_amount, 0_Field)); + utils::check_public_balance(env, token_contract_address, owner, mint_amount - burn_amount); + } + + #[test] + unconstrained fn burn_public_on_behalf_of_other() { + let (env, token_contract_address, owner, recipient, mint_amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_public(true); + let burn_amount: u128 = mint_amount / (10_Field as u128); + let burn_call: aztec::context::calls::PublicCall<11, 3, ()> = Token::at(token_contract_address).burn_public(owner, burn_amount, random()); + add_public_authwit_from_call(env, owner, recipient, burn_call); + env.call_public(recipient, burn_call); + utils::check_public_balance(env, token_contract_address, owner, mint_amount - burn_amount); + } + + #[test(should_fail_with = "Assertion failed: attempt to subtract with overflow")] + unconstrained fn burn_public_failure_more_than_balance() { + let (env, token_contract_address, owner, _, mint_amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_public(false); + let burn_amount: u128 = mint_amount * (10_Field as u128); + env.call_public(owner, Token::at(token_contract_address).burn_public(owner, burn_amount, 0_Field)); + } + + #[test(should_fail_with = "Assertion failed: Invalid authwit nonce. When 'from' and 'msg_sender' are the same, 'authwit_nonce' must be zero")] + unconstrained fn burn_public_failure_on_behalf_of_self_non_zero_nonce() { + let (env, token_contract_address, owner, _, mint_amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_public(false); + let burn_amount: u128 = mint_amount / (10_Field as u128); + env.call_public(owner, Token::at(token_contract_address).burn_public(owner, burn_amount, random())); + } + + #[test(should_fail_with = "unauthorized")] + unconstrained fn burn_public_failure_on_behalf_of_other_without_approval() { + let (env, token_contract_address, owner, recipient, mint_amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_public(true); + let burn_amount: u128 = mint_amount / (10_Field as u128); + let burn_call: aztec::context::calls::PublicCall<11, 3, ()> = Token::at(token_contract_address).burn_public(owner, burn_amount, random()); + env.call_public(recipient, burn_call); + } + + #[test(should_fail_with = "unauthorized")] + unconstrained fn burn_public_failure_on_behalf_of_other_wrong_caller() { + let (env, token_contract_address, owner, recipient, mint_amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_public(true); + let burn_amount: u128 = mint_amount / (10_Field as u128); + let burn_call: aztec::context::calls::PublicCall<11, 3, ()> = Token::at(token_contract_address).burn_public(owner, burn_amount, random()); + add_public_authwit_from_call(env, owner, owner, burn_call); + env.call_public(recipient, burn_call); + } + } + + pub mod mint_to_public { + use super::utils; + use crate::Token; + + #[test] + unconstrained fn mint_to_public_success() { + let (env, token_contract_address, owner, _): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress) = utils::setup(false); + let mint_amount: u128 = 10000_Field as u128; + env.call_public(owner, Token::at(token_contract_address).mint_to_public(owner, mint_amount)); + utils::check_public_balance(env, token_contract_address, owner, mint_amount); + let total_supply: u128 = env.view_public(Token::at(token_contract_address).total_supply()); + assert(total_supply == mint_amount); + } + + #[test(should_fail_with = "caller is not minter")] + unconstrained fn mint_as_non_minter() { + let (env, token_contract_address, _, recipient): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress) = utils::setup(false); + let mint_amount: u128 = 10000_Field as u128; + env.call_public(recipient, Token::at(token_contract_address).mint_to_public(recipient, mint_amount)); + } + + #[test(should_fail)] + unconstrained fn mint_overflow() { + let (env, token_contract_address, owner, recipient): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress) = utils::setup(false); + let amount_until_overflow: u128 = 1000_Field as u128; + let mint_amount: u128 = (2_Field.pow_32(128_Field) - (amount_until_overflow as Field)) as u128; + env.call_public(owner, Token::at(token_contract_address).mint_to_public(recipient, mint_amount)); + env.call_public(owner, Token::at(token_contract_address).mint_to_public(recipient, amount_until_overflow)); + } + } + + pub mod reading_constants { + use super::utils; + use crate::Token; + + #[test] + unconstrained fn check_decimals_private() { + let (env, token_contract_address, owner, _): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress) = utils::setup(false); + let result: u8 = env.view_private(owner, Token::at(token_contract_address).private_get_decimals()); + assert(result == 18_u8); + } + + #[test] + unconstrained fn check_decimals_public() { + let (env, token_contract_address, _, _): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress) = utils::setup(false); + let result: u8 = env.view_public(Token::at(token_contract_address).public_get_decimals()); + assert(result == 18_u8); + } + } + + pub mod transfer { + use super::utils; + use crate::Token; + + #[test] + unconstrained fn transfer_private() { + let (env, token_contract_address, owner, recipient, mint_amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_private(false); + let transfer_amount: u128 = 1000_Field as u128; + env.call_private(owner, Token::at(token_contract_address).transfer(recipient, transfer_amount)); + utils::check_private_balance(env, token_contract_address, owner, mint_amount - transfer_amount); + utils::check_private_balance(env, token_contract_address, recipient, transfer_amount); + } + + #[test] + unconstrained fn transfer_private_to_self() { + let (env, token_contract_address, owner, _, mint_amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_private(false); + let transfer_amount: u128 = 1000_Field as u128; + let _: () = env.call_private(owner, Token::at(token_contract_address).transfer(owner, transfer_amount)); + utils::check_private_balance(env, token_contract_address, owner, mint_amount); + } + + #[test] + unconstrained fn transfer_private_to_non_deployed_account() { + let (mut env, token_contract_address, owner, _, mint_amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_private(false); + let not_deployed: aztec::protocol::address::AztecAddress = env.create_light_account(); + let transfer_amount: u128 = 1000_Field as u128; + env.call_private(owner, Token::at(token_contract_address).transfer(not_deployed, transfer_amount)); + utils::check_private_balance(env, token_contract_address, owner, mint_amount - transfer_amount); + utils::check_private_balance(env, token_contract_address, not_deployed, transfer_amount); + } + + #[test(should_fail_with = "Balance too low")] + unconstrained fn transfer_private_failure_more_than_balance() { + let (env, token_contract_address, owner, recipient, mint_amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_private(false); + let transfer_amount: u128 = mint_amount + (1_Field as u128); + env.call_private(owner, Token::at(token_contract_address).transfer(recipient, transfer_amount)); + } + } + + pub mod transfer_in_private { + use super::utils; + use crate::Token; + use aztec::test::helpers::authwit::add_private_authwit_from_call; + use generic_proxy_contract::GenericProxy; + + #[test] + unconstrained fn transfer_private_on_behalf_of_other() { + let (env, token_contract_address, owner, recipient, mint_amount, proxy): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128, aztec::protocol::address::AztecAddress) = utils::setup_and_mint_to_private_with_proxy(); + let transfer_amount: u128 = 1000_Field as u128; + let transfer_private_from_call: aztec::context::calls::PrivateCall<19, 4, ()> = Token::at(token_contract_address).transfer_in_private(owner, recipient, transfer_amount, 1_Field); + add_private_authwit_from_call(env, owner, proxy, transfer_private_from_call); + env.call_private(owner, GenericProxy::at(proxy).forward_private_4(transfer_private_from_call.target_contract, transfer_private_from_call.selector, transfer_private_from_call.args)); + utils::check_private_balance(env, token_contract_address, owner, mint_amount - transfer_amount); + utils::check_private_balance(env, token_contract_address, recipient, transfer_amount); + } + + #[test(should_fail_with = "Assertion failed: Invalid authwit nonce. When 'from' and 'msg_sender' are the same, 'authwit_nonce' must be zero")] + unconstrained fn transfer_private_failure_on_behalf_of_self_non_zero_nonce() { + let (env, token_contract_address, owner, recipient, _): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_private(false); + let transfer_amount: u128 = 1000_Field as u128; + let transfer_private_from_call: aztec::context::calls::PrivateCall<19, 4, ()> = Token::at(token_contract_address).transfer_in_private(owner, recipient, transfer_amount, 1_Field); + add_private_authwit_from_call(env, owner, recipient, transfer_private_from_call); + env.call_private(owner, transfer_private_from_call); + } + + #[test(should_fail_with = "Balance too low")] + unconstrained fn transfer_private_failure_on_behalf_of_more_than_balance() { + let (env, token_contract_address, owner, recipient, mint_amount, proxy): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128, aztec::protocol::address::AztecAddress) = utils::setup_and_mint_to_private_with_proxy(); + let transfer_amount: u128 = mint_amount + (1_Field as u128); + let transfer_private_from_call: aztec::context::calls::PrivateCall<19, 4, ()> = Token::at(token_contract_address).transfer_in_private(owner, recipient, transfer_amount, 1_Field); + add_private_authwit_from_call(env, owner, proxy, transfer_private_from_call); + env.call_private(owner, GenericProxy::at(proxy).forward_private_4(transfer_private_from_call.target_contract, transfer_private_from_call.selector, transfer_private_from_call.args)); + } + + #[test(should_fail_with = "Unknown auth witness for message hash")] + unconstrained fn transfer_private_failure_on_behalf_of_other_without_approval() { + let (env, token_contract_address, owner, recipient, _, proxy): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128, aztec::protocol::address::AztecAddress) = utils::setup_and_mint_to_private_with_proxy(); + let transfer_amount: u128 = 1000_Field as u128; + let transfer_private_from_call: aztec::context::calls::PrivateCall<19, 4, ()> = Token::at(token_contract_address).transfer_in_private(owner, recipient, transfer_amount, 1_Field); + env.call_private(owner, GenericProxy::at(proxy).forward_private_4(transfer_private_from_call.target_contract, transfer_private_from_call.selector, transfer_private_from_call.args)); + } + + #[test(should_fail_with = "Unknown auth witness for message hash")] + unconstrained fn transfer_private_failure_on_behalf_of_other_wrong_caller() { + let (env, token_contract_address, owner, recipient, _, proxy): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128, aztec::protocol::address::AztecAddress) = utils::setup_and_mint_to_private_with_proxy(); + let transfer_amount: u128 = 1000_Field as u128; + let transfer_private_from_call: aztec::context::calls::PrivateCall<19, 4, ()> = Token::at(token_contract_address).transfer_in_private(owner, recipient, transfer_amount, 1_Field); + add_private_authwit_from_call(env, owner, owner, transfer_private_from_call); + env.call_private(owner, GenericProxy::at(proxy).forward_private_4(transfer_private_from_call.target_contract, transfer_private_from_call.selector, transfer_private_from_call.args)); + } + } + + pub mod transfer_in_private_with_offchain_delivery { + use super::utils; + use crate::Token; + use aztec::test::helpers::authwit::add_private_authwit_from_call; + use generic_proxy_contract::GenericProxy; + + #[test] + unconstrained fn transfer_in_private_with_offchain_delivery_updates_both_balances() { + let (env, token_contract_address, owner, recipient, mint_amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_private(false); + let transfer_amount: u128 = 1000_Field as u128; + let transfer_call: aztec::context::calls::PrivateCall<42, 4, ()> = Token::at(token_contract_address).transfer_in_private_with_offchain_delivery(owner, recipient, transfer_amount, 0_Field); + env.call_private(owner, transfer_call); + let messages: BoundedVec = env.offchain_messages(); + let mut batch: BoundedVec = BoundedVec::::new(); + for i in 0_u32..messages.len() { + batch.push(messages.get(i)); + }; + env.execute_utility(Token::at(token_contract_address).offchain_receive(batch)); + utils::check_private_balance(env, token_contract_address, owner, mint_amount - transfer_amount); + utils::check_private_balance(env, token_contract_address, recipient, transfer_amount); + } + + #[test(should_fail_with = "Assertion failed: Invalid authwit nonce. When 'from' and 'msg_sender' are the same, 'authwit_nonce' must be zero")] + unconstrained fn transfer_in_private_with_offchain_delivery_failure_on_behalf_of_self_non_zero_nonce() { + let (env, token_contract_address, owner, recipient, _): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_private(false); + let transfer_amount: u128 = 1000_Field as u128; + let transfer_call: aztec::context::calls::PrivateCall<42, 4, ()> = Token::at(token_contract_address).transfer_in_private_with_offchain_delivery(owner, recipient, transfer_amount, 1_Field); + add_private_authwit_from_call(env, owner, recipient, transfer_call); + env.call_private(owner, transfer_call); + } + + #[test(should_fail_with = "Balance too low")] + unconstrained fn transfer_in_private_with_offchain_delivery_failure_on_behalf_of_more_than_balance() { + let (env, token_contract_address, owner, recipient, mint_amount, proxy): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128, aztec::protocol::address::AztecAddress) = utils::setup_and_mint_to_private_with_proxy(); + let transfer_amount: u128 = mint_amount + (1_Field as u128); + let transfer_call: aztec::context::calls::PrivateCall<42, 4, ()> = Token::at(token_contract_address).transfer_in_private_with_offchain_delivery(owner, recipient, transfer_amount, 1_Field); + add_private_authwit_from_call(env, owner, proxy, transfer_call); + env.call_private(owner, GenericProxy::at(proxy).forward_private_4(transfer_call.target_contract, transfer_call.selector, transfer_call.args)); + } + + #[test(should_fail_with = "Unknown auth witness for message hash")] + unconstrained fn transfer_in_private_with_offchain_delivery_failure_on_behalf_of_other_without_approval() { + let (env, token_contract_address, owner, recipient, _, proxy): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128, aztec::protocol::address::AztecAddress) = utils::setup_and_mint_to_private_with_proxy(); + let transfer_amount: u128 = 1000_Field as u128; + let transfer_call: aztec::context::calls::PrivateCall<42, 4, ()> = Token::at(token_contract_address).transfer_in_private_with_offchain_delivery(owner, recipient, transfer_amount, 1_Field); + env.call_private(owner, GenericProxy::at(proxy).forward_private_4(transfer_call.target_contract, transfer_call.selector, transfer_call.args)); + } + + #[test(should_fail_with = "Unknown auth witness for message hash")] + unconstrained fn transfer_in_private_with_offchain_delivery_failure_on_behalf_of_other_wrong_caller() { + let (env, token_contract_address, owner, recipient, _, proxy): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128, aztec::protocol::address::AztecAddress) = utils::setup_and_mint_to_private_with_proxy(); + let transfer_amount: u128 = 1000_Field as u128; + let transfer_call: aztec::context::calls::PrivateCall<42, 4, ()> = Token::at(token_contract_address).transfer_in_private_with_offchain_delivery(owner, recipient, transfer_amount, 1_Field); + add_private_authwit_from_call(env, owner, owner, transfer_call); + env.call_private(owner, GenericProxy::at(proxy).forward_private_4(transfer_call.target_contract, transfer_call.selector, transfer_call.args)); + } + } + + pub mod transfer_in_public { + use super::utils; + use crate::Token; + use aztec::test::helpers::authwit::add_public_authwit_from_call; + + #[test] + unconstrained fn public_transfer() { + let (env, token_contract_address, owner, recipient, mint_amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_public(false); + let transfer_amount: u128 = mint_amount / (10_Field as u128); + env.call_public(owner, Token::at(token_contract_address).transfer_in_public(owner, recipient, transfer_amount, 0_Field)); + utils::check_public_balance(env, token_contract_address, owner, mint_amount - transfer_amount); + utils::check_public_balance(env, token_contract_address, recipient, transfer_amount); + } + + #[test] + unconstrained fn public_transfer_to_self() { + let (env, token_contract_address, owner, _, mint_amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_public(false); + let transfer_amount: u128 = mint_amount / (10_Field as u128); + env.call_public(owner, Token::at(token_contract_address).transfer_in_public(owner, owner, transfer_amount, 0_Field)); + utils::check_public_balance(env, token_contract_address, owner, mint_amount); + } + + #[test] + unconstrained fn public_transfer_on_behalf_of_other() { + let (env, token_contract_address, owner, recipient, mint_amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_public(true); + let transfer_amount: u128 = mint_amount / (10_Field as u128); + let public_transfer_in_private_call: aztec::context::calls::PublicCall<18, 4, ()> = Token::at(token_contract_address).transfer_in_public(owner, recipient, transfer_amount, 1_Field); + add_public_authwit_from_call(env, owner, recipient, public_transfer_in_private_call); + env.call_public(recipient, public_transfer_in_private_call); + utils::check_public_balance(env, token_contract_address, owner, mint_amount - transfer_amount); + utils::check_public_balance(env, token_contract_address, recipient, transfer_amount); + } + + #[test(should_fail_with = "Assertion failed: attempt to subtract with overflow")] + unconstrained fn public_transfer_failure_more_than_balance() { + let (env, token_contract_address, owner, recipient, mint_amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_public(false); + let transfer_amount: u128 = mint_amount + (1_Field as u128); + let public_transfer_call: aztec::context::calls::PublicCall<18, 4, ()> = Token::at(token_contract_address).transfer_in_public(owner, recipient, transfer_amount, 0_Field); + env.call_public(owner, public_transfer_call); + } + + #[test(should_fail_with = "Assertion failed: Invalid authwit nonce. When 'from' and 'msg_sender' are the same, 'authwit_nonce' must be zero")] + unconstrained fn public_transfer_failure_on_behalf_of_self_non_zero_nonce() { + let (env, token_contract_address, owner, recipient, mint_amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_public(false); + let transfer_amount: u128 = mint_amount / (10_Field as u128); + let public_transfer_call: aztec::context::calls::PublicCall<18, 4, ()> = Token::at(token_contract_address).transfer_in_public(owner, recipient, transfer_amount, 1_Field); + add_public_authwit_from_call(env, owner, recipient, public_transfer_call); + env.call_public(owner, public_transfer_call); + } + + #[test(should_fail_with = "unauthorized")] + unconstrained fn public_transfer_failure_on_behalf_of_other_without_approval() { + let (env, token_contract_address, owner, recipient, mint_amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_public(true); + let transfer_amount: u128 = mint_amount / (10_Field as u128); + let public_transfer_in_private_call: aztec::context::calls::PublicCall<18, 4, ()> = Token::at(token_contract_address).transfer_in_public(owner, recipient, transfer_amount, 1_Field); + env.call_public(recipient, public_transfer_in_private_call); + } + + #[test(should_fail_with = "Assertion failed: attempt to subtract with overflow")] + unconstrained fn public_transfer_failure_on_behalf_of_other_more_than_balance() { + let (env, token_contract_address, owner, recipient, mint_amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_public(true); + let transfer_amount: u128 = mint_amount + (1_Field as u128); + let public_transfer_in_private_call: aztec::context::calls::PublicCall<18, 4, ()> = Token::at(token_contract_address).transfer_in_public(owner, recipient, transfer_amount, 1_Field); + add_public_authwit_from_call(env, owner, recipient, public_transfer_in_private_call); + env.call_public(recipient, public_transfer_in_private_call); + } + + #[test(should_fail_with = "unauthorized")] + unconstrained fn public_transfer_failure_on_behalf_of_other_wrong_caller() { + let (env, token_contract_address, owner, recipient, mint_amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_public(true); + let transfer_amount: u128 = mint_amount / (10_Field as u128); + let public_transfer_in_private_call: aztec::context::calls::PublicCall<18, 4, ()> = Token::at(token_contract_address).transfer_in_public(owner, recipient, transfer_amount, 1_Field); + add_public_authwit_from_call(env, owner, owner, public_transfer_in_private_call); + env.call_public(recipient, public_transfer_in_private_call); + } + } + + pub mod transfer_to_private { + use super::utils; + use crate::Token; + use aztec::oracle::random::random; + use aztec::protocol::traits::Deserialize; + use uint_note::PartialUintNote; + + /// Internal orchestration means that the calls to `prepare_private_balance_increase` + /// and `finalize_transfer_to_private` are done by the TOKEN contract itself. + /// In this test's case this is done by the `Token::transfer_to_private(...)` function called + /// in `utils::setup_mint_and_transfer_to_private`. + #[test] + unconstrained fn transfer_to_private_internal_orchestration() { + let (env, token_contract_address, user, _, amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_private(false); + utils::check_private_balance(env, token_contract_address, user, amount); + } + + /// External orchestration means that the calls to prepare and finalize are not done by the Token contract. This flow + /// will typically be used by a DEX. + #[test] + unconstrained fn transfer_to_private_external_orchestration() { + let (env, token_contract_address, owner, recipient, amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_public(false); + let partial_uint_note: PartialUintNote = env.call_private(owner, Token::at(token_contract_address).prepare_private_balance_increase(recipient)); + env.call_public(owner, Token::at(token_contract_address).finalize_transfer_to_private(amount, partial_uint_note)); + utils::check_private_balance(env, token_contract_address, recipient, amount); + } + + /// External orchestration means that the calls to prepare and finalize are not done by the Token contract. This flow + /// will typically be used by a DEX. + #[test] + unconstrained fn transfer_to_private_from_private_external_orchestration() { + let (env, token_contract_address, owner, recipient, amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_private(false); + let partial_uint_note: PartialUintNote = env.call_private(owner, Token::at(token_contract_address).prepare_private_balance_increase(recipient)); + env.call_private(owner, Token::at(token_contract_address).finalize_transfer_to_private_from_private(owner, partial_uint_note, amount, 0_Field)); + utils::check_private_balance(env, token_contract_address, recipient, amount); + utils::check_private_balance(env, token_contract_address, owner, 0_u128); + } + + #[test(should_fail_with = "Invalid partial note or completer")] + unconstrained fn transfer_to_private_transfer_not_prepared() { + let (env, token_contract_address, owner, _, amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_public(false); + let commitment: Field = random(); + let partial_uint_note: PartialUintNote = PartialUintNote::deserialize([commitment]); + env.call_public(owner, Token::at(token_contract_address).finalize_transfer_to_private(amount, partial_uint_note)); + } + + #[test(should_fail_with = "Assertion failed: attempt to subtract with overflow")] + unconstrained fn transfer_to_private_failure_not_an_owner() { + let (env, token_contract_address, owner, not_owner, amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_public(false); + let partial_uint_note: PartialUintNote = env.call_private(owner, Token::at(token_contract_address).prepare_private_balance_increase(not_owner)); + env.call_public(not_owner, Token::at(token_contract_address).finalize_transfer_to_private(amount, partial_uint_note)); + } + + #[test(should_fail_with = "Invalid partial note or completer")] + unconstrained fn incorrect_completer_cannot_complete_partial_note() { + let (mut env, token_contract_address, owner, recipient, amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_public(false); + let completer: aztec::protocol::address::AztecAddress = env.create_light_account(); + let partial_uint_note: PartialUintNote = env.call_private(completer, Token::at(token_contract_address).prepare_private_balance_increase(recipient)); + env.call_public(owner, Token::at(token_contract_address).finalize_transfer_to_private(amount, partial_uint_note)); + } + } + + pub mod transfer_to_public { + use super::utils; + use crate::Token; + use aztec::oracle::random::random; + use aztec::test::helpers::authwit::add_private_authwit_from_call; + use generic_proxy_contract::GenericProxy; + + #[test] + unconstrained fn transfer_to_public_on_behalf_of_self() { + let (env, token_contract_address, owner, _, mint_amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_private(false); + let transfer_to_public_amount: u128 = mint_amount / (10_Field as u128); + env.call_private(owner, Token::at(token_contract_address).transfer_to_public(owner, owner, transfer_to_public_amount, 0_Field)); + utils::check_private_balance(env, token_contract_address, owner, mint_amount - transfer_to_public_amount); + utils::check_public_balance(env, token_contract_address, owner, transfer_to_public_amount); + } + + #[test] + unconstrained fn transfer_to_public_on_behalf_of_other() { + let (env, token_contract_address, owner, recipient, mint_amount, proxy): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128, aztec::protocol::address::AztecAddress) = utils::setup_and_mint_to_private_with_proxy(); + let transfer_to_public_amount: u128 = mint_amount / (10_Field as u128); + let transfer_to_public_call: aztec::context::calls::PrivateCall<18, 4, ()> = Token::at(token_contract_address).transfer_to_public(owner, recipient, transfer_to_public_amount, 0_Field); + add_private_authwit_from_call(env, owner, proxy, transfer_to_public_call); + env.call_private(owner, GenericProxy::at(proxy).forward_private_4(transfer_to_public_call.target_contract, transfer_to_public_call.selector, transfer_to_public_call.args)); + utils::check_private_balance(env, token_contract_address, owner, mint_amount - transfer_to_public_amount); + utils::check_public_balance(env, token_contract_address, recipient, transfer_to_public_amount); + } + + #[test(should_fail_with = "Balance too low")] + unconstrained fn transfer_to_public_failure_more_than_balance() { + let (env, token_contract_address, owner, _, mint_amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_private(false); + let transfer_to_public_amount: u128 = mint_amount + (1_Field as u128); + env.call_private(owner, Token::at(token_contract_address).transfer_to_public(owner, owner, transfer_to_public_amount, 0_Field)); + } + + #[test(should_fail_with = "Assertion failed: Invalid authwit nonce. When 'from' and 'msg_sender' are the same, 'authwit_nonce' must be zero")] + unconstrained fn transfer_to_public_failure_on_behalf_of_self_non_zero_nonce() { + let (env, token_contract_address, owner, _, mint_amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_private(false); + let transfer_to_public_amount: u128 = mint_amount + (1_Field as u128); + env.call_private(owner, Token::at(token_contract_address).transfer_to_public(owner, owner, transfer_to_public_amount, random())); + } + + #[test(should_fail_with = "Balance too low")] + unconstrained fn transfer_to_public_failure_on_behalf_of_other_more_than_balance() { + let (env, token_contract_address, owner, recipient, mint_amount, proxy): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128, aztec::protocol::address::AztecAddress) = utils::setup_and_mint_to_private_with_proxy(); + let transfer_to_public_amount: u128 = mint_amount + (1_Field as u128); + let transfer_to_public_call: aztec::context::calls::PrivateCall<18, 4, ()> = Token::at(token_contract_address).transfer_to_public(owner, recipient, transfer_to_public_amount, 0_Field); + add_private_authwit_from_call(env, owner, proxy, transfer_to_public_call); + env.call_private(owner, GenericProxy::at(proxy).forward_private_4(transfer_to_public_call.target_contract, transfer_to_public_call.selector, transfer_to_public_call.args)); + } + + #[test(should_fail_with = "Unknown auth witness for message hash")] + unconstrained fn transfer_to_public_failure_on_behalf_of_other_invalid_designated_caller() { + let (env, token_contract_address, owner, recipient, mint_amount, proxy): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128, aztec::protocol::address::AztecAddress) = utils::setup_and_mint_to_private_with_proxy(); + let transfer_to_public_amount: u128 = mint_amount + (1_Field as u128); + let transfer_to_public_call: aztec::context::calls::PrivateCall<18, 4, ()> = Token::at(token_contract_address).transfer_to_public(owner, recipient, transfer_to_public_amount, 0_Field); + add_private_authwit_from_call(env, owner, owner, transfer_to_public_call); + env.call_private(owner, GenericProxy::at(proxy).forward_private_4(transfer_to_public_call.target_contract, transfer_to_public_call.selector, transfer_to_public_call.args)); + } + + #[test(should_fail_with = "Unknown auth witness for message hash")] + unconstrained fn transfer_to_public_failure_on_behalf_of_other_no_approval() { + let (env, token_contract_address, owner, recipient, mint_amount, proxy): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128, aztec::protocol::address::AztecAddress) = utils::setup_and_mint_to_private_with_proxy(); + let transfer_to_public_amount: u128 = mint_amount + (1_Field as u128); + let transfer_to_public_call: aztec::context::calls::PrivateCall<18, 4, ()> = Token::at(token_contract_address).transfer_to_public(owner, recipient, transfer_to_public_amount, 0_Field); + env.call_private(owner, GenericProxy::at(proxy).forward_private_4(transfer_to_public_call.target_contract, transfer_to_public_call.selector, transfer_to_public_call.args)); + } + } + + pub mod transfer_to_public_and_prepare_private_balance_increase { + use super::utils; + use crate::Token; + use aztec::oracle::random::random; + use aztec::protocol::traits::Deserialize; + use aztec::test::helpers::authwit::add_private_authwit_from_call; + use generic_proxy_contract::GenericProxy; + use uint_note::PartialUintNote; + + #[test] + unconstrained fn transfer_to_public_and_prepare_private_balance_increase_and_finalize_transfer_to_private() { + let (env, token_contract_address, liquidity_provider, _, mint_amount, proxy): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128, aztec::protocol::address::AztecAddress) = utils::setup_and_mint_to_private_with_proxy(); + let deposit_amount: u128 = mint_amount / (10_Field as u128); + let transfer_call: aztec::context::calls::PrivateCall<55, 4, PartialUintNote> = Token::at(token_contract_address).transfer_to_public_and_prepare_private_balance_increase(liquidity_provider, proxy, deposit_amount, 1_Field); + add_private_authwit_from_call(env, liquidity_provider, proxy, transfer_call); + let partial_note_field: Field = env.call_private(liquidity_provider, GenericProxy::at(proxy).forward_private_4_and_return(transfer_call.target_contract, transfer_call.selector, transfer_call.args)); + let partial_note: PartialUintNote = ::deserialize([partial_note_field]); + utils::check_private_balance(env, token_contract_address, liquidity_provider, mint_amount - deposit_amount); + utils::check_public_balance(env, token_contract_address, proxy, deposit_amount); + let change_amount: u128 = deposit_amount / (2_Field as u128); + env.call_public(proxy, Token::at(token_contract_address).finalize_transfer_to_private(change_amount, partial_note)); + utils::check_private_balance(env, token_contract_address, liquidity_provider, (mint_amount - deposit_amount) + change_amount); + utils::check_public_balance(env, token_contract_address, proxy, deposit_amount - change_amount); + } + + #[test(should_fail_with = "Balance too low")] + unconstrained fn transfer_to_public_and_prepare_private_balance_increase_failure_more_than_balance() { + let (env, token_contract_address, sender, recipient, mint_amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_private(false); + let transfer_amount: u128 = mint_amount + (1_Field as u128); + let _: PartialUintNote = env.call_private(sender, Token::at(token_contract_address).transfer_to_public_and_prepare_private_balance_increase(sender, recipient, transfer_amount, 0_Field)); + } + + #[test(should_fail_with = "Assertion failed: Invalid authwit nonce. When 'from' and 'msg_sender' are the same, 'authwit_nonce' must be zero")] + unconstrained fn transfer_to_public_and_prepare_private_balance_increase_failure_on_behalf_of_self_non_zero_nonce() { + let (env, token_contract_address, sender, recipient, mint_amount): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128) = utils::setup_and_mint_to_private(false); + let transfer_amount: u128 = mint_amount / (10_Field as u128); + let _: PartialUintNote = env.call_private(sender, Token::at(token_contract_address).transfer_to_public_and_prepare_private_balance_increase(sender, recipient, transfer_amount, random())); + } + + #[test(should_fail_with = "Unknown auth witness for message hash")] + unconstrained fn transfer_to_public_and_prepare_private_balance_increase_failure_on_behalf_of_other_no_approval() { + let (env, token_contract_address, sender, recipient, mint_amount, proxy): (aztec::test::helpers::test_environment::TestEnvironment, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, aztec::protocol::address::AztecAddress, u128, aztec::protocol::address::AztecAddress) = utils::setup_and_mint_to_private_with_proxy(); + let transfer_amount: u128 = mint_amount / (10_Field as u128); + let transfer_call: aztec::context::calls::PrivateCall<55, 4, PartialUintNote> = Token::at(token_contract_address).transfer_to_public_and_prepare_private_balance_increase(sender, recipient, transfer_amount, 1_Field); + env.call_private(sender, GenericProxy::at(proxy).forward_private_4(transfer_call.target_contract, transfer_call.selector, transfer_call.args)); + } + } + + pub mod utils { + use crate::Token; + use aztec::protocol::address::AztecAddress; + use aztec::test::helpers::test_environment::TestEnvironment; + + pub unconstrained fn setup(with_account_contracts: bool) -> (TestEnvironment, AztecAddress, AztecAddress, AztecAddress) { + let mut env: TestEnvironment = TestEnvironment::new(); + let (owner, recipient): (AztecAddress, AztecAddress) = if with_account_contracts { + let owner: AztecAddress = env.create_contract_account(); + let recipient: AztecAddress = env.create_contract_account(); + (owner, recipient) + } else { + let owner: AztecAddress = env.create_light_account(); + let recipient: AztecAddress = env.create_light_account(); + (owner, recipient) + }; + let initializer_call: aztec::context::calls::PublicCall<11, 64, ()> = Token::interface().constructor(owner, "TestToken0000000000000000000000", "TT00000000000000000000000000000", 18_u8); + let token_contract_address: AztecAddress = env.deploy("Token").with_public_initializer(owner, initializer_call); + (env, token_contract_address, owner, recipient) + } + + pub unconstrained fn setup_and_mint_to_public(with_account_contracts: bool) -> (TestEnvironment, AztecAddress, AztecAddress, AztecAddress, u128) { + let (env, token_contract_address, owner, recipient): (TestEnvironment, AztecAddress, AztecAddress, AztecAddress) = setup(with_account_contracts); + let mint_amount: u128 = 10000_Field as u128; + env.call_public(owner, Token::at(token_contract_address).mint_to_public(owner, mint_amount)); + (env, token_contract_address, owner, recipient, mint_amount) + } + + pub unconstrained fn setup_and_mint_amount_to_private(with_account_contracts: bool, mint_amount: u128) -> (TestEnvironment, AztecAddress, AztecAddress, AztecAddress, u128) { + let (env, token_contract_address, owner, recipient): (TestEnvironment, AztecAddress, AztecAddress, AztecAddress) = setup(with_account_contracts); + env.call_private(owner, Token::at(token_contract_address).mint_to_private(owner, mint_amount)); + (env, token_contract_address, owner, recipient, mint_amount) + } + + pub unconstrained fn setup_and_mint_to_private(with_account_contracts: bool) -> (TestEnvironment, AztecAddress, AztecAddress, AztecAddress, u128) { + let mint_amount: u128 = 10000_Field as u128; + setup_and_mint_amount_to_private(with_account_contracts, mint_amount) + } + + pub unconstrained fn check_public_balance(env: TestEnvironment, token_contract_address: AztecAddress, address: AztecAddress, address_amount: u128) { + assert(env.view_public(Token::at(token_contract_address).balance_of_public(address)) == address_amount); + } + + pub unconstrained fn check_private_balance(env: TestEnvironment, token_contract_address: AztecAddress, address: AztecAddress, address_amount: u128) { + assert(env.execute_utility(Token::at(token_contract_address).balance_of_private(address)) == address_amount); + } + + pub unconstrained fn setup_and_mint_to_private_with_proxy() -> (TestEnvironment, AztecAddress, AztecAddress, AztecAddress, u128, AztecAddress) { + let (mut env, token_contract_address, owner, recipient, mint_amount): (TestEnvironment, AztecAddress, AztecAddress, AztecAddress, u128) = setup_and_mint_to_private(true); + let proxy: AztecAddress = env.deploy("@generic_proxy_contract/GenericProxy").without_initializer(); + (env, token_contract_address, owner, recipient, mint_amount, proxy) + } + + pub unconstrained fn setup_and_mint_to_public_with_proxy() -> (TestEnvironment, AztecAddress, AztecAddress, AztecAddress, u128, AztecAddress) { + let (mut env, token_contract_address, owner, recipient, mint_amount): (TestEnvironment, AztecAddress, AztecAddress, AztecAddress, u128) = setup_and_mint_to_public(true); + let proxy: AztecAddress = env.deploy("@generic_proxy_contract/GenericProxy").without_initializer(); + (env, token_contract_address, owner, recipient, mint_amount, proxy) + } + } +} + +// Warning: the generated code has syntax errors diff --git a/noir-projects/noir-contracts-comp-failures/README.md b/noir-projects/noir-contracts-comp-failures/README.md deleted file mode 100644 index d158c4376e3e..000000000000 --- a/noir-projects/noir-contracts-comp-failures/README.md +++ /dev/null @@ -1,37 +0,0 @@ -## Noir Contracts Compilation Failures - -Aztec-nr contracts that are expected to fail to compile. Each case asserts that compilation fails *and* that the full set of `error:` diagnostics nargo emits matches a committed snapshot, so an unrelated regression that breaks compilation for a different reason does not silently pass. - -### Layout - -Each contract lives in `contracts//` with: - -- `Nargo.toml` — `type = "contract"`, depends on `aztec = { path = "../../../aztec-nr/aztec" }`. -- `src/main.nr` — the intentionally invalid contract. -- `expected_error` — one line per nargo `error:` headline (stripped of the `error: ` prefix), in emission order. An empty file means the contract is expected to compile successfully; see its `src/main.nr` doc comment for context. - -### Running - -```sh -./bootstrap.sh test # all cases -./bootstrap.sh test reserved_public_dispatch # one case -./bootstrap.sh test 'panic_on_*' # glob subset -``` - -For each contract the runner: - -1. Runs `nargo compile --silence-warnings` and asserts it fails. -2. Extracts every `error: ` line from stderr in order and strips the `error: ` prefix. -3. Requires the extracted list to equal, line for line, the non-blank lines of `expected_error`. Any difference — text, count, or order — fails the test. - -### Updating expected errors - -When a compiler or macro error message changes intentionally, regenerate snapshots locally: - -```sh -ACCEPT_SNAPSHOTS=1 ./bootstrap.sh test -``` - -The runner extracts each `error: ` headline, strips the prefix, and writes one per line — no manual trimming needed. If nargo emits no `error: ` diagnostics (e.g. an internal compiler panic), the full stderr is written and a `⚠` warning is printed; those cases need a manual trim before committing. - -CI refuses to run with `ACCEPT_SNAPSHOTS` set (`CI=1 ACCEPT_SNAPSHOTS=1` exits non-zero), so any drift between committed snapshots and actual stderr must be resolved intentionally by a developer. diff --git a/noir-projects/noir-contracts-comp-failures/bootstrap.sh b/noir-projects/noir-contracts-comp-failures/bootstrap.sh deleted file mode 100755 index 8983b882b43c..000000000000 --- a/noir-projects/noir-contracts-comp-failures/bootstrap.sh +++ /dev/null @@ -1,146 +0,0 @@ -#!/usr/bin/env bash -source $(git rev-parse --show-toplevel)/ci3/source_bootstrap - -# nargo command path relative to the individual contract directory -export NARGO=${NARGO:-../../../../noir/noir-repo/target/release/nargo} - -# Check that `nargo compile` stderr matches expected_error exactly. -# -# Every nargo compile error begins with a line `error: `. The runner -# extracts that ordered list of headlines (stripped of the `error: ` prefix) and -# requires it to equal, line for line, the non-blank lines in expected_error. -# Any change to the emitted errors — different text, different count, different -# order — fails the test and must be resolved by regenerating the snapshot. -# -# When ACCEPT_SNAPSHOTS=1 the runner skips assertion and writes every extracted -# headline (one per line) into expected_error. CI refuses this flag so any drift -# must be resolved by a developer locally. If nargo emits no `error: ` lines -# (e.g. an internal compiler panic), the full stderr is written instead and a -# warning is printed — such cases need a manual trim before committing. -check_compilation_error() { - local contract_dir=$1 - local expected_error_file="$contract_dir/expected_error" - - local actual_output - local compile_rc=0 - actual_output=$(cd "$contract_dir" && $NARGO compile --silence-warnings 2>&1) || compile_rc=$? - - local actual_headlines - actual_headlines=$(echo "$actual_output" | awk '/^error: /{sub(/^error: /, ""); print}') - - if [ -n "${ACCEPT_SNAPSHOTS:-}" ]; then - if [ "$compile_rc" -eq 0 ]; then - : > "$expected_error_file" - echo "↻ $contract_dir: wrote empty expected_error (compiled successfully)" - elif [ -n "$actual_headlines" ]; then - echo "$actual_headlines" > "$expected_error_file" - local count - count=$(printf '%s\n' "$actual_headlines" | wc -l | tr -d ' ') - echo "↻ $contract_dir: wrote $count headline(s) to expected_error" - else - echo "$actual_output" > "$expected_error_file" - echo "⚠ $contract_dir: no 'error: ' headlines found in stderr; wrote full output — trim manually" - fi - return 0 - fi - - if [ ! -f "$expected_error_file" ]; then - echo "✗ $contract_dir: No expected_error file. Run with ACCEPT_SNAPSHOTS=1 to generate one." - exit 1 - fi - - local -a expected_lines=() actual_lines=() - while IFS= read -r line; do - [ -z "$line" ] && continue - expected_lines+=("$line") - done < "$expected_error_file" - while IFS= read -r line; do - actual_lines+=("$line") - done <<< "$actual_headlines" - # `<<<` always appends a newline; if no headlines were found this leaves a - # single empty element that would miscount 0 as 1. - if [ "${#actual_lines[@]}" -eq 1 ] && [ -z "${actual_lines[0]}" ]; then - actual_lines=() - fi - - if [ "${#expected_lines[@]}" -ne "${#actual_lines[@]}" ]; then - echo "✗ $contract_dir: error count mismatch — expected ${#expected_lines[@]}, got ${#actual_lines[@]}" - echo "Expected lines:" - if [ "${#expected_lines[@]}" -eq 0 ]; then echo " (none)"; else printf ' %s\n' "${expected_lines[@]}"; fi - echo "Actual error headlines:" - if [ "${#actual_lines[@]}" -eq 0 ]; then echo " (none)"; else printf ' %s\n' "${actual_lines[@]}"; fi - echo "Full stderr:" - echo "$actual_output" - exit 1 - fi - - local i - for i in "${!expected_lines[@]}"; do - if [ "${actual_lines[$i]}" != "${expected_lines[$i]}" ]; then - echo "✗ $contract_dir: error $((i + 1)) does not match" - echo " Expected: ${expected_lines[$i]}" - echo " Actual: ${actual_lines[$i]}" - echo "Full stderr:" - echo "$actual_output" - exit 1 - fi - done - - if [ "${#expected_lines[@]}" -eq 0 ]; then - echo "⚠ $contract_dir: compiled successfully (see src/main.nr doc comment)" - else - echo "✓ $contract_dir: Compilation failed as expected with correct error(s)" - fi -} - -# Tests that compilation of contracts in noir-contracts-comp-failures fails with the expected error message. -# -# Optional arg: a shell glob to filter by contract directory name. Examples: -# ./bootstrap.sh test # all cases -# ./bootstrap.sh test reserved_public_dispatch -# ./bootstrap.sh test 'panic_on_*' -test() { - if [ -n "${ACCEPT_SNAPSHOTS:-}" ] && [ "${CI:-0}" = "1" ]; then - echo "ACCEPT_SNAPSHOTS is not permitted in CI. Snapshots must be regenerated locally and committed." >&2 - exit 1 - fi - - local pattern=${1:-} - local matched=0 - - for contract_dir in contracts/*/; do - [ -d "$contract_dir" ] || continue - if [ -n "$pattern" ]; then - local name=${contract_dir%/} - name=${name#contracts/} - # `case` pattern matching supports shell globs; leave $pattern unquoted. - case "$name" in - $pattern) ;; - *) continue ;; - esac - fi - check_compilation_error "$contract_dir" - matched=$((matched + 1)) - done - - if [ -n "$pattern" ] && [ "$matched" -eq 0 ]; then - echo "✗ no contracts matched pattern '$pattern'" >&2 - exit 1 - fi -} - -function test_cmds { - # Fairies want to run these tests on every PR - if [ "${TARGET_BRANCH:-}" = "merge-train/fairies" ]; then - hash=disabled-cache - else - hash=$(hash_str $(../../noir/bootstrap.sh hash) $(cache_content_hash ^noir-projects/noir-contracts-comp-failures)) - fi - echo "$hash ./noir-projects/noir-contracts-comp-failures/bootstrap.sh test" -} - -case "$cmd" in - *) - default_cmd_handler "$@" - ;; -esac diff --git a/noir-projects/noir-contracts-comp-failures/contracts/.gitignore b/noir-projects/noir-contracts-comp-failures/contracts/.gitignore deleted file mode 100644 index b60de5b5f2c9..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/.gitignore +++ /dev/null @@ -1 +0,0 @@ -**/target diff --git a/noir-projects/noir-contracts-comp-failures/contracts/allow_phase_change_on_non_external_fn/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/allow_phase_change_on_non_external_fn/expected_error deleted file mode 100644 index 81efd937b978..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/allow_phase_change_on_non_external_fn/expected_error +++ /dev/null @@ -1 +0,0 @@ -The #[allow_phase_change] attribute can only be applied to #[external("private")] functions - foo is not diff --git a/noir-projects/noir-contracts-comp-failures/contracts/allow_phase_change_on_utility_fn/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/allow_phase_change_on_utility_fn/expected_error deleted file mode 100644 index 8938c1a408f3..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/allow_phase_change_on_utility_fn/expected_error +++ /dev/null @@ -1 +0,0 @@ -The #[allow_phase_change] attribute cannot be applied to #[external("utility")] functions - foo diff --git a/noir-projects/noir-contracts-comp-failures/contracts/authorization_selector_collision/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/authorization_selector_collision/expected_error deleted file mode 100644 index eb13bb71d948..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/authorization_selector_collision/expected_error +++ /dev/null @@ -1,5 +0,0 @@ -Trait crate::authwit::authorization_interface::AuthorizationInterface not found -Could not resolve 'authwit' in path -check_trait_impl_where_clause_matches_trait_where_clause: missing trait ID -check_trait_impl_method_matches_declaration: missing trait impl -Selector collision detected between authorizations 'EventCollision8370082250' and 'EventCollision' diff --git a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_before_external/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_before_external/expected_error deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_from_wrong_type/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_from_wrong_type/expected_error deleted file mode 100644 index 1bbce0be00f8..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_from_wrong_type/expected_error +++ /dev/null @@ -1 +0,0 @@ -Argument from in function foo must be of type AztecAddress, but is of type Field diff --git a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_missing_from_param/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_missing_from_param/expected_error deleted file mode 100644 index 8b1cfa5ad9d6..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_missing_from_param/expected_error +++ /dev/null @@ -1 +0,0 @@ -Function foo does not have a from parameter. Please specify which one to use in #[authorize_once("...", "authwit_nonce")] diff --git a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_missing_nonce_param/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_missing_nonce_param/expected_error deleted file mode 100644 index ed3aaf603d01..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_missing_nonce_param/expected_error +++ /dev/null @@ -1 +0,0 @@ -Function foo does not have a authwit_nonce. Please specify which one to use in #[authorize_once("from", "...")] diff --git a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_nonce_wrong_type/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_nonce_wrong_type/expected_error deleted file mode 100644 index bd57ebb6529a..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_nonce_wrong_type/expected_error +++ /dev/null @@ -1 +0,0 @@ -Argument authwit_nonce in function foo must be of type Field, but is of type u64 diff --git a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_on_non_external_fn/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_on_non_external_fn/expected_error deleted file mode 100644 index f3f70104ef54..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_on_non_external_fn/expected_error +++ /dev/null @@ -1 +0,0 @@ -The #[authorize_once] attribute can only be applied to #[external("private")] or #[external("public")] functions - foo is neither diff --git a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_on_utility_fn/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_on_utility_fn/expected_error deleted file mode 100644 index dbe74ea297fa..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/authorize_once_on_utility_fn/expected_error +++ /dev/null @@ -1 +0,0 @@ -The #[authorize_once] attribute cannot be applied to #[external("utility")] functions - foo diff --git a/noir-projects/noir-contracts-comp-failures/contracts/aztec_macro_too_many_args/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/aztec_macro_too_many_args/expected_error deleted file mode 100644 index ef5de9454fe1..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/aztec_macro_too_many_args/expected_error +++ /dev/null @@ -1 +0,0 @@ -#[aztec] expects 0 or 1 arguments, got 2 diff --git a/noir-projects/noir-contracts-comp-failures/contracts/bob_token/Nargo.toml b/noir-projects/noir-contracts-comp-failures/contracts/bob_token/Nargo.toml deleted file mode 100644 index c43230433fb1..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/bob_token/Nargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "bob_token" -type = "contract" -authors = [""] - -[dependencies] -aztec = { path = "../../../aztec-nr/aztec" } -balance_set = { path = "../../../aztec-nr/balance-set" } diff --git a/noir-projects/noir-contracts-comp-failures/contracts/bob_token/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/bob_token/expected_error deleted file mode 100644 index 29117d5b03e1..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/bob_token/expected_error +++ /dev/null @@ -1,38 +0,0 @@ -The #[internal] attribute cannot be applied to external functions - transfer_public is marked as both #[external] and #[internal("public")] -A function marked as #[external("private")] or #[internal("private")] must not have public Noir visibility - transfer_private's visibility is 'pub' -The #[view] attribute can only be applied to #[external("private")] or #[external("public")] functions - _assert_is_owner is neither -#[external("private")] or #[internal("private")] functions must not be unconstrained - mint_private is -Function _assert_is_owner must be marked as either #[external(...)], #[internal(...)], or #[test] -cannot find `self` in this scope -cannot find `self` in this scope -cannot find `self` in this scope -cannot find `self` in this scope -cannot find `self` in this scope -cannot find `self` in this scope -cannot find `self` in this scope -cannot find `self` in this scope -cannot find `self` in this scope -cannot find `self` in this scope -cannot find `self` in this scope -cannot find `self` in this scope -cannot find `self` in this scope -cannot find `self` in this scope -cannot find `self` in this scope -cannot find `self` in this scope -cannot find `self` in this scope -cannot find `self` in this scope -cannot find `self` in this scope -cannot find `self` in this scope -cannot find `self` in this scope -missing pub keyword on return type of function private_balance_of -cannot find `self` in this scope -missing pub keyword on return type of function public_balance_of -cannot find `self` in this scope -cannot find `self` in this scope -cannot find `self` in this scope -cannot find `self` in this scope -cannot find `self` in this scope -cannot find `self` in this scope -cannot find `self` in this scope -cannot find `self` in this scope -cannot find `self` in this scope diff --git a/noir-projects/noir-contracts-comp-failures/contracts/duplicate_storage/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/duplicate_storage/expected_error deleted file mode 100644 index c1331b6dca3f..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/duplicate_storage/expected_error +++ /dev/null @@ -1 +0,0 @@ -The #[storage] macro can only be applied to a struct with name 'Storage', got 'Storage2' instead. diff --git a/noir-projects/noir-contracts-comp-failures/contracts/event_selector_collision/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/event_selector_collision/expected_error deleted file mode 100644 index 5d2027e29796..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/event_selector_collision/expected_error +++ /dev/null @@ -1 +0,0 @@ -Event selector collision detected between events 'EventCollision8370082250' and 'EventCollision' diff --git a/noir-projects/noir-contracts-comp-failures/contracts/external_and_internal_together/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/external_and_internal_together/expected_error deleted file mode 100644 index bf93cad5e5d7..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/external_and_internal_together/expected_error +++ /dev/null @@ -1 +0,0 @@ -The #[internal] attribute cannot be applied to external functions - foo is marked as both #[external] and #[internal("private")] diff --git a/noir-projects/noir-contracts-comp-failures/contracts/incorrect_storage_struct_name/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/incorrect_storage_struct_name/expected_error deleted file mode 100644 index c1331b6dca3f..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/incorrect_storage_struct_name/expected_error +++ /dev/null @@ -1 +0,0 @@ -The #[storage] macro can only be applied to a struct with name 'Storage', got 'Storage2' instead. diff --git a/noir-projects/noir-contracts-comp-failures/contracts/initializer_on_non_external_fn/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/initializer_on_non_external_fn/expected_error deleted file mode 100644 index 5c684056da32..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/initializer_on_non_external_fn/expected_error +++ /dev/null @@ -1 +0,0 @@ -The #[initializer] attribute can only be applied to #[external("private")] or #[external("public")] functions - foo is neither diff --git a/noir-projects/noir-contracts-comp-failures/contracts/initializer_on_utility_fn/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/initializer_on_utility_fn/expected_error deleted file mode 100644 index 73500d3e2c07..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/initializer_on_utility_fn/expected_error +++ /dev/null @@ -1 +0,0 @@ -The #[initializer] attribute cannot be applied to #[external("utility")] functions - foo diff --git a/noir-projects/noir-contracts-comp-failures/contracts/invalid_event/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/invalid_event/expected_error deleted file mode 100644 index 52ea26ac60ee..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/invalid_event/expected_error +++ /dev/null @@ -1 +0,0 @@ -event's serialized length exceeds the maximum allowed for private events diff --git a/noir-projects/noir-contracts-comp-failures/contracts/invalid_external_function_type/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/invalid_external_function_type/expected_error deleted file mode 100644 index e53202f2683b..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/invalid_external_function_type/expected_error +++ /dev/null @@ -1 +0,0 @@ -Function 'invalid_external_function_type' is marked as #[external("invalid")], but 'invalid' is not a valid external function type. External functions must be one of 'private', 'public' or 'utility' diff --git a/noir-projects/noir-contracts-comp-failures/contracts/invalid_internal_function_type/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/invalid_internal_function_type/expected_error deleted file mode 100644 index 598737fea58a..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/invalid_internal_function_type/expected_error +++ /dev/null @@ -1 +0,0 @@ -Function 'foo' is marked as #[internal("utility")], but 'utility' is not a valid internal function type. Internal functions must be one of 'private', 'public' diff --git a/noir-projects/noir-contracts-comp-failures/contracts/invalid_note/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/invalid_note/expected_error deleted file mode 100644 index 02c046ffd7ab..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/invalid_note/expected_error +++ /dev/null @@ -1 +0,0 @@ -InvalidNote has a packed length of 9 fields, which exceeds the maximum allowed length of 8 fields. See https://docs.aztec.network/errors/4 diff --git a/noir-projects/noir-contracts-comp-failures/contracts/marked_private_unconstrained/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/marked_private_unconstrained/expected_error deleted file mode 100644 index 2688275a93b9..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/marked_private_unconstrained/expected_error +++ /dev/null @@ -1 +0,0 @@ -#[external("private")] or #[internal("private")] functions must not be unconstrained - unconstrained_private_function is diff --git a/noir-projects/noir-contracts-comp-failures/contracts/marked_public_unconstrained/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/marked_public_unconstrained/expected_error deleted file mode 100644 index 8758aa579ffc..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/marked_public_unconstrained/expected_error +++ /dev/null @@ -1 +0,0 @@ -#[external("public")] or #[internal("public")] functions must not be unconstrained - unconstrained_public_function is diff --git a/noir-projects/noir-contracts-comp-failures/contracts/noinitcheck_on_non_external_fn/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/noinitcheck_on_non_external_fn/expected_error deleted file mode 100644 index 69b930611586..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/noinitcheck_on_non_external_fn/expected_error +++ /dev/null @@ -1 +0,0 @@ -The #[noinitcheck] attribute can only be applied to #[external("private")] or #[external("public")] functions - foo is neither diff --git a/noir-projects/noir-contracts-comp-failures/contracts/noinitcheck_on_utility_fn/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/noinitcheck_on_utility_fn/expected_error deleted file mode 100644 index 1e1dfaca9e12..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/noinitcheck_on_utility_fn/expected_error +++ /dev/null @@ -1 +0,0 @@ -The #[noinitcheck] attribute cannot be applied to #[external("utility")] functions - foo diff --git a/noir-projects/noir-contracts-comp-failures/contracts/noinitcheck_without_initializer/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/noinitcheck_without_initializer/expected_error deleted file mode 100644 index 17c3dff427ad..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/noinitcheck_without_initializer/expected_error +++ /dev/null @@ -1 +0,0 @@ -The #[noinitcheck] attribute is unnecessary for contracts with no #[initializer] functions diff --git a/noir-projects/noir-contracts-comp-failures/contracts/non_deserializable/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/non_deserializable/expected_error deleted file mode 100644 index 0752e0c1a17f..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/non_deserializable/expected_error +++ /dev/null @@ -1,6 +0,0 @@ -Contract function 'bad_private_return' returns a value of type NotDeserializable, which does not implement the Deserialize trait. Add #[derive(Deserialize)] to NotDeserializable's declaration. -Parameter '_p' of contract function 'bad_private_param' has type NotDeserializable, which does not implement the Deserialize trait. Add #[derive(Deserialize)] to NotDeserializable's declaration. -Contract function 'bad_public_return' returns a value of type NotDeserializable, which does not implement the Deserialize trait. Add #[derive(Deserialize)] to NotDeserializable's declaration. -Parameter '_p' of contract function 'bad_public_param' has type NotDeserializable, which does not implement the Deserialize trait. Add #[derive(Deserialize)] to NotDeserializable's declaration. -Contract function 'bad_utility_return' returns a value of type NotDeserializable, which does not implement the Deserialize trait. Add #[derive(Deserialize)] to NotDeserializable's declaration. -Parameter '_p' of contract function 'bad_utility_param' has type NotDeserializable, which does not implement the Deserialize trait. Add #[derive(Deserialize)] to NotDeserializable's declaration. diff --git a/noir-projects/noir-contracts-comp-failures/contracts/non_serializable/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/non_serializable/expected_error deleted file mode 100644 index 33a63c051f3a..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/non_serializable/expected_error +++ /dev/null @@ -1,6 +0,0 @@ -Contract function 'bad_private_return' returns a value of type NotSerializable, which does not implement the Serialize trait. Add #[derive(Serialize)] to NotSerializable's declaration. -Parameter '_p' of contract function 'bad_private_param' has type NotSerializable, which does not implement the Serialize trait. Add #[derive(Serialize)] to NotSerializable's declaration. -Contract function 'bad_public_return' returns a value of type NotSerializable, which does not implement the Serialize trait. Add #[derive(Serialize)] to NotSerializable's declaration. -Parameter '_p' of contract function 'bad_public_param' has type NotSerializable, which does not implement the Serialize trait. Add #[derive(Serialize)] to NotSerializable's declaration. -Contract function 'bad_utility_return' returns a value of type NotSerializable, which does not implement the Serialize trait. Add #[derive(Serialize)] to NotSerializable's declaration. -Parameter '_p' of contract function 'bad_utility_param' has type NotSerializable, which does not implement the Serialize trait. Add #[derive(Serialize)] to NotSerializable's declaration. diff --git a/noir-projects/noir-contracts-comp-failures/contracts/only_self_on_non_external_fn/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/only_self_on_non_external_fn/expected_error deleted file mode 100644 index e2cf366b083d..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/only_self_on_non_external_fn/expected_error +++ /dev/null @@ -1 +0,0 @@ -The #[only_self] attribute can only be applied to #[external("private")] or #[external("public")] functions - foo is neither diff --git a/noir-projects/noir-contracts-comp-failures/contracts/only_self_on_utility_fn/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/only_self_on_utility_fn/expected_error deleted file mode 100644 index 67b493e28c6a..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/only_self_on_utility_fn/expected_error +++ /dev/null @@ -1 +0,0 @@ -The #[only_self] attribute cannot be applied to #[external("utility")] functions - foo diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_private_external_fn_call/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_private_external_fn_call/expected_error deleted file mode 100644 index 03dcdf55e48b..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_private_external_fn_call/expected_error +++ /dev/null @@ -1 +0,0 @@ -Direct invocation of private functions is not supported. You attempted to call arbitrary_external_function. See https://docs.aztec.network/errors/6 diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_private_internal_fn_call/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_private_internal_fn_call/expected_error deleted file mode 100644 index 70eb1d78dfed..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_private_internal_fn_call/expected_error +++ /dev/null @@ -1 +0,0 @@ -Direct invocation of private internal functions is not supported. You attempted to call arbitrary_private_function. See https://docs.aztec.network/errors/6 diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_public_external_fn_call/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_public_external_fn_call/expected_error deleted file mode 100644 index b698579729a9..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_public_external_fn_call/expected_error +++ /dev/null @@ -1 +0,0 @@ -Direct invocation of public functions is not supported. You attempted to call arbitrary_external_function. See https://docs.aztec.network/errors/6 diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_public_internal_fn_call/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_public_internal_fn_call/expected_error deleted file mode 100644 index b50d8f6b8a7e..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_public_internal_fn_call/expected_error +++ /dev/null @@ -1 +0,0 @@ -Direct invocation of public internal functions is not supported. You attempted to call arbitrary_public_function. See https://docs.aztec.network/errors/6 diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_utility_external_fn_call/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_utility_external_fn_call/expected_error deleted file mode 100644 index d83a13317cd4..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_utility_external_fn_call/expected_error +++ /dev/null @@ -1 +0,0 @@ -Direct invocation of utility functions is not supported. You attempted to call arbitrary_external_function. See https://docs.aztec.network/errors/6 diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_private_call/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_private_call/expected_error deleted file mode 100644 index 691f42b15075..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_private_call/expected_error +++ /dev/null @@ -1,2 +0,0 @@ -Could not resolve 'ZERO' in path -Your private call needs to be passed into the `self.call(...)` method to be executed (e.g. `self.call(MyContract::at(address).my_private_function(...args))` diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_private_static_call/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_private_static_call/expected_error deleted file mode 100644 index 1ef6eef9437f..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_private_static_call/expected_error +++ /dev/null @@ -1,2 +0,0 @@ -Could not resolve 'ZERO' in path -Your private static call needs to be passed into the `self.view(...)` method to be executed (e.g. `self.view(MyContract::at(address).my_private_static_function(...args))` diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_public_call/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_public_call/expected_error deleted file mode 100644 index aba4880076cb..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_public_call/expected_error +++ /dev/null @@ -1,2 +0,0 @@ -Could not resolve 'ZERO' in path -Your public call needs to be passed into the `self.call(...)`, `self.enqueue(...)` or `self.enqueue_incognito(...)` method to be executed (e.g. `self.call(MyContract::at(address).my_public_function(...args))` diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_public_static_call/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_public_static_call/expected_error deleted file mode 100644 index 663ed39ae75b..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_incorrectly_performed_public_static_call/expected_error +++ /dev/null @@ -1,2 +0,0 @@ -Could not resolve 'ZERO' in path -Your public static call needs to be passed into the `self.view(...)`, `self.enqueue_view(...)` or `self.enqueue_view_incognito(...)` method to be executed (e.g. `self.view(MyContract::at(address).my_public_static_function(...args))` diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_non_state_var_in_storage/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/panic_on_non_state_var_in_storage/expected_error deleted file mode 100644 index a557e8eba5d2..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_non_state_var_in_storage/expected_error +++ /dev/null @@ -1,3 +0,0 @@ -Type NonStateVar does not implement StateVariable and hence cannot be placed in Storage struct. -Could not resolve 'init' in path -Type annotation needed diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_owned_state_var_in_storage/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/panic_on_owned_state_var_in_storage/expected_error deleted file mode 100644 index 912e28180292..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_owned_state_var_in_storage/expected_error +++ /dev/null @@ -1,3 +0,0 @@ -Type PrivateImmutable implements OwnedStateVariable and hence cannot be placed in Storage struct without being wrapped in Owned. Wrap the type in Owned<..., Context>. -Could not resolve 'init' in path -Type annotation needed diff --git a/noir-projects/noir-contracts-comp-failures/contracts/pub_private_external_fn/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/pub_private_external_fn/expected_error deleted file mode 100644 index 669dc8c04480..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/pub_private_external_fn/expected_error +++ /dev/null @@ -1 +0,0 @@ -A function marked as #[external("private")] or #[internal("private")] must not have public Noir visibility - foo's visibility is 'pub' diff --git a/noir-projects/noir-contracts-comp-failures/contracts/pub_public_external_fn/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/pub_public_external_fn/expected_error deleted file mode 100644 index 044cc7b24636..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/pub_public_external_fn/expected_error +++ /dev/null @@ -1 +0,0 @@ -A function marked as #[external("public")] or #[internal("public")] must not have public Noir visibility - foo's visibility is 'pub' diff --git a/noir-projects/noir-contracts-comp-failures/contracts/pub_utility_external_fn/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/pub_utility_external_fn/expected_error deleted file mode 100644 index e619f508ff8e..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/pub_utility_external_fn/expected_error +++ /dev/null @@ -1 +0,0 @@ -A function marked as #[external("utility")] must not have public Noir visibility - foo's visibility is 'pub' diff --git a/noir-projects/noir-contracts-comp-failures/contracts/public_allow_phase_change/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/public_allow_phase_change/expected_error deleted file mode 100644 index abb57930739e..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/public_allow_phase_change/expected_error +++ /dev/null @@ -1 +0,0 @@ -The #[allow_phase_change] attribute cannot be applied to #[external("public")] functions - foo diff --git a/noir-projects/noir-contracts-comp-failures/contracts/public_function_selector_collision/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/public_function_selector_collision/expected_error deleted file mode 100644 index 3ac5de4c49d9..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/public_function_selector_collision/expected_error +++ /dev/null @@ -1 +0,0 @@ -Public function selector collision detected between functions 'fn_selector_collision_1442740381' and 'fn_selector_collision' diff --git a/noir-projects/noir-contracts-comp-failures/contracts/reserved_emit_public_init_nullifier/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/reserved_emit_public_init_nullifier/expected_error deleted file mode 100644 index e7bef0a515de..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/reserved_emit_public_init_nullifier/expected_error +++ /dev/null @@ -1 +0,0 @@ -Function name '__emit_public_init_nullifier' is reserved for internal use diff --git a/noir-projects/noir-contracts-comp-failures/contracts/reserved_public_dispatch/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/reserved_public_dispatch/expected_error deleted file mode 100644 index 6652431061c4..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/reserved_public_dispatch/expected_error +++ /dev/null @@ -1 +0,0 @@ -Function name 'public_dispatch' is reserved for internal use diff --git a/noir-projects/noir-contracts-comp-failures/contracts/unmacroified_function_in_contract/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/unmacroified_function_in_contract/expected_error deleted file mode 100644 index 5923b9ac25d3..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/unmacroified_function_in_contract/expected_error +++ /dev/null @@ -1 +0,0 @@ -Function foo must be marked as either #[external(...)], #[internal(...)], or #[test] diff --git a/noir-projects/noir-contracts-comp-failures/contracts/user_defined_offchain_receive/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/user_defined_offchain_receive/expected_error deleted file mode 100644 index 3aa9a27613c7..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/user_defined_offchain_receive/expected_error +++ /dev/null @@ -1 +0,0 @@ -User-defined 'offchain_receive' is not allowed. The function is auto-injected by the #[aztec] macro. See https://docs.aztec.network/errors/7 diff --git a/noir-projects/noir-contracts-comp-failures/contracts/utility_not_unconstrained/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/utility_not_unconstrained/expected_error deleted file mode 100644 index aeeba4db64c8..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/utility_not_unconstrained/expected_error +++ /dev/null @@ -1 +0,0 @@ -#[external("utility")] must be unconstrained - constrained_utility_function isn't diff --git a/noir-projects/noir-contracts-comp-failures/contracts/view_on_non_external_fn/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/view_on_non_external_fn/expected_error deleted file mode 100644 index 237014f4076a..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/view_on_non_external_fn/expected_error +++ /dev/null @@ -1 +0,0 @@ -The #[view] attribute can only be applied to #[external("private")] or #[external("public")] functions - foo is neither diff --git a/noir-projects/noir-contracts-comp-failures/contracts/view_on_utility_fn/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/view_on_utility_fn/expected_error deleted file mode 100644 index b51bee13a6a6..000000000000 --- a/noir-projects/noir-contracts-comp-failures/contracts/view_on_utility_fn/expected_error +++ /dev/null @@ -1 +0,0 @@ -The #[view] attribute cannot be applied to #[external("utility")] functions - foo