-
Notifications
You must be signed in to change notification settings - Fork 288
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(noir): autogenerate contract interface for calling from external contracts #1487
Conversation
New dependencies detected. Learn more about Socket for GitHub ↗︎
|
yarn-project/noir-contracts/src/contracts/test_contract/src/test_contract_interface.nr
Show resolved
Hide resolved
yarn-project/noir-contracts/src/contracts/test_contract/src/test_contract_interface.nr
Show resolved
Hide resolved
yarn-project/noir-contracts/src/contracts/test_contract/src/test_contract_interface.nr
Show resolved
Hide resolved
Thanks very much for this Santiago! The final code being generated is so clean! There are a few example contracts in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
@iAmMichaelConnor changes ready! |
Builds on @iAmMichaelConnor work to generate a contract interface for simplifying calling function in other contracts. Uses only information present in the ABI. For each function in the target contract, creates a wrapper function that receives the same arguments, serialises them based on the standard ABI encoding format (see here), and uses the
call_private_function
from thecontext
to call into them.To handle custom structs, we're re-defining them in the contract interface. Until we get struct type names in the ABI (see noir-lang/noir#2238), we are autogenerating the name as well, based on the function name and param name where they are used. Serialisation is done manually in the code, but we may want to replace it with a Noir intrinsic when available (see noir-lang/noir#2240).
See this file for example output.
Fixes #1237