Skip to content

Commit 7ab712d

Browse files
fix: field chainId should be acceptable for eth_estimateGas
1 parent 527ccdf commit 7ab712d

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

core/api/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2273,6 +2273,8 @@ The Web3CallRequest objects.
22732273

22742274
* `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.
22752275

2276+
* `chain_id`: [`U64`](#type-U64) - QUANTITY - The id of the chain.
2277+
22762278
* `max_priority_fee_per_gas`: [`U256`](#type-U256) - QUANTITY - (optional) determined by the user, and is paid directly to miners.
22772279

22782280
### Type `AccessList`

core/api/src/jsonrpc/impl/web3.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use protocol::traits::{APIAdapter, Context};
77
use protocol::types::{
88
Block, BlockNumber, Bytes, EthAccountProof, Hash, Header, Hex, Proposal, Receipt,
99
SignedTransaction, TxResp, UnverifiedTransaction, BASE_FEE_PER_GAS, H160, H256,
10-
MAX_FEE_HISTORY, MAX_RPC_GAS_CAP, MIN_TRANSACTION_GAS_LIMIT, U256,
10+
MAX_FEE_HISTORY, MAX_RPC_GAS_CAP, MIN_TRANSACTION_GAS_LIMIT, U256, U64,
1111
};
1212
use protocol::{
1313
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) ->
10931093
},
10941094
proof: latest_header.proof,
10951095
call_system_script_count: 0,
1096-
chain_id: latest_header.chain_id,
1096+
chain_id: call_req
1097+
.chain_id
1098+
.as_ref()
1099+
.map(U64::low_u64)
1100+
.unwrap_or(latest_header.chain_id),
10971101
}
10981102
}
10991103

core/api/src/jsonrpc/web3_types.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ pub struct Web3CallRequest {
317317
pub nonce: Option<U256>,
318318
#[serde(skip_serializing_if = "Option::is_none")]
319319
pub access_list: Option<AccessList>,
320+
pub chain_id: Option<U64>,
320321
#[serde(skip_serializing_if = "Option::is_none")]
321322
pub max_priority_fee_per_gas: Option<U256>,
322323
}

0 commit comments

Comments
 (0)