cw20_ics20/
msg.rs

1use cosmwasm_schema::{cw_serde, QueryResponses};
2use cw20::Cw20ReceiveMsg;
3
4use crate::amount::Amount;
5use crate::state::ChannelInfo;
6
7#[cw_serde]
8pub struct InitMsg {
9    /// Default timeout for ics20 packets, specified in seconds
10    pub default_timeout: u64,
11    /// who can allow more contracts
12    pub gov_contract: String,
13    /// initial allowlist - all cw20 tokens we will send must be previously allowed by governance
14    pub allowlist: Vec<AllowMsg>,
15    /// If set, contracts off the allowlist will run with this gas limit.
16    /// If unset, will refuse to accept any contract off the allow list.
17    pub default_gas_limit: Option<u64>,
18}
19
20#[cw_serde]
21pub struct AllowMsg {
22    pub contract: String,
23    pub gas_limit: Option<u64>,
24}
25
26#[cw_serde]
27pub struct MigrateMsg {
28    pub default_gas_limit: Option<u64>,
29}
30
31#[cw_serde]
32pub enum ExecuteMsg {
33    /// This accepts a properly-encoded ReceiveMsg from a cw20 contract
34    Receive(Cw20ReceiveMsg),
35    /// This allows us to transfer *exactly one* native token
36    Transfer(TransferMsg),
37    /// This must be called by gov_contract, will allow a new cw20 token to be sent
38    Allow(AllowMsg),
39    /// Change the admin (must be called by current admin)
40    UpdateAdmin { admin: String },
41}
42
43/// This is the message we accept via Receive
44#[cw_serde]
45pub struct TransferMsg {
46    /// The local channel to send the packets on
47    pub channel: String,
48    /// The remote address to send to.
49    /// Don't use HumanAddress as this will likely have a different Bech32 prefix than we use
50    /// and cannot be validated locally
51    pub remote_address: String,
52    /// How long the packet lives in seconds. If not specified, use default_timeout
53    pub timeout: Option<u64>,
54    /// An optional memo to add to the IBC transfer
55    pub memo: Option<String>,
56}
57
58#[cw_serde]
59#[derive(QueryResponses)]
60pub enum QueryMsg {
61    /// Return the port ID bound by this contract.
62    #[returns(PortResponse)]
63    Port {},
64    /// Show all channels we have connected to.
65    #[returns(ListChannelsResponse)]
66    ListChannels {},
67    /// Returns the details of the name channel, error if not created.
68    #[returns(ChannelResponse)]
69    Channel { id: String },
70    /// Show the Config.
71    #[returns(ConfigResponse)]
72    Config {},
73    #[returns(cw_controllers::AdminResponse)]
74    Admin {},
75    /// Query if a given cw20 contract is allowed.
76    #[returns(AllowedResponse)]
77    Allowed { contract: String },
78    /// List all allowed cw20 contracts.
79    #[returns(ListAllowedResponse)]
80    ListAllowed {
81        start_after: Option<String>,
82        limit: Option<u32>,
83    },
84}
85
86#[cw_serde]
87pub struct ListChannelsResponse {
88    pub channels: Vec<ChannelInfo>,
89}
90
91#[cw_serde]
92pub struct ChannelResponse {
93    /// Information on the channel's connection
94    pub info: ChannelInfo,
95    /// How many tokens we currently have pending over this channel
96    pub balances: Vec<Amount>,
97    /// The total number of tokens that have been sent over this channel
98    /// (even if many have been returned, so balance is low)
99    pub total_sent: Vec<Amount>,
100}
101
102#[cw_serde]
103pub struct PortResponse {
104    pub port_id: String,
105}
106
107#[cw_serde]
108pub struct ConfigResponse {
109    pub default_timeout: u64,
110    pub default_gas_limit: Option<u64>,
111    pub gov_contract: String,
112}
113
114#[cw_serde]
115pub struct AllowedResponse {
116    pub is_allowed: bool,
117    pub gas_limit: Option<u64>,
118}
119
120#[cw_serde]
121pub struct ListAllowedResponse {
122    pub allow: Vec<AllowedInfo>,
123}
124
125#[cw_serde]
126pub struct AllowedInfo {
127    pub contract: String,
128    pub gas_limit: Option<u64>,
129}