1use async_trait::async_trait;
2use cfx_rpc_cfx_types::ChainStaticMeta;
3use cfx_rpc_eth_api::Web3ApiServer;
4use cfx_rpc_primitives::Bytes;
5use cfx_types::H256;
6use jsonrpsee::core::RpcResult;
7use keccak_hash::keccak;
8use std::fmt::Debug;
9
10pub struct Web3Api;
11
12#[async_trait]
13impl Web3ApiServer for Web3Api {
14 async fn client_version(&self) -> RpcResult<String> {
15 Ok(ChainStaticMeta::client_version())
16 }
17
18 fn sha3(&self, input: Bytes) -> RpcResult<H256> {
19 Ok(keccak(input.into_vec()))
20 }
21}
22
23impl Debug for Web3Api {
24 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
25 f.debug_struct("Web3Api").finish_non_exhaustive()
26 }
27}