From 21db0a8f698c4ddd9cace3331d20f2fa0b20f295 Mon Sep 17 00:00:00 2001 From: Kerber0x Date: Mon, 18 Dec 2023 17:05:24 +0000 Subject: [PATCH 1/3] chore: since the pool factory is permissioned, remove the add_native_decimals check to allow other accounts via authz call this message without sending funds --- .../terraswap_factory/src/commands.rs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/contracts/liquidity_hub/pool-network/terraswap_factory/src/commands.rs b/contracts/liquidity_hub/pool-network/terraswap_factory/src/commands.rs index 28c82951..886e0d52 100644 --- a/contracts/liquidity_hub/pool-network/terraswap_factory/src/commands.rs +++ b/contracts/liquidity_hub/pool-network/terraswap_factory/src/commands.rs @@ -1,26 +1,24 @@ -use crate::contract::{CREATE_PAIR_RESPONSE, CREATE_TRIO_RESPONSE}; - use cosmwasm_std::{ - to_binary, wasm_execute, CosmosMsg, DepsMut, Env, MessageInfo, ReplyOn, Response, SubMsg, + CosmosMsg, DepsMut, Env, MessageInfo, ReplyOn, Response, SubMsg, to_binary, wasm_execute, WasmMsg, }; use white_whale::pool_network; +use white_whale::pool_network::{pair, trio}; use white_whale::pool_network::asset::{AssetInfo, PairType}; use white_whale::pool_network::pair::{ FeatureToggle, InstantiateMsg as PairInstantiateMsg, MigrateMsg as PairMigrateMsg, PoolFee, }; -use white_whale::pool_network::querier::query_balance; use white_whale::pool_network::trio::{ FeatureToggle as TrioFeatureToggle, InstantiateMsg as TrioInstantiateMsg, MigrateMsg as TrioMigrateMsg, PoolFee as TrioPoolFee, RampAmp, }; -use white_whale::pool_network::{pair, trio}; +use crate::contract::{CREATE_PAIR_RESPONSE, CREATE_TRIO_RESPONSE}; use crate::error::ContractError; use crate::state::{ - add_allow_native_token, pair_key, trio_key, Config, TmpPairInfo, TmpTrioInfo, CONFIG, PAIRS, - TMP_PAIR_INFO, TMP_TRIO_INFO, TRIOS, + add_allow_native_token, Config, CONFIG, pair_key, PAIRS, TMP_PAIR_INFO, TMP_TRIO_INFO, TmpPairInfo, + TmpTrioInfo, trio_key, TRIOS, }; /// Updates the contract's [Config] @@ -373,11 +371,6 @@ pub fn add_native_token_decimals( denom: String, decimals: u8, ) -> Result { - let balance = query_balance(&deps.querier, env.contract.address, denom.to_string())?; - if balance.is_zero() { - return Err(ContractError::InvalidVerificationBalance {}); - } - add_allow_native_token(deps.storage, denom.to_string(), decimals)?; Ok(Response::new().add_attributes(vec![ From 4757e5ee3d8964a5ce3040faed7d05480a61b2eb Mon Sep 17 00:00:00 2001 From: Kerber0x Date: Mon, 18 Dec 2023 17:07:50 +0000 Subject: [PATCH 2/3] chore: bump pool factory version --- Cargo.lock | 2 +- .../liquidity_hub/pool-network/terraswap_factory/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c7293902..5c16c79d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1417,7 +1417,7 @@ dependencies = [ [[package]] name = "terraswap-factory" -version = "1.2.0" +version = "1.2.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", diff --git a/contracts/liquidity_hub/pool-network/terraswap_factory/Cargo.toml b/contracts/liquidity_hub/pool-network/terraswap_factory/Cargo.toml index ffd10b12..e7b4097a 100644 --- a/contracts/liquidity_hub/pool-network/terraswap_factory/Cargo.toml +++ b/contracts/liquidity_hub/pool-network/terraswap_factory/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "terraswap-factory" -version = "1.2.0" +version = "1.2.1" authors = [ "Terraform Labs, PTE.", "DELIGHT LABS", From a5ee21c38d32b73fb4dbb86e99b179d6f920ea94 Mon Sep 17 00:00:00 2001 From: Kerber0x Date: Mon, 18 Dec 2023 17:10:18 +0000 Subject: [PATCH 3/3] test: remove irrelevant add_native_decimals test --- .../terraswap_factory/src/commands.rs | 9 ++++----- .../terraswap_factory/src/contract.rs | 2 +- .../terraswap_factory/src/testing.rs | 20 ------------------- 3 files changed, 5 insertions(+), 26 deletions(-) diff --git a/contracts/liquidity_hub/pool-network/terraswap_factory/src/commands.rs b/contracts/liquidity_hub/pool-network/terraswap_factory/src/commands.rs index 886e0d52..bfcff909 100644 --- a/contracts/liquidity_hub/pool-network/terraswap_factory/src/commands.rs +++ b/contracts/liquidity_hub/pool-network/terraswap_factory/src/commands.rs @@ -1,10 +1,9 @@ use cosmwasm_std::{ - CosmosMsg, DepsMut, Env, MessageInfo, ReplyOn, Response, SubMsg, to_binary, wasm_execute, + to_binary, wasm_execute, CosmosMsg, DepsMut, Env, MessageInfo, ReplyOn, Response, SubMsg, WasmMsg, }; use white_whale::pool_network; -use white_whale::pool_network::{pair, trio}; use white_whale::pool_network::asset::{AssetInfo, PairType}; use white_whale::pool_network::pair::{ FeatureToggle, InstantiateMsg as PairInstantiateMsg, MigrateMsg as PairMigrateMsg, PoolFee, @@ -13,12 +12,13 @@ use white_whale::pool_network::trio::{ FeatureToggle as TrioFeatureToggle, InstantiateMsg as TrioInstantiateMsg, MigrateMsg as TrioMigrateMsg, PoolFee as TrioPoolFee, RampAmp, }; +use white_whale::pool_network::{pair, trio}; use crate::contract::{CREATE_PAIR_RESPONSE, CREATE_TRIO_RESPONSE}; use crate::error::ContractError; use crate::state::{ - add_allow_native_token, Config, CONFIG, pair_key, PAIRS, TMP_PAIR_INFO, TMP_TRIO_INFO, TmpPairInfo, - TmpTrioInfo, trio_key, TRIOS, + add_allow_native_token, pair_key, trio_key, Config, TmpPairInfo, TmpTrioInfo, CONFIG, PAIRS, + TMP_PAIR_INFO, TMP_TRIO_INFO, TRIOS, }; /// Updates the contract's [Config] @@ -367,7 +367,6 @@ pub fn remove_trio( /// Adds native/ibc token with decimals to the factory's whitelist so it can create pairs with that asset pub fn add_native_token_decimals( deps: DepsMut, - env: Env, denom: String, decimals: u8, ) -> Result { diff --git a/contracts/liquidity_hub/pool-network/terraswap_factory/src/contract.rs b/contracts/liquidity_hub/pool-network/terraswap_factory/src/contract.rs index 04c0aa8d..f9e7d075 100644 --- a/contracts/liquidity_hub/pool-network/terraswap_factory/src/contract.rs +++ b/contracts/liquidity_hub/pool-network/terraswap_factory/src/contract.rs @@ -105,7 +105,7 @@ pub fn execute( ExecuteMsg::RemovePair { asset_infos } => commands::remove_pair(deps, env, asset_infos), ExecuteMsg::RemoveTrio { asset_infos } => commands::remove_trio(deps, env, asset_infos), ExecuteMsg::AddNativeTokenDecimals { denom, decimals } => { - commands::add_native_token_decimals(deps, env, denom, decimals) + commands::add_native_token_decimals(deps, denom, decimals) } ExecuteMsg::MigratePair { contract, code_id } => { commands::execute_migrate_pair(deps, contract, code_id) diff --git a/contracts/liquidity_hub/pool-network/terraswap_factory/src/testing.rs b/contracts/liquidity_hub/pool-network/terraswap_factory/src/testing.rs index 3aeeb81c..991753da 100644 --- a/contracts/liquidity_hub/pool-network/terraswap_factory/src/testing.rs +++ b/contracts/liquidity_hub/pool-network/terraswap_factory/src/testing.rs @@ -1240,26 +1240,6 @@ fn failed_add_allow_native_token_with_non_admin() { } } -#[test] -fn failed_add_allow_native_token_with_zero_factory_balance() { - let mut deps = mock_dependencies(&[coin(0u128, "uluna".to_string())]); - deps = init(deps); - - let msg = ExecuteMsg::AddNativeTokenDecimals { - denom: "uluna".to_string(), - decimals: 6u8, - }; - - let info = mock_info("addr0000", &[]); - - let res = execute(deps.as_mut(), mock_env(), info, msg); - match res { - Ok(_) => panic!("should return ContractError::InvalidVerificationBalance"), - Err(ContractError::InvalidVerificationBalance {}) => (), - _ => panic!("should return ContractError::InvalidVerificationBalance"), - } -} - #[test] fn append_add_allow_native_token_with_already_exist_token() { let mut deps = mock_dependencies(&[coin(1u128, "uluna".to_string())]);