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
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use cosmwasm_std::{to_binary, Binary, CosmosMsg, HumanAddr, StdResult, Uint128, WasmMsg};
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
#[serde(rename_all = "snake_case")]
pub struct Cw721ReceiveMsg {
pub sender: HumanAddr,
pub amount: Uint128,
pub msg: Option<Binary>,
}
impl Cw721ReceiveMsg {
pub fn into_binary(self) -> StdResult<Binary> {
let msg = ReceiverHandleMsg::ReceiveNft(self);
to_binary(&msg)
}
pub fn into_cosmos_msg(self, contract_addr: HumanAddr) -> StdResult<CosmosMsg> {
let msg = self.into_binary()?;
let execute = WasmMsg::Execute {
contract_addr,
msg,
send: vec![],
};
Ok(execute.into())
}
}
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
#[serde(rename_all = "snake_case")]
enum ReceiverHandleMsg {
ReceiveNft(Cw721ReceiveMsg),
}