Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove add_native_decimals balance check #233

Merged
merged 3 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "terraswap-factory"
version = "1.2.0"
version = "1.2.1"
authors = [
"Terraform Labs, PTE.",
"DELIGHT LABS",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use crate::contract::{CREATE_PAIR_RESPONSE, CREATE_TRIO_RESPONSE};

use cosmwasm_std::{
to_binary, wasm_execute, CosmosMsg, DepsMut, Env, MessageInfo, ReplyOn, Response, SubMsg,
WasmMsg,
Expand All @@ -10,13 +8,13 @@ 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,
Expand Down Expand Up @@ -369,15 +367,9 @@ 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<Response, ContractError> {
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![
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())]);
Expand Down
Loading