Skip to content

Commit

Permalink
Upgrade the cosmwasm version to 1.0.x (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
duguorong009 authored May 23, 2022
1 parent f35cbf4 commit cfc3b0f
Show file tree
Hide file tree
Showing 28 changed files with 305 additions and 149 deletions.
295 changes: 220 additions & 75 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions contracts/anchor-handler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ backtraces = ["cosmwasm-std/backtraces"]
library = []

[dependencies]
cosmwasm-std = { version = "0.16.2" }
cosmwasm-storage = { version = "0.16.0" }
cw-storage-plus = "0.8.0"
cw2 = "0.8.1"
cosmwasm-std = { version = "1.0.0" }
cosmwasm-storage = { version = "1.0.0" }
cw-storage-plus = "0.13.2"
cw2 = "0.13.2"
schemars = "0.8.3"
serde = { version = "1.0.127", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.26" }
Expand All @@ -36,4 +36,4 @@ protocol-cosmwasm = { version = "0.1.0", path = "../../packages/protocol_cosmwas


[dev-dependencies]
cosmwasm-schema = { version = "0.16.0" }
cosmwasm-schema = { version = "1.0.0" }
4 changes: 2 additions & 2 deletions contracts/anchor-handler/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const ANCHOR_CONTRACT: &str = "terra1fex9f78reuwhfsnc8sun6mz8rl9zwqh03fhwf3";
const NEW_HANDLER: &str = "terra1kejftqzx05y9rv00lw5m76csfmx7lf9se02dz4";

fn instantiate_anchor_handler() -> OwnedDeps<MockStorage, MockApi, MockQuerier> {
let mut deps = mock_dependencies(&[]);
let mut deps = mock_dependencies();

// Instantiate the "anchor-handler".
let msg = InstantiateMsg {
Expand All @@ -41,7 +41,7 @@ fn proposal_to_exec_data(resource_id: [u8; 32], proposal: LinkableAnchorExecMsg)

#[test]
fn proper_initialization() {
let mut deps = mock_dependencies(&[]);
let mut deps = mock_dependencies();

let msg = InstantiateMsg {
bridge_addr: BRIDGE_ADDR.to_string(),
Expand Down
14 changes: 7 additions & 7 deletions contracts/anchor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ optimize = """docker run --rm -v "$(pwd)":/code \
"""

[dependencies]
cosmwasm-std = { version = "0.16.2" }
cosmwasm-storage = { version = "0.16.0" }
cw-storage-plus = "0.8.0"
cw2 = "0.8.1"
cw20 = "0.8.1"
cosmwasm-std = { version = "1.0.0" }
cosmwasm-storage = { version = "1.0.0" }
cw-storage-plus = "0.13.2"
cw2 = "0.13.2"
cw20 = "0.13.2"
schemars = "0.8.3"
serde = { version = "1.0.127", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.26" }
Expand All @@ -57,8 +57,8 @@ protocol-cosmwasm = { version = "0.1.0", path = "../../packages/protocol_cosmwas


[dev-dependencies]
cosmwasm-schema = { version = "0.16.0" }
cosmwasm-vm = { version = "0.16.5" }
cosmwasm-schema = { version = "1.0.0" }
cosmwasm-vm = { version = "1.0.0" }

[target.'cfg(not(target_arch="wasm32"))'.dependencies]
wasm-utils = { version = "0.1.3" }
3 changes: 3 additions & 0 deletions contracts/anchor/src/mock_querier.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Contains mock functionality to test multi-contract scenarios

use std::marker::PhantomData;

use cosmwasm_std::testing::{MockApi, MockQuerier, MockStorage, MOCK_CONTRACT_ADDR};
use cosmwasm_std::{
from_binary, from_slice, to_binary, Coin, ContractResult, Empty, OwnedDeps, Querier,
Expand Down Expand Up @@ -31,6 +33,7 @@ pub fn mock_dependencies(
storage: MockStorage::default(),
api: MockApi::default(),
querier: custom_querier,
custom_query_type: PhantomData,
}
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/anchor/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn create_anchor() -> OwnedDeps<MockStorage, MockApi, crate::mock_querier::WasmM

#[test]
fn test_anchor_proper_initialization() {
let mut deps = mock_dependencies(&[]);
let mut deps = mock_dependencies();
let env = mock_env();
let info = mock_info("anyone", &[]);
let instantiate_msg = InstantiateMsg {
Expand Down
Binary file modified contracts/anchor/tests/cosmwasm_anchor.wasm
Binary file not shown.
5 changes: 3 additions & 2 deletions contracts/anchor/tests/integration.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! This integration test tries to run and call the generated wasm.
use cosmwasm_std::{attr, to_binary, Response, Uint128};
use cosmwasm_vm::testing::mock_instance;
use cosmwasm_vm::testing::{
execute, instantiate, mock_env, mock_info, mock_instance_with_gas_limit, query,
};
Expand Down Expand Up @@ -35,7 +36,7 @@ const HANDLER: &str = "terra1fex9f78reuwhfsnc8sun6mz8rl9zwqh03fhwf3";
#[test]
fn integration_test_instantiate_anchor() {
// "Gas_limit" should be set high manually, since the low value can cause "GasDepletion" error.
let mut deps = mock_instance_with_gas_limit(WASM, 100_000_000);
let mut deps = mock_instance_with_gas_limit(WASM, u64::MAX);

let msg = InstantiateMsg {
max_edges: MAX_EDGES,
Expand All @@ -57,7 +58,7 @@ fn integration_test_instantiate_anchor() {

#[test]
fn test_deposit_cw20() {
let mut deps = mock_instance_with_gas_limit(WASM, 200_000_000);
let mut deps = mock_instance_with_gas_limit(WASM, u64::MAX);

// Initialize the contract
let env = mock_env();
Expand Down
14 changes: 7 additions & 7 deletions contracts/mixer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ optimize = """docker run --rm -v "$(pwd)":/code \
"""

[dependencies]
cosmwasm-std = { version = "0.16.2" }
cosmwasm-storage = { version = "0.16.0" }
cw-storage-plus = "0.8.0"
cw2 = "0.8.1"
cw20 = "0.8.1"
cosmwasm-std = { version = "1.0.0" }
cosmwasm-storage = { version = "1.0.0" }
cw-storage-plus = "0.13.2"
cw2 = "0.13.2"
cw20 = "0.13.2"
schemars = "0.8.3"
serde = { version = "1.0.127", default-features = false, features = ["derive"] }

Expand All @@ -56,8 +56,8 @@ protocol-cosmwasm = { version = "0.1.0", path = "../../packages/protocol_cosmwas


[dev-dependencies]
cosmwasm-schema = { version = "0.16.0" }
cosmwasm-vm = { version = "0.16.5" }
cosmwasm-schema = { version ="1.0.0" }
cosmwasm-vm = { version = "1.0.0" }

[target.'cfg(not(target_arch="wasm32"))'.dependencies]
wasm-utils = { version = "0.1.3" }
4 changes: 2 additions & 2 deletions contracts/mixer/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub enum MixerType {
}

fn create_mixer(ty: MixerType) -> OwnedDeps<MockStorage, MockApi, MockQuerier> {
let mut deps = mock_dependencies(&[]);
let mut deps = mock_dependencies();

// Initialize the contract
let env = mock_env();
Expand Down Expand Up @@ -110,7 +110,7 @@ fn prepare_zk_circuit(

#[test]
fn test_mixer_proper_initialization() {
let mut deps = mock_dependencies(&[]);
let mut deps = mock_dependencies();

let env = mock_env();
let info = mock_info("anyone", &[]);
Expand Down
Binary file modified contracts/mixer/tests/cosmwasm_mixer.wasm
Binary file not shown.
6 changes: 3 additions & 3 deletions contracts/mixer/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const NATIVE_TOKEN_DENOM: &str = "uusd";
#[test]
fn integration_test_instantiate_mixer() {
// "Gas_limit" should be set high manually, since the low value can cause "GasDepletion" error.
let mut deps = mock_instance_with_gas_limit(WASM, 100_000_000);
let mut deps = mock_instance_with_gas_limit(WASM, u64::MAX);

let msg = InstantiateMsg {
merkletree_levels: MERKLE_TREE_LEVELS,
Expand All @@ -53,7 +53,7 @@ fn integration_test_instantiate_mixer() {

#[test]
fn integration_test_mixer_deposit_native_token() {
let mut deps = mock_instance_with_gas_limit(WASM, 200_000_000);
let mut deps = mock_instance_with_gas_limit(WASM, u64::MAX);

// Initialize the contract
let env = mock_env();
Expand Down Expand Up @@ -92,7 +92,7 @@ fn integration_test_mixer_deposit_native_token() {

#[test]
fn integration_test_mixer_deposit_cw20_token() {
let mut deps = mock_instance_with_gas_limit(WASM, 200_000_000);
let mut deps = mock_instance_with_gas_limit(WASM, u64::MAX);

// Initialize the contract
let env = mock_env();
Expand Down
10 changes: 5 additions & 5 deletions contracts/signature-bridge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ optimize = """docker run --rm -v "$(pwd)":/code \
"""

[dependencies]
cosmwasm-std = { version = "0.16.2" }
cosmwasm-storage = { version = "0.16.0" }
cw-storage-plus = "0.8.0"
cw2 = "0.8.1"
cosmwasm-std = { version = "1.0.0" }
cosmwasm-storage = { version = "1.0.0" }
cw-storage-plus = "0.13.2"
cw2 = "0.13.2"
schemars = "0.8.3"
serde = { version = "1.0.127", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.26" }
Expand All @@ -43,4 +43,4 @@ protocol-cosmwasm = { version = "0.1.0", path = "../../packages/protocol_cosmwas


[dev-dependencies]
cosmwasm-schema = { version = "0.16.0" }
cosmwasm-schema = { version = "1.0.0" }
2 changes: 1 addition & 1 deletion contracts/signature-bridge/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ mod tests {

#[test]
fn proper_initialization() {
let mut deps = mock_dependencies(&[]);
let mut deps = mock_dependencies();

let msg = InstantiateMsg {
initial_governor: GOVERNOR.to_string(),
Expand Down
10 changes: 5 additions & 5 deletions contracts/tokenwrapper-handler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ backtraces = ["cosmwasm-std/backtraces"]
library = []

[dependencies]
cosmwasm-std = { version = "0.16.2" }
cosmwasm-storage = { version = "0.16.0" }
cw-storage-plus = "0.8.0"
cw2 = "0.8.1"
cosmwasm-std = { version = "1.0.0" }
cosmwasm-storage = { version = "1.0.0" }
cw-storage-plus = "0.13.2"
cw2 = "0.13.2"
schemars = "0.8.3"
serde = { version = "1.0.127", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.26" }
Expand All @@ -36,4 +36,4 @@ protocol-cosmwasm = { version = "0.1.0", path = "../../packages/protocol_cosmwas


[dev-dependencies]
cosmwasm-schema = { version = "0.16.0" }
cosmwasm-schema = { version = "1.0.0" }
4 changes: 2 additions & 2 deletions contracts/tokenwrapper-handler/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const RESOURCE_ID: [u8; 32] = [1u8; 32];
const CONTRACT_ADDRESS: &str = "terra1jrj2vh6cstqwk3pg8nkmdf0r9z0n3q3f3jk5xn";

fn instantiate_tokenwrapper_handler() -> OwnedDeps<MockStorage, MockApi, MockQuerier> {
let mut deps = mock_dependencies(&[]);
let mut deps = mock_dependencies();

// Instantiate the "tokenwrapper-handler".
let msg = InstantiateMsg {
Expand All @@ -41,7 +41,7 @@ fn proposal_to_exec_data(resource_id: [u8; 32], proposal: GovernedTokenWrapperEx

#[test]
fn proper_initialization() {
let mut deps = mock_dependencies(&[]);
let mut deps = mock_dependencies();

let msg = InstantiateMsg {
bridge_addr: BRIDGE_ADDR.to_string(),
Expand Down
20 changes: 10 additions & 10 deletions contracts/tokenwrapper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ optimize = """docker run --rm -v "$(pwd)":/code \
"""

[dependencies]
cosmwasm-std = { version = "0.16.2" }
cosmwasm-storage = { version = "0.16.0" }
cw-storage-plus = "0.8.0"
cw-utils = { version = "0.12.1" }
cw2 = "0.8.1"
cw20 = "0.8.1"
cw-controllers = { version = "0.8.1" }
cw20-base = { version = "0.8.1", features = ["library"] }
cosmwasm-std = { version = "1.0.0" }
cosmwasm-storage = { version = "1.0.0" }
cw-storage-plus = "0.13.2"
cw-utils = { version = "0.13.2" }
cw2 = "0.13.2"
cw20 = "0.13.2"
cw-controllers = { version = "0.13.2" }
cw20-base = { version = "0.13.2", features = ["library"] }
schemars = "0.8.3"
serde = { version = "1.0.127", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.26" }

protocol-cosmwasm = { version = "0.1.0", path = "../../packages/protocol_cosmwasm"}

[dev-dependencies]
cosmwasm-schema = { version = "0.16.0" }
cosmwasm-vm = { version = "0.16.5" }
cosmwasm-schema = { version = "1.0.0" }
cosmwasm-vm = { version = "1.0.0" }
10 changes: 6 additions & 4 deletions contracts/tokenwrapper/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ fn wrap_native(
}

// Calculate the "fee" & "amount_to_wrap".
let cost_to_wrap = get_fee_from_amount(wrapping_amount, config.fee_percentage.numerator());
let cost_to_wrap =
get_fee_from_amount(wrapping_amount, config.fee_percentage.numerator().u128());
let left_over = wrapping_amount - cost_to_wrap;

// Save the wrapped token amount.
Expand Down Expand Up @@ -384,7 +385,8 @@ fn wrap_cw20(

// Calculate the "fee" & "amount_to_wrap".
let config = CONFIG.load(deps.storage)?;
let cost_to_wrap = get_fee_from_amount(cw20_msg.amount, config.fee_percentage.numerator());
let cost_to_wrap =
get_fee_from_amount(cw20_msg.amount, config.fee_percentage.numerator().u128());
let left_over = cw20_msg.amount - cost_to_wrap;

match from_binary(&cw20_msg.msg) {
Expand Down Expand Up @@ -603,7 +605,7 @@ fn query_fee_from_amount(deps: Deps, amount_to_wrap: String) -> StdResult<FeeFro
let config = CONFIG.load(deps.storage)?;
let amount_to_wrap = parse_string_to_uint128(amount_to_wrap)?;
let fee_perc = config.fee_percentage.numerator();
let fee_amt = get_fee_from_amount(amount_to_wrap, fee_perc);
let fee_amt = get_fee_from_amount(amount_to_wrap, fee_perc.u128());
Ok(FeeFromAmountResponse {
amount_to_wrap: amount_to_wrap.to_string(),
fee_amt: fee_amt.to_string(),
Expand All @@ -614,7 +616,7 @@ fn query_amount_to_wrap(deps: Deps, target_amount: String) -> StdResult<GetAmoun
let config = CONFIG.load(deps.storage)?;
let target_amount = parse_string_to_uint128(target_amount)?;
let fee_perc = config.fee_percentage.numerator();
let amount_to_wrap = get_amount_to_wrap(target_amount, fee_perc);
let amount_to_wrap = get_amount_to_wrap(target_amount, fee_perc.u128());
Ok(GetAmountToWrapResponse {
target_amount: target_amount.to_string(),
amount_to_wrap: amount_to_wrap.to_string(),
Expand Down
7 changes: 4 additions & 3 deletions contracts/tokenwrapper/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use cosmwasm_std::testing::{
mock_dependencies, mock_env, mock_info, MockApi, MockQuerier, MockStorage,
mock_dependencies, mock_dependencies_with_balance, mock_env, mock_info, MockApi, MockQuerier,
MockStorage,
};
use cosmwasm_std::{attr, coins, from_binary, to_binary, Addr, Coin, OwnedDeps, Uint128};
use cw20::{BalanceResponse, Cw20ReceiveMsg, TokenInfoResponse};
Expand All @@ -22,7 +23,7 @@ const WRAPPING_LIMIT: u128 = 5000000;
const IS_NATIVE_ALLOWED: u32 = 1;

fn init_tokenwrapper(coins: Vec<Coin>) -> OwnedDeps<MockStorage, MockApi, MockQuerier> {
let mut deps = mock_dependencies(&coins);
let mut deps = mock_dependencies_with_balance(&coins);

let info = mock_info("creator", &[]);
let instantiate_msg = InstantiateMsg {
Expand All @@ -44,7 +45,7 @@ fn init_tokenwrapper(coins: Vec<Coin>) -> OwnedDeps<MockStorage, MockApi, MockQu

#[test]
fn proper_initialization() {
let mut deps = mock_dependencies(&[]);
let mut deps = mock_dependencies();

let info = mock_info("creator", &[]);
let instantiate_msg = InstantiateMsg {
Expand Down
2 changes: 1 addition & 1 deletion contracts/tokenwrapper/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn get_fee_from_amount(amount_to_wrap: Uint128, fee_perc: u128) -> Uint128 {
pub fn get_amount_to_wrap(target_amount: Uint128, fee_perc: u128) -> Uint128 {
target_amount.multiply_ratio(
Decimal::MAX.denominator(),
Decimal::MAX.denominator() - fee_perc,
Decimal::MAX.denominator().u128() - fee_perc,
)
}

Expand Down
Binary file modified contracts/tokenwrapper/tests/cosmwasm_tokenwrapper.wasm
Binary file not shown.
14 changes: 7 additions & 7 deletions contracts/vanchor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ optimize = """docker run --rm -v "$(pwd)":/code \
"""

[dependencies]
cosmwasm-std = { version = "0.16.2" }
cosmwasm-storage = { version = "0.16.0" }
cw-storage-plus = "0.8.0"
cw2 = "0.8.1"
cw20 = "0.8.1"
cosmwasm-std = { version = "1.0.0" }
cosmwasm-storage = { version = "1.0.0" }
cw-storage-plus = "0.13.2"
cw2 = "0.13.2"
cw20 = "0.13.2"
schemars = "0.8.3"
serde = { version = "1.0.127", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.26" }
Expand All @@ -55,8 +55,8 @@ ark-serialize = { version = "^0.3.0", default-features = false }
protocol-cosmwasm = { version = "0.1.0", path = "../../packages/protocol_cosmwasm"}

[dev-dependencies]
cosmwasm-schema = { version = "0.16.0" }
cosmwasm-vm = { version = "0.16.5" }
cosmwasm-schema = { version = "1.0.0" }
cosmwasm-vm = { version = "1.0.0" }

[target.'cfg(not(target_arch="wasm32"))'.dependencies]
wasm-utils = { version = "0.1.3" }
Expand Down
Loading

0 comments on commit cfc3b0f

Please sign in to comment.