levana_perpswap_cosmos/contracts/
cw20.rs1#![allow(missing_docs)]
2pub mod entry;
6pub mod events;
7
8use cosmwasm_std::{Addr, Binary, Uint128};
9use schemars::JsonSchema;
10use serde::{Deserialize, Serialize};
11use std::fmt;
12
13#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug)]
14pub struct Cw20Coin {
15 pub address: String,
16 pub amount: Uint128,
17}
18
19impl Cw20Coin {
20 pub fn is_empty(&self) -> bool {
21 self.amount == Uint128::zero()
22 }
23}
24
25impl fmt::Display for Cw20Coin {
26 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
27 write!(f, "address: {}, amount: {}", self.address, self.amount)
28 }
29}
30
31#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug)]
32pub struct Cw20CoinVerified {
33 pub address: Addr,
34 pub amount: Uint128,
35}
36
37impl Cw20CoinVerified {
38 pub fn is_empty(&self) -> bool {
39 self.amount == Uint128::zero()
40 }
41}
42
43impl fmt::Display for Cw20CoinVerified {
44 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
45 write!(f, "address: {}, amount: {}", self.address, self.amount)
46 }
47}
48
49#[derive(Serialize, Deserialize, Clone, JsonSchema, Debug)]
51#[serde(rename_all = "snake_case")]
52pub enum ReceiverExecuteMsg {
53 Receive(Cw20ReceiveMsg),
54}
55
56#[derive(Serialize, Deserialize, Clone, JsonSchema, Debug)]
57pub struct Cw20ReceiveMsg {
58 pub sender: String,
59 pub amount: Uint128,
60 pub msg: Binary,
61}