@@ -6,7 +6,7 @@ use schemars::JsonSchema;
6
6
use serde:: { Deserialize , Serialize } ;
7
7
8
8
use crate :: coin:: Coin ;
9
- use crate :: prelude:: * ;
9
+ use crate :: { prelude:: * , Uint256 } ;
10
10
use crate :: results:: { Attribute , CosmosMsg , Empty , Event , SubMsg } ;
11
11
use crate :: StdResult ;
12
12
use crate :: { to_json_binary, Binary } ;
@@ -18,6 +18,32 @@ mod transfer_msg_builder;
18
18
pub use callbacks:: * ;
19
19
pub use transfer_msg_builder:: * ;
20
20
21
+
22
+ #[ non_exhaustive]
23
+ #[ derive( Serialize , Deserialize , Clone , Debug , PartialEq , Eq , JsonSchema ) ]
24
+ #[ serde( rename_all = "snake_case" ) ]
25
+ pub struct Token {
26
+ base : String ,
27
+ trace : Vec < Hop > ,
28
+ amount : Uint256 ,
29
+ }
30
+
31
+ #[ non_exhaustive]
32
+ #[ derive( Serialize , Deserialize , Clone , Debug , PartialEq , Eq , JsonSchema ) ]
33
+ #[ serde( rename_all = "snake_case" ) ]
34
+ pub struct Forwarding {
35
+ hops : Vec < Hop > ,
36
+ memo : String ,
37
+ }
38
+
39
+ #[ non_exhaustive]
40
+ #[ derive( Serialize , Deserialize , Clone , Debug , PartialEq , Eq , JsonSchema ) ]
41
+ #[ serde( rename_all = "snake_case" ) ]
42
+ pub struct Hop {
43
+ port_id : String ,
44
+ channel_id : String ,
45
+ }
46
+
21
47
/// These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts
22
48
/// (contracts that directly speak the IBC protocol via 6 entry points)
23
49
#[ non_exhaustive]
@@ -52,6 +78,38 @@ pub enum IbcMsg {
52
78
/// protobuf encoder instead.
53
79
memo : Option < String > ,
54
80
} ,
81
+ /// Sends bank tokens owned by the contract to the given address on another chain.
82
+ /// The channel must already be established between the ibctransfer module on this chain
83
+ /// and a matching module on the remote chain.
84
+ /// We cannot select the port_id, this is whatever the local chain has bound the ibctransfer
85
+ /// module to.
86
+ TransferV2 {
87
+ /// existing channel to send the tokens over
88
+ channel_id : String ,
89
+ /// address on the remote chain to receive these tokens
90
+ to_address : String ,
91
+ /// packet data only supports one coin
92
+ /// https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/ibc/applications/transfer/v1/transfer.proto#L11-L20
93
+ tokens : Vec < Token > ,
94
+ /// when packet times out, measured on remote chain
95
+ timeout : IbcTimeout ,
96
+ /// An optional memo. See the blog post
97
+ /// ["Moving Beyond Simple Token Transfers"](https://medium.com/the-interchain-foundation/moving-beyond-simple-token-transfers-d42b2b1dc29b)
98
+ /// for more information.
99
+ ///
100
+ /// There is no difference between setting this to `None` or an empty string.
101
+ ///
102
+ /// This field is only supported on chains with CosmWasm >= 2.0 and silently
103
+ /// ignored on older chains.
104
+ /// If you need support for both 1.x and 2.x chain with the same codebase,
105
+ /// it is recommended to use `CosmosMsg::Stargate` with a custom MsgTransfer
106
+ /// protobuf encoder instead.
107
+ memo : Option < String > ,
108
+ // a struct containing the list of next hops,
109
+ // determining where the tokens must be forwarded next,
110
+ // and the memo for the final hop
111
+ forwarding : Forwarding ,
112
+ } ,
55
113
/// Sends an IBC packet with given data over the existing channel.
56
114
/// Data should be encoded in a format defined by the channel version,
57
115
/// and the module on the other side should know how to parse this.
0 commit comments