1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use schemars::JsonSchema;
use cosmwasm_std::{to_binary, Binary, CosmosMsg, StdResult, WasmMsg};
use crate::StdAck;
#[cosmwasm_schema::cw_serde]
pub struct IbcResponseMsg {
pub id: String,
pub msg: StdAck,
}
impl IbcResponseMsg {
pub fn into_binary(self) -> StdResult<Binary> {
let msg = IbcCallbackMsg::IbcCallback(self);
to_binary(&msg)
}
pub fn into_cosmos_msg<T: Into<String>, C>(self, contract_addr: T) -> StdResult<CosmosMsg<C>>
where
C: Clone + std::fmt::Debug + PartialEq + JsonSchema,
{
let msg = self.into_binary()?;
let execute = WasmMsg::Execute {
contract_addr: contract_addr.into(),
msg,
funds: vec![],
};
Ok(execute.into())
}
}
#[cosmwasm_schema::cw_serde]
enum IbcCallbackMsg {
IbcCallback(IbcResponseMsg),
}