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