Skip to content

Commit

Permalink
bridge-proxy: Remove cooldown from refund
Browse files Browse the repository at this point in the history
  • Loading branch information
CostinCarabas committed Dec 9, 2024
1 parent 13d34c7 commit 5f05e2e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
10 changes: 1 addition & 9 deletions bridge-proxy/src/bridge-proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use transaction::{CallData, EthTransaction};
const MIN_GAS_LIMIT_FOR_SC_CALL: u64 = 10_000_000;
const MAX_GAS_LIMIT_FOR_SC_CALL: u64 = 249999999;
const DEFAULT_GAS_LIMIT_FOR_REFUND_CALLBACK: u64 = 20_000_000; // 20 million
const DELAY_BEFORE_OWNER_CAN_REFUND_TRANSACTION: u64 = 300;

#[multiversx_sc::contract]
pub trait BridgeProxyContract:
Expand Down Expand Up @@ -113,13 +112,6 @@ pub trait BridgeProxyContract:

#[endpoint(executeRefundTransaction)]
fn execute_refund_transaction(&self, tx_id: usize) {
let tx_start_round = self.ongoing_execution(tx_id).get();
let current_block_round = self.blockchain().get_block_round();
require!(
current_block_round - tx_start_round > DELAY_BEFORE_OWNER_CAN_REFUND_TRANSACTION,
"Refund executed too early!"
);

let tx = self.get_refund_transaction_by_id(tx_id);
let esdt_safe_contract_address = self.get_esdt_safe_address();
let unwrapped_token = self.unwrap_token(&tx.token_id, tx_id);
Expand Down Expand Up @@ -184,10 +176,10 @@ pub trait BridgeProxyContract:
}

fn finish_refund(&self, tx_id: usize) {
self.refund_transactions().remove(&tx_id);
self.ongoing_execution(tx_id).clear();
self.payments(tx_id).clear();
self.batch_id(tx_id).clear();
self.refund_transactions().remove(&tx_id);
}

fn add_pending_tx_to_refund(&self, tx_id: usize) {
Expand Down
11 changes: 0 additions & 11 deletions bridge-proxy/tests/bridge_proxy_blackbox_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -955,17 +955,6 @@ fn bridge_proxy_refund_tx_test() {
.check_account(USER_ADDRESS)
.esdt_balance(BRIDGE_TOKEN_ID, BigUint::from(INITIAL_BALANCE));

test.world
.tx()
.from(USER_ADDRESS)
.to(BRIDGE_PROXY_ADDRESS)
.typed(bridge_proxy_contract_proxy::BridgeProxyContractProxy)
.execute_refund_transaction(1u32)
.returns(ExpectError(4, "Refund executed too early!"))
.run();

test.set_block_round(DELAY_BEFORE_OWNER_CAN_REFUND_TRANSACTION + 1);

test.world
.tx()
.from(USER_ADDRESS)
Expand Down

0 comments on commit 5f05e2e

Please sign in to comment.