-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: contract interfaces and better function calls (#5687)
Closes #5081 This PR introduces autogenerated contract interfaces for easy intra and inter contract interactions. The `aztec-macro` crate is used to stub every non-internal private and public function and inject them into a ghost struct which has the same name as the contract that generated them. After that, they can be called like this: ```rust contract ImportTest { use dep::my_imported_contract::MyImportedContract; #[aztec(private)] fn a_private_fn() { let deserialized_return = MyImportedContract::at(some_address).another_private_fn(arg1, arg2).call(&mut context); MyImportedContract::at(some_address).a_public_fn(arg1).enqueue(&mut context); } #[aztec(public)] fn a_public_fn() { let deserialized_return = MyImportedContract::at(some_address).a_public_fn(arg1).call(&mut context); } #[aztec(private)] fn calling_my_own_fns() { ImportTest::at(context.this_address).a_private_fn().call(&mut context); ImportTest::at(context.this_address).a_public_fn().enqueue(&mut context); } } ``` Return values are `deserialized_into()` automatically, providing "real" return values thanks to #5633 Also, some general cleanup was required to allow importing contracts in another contracts. Main changes: - `HirContext.fully_qualified_struct_path` now uses BFS to avoid returning the longest path when looking for a struct in a crate. This is required to avoid pulling structs usually imported in top-level dependencies (usually notes from our main contract) from other imported contracts. - `pack_args_oracle` now has a slice mode in addition to its usual array mode. PENDING: ~~AvmContext. The AVM team is discussing supporting args as slices. In case it's decided not to do that, a workaround could possibly be implemented using the macro, but it would be fairly complex.~~ Thanks to @fcarreiro and the amazing AVM team, this is now supported for the AvmContext! --------- Co-authored-by: esau <[email protected]> Co-authored-by: Álvaro Rodríguez <[email protected]>
- Loading branch information
1 parent
be9f24c
commit 274f7d9
Showing
100 changed files
with
1,338 additions
and
2,205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.