feat!: contract_abi-exports#5386
Merged
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal
This PR aims to expose arbitrary types and values resulting from contract compilation in the resulting JSON artifact, in a way that is not tied to aztec-specific features or even smart contracts at all.
Problem
Up until now, Noir compiled crates that used the
contractkeyword with a specific flow, which also added additional structs and metadata to the output such as whatever structs were marked with the#[event]attribute. This coupled Noir to smart contract specific constructs, which were propagated through the compiler (from the parser to the actual compilation output). For #5079 and several other tasks that aim to reduce the mental load and improve the general devex of our users, we need to expose several other structs that are even more specific to aztec, which would only compromise the generality of the compiler further.Proposed solution
The introduction of a new attribute
#[abi(tag)]that can be applied to bothstructsandglobaltop-level statements, and export types (with the currentABITypeformat) and values (with the newABIValueformat) in a way that can be interpreted by components further downstream (for example, our typescript codegen). This way, the noir compiler doesn't know (or care) about whatever gets included in the artifact.The
eventscontract artifact key gets replaced by:What this approach allows
#[event], replacing it by a more general#[abi(events)]....or even private function return values prior to macro processing for decoding
.viewcalls feat(Simulate): Allow callingviewon constrained functions #2665