Skip to content

Commit

Permalink
fix single esdt
Browse files Browse the repository at this point in the history
  • Loading branch information
dragos-rebegea committed Jul 18, 2024
1 parent d02de51 commit df1b9de
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions bridge-proxy/src/bridge-proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ pub trait BridgeProxyContract:
.with_esdt_transfer((tx.token_id.clone(), 0, tx.amount.clone()))
.with_gas_limit(call_data.gas_limit)
.async_call_promise()
.with_callback(self.callbacks().execution_callback(tx_id))
.with_callback(self.callbacks().execution_callback(tx_id, &tx.token_id, &tx.amount))
.with_extra_gas_for_callback(DEFAULT_GAS_LIMIT_FOR_REFUND_CALLBACK)
.register_promise();
}

#[promises_callback]
fn execution_callback(&self, #[call_result] result: ManagedAsyncCallResult<()>, tx_id: usize) {
fn execution_callback(&self, #[call_result] result: ManagedAsyncCallResult<()>, tx_id: usize, token_id: &TokenIdentifier, amount: &BigUint) {
if result.is_err() {
self.refund_transaction(tx_id);
self.refund_transaction(tx_id, token_id, amount);
}
let lowest_tx_id = self.lowest_tx_id().get();
if tx_id < lowest_tx_id {
Expand All @@ -68,17 +68,15 @@ pub trait BridgeProxyContract:
self.pending_transactions().clear_entry_unchecked(tx_id);
}

fn refund_transaction(&self, tx_id: usize) {
fn refund_transaction(&self, tx_id: usize, token_id: &TokenIdentifier, amount: &BigUint) {
let tx = self.get_pending_transaction_by_id(tx_id);
let esdt_safe_addr = self.esdt_safe_address().get();

let (payment_token, payment_amount) = self.call_value().single_fungible_esdt();

self.tx()
.to(esdt_safe_addr)
.typed(bridged_tokens_wrapper::BridgedTokensWrapperProxy)
.unwrap_token_create_transaction(&tx.token_id, tx.from)
.single_esdt(&payment_token, 0, &payment_amount)
.single_esdt(&token_id, 0, &amount)

Check warning on line 79 in bridge-proxy/src/bridge-proxy.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] bridge-proxy/src/bridge-proxy.rs#L79

warning: this expression creates a reference which is immediately dereferenced by the compiler --> bridge-proxy/src/bridge-proxy.rs:79:26 | 79 | .single_esdt(&token_id, 0, &amount) | ^^^^^^^^^ help: change this to: `token_id` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `#[warn(clippy::needless_borrow)]` on by default
Raw output
bridge-proxy/src/bridge-proxy.rs:79:26:w:warning: this expression creates a reference which is immediately dereferenced by the compiler
  --> bridge-proxy/src/bridge-proxy.rs:79:26
   |
79 |             .single_esdt(&token_id, 0, &amount)
   |                          ^^^^^^^^^ help: change this to: `token_id`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
   = note: `#[warn(clippy::needless_borrow)]` on by default


__END__

Check warning on line 79 in bridge-proxy/src/bridge-proxy.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] bridge-proxy/src/bridge-proxy.rs#L79

warning: this expression creates a reference which is immediately dereferenced by the compiler --> bridge-proxy/src/bridge-proxy.rs:79:40 | 79 | .single_esdt(&token_id, 0, &amount) | ^^^^^^^ help: change this to: `amount` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
Raw output
bridge-proxy/src/bridge-proxy.rs:79:40:w:warning: this expression creates a reference which is immediately dereferenced by the compiler
  --> bridge-proxy/src/bridge-proxy.rs:79:40
   |
79 |             .single_esdt(&token_id, 0, &amount)
   |                                        ^^^^^^^ help: change this to: `amount`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow


__END__

Check warning on line 79 in bridge-proxy/src/bridge-proxy.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] bridge-proxy/src/bridge-proxy.rs#L79

warning: this expression creates a reference which is immediately dereferenced by the compiler --> bridge-proxy/src/bridge-proxy.rs:79:26 | 79 | .single_esdt(&token_id, 0, &amount) | ^^^^^^^^^ help: change this to: `token_id` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `#[warn(clippy::needless_borrow)]` on by default
Raw output
bridge-proxy/src/bridge-proxy.rs:79:26:w:warning: this expression creates a reference which is immediately dereferenced by the compiler
  --> bridge-proxy/src/bridge-proxy.rs:79:26
   |
79 |             .single_esdt(&token_id, 0, &amount)
   |                          ^^^^^^^^^ help: change this to: `token_id`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
   = note: `#[warn(clippy::needless_borrow)]` on by default


__END__

Check warning on line 79 in bridge-proxy/src/bridge-proxy.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] bridge-proxy/src/bridge-proxy.rs#L79

warning: this expression creates a reference which is immediately dereferenced by the compiler --> bridge-proxy/src/bridge-proxy.rs:79:40 | 79 | .single_esdt(&token_id, 0, &amount) | ^^^^^^^ help: change this to: `amount` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
Raw output
bridge-proxy/src/bridge-proxy.rs:79:40:w:warning: this expression creates a reference which is immediately dereferenced by the compiler
  --> bridge-proxy/src/bridge-proxy.rs:79:40
   |
79 |             .single_esdt(&token_id, 0, &amount)
   |                                        ^^^^^^^ help: change this to: `amount`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow


__END__
.sync_call();
}

Expand Down

0 comments on commit df1b9de

Please sign in to comment.