Skip to content

Commit

Permalink
network response cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-marinica committed Jun 18, 2024
1 parent 0bbede2 commit 1b25460
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions framework/snippets/src/network_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn process_signal_error(tx: &TransactionOnNetwork) -> TxResponseStatus {
}

fn process(tx_response: &mut TxResponse, tx: &TransactionOnNetwork) {
process_out(tx_response, tx);
tx_response.out = process_out(tx);
process_new_deployed_address(
tx_response,
tx.sender.to_bytes(),
Expand All @@ -52,13 +52,15 @@ fn process(tx_response: &mut TxResponse, tx: &TransactionOnNetwork) {
process_new_issued_token_identifier(tx_response, tx);
}

fn process_out(tx_response: &mut TxResponse, tx: &TransactionOnNetwork) {
fn process_out(tx: &TransactionOnNetwork) -> Vec<Vec<u8>> {
let out_scr = tx.smart_contract_results.iter().find(is_out_scr);

if let Some(out_scr) = out_scr {
tx_response.out = decode_scr_data_or_panic(&out_scr.data);
decode_scr_data_or_panic(&out_scr.data)
} else if let Some(data) = process_out_from_log(tx) {

Check warning on line 60 in framework/snippets/src/network_response.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] framework/snippets/src/network_response.rs#L60

warning: if let can be simplified with `.unwrap_or_default()` --> framework/snippets/src/network_response.rs:60:12 | 60 | } else if let Some(data) = process_out_from_log(tx) { | ____________^ 61 | | data 62 | | } else { 63 | | Vec::new() 64 | | } | |_____^ help: replace it with: `process_out_from_log(tx).unwrap_or_default()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_unwrap_or_default = note: `#[warn(clippy::manual_unwrap_or_default)]` on by default
Raw output
framework/snippets/src/network_response.rs:60:12:w:warning: if let can be simplified with `.unwrap_or_default()`
  --> framework/snippets/src/network_response.rs:60:12
   |
60 |       } else if let Some(data) = process_out_from_log(tx) {
   |  ____________^
61 | |         data
62 | |     } else {
63 | |         Vec::new()
64 | |     }
   | |_____^ help: replace it with: `process_out_from_log(tx).unwrap_or_default()`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_unwrap_or_default
   = note: `#[warn(clippy::manual_unwrap_or_default)]` on by default


__END__

Check warning on line 60 in framework/snippets/src/network_response.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] framework/snippets/src/network_response.rs#L60

warning: if let can be simplified with `.unwrap_or_default()` --> framework/snippets/src/network_response.rs:60:12 | 60 | } else if let Some(data) = process_out_from_log(tx) { | ____________^ 61 | | data 62 | | } else { 63 | | Vec::new() 64 | | } | |_____^ help: replace it with: `process_out_from_log(tx).unwrap_or_default()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_unwrap_or_default = note: `#[warn(clippy::manual_unwrap_or_default)]` on by default
Raw output
framework/snippets/src/network_response.rs:60:12:w:warning: if let can be simplified with `.unwrap_or_default()`
  --> framework/snippets/src/network_response.rs:60:12
   |
60 |       } else if let Some(data) = process_out_from_log(tx) {
   |  ____________^
61 | |         data
62 | |     } else {
63 | |         Vec::new()
64 | |     }
   | |_____^ help: replace it with: `process_out_from_log(tx).unwrap_or_default()`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_unwrap_or_default
   = note: `#[warn(clippy::manual_unwrap_or_default)]` on by default


__END__
tx_response.out = data
data
} else {
Vec::new()
}
}

Expand Down

0 comments on commit 1b25460

Please sign in to comment.