Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: contract interfaces and better function calls #5687

Merged
merged 216 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
216 commits
Select commit Hold shift + click to select a range
e1190bc
changed storage macro to look for attribute
Thunkar Mar 19, 2024
c41eba8
added abi exports to contract artifact
Thunkar Mar 22, 2024
6caea1e
changed storage macro to look for attribute
Thunkar Mar 19, 2024
01506c9
added abi exports to contract artifact
Thunkar Mar 22, 2024
3873a65
reverted change
Thunkar Mar 22, 2024
ce6b163
removed unused variable
Thunkar Mar 22, 2024
733f0ec
clippy pass
Thunkar Mar 22, 2024
9b6af4b
fixes and consistency
Thunkar Mar 22, 2024
ad2a62f
cleanup and test
Thunkar Mar 26, 2024
445b9e6
updated snapshots, types
Thunkar Mar 26, 2024
2124cfa
changed integer serialization
Thunkar Mar 26, 2024
3a388be
added abi exports to contract artifact
Thunkar Mar 22, 2024
85596ec
added abi exports to contract artifact
Thunkar Mar 22, 2024
46df9a5
reverted change
Thunkar Mar 22, 2024
0132139
clippy pass
Thunkar Mar 22, 2024
6545eec
wip
Thunkar Mar 22, 2024
7c6544f
wip
Thunkar Mar 22, 2024
efe757d
storage layout export and note ids
Thunkar Mar 26, 2024
82ca876
working storage layout and notes
Thunkar Mar 26, 2024
1fa96db
experimental support
Thunkar Mar 22, 2024
f367d15
updated snapshot
Thunkar Mar 26, 2024
84bf37a
better codegen and fixed test
Thunkar Mar 26, 2024
f1baaf0
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Mar 26, 2024
614942a
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Mar 26, 2024
3c0787c
Merge branch 'gj/contract_abi_exports' into gj/storage_layout
Thunkar Mar 26, 2024
e4cf336
Merge branch 'master' into gj/contract_abi_exports
Thunkar Mar 27, 2024
7b8eed6
Merge branch 'gj/contract_abi_exports' of github.com:AztecProtocol/az…
Thunkar Mar 27, 2024
9f94e95
removed macro pass, general cleanup and fixes
Thunkar Mar 27, 2024
1e238d8
used in e2e, clippy
Thunkar Mar 27, 2024
28ce5e6
fixed snapshot
Thunkar Mar 27, 2024
edba6f1
prettier run
Thunkar Mar 27, 2024
654fa04
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Mar 27, 2024
423537e
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Mar 27, 2024
99c5128
yet another snapshot. fun
Thunkar Mar 27, 2024
7227650
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Mar 27, 2024
be95f17
Merge branch 'master' into gj/contract_abi_exports
Thunkar Mar 27, 2024
a176860
Merge branch 'gj/contract_abi_exports' into gj/storage_layout
Thunkar Mar 27, 2024
92e4397
Merge branch 'master' into gj/contract_abi_exports
Thunkar Mar 27, 2024
04b7b19
Merge branch 'gj/contract_abi_exports' into gj/storage_layout
Thunkar Mar 27, 2024
ba59549
Merge branch 'master' into gj/contract_abi_exports
Thunkar Mar 27, 2024
08a3374
Merge branch 'gj/contract_abi_exports' into gj/storage_layout
Thunkar Mar 27, 2024
328108f
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Apr 1, 2024
a75c843
updated snapshots
Thunkar Apr 1, 2024
1c1e156
Merge branch 'gj/contract_abi_exports' of github.com:AztecProtocol/az…
Thunkar Apr 1, 2024
e4f75eb
merge changes
Thunkar Apr 1, 2024
80df865
Merge branch 'gj/contract_abi_exports' of github.com:AztecProtocol/az…
Thunkar Apr 1, 2024
5482aee
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 1, 2024
2859f5f
updated artifact hash
Thunkar Apr 1, 2024
53918d9
correct hash
Thunkar Apr 1, 2024
9a20ff4
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 1, 2024
3d8deb1
merge conflicts
Thunkar Apr 1, 2024
ccd1b7b
fmt
Thunkar Apr 1, 2024
6b6080d
wip
Thunkar Apr 2, 2024
f16ec80
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Apr 2, 2024
622ef04
Merge branch 'gj/contract_abi_exports' of github.com:AztecProtocol/az…
Thunkar Apr 2, 2024
e0f2ca2
Update noir/noir-repo/aztec_macros/src/lib.rs
Thunkar Apr 2, 2024
b0b796e
Merge branch 'gj/contract_abi_exports' into gj/storage_layout
Thunkar Apr 2, 2024
d34e4a3
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 2, 2024
2d18874
guess what
Thunkar Apr 2, 2024
2e61cda
increased test machine size, hash
Thunkar Apr 2, 2024
9ab84fd
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 2, 2024
617dc53
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 2, 2024
a6aa905
avoid oom
Thunkar Apr 2, 2024
e2a14fe
wip
Thunkar Apr 2, 2024
4b8464d
PR changes
Thunkar Apr 2, 2024
0c175fd
more pr improvements
Thunkar Apr 2, 2024
db649f8
Merge branch 'gj/contract_abi_exports' of github.com:AztecProtocol/az…
Thunkar Apr 2, 2024
c2febc9
reverted abi tag error
Thunkar Apr 2, 2024
95e5025
clippy pass
Thunkar Apr 2, 2024
93b6cb1
Merge branch 'master' into gj/contract_abi_exports
Thunkar Apr 2, 2024
38e17fa
Merge branch 'gj/contract_abi_exports' of github.com:AztecProtocol/az…
Thunkar Apr 2, 2024
f5b158a
correct order
Thunkar Apr 2, 2024
bd89f36
reverted ci changes
Thunkar Apr 2, 2024
8f7d587
Merge branch 'gj/contract_abi_exports' of github.com:AztecProtocol/az…
Thunkar Apr 2, 2024
5ad4ce5
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 2, 2024
ef571c9
pr comment
Thunkar Apr 2, 2024
3b7d7b5
added tuple values
Thunkar Apr 2, 2024
ce404c9
removed unused import
Thunkar Apr 2, 2024
31996d9
Merge branch 'gj/contract_abi_exports' of github.com:AztecProtocol/az…
Thunkar Apr 2, 2024
2bcdac7
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 2, 2024
b673d1c
fixed integer conversion
Thunkar Apr 2, 2024
8feb6d4
Merge branch 'gj/contract_abi_exports' of github.com:AztecProtocol/az…
Thunkar Apr 2, 2024
1794b8e
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 2, 2024
fa353be
fixed constants
Thunkar Apr 2, 2024
7185448
fixed artifact hash
Thunkar Apr 2, 2024
ecd305b
changed approach
Thunkar Apr 3, 2024
45914ba
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Apr 3, 2024
a586479
restrict abi tag again
Thunkar Apr 3, 2024
a8536aa
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Apr 3, 2024
9479047
Merge branch 'gj/contract_abi_exports' of github.com:AztecProtocol/az…
Thunkar Apr 3, 2024
8a28659
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 3, 2024
6455797
clippy pass
Thunkar Apr 3, 2024
564f438
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 3, 2024
defffbb
updated snapshot
Thunkar Apr 3, 2024
0faea97
updated snapshot
Thunkar Apr 3, 2024
2ed4aaf
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Apr 4, 2024
2e5d302
Merge branch 'gj/contract_abi_exports' of github.com:AztecProtocol/az…
Thunkar Apr 4, 2024
0329e06
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 4, 2024
95be1cd
fixed merge conflicts
Thunkar Apr 4, 2024
db2a411
hash
Thunkar Apr 4, 2024
fb8b091
Merge branch 'gj_lh/fn_return_values' of github.com:AztecProtocol/azt…
Thunkar Apr 4, 2024
6b556f3
reverted extraneous changes
Thunkar Apr 4, 2024
319e5e1
reverted extraneous changes
Thunkar Apr 4, 2024
874f651
reverted extraneous changesç
Thunkar Apr 4, 2024
d428f41
reverted extraneous changesç
Thunkar Apr 4, 2024
78a218d
wip
Thunkar Apr 4, 2024
7a2d041
removed repeated block
Thunkar Apr 4, 2024
e7ee0c2
Merge branch 'gj/contract_abi_exports' of github.com:AztecProtocol/az…
Thunkar Apr 4, 2024
cf1f97b
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 4, 2024
fd4cf70
Merge branch 'gj_lh/fn_return_values' of github.com:AztecProtocol/azt…
Thunkar Apr 4, 2024
f35d058
wip
Thunkar Apr 4, 2024
52c6db0
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Apr 4, 2024
8e49bb5
Merge branch 'gj/contract_abi_exports' into gj/storage_layout
Thunkar Apr 4, 2024
940c39e
Merge branch 'gj/storage_layout' into gj_lh/fn_return_values
Thunkar Apr 4, 2024
f339ffb
updated artifact hash
Thunkar Apr 4, 2024
1177369
Merge branch 'gj_lh/fn_return_values' of github.com:AztecProtocol/azt…
Thunkar Apr 4, 2024
a29a4e1
wip
Thunkar Apr 4, 2024
5d1bdcc
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Apr 4, 2024
3e7cf15
updated artifact hash
Thunkar Apr 4, 2024
8861e7d
Merge branch 'master' into gj/storage_layout
Thunkar Apr 4, 2024
97372a9
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 4, 2024
1c2925d
Merge branch 'gj_lh/fn_return_values' of github.com:AztecProtocol/azt…
Thunkar Apr 4, 2024
9524c9c
merge conflicts
Thunkar Apr 4, 2024
13d016a
Merge branch 'gj_lh/fn_return_values' of github.com:AztecProtocol/azt…
Thunkar Apr 4, 2024
a229328
another hash
Thunkar Apr 5, 2024
7f49549
Merge branch 'gj_lh/fn_return_values' of github.com:AztecProtocol/azt…
Thunkar Apr 5, 2024
4179c57
wip
Thunkar Apr 5, 2024
01f8838
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Apr 5, 2024
0a18551
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Apr 8, 2024
7674111
added docs
Thunkar Apr 8, 2024
904a791
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 8, 2024
73a6be7
Merge branch 'gj_lh/fn_return_values' of github.com:AztecProtocol/azt…
Thunkar Apr 8, 2024
88e6858
migration notes
Thunkar Apr 8, 2024
c1b64b0
Merge branch 'gj/storage_layout' into gj_lh/fn_return_values
Thunkar Apr 8, 2024
a304c3d
Merge branch 'gj_lh/fn_return_values' of github.com:AztecProtocol/azt…
Thunkar Apr 8, 2024
bb76d0e
wip
Thunkar Apr 8, 2024
d08e7bb
updated hash
Thunkar Apr 8, 2024
8a4d9fe
just to see ci fail
Thunkar Apr 8, 2024
cd60d9b
fix
Thunkar Apr 8, 2024
088536c
Merge branch 'gj/storage_layout' of github.com:AztecProtocol/aztec-pa…
Thunkar Apr 8, 2024
d7e2e22
guess what
Thunkar Apr 8, 2024
e631507
wait for red
Thunkar Apr 8, 2024
2b88ea2
merge conflicts
Thunkar Apr 8, 2024
7f99205
updated constants
Thunkar Apr 8, 2024
1962220
Merge branch 'gj_lh/fn_return_values' of github.com:AztecProtocol/azt…
Thunkar Apr 8, 2024
1a58989
wip
Thunkar Apr 8, 2024
bed79fd
wip
Thunkar Apr 9, 2024
013fc49
working implementation
Thunkar Apr 9, 2024
6e29f8c
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Apr 10, 2024
3df4ade
fixes and improvements, added void calls
Thunkar Apr 10, 2024
1a55e19
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Apr 10, 2024
d53fbbd
new attempt to deserialize slices
Thunkar Apr 10, 2024
15975c3
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Apr 10, 2024
fa07219
compiles, more tomorrow!
Thunkar Apr 10, 2024
b977ddd
wip
Thunkar Apr 11, 2024
d44ec99
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Apr 11, 2024
ed69b1b
adapted to variable returns
Thunkar Apr 11, 2024
11dc827
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Apr 11, 2024
6af7857
reverted changes
Thunkar Apr 11, 2024
49a4219
removed unnecesary cahnges
Thunkar Apr 12, 2024
a766ee1
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Apr 12, 2024
0deee2f
more dead code
Thunkar Apr 12, 2024
2a4ada5
new test structure, fix
Thunkar Apr 12, 2024
91ea029
Clippy pass, remove legacy test
Thunkar Apr 12, 2024
41df50f
clippy pass and comments
Thunkar Apr 12, 2024
5d69154
fix
Thunkar Apr 12, 2024
cee23c5
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Apr 12, 2024
acc55e9
fixes
Thunkar Apr 12, 2024
b1c5ad2
facepalmus maximus
Thunkar Apr 12, 2024
3fb5d7c
corrected signatures
Thunkar Apr 12, 2024
9f0459e
clippy pass
Thunkar Apr 12, 2024
131e0be
updated ci config
Thunkar Apr 12, 2024
de408a9
more ci config
Thunkar Apr 12, 2024
0ffdc01
Merge branch 'master' into gj/better_fn_calls
Thunkar Apr 12, 2024
9850681
yeeted manual interfaces and context.call_*
Thunkar Apr 12, 2024
892c8eb
Merge branch 'master' of https://github.com/AztecProtocol/aztec-packa…
Thunkar Apr 12, 2024
4c99353
fixes
Thunkar Apr 12, 2024
08882a3
PR comments
Thunkar Apr 15, 2024
55751e3
Merge branch 'master' of https://github.com/AztecProtocol/aztec-packa…
Thunkar Apr 15, 2024
fc02b4c
docs
Thunkar Apr 15, 2024
bdfc55e
added migration notes
Thunkar Apr 15, 2024
c533fc4
Merge branch 'master' of https://github.com/AztecProtocol/aztec-packa…
Thunkar Apr 15, 2024
9a9a5da
PR reviews
Thunkar Apr 15, 2024
cff705b
removed acvm whitespace change
Thunkar Apr 15, 2024
2f2dab1
Update noir/noir-repo/aztec_macros/src/utils/hir_utils.rs
Thunkar Apr 15, 2024
e9a9d25
Merge branch 'master' into gj/better_fn_calls
Thunkar Apr 15, 2024
e43119e
comments and PR fixes
Thunkar Apr 15, 2024
881e570
Merge branch 'gj/better_fn_calls' of https://github.com/AztecProtocol…
Thunkar Apr 15, 2024
004d748
Merge branch 'master' of https://github.com/AztecProtocol/aztec-packa…
Thunkar Apr 15, 2024
a524d25
Merge branch 'master' into gj/better_fn_calls
Thunkar Apr 16, 2024
9344b35
cleanup, more PR comments, removed nr codegen, fixed more notes
Thunkar Apr 16, 2024
f3a5342
Merge branch 'gj/better_fn_calls' of https://github.com/AztecProtocol…
Thunkar Apr 16, 2024
9c7393a
Merge branch 'master' of https://github.com/AztecProtocol/aztec-packa…
Thunkar Apr 16, 2024
62f3d7a
Merge branch 'master' of https://github.com/AztecProtocol/aztec-packa…
Thunkar Apr 16, 2024
ac80904
fixed tests
Thunkar Apr 16, 2024
e98c816
avm support
Thunkar Apr 16, 2024
ee899d2
Merge branch 'master' of https://github.com/AztecProtocol/aztec-packa…
Thunkar Apr 16, 2024
c1aaa5c
contract fix
Thunkar Apr 16, 2024
f240b4a
more fixes
Thunkar Apr 16, 2024
6802f9c
Merge branch 'master' into gj/better_fn_calls
Thunkar Apr 16, 2024
189edf1
reverted public context change
Thunkar Apr 16, 2024
b95225d
Merge branch 'master' into gj/better_fn_calls
Thunkar Apr 17, 2024
c8599f6
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Apr 17, 2024
73270c1
fix: Don't reuse brillig with slice arguments
sirasistant Apr 17, 2024
b403518
chore: fmt sol
sirasistant Apr 17, 2024
215acfb
docs: added todo
sirasistant Apr 17, 2024
b37aea7
Merge branch 'arv/fix_brillig_slice_entrypoint' of github.com:AztecPr…
Thunkar Apr 17, 2024
0660e84
Merge branch 'gj/better_fn_calls' of github.com:AztecProtocol/aztec-p…
Thunkar Apr 17, 2024
531056f
chore: update deployer addr
sirasistant Apr 17, 2024
043a3c0
chore: fmt
sirasistant Apr 17, 2024
b04b3f0
fixed test
Thunkar Apr 17, 2024
1cbeef7
fix: avoid nondeterminism?
sirasistant Apr 17, 2024
a246003
chore: fmt
sirasistant Apr 17, 2024
94b6c72
changed publiccontext, updated deployer address
Thunkar Apr 17, 2024
f784ed7
Merge branch 'arv/fix_brillig_slice_entrypoint' of github.com:AztecPr…
Thunkar Apr 17, 2024
47421c8
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Apr 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion boxes/boxes/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"main": "./dist/index.js",
"scripts": {
"compile": "cd src/contracts && ${AZTEC_NARGO:-aztec-nargo} compile",
"codegen": "${AZTEC_CLI:-aztec-cli} codegen src/contracts/target -o artifacts --ts",
"codegen": "${AZTEC_CLI:-aztec-cli} codegen src/contracts/target -o artifacts",
"clean": "rm -rf ./dist .tsbuildinfo ./artifacts ./src/contracts/target",
"prep": "yarn clean && yarn compile && yarn codegen",
"dev": "yarn prep && webpack serve --mode development",
Expand Down
2 changes: 1 addition & 1 deletion boxes/boxes/vanilla/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "module",
"scripts": {
"compile": "cd src/contracts && ${AZTEC_NARGO:-aztec-nargo} compile",
"codegen": "${AZTEC_CLI:-aztec-cli} codegen src/contracts/target -o artifacts --ts",
"codegen": "${AZTEC_CLI:-aztec-cli} codegen src/contracts/target -o artifacts",
"clean": "rm -rf ./dest .tsbuildinfo ./artifacts ./src/contracts/target",
"prep": "yarn clean && yarn compile && yarn codegen && tsc -b",
"dev": "yarn prep && webpack serve --mode development",
Expand Down
2 changes: 1 addition & 1 deletion boxes/contract-only/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "module",
"scripts": {
"compile": "cd src && ${AZTEC_NARGO:-aztec-nargo} compile",
"codegen": "${AZTEC_CLI:-aztec-cli} codegen target -o artifacts --ts",
"codegen": "${AZTEC_CLI:-aztec-cli} codegen target -o artifacts",
"clean": "rm -rf ./dest .tsbuildinfo ./artifacts ./target",
"prep": "yarn clean && yarn compile && yarn codegen && tsc -b",
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --runInBand",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ This will output a JSON [artifact](./artifacts.md) for each contract in the proj

You can use the code generator to autogenerate type-safe typescript classes for each of your contracts. These classes define type-safe methods for deploying and interacting with your contract based on their artifact.

To generate them, include a `--ts` option in the `codegen` command with a path to the target folder for the typescript files:

```bash
aztec-cli codegen ./aztec-nargo/output/target/path -o src/artifacts --ts
aztec-cli codegen ./aztec-nargo/output/target/path -o src/artifacts
```

Below is typescript code generated from the [Token](https://github.com/AztecProtocol/aztec-packages/blob/master/noir-projects/noir-contracts/contracts/token_contract/src/main.nr) contract:
Expand Down Expand Up @@ -119,94 +117,34 @@ Read more about interacting with contracts using `aztec.js` [here](../../getting

An Aztec.nr contract can [call a function](../writing_contracts/functions/call_functions.md) in another contract via `context.call_private_function` or `context.call_public_function`. However, this requires manually assembling the function selector and manually serializing the arguments, which is not type-safe.

To make this easier, the compiler can generate contract interface structs that expose a convenience method for each function listed in a given contract artifact. These structs are intended to be used from another contract project that calls into the current one. For each contract, two interface structs are generated: one to be used from private functions with a `PrivateContext`, and one to be used from open functions with a `PublicContext`.

To generate them, include a `--nr` option in the `codegen` command with a path to the target folder for the generated Aztec.nr interface files:

```bash
aztec-cli codegen ./aztec-nargo/output/target/path -o ./path/to/output/folder --nr
```
To make this easier, the compiler automatically generates interface structs that expose a convenience method for each function listed in a given contract artifact. These structs are intended to be used from another contract project that calls into the current one.

Below is an example interface, also generated from the [Token](https://github.com/AztecProtocol/aztec-packages/blob/master/noir-projects/noir-contracts/contracts/token_contract/src/main.nr) contract:
Below is an example of interface usage generated from the [Token](https://github.com/AztecProtocol/aztec-packages/blob/master/noir-projects/noir-contracts/contracts/token_contract/src/main.nr) contract, used from the [FPC](https://github.com/AztecProtocol/aztec-packages/blob/master/noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr):

```rust
impl TokenPrivateContextInterface {
pub fn at(address: Field) -> Self {
Self {
address,
}
}

pub fn burn(
self,
context: &mut PrivateContext,
from: FromBurnStruct,
amount: Field,
nonce: Field
) -> [Field; RETURN_VALUES_LENGTH] {
let mut serialized_args = [0; 3];
serialized_args[0] = from.address;
serialized_args[1] = amount;
serialized_args[2] = nonce;

context.call_private_function(self.address, 0xd4fcc96e, serialized_args)
}


pub fn burn_public(
self,
context: &mut PrivateContext,
from: FromBurnPublicStruct,
amount: Field,
nonce: Field
) {
let mut serialized_args = [0; 3];
serialized_args[0] = from.address;
serialized_args[1] = amount;
serialized_args[2] = nonce;
contract FPC {

context.call_public_function(self.address, 0xb0e964d5, serialized_args)
}
...

}
...

impl TokenPublicContextInterface {
pub fn at(address: Field) -> Self {
Self {
address,
}
}
use dep::token::Token;

pub fn burn_public(
self,
context: PublicContext,
from: FromBurnPublicStruct,
amount: Field,
nonce: Field
) -> [Field; RETURN_VALUES_LENGTH] {
let mut serialized_args = [0; 3];
serialized_args[0] = from.address;
serialized_args[1] = amount;
serialized_args[2] = nonce;

context.call_public_function(self.address, 0xb0e964d5, serialized_args)
}
...


pub fn mint_private(
self,
context: PublicContext,
amount: Field,
secret_hash: Field
) -> [Field; RETURN_VALUES_LENGTH] {
let mut serialized_args = [0; 2];
serialized_args[0] = amount;
serialized_args[1] = secret_hash;
#[aztec(private)]
fn fee_entrypoint_private(amount: Field, asset: AztecAddress, secret_hash: Field, nonce: Field) {
assert(asset == storage.other_asset.read_private());
Token::at(asset).unshield(context.msg_sender(), context.this_address(), amount, nonce).call(&mut context);
FPC::at(context.this_address()).pay_fee_with_shielded_rebate(amount, asset, secret_hash).enqueue(&mut context);
}

context.call_public_function(self.address, 0x10763932, serialized_args)
}
#[aztec(private)]
fn fee_entrypoint_public(amount: Field, asset: AztecAddress, nonce: Field) {
FPC::at(context.this_address()).prepare_fee(context.msg_sender(), amount, asset, nonce).enqueue(&mut context);
FPC::at(context.this_address()).pay_fee(context.msg_sender(), amount, asset).enqueue(&mut context);
}

...

}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ aztec-nargo compile
Generate the typescript class:

```bash
aztec-cli codegen ./aztec-nargo/output/target/path -o src/artifacts --ts
aztec-cli codegen ./aztec-nargo/output/target/path -o src/artifacts
```

This would create a typescript file like `Example.ts` in `./src/artifacts`. Read more on the [compiling page](../compiling_contracts/how_to_compile_contract.md).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,19 @@ On this page you will learn how to implement a slow updates tree into your contr

# How to implement a slow updates tree

1. Copy the _SlowTree.nr_ example and its dependencies, found [here](https://github.com/AztecProtocol/aztec-packages/tree/master/noir-projects/noir-contracts/contracts/slow_tree_contract). Replace the constants with whatever you like and deploy it to your sandbox
2. Copy the _SlowMap interface_ for easy interaction with your deployed SlowTree. Find it [here](https://github.com/AztecProtocol/aztec-packages/blob/master/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/interfaces.nr)
3. Import this interface into your contract

#include_code interface noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr rust

5. Store the SlowTree address in private storage as a FieldNote
1. Store the SlowTree address in private storage as a FieldNote

#include_code constructor noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr rust

6. Store the SlowTree address in public storage and initialize an instance of SlowMap using this address
2. Store the SlowTree address in public storage and initialize an instance of SlowMap using this address

#include_code write_slow_update_public noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr rust

7. Now you can read and update from private functions:
3. Now you can read and update from private functions:

#include_code get_and_update_private noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr rust

8. Or from public functions:
4. Or from public functions:

#include_code get_public noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr rust

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ There are generally 4 main components involved to make it easier to use a slow u

This is the primary smart contract that will use the slow updates tree. In the example we use a [token with blacklisting features](./implement_slow_updates.md#exploring-an-example-integration-through-a-tokenblacklist-smart-contract).

## Interface

This interface of the slow updates tree contract allows your contract to interact with the Slow Updates Tree contract. It provides methods for reading and updating values in the tree in both public and private contexts. You can find it [here](https://github.com/AztecProtocol/aztec-packages/blob/master/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/interfaces.nr).

## SlowTree.nr contract

This is a smart contract developed by Aztec that establishes and manages a slow updates tree structure. It allows developers to access and interact with the tree, such as reading and updating data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ This will compile the smart contract and create a `target` folder with a `.json`
After compiling, you can generate a typescript class. In the same directory, run this:

```bash
aztec-cli codegen target -o src/artifacts --ts
aztec-cli codegen target -o src/artifacts
```

### Deploy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ In our `token-bridge` Aztec project in `aztec-contracts`, under `src` there is a

#include_code token_bridge_storage_and_constructor /noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr rust

This imports Aztec-related dependencies and our helper file `token_interface.nr`.
(The code above will give errors right now - this is because we haven't implemented util and token_interface yet.)

In `token_interface.nr`, add this:

#include_code token_bridge_token_interface /noir-projects/noir-contracts/contracts/token_bridge_contract/src/token_interface.nr rust

## Consume the L1 message

In the previous step, we have moved our funds to the portal and created a L1->L2 message. Upon building the next rollup, the sequencer asks the inbox for any incoming messages and adds them to Aztec’s L1->L2 message tree, so an application on L2 can prove that the message exists and consumes it.
Expand Down
3 changes: 1 addition & 2 deletions docs/docs/developers/tutorials/token_portal/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,14 @@ aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_
token_portal_content_hash_lib = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="noir-projects/noir-contracts/contracts/token_portal_content_hash_lib" }
```

We will also be writing some helper functions that should exist elsewhere so we don't overcomplicated our contract. In `src` create two more files - one called `util.nr` and one called `token_interface` - so your dir structure should now look like this:
We will also be writing some helper functions that should exist elsewhere so we don't overcomplicated our contract. In `src` create one more file called `util.nr` - so your dir structure should now look like this:

```tree
aztec-contracts
└── token_bridge
├── Nargo.toml
├── src
├── main.nr
├── token_interface.nr
├── util.nr
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ aztec-nargo compile
And generate the TypeScript interface for the contract and add it to the test dir:

```bash
aztec-cli codegen target -o ../../src/test/fixtures --ts
aztec-cli codegen target -o ../../src/test/fixtures
```

This will create a TS interface in our `src/test` folder!
Expand Down
13 changes: 3 additions & 10 deletions docs/docs/developers/tutorials/uniswap/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,18 @@ Inside `uniswap/Nargo.toml` paste this in `[dependencies]`:
[dependencies]
aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="noir-projects/aztec-nr/aztec" }
authwit = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="noir-projects/aztec-nr/authwit"}
token = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="noir-projects/noir-contracts/token_contract" }
token_bridge = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="noir-projects/noir-contracts/token_bridge_contract" }
```

## L2 contracts

The `main.nr` will utilize a few helper functions that are outside the scope of this tutorial. Inside `uniswap/src` create two new files:

```bash
cd uniswap/src && touch util.nr && touch interfaces.nr
cd uniswap/src && touch util.nr
```

Inside `interfaces.nr` paste this:

#include_code interfaces noir-projects/noir-contracts/contracts/uniswap_contract/src/interfaces.nr rust

This creates interfaces for the `Token` contract and `TokenBridge` contract

- `Token` is a reference implementation for a token on Aztec. Here we just need two methods - [`transfer_public`](../writing_token_contract.md#transfer_public) and [`unshield()`](../writing_token_contract.md#unshield).
- The `TokenBridge` facilitates interactions with our [bridge contract](../token_portal/main.md). Here we just need its [`exit_to_l1_public`](../token_portal/withdrawing_to_l1.md)

## Run Aztec sandbox

You will need a running sandbox.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ aztec-nargo compile
And then generate the typescript interface:

```bash
aztec-cli codegen ./target/ -o ../../../src/test/fixtures uniswap --ts
aztec-cli codegen ./target/ -o ../../../src/test/fixtures uniswap
```

This will create a TS interface in our `src/test` folder that will help us write our test.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ aztec-nargo compile
This will create a new directory called `target` and a JSON artifact inside it. To optionally create a typescript interface, run:

```bash
aztec-cli codegen target -o src/artifacts --ts
aztec-cli codegen target -o src/artifacts
```

Once it is compiled you can [deploy](../contracts/deploying_contracts/how_to_deploy_contract.md) it to the sandbox. Ensure your [sandbox is running](../sandbox/references/sandbox-reference.md) and run this in the same dir as before:
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/developers/tutorials/writing_token_contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ aztec-nargo compile
Once your contract is compiled, optionally generate a typescript interface with the following command:

```bash
aztec-cli codegen target -o src/artifacts --ts
aztec-cli codegen target -o src/artifacts
```

## Next Steps
Expand Down
48 changes: 48 additions & 0 deletions docs/docs/misc/migration_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,54 @@ Aztec is in full-speed development. Literally every version breaks compatibility

## TBD

### [Aztec.nr] Contract interfaces

It is now possible to import contracts on another contracts and use their automatic interfaces to perform calls. The interfaces have the same name as the contract, and are automatically exported. Parameters are automatically serialized (using the `Serialize<N>` trait) and return values are automatically deserialized (using the `Deserialize<N>` trait). Serialize and Deserialize methods have to conform to the standard ACVM serialization schema for the interface to work!

1. Only fixed length types are supported
2. All numeric types become Fields
3. Strings become arrays of Fields, one per char
4. Arrays become arrays of Fields following rules 2 and 3
5. Structs become arrays of Fields, with every item defined in the same order as they are in Noir code, following rules 2, 3, 4 and 5 (recursive)


```diff
- context.call_public_function(
- storage.gas_token_address.read_private(),
- FunctionSelector::from_signature("pay_fee(Field)"),
- [42]
- );
-
- context.call_public_function(
- storage.gas_token_address.read_private(),
- FunctionSelector::from_signature("pay_fee(Field)"),
- [42]
- );
-
- let _ = context.call_private_function(
- storage.subscription_token_address.read_private(),
- FunctionSelector::from_signature("transfer((Field),(Field),Field,Field)"),
- [
- context.msg_sender().to_field(),
- storage.subscription_recipient_address.read_private().to_field(),
- storage.subscription_price.read_private(),
- nonce
- ]
- );
+ use dep::gas_token::GasToken;
+ use dep::token::Token;
+
+ ...
+ // Public call from public land
+ GasToken::at(storage.gas_token_address.read_private()).pay_fee(42).call(&mut context);
+ // Public call from private land
+ GasToken::at(storage.gas_token_address.read_private()).pay_fee(42).enqueue(&mut context);
+ // Private call from private land
+ Token::at(asset).transfer(context.msg_sender(), storage.subscription_recipient_address.read_private(), amount, nonce).call(&mut context);
```

It is also possible to use these automatic interfaces from the local contract, and thus enqueue public calls from private without having to rely on low level `context` calls.

### [Aztec.nr] Rename max block number setter

The `request_max_block_number` function has been renamed to `set_tx_max_block_number` to better reflect that it is not a getter, and that the setting is transaction-wide.
Expand Down
2 changes: 1 addition & 1 deletion l1-contracts/src/core/libraries/ConstantsGen.sol
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ library Constants {
uint256 internal constant DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE =
0x85864497636cf755ae7bde03f267ce01a520981c21c3682aaf82a631;
uint256 internal constant DEPLOYER_CONTRACT_ADDRESS =
0x2d8e7aedc70b65d49e6aa0794d8d12721896c177e87126701f6e60d184358e74;
0x0b98aeb0111208b95d8d71f484f849d7ab44b3e34c545d13736a707ce3cb0839;
uint256 internal constant L1_TO_L2_MESSAGE_ORACLE_CALL_LENGTH = 17;
uint256 internal constant MAX_NOTE_FIELDS_LENGTH = 20;
uint256 internal constant GET_NOTE_ORACLE_RETURN_LENGTH = 23;
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/authwit/src/auth.nr
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub fn assert_current_call_valid_authwit_public<TPublicContext>(
context,
on_behalf_of,
function_selector,
[inner_hash],
[inner_hash].as_slice(),
GasOpts::default()
).deserialize_into();
assert(result == IS_VALID_SELECTOR, "Message not authorized by account");
Expand Down
5 changes: 4 additions & 1 deletion noir-projects/aztec-nr/aztec/src/context.nr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ mod avm_context;
mod interface;
mod gas;

use interface::ContextInterface;
use interface::{
ContextInterface, PrivateCallInterface, PublicCallInterface, PrivateVoidCallInterface,
PublicVoidCallInterface, AvmCallInterface, AvmVoidCallInterface
};
use private_context::PrivateContext;
use private_context::PackedReturns;
use public_context::PublicContext;
Expand Down
Loading
Loading