Skip to content

Commit

Permalink
Merge pull request #923 from multiversx/simple-lock-legacy-remove-checks
Browse files Browse the repository at this point in the history
Remove checks in simple lock legacy SC
  • Loading branch information
CostinCarabas authored Jun 19, 2024
2 parents b279755 + 07f1db2 commit a255383
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 78 deletions.
24 changes: 0 additions & 24 deletions legacy-contracts/simple-lock-legacy/src/proxy_lp.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
multiversx_sc::imports!();
multiversx_sc::derive_imports!();

use crate::{error_messages::CANNOT_UNLOCK_YET_ERR_MSG, locked_token::LockedTokenAttributes};

#[derive(TypeAbi, TopEncode, TopDecode, NestedEncode, NestedDecode, PartialEq, Debug)]
pub struct LpProxyTokenAttributes<M: ManagedTypeApi> {
pub lp_token_id: TokenIdentifier<M>,
Expand Down Expand Up @@ -55,28 +53,6 @@ pub trait ProxyLpModule: crate::locked_token::LockedTokenModule {
let lp_proxy_token_attributes: LpProxyTokenAttributes<Self::Api> =
lp_proxy_token_mapper.get_token_attributes(token_nonce);

let current_epoch = self.blockchain().get_block_epoch();
if lp_proxy_token_attributes.first_token_locked_nonce > 0 {
let token_attributes: LockedTokenAttributes<Self::Api> = self
.locked_token()
.get_token_attributes(lp_proxy_token_attributes.first_token_locked_nonce);

require!(
current_epoch >= token_attributes.unlock_epoch,
CANNOT_UNLOCK_YET_ERR_MSG
);
}
if lp_proxy_token_attributes.second_token_locked_nonce > 0 {
let token_attributes: LockedTokenAttributes<Self::Api> = self
.locked_token()
.get_token_attributes(lp_proxy_token_attributes.second_token_locked_nonce);

require!(
current_epoch >= token_attributes.unlock_epoch,
CANNOT_UNLOCK_YET_ERR_MSG
);
}

lp_proxy_token_attributes.lp_token_id
}

Expand Down
54 changes: 0 additions & 54 deletions legacy-contracts/simple-lock-legacy/tests/rust_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,6 @@ fn unlock_token_test() {
b_mock.check_esdt_balance(sc_wrapper.address_ref(), FREE_TOKEN_ID, &lock_amount);
b_mock.check_esdt_balance(&user_addr, FREE_TOKEN_ID, &rust_zero);

// try unlock too early
b_mock
.execute_esdt_transfer(
&user_addr,
&sc_wrapper,
LOCKED_TOKEN_ID,
lock_token_nonce,
&lock_amount,
|sc| {
sc.unlock_tokens_endpoint(OptionalValue::None);
},
)
.assert_user_error("Cannot unlock yet");

// unlock ok
b_mock.set_block_epoch(10);
b_mock
Expand Down Expand Up @@ -264,20 +250,6 @@ fn exit_lp_test() {
Some(&locked_lp_token_attributes),
);

// try unlock too early
b_mock
.execute_esdt_transfer(
&user_addr,
&sc_wrapper,
LP_PROXY_TOKEN_ID,
lock_token_nonce,
&lock_amount,
|sc| {
sc.remove_liquidity_locked_token(managed_biguint!(0u64), managed_biguint!(0u64));
},
)
.assert_user_error("Cannot unlock yet");

// unlock ok
b_mock.set_block_epoch(10);
b_mock
Expand Down Expand Up @@ -460,32 +432,6 @@ fn exit_farm_test() {
Some(&farm_attributes),
);

// try unlock too early
b_mock
.execute_esdt_transfer(
&user_addr,
&sc_wrapper,
FARM_PROXY_TOKEN_ID,
lock_token_nonce,
&lock_amount,
|sc| {
sc.farm_claim_rewards_locked_token();
},
)
.assert_user_error("Cannot unlock yet");
b_mock
.execute_esdt_transfer(
&user_addr,
&sc_wrapper,
FARM_PROXY_TOKEN_ID,
lock_token_nonce,
&lock_amount,
|sc| {
sc.exit_farm_locked_token();
},
)
.assert_user_error("Cannot unlock yet");

// unlock ok
let half_lock_amount = rust_biguint!(1_000u64);
b_mock.set_block_epoch(10);
Expand Down

0 comments on commit a255383

Please sign in to comment.