abstract_cw20_ics20/
msg.rs

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