From b655b993c277daa545322b8dfda113ebfacc0c21 Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Wed, 13 Oct 2021 14:56:02 +0200 Subject: [PATCH 1/8] Update all dependencies --- Cargo.lock | 62 +++++++++++++++--------------- contracts/dso-token/Cargo.toml | 18 ++++----- contracts/tfi-factory/Cargo.toml | 18 ++++----- contracts/tfi-pair/Cargo.toml | 16 ++++---- packages/mocks/Cargo.toml | 6 +-- packages/mocks/src/lib.rs | 3 ++ packages/tfi/Cargo.toml | 8 ++-- packages/trusted-circle/Cargo.toml | 8 ++-- 8 files changed, 72 insertions(+), 67 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5d09c7a..3d12ba1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -94,9 +94,9 @@ checksum = "44c32f031ea41b4291d695026c023b95d59db2d8a2c7640800ed56bc8f510f22" [[package]] name = "cosmwasm-crypto" -version = "0.16.0" +version = "1.0.0-beta" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa1715a9b71c7c31385a3f021dee2fd0a17b82043ab937467e103aa25043d2e" +checksum = "1b6da9aa7d6d1f5607b184bb207ead134df3ddc99ddb1a2d8d9915b59454d535" dependencies = [ "digest", "ed25519-zebra", @@ -107,18 +107,18 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "0.16.0" +version = "1.0.0-beta" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f6e6dff07965015c4fcdf477c4becde738a2bfb40cf6239bdcea9335016c5a2" +checksum = "eb6c5b99d05fcf047bafc0fc093e8e7b7ecb63b76791f644f5dc3eca5a548de1" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "0.16.0" +version = "1.0.0-beta" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac9ba1eea088e7f1ec4a7679c43adcb51e80cbc2af6a6d83d1bb652b7adaf6dc" +checksum = "22e4b3f6933f94acdd3ddb931af4870c2002e3331a4a8b247a4ef070dd31ccb0" dependencies = [ "schemars", "serde_json", @@ -126,9 +126,9 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "0.16.0" +version = "1.0.0-beta" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92bdeee0ebba164ebbef9380522cc50f889db38acc1f1210f6b55ee2244b8c59" +checksum = "3b7214fed59d78adc13b98e68072bf49f5273c8a6713ca98cb7784339f49ef01" dependencies = [ "base64", "cosmwasm-crypto", @@ -142,9 +142,9 @@ dependencies = [ [[package]] name = "cosmwasm-storage" -version = "0.16.0" +version = "1.0.0-beta" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e26053f14f971b05abca3be34f80c631d70c5b5b9df175e7a1d8b4aad83e40cc" +checksum = "665cf97ad42be46936f6e6739711824a9bf21c440a6c98e185a3404aef0c3b81" dependencies = [ "cosmwasm-std", "serde", @@ -202,9 +202,9 @@ dependencies = [ [[package]] name = "cw-controllers" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26bd89d1f5cbae950ec3946ce5874f049c98d5608b1420292d5eda913aa4948d" +checksum = "284e5f6341e10019e1bb96c4accb5ad0e4b84798d5ee57c93478f8acb086dc0e" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -216,15 +216,16 @@ dependencies = [ [[package]] name = "cw-multi-test" -version = "0.8.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecca04ea07d99e8cb7031c58ec5a7d8f581d597621353f1ecbee9e2829169d27" +checksum = "670f079c08ee111664b4d01f845ab11aa1f722a51013bd71bfe9d930f323406d" dependencies = [ "anyhow", "cosmwasm-std", "cosmwasm-storage", "cw-storage-plus", "cw0", + "derivative", "itertools", "prost", "schemars", @@ -234,9 +235,9 @@ dependencies = [ [[package]] name = "cw-storage-plus" -version = "0.8.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1e867b9972b83b32e00e878dfbff48299ba26618dabeb19b9c56fae176dc225" +checksum = "bbae8575a3517f88581f0a48f7021f01a0ebde1b65d47d33b54d1cba3bd9028f" dependencies = [ "cosmwasm-std", "schemars", @@ -245,9 +246,9 @@ dependencies = [ [[package]] name = "cw0" -version = "0.8.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c497f885a40918a02df7d938c81809965fa05cfc21b3dc591e9950237b5de0a9" +checksum = "1a7ed2e4c60ec883bc5295613b016e9d7710ad6e28610361981ae999e6fe9bc5" dependencies = [ "cosmwasm-std", "schemars", @@ -257,9 +258,9 @@ dependencies = [ [[package]] name = "cw2" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51698a50df8be3d31d7261082f052685d04fe6289df89792fd4efa41daee8b90" +checksum = "f4dc7be3e594753983f9c0a3ef23a1a3fb3afc2155f65ea8522c66703c8bd90f" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -269,9 +270,9 @@ dependencies = [ [[package]] name = "cw20" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f24779556263d95d5a7ebf8a0b0cd615df0b34bff69c23f409e5f17b5fb529ef" +checksum = "1ecdcc2b01eaca7c322c841bac5c2eb077c1289c54b393a174d34971212c4b4d" dependencies = [ "cosmwasm-std", "cw0", @@ -281,9 +282,9 @@ dependencies = [ [[package]] name = "cw20-base" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc6cac998c7ac2b907fe2ccf1b5b966f5ea823b4aa6c2985770223547b7b77ec" +checksum = "30b9c237cb0713816588c0cc6fb49dbdaf2688b184d441518436b0c986fb45dd" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -297,9 +298,9 @@ dependencies = [ [[package]] name = "cw3" -version = "0.8.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "078acdb1876c5c73b443f394f5eb7bbb998b56452836a2545d92ab01d4cb5a9b" +checksum = "2253b0f9e257a954db4657e4edad03acd2d42558aa3da3fe03daf99c429d73c4" dependencies = [ "cosmwasm-std", "cw0", @@ -309,20 +310,21 @@ dependencies = [ [[package]] name = "cw4" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1975f157f12d9a97be34aefb6da6dd054e13812da0fd2f0e5abb195f6db6e475" +checksum = "9d5721e82368b31ff1690258d283b9e1682169d9236c1c2157d30375d5ebf736" dependencies = [ "cosmwasm-std", + "cw-storage-plus", "schemars", "serde", ] [[package]] name = "cw4-group" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aad2ff66f8b09bb3b121b106154afabde83f889b615bc7b18501c2f97966d42" +checksum = "f6ca733c2df6fd4f02f29270893e2075b193d8d87f5d3864ee4b337d1be013f9" dependencies = [ "cosmwasm-std", "cw-controllers", diff --git a/contracts/dso-token/Cargo.toml b/contracts/dso-token/Cargo.toml index 2591261..a826a70 100644 --- a/contracts/dso-token/Cargo.toml +++ b/contracts/dso-token/Cargo.toml @@ -20,19 +20,19 @@ crate-type = ["cdylib", "rlib"] backtraces = ["cosmwasm-std/backtraces"] [dependencies] -cosmwasm-std = { version = "0.16.0" } -cw-storage-plus = "0.8.0" -cw20-base = { version = "0.8.0", features = ["library"] } -cw2 = "0.8.0" -cw4 = "0.8.0" -cw20 = "0.8.0" +cosmwasm-std = "=1.0.0-beta" +cw-storage-plus = "=0.10" +cw20-base = { version = "=0.10", features = ["library"] } +cw2 = "=0.10" +cw4 = "=0.10" +cw20 = "=0.10" schemars = "0.8.1" serde = { version = "1.0.125", default-features = false, features = ["derive"] } thiserror = { version = "1.0.24" } [dev-dependencies] anyhow = "1" -cosmwasm-schema = { version = "0.16.0" } -cw-multi-test = "0.8.1" -cw4-group = "0.8.0" +cosmwasm-schema = "=1.0.0-beta" +cw-multi-test = "=0.10" +cw4-group = "=0.10" derivative = "2" diff --git a/contracts/tfi-factory/Cargo.toml b/contracts/tfi-factory/Cargo.toml index 4adfeeb..77f0738 100644 --- a/contracts/tfi-factory/Cargo.toml +++ b/contracts/tfi-factory/Cargo.toml @@ -24,23 +24,23 @@ backtraces = ["cosmwasm-std/backtraces"] [dependencies] tfi = { path = "../../packages/tfi", default-features = false, version = "0.1.0"} -cosmwasm-std = { version = "0.16.0", features = ["iterator"] } -cw-storage-plus = { version = "0.8.0", features = ["iterator"]} +cosmwasm-std = { version = "=1.0.0-beta", features = ["iterator"] } +cw-storage-plus = { version = "=0.10", features = ["iterator"]} schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } protobuf = { version = "2", features = ["with-bytes"] } thiserror = "1" [dev-dependencies] -cosmwasm-schema = "0.16.0" -cosmwasm-storage = { version = "0.16.0", features = ["iterator"] } +cosmwasm-schema = "=1.0.0-beta" +cosmwasm-storage = { version = "=1.0.0-beta", features = ["iterator"] } anyhow = { version = "1", features = ["backtrace"] } -cw-multi-test = "0.8.1" +cw-multi-test = "=0.10" tfi-pair = { path = "../tfi-pair", version = "0.1" } dso-token = { path = "../dso-token", version = "0.1" } derivative = "2" -cw4-group = { version = "0.8", features = ["library"] } -cw4 = "0.8" -cw20 = "0.8" -cw20-base = { version = "0.8", features = ["library"] } +cw4-group = { version = "=0.10", features = ["library"] } +cw4 = "=0.10" +cw20 = "=0.10" +cw20-base = { version = "=0.10", features = ["library"] } diff --git a/contracts/tfi-pair/Cargo.toml b/contracts/tfi-pair/Cargo.toml index 11427a6..f15423c 100644 --- a/contracts/tfi-pair/Cargo.toml +++ b/contracts/tfi-pair/Cargo.toml @@ -25,19 +25,19 @@ backtraces = ["cosmwasm-std/backtraces"] [dependencies] integer-sqrt = "0.1.5" tfi = { path = "../../packages/tfi", default-features = false, version = "0.1.0"} -cw2 = { version = "0.8.0" } -cw20 = { version = "0.8.0" } -cosmwasm-std = { version = "0.16.0" } -cw-storage-plus = { version = "0.8.0" } +cw2 = "=0.10" +cw20 = "=0.10" +cosmwasm-std = "=1.0.0-beta" +cw-storage-plus = "=0.10" schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.20" } [dev-dependencies] -cosmwasm-schema = "0.16.0" -cosmwasm-storage = { version = "0.16.0", features = ["iterator"] } -cw20-base = { version = "0.8.0", features = ["library"] } -cw-multi-test = { version = "0.8.1" } +cosmwasm-schema = "=1.0.0-beta" +cosmwasm-storage = { version = "=1.0.0-beta", features = ["iterator"] } +cw20-base = { version = "=0.10", features = ["library"] } +cw-multi-test = { version = "=0.10" } tfi-mocks = { path = "../../packages/mocks", version = "0.1.0"} derivative = "2" anyhow = { version = "1", features = ["backtrace"] } diff --git a/packages/mocks/Cargo.toml b/packages/mocks/Cargo.toml index 4fe2804..52a1c91 100644 --- a/packages/mocks/Cargo.toml +++ b/packages/mocks/Cargo.toml @@ -12,8 +12,8 @@ homepage = "https://tgrade.finance" [dependencies] tfi = { path = "../tfi", version = "0.1.0" } -cw20 = { version = "0.8.0-rc1" } -cosmwasm-storage = { version = "0.16.0" } -cosmwasm-std = { version = "0.16.0" } +cw20 = "=0.10" +cosmwasm-storage = "=1.0.0-beta" +cosmwasm-std = "=1.0.0-beta" schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/mocks/src/lib.rs b/packages/mocks/src/lib.rs index d5647c6..f3c2961 100644 --- a/packages/mocks/src/lib.rs +++ b/packages/mocks/src/lib.rs @@ -9,6 +9,8 @@ use cw20::{BalanceResponse as Cw20BalanceResponse, Cw20QueryMsg, TokenInfoRespon use tfi::asset::PairInfo; use tfi::factory::QueryMsg as FactoryQueryMsg; +use std::marker::PhantomData; + /// mock_dependencies is a drop-in replacement for cosmwasm_std::testing::mock_dependencies /// this uses our CustomQuerier. pub fn mock_dependencies( @@ -21,6 +23,7 @@ pub fn mock_dependencies( storage: MockStorage::default(), api: MockApi::default(), querier: custom_querier, + custom_query_type: PhantomData } } diff --git a/packages/tfi/Cargo.toml b/packages/tfi/Cargo.toml index 644573e..c0fd744 100644 --- a/packages/tfi/Cargo.toml +++ b/packages/tfi/Cargo.toml @@ -16,13 +16,13 @@ homepage = "https://tgrade.finance" backtraces = ["cosmwasm-std/backtraces"] [dependencies] -cw20 = { version = "0.8.0-rc1" } -cosmwasm-storage = { version = "0.16.0" } -cosmwasm-std = { version = "0.16.0" } +cw20 = "=0.10" +cosmwasm-storage = "=1.0.0-beta" +cosmwasm-std = "=1.0.0-beta" schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] -cosmwasm-schema = "0.16.0" +cosmwasm-schema = "=1.0.0-beta" tfi-mocks = { path = "../mocks", version = "0.1.0" } diff --git a/packages/trusted-circle/Cargo.toml b/packages/trusted-circle/Cargo.toml index 8b66867..ceeb1fd 100644 --- a/packages/trusted-circle/Cargo.toml +++ b/packages/trusted-circle/Cargo.toml @@ -16,12 +16,12 @@ homepage = "https://tgrade.finance" backtraces = ["cosmwasm-std/backtraces"] [dependencies] -cosmwasm-std = { version = "0.16.0" } +cosmwasm-std = "=1.0.0-beta" schemars = "0.8.1" -cw0 = "0.8" -cw3 = "0.8" +cw0 = "=0.10" +cw3 = "=0.10" serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] -cosmwasm-schema = "0.16.0" +cosmwasm-schema = "=1.0.0-beta" From 69d5882c4132bf2fee26e9bad1e4909edc544356 Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Wed, 13 Oct 2021 15:37:32 +0200 Subject: [PATCH 2/8] Fix or adapt tests to new version of comswam-std and cw-plus --- contracts/dso-token/src/contract.rs | 5 +++++ contracts/dso-token/src/multitest/suite.rs | 10 ++-------- contracts/tfi-factory/src/mock_querier.rs | 3 ++- contracts/tfi-factory/src/multitest/suite.rs | 21 +++++++++++--------- contracts/tfi-pair/src/multitest.rs | 10 ++-------- packages/mocks/src/lib.rs | 2 +- 6 files changed, 24 insertions(+), 27 deletions(-) diff --git a/contracts/dso-token/src/contract.rs b/contracts/dso-token/src/contract.rs index 0d45d52..262bc71 100644 --- a/contracts/dso-token/src/contract.rs +++ b/contracts/dso-token/src/contract.rs @@ -386,6 +386,8 @@ mod tests { use cw20_base::state::TokenInfo; use cw_storage_plus::Map; + use std::marker::PhantomData; + const MEMBERS: Map<&Addr, u64> = Map::new(cw4::MEMBERS_KEY); struct GroupQuerier { @@ -500,6 +502,7 @@ mod tests { storage, api, querier, + custom_query_type: PhantomData, }; BALANCES @@ -552,6 +555,7 @@ mod tests { storage, api, querier, + custom_query_type: PhantomData, }; TOKEN_INFO @@ -600,6 +604,7 @@ mod tests { storage, api, querier, + custom_query_type: PhantomData, }; BALANCES diff --git a/contracts/dso-token/src/multitest/suite.rs b/contracts/dso-token/src/multitest/suite.rs index d0510cd..f806a1a 100644 --- a/contracts/dso-token/src/multitest/suite.rs +++ b/contracts/dso-token/src/multitest/suite.rs @@ -1,11 +1,10 @@ use cw20_base::msg::InstantiateMarketingInfo; -use cosmwasm_std::testing::{mock_env, MockApi, MockStorage}; use cosmwasm_std::{to_binary, Addr, Binary, Empty, Response, StdError, Uint128}; use cw20::{Cw20Coin, Cw20Contract, Cw20ReceiveMsg, MinterResponse, TokenInfoResponse}; use cw4::{Cw4Contract, Member}; use cw4_group::msg::ExecuteMsg as Cw4ExecuteMsg; -use cw_multi_test::{App, AppResponse, BankKeeper, Contract, ContractWrapper, Executor}; +use cw_multi_test::{App, AppResponse, Contract, ContractWrapper, Executor}; use crate::msg::{ExecuteMsg, InstantiateMsg}; @@ -107,12 +106,7 @@ impl ReceiverContract { } fn mock_app() -> App { - let env = mock_env(); - let api = MockApi::default(); - let bank = BankKeeper::new(); - let storage = MockStorage::new(); - - App::new(api, env.block, bank, storage) + App::default() } fn contract_group() -> Box> { diff --git a/contracts/tfi-factory/src/mock_querier.rs b/contracts/tfi-factory/src/mock_querier.rs index bd07b90..1b63d64 100644 --- a/contracts/tfi-factory/src/mock_querier.rs +++ b/contracts/tfi-factory/src/mock_querier.rs @@ -3,7 +3,7 @@ use cosmwasm_std::{ from_slice, to_binary, Coin, ContractResult, Empty, OwnedDeps, Querier, QuerierResult, QueryRequest, SystemError, SystemResult, WasmQuery, }; -use std::collections::HashMap; +use std::{collections::HashMap, marker::PhantomData}; use tfi::asset::{AssetInfo, PairInfo}; /// mock_dependencies is a drop-in replacement for cosmwasm_std::testing::mock_dependencies @@ -18,6 +18,7 @@ pub fn mock_dependencies( api: MockApi::default(), storage: MockStorage::default(), querier: custom_querier, + custom_query_type: PhantomData, } } diff --git a/contracts/tfi-factory/src/multitest/suite.rs b/contracts/tfi-factory/src/multitest/suite.rs index 66ade9c..d603b0d 100644 --- a/contracts/tfi-factory/src/multitest/suite.rs +++ b/contracts/tfi-factory/src/multitest/suite.rs @@ -1,22 +1,16 @@ use anyhow::{anyhow, Result}; -use cosmwasm_std::testing::{mock_env, MockApi, MockStorage}; -use cosmwasm_std::{coins, to_binary, Addr, Decimal, Empty, Uint128}; +use cosmwasm_std::{coins, to_binary, Addr, BankMsg, Decimal, Empty, Uint128}; use cw20::{Cw20Coin, Cw20Contract, Cw20ExecuteMsg}; use cw4::{Cw4Contract, Member}; use cw4_group::msg::ExecuteMsg as Cw4ExecuteMsg; -use cw_multi_test::{App, BankKeeper, Contract, ContractWrapper, Executor}; +use cw_multi_test::{App, Contract, ContractWrapper, Executor}; use derivative::Derivative; use tfi::asset::{Asset, AssetInfo, PairInfo}; use tfi::factory::{ExecuteMsg, InstantiateMsg, QueryMsg}; use tfi::pair::{Cw20HookMsg, ExecuteMsg as PairExecuteMsg}; fn mock_app() -> App { - let env = mock_env(); - let api = MockApi::default(); - let bank = BankKeeper::new(); - let storage = MockStorage::new(); - - App::new(api, env.block, bank, storage) + App::default() } fn contract_factory() -> Box> { @@ -338,6 +332,15 @@ impl Config { .into_iter() .map(|actor| -> Result<_> { let addr = Addr::unchecked(&actor.addr); + // app.execute( + // Addr::unchecked("reserve"), + // BankMsg::Send { + // to_address: addr.to_string(), + // amount: coins(actor.btc, "btc"), + // } + // .into(), + // ) + // .unwrap(); app.init_bank_balance(&addr, coins(actor.btc, "btc")) .map_err(|err| anyhow!(err))?; diff --git a/contracts/tfi-pair/src/multitest.rs b/contracts/tfi-pair/src/multitest.rs index c226e5a..ad6f6f2 100644 --- a/contracts/tfi-pair/src/multitest.rs +++ b/contracts/tfi-pair/src/multitest.rs @@ -1,8 +1,7 @@ use anyhow::{anyhow, Result}; -use cosmwasm_std::testing::{mock_env, MockApi, MockStorage}; use cosmwasm_std::{coin, coins, to_binary, Addr, Decimal, Empty, StdError, Uint128}; use cw20::{Cw20Coin, Cw20ExecuteMsg}; -use cw_multi_test::{App, BankKeeper, Contract, ContractWrapper, Executor}; +use cw_multi_test::{App, Contract, ContractWrapper, Executor}; use derivative::Derivative; use crate::error::ContractError; @@ -13,12 +12,7 @@ use tfi::pair::{ }; fn mock_app() -> App { - let env = mock_env(); - let api = MockApi::default(); - let bank = BankKeeper::new(); - let storage = MockStorage::new(); - - App::new(api, env.block, bank, storage) + App::default() } pub fn contract_pair() -> Box> { diff --git a/packages/mocks/src/lib.rs b/packages/mocks/src/lib.rs index f3c2961..25e7d02 100644 --- a/packages/mocks/src/lib.rs +++ b/packages/mocks/src/lib.rs @@ -23,7 +23,7 @@ pub fn mock_dependencies( storage: MockStorage::default(), api: MockApi::default(), querier: custom_querier, - custom_query_type: PhantomData + custom_query_type: PhantomData, } } From 44b7a8abdc76513d077a9e9bf35fc5741f20bb3b Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Wed, 13 Oct 2021 16:20:52 +0200 Subject: [PATCH 3/8] Add federal reserve as initial account with millions of tokens... --- contracts/tfi-factory/src/multitest/suite.rs | 36 ++++++++++------- contracts/tfi-pair/src/multitest.rs | 41 ++++++++++++++++---- 2 files changed, 57 insertions(+), 20 deletions(-) diff --git a/contracts/tfi-factory/src/multitest/suite.rs b/contracts/tfi-factory/src/multitest/suite.rs index d603b0d..1854202 100644 --- a/contracts/tfi-factory/src/multitest/suite.rs +++ b/contracts/tfi-factory/src/multitest/suite.rs @@ -3,14 +3,26 @@ use cosmwasm_std::{coins, to_binary, Addr, BankMsg, Decimal, Empty, Uint128}; use cw20::{Cw20Coin, Cw20Contract, Cw20ExecuteMsg}; use cw4::{Cw4Contract, Member}; use cw4_group::msg::ExecuteMsg as Cw4ExecuteMsg; -use cw_multi_test::{App, Contract, ContractWrapper, Executor}; +use cw_multi_test::{App, AppBuilder, Contract, ContractWrapper, Executor}; use derivative::Derivative; use tfi::asset::{Asset, AssetInfo, PairInfo}; use tfi::factory::{ExecuteMsg, InstantiateMsg, QueryMsg}; use tfi::pair::{Cw20HookMsg, ExecuteMsg as PairExecuteMsg}; +const FEDERAL_RESERVE: &str = "reserve"; +const DENOM: &str = "btc"; + fn mock_app() -> App { - App::default() + AppBuilder::new_custom().build(|router, _, storage| { + router + .bank + .init_balance( + storage, + &Addr::unchecked(FEDERAL_RESERVE), + coins(100000, DENOM), + ) + .unwrap(); + }) } fn contract_factory() -> Box> { @@ -332,17 +344,15 @@ impl Config { .into_iter() .map(|actor| -> Result<_> { let addr = Addr::unchecked(&actor.addr); - // app.execute( - // Addr::unchecked("reserve"), - // BankMsg::Send { - // to_address: addr.to_string(), - // amount: coins(actor.btc, "btc"), - // } - // .into(), - // ) - // .unwrap(); - app.init_bank_balance(&addr, coins(actor.btc, "btc")) - .map_err(|err| anyhow!(err))?; + app.execute( + Addr::unchecked(FEDERAL_RESERVE), + BankMsg::Send { + to_address: actor.addr.to_owned(), + amount: coins(actor.btc, DENOM), + } + .into(), + ) + .unwrap(); let initial_cash = Cw20Coin { address: addr.to_string(), diff --git a/contracts/tfi-pair/src/multitest.rs b/contracts/tfi-pair/src/multitest.rs index ad6f6f2..f79352f 100644 --- a/contracts/tfi-pair/src/multitest.rs +++ b/contracts/tfi-pair/src/multitest.rs @@ -1,7 +1,7 @@ use anyhow::{anyhow, Result}; -use cosmwasm_std::{coin, coins, to_binary, Addr, Decimal, Empty, StdError, Uint128}; +use cosmwasm_std::{coin, coins, to_binary, Addr, BankMsg, Decimal, Empty, StdError, Uint128}; use cw20::{Cw20Coin, Cw20ExecuteMsg}; -use cw_multi_test::{App, Contract, ContractWrapper, Executor}; +use cw_multi_test::{App, AppBuilder, Contract, ContractWrapper, Executor}; use derivative::Derivative; use crate::error::ContractError; @@ -11,8 +11,20 @@ use tfi::pair::{ SimulationResponse, }; +const FEDERAL_RESERVE: &str = "reserve"; +const DENOM: &str = "btc"; + fn mock_app() -> App { - App::default() + AppBuilder::new_custom().build(|router, _, storage| { + router + .bank + .init_balance( + storage, + &Addr::unchecked(FEDERAL_RESERVE), + coins(100000, DENOM), + ) + .unwrap(); + }) } pub fn contract_pair() -> Box> { @@ -374,8 +386,15 @@ impl SuiteConfig { let pairs = actors .into_iter() .map(|lp| -> Result<_> { - app.init_bank_balance(&lp.addr, coins(lp.btc, "btc")) - .map_err(|err| anyhow!(err))?; + app.execute( + Addr::unchecked(FEDERAL_RESERVE), + BankMsg::Send { + to_address: lp.addr.to_string(), + amount: coins(lp.btc, DENOM), + } + .into(), + ) + .unwrap(); let cash = Cw20Coin { address: lp.addr.to_string(), @@ -466,8 +485,16 @@ fn setup_liquidity_pool() { // set personal balance let owner = Addr::unchecked("owner"); - let init_funds = coins(20000, "btc"); - app.init_bank_balance(&owner, init_funds).unwrap(); + let init_funds = coins(20000, DENOM); + app.execute( + Addr::unchecked(FEDERAL_RESERVE), + BankMsg::Send { + to_address: owner.to_string(), + amount: init_funds, + } + .into(), + ) + .unwrap(); // set up cw20 contract with some tokens let cw20_id = app.store_code(contract_cw20()); From 66e049f14e05090891b8c9a142c11fee341700ab Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Wed, 13 Oct 2021 16:25:08 +0200 Subject: [PATCH 4/8] Update circleci --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c0b5cfc..ba74e72 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -229,7 +229,7 @@ jobs: - run: name: Install check_contract # Uses --debug for compilation speed - command: cargo install --debug --version 0.16.0-rc5 --features iterator --example check_contract -- cosmwasm-vm + command: cargo install --debug --version 1.0.0-beta --features iterator --example check_contract -- cosmwasm-vm - save_cache: paths: - /usr/local/cargo/registry From ab7f0aff35ef8a1f4eb8876630dee406fd2f6069 Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Wed, 13 Oct 2021 16:29:04 +0200 Subject: [PATCH 5/8] Remove enabled-by-default iterator feature --- contracts/tfi-factory/Cargo.toml | 6 +++--- contracts/tfi-pair/Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/contracts/tfi-factory/Cargo.toml b/contracts/tfi-factory/Cargo.toml index 77f0738..4b44796 100644 --- a/contracts/tfi-factory/Cargo.toml +++ b/contracts/tfi-factory/Cargo.toml @@ -24,8 +24,8 @@ backtraces = ["cosmwasm-std/backtraces"] [dependencies] tfi = { path = "../../packages/tfi", default-features = false, version = "0.1.0"} -cosmwasm-std = { version = "=1.0.0-beta", features = ["iterator"] } -cw-storage-plus = { version = "=0.10", features = ["iterator"]} +cosmwasm-std = "=1.0.0-beta" +cw-storage-plus = "=0.10" schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } protobuf = { version = "2", features = ["with-bytes"] } @@ -33,7 +33,7 @@ thiserror = "1" [dev-dependencies] cosmwasm-schema = "=1.0.0-beta" -cosmwasm-storage = { version = "=1.0.0-beta", features = ["iterator"] } +cosmwasm-storage = "=1.0.0-beta" anyhow = { version = "1", features = ["backtrace"] } cw-multi-test = "=0.10" tfi-pair = { path = "../tfi-pair", version = "0.1" } diff --git a/contracts/tfi-pair/Cargo.toml b/contracts/tfi-pair/Cargo.toml index f15423c..1f43443 100644 --- a/contracts/tfi-pair/Cargo.toml +++ b/contracts/tfi-pair/Cargo.toml @@ -35,7 +35,7 @@ thiserror = { version = "1.0.20" } [dev-dependencies] cosmwasm-schema = "=1.0.0-beta" -cosmwasm-storage = { version = "=1.0.0-beta", features = ["iterator"] } +cosmwasm-storage = "=1.0.0-beta" cw20-base = { version = "=0.10", features = ["library"] } cw-multi-test = { version = "=0.10" } tfi-mocks = { path = "../../packages/mocks", version = "0.1.0"} From ceb1c7ccd1f83c4c44beb7ee96a25641c3d8cb41 Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Wed, 13 Oct 2021 17:04:43 +0200 Subject: [PATCH 6/8] Rename and add explanatory comment --- contracts/tfi-factory/src/multitest/suite.rs | 8 +++++--- contracts/tfi-pair/src/multitest.rs | 10 ++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/contracts/tfi-factory/src/multitest/suite.rs b/contracts/tfi-factory/src/multitest/suite.rs index 1854202..ef4ffb0 100644 --- a/contracts/tfi-factory/src/multitest/suite.rs +++ b/contracts/tfi-factory/src/multitest/suite.rs @@ -9,16 +9,18 @@ use tfi::asset::{Asset, AssetInfo, PairInfo}; use tfi::factory::{ExecuteMsg, InstantiateMsg, QueryMsg}; use tfi::pair::{Cw20HookMsg, ExecuteMsg as PairExecuteMsg}; -const FEDERAL_RESERVE: &str = "reserve"; +const TEST_RESERVE: &str = "reserve"; const DENOM: &str = "btc"; fn mock_app() -> App { + // Instantiates custom account (TEST_RESEVE) with arbitrary amount + // of tokens to fill any custom account later needed in tests AppBuilder::new_custom().build(|router, _, storage| { router .bank .init_balance( storage, - &Addr::unchecked(FEDERAL_RESERVE), + &Addr::unchecked(TEST_RESERVE), coins(100000, DENOM), ) .unwrap(); @@ -345,7 +347,7 @@ impl Config { .map(|actor| -> Result<_> { let addr = Addr::unchecked(&actor.addr); app.execute( - Addr::unchecked(FEDERAL_RESERVE), + Addr::unchecked(TEST_RESERVE), BankMsg::Send { to_address: actor.addr.to_owned(), amount: coins(actor.btc, DENOM), diff --git a/contracts/tfi-pair/src/multitest.rs b/contracts/tfi-pair/src/multitest.rs index f79352f..125265e 100644 --- a/contracts/tfi-pair/src/multitest.rs +++ b/contracts/tfi-pair/src/multitest.rs @@ -11,16 +11,18 @@ use tfi::pair::{ SimulationResponse, }; -const FEDERAL_RESERVE: &str = "reserve"; +const TEST_RESERVE: &str = "reserve"; const DENOM: &str = "btc"; fn mock_app() -> App { + // Instantiates custom account (TEST_RESEVE) with arbitrary amount + // of tokens to fill any custom account later needed in tests AppBuilder::new_custom().build(|router, _, storage| { router .bank .init_balance( storage, - &Addr::unchecked(FEDERAL_RESERVE), + &Addr::unchecked(TEST_RESERVE), coins(100000, DENOM), ) .unwrap(); @@ -387,7 +389,7 @@ impl SuiteConfig { .into_iter() .map(|lp| -> Result<_> { app.execute( - Addr::unchecked(FEDERAL_RESERVE), + Addr::unchecked(TEST_RESERVE), BankMsg::Send { to_address: lp.addr.to_string(), amount: coins(lp.btc, DENOM), @@ -487,7 +489,7 @@ fn setup_liquidity_pool() { let owner = Addr::unchecked("owner"); let init_funds = coins(20000, DENOM); app.execute( - Addr::unchecked(FEDERAL_RESERVE), + Addr::unchecked(TEST_RESERVE), BankMsg::Send { to_address: owner.to_string(), amount: init_funds, From 40bee92664a4a0d8fb07a98603e89a26842f0441 Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Thu, 14 Oct 2021 09:46:10 +0200 Subject: [PATCH 7/8] Fix two typos in comments --- contracts/tfi-factory/src/multitest/suite.rs | 2 +- contracts/tfi-pair/src/multitest.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/tfi-factory/src/multitest/suite.rs b/contracts/tfi-factory/src/multitest/suite.rs index ef4ffb0..469131c 100644 --- a/contracts/tfi-factory/src/multitest/suite.rs +++ b/contracts/tfi-factory/src/multitest/suite.rs @@ -13,7 +13,7 @@ const TEST_RESERVE: &str = "reserve"; const DENOM: &str = "btc"; fn mock_app() -> App { - // Instantiates custom account (TEST_RESEVE) with arbitrary amount + // Instantiates custom account (TEST_RESERVE) with arbitrary amount // of tokens to fill any custom account later needed in tests AppBuilder::new_custom().build(|router, _, storage| { router diff --git a/contracts/tfi-pair/src/multitest.rs b/contracts/tfi-pair/src/multitest.rs index 125265e..6bbcf89 100644 --- a/contracts/tfi-pair/src/multitest.rs +++ b/contracts/tfi-pair/src/multitest.rs @@ -15,7 +15,7 @@ const TEST_RESERVE: &str = "reserve"; const DENOM: &str = "btc"; fn mock_app() -> App { - // Instantiates custom account (TEST_RESEVE) with arbitrary amount + // Instantiates custom account (TEST_RESERVE) with arbitrary amount // of tokens to fill any custom account later needed in tests AppBuilder::new_custom().build(|router, _, storage| { router From de294550932d44be6e1fb55baa98a89ab7f49f90 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 14 Oct 2021 10:25:13 +0200 Subject: [PATCH 8/8] Bump version to 0.2.0 --- Cargo.lock | 12 ++++++------ contracts/dso-token/Cargo.toml | 2 +- contracts/tfi-factory/Cargo.toml | 8 ++++---- contracts/tfi-pair/Cargo.toml | 6 +++--- packages/mocks/Cargo.toml | 4 ++-- packages/tfi/Cargo.toml | 4 ++-- packages/trusted-circle/Cargo.toml | 2 +- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9b62367..4d465b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -368,7 +368,7 @@ dependencies = [ [[package]] name = "dso-token" -version = "0.1.1" +version = "0.2.0" dependencies = [ "anyhow", "cosmwasm-schema", @@ -819,7 +819,7 @@ dependencies = [ [[package]] name = "tfi" -version = "0.1.1" +version = "0.2.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -832,7 +832,7 @@ dependencies = [ [[package]] name = "tfi-factory" -version = "0.1.1" +version = "0.2.0" dependencies = [ "anyhow", "cosmwasm-schema", @@ -856,7 +856,7 @@ dependencies = [ [[package]] name = "tfi-mocks" -version = "0.1.1" +version = "0.2.0" dependencies = [ "cosmwasm-std", "cosmwasm-storage", @@ -868,7 +868,7 @@ dependencies = [ [[package]] name = "tfi-pair" -version = "0.1.1" +version = "0.2.0" dependencies = [ "anyhow", "cosmwasm-schema", @@ -910,7 +910,7 @@ dependencies = [ [[package]] name = "trusted-circle" -version = "0.1.1" +version = "0.2.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", diff --git a/contracts/dso-token/Cargo.toml b/contracts/dso-token/Cargo.toml index b8d9d47..73282ce 100644 --- a/contracts/dso-token/Cargo.toml +++ b/contracts/dso-token/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dso-token" -version = "0.1.1" +version = "0.2.0" authors = ["Ethan Frey "] edition = "2018" diff --git a/contracts/tfi-factory/Cargo.toml b/contracts/tfi-factory/Cargo.toml index 6e8ab6e..716e5a8 100644 --- a/contracts/tfi-factory/Cargo.toml +++ b/contracts/tfi-factory/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tfi-factory" -version = "0.1.1" +version = "0.2.0" authors = ["Terraform Labs, PTE."] edition = "2018" description = "A tfi factory contract - auto pair contract generator and also directory for all pairs" @@ -23,7 +23,7 @@ crate-type = ["cdylib", "rlib"] backtraces = ["cosmwasm-std/backtraces"] [dependencies] -tfi = { path = "../../packages/tfi", default-features = false, version = "0.1.1"} +tfi = { path = "../../packages/tfi", default-features = false, version = "0.2.0"} cosmwasm-std = "=1.0.0-beta" cw-storage-plus = "=0.10" schemars = "0.8.1" @@ -36,8 +36,8 @@ cosmwasm-schema = "=1.0.0-beta" cosmwasm-storage = "=1.0.0-beta" anyhow = { version = "1", features = ["backtrace"] } cw-multi-test = "=0.10" -tfi-pair = { path = "../tfi-pair", version = "0.1" } -dso-token = { path = "../dso-token", version = "0.1" } +tfi-pair = { path = "../tfi-pair", version = "0.2.0" } +dso-token = { path = "../dso-token", version = "0.2.0" } derivative = "2" cw4-group = { version = "=0.10", features = ["library"] } cw4 = "=0.10" diff --git a/contracts/tfi-pair/Cargo.toml b/contracts/tfi-pair/Cargo.toml index 632a5e7..f0b127b 100644 --- a/contracts/tfi-pair/Cargo.toml +++ b/contracts/tfi-pair/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tfi-pair" -version = "0.1.1" +version = "0.2.0" authors = ["Terraform Labs, PTE."] edition = "2018" description = "A tfi pair contract" @@ -24,7 +24,7 @@ backtraces = ["cosmwasm-std/backtraces"] [dependencies] integer-sqrt = "0.1.5" -tfi = { path = "../../packages/tfi", default-features = false, version = "0.1.1"} +tfi = { path = "../../packages/tfi", default-features = false, version = "0.2.0"} cw2 = "=0.10" cw20 = "=0.10" cosmwasm-std = "=1.0.0-beta" @@ -38,6 +38,6 @@ cosmwasm-schema = "=1.0.0-beta" cosmwasm-storage = "=1.0.0-beta" cw20-base = { version = "=0.10", features = ["library"] } cw-multi-test = { version = "=0.10" } -tfi-mocks = { path = "../../packages/mocks", version = "0.1.1"} +tfi-mocks = { path = "../../packages/mocks", version = "0.2.0"} derivative = "2" anyhow = { version = "1", features = ["backtrace"] } diff --git a/packages/mocks/Cargo.toml b/packages/mocks/Cargo.toml index 87b3cde..55be88d 100644 --- a/packages/mocks/Cargo.toml +++ b/packages/mocks/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tfi-mocks" -version = "0.1.1" +version = "0.2.0" authors = ["Ethan Frey "] edition = "2018" description = "Mocks for tfi tests" @@ -11,7 +11,7 @@ homepage = "https://tgrade.finance" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -tfi = { path = "../tfi", version = "0.1.1" } +tfi = { path = "../tfi", version = "0.2.0" } cw20 = "=0.10" cosmwasm-storage = "=1.0.0-beta" cosmwasm-std = "=1.0.0-beta" diff --git a/packages/tfi/Cargo.toml b/packages/tfi/Cargo.toml index e9d5051..e0bf9f0 100644 --- a/packages/tfi/Cargo.toml +++ b/packages/tfi/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tfi" -version = "0.1.1" +version = "0.2.0" authors = ["Ethan Frey "] edition = "2018" description = "Common tfi types" @@ -24,5 +24,5 @@ serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] cosmwasm-schema = "=1.0.0-beta" -tfi-mocks = { path = "../mocks", version = "0.1.1" } +tfi-mocks = { path = "../mocks", version = "0.2.0" } diff --git a/packages/trusted-circle/Cargo.toml b/packages/trusted-circle/Cargo.toml index b28e76d..412368b 100644 --- a/packages/trusted-circle/Cargo.toml +++ b/packages/trusted-circle/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "trusted-circle" -version = "0.1.1" +version = "0.2.0" authors = ["Ethan Frey "] edition = "2018" description = "Public API to call into the trusted-circle contracts"