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

Remove checks in simple lock legacy SC #923

Merged
merged 4 commits into from
Jun 19, 2024
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
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
Loading