sv::attr attribute

Use sv::attr to forward an external attribute to the generated message variant.

Macros

List of macros supporting the sv::attr attribute:

Usage

Use the sv::attr above any of the methods marked with #[sv::msg(exec|sudo|query)] attribute.

pub struct Contract;
 
#[contract]
impl Contract {
    pub fn new() -> Self {
        Self
    }
 
    #[sv::msg(instantiate)]
    fn instantiate(&self, ctx: InstantiateCtx) -> StdResult<Response> {
        Ok(Response::new())
    }
 
    #[sv::msg(exec)]
    #[sv::attr(serde(rename = "execute"))]
    fn exec(&self, ctx: ExecCtx) -> StdResult<Response> {
        Ok(Response::new())
    }
}

The contract and interface macros will decorate the message variant with the attribute provided in sv::attr.

#[cw_serde]
pub enum ExecMsg {
    #[serde(rename = "execute")]
    Exec {},
}