Skip to content

Commit

Permalink
Merge pull request #244 from multiversx/merge-v3-to-v3.5-29.10.2024
Browse files Browse the repository at this point in the history
Merge v3 to v3.5 29.10.2024
  • Loading branch information
evelinemolnar authored Oct 30, 2024
2 parents eb7fa9d + be4c206 commit 7b7974a
Show file tree
Hide file tree
Showing 4 changed files with 271 additions and 40 deletions.
8 changes: 6 additions & 2 deletions bridge-proxy/src/bridge-proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ 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_CANCEL_TRANSACTION: u64 = 300;
const MIN_GAS_TO_SAVE_PROGRESS: u64 = 100_000;
const MIN_GAS_TO_SAVE_PROGRESS: u64 = 1_000_000;

#[multiversx_sc::contract]
pub trait BridgeProxyContract:
Expand Down Expand Up @@ -158,9 +158,13 @@ pub trait BridgeProxyContract:
let payment = self.payments(tx_id).get();
let bridged_tokens_wrapper_address = self.bridged_tokens_wrapper_address().get();

if requested_token == &payment.token_identifier {
return payment;
}

let transfers = self
.tx()
.to(bridged_tokens_wrapper_address)
.to(&bridged_tokens_wrapper_address)
.typed(bridged_tokens_wrapper_proxy::BridgedTokensWrapperProxy)
.unwrap_token(requested_token)
.single_esdt(
Expand Down
25 changes: 9 additions & 16 deletions bridged-tokens-wrapper/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,26 +248,20 @@ pub trait BridgedTokensWrapper:
requested_token: TokenIdentifier,
to: EthAddress<Self::Api>,
) {
let (payment_token, payment_amount) = self.call_value().single_fungible_esdt();
let universal_token_id = self
.chain_specific_to_universal_mapping(&requested_token)
.get();

let converted_amount = if universal_token_id == payment_token {
self.unwrap_token_common(&requested_token)
} else {
payment_amount
};
let converted_amount = self.unwrap_token_common(&requested_token);

let caller = self.blockchain().get_caller();
self.tx()
.to(self.esdt_safe_contract_address().get())
.typed(esdt_safe_proxy::EsdtSafeProxy)
.create_transaction(to, OptionalValue::Some(esdt_safe_proxy::RefundInfo {
address: caller,
initial_batch_id: 0,
initial_nonce: 0,
}))
.create_transaction(
to,
OptionalValue::Some(esdt_safe_proxy::RefundInfo {
address: caller,
initial_batch_id: 0,
initial_nonce: 0,
}),
)
.single_esdt(&requested_token, 0, &converted_amount)
.sync_call();
}
Expand Down Expand Up @@ -347,5 +341,4 @@ pub trait BridgedTokensWrapper:
#[view(getEsdtSafeContractAddress)]
#[storage_mapper("esdtSafeContractAddress")]
fn esdt_safe_contract_address(&self) -> SingleValueMapper<ManagedAddress>;

}
14 changes: 9 additions & 5 deletions esdt-safe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub struct TransactionDetails<Api: ManagedTypeApi> {
pub struct RefundInfo<M: ManagedTypeApi> {
pub address: ManagedAddress<M>,
pub initial_batch_id: u64,
pub initial_nonce: u64
pub initial_nonce: u64,
}

#[multiversx_sc::contract]
Expand Down Expand Up @@ -91,8 +91,8 @@ pub trait EsdtSafe:
.set(&fee_estimator_contract_address);
self.multi_transfer_contract_address()
.set(&multi_transfer_contract_address);
self.bridge_proxy_contract_address().
set(&bridge_proxy_contract_address);
self.bridge_proxy_contract_address()
.set(&bridge_proxy_contract_address);

self.eth_tx_gas_limit().set(&eth_tx_gas_limit);

Expand Down Expand Up @@ -257,7 +257,7 @@ pub trait EsdtSafe:
});
} else {
self.total_balances(&refund_token_id).update(|total| {
*total -= &actual_bridged_amount;
*total += &actual_bridged_amount;
});
}
}
Expand Down Expand Up @@ -304,7 +304,11 @@ pub trait EsdtSafe:
sc_panic!("Cannot specify a refund address from this caller");
}
}
OptionalValue::None => RefundInfo{ address: caller, initial_batch_id: 0, initial_nonce: 0},
OptionalValue::None => RefundInfo {
address: caller,
initial_batch_id: 0,
initial_nonce: 0,
},
};

self.accumulated_transaction_fees(&payment_token)
Expand Down
Loading

0 comments on commit 7b7974a

Please sign in to comment.