Skip to content

Commit

Permalink
use GetCurrentESDTNFTNonce VM endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
psorinionut committed Sep 21, 2023
1 parent 4303c0c commit 767f452
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 29 deletions.
18 changes: 3 additions & 15 deletions dex/farm/src/base_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
17 changes: 3 additions & 14 deletions farm-staking/farm-staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down

0 comments on commit 767f452

Please sign in to comment.