Skip to content

Commit 481ed6f

Browse files
committed
Add ibc fee docs
1 parent c917595 commit 481ed6f

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

packages/std/src/ibc.rs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,52 @@ pub enum IbcMsg {
7575
/// This will close an existing channel that is owned by this contract.
7676
/// Port is auto-assigned to the contract's IBC port
7777
CloseChannel { channel_id: String },
78+
/// Incentivizes the next IBC packet sent after this message with a fee.
79+
/// Note that this does not necessarily have to be a packet sent by this contract.
80+
/// The fees are taken from the contract's balance immediately and locked until the packet is handled.
81+
///
82+
/// # Example
83+
///
84+
/// Most commonly, you will attach this message to a response right before sending a packet using
85+
/// [`IbcMsg::SendPacket`] or [`IbcMsg::Transfer`].
86+
///
87+
/// ```rust
88+
/// # use cosmwasm_std::{IbcMsg, IbcEndpoint, IbcFee, IbcTimeout, Coin, CosmosMsg, Response, Timestamp};
89+
///
90+
/// let incentivize = IbcMsg::PayPacketFee {
91+
/// src: IbcEndpoint {
92+
/// port_id: "transfer".to_string(),
93+
/// channel_id: "source-channel".to_string(),
94+
/// },
95+
/// fee: IbcFee {
96+
/// recv_fee: vec![Coin::new(100u32, "token")],
97+
/// ..IbcFee::default()
98+
/// },
99+
/// relayers: vec![],
100+
/// };
101+
/// let transfer = IbcMsg::Transfer {
102+
/// channel_id: "source-channel".to_string(),
103+
/// to_address: "receiver".to_string(),
104+
/// amount: Coin::new(100u32, "token"),
105+
/// timeout: IbcTimeout::with_timestamp(Timestamp::from_nanos(0)),
106+
/// memo: None,
107+
/// };
108+
///
109+
/// # #[cfg(feature = "stargate")]
110+
/// let _: Response = Response::new()
111+
/// .add_message(CosmosMsg::Ibc(incentivize))
112+
/// .add_message(CosmosMsg::Ibc(transfer));
113+
/// ```
78114
PayPacketFee {
79115
src: IbcEndpoint,
80116
fee: IbcFee,
81117
/// Allowlist of relayer addresses that can receive the fee.
82118
/// This is currently not implemented and *must* be empty.
83119
relayers: Vec<String>,
84120
},
121+
/// Incentivizes the existing IBC packet with the given port, channel and sequence with a fee.
122+
/// Note that this does not necessarily have to be a packet sent by this contract.
123+
/// The fees are taken from the contract's balance immediately and locked until the packet is handled.
85124
PayPacketFeeAsync {
86125
src: IbcEndpoint,
87126
sequence: u64,
@@ -92,7 +131,7 @@ pub enum IbcMsg {
92131
},
93132
}
94133

95-
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
134+
#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq, JsonSchema)]
96135
pub struct IbcFee {
97136
// the packet receive fee
98137
pub recv_fee: Vec<Coin>,

packages/std/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub use crate::ibc::IbcChannelOpenResponse;
7070
pub use crate::ibc::{
7171
Ibc3ChannelOpenResponse, IbcAckCallbackMsg, IbcAcknowledgement, IbcBasicResponse,
7272
IbcCallbackRequest, IbcChannel, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg,
73-
IbcDestinationCallbackMsg, IbcDstCallback, IbcEndpoint, IbcMsg, IbcOrder, IbcPacket,
73+
IbcDestinationCallbackMsg, IbcDstCallback, IbcEndpoint, IbcFee, IbcMsg, IbcOrder, IbcPacket,
7474
IbcPacketAckMsg, IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcReceiveResponse,
7575
IbcSourceCallbackMsg, IbcSrcCallback, IbcTimeout, IbcTimeoutBlock, IbcTimeoutCallbackMsg,
7676
TransferMsgBuilder,

0 commit comments

Comments
 (0)