Skip to content

Commit abba6cf

Browse files
committed
Add FeeEnabledChannel query
1 parent 77f616a commit abba6cf

File tree

4 files changed

+38
-6
lines changed

4 files changed

+38
-6
lines changed

packages/std/src/ibc.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ pub enum IbcMsg {
113113
/// ```
114114
#[cfg(feature = "cosmwasm_2_2")]
115115
PayPacketFee {
116-
src: IbcEndpoint,
116+
/// The port id on the chain where the packet is sent from (this chain).
117+
port_id: String,
118+
/// The channel id on the chain where the packet is sent from (this chain).
119+
channel_id: String,
117120
fee: IbcFee,
118121
/// Allowlist of relayer addresses that can receive the fee.
119122
/// This is currently not implemented and *must* be empty.
@@ -124,7 +127,11 @@ pub enum IbcMsg {
124127
/// The fees are taken from the contract's balance immediately and locked until the packet is handled.
125128
#[cfg(feature = "cosmwasm_2_2")]
126129
PayPacketFeeAsync {
127-
src: IbcEndpoint,
130+
/// The port id on the chain where the packet is sent from (this chain).
131+
port_id: String,
132+
/// The channel id on the chain where the packet is sent from (this chain).
133+
channel_id: String,
134+
/// The sequence number of the packet that should be incentivized.
128135
sequence: u64,
129136
fee: IbcFee,
130137
/// Allowlist of relayer addresses that can receive the fee.

packages/std/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ pub use crate::query::{
9292
ContractInfoResponse, CustomQuery, DecCoin, Delegation, DelegationResponse,
9393
DelegationRewardsResponse, DelegationTotalRewardsResponse, DelegatorReward,
9494
DelegatorValidatorsResponse, DelegatorWithdrawAddressResponse, DenomMetadataResponse,
95-
DistributionQuery, FullDelegation, GrpcQuery, IbcQuery, ListChannelsResponse, PortIdResponse,
96-
QueryRequest, StakingQuery, SupplyResponse, Validator, ValidatorResponse, WasmQuery,
95+
DistributionQuery, FeeEnabledChannelResponse, FullDelegation, GrpcQuery, IbcQuery,
96+
ListChannelsResponse, PortIdResponse, QueryRequest, StakingQuery, SupplyResponse, Validator,
97+
ValidatorResponse, WasmQuery,
9798
};
9899
#[cfg(all(feature = "stargate", feature = "cosmwasm_1_2"))]
99100
pub use crate::results::WeightedVoteOption;

packages/std/src/query/ibc.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ use crate::ibc::IbcChannel;
55
use crate::prelude::*;
66

77
/// These are queries to the various IBC modules to see the state of the contract's
8-
/// IBC connection. These will return errors if the contract is not "ibc enabled"
8+
/// IBC connection.
9+
/// Most of these will return errors if the contract is not "ibc enabled"
910
#[non_exhaustive]
1011
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
1112
#[serde(rename_all = "snake_case")]
@@ -28,7 +29,16 @@ pub enum IbcQuery {
2829
channel_id: String,
2930
port_id: Option<String>,
3031
},
31-
// TODO: Add more
32+
/// Queries whether the given channel supports IBC fees.
33+
/// If port_id is omitted, it will default to the contract's own channel.
34+
/// (To save a PortId{} call)
35+
///
36+
/// Returns a `FeeEnabledChannelResponse`.
37+
#[cfg(feature = "cosmwasm_2_2")]
38+
FeeEnabledChannel {
39+
port_id: Option<String>,
40+
channel_id: String,
41+
},
3242
}
3343

3444
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
@@ -54,3 +64,11 @@ pub struct ChannelResponse {
5464
}
5565

5666
impl_response_constructor!(ChannelResponse, channel: Option<IbcChannel>);
67+
68+
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
69+
#[non_exhaustive]
70+
pub struct FeeEnabledChannelResponse {
71+
pub fee_enabled: bool,
72+
}
73+
74+
impl_response_constructor!(FeeEnabledChannelResponse, fee_enabled: bool);

packages/std/src/testing/mock.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::prelude::*;
2+
use crate::query::FeeEnabledChannelResponse;
23
use crate::HashFunction;
34
use crate::{Addr, CanonicalAddr, Timestamp};
45
use alloc::collections::BTreeMap;
@@ -903,6 +904,11 @@ impl IbcQuerier {
903904
};
904905
to_json_binary(&res).into()
905906
}
907+
#[cfg(feature = "cosmwasm_2_2")]
908+
IbcQuery::FeeEnabledChannel { .. } => {
909+
// for now, we always return true
910+
to_json_binary(&FeeEnabledChannelResponse::new(true)).into()
911+
}
906912
};
907913
// system result is always ok in the mock implementation
908914
SystemResult::Ok(contract_result)

0 commit comments

Comments
 (0)