Skip to content

Commit

Permalink
Merge pull request #900 from CosmWasm/std1.5
Browse files Browse the repository at this point in the history
Update to `1.5` tooling
  • Loading branch information
webmaster128 committed Mar 11, 2024
2 parents f40c2c0 + ea24ff9 commit 2c9eb8f
Show file tree
Hide file tree
Showing 40 changed files with 542 additions and 616 deletions.
447 changes: 165 additions & 282 deletions Cargo.lock

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,35 @@ members = ["packages/*", "contracts/*"]
# Resolver has to be set explicitely in workspaces, see https://github.com/rust-lang/cargo/issues/9956
resolver = "2"

[workspace.package]
version = "1.1.2"

[workspace.dependencies]
cosmwasm-schema = "1.5"
cosmwasm-std = "1.5"
cw2 = "1.1"
cw-controllers = "1.1"
cw-multi-test = "1.0.0-rc.0"
cw-storage-plus = "1.2"
cw-utils = "1"
schemars = "0.8.15"
semver = "1"
serde = { version = "1.0.188", default-features = false, features = ["derive"] }
thiserror = "1.0.4"

cw1 = { path = "packages/cw1", version = "1.1.2" }
cw1-whitelist = { path = "contracts/cw1-whitelist", version = "1.1.2", features = [
"library",
] }
cw20 = { path = "packages/cw20", version = "1.1.2" }
cw20-base = { path = "contracts/cw20-base", version = "1.1.2", features = ["library"] }
cw3 = { path = "packages/cw3", version = "1.1.2" }
cw3-fixed-multisig = { path = "contracts/cw3-fixed-multisig", version = "1.1.2", features = [
"library",
] }
cw4 = { path = "packages/cw4", version = "1.1.2" }
cw4-group = { path = "contracts/cw4-group", version = "1.1.2" }

[profile.release.package.cw1-subkeys]
codegen-units = 1
incremental = false
Expand Down
26 changes: 12 additions & 14 deletions contracts/cw1-subkeys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,20 @@ library = []
test-utils = []

[dependencies]
cosmwasm-schema = { version = "1.4.0" }
cw-utils = "1.0.1"
cw1 = { path = "../../packages/cw1", version = "1.1.2" }
cw2 = "1.1.2"
cw1-whitelist = { path = "../cw1-whitelist", version = "1.1.2", features = [
"library",
] }
cosmwasm-std = { version = "1.4.0", features = ["staking"] }
cw-storage-plus = "1.1.0"
schemars = "0.8.15"
serde = { version = "1.0.188", default-features = false, features = ["derive"] }
thiserror = "1.0.49"
semver = "1"
cosmwasm-schema = { workspace = true }
cw-utils = { workspace = true }
cw1 = { workspace = true }
cw2 = { workspace = true }
cw1-whitelist = { workspace = true }
cosmwasm-std = { workspace = true, features = ["staking"] }
cw-storage-plus = { workspace = true }
schemars = { workspace = true }
serde = { workspace = true }
thiserror = { workspace = true }
semver = { workspace = true }

