Struct cosmwasm_std::Response[][src]

pub struct Response<T = Empty> where
    T: Clone + Debug + PartialEq + JsonSchema
{ pub submessages: Vec<SubMsg<T>>, pub messages: Vec<CosmosMsg<T>>, pub attributes: Vec<Attribute>, pub data: Option<Binary>, }

A response of a contract entry point, such as instantiate, execute or migrate.

This type can be constructed directly at the end of the call. Alternatively a mutable response instance can be created early in the contract’s logic and incrementally be updated.

Examples

Direct:

use cosmwasm_std::{attr, Response, StdResult};

pub fn instantiate(
    deps: DepsMut,
    _env: Env,
    _info: MessageInfo,
    msg: InstantiateMsg,
) -> StdResult<Response> {
    // ...

    Ok(Response {
        submessages: vec![],
        messages: vec![],
        attributes: vec![attr("action", "instantiate")],
        data: None,
    })
}

Mutating:

use cosmwasm_std::Response;

pub fn instantiate(
    deps: DepsMut,
    _env: Env,
    info: MessageInfo,
    msg: InstantiateMsg,
) -> Result<Response, MyError> {
    let mut response = Response::new();
    // ...
    response.add_attribute("Let the", "hacking begin");
    // ...
    response.add_message(BankMsg::Send {
        to_address: String::from("recipient"),
        amount: coins(128, "uint"),
    });
    response.add_attribute("foo", "bar");
    // ...
    response.set_data(Binary::from(b"the result data"));
    Ok(response)
}

Fields

submessages: Vec<SubMsg<T>>

Optional list of “subcalls” to make. These will be executed in order (and this contract’s subcall_response entry point invoked) before any of the “fire and forget” messages get executed.

messages: Vec<CosmosMsg<T>>

After any submessages are processed, these are all dispatched in the host blockchain. If they all succeed, then the transaction is committed. If any fail, then the transaction and any local contract state changes are reverted.

attributes: Vec<Attribute>

The attributes that will be emitted as part of a “wasm” event

data: Option<Binary>

Implementations

impl<T> Response<T> where
    T: Clone + Debug + PartialEq + JsonSchema
[src]

pub fn new() -> Self[src]

pub fn add_attribute<K: Into<String>, V: Into<String>>(
    &mut self,
    key: K,
    value: V
)
[src]

pub fn add_message<U: Into<CosmosMsg<T>>>(&mut self, msg: U)[src]

pub fn add_submessage<U: Into<CosmosMsg<T>>>(
    &mut self,
    id: u64,
    msg: U,
    gas_limit: Option<u64>,
    reply_on: ReplyOn
)
[src]

pub fn set_data<U: Into<Binary>>(&mut self, data: U)[src]

Trait Implementations

impl<T: Clone> Clone for Response<T> where
    T: Clone + Debug + PartialEq + JsonSchema
[src]

impl<T: Debug> Debug for Response<T> where
    T: Clone + Debug + PartialEq + JsonSchema
[src]

impl<T> Default for Response<T> where
    T: Clone + Debug + PartialEq + JsonSchema
[src]

impl<'de, T> Deserialize<'de> for Response<T> where
    T: Clone + Debug + PartialEq + JsonSchema,
    T: Deserialize<'de>, 
[src]

impl<T> From<Context<T>> for Response<T> where
    T: Clone + Debug + PartialEq + JsonSchema
[src]

impl<T: JsonSchema> JsonSchema for Response<T> where
    T: Clone + Debug + PartialEq + JsonSchema
[src]

impl<T: PartialEq> PartialEq<Response<T>> for Response<T> where
    T: Clone + Debug + PartialEq + JsonSchema
[src]

impl<T> Serialize for Response<T> where
    T: Clone + Debug + PartialEq + JsonSchema,
    T: Serialize
[src]

impl<T> StructuralPartialEq for Response<T> where
    T: Clone + Debug + PartialEq + JsonSchema
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Response<T> where
    T: RefUnwindSafe

impl<T> Send for Response<T> where
    T: Send

impl<T> Sync for Response<T> where
    T: Sync

impl<T> Unpin for Response<T> where
    T: Unpin

impl<T> UnwindSafe for Response<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> DynClone for T where
    T: Clone
[src]

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.