From bcdb4db4e85730074b084bfb3d178ca62d65a078 Mon Sep 17 00:00:00 2001 From: Mykhailo Donchenko <91957742+Buckram123@users.noreply.github.com> Date: Tue, 8 Oct 2024 15:52:21 +0300 Subject: [PATCH] Roll back feature cosmwasm_2_0 of cosmwasm std (#488) * rollback 2_0 * roll-back cosmwasm_2_0 * remove lcov --------- Co-authored-by: CyberHoward <88450409+CyberHoward@users.noreply.github.com> --- framework/Cargo.lock | 8 +-- framework/Cargo.toml | 2 +- framework/contracts/account/Cargo.toml | 1 + .../native/ibc-client/src/commands.rs | 12 +++-- .../native/ibc-client/src/contract.rs | 49 +++++++++---------- framework/packages/abstract-sdk/src/apis.rs | 11 +++++ .../packages/abstract-sdk/src/apis/authz.rs | 36 ++++++-------- .../abstract-sdk/src/apis/distribution.rs | 34 ++++++------- .../abstract-sdk/src/apis/feegrant.rs | 34 ++++++------- 9 files changed, 96 insertions(+), 91 deletions(-) diff --git a/framework/Cargo.lock b/framework/Cargo.lock index 5792d490fb..f912c5ee3b 100644 --- a/framework/Cargo.lock +++ b/framework/Cargo.lock @@ -2327,9 +2327,9 @@ dependencies = [ [[package]] name = "cw-orch-networks" -version = "0.24.2" +version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21dc63b942a44796fd0b5e4aff3dd6f65b8b1ce456b478ed22512385f24df958" +checksum = "032bee6b3f3231de3be5feef6450572307b953220e1acc18cc2e1a0afed196fe" dependencies = [ "cw-orch-core", "serde", @@ -5265,9 +5265,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" dependencies = [ "unicode-ident", ] diff --git a/framework/Cargo.toml b/framework/Cargo.toml index 2f46452e13..e4bff24514 100644 --- a/framework/Cargo.toml +++ b/framework/Cargo.toml @@ -31,7 +31,7 @@ license = "GPL-3.0-or-later" keywords = ["cosmos", "cosmwasm", "framework"] [workspace.dependencies] -cosmwasm-std = { version = "2.0.0", features = ["cosmwasm_2_0"] } +cosmwasm-std = { version = "2.0.0", features = ["cosmwasm_1_2"] } cosmwasm-schema = { version = "2.0" } cw-controllers = { version = "2.0" } cw-utils = { version = "2.0" } diff --git a/framework/contracts/account/Cargo.toml b/framework/contracts/account/Cargo.toml index b214bccc2b..42981f015a 100644 --- a/framework/contracts/account/Cargo.toml +++ b/framework/contracts/account/Cargo.toml @@ -34,6 +34,7 @@ xion = [ "ripemd", "cosmos-sdk-proto", "prost", + "cosmwasm-std/cosmwasm_2_0", ] [package.metadata.optimizer] diff --git a/framework/contracts/native/ibc-client/src/commands.rs b/framework/contracts/native/ibc-client/src/commands.rs index f9bf47098c..27946446d2 100644 --- a/framework/contracts/native/ibc-client/src/commands.rs +++ b/framework/contracts/native/ibc-client/src/commands.rs @@ -21,8 +21,8 @@ use abstract_std::{ IBC_CLIENT, ICS20, }; use cosmwasm_std::{ - ensure, to_json_binary, wasm_execute, AnyMsg, Binary, Coin, CosmosMsg, Deps, DepsMut, Empty, - Env, IbcMsg, MessageInfo, QueryRequest, WasmQuery, + ensure, to_json_binary, wasm_execute, Binary, Coin, CosmosMsg, Deps, DepsMut, Empty, Env, + IbcMsg, MessageInfo, QueryRequest, WasmQuery, }; use cw_storage_plus::Item; use prost::Name; @@ -446,10 +446,11 @@ fn _ics_20_send_msg( let value = value.encode_to_vec(); let value = Binary::from(value); - CosmosMsg::Any(AnyMsg { + #[allow(deprecated)] + CosmosMsg::Stargate { type_url: MsgTransfer::type_url(), value, - }) + } } None => IbcMsg::Transfer { channel_id: ics20_channel_id, @@ -474,7 +475,8 @@ fn map_query(ibc_host: &str, query: QueryRequest) -> QueryRequest QueryRequest::Bank(query), QueryRequest::Staking(query) => QueryRequest::Staking(query), - QueryRequest::Grpc(grpc) => QueryRequest::Grpc(grpc), + #[allow(deprecated)] + QueryRequest::Stargate { path, data } => QueryRequest::Stargate { path, data }, QueryRequest::Ibc(query) => QueryRequest::Ibc(query), QueryRequest::Wasm(query) => QueryRequest::Wasm(query), // Distribution flag not enabled on polytone, so should not be accepted. diff --git a/framework/contracts/native/ibc-client/src/contract.rs b/framework/contracts/native/ibc-client/src/contract.rs index f4c97c84b9..d2b8b1cde2 100644 --- a/framework/contracts/native/ibc-client/src/contract.rs +++ b/framework/contracts/native/ibc-client/src/contract.rs @@ -606,7 +606,7 @@ mod tests { objects::{registry::RegistryError, ChannelEntry, TruncatedChainId}, ICS20, }; - use cosmwasm_std::{coins, AnyMsg, Binary, CosmosMsg, IbcMsg}; + use cosmwasm_std::{coins, Binary, CosmosMsg, IbcMsg}; use prost::Name; use std::str::FromStr; @@ -714,32 +714,31 @@ mod tests { let res = execute_as(&mut deps, account.addr(), msg)?; use prost::Message; + #[allow(deprecated)] let transfer_msgs: Vec = funds .into_iter() - .map(|c| { - CosmosMsg::Any(AnyMsg { - type_url: ibc_proto::ibc::apps::transfer::v1::MsgTransfer::type_url(), - value: Binary::from( - ibc_proto::ibc::apps::transfer::v1::MsgTransfer { - source_port: "transfer".to_owned(), - source_channel: channel_id.clone(), - token: Some(ibc_proto::cosmos::base::v1beta1::Coin { - denom: c.denom, - amount: c.amount.to_string(), - }), - sender: mock_env_validated(deps.api).contract.address.to_string(), - receiver: remote_addr.clone(), - timeout_height: None, - timeout_timestamp: mock_env_validated(deps.api) - .block - .time - .plus_seconds(PACKET_LIFETIME) - .nanos(), - memo: memo.clone().unwrap(), - } - .encode_to_vec(), - ), - }) + .map(|c| CosmosMsg::Stargate { + type_url: ibc_proto::ibc::apps::transfer::v1::MsgTransfer::type_url(), + value: Binary::from( + ibc_proto::ibc::apps::transfer::v1::MsgTransfer { + source_port: "transfer".to_owned(), + source_channel: channel_id.clone(), + token: Some(ibc_proto::cosmos::base::v1beta1::Coin { + denom: c.denom, + amount: c.amount.to_string(), + }), + sender: mock_env_validated(deps.api).contract.address.to_string(), + receiver: remote_addr.clone(), + timeout_height: None, + timeout_timestamp: mock_env_validated(deps.api) + .block + .time + .plus_seconds(PACKET_LIFETIME) + .nanos(), + memo: memo.clone().unwrap(), + } + .encode_to_vec(), + ), }) .collect(); diff --git a/framework/packages/abstract-sdk/src/apis.rs b/framework/packages/abstract-sdk/src/apis.rs index d358c2eb25..edfb35dd8a 100644 --- a/framework/packages/abstract-sdk/src/apis.rs +++ b/framework/packages/abstract-sdk/src/apis.rs @@ -1,3 +1,5 @@ +// Remove deprecated if we move to cosmwasm_2_0 feature + pub mod adapter; pub mod app; pub mod bank; @@ -20,3 +22,12 @@ pub mod distribution; pub mod feegrant; #[cfg(feature = "stargate")] pub mod stargate; + +#[cfg(feature = "stargate")] +pub(crate) fn stargate_msg( + type_url: String, + value: cosmwasm_std::Binary, +) -> cosmwasm_std::CosmosMsg { + #[allow(deprecated)] + cosmwasm_std::CosmosMsg::Stargate { type_url, value } +} diff --git a/framework/packages/abstract-sdk/src/apis/authz.rs b/framework/packages/abstract-sdk/src/apis/authz.rs index 9b8fc34100..48c6cd3921 100644 --- a/framework/packages/abstract-sdk/src/apis/authz.rs +++ b/framework/packages/abstract-sdk/src/apis/authz.rs @@ -17,7 +17,7 @@ use cosmos_sdk_proto::{ }, traits::{Message, Name}, }; -use cosmwasm_std::{Addr, AnyMsg, Binary, Coin, CosmosMsg, Timestamp, WasmMsg}; +use cosmwasm_std::{Addr, Binary, Coin, CosmosMsg, Timestamp, WasmMsg}; use ibc_proto::ibc::{applications::transfer::v1::MsgTransfer, core::client::v1::Height}; use super::stargate::{ @@ -104,10 +104,7 @@ impl AuthZ { } .encode_to_vec(); - CosmosMsg::Any(AnyMsg { - type_url: authz::v1beta1::MsgRevoke::type_url(), - value: Binary::new(msg), - }) + super::stargate_msg(authz::v1beta1::MsgRevoke::type_url(), Binary::new(msg)) } /// Generate cosmwasm message for the AuthZAuthorization type @@ -124,10 +121,7 @@ impl AuthZ { } .encode_to_vec(); - CosmosMsg::Any(AnyMsg { - type_url: authz::v1beta1::MsgGrant::type_url(), - value: Binary::new(msg), - }) + super::stargate_msg(authz::v1beta1::MsgGrant::type_url(), Binary::new(msg)) } /// Grants generic authorization to a **grantee**. @@ -288,7 +282,8 @@ impl AuthZ { ), _ => todo!(), }, - CosmosMsg::Any(AnyMsg { type_url, value }) => (type_url.clone(), value.into()), + #[allow(deprecated)] + CosmosMsg::Stargate { type_url, value } => (type_url.clone(), value.into()), CosmosMsg::Bank(bank_msg) => match bank_msg { cosmwasm_std::BankMsg::Send { to_address, amount } => ( MsgSend::type_url(), @@ -458,10 +453,7 @@ impl AuthZ { } .encode_to_vec(); - CosmosMsg::Any(AnyMsg { - type_url: authz::v1beta1::MsgExec::type_url(), - value: Binary::new(msg), - }) + super::stargate_msg(authz::v1beta1::MsgExec::type_url(), Binary::new(msg)) } } @@ -487,9 +479,9 @@ mod tests { expiration, ); - let expected_msg = CosmosMsg::Any(AnyMsg { - type_url: "/cosmos.authz.v1beta1.MsgGrant".to_string(), - value: Binary::new( + let expected_msg = crate::apis::stargate_msg( + "/cosmos.authz.v1beta1.MsgGrant".to_string(), + Binary::new( authz::v1beta1::MsgGrant { granter: granter.into_string(), grantee: grantee.into_string(), @@ -506,7 +498,7 @@ mod tests { } .encode_to_vec(), ), - }); + ); assert_eq!(generic_authorization_msg, expected_msg); } @@ -523,9 +515,9 @@ mod tests { let generic_authorization_msg = auth_z.revoke(&grantee, "/cosmos.gov.v1beta1.MsgVote".to_string()); - let expected_msg = CosmosMsg::Any(AnyMsg { - type_url: "/cosmos.authz.v1beta1.MsgRevoke".to_string(), - value: Binary::new( + let expected_msg = crate::apis::stargate_msg( + "/cosmos.authz.v1beta1.MsgRevoke".to_string(), + Binary::new( authz::v1beta1::MsgRevoke { granter: granter.into_string(), grantee: grantee.into_string(), @@ -533,7 +525,7 @@ mod tests { } .encode_to_vec(), ), - }); + ); assert_eq!(generic_authorization_msg, expected_msg); } diff --git a/framework/packages/abstract-sdk/src/apis/distribution.rs b/framework/packages/abstract-sdk/src/apis/distribution.rs index d537e98669..c1917ed2de 100644 --- a/framework/packages/abstract-sdk/src/apis/distribution.rs +++ b/framework/packages/abstract-sdk/src/apis/distribution.rs @@ -7,7 +7,7 @@ use cosmos_sdk_proto::{ prost::Name, traits::Message, }; -use cosmwasm_std::{to_json_binary, Addr, AnyMsg, Coin, CosmosMsg}; +use cosmwasm_std::{to_json_binary, Addr, Coin}; use crate::{features::AccountExecutor, AbstractSdkResult, AccountAction}; @@ -69,10 +69,10 @@ impl Distribution { } .encode_to_vec(); - let msg = CosmosMsg::Any(AnyMsg { - type_url: distribution::v1beta1::MsgSetWithdrawAddress::type_url(), - value: to_json_binary(&msg)?, - }); + let msg = super::stargate_msg( + distribution::v1beta1::MsgSetWithdrawAddress::type_url(), + to_json_binary(&msg)?, + ); Ok(msg.into()) } @@ -89,10 +89,10 @@ impl Distribution { } .encode_to_vec(); - let msg = CosmosMsg::Any(AnyMsg { - type_url: distribution::v1beta1::MsgWithdrawDelegatorReward::type_url(), - value: to_json_binary(&msg)?, - }); + let msg = super::stargate_msg( + distribution::v1beta1::MsgWithdrawDelegatorReward::type_url(), + to_json_binary(&msg)?, + ); Ok(msg.into()) } @@ -107,10 +107,10 @@ impl Distribution { } .encode_to_vec(); - let msg = CosmosMsg::Any(AnyMsg { - type_url: distribution::v1beta1::MsgWithdrawValidatorCommission::type_url(), - value: to_json_binary(&msg)?, - }); + let msg = super::stargate_msg( + distribution::v1beta1::MsgWithdrawValidatorCommission::type_url(), + to_json_binary(&msg)?, + ); Ok(msg.into()) } @@ -133,10 +133,10 @@ impl Distribution { } .encode_to_vec(); - let msg = CosmosMsg::Any(AnyMsg { - type_url: distribution::v1beta1::MsgFundCommunityPool::type_url(), - value: to_json_binary(&msg)?, - }); + let msg = super::stargate_msg( + distribution::v1beta1::MsgFundCommunityPool::type_url(), + to_json_binary(&msg)?, + ); Ok(msg.into()) } diff --git a/framework/packages/abstract-sdk/src/apis/feegrant.rs b/framework/packages/abstract-sdk/src/apis/feegrant.rs index ebdf1e4d3d..43aa814e5a 100644 --- a/framework/packages/abstract-sdk/src/apis/feegrant.rs +++ b/framework/packages/abstract-sdk/src/apis/feegrant.rs @@ -8,7 +8,7 @@ use cosmos_sdk_proto::{ cosmos::feegrant, traits::{Message, Name}, }; -use cosmwasm_std::{Addr, AnyMsg, Binary, Coin, CosmosMsg, Timestamp}; +use cosmwasm_std::{Addr, Binary, Coin, CosmosMsg, Timestamp}; use super::stargate::feegrant::{BasicOrPeriodicAllowance, MsgAllowance}; use crate::{ @@ -88,10 +88,10 @@ impl FeeGranter { } .encode_to_vec(); - CosmosMsg::Any(AnyMsg { - type_url: feegrant::v1beta1::MsgRevokeAllowance::type_url(), - value: Binary::new(msg), - }) + super::stargate_msg( + feegrant::v1beta1::MsgRevokeAllowance::type_url(), + Binary::new(msg), + ) } /// Grants an allowance to a **grantee**. @@ -108,10 +108,10 @@ impl FeeGranter { } .encode_to_vec(); - CosmosMsg::Any(AnyMsg { - type_url: feegrant::v1beta1::MsgGrantAllowance::type_url(), - value: Binary::new(msg), - }) + super::stargate_msg( + feegrant::v1beta1::MsgGrantAllowance::type_url(), + Binary::new(msg), + ) } /// Grants a basic allowance. @@ -190,9 +190,9 @@ mod test { grantee: Addr, allowance: impl StargateMessage, ) -> CosmosMsg { - CosmosMsg::Any(AnyMsg { - type_url: feegrant::v1beta1::MsgGrantAllowance::type_url(), - value: Binary::new( + crate::apis::stargate_msg( + feegrant::v1beta1::MsgGrantAllowance::type_url(), + Binary::new( feegrant::v1beta1::MsgGrantAllowance { granter: granter.to_string(), grantee: grantee.to_string(), @@ -200,7 +200,7 @@ mod test { } .encode_to_vec(), ), - }) + ) } mod basic_allowance { @@ -294,16 +294,16 @@ mod test { let revoke_msg = fee_granter.revoke_allowance(&grantee); - let expected_msg = CosmosMsg::Any(AnyMsg { - type_url: feegrant::v1beta1::MsgRevokeAllowance::type_url(), - value: Binary::new( + let expected_msg = crate::apis::stargate_msg( + feegrant::v1beta1::MsgRevokeAllowance::type_url(), + Binary::new( feegrant::v1beta1::MsgRevokeAllowance { granter: granter.to_string(), grantee: grantee.to_string(), } .encode_to_vec(), ), - }); + ); assert_eq!(revoke_msg, expected_msg); } }