[dev-dependencies]
cw1-whitelist = { path = "../cw1-whitelist", version = "1.1.2", features = [
cw1-whitelist = { workspace = true, features = [
"library",
"test-utils",
] }
18 changes: 9 additions & 9 deletions contracts/cw1-subkeys/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use std::ops::{AddAssign, Sub};
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
ensure, ensure_ne, to_binary, BankMsg, Binary, Coin, CosmosMsg, Deps, DepsMut, DistributionMsg,
Empty, Env, MessageInfo, Order, Response, StakingMsg, StdResult,
ensure, ensure_ne, to_json_binary, BankMsg, Binary, Coin, CosmosMsg, Deps, DepsMut,
DistributionMsg, Empty, Env, MessageInfo, Order, Response, StakingMsg, StdResult,
};
use cw1::CanExecuteResponse;
use cw1_whitelist::{
Expand Down Expand Up @@ -304,17 +304,17 @@ where
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::AdminList {} => to_binary(&query_admin_list(deps)?),
QueryMsg::Allowance { spender } => to_binary(&query_allowance(deps, env, spender)?),
QueryMsg::Permissions { spender } => to_binary(&query_permissions(deps, spender)?),
QueryMsg::AdminList {} => to_json_binary(&query_admin_list(deps)?),
QueryMsg::Allowance { spender } => to_json_binary(&query_allowance(deps, env, spender)?),
QueryMsg::Permissions { spender } => to_json_binary(&query_permissions(deps, spender)?),
QueryMsg::CanExecute { sender, msg } => {
to_binary(&query_can_execute(deps, env, sender, msg)?)
to_json_binary(&query_can_execute(deps, env, sender, msg)?)
}
QueryMsg::AllAllowances { start_after, limit } => {
to_binary(&query_all_allowances(deps, env, start_after, limit)?)
to_json_binary(&query_all_allowances(deps, env, start_after, limit)?)
}
QueryMsg::AllPermissions { start_after, limit } => {
to_binary(&query_all_permissions(deps, start_after, limit)?)
to_json_binary(&query_all_permissions(deps, start_after, limit)?)
}
}
}
Expand Down Expand Up @@ -453,7 +453,7 @@ pub fn query_all_permissions(
}

// Migrate contract if version is lower than current version
#[entry_point]
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn migrate(deps: DepsMut, _env: Env, _msg: Empty) -> Result<Response, ContractError> {
let version: Version = CONTRACT_VERSION.parse()?;
let storage_version: Version = get_contract_version(deps.storage)?.version.parse()?;
Expand Down
20 changes: 10 additions & 10 deletions contracts/cw1-whitelist/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ library = []
test-utils = []

[dependencies]
cosmwasm-schema = { version = "1.4.0" }
cw-utils = "1.0.1"
cw1 = { path = "../../packages/cw1", version = "1.1.2" }
cw2 = "1.1.2"
cosmwasm-std = { version = "1.4.0", features = ["staking"] }
cw-storage-plus = "1.1.0"
schemars = "0.8.15"
serde = { version = "1.0.188", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.49" }
cosmwasm-schema = { workspace = true }
cw-utils = { workspace = true }
cw1 = { workspace = true }
cw2 = { workspace = true }
cosmwasm-std = { workspace = true, features = ["staking"] }
cw-storage-plus = { workspace = true }
schemars = { workspace = true }
serde = { workspace = true }
thiserror = { workspace = true }

[dev-dependencies]
anyhow = "1"
assert_matches = "1"
cw-multi-test = "0.16.5"
cw-multi-test = { workspace = true }
derivative = "2"
10 changes: 6 additions & 4 deletions contracts/cw1-whitelist/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::fmt;
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
to_binary, Addr, Api, Binary, CosmosMsg, Deps, DepsMut, Empty, Env, MessageInfo, Response,
to_json_binary, Addr, Api, Binary, CosmosMsg, Deps, DepsMut, Empty, Env, MessageInfo, Response,
StdResult,
};

Expand Down Expand Up @@ -118,8 +118,10 @@ fn can_execute(deps: Deps, sender: &str) -> StdResult<bool> {
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::AdminList {} => to_binary(&query_admin_list(deps)?),
QueryMsg::CanExecute { sender, msg } => to_binary(&query_can_execute(deps, sender, msg)?),
QueryMsg::AdminList {} => to_json_binary(&query_admin_list(deps)?),
QueryMsg::CanExecute { sender, msg } => {
to_json_binary(&query_can_execute(deps, sender, msg)?)
}
}
}

