abstract_cw20/
receiver.rs1use cosmwasm_schema::cw_serde;
2use cosmwasm_std::{to_json_binary, Binary, CosmosMsg, StdResult, Uint128, WasmMsg};
3
4#[cw_serde]
6
7pub struct Cw20ReceiveMsg {
8 pub sender: String,
9 pub amount: Uint128,
10 pub msg: Binary,
11}
12
13impl Cw20ReceiveMsg {
14 pub fn into_json_binary(self) -> StdResult<Binary> {
16 let msg = ReceiverExecuteMsg::Receive(self);
17 to_json_binary(&msg)
18 }
19
20 pub fn into_cosmos_msg<T: Into<String>>(self, contract_addr: T) -> StdResult<CosmosMsg> {
22 let msg = self.into_json_binary()?;
23 let execute = WasmMsg::Execute {
24 contract_addr: contract_addr.into(),
25 msg,
26 funds: vec![],
27 };
28 Ok(execute.into())
29 }
30}
31
32#[cw_serde]
34
35enum ReceiverExecuteMsg {
36 Receive(Cw20ReceiveMsg),
37}