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