From d3123dc6cf9640d1d376abdd59bf34d5411967bb Mon Sep 17 00:00:00 2001 From: Dorin Marian Iancu Date: Fri, 15 Nov 2024 13:26:50 +0200 Subject: [PATCH 1/2] change disable add liq code --- common/modules/disable-add-liq/src/lib.rs | 16 ++++++++-------- dex/pair/tests/pair_rs_test.rs | 4 +++- locked-asset/proxy_dex/src/lib.rs | 9 +++------ .../proxy_dex/tests/proxy_dex_test_setup/mod.rs | 3 +++ 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/common/modules/disable-add-liq/src/lib.rs b/common/modules/disable-add-liq/src/lib.rs index 47fba58c5..63bf5e6e5 100644 --- a/common/modules/disable-add-liq/src/lib.rs +++ b/common/modules/disable-add-liq/src/lib.rs @@ -2,31 +2,31 @@ multiversx_sc::imports!(); -pub const ADD_LIQ_ENABLED: bool = false; -pub const ADD_LIQ_DISABLED: bool = true; +pub const ADD_LIQ_ENABLED: bool = true; +pub const ADD_LIQ_DISABLED: bool = false; #[multiversx_sc::module] pub trait DisableAddLiqModule { #[only_owner] #[endpoint(enableAddLiq)] fn enable_add_liq(&self) { - self.add_liq_disabled().set(ADD_LIQ_ENABLED); + self.add_liq_enabled().set(ADD_LIQ_ENABLED); } #[only_owner] #[endpoint(disableAddLiq)] fn disable_add_liq(&self) { - self.add_liq_disabled().set(ADD_LIQ_DISABLED); + self.add_liq_enabled().set(ADD_LIQ_DISABLED); } fn require_add_liq_enabled(&self) { require!( - self.add_liq_disabled().get() == ADD_LIQ_ENABLED, + self.add_liq_enabled().get() == ADD_LIQ_ENABLED, "Add Liquidity is disabled" ); } - #[view(isAddLiqDisabled)] - #[storage_mapper("addLiqDisabled")] - fn add_liq_disabled(&self) -> SingleValueMapper; + #[view(isAddLiqEnabled)] + #[storage_mapper("addLiqEnabled")] + fn add_liq_enabled(&self) -> SingleValueMapper; } diff --git a/dex/pair/tests/pair_rs_test.rs b/dex/pair/tests/pair_rs_test.rs index 01ee97bc5..39edfb746 100644 --- a/dex/pair/tests/pair_rs_test.rs +++ b/dex/pair/tests/pair_rs_test.rs @@ -1,7 +1,7 @@ #![allow(deprecated)] mod pair_setup; -use disable_add_liq::DisableAddLiqModule; +use disable_add_liq::{DisableAddLiqModule, ADD_LIQ_ENABLED}; use fees_collector::{ config::ConfigModule, fees_accumulation::FeesAccumulationModule, FeesCollector, }; @@ -1293,6 +1293,8 @@ fn add_liquidity_through_simple_lock_proxy() { .b_mock .execute_tx(&locking_owner, &locking_sc_wrapper, &rust_zero, |sc| { sc.init(); + sc.add_liq_enabled().set(ADD_LIQ_ENABLED); + sc.locked_token() .set_token_id(managed_token_id!(LOCKED_TOKEN_ID)); sc.add_lp_to_whitelist( diff --git a/locked-asset/proxy_dex/src/lib.rs b/locked-asset/proxy_dex/src/lib.rs index ee5672a04..7ec982ecc 100644 --- a/locked-asset/proxy_dex/src/lib.rs +++ b/locked-asset/proxy_dex/src/lib.rs @@ -49,12 +49,9 @@ pub trait ProxyDexImpl: self.require_sc_address(&old_factory_address); self.require_sc_address(&energy_factory_address); - self.old_locked_token_id() - .set_if_empty(&old_locked_token_id); - self.old_factory_address() - .set_if_empty(&old_factory_address); - self.energy_factory_address() - .set_if_empty(&energy_factory_address); + self.old_locked_token_id().set(&old_locked_token_id); + self.old_factory_address().set(&old_factory_address); + self.energy_factory_address().set(&energy_factory_address); } #[upgrade] diff --git a/locked-asset/proxy_dex/tests/proxy_dex_test_setup/mod.rs b/locked-asset/proxy_dex/tests/proxy_dex_test_setup/mod.rs index 73dd9d9c9..90db558e1 100644 --- a/locked-asset/proxy_dex/tests/proxy_dex_test_setup/mod.rs +++ b/locked-asset/proxy_dex/tests/proxy_dex_test_setup/mod.rs @@ -3,6 +3,7 @@ use common_structs::{LockedAssetTokenAttributesEx, UnlockMilestoneEx, UnlockScheduleEx}; use config::ConfigModule; +use disable_add_liq::{DisableAddLiqModule, ADD_LIQ_ENABLED}; use energy_factory::{locked_token_transfer::LockedTokenTransferModule, SimpleLockEnergy}; use energy_query::EnergyQueryModule; use farm_boosted_yields::boosted_yields_factors::BoostedYieldsFactorsModule; @@ -455,6 +456,8 @@ where managed_address!(simple_lock_addr), ); + sc.add_liq_enabled().set(ADD_LIQ_ENABLED); + sc.wrapped_lp_token() .set_token_id(managed_token_id!(WRAPPED_LP_TOKEN_ID)); sc.wrapped_farm_token() From 12c7a3ab97bccfe1f1969563a5d6a78a850c43ac Mon Sep 17 00:00:00 2001 From: Dorin Marian Iancu Date: Fri, 15 Nov 2024 13:29:13 +0200 Subject: [PATCH 2/2] build --- locked-asset/proxy_dex/wasm/src/lib.rs | 2 +- locked-asset/simple-lock/wasm/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/locked-asset/proxy_dex/wasm/src/lib.rs b/locked-asset/proxy_dex/wasm/src/lib.rs index e5b1b3038..575932340 100644 --- a/locked-asset/proxy_dex/wasm/src/lib.rs +++ b/locked-asset/proxy_dex/wasm/src/lib.rs @@ -52,7 +52,7 @@ multiversx_sc_wasm_adapter::endpoints! { isSCAddressWhitelisted => is_sc_address_whitelisted enableAddLiq => enable_add_liq disableAddLiq => disable_add_liq - isAddLiqDisabled => add_liq_disabled + isAddLiqEnabled => add_liq_enabled ) } diff --git a/locked-asset/simple-lock/wasm/src/lib.rs b/locked-asset/simple-lock/wasm/src/lib.rs index 6c74ebe77..09c1ec3ad 100644 --- a/locked-asset/simple-lock/wasm/src/lib.rs +++ b/locked-asset/simple-lock/wasm/src/lib.rs @@ -41,7 +41,7 @@ multiversx_sc_wasm_adapter::endpoints! { getFarmProxyTokenId => farm_proxy_token enableAddLiq => enable_add_liq disableAddLiq => disable_add_liq - isAddLiqDisabled => add_liq_disabled + isAddLiqEnabled => add_liq_enabled ) }