signed_query_multi

Attribute Macro signed_query_multi 

Source
#[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) for CanExecuteSigned.
  • Second type (optional): Signed data type (e.g., SignedDataMsg) for CanExecuteSigned. Defaults to cosmwasm_std::Binary.
  • Third type (optional): Payload type (e.g., CustomPayload) for ValidSignature, wrapped in Option. Defaults to Option<cosmwasm_std::Binary>.
  • Fourth type (optional): Payload type (e.g., CustomMultiPayload) for ValidSignatures, wrapped in Option. Defaults to the same as the third argument if not provided.

§Generated Variants

  • CanExecute: Queries if a CosmosMsg can 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)] from cosmwasm_schema for #[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.