Skip to content

Commit

Permalink
fix: more gas estimation checks for transfer (#7845)
Browse files Browse the repository at this point in the history
* fix: more gas estimation checks for transfer

* rustmft

* flip value check

* style
  • Loading branch information
mattsse authored May 3, 2024
1 parent 181dc3c commit e159e6e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions crates/anvil/src/eth/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2192,8 +2192,14 @@ impl EthApi {
// If the request is a simple native token transfer we can optimize
// We assume it's a transfer if we have no input data.
let to = request.to.as_ref().and_then(TxKind::to);
let likely_transfer = request.input.clone().into_input().is_none();
if likely_transfer {

// check certain fields to see if the request could be a simple transfer
let maybe_transfer = request.input.input().is_none() &&
request.access_list.is_none() &&
request.blob_versioned_hashes.is_none() &&
request.value.is_some();

if maybe_transfer {
if let Some(to) = to {
if let Ok(target_code) = self.backend.get_code_with_state(&state, *to) {
if target_code.as_ref().is_empty() {
Expand Down

0 comments on commit e159e6e

Please sign in to comment.