fc_rpc_v2_types/
state.rs

1// This file is part of Frontier.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
5
6// This program is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License
17// along with this program. If not, see <https://www.gnu.org/licenses/>.
18
19use std::collections::HashMap;
20
21use ethereum_types::{Address, H256, U256, U64};
22use serde::{Deserialize, Serialize};
23
24use crate::bytes::Bytes;
25
26pub type StateOverrides = HashMap<Address, AccountOverride>;
27
28/// Indicates the overriding fields of account during the execution of a message call.
29///
30/// Note, state and stateDiff can't be specified at the same time.
31/// If state is set, message execution will only use the data in the given state.
32/// Otherwise, if statDiff is set, all diff will be applied first and then execute the call message.
33#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
34#[serde(default, rename_all = "camelCase")]
35pub struct AccountOverride {
36	/// Fake balance to set for the account before executing the call.
37	#[serde(default, skip_serializing_if = "Option::is_none")]
38	pub balance: Option<U256>,
39	/// Fake nonce to set for the account before executing the call.
40	#[serde(default, skip_serializing_if = "Option::is_none")]
41	pub nonce: Option<U64>,
42	/// Fake EVM bytecode to inject into the account before executing the call.
43	#[serde(default, skip_serializing_if = "Option::is_none")]
44	pub code: Option<Bytes>,
45	/// Fake key-value mapping to override all slots in the account storage before
46	/// executing the call.
47	#[serde(default, skip_serializing_if = "Option::is_none")]
48	pub state: Option<HashMap<H256, H256>>,
49	/// Fake key-value mapping to override individual slots in the account storage before
50	/// executing the call.
51	#[serde(default, skip_serializing_if = "Option::is_none")]
52	pub state_diff: Option<HashMap<H256, H256>>,
53}