Skip to content

Commit e5ec47b

Browse files
authored
fix(anvil): return nonce and signature for deposit tx type (#9883)
* return nonce and signature for deposit tx type * fix clippy
1 parent aece6f4 commit e5ec47b

File tree

1 file changed

+12
-2
lines changed
  • crates/anvil/src/eth/backend/mem

1 file changed

+12
-2
lines changed

crates/anvil/src/eth/backend/mem/mod.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -2866,7 +2866,7 @@ pub fn transaction_build(
28662866
) -> AnyRpcTransaction {
28672867
if let TypedTransaction::Deposit(ref deposit_tx) = eth_transaction.transaction {
28682868
let DepositTransaction {
2869-
nonce: _,
2869+
nonce,
28702870
source_hash,
28712871
from,
28722872
kind,
@@ -2892,7 +2892,17 @@ pub fn transaction_build(
28922892
let maybe_deposit_fields = OtherFields::try_from(ser);
28932893

28942894
match maybe_deposit_fields {
2895-
Ok(fields) => {
2895+
Ok(mut fields) => {
2896+
// Add zeroed signature fields for backwards compatibility
2897+
// https://specs.optimism.io/protocol/deposits.html#the-deposited-transaction-type
2898+
fields.insert("v".to_string(), serde_json::to_value("0x0").unwrap());
2899+
fields.insert("r".to_string(), serde_json::to_value(B256::ZERO).unwrap());
2900+
fields.insert(String::from("s"), serde_json::to_value(B256::ZERO).unwrap());
2901+
fields.insert(
2902+
String::from("nonce"),
2903+
serde_json::to_value(format!("0x{nonce}")).unwrap(),
2904+
);
2905+
28962906
let inner = UnknownTypedTransaction {
28972907
ty: AnyTxType(DEPOSIT_TX_TYPE_ID),
28982908
fields,

0 commit comments

Comments
 (0)