From 91180b77cf1ae022dfec19e184cc5f155de39ccc Mon Sep 17 00:00:00 2001 From: Danilo Tuler Date: Wed, 4 Dec 2019 04:35:34 -0500 Subject: [PATCH] Adds eth_chainId method call (#293) --- src/api/eth.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/api/eth.rs b/src/api/eth.rs index 82fe144b..212e8e0a 100644 --- a/src/api/eth.rs +++ b/src/api/eth.rs @@ -166,6 +166,11 @@ impl Eth { CallFuture::new(self.transport.execute("eth_getCompilers", vec![])) } + /// Get chain id + pub fn chain_id(&self) -> CallFuture { + CallFuture::new(self.transport.execute("eth_chainId", vec![])) + } + /// Get storage entry pub fn storage(&self, address: Address, idx: U256, block: Option) -> CallFuture { let address = helpers::serialize(&address); @@ -541,6 +546,11 @@ mod tests { Value::Array(vec![]) => vec![] ); + rpc_test! ( + Eth:chain_id => "eth_chainId"; + Value::String("0x123".into()) => 0x123 + ); + rpc_test! ( Eth:storage, Address::from_low_u64_be(0x123), 0x456, None =>