Expand Down Expand Up @@ -242,7 +244,7 @@ mod tests {
.into(),
WasmMsg::Execute {
contract_addr: "some contract".into(),
msg: to_binary(&freeze).unwrap(),
msg: to_json_binary(&freeze).unwrap(),
funds: vec![],
}
.into(),
Expand Down
8 changes: 5 additions & 3 deletions contracts/cw1-whitelist/src/integration_tests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::msg::{AdminListResponse, ExecuteMsg, InstantiateMsg, QueryMsg};
use anyhow::{anyhow, Result};
use assert_matches::assert_matches;
use cosmwasm_std::{to_binary, Addr, CosmosMsg, Empty, QueryRequest, StdError, WasmMsg, WasmQuery};
use cosmwasm_std::{
to_json_binary, Addr, CosmosMsg, Empty, QueryRequest, StdError, WasmMsg, WasmQuery,
};
use cw1::Cw1Contract;
use cw_multi_test::{App, AppResponse, Contract, ContractWrapper, Executor};
use derivative::Derivative;
Expand Down Expand Up @@ -68,7 +70,7 @@ impl Suite {
let execute: ExecuteMsg = ExecuteMsg::Execute {
msgs: vec![CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: target_contract.to_string(),
msg: to_binary(&msg)?,
msg: to_json_binary(&msg)?,
funds: vec![],
})],
};
Expand All @@ -88,7 +90,7 @@ impl Suite {
{
self.app.wrap().query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: target_contract.to_string(),
msg: to_binary(&msg).unwrap(),
msg: to_json_binary(&msg).unwrap(),
}))
}
}
Expand Down
25 changes: 12 additions & 13 deletions contracts/cw20-base/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cw20-base"
version = "1.1.2"
version.workspace = true
authors = ["Ethan Frey <ethanfrey@users.noreply.github.com>"]
edition = "2021"
description = "Basic implementation of a CosmWasm-20 compliant token"
Expand All @@ -13,21 +13,20 @@ documentation = "https://docs.cosmwasm.com"
crate-type = ["cdylib", "rlib"]

[features]
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all instantiate/execute/query exports
library = []

