Skip to content

feat!: contract_abi-exports#5386

Merged
Thunkar merged 49 commits into
masterfrom
gj/contract_abi_exports
Apr 4, 2024
Merged

feat!: contract_abi-exports#5386
Thunkar merged 49 commits into
masterfrom
gj/contract_abi_exports

Conversation

@Thunkar

@Thunkar Thunkar commented Mar 22, 2024

Copy link
Copy Markdown
Collaborator

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 contract keyword 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 both structs and global top-level statements, and export types (with the current ABIType format) and values (with the new ABIValue format) 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 events contract artifact key gets replaced by:

outputs: {
    structs: Record<string, ABIType[]>;
    globals: Record<string, ABIValue[]>;
};

What this approach allows

  • Removing the smart contract specific attribute #[event], replacing it by a more general #[abi(events)].
  • Substantial devex improvements, such as exposing storage layout, note ids:
    image
    ...or even private function return values prior to macro processing for decoding .view calls feat(Simulate): Allow calling view on constrained functions #2665

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants