aztec-nr - noir_aztec::macros

Struct AztecConfig

pub struct AztecConfig
{ /* private fields */ }

Configuration for the aztec macro.

This type lets users override different parts of the default aztec-nr contract behavior, such as message handling and state synchronization. These are advanced features that require careful understanding of the behavior of these systems.

Examples

#[aztec(aztec::macros::AztecConfig::new().custom_message_handler(my_handler))]
contract MyContract { ... }

Implementations

impl AztecConfig

pub comptime fn new() -> Self

Creates a new AztecConfig with default values.

Calling new is equivalent to invoking the aztec macro with no parameters. The different methods (e.g. AztecConfig::custom_message_handler) can then be used to change the default behavior.

pub comptime fn custom_message_handler(&mut self, handler: CustomMessageHandler) -> Self

Sets a handler for custom messages.

This enables contracts to process non-standard messages (i.e. any with a message type that is not in crate::messages::msg_type).

handler must be a function that conforms to the crate::messages::discovery::CustomMessageHandler type signature.

pub comptime fn custom_sync_state(&mut self, handler: CustomSyncHandler) -> Self

Overrides the default state synchronization logic.

The generated sync_state function will call handler instead of crate::messages::discovery::do_sync_state. The handler receives all of the same parameters, so it can run custom logic (e.g. fetching and decrypting custom logs) before, after, or instead of calling do_sync_state.

handler must be a function that conforms to the crate::messages::discovery::CustomSyncHandler type signature.