Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Roll back feature cosmwasm_2_0 of cosmwasm std #488

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions framework/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion framework/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
1 change: 1 addition & 0 deletions framework/contracts/account/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ xion = [
"ripemd",
"cosmos-sdk-proto",
"prost",
"cosmwasm-std/cosmwasm_2_0",
]

[package.metadata.optimizer]
Expand Down
12 changes: 7 additions & 5 deletions framework/contracts/native/ibc-client/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -474,7 +475,8 @@ fn map_query(ibc_host: &str, query: QueryRequest<ModuleQuery>) -> QueryRequest<E
}
QueryRequest::Bank(query) => 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.
Expand Down
49 changes: 24 additions & 25 deletions framework/contracts/native/ibc-client/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -714,32 +714,31 @@ mod tests {
let res = execute_as(&mut deps, account.addr(), msg)?;

use prost::Message;
#[allow(deprecated)]
let transfer_msgs: Vec<CosmosMsg> = 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();

Expand Down
11 changes: 11 additions & 0 deletions framework/packages/abstract-sdk/src/apis.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Remove deprecated if we move to cosmwasm_2_0 feature

pub mod adapter;
pub mod app;
pub mod bank;
Expand All @@ -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 }
}
36 changes: 14 additions & 22 deletions framework/packages/abstract-sdk/src/apis/authz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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
Expand All @@ -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**.
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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))
}
}

Expand All @@ -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(),
Expand All @@ -506,7 +498,7 @@ mod tests {
}
.encode_to_vec(),
),
});
);

assert_eq!(generic_authorization_msg, expected_msg);
}
Expand All @@ -523,17 +515,17 @@ 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(),
msg_type_url: "/cosmos.gov.v1beta1.MsgVote".to_string(),
}
.encode_to_vec(),
),
});
);

assert_eq!(generic_authorization_msg, expected_msg);
}
Expand Down
34 changes: 17 additions & 17 deletions framework/packages/abstract-sdk/src/apis/distribution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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())
}
Expand All @@ -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())
}
Expand All @@ -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())
}
Expand All @@ -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())
}
Expand Down
Loading
Loading