Skip to content

Commit

Permalink
fix: field chainId should be acceptable for eth_estimateGas (#1601)
Browse files Browse the repository at this point in the history
  • Loading branch information
yangby-cryptape authored Nov 28, 2023
1 parent 5f5045a commit dfcb211
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions core/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
8 changes: 6 additions & 2 deletions core/api/src/jsonrpc/impl/web3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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),
}
}

Expand Down
1 change: 1 addition & 0 deletions core/api/src/jsonrpc/web3_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ pub struct Web3CallRequest {
pub nonce: Option<U256>,
#[serde(skip_serializing_if = "Option::is_none")]
pub access_list: Option<AccessList>,
pub chain_id: Option<U64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_priority_fee_per_gas: Option<U256>,
}
Expand Down

0 comments on commit dfcb211

Please sign in to comment.