#[signed_query_multi]Expand description
Procedural macro for the CW84 standard that injects query variants for signed message validation
into a query enum, supporting generic and non-generic CosmosMsg types.
This macro extends a query enum with CW84-compliant variants for smart accounts. It checks if the
enum is generic over T, using CosmosMsg<T> for CanExecute if so, or CosmosMsg otherwise.
It supports custom types for the action message, signed data, and payload, enabling flexible
signed message validation with the multi feature for batch signature verification.
§Arguments
- First type (required): Inner action message type (e.g.,
ExecuteMsg) forCanExecuteSigned. - Second type (optional): Signed data type (e.g.,
SignedDataMsg) forCanExecuteSigned. Defaults tocosmwasm_std::Binary. - Third type (optional): Payload type (e.g.,
CustomPayload) forValidSignature, wrapped inOption. Defaults toOption<cosmwasm_std::Binary>. - Fourth type (optional): Payload type (e.g.,
CustomMultiPayload) forValidSignatures, wrapped inOption. Defaults to the same as the third argument if not provided.
§Generated Variants
CanExecute: Queries if aCosmosMsgcan be executed.CanExecuteSigned: Queries if signed messages can be executed, using provided types.ValidSignature: Verifies a single signature against data and optional payload.ValidSignatures: Verifies multiple signatures against data and optional payload (may use different payload type).
§Notes
- Apply
#[signed_query]before#[cw_serde]or other derives. - Enum must derive
#[derive(QueryResponses)]fromcosmwasm_schemafor#[returns(...)]. - Part of the CW84 spec for smart account signed message validation.
§Examples
§Basic usage
ⓘ
use cosmwasm_schema::{cw_serde, QueryResponses};
#[cw_serde]
pub enum ExecuteMsg { Foo {} }
#[signed_query(ExecuteMsg)]
#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg { /* User queries */ }
// Generates `CanExecute`, `CanExecuteSigned` (with `Binary` signed), `ValidSignature`, and
// `ValidSignatures` with `Option<Binary>` payload.§Custom types with generic enum
ⓘ
#[cw_serde]
pub struct SignedDataMsg { pub data: String, pub signature: String }
#[cw_serde]
pub struct CustomPayload { pub metadata: String }
#[signed_query(ExecuteMsg, SignedDataMsg, CustomPayload)]
#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg<T> { /* User queries */ }
// Generates variants with `CosmosMsg<T>`, `SignedDataMsg` signed, and `Option<CustomPayload>`.§Errors
- Fails if arguments are invalid (e.g., not a type path or wrong count).
- Fails if input is not a valid enum or variant merge fails.