[dependencies]
cosmwasm-schema = { version = "1.4.0" }
cw2 = "1.1.2"
cw20 = { path = "../../packages/cw20", version = "1.1.2" }
cw-storage-plus = "1.1.0"
cosmwasm-std = { version = "1.4.0" }
schemars = "0.8.15"
semver = "1"
serde = { version = "1.0.188", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.49" }
cosmwasm-schema = { workspace = true }
cw2 = { workspace = true }
cw20 = { workspace = true }
cw-storage-plus = { workspace = true }
cosmwasm-std = { workspace = true }
schemars = { workspace = true }
semver = { workspace = true }
serde = { workspace = true }
thiserror = { workspace = true }

[dev-dependencies]
cw-multi-test = "0.16.5"
cw-utils = "1.0.1"
cw-multi-test = { workspace = true }
cw-utils = { workspace = true }
2 changes: 1 addition & 1 deletion contracts/cw20-base/src/allowances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ mod tests {
amount: transfer,
msg: send_msg.clone(),
}
.into_binary()
.into_json_binary()
.unwrap();
assert_eq!(
res.messages[0],
Expand Down
36 changes: 18 additions & 18 deletions contracts/cw20-base/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use cosmwasm_std::entry_point;
use cosmwasm_std::Order::Ascending;
use cosmwasm_std::{
to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult, Uint128,
to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult, Uint128,
};

use cw2::{ensure_from_older_version, set_contract_version};
Expand Down Expand Up @@ -506,32 +506,32 @@ pub fn execute_upload_logo(
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::Balance { address } => to_binary(&query_balance(deps, address)?),
QueryMsg::TokenInfo {} => to_binary(&query_token_info(deps)?),
QueryMsg::Minter {} => to_binary(&query_minter(deps)?),
QueryMsg::Balance { address } => to_json_binary(&query_balance(deps, address)?),
QueryMsg::TokenInfo {} => to_json_binary(&query_token_info(deps)?),
QueryMsg::Minter {} => to_json_binary(&query_minter(deps)?),
QueryMsg::Allowance { owner, spender } => {
to_binary(&query_allowance(deps, owner, spender)?)
to_json_binary(&query_allowance(deps, owner, spender)?)
}
QueryMsg::AllAllowances {
owner,
start_after,
limit,
} => to_binary(&query_owner_allowances(deps, owner, start_after, limit)?),
} => to_json_binary(&query_owner_allowances(deps, owner, start_after, limit)?),
QueryMsg::AllSpenderAllowances {
spender,
start_after,
limit,
} => to_binary(&query_spender_allowances(
} => to_json_binary(&query_spender_allowances(
deps,
spender,
start_after,
limit,
)?),
QueryMsg::AllAccounts { start_after, limit } => {
to_binary(&query_all_accounts(deps, start_after, limit)?)
to_json_binary(&query_all_accounts(deps, start_after, limit)?)
}
QueryMsg::MarketingInfo {} => to_binary(&query_marketing_info(deps)?),
QueryMsg::DownloadLogo {} => to_binary(&query_download_logo(deps)?),
QueryMsg::MarketingInfo {} => to_json_binary(&query_marketing_info(deps)?),
QueryMsg::DownloadLogo {} => to_json_binary(&query_download_logo(deps)?),
}
}

Expand Down Expand Up @@ -607,7 +607,7 @@ mod tests {
use cosmwasm_std::testing::{
mock_dependencies, mock_dependencies_with_balance, mock_env, mock_info,
};
use cosmwasm_std::{coins, from_binary, Addr, CosmosMsg, StdError, SubMsg, WasmMsg};
use cosmwasm_std::{coins, from_json, Addr, CosmosMsg, StdError, SubMsg, WasmMsg};

use super::*;
use crate::msg::InstantiateMarketingInfo;
Expand Down Expand Up @@ -957,7 +957,7 @@ mod tests {
assert!(res.is_ok());
let query_minter_msg = QueryMsg::Minter {};
let res = query(deps.as_ref(), env, query_minter_msg);
let mint: MinterResponse = from_binary(&res.unwrap()).unwrap();
let mint: MinterResponse = from_json(res.unwrap()).unwrap();

// Minter cannot update cap.
assert!(mint.cap == cap);
Expand Down Expand Up @@ -1007,7 +1007,7 @@ mod tests {
assert!(res.is_ok());
let query_minter_msg = QueryMsg::Minter {};
let res = query(deps.as_ref(), env, query_minter_msg);
let mint: Option<MinterResponse> = from_binary(&res.unwrap()).unwrap();
let mint: Option<MinterResponse> = from_json(res.unwrap()).unwrap();

// Check that mint information was removed.
assert_eq!(mint, None);
Expand Down Expand Up @@ -1124,7 +1124,7 @@ mod tests {
QueryMsg::Balance { address: addr1 },
)
.unwrap();
let loaded: BalanceResponse = from_binary(&data).unwrap();
let loaded: BalanceResponse = from_json(data).unwrap();
assert_eq!(loaded.balance, amount1);

// check balance query (empty)
Expand All @@ -1136,7 +1136,7 @@ mod tests {
},
)
.unwrap();
let loaded: BalanceResponse = from_binary(&data).unwrap();
let loaded: BalanceResponse = from_json(data).unwrap();
assert_eq!(loaded.balance, Uint128::zero());
}

Expand Down Expand Up @@ -1298,7 +1298,7 @@ mod tests {
amount: transfer,
msg: send_msg,
}
.into_binary()
.into_json_binary()
.unwrap();
// and this is how it must be wrapped for the vm to process it
assert_eq!(
Expand Down Expand Up @@ -1383,7 +1383,7 @@ mod tests {
let expires = Expiration::AtHeight(123_456);
let msg = CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: cw20_addr.to_string(),
msg: to_binary(&ExecuteMsg::IncreaseAllowance {
msg: to_json_binary(&ExecuteMsg::IncreaseAllowance {
spender: "spender".into(),
amount: allow1,
expires: Some(expires),
Expand All @@ -1399,7 +1399,7 @@ mod tests {
CosmosMsg::Wasm(WasmMsg::Migrate {
contract_addr: cw20_addr.to_string(),
new_code_id: cw20_id,
msg: to_binary(&MigrateMsg {}).unwrap(),
msg: to_json_binary(&MigrateMsg {}).unwrap(),
}),
)
.unwrap();
Expand Down

0 comments on commit 2c9eb8f

Please sign in to comment.