Skip to content

Commit 005e737

Browse files
authored
fix: eth_fillTransaction response (#12597)
* fix: fill tx response * fmt
1 parent 72e08ef commit 005e737

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

crates/anvil/src/eth/api.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ use anvil_core::{
7272
EthRequest,
7373
block::BlockInfo,
7474
transaction::{
75-
FillTransactionResult, PendingTransaction, ReceiptResponse, TypedTransaction,
76-
TypedTransactionRequest, transaction_request_to_typed,
75+
FillTransactionResult, MaybeImpersonatedTransaction, PendingTransaction,
76+
ReceiptResponse, TypedTransaction, TypedTransactionRequest,
77+
transaction_request_to_typed,
7778
},
7879
wallet::WalletCapabilities,
7980
},
@@ -1373,7 +1374,7 @@ impl EthApi {
13731374
pub async fn fill_transaction(
13741375
&self,
13751376
mut request: WithOtherFields<TransactionRequest>,
1376-
) -> Result<FillTransactionResult<TypedTransaction>> {
1377+
) -> Result<FillTransactionResult<AnyRpcTransaction>> {
13771378
node_info!("eth_fillTransaction");
13781379

13791380
let from = match request.as_ref().from() {
@@ -1429,6 +1430,13 @@ impl EthApi {
14291430

14301431
let raw = tx.encoded_2718().to_vec().into();
14311432

1433+
let mut tx =
1434+
transaction_build(None, MaybeImpersonatedTransaction::new(tx), None, None, None);
1435+
1436+
// Set the correct `from` address (overrides the recovered zero address from dummy
1437+
// signature)
1438+
tx.0.inner.inner = Recovered::new_unchecked(tx.0.inner.inner.into_inner(), from);
1439+
14321440
Ok(FillTransactionResult { raw, tx })
14331441
}
14341442

crates/anvil/tests/it/api.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,8 @@ async fn test_fill_transaction_fills_all_missing_fields() {
550550
// Should fill all required fields and be EIP-1559
551551
assert!(filled.tx.is_eip1559());
552552
assert!(filled.tx.gas_limit() > 0);
553-
let essentials = filled.tx.essentials();
554-
assert!(essentials.max_fee_per_gas.is_some());
555-
assert!(essentials.max_priority_fee_per_gas.is_some());
553+
assert!(filled.tx.max_fee_per_gas() > 0);
554+
assert!(filled.tx.max_priority_fee_per_gas().is_some());
556555
}
557556

558557
#[tokio::test(flavor = "multi_thread")]
@@ -578,8 +577,7 @@ async fn test_fill_transaction_eip4844_blob_fee() {
578577
filled.tx.max_fee_per_blob_gas().is_some(),
579578
"max_fee_per_blob_gas should be filled for blob tx"
580579
);
581-
let essentials = filled.tx.essentials();
582-
assert!(essentials.blob_versioned_hashes.is_some(), "blob_versioned_hashes should be present");
580+
assert!(filled.tx.blob_versioned_hashes().is_some(), "blob_versioned_hashes should be present");
583581
}
584582

585583
#[tokio::test(flavor = "multi_thread")]

0 commit comments

Comments
 (0)