#[account_execute]Expand description
Procedural macro to extend an enum with a standardized smart account execution variant.
This macro checks whether the input enum is generic over T and inserts a variant accordingly. If
the enum is generic over T, the Execute variant uses CosmosMsg<T>; otherwise, it uses the
non-generic CosmosMsg. The macro is part of the CW82 specification for smart accounts and is
designed to standardize execution interfaces for smart accounts.
§Arguments
The macro does not accept any type arguments via the attribute.
§Generated Variants
The macro inserts the following execute variant:
Execute: Executes a list ofCosmosMsgmessages by a smart account.
§Notes
- The
#[account_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 executing multiple
CosmosMsgmessages, suitable for batch operations in smart accounts.
§Examples
§Example 1: Basic usage with non-generic enum
ⓘ
use cw82::account_execute;
use cosmwasm_schema::cw_serde;
#[account_execute]
#[cw_serde]
pub enum ExecuteMsg {
// User-defined execute messages
}
// Generated:
// pub enum ExecuteMsg {
// // User-defined execute messages
//
// Execute {
// msgs: Vec<::cosmwasm_std::CosmosMsg>,
// },
// }§Example 2: Usage with a generic enum
ⓘ
#[account_execute]
#[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>>,
// },
// }§Errors
- Fails with a compile-time error if the input is not a valid enum or if the merge with the generated variant cannot be performed.
This macro is part of the CW82 specification for smart account execution.