Skip to content

Commit

Permalink
feat: Add TransferV2
Browse files Browse the repository at this point in the history
  • Loading branch information
kulikthebird committed Dec 13, 2024
1 parent e17ecc4 commit a1910c3
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions packages/std/src/ibc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@ mod transfer_msg_builder;
pub use callbacks::*;
pub use transfer_msg_builder::*;

pub struct Token {
base: String,
trace: Vec<Hop>,
amount: uint256,
}

pub struct Forwarding {
hops: Vec<Hop>,
memo: String,
}

pub struct Hop {
port_id: String,
channel_id: String,
}

/// These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts
/// (contracts that directly speak the IBC protocol via 6 entry points)
#[non_exhaustive]
Expand Down Expand Up @@ -52,6 +68,38 @@ pub enum IbcMsg {
/// protobuf encoder instead.
memo: Option<String>,
},
/// Sends bank tokens owned by the contract to the given address on another chain.
/// The channel must already be established between the ibctransfer module on this chain
/// and a matching module on the remote chain.
/// We cannot select the port_id, this is whatever the local chain has bound the ibctransfer
/// module to.
TransferV2 {
/// existing channel to send the tokens over
channel_id: String,
/// address on the remote chain to receive these tokens
to_address: String,
/// packet data only supports one coin
/// https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/ibc/applications/transfer/v1/transfer.proto#L11-L20
tokens: Vec<Token>,
/// when packet times out, measured on remote chain
timeout: IbcTimeout,
/// An optional memo. See the blog post
/// ["Moving Beyond Simple Token Transfers"](https://medium.com/the-interchain-foundation/moving-beyond-simple-token-transfers-d42b2b1dc29b)
/// for more information.
///
/// There is no difference between setting this to `None` or an empty string.
///
/// This field is only supported on chains with CosmWasm >= 2.0 and silently
/// ignored on older chains.
/// If you need support for both 1.x and 2.x chain with the same codebase,
/// it is recommended to use `CosmosMsg::Stargate` with a custom MsgTransfer
/// protobuf encoder instead.
memo: Option<String>,
// a struct containing the list of next hops,
// determining where the tokens must be forwarded next,
// and the memo for the final hop
forwarding: Forwarding,
},
/// Sends an IBC packet with given data over the existing channel.
/// Data should be encoded in a format defined by the channel version,
/// and the module on the other side should know how to parse this.
Expand Down

0 comments on commit a1910c3

Please sign in to comment.