From ae65a63ce8dec565504b8fc5878bdb17a56eec8d Mon Sep 17 00:00:00 2001 From: Peter Grassberger Date: Sat, 3 Oct 2020 18:48:51 +0200 Subject: [PATCH 1/2] Add RPC eth_symbol test --- rpc/src/v1/tests/mocked/eth.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rpc/src/v1/tests/mocked/eth.rs b/rpc/src/v1/tests/mocked/eth.rs index 5f81c1a65c0..4dd9206027b 100644 --- a/rpc/src/v1/tests/mocked/eth.rs +++ b/rpc/src/v1/tests/mocked/eth.rs @@ -187,6 +187,15 @@ fn rpc_eth_chain_id() { assert_eq!(tester.io.handle_request_sync(request), Some(response.to_owned())); } +#[test] +fn rpc_eth_symbol() { + let tester = EthTester::default(); + let request = r#"{"jsonrpc": "2.0", "method": "eth_symbol", "params": [], "id": 1}"#; + let response = r#"{"jsonrpc":"2.0","result":null,"id":1}"#; + + assert_eq!(tester.io.handle_request_sync(request), Some(response.to_owned())); +} + #[test] fn rpc_eth_hashrate() { let tester = EthTester::default(); From a24e09ffa4dc1b1c28e5289eee34616dc2c16aaa Mon Sep 17 00:00:00 2001 From: PeterTheOne Date: Sat, 3 Oct 2020 23:14:51 +0200 Subject: [PATCH 2/2] Add RPC eth_symbol static wip --- rpc/src/v1/impls/eth.rs | 5 +++++ rpc/src/v1/impls/light/eth.rs | 5 +++++ rpc/src/v1/traits/eth.rs | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index fa28a7e4303..c7ff185ebd8 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -597,6 +597,11 @@ impl Eth for EthClient< Ok(self.client.signing_chain_id().map(U64::from)) } + fn symbol(&self) -> Result { + // TODO: symbol should be configurable + Ok("ETH".to_string()) + } + fn hashrate(&self) -> Result { Ok(self.external_miner.hashrate()) } diff --git a/rpc/src/v1/impls/light/eth.rs b/rpc/src/v1/impls/light/eth.rs index 42e95800728..baf2d931645 100644 --- a/rpc/src/v1/impls/light/eth.rs +++ b/rpc/src/v1/impls/light/eth.rs @@ -266,6 +266,11 @@ where Ok(self.client.signing_chain_id().map(U64::from)) } + fn symbol(&self) -> Result { + // TODO: symbol should be configurable + Ok("ETH".to_string()) + } + fn hashrate(&self) -> Result { Ok(Default::default()) } diff --git a/rpc/src/v1/traits/eth.rs b/rpc/src/v1/traits/eth.rs index 8fb1bba7041..5978cb3cfc6 100644 --- a/rpc/src/v1/traits/eth.rs +++ b/rpc/src/v1/traits/eth.rs @@ -54,6 +54,10 @@ pub trait Eth { #[rpc(name = "eth_chainId")] fn chain_id(&self) -> Result>; + /// Returns native coin symbol. + #[rpc(name = "eth_symbol")] + fn symbol(&self) -> Result; + /// Returns current gas_price. #[rpc(name = "eth_gasPrice")] fn gas_price(&self) -> BoxFuture;