macro_rules! combine_extensions {
    ($(#[$meta:meta])* $vis:vis struct $name:ident {
        $($(#[$field_meta:meta])* $field_vis:vis $field_name:ident: $field_type:ty,)*
    }) => { ... };
}
Expand description

Macro defines the combined chain extension via structure definition. Each sub-extension can be accessed by the corresponding field.

The macro expects a structure definition as an input where each field should implement ChainExtensionInstance. Usually, this trait is implemented by the #[ink::chain_extension] macro during the definition of the chain extension.

#[ink::scale_derive(TypeInfo)]
struct ExtensionOne;
impl ink::ChainExtensionInstance for ExtensionOne {
    type Instance = Self;

    fn instantiate() -> Self::Instance {
        Self {}
    }
}

#[ink::scale_derive(TypeInfo)]
struct ExtensionTwo;
impl ink::ChainExtensionInstance for ExtensionTwo {
    type Instance = Self;

    fn instantiate() -> Self::Instance {
        Self {}
    }
}

ink::combine_extensions! {
    /// Defines a combined extension with [`ExtensionOne`] and [`ExtensionTwo`].
    struct Combined {
        /// This field can be used to access the first extension like
        /// `self.env().extension().extension_one` in the contract's context.
        extension_one: ExtensionOne,
        /// This field can be used to access the second extension like
        /// `self.env().extension().extension_two` in the contract's context.
        extension_two: ExtensionTwo,
    }
}