From ba8650585ec8029a68a386efc368744ba2240141 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 24 Mar 2023 04:14:03 +0100 Subject: [PATCH] fix(rpc): AccountOverride nonce type is Quantity (#1948) --- crates/rpc/rpc-types/src/eth/state.rs | 18 +++++++++++++++--- crates/rpc/rpc/src/eth/api/call.rs | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/crates/rpc/rpc-types/src/eth/state.rs b/crates/rpc/rpc-types/src/eth/state.rs index 9fbc0d8a13..35b6b87648 100644 --- a/crates/rpc/rpc-types/src/eth/state.rs +++ b/crates/rpc/rpc-types/src/eth/state.rs @@ -1,6 +1,6 @@ //! bindings for state overrides in eth_call -use reth_primitives::{Address, Bytes, H256, U256}; +use reth_primitives::{Address, Bytes, H256, U256, U64}; use serde::{Deserialize, Serialize}; use std::collections::HashMap; @@ -12,9 +12,21 @@ pub type StateOverride = HashMap; #[serde(default, rename_all = "camelCase", deny_unknown_fields)] #[allow(missing_docs)] pub struct AccountOverride { - pub nonce: Option, - pub code: Option, + /// Fake balance to set for the account before executing the call. + #[serde(default, skip_serializing_if = "Option::is_none")] pub balance: Option, + /// Fake nonce to set for the account before executing the call. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub nonce: Option, + /// Fake EVM bytecode to inject into the account before executing the call. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub code: Option, + /// Fake key-value mapping to override all slots in the account storage before executing the + /// call. + #[serde(default, skip_serializing_if = "Option::is_none")] pub state: Option>, + /// Fake key-value mapping to override individual slots in the account storage before executing + /// the call. + #[serde(default, skip_serializing_if = "Option::is_none")] pub state_diff: Option>, } diff --git a/crates/rpc/rpc/src/eth/api/call.rs b/crates/rpc/rpc/src/eth/api/call.rs index 773f1ccc66..54c8217818 100644 --- a/crates/rpc/rpc/src/eth/api/call.rs +++ b/crates/rpc/rpc/src/eth/api/call.rs @@ -345,7 +345,7 @@ where let mut account_info = db.basic(account)?.unwrap_or_default(); if let Some(nonce) = account_override.nonce { - account_info.nonce = nonce; + account_info.nonce = nonce.as_u64(); } if let Some(code) = account_override.code { account_info.code = Some(Bytecode::new_raw(code.0));