#[non_exhaustive]pub enum IbcMsg {
Transfer {
channel_id: String,
to_address: String,
amount: Coin,
timeout: IbcTimeout,
memo: Option<String>,
},
SendPacket {
channel_id: String,
data: Binary,
timeout: IbcTimeout,
},
WriteAcknowledgement {
channel_id: String,
packet_sequence: u64,
ack: IbcAcknowledgement,
},
CloseChannel {
channel_id: String,
},
PayPacketFee {
port_id: String,
channel_id: String,
fee: IbcFee,
relayers: Vec<String>,
},
PayPacketFeeAsync {
port_id: String,
channel_id: String,
sequence: u64,
fee: IbcFee,
relayers: Vec<String>,
},
}
Expand description
These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Transfer
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.
Fields
amount: Coin
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
timeout: IbcTimeout
when packet times out, measured on remote chain
memo: Option<String>
An optional memo. See the blog post “Moving Beyond Simple Token Transfers” 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.
SendPacket
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.
Fields
timeout: IbcTimeout
when packet times out, measured on remote chain
WriteAcknowledgement
Acknowledges a packet that this contract received over IBC.
This allows acknowledging a packet that was not acknowledged yet in the ibc_packet_receive
call.
Fields
ack: IbcAcknowledgement
The acknowledgement to send back
CloseChannel
This will close an existing channel that is owned by this contract. Port is auto-assigned to the contract’s IBC port
PayPacketFee
Incentivizes the next IBC packet sent after this message with a fee. Note that this does not necessarily have to be a packet sent by this contract. The fees are taken from the contract’s balance immediately and locked until the packet is handled.
§Example
Most commonly, you will attach this message to a response right before sending a packet using
IbcMsg::SendPacket
or IbcMsg::Transfer
.
let incentivize = IbcMsg::PayPacketFee {
port_id: "transfer".to_string(),
channel_id: "source-channel".to_string(),
fee: IbcFee {
receive_fee: coins(100, "token"),
ack_fee: coins(201, "token"),
timeout_fee: coins(200, "token"),
},
relayers: vec![],
};
let transfer = IbcMsg::Transfer {
channel_id: "source-channel".to_string(),
to_address: "receiver".to_string(),
amount: Coin::new(100u32, "token"),
timeout: IbcTimeout::with_timestamp(Timestamp::from_nanos(0)),
memo: None,
};
let _: Response = Response::new()
.add_message(CosmosMsg::Ibc(incentivize))
.add_message(CosmosMsg::Ibc(transfer));
Fields
PayPacketFeeAsync
Incentivizes the existing IBC packet with the given port, channel and sequence with a fee. Note that this does not necessarily have to be a packet sent by this contract. The fees are taken from the contract’s balance immediately and locked until the packet is handled. They are added to the existing fees on the packet.
Fields
Trait Implementations§
Source§impl<'de> Deserialize<'de> for IbcMsg
impl<'de> Deserialize<'de> for IbcMsg
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for IbcMsg
impl JsonSchema for IbcMsg
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read moreimpl Eq for IbcMsg
impl StructuralPartialEq for IbcMsg
Auto Trait Implementations§
impl Freeze for IbcMsg
impl RefUnwindSafe for IbcMsg
impl Send for IbcMsg
impl Sync for IbcMsg
impl Unpin for IbcMsg
impl UnwindSafe for IbcMsg
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more