Skip to content

Commit

Permalink
VM Rust - fix transferValueOnly in async call
Browse files Browse the repository at this point in the history
  • Loading branch information
BiancaIalangi committed Nov 26, 2024
1 parent 6a6ff5c commit 4acebb0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions chain/vm/src/tx_execution/exec_general_tx.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use num_bigint::BigUint;

Check failure on line 1 in chain/vm/src/tx_execution/exec_general_tx.rs

View workflow job for this annotation

GitHub Actions / Template tool test - current (unreleased) templates

unused import: `num_bigint::BigUint`

Check failure on line 1 in chain/vm/src/tx_execution/exec_general_tx.rs

View workflow job for this annotation

GitHub Actions / Template tool test - released templates

unused import: `num_bigint::BigUint`

Check failure on line 1 in chain/vm/src/tx_execution/exec_general_tx.rs

View workflow job for this annotation

GitHub Actions / Proxy compare - newly generated vs present in file tree

unused import: `num_bigint::BigUint`

Check failure on line 1 in chain/vm/src/tx_execution/exec_general_tx.rs

View workflow job for this annotation

GitHub Actions / Plotter tests

unused import: `num_bigint::BigUint`

Check failure on line 1 in chain/vm/src/tx_execution/exec_general_tx.rs

View workflow job for this annotation

GitHub Actions / Contracts / Wasm tests

unused import: `num_bigint::BigUint`

Check failure on line 1 in chain/vm/src/tx_execution/exec_general_tx.rs

View workflow job for this annotation

GitHub Actions / Contracts / Interactor tests

unused import: `num_bigint::BigUint`

Check failure on line 1 in chain/vm/src/tx_execution/exec_general_tx.rs

View workflow job for this annotation

GitHub Actions / Contracts (nightly) / Test Coverage

unused import: `num_bigint::BigUint`

Check warning on line 1 in chain/vm/src/tx_execution/exec_general_tx.rs

View workflow job for this annotation

GitHub Actions / Contracts / Rust tests

unused import: `num_bigint::BigUint`

Check warning on line 1 in chain/vm/src/tx_execution/exec_general_tx.rs

View workflow job for this annotation

GitHub Actions / Contracts (nightly) / Rust tests

unused import: `num_bigint::BigUint`

Check failure on line 1 in chain/vm/src/tx_execution/exec_general_tx.rs

View workflow job for this annotation

GitHub Actions / Contracts / Test Coverage

unused import: `num_bigint::BigUint`

Check failure on line 1 in chain/vm/src/tx_execution/exec_general_tx.rs

View workflow job for this annotation

GitHub Actions / Contracts (nightly) / Wasm tests

unused import: `num_bigint::BigUint`

Check warning on line 1 in chain/vm/src/tx_execution/exec_general_tx.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] chain/vm/src/tx_execution/exec_general_tx.rs#L1

warning: unused import: `num_bigint::BigUint` --> chain/vm/src/tx_execution/exec_general_tx.rs:1:5 | 1 | use num_bigint::BigUint; | ^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default
Raw output
chain/vm/src/tx_execution/exec_general_tx.rs:1:5:w:warning: unused import: `num_bigint::BigUint`
 --> chain/vm/src/tx_execution/exec_general_tx.rs:1:5
  |
1 | use num_bigint::BigUint;
  |     ^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default


__END__

Check warning on line 1 in chain/vm/src/tx_execution/exec_general_tx.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] chain/vm/src/tx_execution/exec_general_tx.rs#L1

warning: unused import: `num_bigint::BigUint` --> chain/vm/src/tx_execution/exec_general_tx.rs:1:5 | 1 | use num_bigint::BigUint; | ^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default
Raw output
chain/vm/src/tx_execution/exec_general_tx.rs:1:5:w:warning: unused import: `num_bigint::BigUint`
 --> chain/vm/src/tx_execution/exec_general_tx.rs:1:5
  |
1 | use num_bigint::BigUint;
  |     ^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default


__END__
use num_traits::Zero;

