From 767f452b63295451a849f07bd8a3dba30fa41990 Mon Sep 17 00:00:00 2001 From: Sorin Petreasca Date: Thu, 21 Sep 2023 11:32:51 +0300 Subject: [PATCH] use GetCurrentESDTNFTNonce VM endpoint --- dex/farm/src/base_functions.rs | 18 +++--------------- farm-staking/farm-staking/src/lib.rs | 17 +++-------------- 2 files changed, 6 insertions(+), 29 deletions(-) diff --git a/dex/farm/src/base_functions.rs b/dex/farm/src/base_functions.rs index fe95ce920..bbe12a49f 100644 --- a/dex/farm/src/base_functions.rs +++ b/dex/farm/src/base_functions.rs @@ -246,22 +246,10 @@ pub trait BaseFunctionsModule: let farm_token_mapper = self.farm_token(); - let attributes = FarmTokenAttributes { - reward_per_share: BigUint::zero(), - entering_epoch: 0, - compounded_reward: BigUint::zero(), - current_farm_amount: BigUint::zero(), - original_owner: self.blockchain().get_sc_address(), - }; - let migration_farm_token_nonce = if farm_token_mapper.get_token_state().is_set() { - let migration_farm_token = - farm_token_mapper.nft_create(BigUint::from(1u64), &attributes); - farm_token_mapper.nft_burn( - migration_farm_token.token_nonce, - &migration_farm_token.amount, - ); - migration_farm_token.token_nonce + let token_identifier = farm_token_mapper.get_token_id_ref(); + self.blockchain() + .get_current_esdt_nft_nonce(&self.blockchain().get_sc_address(), token_identifier) } else { DEFAULT_FARM_POSITION_MIGRATION_NONCE }; diff --git a/farm-staking/farm-staking/src/lib.rs b/farm-staking/farm-staking/src/lib.rs index 81c4d4d1b..26622a02b 100644 --- a/farm-staking/farm-staking/src/lib.rs +++ b/farm-staking/farm-staking/src/lib.rs @@ -157,21 +157,10 @@ pub trait FarmStaking: let farm_token_mapper = self.farm_token(); - let attributes = StakingFarmTokenAttributes { - reward_per_share: BigUint::zero(), - compounded_reward: BigUint::zero(), - current_farm_amount: BigUint::zero(), - original_owner: self.blockchain().get_sc_address(), - }; - let migration_farm_token_nonce = if farm_token_mapper.get_token_state().is_set() { - let migration_farm_token = - farm_token_mapper.nft_create(BigUint::from(1u64), &attributes); - farm_token_mapper.nft_burn( - migration_farm_token.token_nonce, - &migration_farm_token.amount, - ); - migration_farm_token.token_nonce + let token_identifier = farm_token_mapper.get_token_id_ref(); + self.blockchain() + .get_current_esdt_nft_nonce(&self.blockchain().get_sc_address(), token_identifier) } else { DEFAULT_FARM_POSITION_MIGRATION_NONCE };