diff --git a/Cargo.lock b/Cargo.lock index be01ddef..5f90ea7d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -311,17 +311,18 @@ dependencies = [ [[package]] name = "cw-multi-test" -version = "0.18.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "579e2c2f2c0877b839c5cad85e67811074e854a50c1ff3085eb8290b1c27809c" +checksum = "67fff029689ae89127cf6d7655809a68d712f3edbdb9686c70b018ba438b26ca" dependencies = [ "anyhow", + "bech32", "cosmwasm-std", "cw-storage-plus", "cw-utils", "derivative", - "itertools 0.11.0", - "prost 0.12.1", + "itertools 0.12.0", + "prost 0.12.3", "schemars", "serde", "sha2 0.10.8", @@ -356,9 +357,9 @@ dependencies = [ [[package]] name = "cw-storage-plus" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f0e92a069d62067f3472c62e30adedb4cab1754725c0f2a682b3128d2bf3c79" +checksum = "d5ff29294ee99373e2cd5fd21786a3c0ced99a52fec2ca347d565489c61b723c" dependencies = [ "cosmwasm-std", "schemars", @@ -367,9 +368,9 @@ dependencies = [ [[package]] name = "cw-utils" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9f351a4e4d81ef7c890e44d903f8c0bdcdc00f094fd3a181eaf70c0eec7a3a" +checksum = "1c4a657e5caacc3a0d00ee96ca8618745d050b8f757c709babafb81208d4239c" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -588,7 +589,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-controllers", - "cw-multi-test 0.18.0", + "cw-multi-test 0.20.0", "cw-storage-plus", "cw2", "schemars", @@ -650,7 +651,7 @@ version = "1.1.2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-multi-test 0.18.0", + "cw-multi-test 0.20.0", "cw-storage-plus", "cw-utils", "cw2", @@ -677,7 +678,7 @@ version = "0.9.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-multi-test 0.18.0", + "cw-multi-test 0.20.0", "cw-storage-plus", "cw-utils", "cw2", @@ -726,7 +727,7 @@ version = "1.0.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-multi-test 0.18.0", + "cw-multi-test 0.20.0", "cw-storage-plus", "cw2", "cw20", @@ -825,7 +826,7 @@ dependencies = [ "anyhow", "cosmwasm-schema", "cosmwasm-std", - "cw-multi-test 0.18.0", + "cw-multi-test 0.20.0", "cw-storage-plus", "cw-utils", "cw2", @@ -914,6 +915,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25db6b064527c5d482d0423354fcd07a89a2dfe07b67892e62411946db7f07b0" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.3" @@ -1124,12 +1134,12 @@ dependencies = [ [[package]] name = "prost" -version = "0.12.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4fdd22f3b9c31b53c060df4a0613a1c7f062d4115a2b984dd15b1858f7e340d" +checksum = "146c289cda302b98a28d40c8b3b90498d6e526dd24ac2ecea73e4e491685b94a" dependencies = [ "bytes", - "prost-derive 0.12.1", + "prost-derive 0.12.3", ] [[package]] @@ -1160,9 +1170,9 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.12.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "265baba7fabd416cf5078179f7d2cbeca4ce7a9041111900675ea7c4cb8a4c32" +checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e" dependencies = [ "anyhow", "itertools 0.11.0", @@ -1409,9 +1419,9 @@ checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" [[package]] name = "schemars" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f7b0ce13155372a76ee2e1c5ffba1fe61ede73fbea5630d61eee6fac4929c0c" +checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" dependencies = [ "dyn-clone", "schemars_derive", @@ -1421,9 +1431,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e85e2a16b12bdb763244c69ab79363d71db2b4b918a2def53f80b02e0574b13c" +checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" dependencies = [ "proc-macro2", "quote", @@ -1473,9 +1483,9 @@ checksum = "93f6841e709003d68bb2deee8c343572bf446003ec20a583e76f7b15cebf3711" [[package]] name = "serde" -version = "1.0.188" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] @@ -1491,9 +1501,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.188" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", @@ -1697,7 +1707,7 @@ version = "1.3.3" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-multi-test 0.18.0", + "cw-multi-test 0.20.0", "cw-storage-plus", "cw2", "cw20", @@ -1747,18 +1757,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", @@ -1807,7 +1817,7 @@ version = "1.2.6" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-multi-test 0.18.0", + "cw-multi-test 0.20.0", "cw-storage-plus", "cw2", "cw20", @@ -1826,10 +1836,9 @@ name = "vault-manager" version = "0.1.0" dependencies = [ "anyhow", - "bech32", "cosmwasm-schema", "cosmwasm-std", - "cw-multi-test 0.18.0", + "cw-multi-test 0.20.0", "cw-ownable", "cw-storage-plus", "cw-utils", @@ -1854,7 +1863,7 @@ version = "1.1.3" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-multi-test 0.18.0", + "cw-multi-test 0.20.0", "cw-storage-plus", "cw2", "cw20", @@ -1875,7 +1884,7 @@ version = "1.1.6" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-multi-test 0.18.0", + "cw-multi-test 0.20.0", "cw-storage-plus", "cw2", "cw20", @@ -1925,7 +1934,7 @@ dependencies = [ "anyhow", "cosmwasm-schema", "cosmwasm-std", - "cw-multi-test 0.18.0", + "cw-multi-test 0.20.0", "cw-storage-plus", "cw2", "schemars", @@ -1962,7 +1971,7 @@ version = "1.0.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-multi-test 0.18.0", + "cw-multi-test 0.20.0", "fee_collector", "fee_distributor", "schemars", diff --git a/Cargo.toml b/Cargo.toml index 0f85221a..9a810fd4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,16 +38,14 @@ prost = {version = "0.11.9", default-features = false, features = ["prost-derive prost-types = {version = "0.11.9", default-features = false} white-whale = { path = "./packages/white-whale" } white-whale-testing = { path = "./packages/white-whale-testing" } -cw-multi-test = { version = "0.18.0", features = ["cosmwasm_1_2", "stargate"] } +cw-multi-test = { version = "0.20.0", features = ["cosmwasm_1_2"] } uint = { version = "0.9.5"} integer-sqrt = { version = "0.1.5"} anyhow = { version = "1.0.71"} cw-controllers = { version = "1.1.0"} cw-ownable = { version = "0.5.1"} anybuf = { version = "0.3.0"} -bech32 = { version = "0.9.1"} sha2 = { version = "0.10.8"} -ecdsa = { version = "0.16.8"} # contracts whale-lair = { path = "./contracts/liquidity_hub/whale_lair" } diff --git a/contracts/liquidity_hub/vault-manager/Cargo.toml b/contracts/liquidity_hub/vault-manager/Cargo.toml index 4cb052df..e8f249fa 100644 --- a/contracts/liquidity_hub/vault-manager/Cargo.toml +++ b/contracts/liquidity_hub/vault-manager/Cargo.toml @@ -51,4 +51,3 @@ terraswap-token.workspace = true terraswap-pair.workspace = true fee_collector.workspace = true anyhow.workspace = true -bech32.workspace = true diff --git a/contracts/liquidity_hub/vault-manager/tests/common/mod.rs b/contracts/liquidity_hub/vault-manager/tests/common/mod.rs index e34b248f..9987f33e 100644 --- a/contracts/liquidity_hub/vault-manager/tests/common/mod.rs +++ b/contracts/liquidity_hub/vault-manager/tests/common/mod.rs @@ -1,168 +1,4 @@ pub mod suite; mod suite_contracts; -use bech32::{decode, encode, FromBase32, ToBase32, Variant}; -use cosmwasm_std::{ - instantiate2_address, Addr, Api, CanonicalAddr, RecoverPubkeyError, StdError, StdResult, - Storage, VerificationError, -}; -use cw_multi_test::error::AnyResult; -use cw_multi_test::AddressGenerator; -use serde::{Deserialize, Serialize}; -use sha2::digest::Update; -use sha2::{Digest, Sha256}; - pub(crate) const MOCK_CONTRACT_ADDR: &str = "migaloo1wrv0vap0sdpxt3xrdy0yg9ppsx3ppxrfhm6m3s"; - -mod test_api { - use super::*; - - pub struct MockApiBech32 { - prefix: &'static str, - } - - impl MockApiBech32 { - pub fn new(prefix: &'static str) -> Self { - Self { prefix } - } - } - - impl Api for MockApiBech32 { - fn addr_validate(&self, input: &str) -> StdResult { - let canonical = self.addr_canonicalize(input)?; - let normalized = self.addr_humanize(&canonical)?; - if input != normalized { - Err(StdError::generic_err( - "Invalid input: address not normalized", - )) - } else { - Ok(Addr::unchecked(input)) - } - } - - fn addr_canonicalize(&self, input: &str) -> StdResult { - if let Ok((prefix, decoded, Variant::Bech32)) = decode(input) { - if prefix == self.prefix { - if let Ok(bytes) = Vec::::from_base32(&decoded) { - return Ok(bytes.into()); - } - } - } - Err(StdError::generic_err("Invalid input")) - } - - fn addr_humanize(&self, canonical: &CanonicalAddr) -> StdResult { - if let Ok(encoded) = encode( - self.prefix, - canonical.as_slice().to_base32(), - Variant::Bech32, - ) { - Ok(Addr::unchecked(encoded)) - } else { - Err(StdError::generic_err("Invalid canonical address")) - } - } - - fn secp256k1_verify( - &self, - _message_hash: &[u8], - _signature: &[u8], - _public_key: &[u8], - ) -> Result { - unimplemented!() - } - - fn secp256k1_recover_pubkey( - &self, - _message_hash: &[u8], - _signature: &[u8], - _recovery_param: u8, - ) -> Result, RecoverPubkeyError> { - unimplemented!() - } - - fn ed25519_verify( - &self, - _message: &[u8], - _signature: &[u8], - _public_key: &[u8], - ) -> Result { - unimplemented!() - } - - fn ed25519_batch_verify( - &self, - _messages: &[&[u8]], - _signatures: &[&[u8]], - _public_keys: &[&[u8]], - ) -> Result { - unimplemented!() - } - - fn debug(&self, _message: &str) { - unimplemented!() - } - } - - impl MockApiBech32 { - pub fn addr_make(&self, input: &str) -> Addr { - let digest = Sha256::digest(input).to_vec(); - match encode(self.prefix, digest.to_base32(), Variant::Bech32) { - Ok(address) => Addr::unchecked(address), - Err(reason) => panic!("Generating address failed with reason: {reason}"), - } - } - } -} - -mod test_addresses { - use super::*; - - #[derive(Default)] - pub struct MockAddressGenerator; - - impl AddressGenerator for MockAddressGenerator { - fn contract_address( - &self, - api: &dyn Api, - _storage: &mut dyn Storage, - code_id: u64, - instance_id: u64, - ) -> AnyResult { - let canonical_addr = Self::instantiate_address(code_id, instance_id); - Ok(Addr::unchecked(api.addr_humanize(&canonical_addr)?)) - } - - fn predictable_contract_address( - &self, - api: &dyn Api, - _storage: &mut dyn Storage, - _code_id: u64, - _instance_id: u64, - checksum: &[u8], - creator: &CanonicalAddr, - salt: &[u8], - ) -> AnyResult { - let canonical_addr = instantiate2_address(checksum, creator, salt)?; - Ok(Addr::unchecked(api.addr_humanize(&canonical_addr)?)) - } - } - - impl MockAddressGenerator { - // non-predictable contract address generator, see `BuildContractAddressClassic` - // implementation in wasmd: https://github.com/CosmWasm/wasmd/blob/main/x/wasm/keeper/addresses.go#L35-L42 - fn instantiate_address(code_id: u64, instance_id: u64) -> CanonicalAddr { - let mut key = Vec::::new(); - key.extend_from_slice(b"wasm\0"); - key.extend_from_slice(&code_id.to_be_bytes()); - key.extend_from_slice(&instance_id.to_be_bytes()); - let module = Sha256::digest("module".as_bytes()); - Sha256::new() - .chain(module) - .chain(key) - .finalize() - .to_vec() - .into() - } - } -} diff --git a/contracts/liquidity_hub/vault-manager/tests/common/suite.rs b/contracts/liquidity_hub/vault-manager/tests/common/suite.rs index b694bee1..2b6679e3 100644 --- a/contracts/liquidity_hub/vault-manager/tests/common/suite.rs +++ b/contracts/liquidity_hub/vault-manager/tests/common/suite.rs @@ -4,6 +4,7 @@ use cosmwasm_std::{ }; use cw20::{BalanceResponse, Cw20Coin, MinterResponse}; use cw_multi_test::{App, AppBuilder, AppResponse, BankKeeper, Executor, Wasm, WasmKeeper}; +use cw_multi_test::addons::{MockAddressGenerator, MockApiBech32}; use white_whale::pool_network::asset::{Asset, AssetInfo, PairType}; use white_whale::pool_network::pair::ExecuteMsg::{ProvideLiquidity, Swap}; @@ -17,8 +18,6 @@ use crate::common::suite_contracts::{ cw20_token_contract, fee_collector_contract, pair_contract, vault_manager_contract, whale_lair_contract, }; -use crate::common::test_addresses::MockAddressGenerator; -use crate::common::test_api::MockApiBech32; pub struct TestingSuite { app: App,