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/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(); 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;