From 3f0b433f4ea40c9196a1471e16b753fa66e3e4cc Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Wed, 5 Mar 2025 12:00:29 +0100 Subject: [PATCH 01/26] Add changelog entry --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3da090fd89..2d68d7cea1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,10 @@ and this project adheres to [#2384]: https://github.com/CosmWasm/cosmwasm/pull/2384 +## Fixed + +- cosmwasm-vm: Fix CWA-2025-003. + ## [2.2.1] - 2025-02-04 ## Added From 2fa28a3ebcfb004df0da8aca5f28762ba0b6222e Mon Sep 17 00:00:00 2001 From: BigtoC Date: Fri, 14 Mar 2025 23:03:49 +0800 Subject: [PATCH 02/26] feat(query): Introduce non-breaking changes to handle nullable data stated in https://github.com/CosmWasm/cosmwasm/issues/2414 --- packages/std/src/metadata.rs | 22 ++++++++++++++++++++++ packages/std/src/query/bank.rs | 10 +++++++++- packages/std/src/traits.rs | 15 ++++++++++++--- 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/packages/std/src/metadata.rs b/packages/std/src/metadata.rs index b741f32099..23ed5de279 100644 --- a/packages/std/src/metadata.rs +++ b/packages/std/src/metadata.rs @@ -23,3 +23,25 @@ pub struct DenomUnit { pub exponent: u32, pub aliases: Vec, } + +#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, JsonSchema)] +pub struct NullableDenomMetadata { + pub description: String, + // https://github.com/cosmos/cosmos-sdk/blob/main/api/cosmos/bank/v1beta1/bank.pulsar.go#L4539 + pub denom_units: Option>, + pub base: String, + pub display: String, + pub name: String, + pub symbol: String, + pub uri: String, + pub uri_hash: String, +} + +/// Replicates the cosmos-sdk bank module DenomUnit type +#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, JsonSchema)] +pub struct NullableDenomUnit { + pub denom: String, + pub exponent: u32, + // https://github.com/cosmos/cosmos-sdk/blob/main/api/cosmos/bank/v1beta1/bank.pulsar.go#L4478 + pub aliases: Option>, +} diff --git a/packages/std/src/query/bank.rs b/packages/std/src/query/bank.rs index 7bd4f62e97..db35801e98 100644 --- a/packages/std/src/query/bank.rs +++ b/packages/std/src/query/bank.rs @@ -7,7 +7,7 @@ use crate::prelude::*; #[cfg(feature = "cosmwasm_1_3")] use crate::PageRequest; use crate::{Binary, DenomMetadata}; - +use crate::metadata::NullableDenomMetadata; use super::query_response::QueryResponseType; #[non_exhaustive] @@ -83,6 +83,14 @@ pub struct DenomMetadataResponse { pub metadata: DenomMetadata, } +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[serde(rename_all = "snake_case")] +#[non_exhaustive] +pub struct NullableDenomMetadataResponse { + /// The metadata for the queried denom. + pub metadata: NullableDenomMetadata, +} + impl_response_constructor!(DenomMetadataResponse, metadata: DenomMetadata); impl QueryResponseType for DenomMetadataResponse {} diff --git a/packages/std/src/traits.rs b/packages/std/src/traits.rs index e857063719..032e0ae4ab 100644 --- a/packages/std/src/traits.rs +++ b/packages/std/src/traits.rs @@ -10,9 +10,7 @@ use crate::prelude::*; use crate::query::CodeInfoResponse; #[cfg(feature = "cosmwasm_1_1")] use crate::query::SupplyResponse; -use crate::query::{ - AllBalanceResponse, BalanceResponse, BankQuery, CustomQuery, QueryRequest, WasmQuery, -}; +use crate::query::{AllBalanceResponse, BalanceResponse, BankQuery, CustomQuery, NullableDenomMetadataResponse, QueryRequest, WasmQuery}; #[cfg(feature = "staking")] use crate::query::{ AllDelegationsResponse, AllValidatorsResponse, BondedDenomResponse, Delegation, @@ -30,6 +28,7 @@ use crate::{Addr, CanonicalAddr}; #[cfg(feature = "cosmwasm_1_3")] use crate::{DenomMetadata, PageRequest}; use crate::{RecoverPubkeyError, StdError, StdResult, VerificationError}; +use crate::metadata::NullableDenomMetadata; #[derive(Clone, Copy, Debug)] #[non_exhaustive] @@ -454,6 +453,16 @@ impl<'a, C: CustomQuery> QuerierWrapper<'a, C> { Ok(res.metadata) } + #[cfg(feature = "cosmwasm_1_3")] + pub fn query_nullable_denom_metadata(&self, denom: impl Into) -> StdResult { + let request = BankQuery::DenomMetadata { + denom: denom.into(), + } + .into(); + let res: NullableDenomMetadataResponse = self.query(&request)?; + Ok(res.metadata) + } + #[cfg(feature = "cosmwasm_1_3")] pub fn query_all_denom_metadata( &self, From dbc32830c1de08174853ffe85dd8af6a78d1ea3f Mon Sep 17 00:00:00 2001 From: BigtoC Date: Fri, 14 Mar 2025 23:08:56 +0800 Subject: [PATCH 03/26] chore(fmt): Code formatting --- packages/std/src/query/bank.rs | 4 ++-- packages/std/src/traits.rs | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/std/src/query/bank.rs b/packages/std/src/query/bank.rs index db35801e98..86ebaa9bf1 100644 --- a/packages/std/src/query/bank.rs +++ b/packages/std/src/query/bank.rs @@ -3,12 +3,12 @@ use serde::{Deserialize, Serialize}; use crate::Coin; +use super::query_response::QueryResponseType; +use crate::metadata::NullableDenomMetadata; use crate::prelude::*; #[cfg(feature = "cosmwasm_1_3")] use crate::PageRequest; use crate::{Binary, DenomMetadata}; -use crate::metadata::NullableDenomMetadata; -use super::query_response::QueryResponseType; #[non_exhaustive] #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] diff --git a/packages/std/src/traits.rs b/packages/std/src/traits.rs index 032e0ae4ab..6f87d3812e 100644 --- a/packages/std/src/traits.rs +++ b/packages/std/src/traits.rs @@ -5,12 +5,16 @@ use serde::{de::DeserializeOwned, Serialize}; use crate::coin::Coin; #[cfg(feature = "iterator")] use crate::iterator::{Order, Record}; +use crate::metadata::NullableDenomMetadata; use crate::prelude::*; #[cfg(feature = "cosmwasm_1_2")] use crate::query::CodeInfoResponse; #[cfg(feature = "cosmwasm_1_1")] use crate::query::SupplyResponse; -use crate::query::{AllBalanceResponse, BalanceResponse, BankQuery, CustomQuery, NullableDenomMetadataResponse, QueryRequest, WasmQuery}; +use crate::query::{ + AllBalanceResponse, BalanceResponse, BankQuery, CustomQuery, NullableDenomMetadataResponse, + QueryRequest, WasmQuery, +}; #[cfg(feature = "staking")] use crate::query::{ AllDelegationsResponse, AllValidatorsResponse, BondedDenomResponse, Delegation, @@ -28,7 +32,6 @@ use crate::{Addr, CanonicalAddr}; #[cfg(feature = "cosmwasm_1_3")] use crate::{DenomMetadata, PageRequest}; use crate::{RecoverPubkeyError, StdError, StdResult, VerificationError}; -use crate::metadata::NullableDenomMetadata; #[derive(Clone, Copy, Debug)] #[non_exhaustive] @@ -454,11 +457,14 @@ impl<'a, C: CustomQuery> QuerierWrapper<'a, C> { } #[cfg(feature = "cosmwasm_1_3")] - pub fn query_nullable_denom_metadata(&self, denom: impl Into) -> StdResult { + pub fn query_nullable_denom_metadata( + &self, + denom: impl Into, + ) -> StdResult { let request = BankQuery::DenomMetadata { denom: denom.into(), } - .into(); + .into(); let res: NullableDenomMetadataResponse = self.query(&request)?; Ok(res.metadata) } From 7d2fd917fabe157a0eed19d05a801d6761a62cb7 Mon Sep 17 00:00:00 2001 From: BigtoC Date: Sat, 15 Mar 2025 16:01:40 +0800 Subject: [PATCH 04/26] doc(comment): Add code comments --- packages/std/src/metadata.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/std/src/metadata.rs b/packages/std/src/metadata.rs index 23ed5de279..72af8a3abf 100644 --- a/packages/std/src/metadata.rs +++ b/packages/std/src/metadata.rs @@ -27,7 +27,7 @@ pub struct DenomUnit { #[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, JsonSchema)] pub struct NullableDenomMetadata { pub description: String, - // https://github.com/cosmos/cosmos-sdk/blob/main/api/cosmos/bank/v1beta1/bank.pulsar.go#L4539 + // denom_units is nullable: https://github.com/cosmos/cosmos-sdk/blob/main/api/cosmos/bank/v1beta1/bank.pulsar.go#L4539 pub denom_units: Option>, pub base: String, pub display: String, @@ -42,6 +42,6 @@ pub struct NullableDenomMetadata { pub struct NullableDenomUnit { pub denom: String, pub exponent: u32, - // https://github.com/cosmos/cosmos-sdk/blob/main/api/cosmos/bank/v1beta1/bank.pulsar.go#L4478 + // aliases is nullable: https://github.com/cosmos/cosmos-sdk/blob/main/api/cosmos/bank/v1beta1/bank.pulsar.go#L4478 pub aliases: Option>, } From bb6693b53207d0dc2000ad21bec69a93f0082889 Mon Sep 17 00:00:00 2001 From: BigtoC Date: Sat, 15 Mar 2025 17:24:17 +0800 Subject: [PATCH 05/26] chore(crate): Fix struct imports --- packages/std/src/lib.rs | 6 +++--- packages/std/src/query/bank.rs | 7 ++++--- packages/std/src/traits.rs | 8 +++----- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/std/src/lib.rs b/packages/std/src/lib.rs index eede5242a0..e37ed35adb 100644 --- a/packages/std/src/lib.rs +++ b/packages/std/src/lib.rs @@ -82,7 +82,7 @@ pub use crate::math::{ Int512, Int64, Isqrt, SignedDecimal, SignedDecimal256, SignedDecimal256RangeExceeded, SignedDecimalRangeExceeded, Uint128, Uint256, Uint512, Uint64, }; -pub use crate::metadata::{DenomMetadata, DenomUnit}; +pub use crate::metadata::{DenomMetadata, DenomUnit, NullableDenomMetadata, NullableDenomUnit}; pub use crate::msgpack::{from_msgpack, to_msgpack_binary, to_msgpack_vec}; pub use crate::never::Never; pub use crate::pagination::PageRequest; @@ -93,8 +93,8 @@ pub use crate::query::{ DelegationRewardsResponse, DelegationTotalRewardsResponse, DelegatorReward, DelegatorValidatorsResponse, DelegatorWithdrawAddressResponse, DenomMetadataResponse, DistributionQuery, FeeEnabledChannelResponse, FullDelegation, GrpcQuery, IbcQuery, - ListChannelsResponse, PortIdResponse, QueryRequest, StakingQuery, SupplyResponse, Validator, - ValidatorResponse, WasmQuery, + ListChannelsResponse, NullableDenomMetadataResponse, PortIdResponse, QueryRequest, + StakingQuery, SupplyResponse, Validator, ValidatorResponse, WasmQuery, }; #[cfg(all(feature = "stargate", feature = "cosmwasm_1_2"))] pub use crate::results::WeightedVoteOption; diff --git a/packages/std/src/query/bank.rs b/packages/std/src/query/bank.rs index 86ebaa9bf1..e918d5a0b0 100644 --- a/packages/std/src/query/bank.rs +++ b/packages/std/src/query/bank.rs @@ -4,11 +4,10 @@ use serde::{Deserialize, Serialize}; use crate::Coin; use super::query_response::QueryResponseType; -use crate::metadata::NullableDenomMetadata; use crate::prelude::*; #[cfg(feature = "cosmwasm_1_3")] use crate::PageRequest; -use crate::{Binary, DenomMetadata}; +use crate::{Binary, DenomMetadata, NullableDenomMetadata}; #[non_exhaustive] #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] @@ -83,6 +82,8 @@ pub struct DenomMetadataResponse { pub metadata: DenomMetadata, } +impl_response_constructor!(DenomMetadataResponse, metadata: DenomMetadata); + #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] #[serde(rename_all = "snake_case")] #[non_exhaustive] @@ -91,7 +92,7 @@ pub struct NullableDenomMetadataResponse { pub metadata: NullableDenomMetadata, } -impl_response_constructor!(DenomMetadataResponse, metadata: DenomMetadata); +impl_response_constructor!(NullableDenomMetadataResponse, metadata: NullableDenomMetadata); impl QueryResponseType for DenomMetadataResponse {} diff --git a/packages/std/src/traits.rs b/packages/std/src/traits.rs index 6f87d3812e..ca64f362f9 100644 --- a/packages/std/src/traits.rs +++ b/packages/std/src/traits.rs @@ -5,15 +5,13 @@ use serde::{de::DeserializeOwned, Serialize}; use crate::coin::Coin; #[cfg(feature = "iterator")] use crate::iterator::{Order, Record}; -use crate::metadata::NullableDenomMetadata; use crate::prelude::*; #[cfg(feature = "cosmwasm_1_2")] use crate::query::CodeInfoResponse; #[cfg(feature = "cosmwasm_1_1")] use crate::query::SupplyResponse; use crate::query::{ - AllBalanceResponse, BalanceResponse, BankQuery, CustomQuery, NullableDenomMetadataResponse, - QueryRequest, WasmQuery, + AllBalanceResponse, BalanceResponse, BankQuery, CustomQuery, QueryRequest, WasmQuery, }; #[cfg(feature = "staking")] use crate::query::{ @@ -23,14 +21,14 @@ use crate::query::{ #[cfg(feature = "cosmwasm_1_3")] use crate::query::{ AllDenomMetadataResponse, DelegatorWithdrawAddressResponse, DenomMetadataResponse, - DistributionQuery, + DistributionQuery, NullableDenomMetadataResponse, }; use crate::results::{ContractResult, Empty, SystemResult}; use crate::ContractInfoResponse; use crate::{from_json, to_json_binary, to_json_vec, Binary}; use crate::{Addr, CanonicalAddr}; #[cfg(feature = "cosmwasm_1_3")] -use crate::{DenomMetadata, PageRequest}; +use crate::{DenomMetadata, NullableDenomMetadata, PageRequest}; use crate::{RecoverPubkeyError, StdError, StdResult, VerificationError}; #[derive(Clone, Copy, Debug)] From 093e5946b6982c282f824712ac655dab45c652bc Mon Sep 17 00:00:00 2001 From: Tomasz Kulik Date: Wed, 19 Mar 2025 16:43:32 +0100 Subject: [PATCH 06/26] chore: Deprecate IBC fees --- contracts/ibc-reflect/schema/ibc/packet_msg.json | 3 +++ contracts/reflect/schema/raw/execute.json | 3 +++ contracts/reflect/schema/reflect.json | 3 +++ packages/std/src/ibc.rs | 12 ++++++++++++ 4 files changed, 21 insertions(+) diff --git a/contracts/ibc-reflect/schema/ibc/packet_msg.json b/contracts/ibc-reflect/schema/ibc/packet_msg.json index eec0371bd4..437bb46ac6 100644 --- a/contracts/ibc-reflect/schema/ibc/packet_msg.json +++ b/contracts/ibc-reflect/schema/ibc/packet_msg.json @@ -416,6 +416,7 @@ "additionalProperties": false }, "IbcFee": { + "deprecated": true, "type": "object", "required": [ "ack_fee", @@ -598,6 +599,7 @@ }, { "description": "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.\n\n# Example\n\nMost commonly, you will attach this message to a response right before sending a packet using [`IbcMsg::SendPacket`] or [`IbcMsg::Transfer`].\n\n```rust # use cosmwasm_std::{IbcMsg, IbcEndpoint, IbcFee, IbcTimeout, Coin, coins, CosmosMsg, Response, Timestamp};\n\nlet 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, };\n\n# #[cfg(feature = \"stargate\")] let _: Response = Response::new() .add_message(CosmosMsg::Ibc(incentivize)) .add_message(CosmosMsg::Ibc(transfer)); ```", + "deprecated": true, "type": "object", "required": [ "pay_packet_fee" @@ -638,6 +640,7 @@ }, { "description": "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.", + "deprecated": true, "type": "object", "required": [ "pay_packet_fee_async" diff --git a/contracts/reflect/schema/raw/execute.json b/contracts/reflect/schema/raw/execute.json index 60689b4e44..869f13e077 100644 --- a/contracts/reflect/schema/raw/execute.json +++ b/contracts/reflect/schema/raw/execute.json @@ -489,6 +489,7 @@ "additionalProperties": false }, "IbcFee": { + "deprecated": true, "type": "object", "required": [ "ack_fee", @@ -671,6 +672,7 @@ }, { "description": "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.\n\n# Example\n\nMost commonly, you will attach this message to a response right before sending a packet using [`IbcMsg::SendPacket`] or [`IbcMsg::Transfer`].\n\n```rust # use cosmwasm_std::{IbcMsg, IbcEndpoint, IbcFee, IbcTimeout, Coin, coins, CosmosMsg, Response, Timestamp};\n\nlet 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, };\n\n# #[cfg(feature = \"stargate\")] let _: Response = Response::new() .add_message(CosmosMsg::Ibc(incentivize)) .add_message(CosmosMsg::Ibc(transfer)); ```", + "deprecated": true, "type": "object", "required": [ "pay_packet_fee" @@ -711,6 +713,7 @@ }, { "description": "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.", + "deprecated": true, "type": "object", "required": [ "pay_packet_fee_async" diff --git a/contracts/reflect/schema/reflect.json b/contracts/reflect/schema/reflect.json index 7d59934563..ba37bac72a 100644 --- a/contracts/reflect/schema/reflect.json +++ b/contracts/reflect/schema/reflect.json @@ -499,6 +499,7 @@ "additionalProperties": false }, "IbcFee": { + "deprecated": true, "type": "object", "required": [ "ack_fee", @@ -681,6 +682,7 @@ }, { "description": "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.\n\n# Example\n\nMost commonly, you will attach this message to a response right before sending a packet using [`IbcMsg::SendPacket`] or [`IbcMsg::Transfer`].\n\n```rust # use cosmwasm_std::{IbcMsg, IbcEndpoint, IbcFee, IbcTimeout, Coin, coins, CosmosMsg, Response, Timestamp};\n\nlet 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, };\n\n# #[cfg(feature = \"stargate\")] let _: Response = Response::new() .add_message(CosmosMsg::Ibc(incentivize)) .add_message(CosmosMsg::Ibc(transfer)); ```", + "deprecated": true, "type": "object", "required": [ "pay_packet_fee" @@ -721,6 +723,7 @@ }, { "description": "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.", + "deprecated": true, "type": "object", "required": [ "pay_packet_fee_async" diff --git a/packages/std/src/ibc.rs b/packages/std/src/ibc.rs index 5612cf5ebb..7db03915f6 100644 --- a/packages/std/src/ibc.rs +++ b/packages/std/src/ibc.rs @@ -111,6 +111,10 @@ pub enum IbcMsg { /// .add_message(CosmosMsg::Ibc(transfer)); /// ``` #[cfg(feature = "cosmwasm_2_2")] + #[deprecated( + since = "3.0.0", + note = "IBC fees have been removed from ibc-go `v10`, which is used in wasmd `v0.55.0`." + )] PayPacketFee { /// The port id on the chain where the packet is sent from (this chain). port_id: String, @@ -128,6 +132,10 @@ pub enum IbcMsg { /// 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. #[cfg(feature = "cosmwasm_2_2")] + #[deprecated( + since = "3.0.0", + note = "IBC fees have been removed from ibc-go `v10`, which is used in wasmd `v0.55.0`." + )] PayPacketFeeAsync { /// The port id on the chain where the packet is sent from (this chain). port_id: String, @@ -144,6 +152,10 @@ pub enum IbcMsg { }, } +#[deprecated( + since = "3.0.0", + note = "IBC fees have been removed from ibc-go `v10`, which is used in wasmd `v0.55.0`." +)] #[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq, JsonSchema)] pub struct IbcFee { // the packet receive fee From 7963497eb8ce07aa65be54460a616775db73f93b Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Thu, 20 Mar 2025 11:15:29 +0100 Subject: [PATCH 07/26] Add `#[allow(deprecated)]` over reexport --- packages/std/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/std/src/lib.rs b/packages/std/src/lib.rs index eede5242a0..7120d82650 100644 --- a/packages/std/src/lib.rs +++ b/packages/std/src/lib.rs @@ -67,10 +67,12 @@ pub use crate::errors::{ }; pub use crate::hex_binary::HexBinary; pub use crate::ibc::IbcChannelOpenResponse; +#[allow(deprecated)] +pub use crate::ibc::IbcFee; pub use crate::ibc::{ Ibc3ChannelOpenResponse, IbcAckCallbackMsg, IbcAcknowledgement, IbcBasicResponse, IbcCallbackRequest, IbcChannel, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg, - IbcDestinationCallbackMsg, IbcDstCallback, IbcEndpoint, IbcFee, IbcMsg, IbcOrder, IbcPacket, + IbcDestinationCallbackMsg, IbcDstCallback, IbcEndpoint, IbcMsg, IbcOrder, IbcPacket, IbcPacketAckMsg, IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcReceiveResponse, IbcSourceCallbackMsg, IbcSrcCallback, IbcTimeout, IbcTimeoutBlock, IbcTimeoutCallbackMsg, TransferMsgBuilder, From f616ad27301439361aeb37cfd6b73498994092aa Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Thu, 20 Mar 2025 11:25:38 +0100 Subject: [PATCH 08/26] Allow usage of deprecated APIs in IBC module --- packages/std/src/ibc.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/std/src/ibc.rs b/packages/std/src/ibc.rs index 7db03915f6..fd4a5bb753 100644 --- a/packages/std/src/ibc.rs +++ b/packages/std/src/ibc.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + // The CosmosMsg variants are defined in results/cosmos_msg.rs // The rest of the IBC related functionality is defined here From 01837e0e9f811226310d0a023da59ece44767023 Mon Sep 17 00:00:00 2001 From: Tomasz Kulik Date: Thu, 20 Mar 2025 11:58:08 +0100 Subject: [PATCH 09/26] chore: Fix 'since' argument --- packages/std/src/ibc.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/std/src/ibc.rs b/packages/std/src/ibc.rs index fd4a5bb753..fa3260122a 100644 --- a/packages/std/src/ibc.rs +++ b/packages/std/src/ibc.rs @@ -114,7 +114,7 @@ pub enum IbcMsg { /// ``` #[cfg(feature = "cosmwasm_2_2")] #[deprecated( - since = "3.0.0", + since = "2.2.3", note = "IBC fees have been removed from ibc-go `v10`, which is used in wasmd `v0.55.0`." )] PayPacketFee { @@ -135,7 +135,7 @@ pub enum IbcMsg { /// They are added to the existing fees on the packet. #[cfg(feature = "cosmwasm_2_2")] #[deprecated( - since = "3.0.0", + since = "2.2.3", note = "IBC fees have been removed from ibc-go `v10`, which is used in wasmd `v0.55.0`." )] PayPacketFeeAsync { @@ -155,7 +155,7 @@ pub enum IbcMsg { } #[deprecated( - since = "3.0.0", + since = "2.2.3", note = "IBC fees have been removed from ibc-go `v10`, which is used in wasmd `v0.55.0`." )] #[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq, JsonSchema)] From 46817143063ad8dda46a827067adf7a29e071245 Mon Sep 17 00:00:00 2001 From: Tomasz Kulik Date: Thu, 20 Mar 2025 14:41:14 +0100 Subject: [PATCH 10/26] chore: Update CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d68d7cea1..b0ea9ed06d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,11 +59,15 @@ and this project adheres to - cosmwasm-derive: Add support for migrate method with `migrate_info: MigrateInfo` argument. ([#2212]) - cosmwasm-vm: Add `Cache::store_code` +- cosmwasm-vm: Deprecate `PayPacketFee`, `PayPacketFeeAsync`, `IbcFee`. IBC fees have been + removed from ibc-go in version 10. The mentioned struct and enum fields are deprecated + and will be removed in cosmwasm `3.0` ([#2431]) [#2118]: https://github.com/CosmWasm/cosmwasm/pull/2118 [#2196]: https://github.com/CosmWasm/cosmwasm/pull/2196 [#2220]: https://github.com/CosmWasm/cosmwasm/pull/2220 [#2212]: https://github.com/CosmWasm/cosmwasm/pull/2212 +[#2431]: https://github.com/CosmWasm/cosmwasm/pull/2431 ### Changed From 14f80971a8d72fc708f10f158c4e351d32613a89 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 20 Mar 2025 13:51:37 +0000 Subject: [PATCH 11/26] [autofix.ci] apply automated fixes --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0ea9ed06d..42ca395b6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,9 +59,9 @@ and this project adheres to - cosmwasm-derive: Add support for migrate method with `migrate_info: MigrateInfo` argument. ([#2212]) - cosmwasm-vm: Add `Cache::store_code` -- cosmwasm-vm: Deprecate `PayPacketFee`, `PayPacketFeeAsync`, `IbcFee`. IBC fees have been - removed from ibc-go in version 10. The mentioned struct and enum fields are deprecated - and will be removed in cosmwasm `3.0` ([#2431]) +- cosmwasm-vm: Deprecate `PayPacketFee`, `PayPacketFeeAsync`, `IbcFee`. IBC fees + have been removed from ibc-go in version 10. The mentioned struct and enum + fields are deprecated and will be removed in cosmwasm `3.0` ([#2431]) [#2118]: https://github.com/CosmWasm/cosmwasm/pull/2118 [#2196]: https://github.com/CosmWasm/cosmwasm/pull/2196 From d6cb88c917b3572ca8488fec751506c201a566b9 Mon Sep 17 00:00:00 2001 From: BigtoC Date: Fri, 28 Mar 2025 22:13:40 +0800 Subject: [PATCH 12/26] Rollback changes --- packages/std/src/lib.rs | 6 +++--- packages/std/src/query/bank.rs | 15 +++------------ packages/std/src/traits.rs | 17 ++--------------- 3 files changed, 8 insertions(+), 30 deletions(-) diff --git a/packages/std/src/lib.rs b/packages/std/src/lib.rs index e37ed35adb..eede5242a0 100644 --- a/packages/std/src/lib.rs +++ b/packages/std/src/lib.rs @@ -82,7 +82,7 @@ pub use crate::math::{ Int512, Int64, Isqrt, SignedDecimal, SignedDecimal256, SignedDecimal256RangeExceeded, SignedDecimalRangeExceeded, Uint128, Uint256, Uint512, Uint64, }; -pub use crate::metadata::{DenomMetadata, DenomUnit, NullableDenomMetadata, NullableDenomUnit}; +pub use crate::metadata::{DenomMetadata, DenomUnit}; pub use crate::msgpack::{from_msgpack, to_msgpack_binary, to_msgpack_vec}; pub use crate::never::Never; pub use crate::pagination::PageRequest; @@ -93,8 +93,8 @@ pub use crate::query::{ DelegationRewardsResponse, DelegationTotalRewardsResponse, DelegatorReward, DelegatorValidatorsResponse, DelegatorWithdrawAddressResponse, DenomMetadataResponse, DistributionQuery, FeeEnabledChannelResponse, FullDelegation, GrpcQuery, IbcQuery, - ListChannelsResponse, NullableDenomMetadataResponse, PortIdResponse, QueryRequest, - StakingQuery, SupplyResponse, Validator, ValidatorResponse, WasmQuery, + ListChannelsResponse, PortIdResponse, QueryRequest, StakingQuery, SupplyResponse, Validator, + ValidatorResponse, WasmQuery, }; #[cfg(all(feature = "stargate", feature = "cosmwasm_1_2"))] pub use crate::results::WeightedVoteOption; diff --git a/packages/std/src/query/bank.rs b/packages/std/src/query/bank.rs index e918d5a0b0..7bd4f62e97 100644 --- a/packages/std/src/query/bank.rs +++ b/packages/std/src/query/bank.rs @@ -3,11 +3,12 @@ use serde::{Deserialize, Serialize}; use crate::Coin; -use super::query_response::QueryResponseType; use crate::prelude::*; #[cfg(feature = "cosmwasm_1_3")] use crate::PageRequest; -use crate::{Binary, DenomMetadata, NullableDenomMetadata}; +use crate::{Binary, DenomMetadata}; + +use super::query_response::QueryResponseType; #[non_exhaustive] #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] @@ -84,16 +85,6 @@ pub struct DenomMetadataResponse { impl_response_constructor!(DenomMetadataResponse, metadata: DenomMetadata); -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -#[serde(rename_all = "snake_case")] -#[non_exhaustive] -pub struct NullableDenomMetadataResponse { - /// The metadata for the queried denom. - pub metadata: NullableDenomMetadata, -} - -impl_response_constructor!(NullableDenomMetadataResponse, metadata: NullableDenomMetadata); - impl QueryResponseType for DenomMetadataResponse {} #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] diff --git a/packages/std/src/traits.rs b/packages/std/src/traits.rs index ca64f362f9..e857063719 100644 --- a/packages/std/src/traits.rs +++ b/packages/std/src/traits.rs @@ -21,14 +21,14 @@ use crate::query::{ #[cfg(feature = "cosmwasm_1_3")] use crate::query::{ AllDenomMetadataResponse, DelegatorWithdrawAddressResponse, DenomMetadataResponse, - DistributionQuery, NullableDenomMetadataResponse, + DistributionQuery, }; use crate::results::{ContractResult, Empty, SystemResult}; use crate::ContractInfoResponse; use crate::{from_json, to_json_binary, to_json_vec, Binary}; use crate::{Addr, CanonicalAddr}; #[cfg(feature = "cosmwasm_1_3")] -use crate::{DenomMetadata, NullableDenomMetadata, PageRequest}; +use crate::{DenomMetadata, PageRequest}; use crate::{RecoverPubkeyError, StdError, StdResult, VerificationError}; #[derive(Clone, Copy, Debug)] @@ -454,19 +454,6 @@ impl<'a, C: CustomQuery> QuerierWrapper<'a, C> { Ok(res.metadata) } - #[cfg(feature = "cosmwasm_1_3")] - pub fn query_nullable_denom_metadata( - &self, - denom: impl Into, - ) -> StdResult { - let request = BankQuery::DenomMetadata { - denom: denom.into(), - } - .into(); - let res: NullableDenomMetadataResponse = self.query(&request)?; - Ok(res.metadata) - } - #[cfg(feature = "cosmwasm_1_3")] pub fn query_all_denom_metadata( &self, From eccbf556f704a10fb5e7cbcd1d0172a1afb55104 Mon Sep 17 00:00:00 2001 From: BigtoC Date: Fri, 28 Mar 2025 22:14:12 +0800 Subject: [PATCH 13/26] refactor(metadata): Add deserializer for denom_units and aliases to handle null values --- packages/std/src/metadata.rs | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/packages/std/src/metadata.rs b/packages/std/src/metadata.rs index 72af8a3abf..aa7a111b91 100644 --- a/packages/std/src/metadata.rs +++ b/packages/std/src/metadata.rs @@ -1,5 +1,5 @@ use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; +use serde::{Deserialize, Deserializer, Serialize}; use crate::prelude::*; @@ -7,6 +7,7 @@ use crate::prelude::*; #[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, JsonSchema)] pub struct DenomMetadata { pub description: String, + #[serde(deserialize_with = "deserialize_null_default")] pub denom_units: Vec, pub base: String, pub display: String, @@ -21,27 +22,15 @@ pub struct DenomMetadata { pub struct DenomUnit { pub denom: String, pub exponent: u32, + #[serde(deserialize_with = "deserialize_null_default")] pub aliases: Vec, } -#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, JsonSchema)] -pub struct NullableDenomMetadata { - pub description: String, - // denom_units is nullable: https://github.com/cosmos/cosmos-sdk/blob/main/api/cosmos/bank/v1beta1/bank.pulsar.go#L4539 - pub denom_units: Option>, - pub base: String, - pub display: String, - pub name: String, - pub symbol: String, - pub uri: String, - pub uri_hash: String, -} - -/// Replicates the cosmos-sdk bank module DenomUnit type -#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, JsonSchema)] -pub struct NullableDenomUnit { - pub denom: String, - pub exponent: u32, - // aliases is nullable: https://github.com/cosmos/cosmos-sdk/blob/main/api/cosmos/bank/v1beta1/bank.pulsar.go#L4478 - pub aliases: Option>, +fn deserialize_null_default<'de, D, T>(deserializer: D) -> Result +where + T: Default + Deserialize<'de>, + D: Deserializer<'de>, +{ + let opt = Option::deserialize(deserializer)?; + Ok(opt.unwrap_or_default()) } From a9b5b16dd2dbd1ca14d21f7dbbe050ebf073048a Mon Sep 17 00:00:00 2001 From: BigtoC Date: Fri, 28 Mar 2025 23:09:34 +0800 Subject: [PATCH 14/26] feat(metadata): Add test --- contracts/cyberpunk/Cargo.lock | 3 +- contracts/cyberpunk/Cargo.toml | 1 + contracts/cyberpunk/src/contract.rs | 158 ++++++++++++++++++++++++++++ packages/std/src/metadata.rs | 108 +++++++++++++++++++ 4 files changed, 269 insertions(+), 1 deletion(-) diff --git a/contracts/cyberpunk/Cargo.lock b/contracts/cyberpunk/Cargo.lock index 11590c8d73..8744cebdaf 100644 --- a/contracts/cyberpunk/Cargo.lock +++ b/contracts/cyberpunk/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -590,6 +590,7 @@ dependencies = [ "cosmwasm-std", "cosmwasm-vm", "rust-argon2", + "serde_json", "tempfile", "thiserror", ] diff --git a/contracts/cyberpunk/Cargo.toml b/contracts/cyberpunk/Cargo.toml index e16fb8dbdd..1096d4b87e 100644 --- a/contracts/cyberpunk/Cargo.toml +++ b/contracts/cyberpunk/Cargo.toml @@ -28,6 +28,7 @@ cosmwasm-std = { path = "../../packages/std", default-features = false, features ] } rust-argon2 = "2.1" thiserror = "1.0.26" +serde_json = "1.0.117" [dev-dependencies] cosmwasm-vm = { path = "../../packages/vm", default-features = false } diff --git a/contracts/cyberpunk/src/contract.rs b/contracts/cyberpunk/src/contract.rs index b269fe6ea3..5255e67ed7 100644 --- a/contracts/cyberpunk/src/contract.rs +++ b/contracts/cyberpunk/src/contract.rs @@ -230,6 +230,7 @@ mod tests { message_info, mock_dependencies, mock_env, MockApi, MockQuerier, MockStorage, }; use cosmwasm_std::{from_json, DenomMetadata, DenomUnit, OwnedDeps}; + use serde_json::{json, Error}; fn setup() -> OwnedDeps { let mut deps = mock_dependencies(); @@ -297,4 +298,161 @@ mod tests { assert_eq!(denom.symbol, "FOO0"); } + + #[test] + fn query_denom_metadata_with_null_denom_units_works() { + // Test case with null denom_units - should deserialize as empty vec + let json_with_null_denom_units = json!({ + "description": "Test Token", + "denom_units": null, + "base": "utest", + "display": "TEST", + "name": "Test Token", + "symbol": "TEST", + "uri": "https://test.com", + "uri_hash": "hash" + }); + + let metadata_with_null_denom_units: DenomMetadata = + serde_json::from_value(json_with_null_denom_units).unwrap(); + assert_eq!( + metadata_with_null_denom_units.denom_units, + Vec::::default() + ); + assert!(metadata_with_null_denom_units.denom_units.is_empty()); + + // Test normal case with provided denom_units + let json_with_units = json!({ + "description": "Test Token", + "denom_units": [ + { + "denom": "utest", + "exponent": 6, + "aliases": ["microtest"] + } + ], + "base": "utest", + "display": "TEST", + "name": "Test Token", + "symbol": "TEST", + "uri": "https://test.com", + "uri_hash": "hash" + }); + + let metadata_with_units: DenomMetadata = serde_json::from_value(json_with_units).unwrap(); + assert_eq!(metadata_with_units.denom_units.len(), 1); + assert_eq!(metadata_with_units.denom_units[0].denom, "utest"); + assert_eq!(metadata_with_units.denom_units[0].aliases.len(), 1); + assert_eq!(metadata_with_units.denom_units[0].aliases[0], "microtest"); + + // Test with null aliases inside denom_units - should deserialize as empty vec + let json_with_null_aliases = json!({ + "description": "Test Token", + "denom_units": [ + { + "denom": "utest", + "exponent": 6, + "aliases": null + } + ], + "base": "utest", + "display": "TEST", + "name": "Test Token", + "symbol": "TEST", + "uri": "https://test.com", + "uri_hash": "hash" + }); + + let metadata_with_null_aliases: DenomMetadata = + serde_json::from_value(json_with_null_aliases).unwrap(); + assert_eq!(metadata_with_null_aliases.denom_units.len(), 1); + assert_eq!( + metadata_with_null_aliases.denom_units[0].aliases, + Vec::::default() + ); + assert!(metadata_with_null_aliases.denom_units[0].aliases.is_empty()); + } + + #[test] + fn query_denom_metadata_with_missing_fields_fails() { + // Missing denom_units should be treated as default value (empty vec) + let json_missing_denom_units = json!({ + "description": "Test Token", + "base": "utest", + "display": "TEST", + "name": "Test Token", + "symbol": "TEST", + "uri": "https://test.com", + "uri_hash": "hash" + }); + + let json_missing_denom_units_metadata: Result = + serde_json::from_value(json_missing_denom_units); + assert!(json_missing_denom_units_metadata.is_err()); + + // Missing aliases field should be treated as default (empty vec) + let json_missing_aliases = json!({ + "description": "Test Token", + "denom_units": [ + { + "denom": "utest", + "exponent": 6 + } + ], + "base": "utest", + "display": "TEST", + "name": "Test Token", + "symbol": "TEST", + "uri": "https://test.com", + "uri_hash": "hash" + }); + + let missing_aliases_metadata: Result = + serde_json::from_value(json_missing_aliases); + assert!(missing_aliases_metadata.is_err()); + } + + #[test] + fn query_denom_metadata_with_mixed_null_and_value_works() { + // Test with multiple denom units, some with null aliases and some with values + let mixed_json = json!({ + "description": "Mixed Token", + "denom_units": [ + { + "denom": "unit1", + "exponent": 0, + "aliases": null + }, + { + "denom": "unit2", + "exponent": 6, + "aliases": ["microunit", "u"] + }, + { + "denom": "unit3", + "exponent": 9, + "aliases": [] + } + ], + "base": "unit1", + "display": "MIXED", + "name": "Mixed Token", + "symbol": "MIX", + "uri": "https://mixed.token", + "uri_hash": "hash123" + }); + + let metadata: DenomMetadata = serde_json::from_value(mixed_json).unwrap(); + + // First denom unit has null aliases, should be empty vec + assert!(metadata.denom_units[0].aliases.is_empty()); + + // Second has two aliases + assert_eq!(metadata.denom_units[1].aliases.len(), 2); + assert_eq!(metadata.denom_units[1].aliases[0], "microunit"); + assert_eq!(metadata.denom_units[1].aliases[1], "u"); + + // Third has explicitly empty aliases + assert!(metadata.denom_units[2].aliases.is_empty()); + } } diff --git a/packages/std/src/metadata.rs b/packages/std/src/metadata.rs index aa7a111b91..03106d8874 100644 --- a/packages/std/src/metadata.rs +++ b/packages/std/src/metadata.rs @@ -26,6 +26,8 @@ pub struct DenomUnit { pub aliases: Vec, } +// Deserialize a field that is null, defaulting to the type's default value. +// Panic if the field is missing. fn deserialize_null_default<'de, D, T>(deserializer: D) -> Result where T: Default + Deserialize<'de>, @@ -34,3 +36,109 @@ where let opt = Option::deserialize(deserializer)?; Ok(opt.unwrap_or_default()) } + +#[cfg(test)] +mod tests { + use super::*; + use serde_json::{json, Error}; + + #[test] + fn deserialize_denom_metadata_with_null_fields_works() { + // Test case with null denom_units - should deserialize as empty vec + let json_with_null_denom_units = json!({ + "description": "Test Token", + "denom_units": null, + "base": "utest", + "display": "TEST", + "name": "Test Token", + "symbol": "TEST", + "uri": "https://test.com", + "uri_hash": "hash" + }); + + let metadata_null_denom_units: DenomMetadata = serde_json::from_value(json_with_null_denom_units).unwrap(); + assert_eq!(metadata_null_denom_units.denom_units, Vec::::default()); + assert!(metadata_null_denom_units.denom_units.is_empty()); + + // Test normal case with provided denom_units + let json_with_units = json!({ + "description": "Test Token", + "denom_units": [ + { + "denom": "utest", + "exponent": 6, + "aliases": ["microtest"] + } + ], + "base": "utest", + "display": "TEST", + "name": "Test Token", + "symbol": "TEST", + "uri": "https://test.com", + "uri_hash": "hash" + }); + + let metadata_with_units: DenomMetadata = serde_json::from_value(json_with_units).unwrap(); + assert_eq!(metadata_with_units.denom_units.len(), 1); + assert_eq!(metadata_with_units.denom_units[0].denom, "utest"); + + // Test with null aliases inside denom_units - should deserialize as empty vec + let json_with_null_aliases = json!({ + "description": "Test Token", + "denom_units": [ + { + "denom": "utest", + "exponent": 6, + "aliases": null + } + ], + "base": "utest", + "display": "TEST", + "name": "Test Token", + "symbol": "TEST", + "uri": "https://test.com", + "uri_hash": "hash" + }); + + let metadata_with_null_aliases: DenomMetadata = serde_json::from_value(json_with_null_aliases).unwrap(); + assert_eq!(metadata_with_null_aliases.denom_units.len(), 1); + assert_eq!(metadata_with_null_aliases.denom_units[0].aliases, Vec::::default()); + assert!(metadata_with_null_aliases.denom_units[0].aliases.is_empty()); + } + + #[test] + fn deserialize_denom_metadata_with_missing_fields_fails() { + // Missing denom_units should be treated like null + let json_missing_denom_units = json!({ + "description": "Test Token", + "base": "utest", + "display": "TEST", + "name": "Test Token", + "symbol": "TEST", + "uri": "https://test.com", + "uri_hash": "hash" + }); + + let metadata: Result = serde_json::from_value(json_missing_denom_units); + assert!(metadata.is_err()); + + let json_missing_alias = json!({ + "description": "Test Token", + "base": "utest", + "denom_units": [ + { + "denom": "utest", + "exponent": 6, + } + ], + "display": "TEST", + "name": "Test Token", + "symbol": "TEST", + "uri": "https://test.com", + "uri_hash": "hash" + }); + + let metadata_missing_alias: Result = serde_json::from_value(json_missing_alias); + assert!(metadata_missing_alias.is_err()); + } +} From 0d8b5ebad191229a605dd7b7790930ea4b46b5a6 Mon Sep 17 00:00:00 2001 From: BigtoC Date: Fri, 28 Mar 2025 23:14:14 +0800 Subject: [PATCH 15/26] chore(fmt): Fix code format --- packages/std/src/metadata.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/std/src/metadata.rs b/packages/std/src/metadata.rs index 03106d8874..a38f1152cf 100644 --- a/packages/std/src/metadata.rs +++ b/packages/std/src/metadata.rs @@ -56,8 +56,12 @@ mod tests { "uri_hash": "hash" }); - let metadata_null_denom_units: DenomMetadata = serde_json::from_value(json_with_null_denom_units).unwrap(); - assert_eq!(metadata_null_denom_units.denom_units, Vec::::default()); + let metadata_null_denom_units: DenomMetadata = + serde_json::from_value(json_with_null_denom_units).unwrap(); + assert_eq!( + metadata_null_denom_units.denom_units, + Vec::::default() + ); assert!(metadata_null_denom_units.denom_units.is_empty()); // Test normal case with provided denom_units @@ -100,9 +104,13 @@ mod tests { "uri_hash": "hash" }); - let metadata_with_null_aliases: DenomMetadata = serde_json::from_value(json_with_null_aliases).unwrap(); + let metadata_with_null_aliases: DenomMetadata = + serde_json::from_value(json_with_null_aliases).unwrap(); assert_eq!(metadata_with_null_aliases.denom_units.len(), 1); - assert_eq!(metadata_with_null_aliases.denom_units[0].aliases, Vec::::default()); + assert_eq!( + metadata_with_null_aliases.denom_units[0].aliases, + Vec::::default() + ); assert!(metadata_with_null_aliases.denom_units[0].aliases.is_empty()); } @@ -119,7 +127,8 @@ mod tests { "uri_hash": "hash" }); - let metadata: Result = serde_json::from_value(json_missing_denom_units); + let metadata: Result = + serde_json::from_value(json_missing_denom_units); assert!(metadata.is_err()); let json_missing_alias = json!({ @@ -138,7 +147,8 @@ mod tests { "uri_hash": "hash" }); - let metadata_missing_alias: Result = serde_json::from_value(json_missing_alias); + let metadata_missing_alias: Result = + serde_json::from_value(json_missing_alias); assert!(metadata_missing_alias.is_err()); } } From caf66b53a645cb441cc05ec46067144430ca3a83 Mon Sep 17 00:00:00 2001 From: BigtoC Date: Fri, 28 Mar 2025 23:17:21 +0800 Subject: [PATCH 16/26] chore(Cargo): Downgrade Cargo.lock version from 4 to 3 --- contracts/cyberpunk/Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/cyberpunk/Cargo.lock b/contracts/cyberpunk/Cargo.lock index 8744cebdaf..1529b14896 100644 --- a/contracts/cyberpunk/Cargo.lock +++ b/contracts/cyberpunk/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 4 +version = 3 [[package]] name = "addr2line" From 17a7a3b2072edfe147bd45055f9bf4fb23529bc4 Mon Sep 17 00:00:00 2001 From: BigtoC Date: Sat, 29 Mar 2025 11:59:37 +0800 Subject: [PATCH 17/26] Rollback cyberpunk test related codes --- contracts/cyberpunk/Cargo.lock | 1 - contracts/cyberpunk/Cargo.toml | 1 - contracts/cyberpunk/src/contract.rs | 158 ---------------------------- 3 files changed, 160 deletions(-) diff --git a/contracts/cyberpunk/Cargo.lock b/contracts/cyberpunk/Cargo.lock index 1529b14896..11590c8d73 100644 --- a/contracts/cyberpunk/Cargo.lock +++ b/contracts/cyberpunk/Cargo.lock @@ -590,7 +590,6 @@ dependencies = [ "cosmwasm-std", "cosmwasm-vm", "rust-argon2", - "serde_json", "tempfile", "thiserror", ] diff --git a/contracts/cyberpunk/Cargo.toml b/contracts/cyberpunk/Cargo.toml index 1096d4b87e..e16fb8dbdd 100644 --- a/contracts/cyberpunk/Cargo.toml +++ b/contracts/cyberpunk/Cargo.toml @@ -28,7 +28,6 @@ cosmwasm-std = { path = "../../packages/std", default-features = false, features ] } rust-argon2 = "2.1" thiserror = "1.0.26" -serde_json = "1.0.117" [dev-dependencies] cosmwasm-vm = { path = "../../packages/vm", default-features = false } diff --git a/contracts/cyberpunk/src/contract.rs b/contracts/cyberpunk/src/contract.rs index 5255e67ed7..b269fe6ea3 100644 --- a/contracts/cyberpunk/src/contract.rs +++ b/contracts/cyberpunk/src/contract.rs @@ -230,7 +230,6 @@ mod tests { message_info, mock_dependencies, mock_env, MockApi, MockQuerier, MockStorage, }; use cosmwasm_std::{from_json, DenomMetadata, DenomUnit, OwnedDeps}; - use serde_json::{json, Error}; fn setup() -> OwnedDeps { let mut deps = mock_dependencies(); @@ -298,161 +297,4 @@ mod tests { assert_eq!(denom.symbol, "FOO0"); } - - #[test] - fn query_denom_metadata_with_null_denom_units_works() { - // Test case with null denom_units - should deserialize as empty vec - let json_with_null_denom_units = json!({ - "description": "Test Token", - "denom_units": null, - "base": "utest", - "display": "TEST", - "name": "Test Token", - "symbol": "TEST", - "uri": "https://test.com", - "uri_hash": "hash" - }); - - let metadata_with_null_denom_units: DenomMetadata = - serde_json::from_value(json_with_null_denom_units).unwrap(); - assert_eq!( - metadata_with_null_denom_units.denom_units, - Vec::::default() - ); - assert!(metadata_with_null_denom_units.denom_units.is_empty()); - - // Test normal case with provided denom_units - let json_with_units = json!({ - "description": "Test Token", - "denom_units": [ - { - "denom": "utest", - "exponent": 6, - "aliases": ["microtest"] - } - ], - "base": "utest", - "display": "TEST", - "name": "Test Token", - "symbol": "TEST", - "uri": "https://test.com", - "uri_hash": "hash" - }); - - let metadata_with_units: DenomMetadata = serde_json::from_value(json_with_units).unwrap(); - assert_eq!(metadata_with_units.denom_units.len(), 1); - assert_eq!(metadata_with_units.denom_units[0].denom, "utest"); - assert_eq!(metadata_with_units.denom_units[0].aliases.len(), 1); - assert_eq!(metadata_with_units.denom_units[0].aliases[0], "microtest"); - - // Test with null aliases inside denom_units - should deserialize as empty vec - let json_with_null_aliases = json!({ - "description": "Test Token", - "denom_units": [ - { - "denom": "utest", - "exponent": 6, - "aliases": null - } - ], - "base": "utest", - "display": "TEST", - "name": "Test Token", - "symbol": "TEST", - "uri": "https://test.com", - "uri_hash": "hash" - }); - - let metadata_with_null_aliases: DenomMetadata = - serde_json::from_value(json_with_null_aliases).unwrap(); - assert_eq!(metadata_with_null_aliases.denom_units.len(), 1); - assert_eq!( - metadata_with_null_aliases.denom_units[0].aliases, - Vec::::default() - ); - assert!(metadata_with_null_aliases.denom_units[0].aliases.is_empty()); - } - - #[test] - fn query_denom_metadata_with_missing_fields_fails() { - // Missing denom_units should be treated as default value (empty vec) - let json_missing_denom_units = json!({ - "description": "Test Token", - "base": "utest", - "display": "TEST", - "name": "Test Token", - "symbol": "TEST", - "uri": "https://test.com", - "uri_hash": "hash" - }); - - let json_missing_denom_units_metadata: Result = - serde_json::from_value(json_missing_denom_units); - assert!(json_missing_denom_units_metadata.is_err()); - - // Missing aliases field should be treated as default (empty vec) - let json_missing_aliases = json!({ - "description": "Test Token", - "denom_units": [ - { - "denom": "utest", - "exponent": 6 - } - ], - "base": "utest", - "display": "TEST", - "name": "Test Token", - "symbol": "TEST", - "uri": "https://test.com", - "uri_hash": "hash" - }); - - let missing_aliases_metadata: Result = - serde_json::from_value(json_missing_aliases); - assert!(missing_aliases_metadata.is_err()); - } - - #[test] - fn query_denom_metadata_with_mixed_null_and_value_works() { - // Test with multiple denom units, some with null aliases and some with values - let mixed_json = json!({ - "description": "Mixed Token", - "denom_units": [ - { - "denom": "unit1", - "exponent": 0, - "aliases": null - }, - { - "denom": "unit2", - "exponent": 6, - "aliases": ["microunit", "u"] - }, - { - "denom": "unit3", - "exponent": 9, - "aliases": [] - } - ], - "base": "unit1", - "display": "MIXED", - "name": "Mixed Token", - "symbol": "MIX", - "uri": "https://mixed.token", - "uri_hash": "hash123" - }); - - let metadata: DenomMetadata = serde_json::from_value(mixed_json).unwrap(); - - // First denom unit has null aliases, should be empty vec - assert!(metadata.denom_units[0].aliases.is_empty()); - - // Second has two aliases - assert_eq!(metadata.denom_units[1].aliases.len(), 2); - assert_eq!(metadata.denom_units[1].aliases[0], "microunit"); - assert_eq!(metadata.denom_units[1].aliases[1], "u"); - - // Third has explicitly empty aliases - assert!(metadata.denom_units[2].aliases.is_empty()); - } } From 275ea848b6a4bce8be732a5c9dcd00551dd97499 Mon Sep 17 00:00:00 2001 From: BigtoC Date: Sat, 29 Mar 2025 12:00:07 +0800 Subject: [PATCH 18/26] feat(metadata): add unit and integration tests for DenomMetadata handling null values --- packages/std/src/metadata.rs | 165 ++++++++++++++++++++++++++++++++++- 1 file changed, 164 insertions(+), 1 deletion(-) diff --git a/packages/std/src/metadata.rs b/packages/std/src/metadata.rs index a38f1152cf..2496150d2d 100644 --- a/packages/std/src/metadata.rs +++ b/packages/std/src/metadata.rs @@ -38,7 +38,7 @@ where } #[cfg(test)] -mod tests { +mod unit_tests { use super::*; use serde_json::{json, Error}; @@ -152,3 +152,166 @@ mod tests { assert!(metadata_missing_alias.is_err()); } } + +#[cfg(test)] +mod integration_tests { + use crate::{DenomMetadata, DenomUnit}; + use serde_json::{json, Error}; + + #[test] + fn query_denom_metadata_with_null_denom_units_works() { + // Test case with null denom_units - should deserialize as empty vec + let json_with_null_denom_units = json!({ + "description": "Test Token", + "denom_units": null, + "base": "utest", + "display": "TEST", + "name": "Test Token", + "symbol": "TEST", + "uri": "https://test.com", + "uri_hash": "hash" + }); + + let metadata_with_null_denom_units: DenomMetadata = + serde_json::from_value(json_with_null_denom_units).unwrap(); + assert_eq!( + metadata_with_null_denom_units.denom_units, + Vec::::default() + ); + assert!(metadata_with_null_denom_units.denom_units.is_empty()); + + // Test normal case with provided denom_units + let json_with_units = json!({ + "description": "Test Token", + "denom_units": [ + { + "denom": "utest", + "exponent": 6, + "aliases": ["microtest"] + } + ], + "base": "utest", + "display": "TEST", + "name": "Test Token", + "symbol": "TEST", + "uri": "https://test.com", + "uri_hash": "hash" + }); + + let metadata_with_units: DenomMetadata = serde_json::from_value(json_with_units).unwrap(); + assert_eq!(metadata_with_units.denom_units.len(), 1); + assert_eq!(metadata_with_units.denom_units[0].denom, "utest"); + assert_eq!(metadata_with_units.denom_units[0].aliases.len(), 1); + assert_eq!(metadata_with_units.denom_units[0].aliases[0], "microtest"); + + // Test with null aliases inside denom_units - should deserialize as empty vec + let json_with_null_aliases = json!({ + "description": "Test Token", + "denom_units": [ + { + "denom": "utest", + "exponent": 6, + "aliases": null + } + ], + "base": "utest", + "display": "TEST", + "name": "Test Token", + "symbol": "TEST", + "uri": "https://test.com", + "uri_hash": "hash" + }); + + let metadata_with_null_aliases: DenomMetadata = + serde_json::from_value(json_with_null_aliases).unwrap(); + assert_eq!(metadata_with_null_aliases.denom_units.len(), 1); + assert_eq!( + metadata_with_null_aliases.denom_units[0].aliases, + Vec::::default() + ); + assert!(metadata_with_null_aliases.denom_units[0].aliases.is_empty()); + } + + #[test] + fn query_denom_metadata_with_missing_fields_fails() { + // Missing denom_units should be treated as default value (empty vec) + let json_missing_denom_units = json!({ + "description": "Test Token", + "base": "utest", + "display": "TEST", + "name": "Test Token", + "symbol": "TEST", + "uri": "https://test.com", + "uri_hash": "hash" + }); + + let json_missing_denom_units_metadata: Result = + serde_json::from_value(json_missing_denom_units); + assert!(json_missing_denom_units_metadata.is_err()); + + // Missing aliases field should be treated as default (empty vec) + let json_missing_aliases = json!({ + "description": "Test Token", + "denom_units": [ + { + "denom": "utest", + "exponent": 6 + } + ], + "base": "utest", + "display": "TEST", + "name": "Test Token", + "symbol": "TEST", + "uri": "https://test.com", + "uri_hash": "hash" + }); + + let missing_aliases_metadata: Result = + serde_json::from_value(json_missing_aliases); + assert!(missing_aliases_metadata.is_err()); + } + + #[test] + fn query_denom_metadata_with_mixed_null_and_value_works() { + // Test with multiple denom units, some with null aliases and some with values + let mixed_json = json!({ + "description": "Mixed Token", + "denom_units": [ + { + "denom": "unit1", + "exponent": 0, + "aliases": null + }, + { + "denom": "unit2", + "exponent": 6, + "aliases": ["microunit", "u"] + }, + { + "denom": "unit3", + "exponent": 9, + "aliases": [] + } + ], + "base": "unit1", + "display": "MIXED", + "name": "Mixed Token", + "symbol": "MIX", + "uri": "https://mixed.token", + "uri_hash": "hash123" + }); + + let metadata: DenomMetadata = serde_json::from_value(mixed_json).unwrap(); + + // First denom unit has null aliases, should be empty vec + assert!(metadata.denom_units[0].aliases.is_empty()); + + // Second has two aliases + assert_eq!(metadata.denom_units[1].aliases.len(), 2); + assert_eq!(metadata.denom_units[1].aliases[0], "microunit"); + assert_eq!(metadata.denom_units[1].aliases[1], "u"); + + // Third has explicitly empty aliases + assert!(metadata.denom_units[2].aliases.is_empty()); + } +} From 20450e6c0df28cccbda94c9e6ca0c3044309c2b3 Mon Sep 17 00:00:00 2001 From: Bigto Chan Date: Tue, 8 Apr 2025 00:33:58 +0800 Subject: [PATCH 19/26] Delete redundant test Co-authored-by: Christoph Otter --- packages/std/src/metadata.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/std/src/metadata.rs b/packages/std/src/metadata.rs index 2496150d2d..50b9e66c9a 100644 --- a/packages/std/src/metadata.rs +++ b/packages/std/src/metadata.rs @@ -60,9 +60,8 @@ mod unit_tests { serde_json::from_value(json_with_null_denom_units).unwrap(); assert_eq!( metadata_null_denom_units.denom_units, - Vec::::default() + Vec::::new() ); - assert!(metadata_null_denom_units.denom_units.is_empty()); // Test normal case with provided denom_units let json_with_units = json!({ From 832eec542a3aee9a7e7e93474cc730fe361d5a81 Mon Sep 17 00:00:00 2001 From: Bigto Chan Date: Tue, 8 Apr 2025 00:34:14 +0800 Subject: [PATCH 20/26] Delete redundant test Co-authored-by: Christoph Otter --- packages/std/src/metadata.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/std/src/metadata.rs b/packages/std/src/metadata.rs index 50b9e66c9a..b19c6dc8ba 100644 --- a/packages/std/src/metadata.rs +++ b/packages/std/src/metadata.rs @@ -108,9 +108,8 @@ mod unit_tests { assert_eq!(metadata_with_null_aliases.denom_units.len(), 1); assert_eq!( metadata_with_null_aliases.denom_units[0].aliases, - Vec::::default() + Vec::::new() ); - assert!(metadata_with_null_aliases.denom_units[0].aliases.is_empty()); } #[test] From 62139012b2978c76158195d45bf691bc24058f21 Mon Sep 17 00:00:00 2001 From: Bigto Chan Date: Tue, 8 Apr 2025 00:34:23 +0800 Subject: [PATCH 21/26] Delete redundant test Co-authored-by: Christoph Otter --- packages/std/src/metadata.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/std/src/metadata.rs b/packages/std/src/metadata.rs index b19c6dc8ba..10c75f943a 100644 --- a/packages/std/src/metadata.rs +++ b/packages/std/src/metadata.rs @@ -174,9 +174,8 @@ mod integration_tests { serde_json::from_value(json_with_null_denom_units).unwrap(); assert_eq!( metadata_with_null_denom_units.denom_units, - Vec::::default() + Vec::::new() ); - assert!(metadata_with_null_denom_units.denom_units.is_empty()); // Test normal case with provided denom_units let json_with_units = json!({ From 2d77b1d38bdd85fbcc3a53705f7c77f8b08a4609 Mon Sep 17 00:00:00 2001 From: Bigto Chan Date: Tue, 8 Apr 2025 00:34:33 +0800 Subject: [PATCH 22/26] Delete redundant test Co-authored-by: Christoph Otter --- packages/std/src/metadata.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/std/src/metadata.rs b/packages/std/src/metadata.rs index 10c75f943a..fe4ab28c53 100644 --- a/packages/std/src/metadata.rs +++ b/packages/std/src/metadata.rs @@ -224,9 +224,8 @@ mod integration_tests { assert_eq!(metadata_with_null_aliases.denom_units.len(), 1); assert_eq!( metadata_with_null_aliases.denom_units[0].aliases, - Vec::::default() + Vec::::new() ); - assert!(metadata_with_null_aliases.denom_units[0].aliases.is_empty()); } #[test] From c190704a7e7ca3b6dc7dfc9a20d9bc5ae275a1ab Mon Sep 17 00:00:00 2001 From: BigtoC Date: Tue, 8 Apr 2025 00:38:09 +0800 Subject: [PATCH 23/26] fix(metadata): update test comments to reflect error handling for missing fields --- packages/std/src/metadata.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/std/src/metadata.rs b/packages/std/src/metadata.rs index 2496150d2d..0a812773f4 100644 --- a/packages/std/src/metadata.rs +++ b/packages/std/src/metadata.rs @@ -234,7 +234,7 @@ mod integration_tests { #[test] fn query_denom_metadata_with_missing_fields_fails() { - // Missing denom_units should be treated as default value (empty vec) + // Missing denom_units should throw an error let json_missing_denom_units = json!({ "description": "Test Token", "base": "utest", @@ -249,7 +249,7 @@ mod integration_tests { serde_json::from_value(json_missing_denom_units); assert!(json_missing_denom_units_metadata.is_err()); - // Missing aliases field should be treated as default (empty vec) + // Missing aliases field should throw an error let json_missing_aliases = json!({ "description": "Test Token", "denom_units": [ From ad6c72ffaaadc994c458ea311d37cc31afba01ea Mon Sep 17 00:00:00 2001 From: BigtoC Date: Wed, 9 Apr 2025 00:09:22 +0800 Subject: [PATCH 24/26] chore(test): Move all unit tests to test module --- packages/std/src/metadata.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/std/src/metadata.rs b/packages/std/src/metadata.rs index 5122b9cf16..d21936f6c8 100644 --- a/packages/std/src/metadata.rs +++ b/packages/std/src/metadata.rs @@ -38,8 +38,9 @@ where } #[cfg(test)] -mod unit_tests { +mod tests { use super::*; + use crate::{DenomMetadata, DenomUnit}; use serde_json::{json, Error}; #[test] @@ -149,12 +150,6 @@ mod unit_tests { serde_json::from_value(json_missing_alias); assert!(metadata_missing_alias.is_err()); } -} - -#[cfg(test)] -mod integration_tests { - use crate::{DenomMetadata, DenomUnit}; - use serde_json::{json, Error}; #[test] fn query_denom_metadata_with_null_denom_units_works() { From 0ed6e01b033f17c784dadbd85b06b49f68ed6756 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Wed, 9 Apr 2025 11:09:24 +0200 Subject: [PATCH 25/26] Add changelog entry --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d68d7cea1..d60c837000 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ and this project adheres to ## [Unreleased] +## Fixed + +- cosmwasm-std: Fix deserialization of `DenomMetadata`. ([#2417]) + +[#2417]: https://github.com/CosmWasm/cosmwasm/pull/2417 + ## [2.2.2] - 2025-03-05 ### Changed From 09d9d14459e39e8c3ac09b101137d11d399c545a Mon Sep 17 00:00:00 2001 From: Tomasz Kulik Date: Thu, 15 May 2025 12:51:45 +0200 Subject: [PATCH 26/26] chore: Deprecate `FeeEnabledChannel` and `FeeEnabledChannelResponse` (#2481) * chore: Deprecate FeeEnabledChannel and FeeEnabledChannelResponse * [autofix.ci] apply automated fixes * chore: Update and fix CHANGELOG --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- CHANGELOG.md | 11 +++++++---- contracts/reflect/schema/raw/query.json | 1 + contracts/reflect/schema/reflect.json | 1 + packages/std/src/lib.rs | 7 ++++--- packages/std/src/query/ibc.rs | 8 ++++++++ packages/std/src/testing/mock.rs | 1 + 6 files changed, 22 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fa7c8fde1..0b6c1e9a05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,8 +11,15 @@ and this project adheres to ## Fixed - cosmwasm-std: Fix deserialization of `DenomMetadata`. ([#2417]) +- cosmwasm-std: Deprecate `PayPacketFee`, `PayPacketFeeAsync`, `IbcFee`. IBC + fees have been removed from ibc-go in version 10. The mentioned struct and + enum fields are deprecated and will be removed in cosmwasm `3.0` ([#2431]) +- cosmwasm-std: Deprecate `FeeEnabledChannel` and `FeeEnabledChannelResponse` + ([#2481]) [#2417]: https://github.com/CosmWasm/cosmwasm/pull/2417 +[#2431]: https://github.com/CosmWasm/cosmwasm/pull/2431 +[#2481]: https://github.com/CosmWasm/cosmwasm/pull/2481 ## [2.2.2] - 2025-03-05 @@ -65,15 +72,11 @@ and this project adheres to - cosmwasm-derive: Add support for migrate method with `migrate_info: MigrateInfo` argument. ([#2212]) - cosmwasm-vm: Add `Cache::store_code` -- cosmwasm-vm: Deprecate `PayPacketFee`, `PayPacketFeeAsync`, `IbcFee`. IBC fees - have been removed from ibc-go in version 10. The mentioned struct and enum - fields are deprecated and will be removed in cosmwasm `3.0` ([#2431]) [#2118]: https://github.com/CosmWasm/cosmwasm/pull/2118 [#2196]: https://github.com/CosmWasm/cosmwasm/pull/2196 [#2220]: https://github.com/CosmWasm/cosmwasm/pull/2220 [#2212]: https://github.com/CosmWasm/cosmwasm/pull/2212 -[#2431]: https://github.com/CosmWasm/cosmwasm/pull/2431 ### Changed diff --git a/contracts/reflect/schema/raw/query.json b/contracts/reflect/schema/raw/query.json index 2419726e55..ff1d9d5a98 100644 --- a/contracts/reflect/schema/raw/query.json +++ b/contracts/reflect/schema/raw/query.json @@ -427,6 +427,7 @@ }, { "description": "Queries whether the given channel supports IBC fees. If port_id is omitted, it will default to the contract's own channel. (To save a PortId{} call)\n\nReturns a `FeeEnabledChannelResponse`.", + "deprecated": true, "type": "object", "required": [ "fee_enabled_channel" diff --git a/contracts/reflect/schema/reflect.json b/contracts/reflect/schema/reflect.json index ba37bac72a..382771e0c0 100644 --- a/contracts/reflect/schema/reflect.json +++ b/contracts/reflect/schema/reflect.json @@ -1690,6 +1690,7 @@ }, { "description": "Queries whether the given channel supports IBC fees. If port_id is omitted, it will default to the contract's own channel. (To save a PortId{} call)\n\nReturns a `FeeEnabledChannelResponse`.", + "deprecated": true, "type": "object", "required": [ "fee_enabled_channel" diff --git a/packages/std/src/lib.rs b/packages/std/src/lib.rs index 7120d82650..39fd88d9e4 100644 --- a/packages/std/src/lib.rs +++ b/packages/std/src/lib.rs @@ -88,15 +88,16 @@ pub use crate::metadata::{DenomMetadata, DenomUnit}; pub use crate::msgpack::{from_msgpack, to_msgpack_binary, to_msgpack_vec}; pub use crate::never::Never; pub use crate::pagination::PageRequest; +#[allow(deprecated)] +pub use crate::query::FeeEnabledChannelResponse; pub use crate::query::{ AllBalanceResponse, AllDelegationsResponse, AllDenomMetadataResponse, AllValidatorsResponse, BalanceResponse, BankQuery, BondedDenomResponse, ChannelResponse, CodeInfoResponse, ContractInfoResponse, CustomQuery, DecCoin, Delegation, DelegationResponse, DelegationRewardsResponse, DelegationTotalRewardsResponse, DelegatorReward, DelegatorValidatorsResponse, DelegatorWithdrawAddressResponse, DenomMetadataResponse, - DistributionQuery, FeeEnabledChannelResponse, FullDelegation, GrpcQuery, IbcQuery, - ListChannelsResponse, PortIdResponse, QueryRequest, StakingQuery, SupplyResponse, Validator, - ValidatorResponse, WasmQuery, + DistributionQuery, FullDelegation, GrpcQuery, IbcQuery, ListChannelsResponse, PortIdResponse, + QueryRequest, StakingQuery, SupplyResponse, Validator, ValidatorResponse, WasmQuery, }; #[cfg(all(feature = "stargate", feature = "cosmwasm_1_2"))] pub use crate::results::WeightedVoteOption; diff --git a/packages/std/src/query/ibc.rs b/packages/std/src/query/ibc.rs index 123156ea24..80f271c284 100644 --- a/packages/std/src/query/ibc.rs +++ b/packages/std/src/query/ibc.rs @@ -36,6 +36,10 @@ pub enum IbcQuery { /// /// Returns a `FeeEnabledChannelResponse`. #[cfg(feature = "cosmwasm_2_2")] + #[deprecated( + since = "2.2.3", + note = "IBC fees have been removed from ibc-go `v10`, which is used in wasmd `v0.55.0`." + )] FeeEnabledChannel { port_id: Option, channel_id: String, @@ -68,6 +72,10 @@ impl_response_constructor!(ChannelResponse, channel: Option); #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] #[non_exhaustive] +#[deprecated( + since = "2.2.3", + note = "IBC fees have been removed from ibc-go `v10`, which is used in wasmd `v0.55.0`." +)] pub struct FeeEnabledChannelResponse { pub fee_enabled: bool, } diff --git a/packages/std/src/testing/mock.rs b/packages/std/src/testing/mock.rs index 0d1c35565f..bfe606ef4a 100644 --- a/packages/std/src/testing/mock.rs +++ b/packages/std/src/testing/mock.rs @@ -958,6 +958,7 @@ impl IbcQuerier { to_json_binary(&res).into() } #[cfg(feature = "cosmwasm_2_2")] + #[allow(deprecated)] IbcQuery::FeeEnabledChannel { .. } => { use crate::query::FeeEnabledChannelResponse; // for now, we always return true