Skip to main content

tx_wrapper

Macro tx_wrapper 

Source
macro_rules! tx_wrapper {
    (
        $wrapper_name:ident,
        $entry_type:ty,
        $amount_field:ident,
        $tx_conversion_fn:ident
    ) => { ... };
    (
        $wrapper_name:ident,
        $entry_type:ty,
        $amount_field:ident
    ) => { ... };
}
Expand description

Macro to generate a wrapper struct and its common implementations for transaction entry types.

This macro generates:

  • A wrapper struct with standardized field types (ActionHashB64, AgentPubKeyB64)
  • must_get() method to retrieve the wrapper from a hash
  • amount() method that delegates to the entry’s amount field
  • Optionally TryFrom<Wrapper> for Transaction if a conversion function is provided

§Parameters

  • $wrapper_name: Name of the wrapper struct (e.g., ProposalWrapper)
  • $entry_type: The entry type (e.g., Proposal)
  • $amount_field: The field name in the entry that contains the amount (e.g., proposed_amount)
  • $tx_conversion_fn: Optional function name for converting to Transaction (e.g., from_proposal)