use crate::{
Expand Down Expand Up @@ -52,6 +53,19 @@ pub(crate) fn create_transfer_value_log(tx_input: &TxInput, call_type: CallType)
let mut data = vec![call_type.to_log_bytes(), tx_input.func_name.to_bytes()];
data.append(&mut tx_input.args.clone());

if tx_input.esdt_values.is_empty() {

Check warning on line 56 in chain/vm/src/tx_execution/exec_general_tx.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] chain/vm/src/tx_execution/exec_general_tx.rs#L56

warning: this `if` statement can be collapsed --> chain/vm/src/tx_execution/exec_general_tx.rs:56:5 | 56 | / if tx_input.esdt_values.is_empty() { 57 | | if !tx_input.callback_payments.egld_value.is_zero() 58 | | && tx_input.call_type == CallType::AsyncCallback 59 | | { ... | 66 | | } 67 | | } | |_____^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if = note: `#[warn(clippy::collapsible_if)]` on by default help: collapse nested if block | 56 ~ if tx_input.esdt_values.is_empty() && !tx_input.callback_payments.egld_value.is_zero() && tx_input.call_type == CallType::AsyncCallback { 57 + return TxLog { 58 + address: tx_input.from.clone(), 59 + endpoint: "transferValueOnly".into(), 60 + topics: vec![b"".to_vec(), tx_input.to.to_vec()], 61 + data, 62 + }; 63 + } |
Raw output
chain/vm/src/tx_execution/exec_general_tx.rs:56:5:w:warning: this `if` statement can be collapsed
  --> chain/vm/src/tx_execution/exec_general_tx.rs:56:5
   |
56 | /     if tx_input.esdt_values.is_empty() {
57 | |         if !tx_input.callback_payments.egld_value.is_zero()
58 | |             && tx_input.call_type == CallType::AsyncCallback
59 | |         {
...  |
66 | |         }
67 | |     }
   | |_____^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
   = note: `#[warn(clippy::collapsible_if)]` on by default
help: collapse nested if block
   |
56 ~     if tx_input.esdt_values.is_empty() && !tx_input.callback_payments.egld_value.is_zero() && tx_input.call_type == CallType::AsyncCallback {
57 +         return TxLog {
58 +             address: tx_input.from.clone(),
59 +             endpoint: "transferValueOnly".into(),
60 +             topics: vec![b"".to_vec(), tx_input.to.to_vec()],
61 +             data,
62 +         };
63 +     }
   |


__END__

Check warning on line 56 in chain/vm/src/tx_execution/exec_general_tx.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] chain/vm/src/tx_execution/exec_general_tx.rs#L56

warning: this `if` statement can be collapsed --> chain/vm/src/tx_execution/exec_general_tx.rs:56:5 | 56 | / if tx_input.esdt_values.is_empty() { 57 | | if !tx_input.callback_payments.egld_value.is_zero() 58 | | && tx_input.call_type == CallType::AsyncCallback 59 | | { ... | 66 | | } 67 | | } | |_____^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if = note: `#[warn(clippy::collapsible_if)]` on by default help: collapse nested if block | 56 ~ if tx_input.esdt_values.is_empty() && !tx_input.callback_payments.egld_value.is_zero() && tx_input.call_type == CallType::AsyncCallback { 57 + return TxLog { 58 + address: tx_input.from.clone(), 59 + endpoint: "transferValueOnly".into(), 60 + topics: vec![b"".to_vec(), tx_input.to.to_vec()], 61 + data, 62 + }; 63 + } |
Raw output
chain/vm/src/tx_execution/exec_general_tx.rs:56:5:w:warning: this `if` statement can be collapsed
  --> chain/vm/src/tx_execution/exec_general_tx.rs:56:5
   |
56 | /     if tx_input.esdt_values.is_empty() {
57 | |         if !tx_input.callback_payments.egld_value.is_zero()
58 | |             && tx_input.call_type == CallType::AsyncCallback
59 | |         {
...  |
66 | |         }
67 | |     }
   | |_____^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
   = note: `#[warn(clippy::collapsible_if)]` on by default
help: collapse nested if block
   |
56 ~     if tx_input.esdt_values.is_empty() && !tx_input.callback_payments.egld_value.is_zero() && tx_input.call_type == CallType::AsyncCallback {
57 +         return TxLog {
58 +             address: tx_input.from.clone(),
59 +             endpoint: "transferValueOnly".into(),
60 +             topics: vec![b"".to_vec(), tx_input.to.to_vec()],
61 +             data,
62 +         };
63 +     }
   |


__END__
if !tx_input.callback_payments.egld_value.is_zero()
&& tx_input.call_type == CallType::AsyncCallback
{
return TxLog {
address: tx_input.from.clone(),
endpoint: "transferValueOnly".into(),
topics: vec![b"".to_vec(), tx_input.to.to_vec()],
data,
};
}
}

let egld_value = if tx_input.call_type == CallType::AsyncCallback {
&tx_input.callback_payments.egld_value
} else {
Expand Down

0 comments on commit 4acebb0

Please sign in to comment.