#[signed_execute_multi]Expand description
Procedural macro for the CW84 standard that injects execute variants for signed message execution
into an execute enum, supporting both generic and non-generic CosmosMsg types.
This macro extends an enum with standardized execute variants for smart accounts as defined in the
CW84 specification. It checks if the input enum is generic over T and adjusts the Execute
variant to use CosmosMsg<T> or CosmosMsg accordingly. The macro supports custom types for the
inner action message and signed data, enabling execution of signed messages with multiple messages.
§Arguments
The macro accepts zero to two type arguments via the attribute:
- First type (optional): The inner action message type (e.g.,
ExecuteMsg) for theExecuteSignedandNativevariants. Defaults to the enum’s own type if not provided. - Second type (optional): The signed data type (e.g.,
SignedDataMsg) for theExecuteSignedvariant. Defaults tocw84::Binaryif not provided.
§Generated Variants
The macro injects the following execute variants:
Execute: Executes a list ofCosmosMsgmessages by a smart account.ExecuteSigned: Executes a list of signed messages, using the provided action and data types.Native(only ifexec_typeis specified): Executes a list of messages of the specifiedexec_typedirectly, without requiring signed data.
§Notes
- The
#[signed_execute]attribute must be applied before#[cw_serde]or other derive macros. - Unlike query macros, this macro does not require
#[derive(QueryResponses)]since it targets execute messages. - This macro is designed for the
multifeature, supporting execution of multiple messages.
§Examples
§Example 1: Basic usage with no arguments
use cosmwasm_schema::cw_serde;
#[cw_serde]
#[signed_execute]
pub enum ExecuteMsg {
// User-defined execute messages
}
// Generated:
// pub enum ExecuteMsg {
// // User-defined execute messages
//
// Execute {
// msgs: Vec<::cosmwasm_std::CosmosMsg>,
// },
//
// ExecuteSigned {
// msgs: Vec<ExecuteMsg>,
// signed: ::cw84::Binary,
// nonce: Option<::cosmwasm_std::Uint64>,
// },
// }§Example 2: Usage with a custom execute message type
#[cw_serde]
pub enum ActionMsg {
Foo {},
}
#[signed_execute(ActionMsg)]
#[cw_serde]
pub enum ExecuteMsg {
// User-defined execute messages
}
// Generated:
// pub enum ExecuteMsg {
// // User-defined execute messages
//
// Execute {
// msgs: Vec<::cosmwasm_std::CosmosMsg>,
// },
//
// ExecuteSigned {
// msgs: Vec<ActionMsg>,
// signed: ::cw84::Binary,
// nonce: Option<::cosmwasm_std::Uint64>,
// },
//
// ExecuteNative {
// msgs: Vec<ActionMsg>,
// },
// }§Example 3: Usage with custom execute and signed data types
#[cw_serde]
pub struct SignedDataMsg {
pub data: String,
pub signature: String,
}
#[signed_execute(ActionMsg, SignedDataMsg)]
#[cw_serde]
pub enum ExecuteMsgSigned {
// User-defined execute messages
}
// Generated:
// pub enum ExecuteMsgSigned {
// // User-defined execute messages
//
// Execute {
// msgs: Vec<::cosmwasm_std::CosmosMsg>,
// },
//
// ExecuteSigned {
// msgs: Vec<ActionMsg>,
// signed: SignedDataMsg,
// nonce: Option<::cosmwasm_std::Uint64>,
// },
//
// ExecuteNative {
// msgs: Vec<ActionMsg>,
// },
// }§Example 4: Generic enum with custom types
#[signed_execute(ActionMsg, SignedDataMsg)]
#[cw_serde]
pub enum ExecuteMsgCustom<T> {
// User-defined execute messages
}
// Generated:
// pub enum ExecuteMsgCustom<T> {
// // User-defined execute messages
//
// Execute {
// msgs: Vec<::cosmwasm_std::CosmosMsg<T>>,
// },
//
// ExecuteSigned {
// msgs: Vec<ActionMsg>,
// signed: SignedDataMsg,
// nonce: Option<::cosmwasm_std::Uint64>,
// },
//
// ExecuteNative {
// msgs: Vec<ActionMsg>,
// },
// }§Errors
- Fails with a compile-time error if the attribute arguments are invalid (e.g., not a type path or more than two arguments).
- Fails if the input is not a valid enum or if the merge with generated variants cannot be performed.
This macro is part of the CW84 specification for smart account signed message execution.