diff --git a/core/api/README.md b/core/api/README.md index 60ff60da4..8782f4a20 100644 --- a/core/api/README.md +++ b/core/api/README.md @@ -2273,6 +2273,8 @@ The Web3CallRequest objects. * `access_list`: `Array<` [`AccessList`](#type-AccessList)`>` - The accessList specifies a list of addresses and storage keys; these addresses and storage keys are added into the accessed_addresses and accessed_storage_keys global sets. +* `chain_id`: [`U64`](#type-U64) - QUANTITY - The id of the chain. + * `max_priority_fee_per_gas`: [`U256`](#type-U256) - QUANTITY - (optional) determined by the user, and is paid directly to miners. ### Type `AccessList` diff --git a/core/api/src/jsonrpc/impl/web3.rs b/core/api/src/jsonrpc/impl/web3.rs index 60d939d7c..625de63de 100644 --- a/core/api/src/jsonrpc/impl/web3.rs +++ b/core/api/src/jsonrpc/impl/web3.rs @@ -7,7 +7,7 @@ use protocol::traits::{APIAdapter, Context}; use protocol::types::{ Block, BlockNumber, Bytes, EthAccountProof, Hash, Header, Hex, Proposal, Receipt, SignedTransaction, TxResp, UnverifiedTransaction, BASE_FEE_PER_GAS, H160, H256, - MAX_FEE_HISTORY, MAX_RPC_GAS_CAP, MIN_TRANSACTION_GAS_LIMIT, U256, + MAX_FEE_HISTORY, MAX_RPC_GAS_CAP, MIN_TRANSACTION_GAS_LIMIT, U256, U64, }; use protocol::{ async_trait, codec::ProtocolCodec, lazy::PROTOCOL_VERSION, tokio::time::sleep, ProtocolResult, @@ -1093,7 +1093,11 @@ fn mock_header_by_call_req(latest_header: Header, call_req: &Web3CallRequest) -> }, proof: latest_header.proof, call_system_script_count: 0, - chain_id: latest_header.chain_id, + chain_id: call_req + .chain_id + .as_ref() + .map(U64::low_u64) + .unwrap_or(latest_header.chain_id), } } diff --git a/core/api/src/jsonrpc/web3_types.rs b/core/api/src/jsonrpc/web3_types.rs index 1fd3746e1..8d3efb611 100644 --- a/core/api/src/jsonrpc/web3_types.rs +++ b/core/api/src/jsonrpc/web3_types.rs @@ -317,6 +317,7 @@ pub struct Web3CallRequest { pub nonce: Option, #[serde(skip_serializing_if = "Option::is_none")] pub access_list: Option, + pub chain_id: Option, #[serde(skip_serializing_if = "Option::is_none")] pub max_priority_fee_per_gas: Option, }