Please sign in to comment.
Add RPC eth_chainId for querying the current blockchain chain ID (#6329)
* Add RPC eth_chainId for querying the current blockchain chain ID Currently although we can use `net_version` RPC call to get the current network ID, there's no RPC for querying the chain ID. This makes it impossible to determine the current actual blockchain using the RPC. An ETH/ETC client can accidentally connect to an ETC/ETH RPC endpoint without knowing it unless it tries to sign a transaction or it fetch a transaction that is known to have signed with a chain ID. This has since caused trouble for application developers, such as MetaMask, to add multi-chain support. The same RPC endpoint is also about to be merged for ETC's go-ethereum: ethereumproject/go-ethereum#336 * Add eth_chainId to js's web3 interface * Add a mocked test for eth_chainId * Add chainId in js's jsonrpc interfaces * Change return type for eth_chainId to `Option<u64>` * Change name eth_chainId to parity_chainId * Wrong test name and missed var for rpc_parity_chain_id test * Use U256 to return chainId and fix for master u64 returns decimal integer, and there seems to be no type called U64. So here I use U256 to return the hex integer. * Fix chainID test Before EIP155 fork number, chainID should be null. * Change both parity_chainId and transaction::chainId to use U64 This makes it consistent that all chain ids returned are hex string. * Fix wrong U64 serialization
- Loading branch information...
Showing with 68 additions and 14 deletions.
- +5 −0 js/src/api/rpc/parity/parity.js
- +10 −0 js/src/jsonrpc/interfaces/parity.js
- +7 −1 rpc/src/v1/impls/light/parity.rs
- +5 −1 rpc/src/v1/impls/parity.rs
- +11 −0 rpc/src/v1/tests/mocked/parity.rs
- +7 −1 rpc/src/v1/traits/parity.rs
- +1 −1 rpc/src/v1/types/mod.rs
- +4 −4 rpc/src/v1/types/transaction.rs
- +18 −6 rpc/src/v1/types/uint.rs