Skip to content

Commit

Permalink
fix(anvil): return nonce and signature for deposit tx type (foundry-r…
Browse files Browse the repository at this point in the history
…s#9883)

* return nonce and signature for deposit tx type

* fix clippy
  • Loading branch information
jakim929 authored Feb 13, 2025
1 parent aece6f4 commit e5ec47b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions crates/anvil/src/eth/backend/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2866,7 +2866,7 @@ pub fn transaction_build(
) -> AnyRpcTransaction {
if let TypedTransaction::Deposit(ref deposit_tx) = eth_transaction.transaction {
let DepositTransaction {
nonce: _,
nonce,
source_hash,
from,
kind,
Expand All @@ -2892,7 +2892,17 @@ pub fn transaction_build(
let maybe_deposit_fields = OtherFields::try_from(ser);

match maybe_deposit_fields {
Ok(fields) => {
Ok(mut fields) => {
// Add zeroed signature fields for backwards compatibility
// https://specs.optimism.io/protocol/deposits.html#the-deposited-transaction-type
fields.insert("v".to_string(), serde_json::to_value("0x0").unwrap());
fields.insert("r".to_string(), serde_json::to_value(B256::ZERO).unwrap());
fields.insert(String::from("s"), serde_json::to_value(B256::ZERO).unwrap());
fields.insert(
String::from("nonce"),
serde_json::to_value(format!("0x{nonce}")).unwrap(),
);

let inner = UnknownTypedTransaction {
ty: AnyTxType(DEPOSIT_TX_TYPE_ID),
fields,
Expand Down

0 comments on commit e5ec47b

Please sign in to comment.