1use ethereum_types::{H160, H256, H64, U256, U64};
22use jsonrpc_core::{BoxFuture, Result};
23use jsonrpc_derive::rpc;
24
25use crate::types::{
26 BlockNumber, Bytes, CallRequest, Filter, FilterChanges, Index, Log, Receipt,
27 RichBlock, SyncStatus, Transaction, Work, TransactionRequest,
28};
29pub use rpc_impl_EthApi::gen_server::EthApi as EthApiServer;
30pub use rpc_impl_EthFilterApi::gen_server::EthFilterApi as EthFilterApiServer;
31
32#[rpc(server)]
34pub trait EthApi {
35 #[rpc(name = "eth_protocolVersion")]
37 fn protocol_version(&self) -> Result<u64>;
38
39 #[rpc(name = "eth_syncing")]
41 fn syncing(&self) -> Result<SyncStatus>;
42
43 #[rpc(name = "eth_hashrate")]
45 fn hashrate(&self) -> Result<U256>;
46
47 #[rpc(name = "eth_coinbase")]
49 fn author(&self) -> Result<H160>;
50
51 #[rpc(name = "eth_mining")]
53 fn is_mining(&self) -> Result<bool>;
54
55 #[rpc(name = "eth_chainId")]
59 fn chain_id(&self) -> Result<Option<U64>>;
60
61 #[rpc(name = "eth_gasPrice")]
63 fn gas_price(&self) -> Result<U256>;
64
65 #[rpc(name = "eth_accounts")]
67 fn accounts(&self) -> Result<Vec<H160>>;
68
69 #[rpc(name = "eth_blockNumber")]
71 fn block_number(&self) -> Result<U256>;
72
73 #[rpc(name = "eth_getBalance")]
75 fn balance(&self, _: H160, _: Option<BlockNumber>) -> Result<U256>;
76
77 #[rpc(name = "eth_getStorageAt")]
79 fn storage_at(&self, _: H160, _: U256, _: Option<BlockNumber>) -> Result<H256>;
80
81 #[rpc(name = "eth_getBlockByHash")]
83 fn block_by_hash(&self, _: H256, _: bool) -> Result<Option<RichBlock>>;
84
85 #[rpc(name = "eth_getBlockByNumber")]
87 fn block_by_number(&self, _: BlockNumber, _: bool) -> Result<Option<RichBlock>>;
88
89 #[rpc(name = "eth_getTransactionCount")]
91 fn transaction_count(&self, _: H160, _: Option<BlockNumber>) -> Result<U256>;
92
93 #[rpc(name = "eth_getBlockTransactionCountByHash")]
95 fn block_transaction_count_by_hash(&self, _: H256) -> Result<Option<U256>>;
96
97 #[rpc(name = "eth_getBlockTransactionCountByNumber")]
99 fn block_transaction_count_by_number(&self, _: BlockNumber) -> Result<Option<U256>>;
100
101 #[rpc(name = "eth_getUncleCountByBlockHash")]
103 fn block_uncles_count_by_hash(&self, _: H256) -> Result<U256>;
104
105 #[rpc(name = "eth_getUncleCountByBlockNumber")]
107 fn block_uncles_count_by_number(&self, _: BlockNumber) -> Result<U256>;
108
109 #[rpc(name = "eth_getCode")]
111 fn code_at(&self, _: H160, _: Option<BlockNumber>) -> Result<Bytes>;
112
113 #[rpc(name = "eth_sendTransaction")]
116 fn send_transaction(&self, _: TransactionRequest) -> BoxFuture<H256>;
117
118 #[rpc(name = "eth_sendRawTransaction")]
120 fn send_raw_transaction(&self, _: Bytes) -> BoxFuture<H256>;
121
122 #[rpc(name = "eth_call")]
124 fn call(&self, _: CallRequest, _: Option<BlockNumber>) -> Result<Bytes>;
125
126 #[rpc(name = "eth_estimateGas")]
128 fn estimate_gas(&self, _: CallRequest, _: Option<BlockNumber>) -> Result<U256>;
129
130 #[rpc(name = "eth_getTransactionByHash")]
132 fn transaction_by_hash(&self, _: H256) -> Result<Option<Transaction>>;
133
134 #[rpc(name = "eth_getTransactionByBlockHashAndIndex")]
136 fn transaction_by_block_hash_and_index(
137 &self,
138 _: H256,
139 _: Index,
140 ) -> Result<Option<Transaction>>;
141
142 #[rpc(name = "eth_getTransactionByBlockNumberAndIndex")]
144 fn transaction_by_block_number_and_index(
145 &self,
146 _: BlockNumber,
147 _: Index,
148 ) -> Result<Option<Transaction>>;
149
150 #[rpc(name = "eth_getTransactionReceipt")]
152 fn transaction_receipt(&self, _: H256) -> Result<Option<Receipt>>;
153
154 #[rpc(name = "eth_getUncleByBlockHashAndIndex")]
156 fn uncle_by_block_hash_and_index(&self, _: H256, _: Index) -> Result<Option<RichBlock>>;
157
158 #[rpc(name = "eth_getUncleByBlockNumberAndIndex")]
160 fn uncle_by_block_number_and_index(
161 &self,
162 _: BlockNumber,
163 _: Index,
164 ) -> Result<Option<RichBlock>>;
165
166 #[rpc(name = "eth_getLogs")]
168 fn logs(&self, _: Filter) -> Result<Vec<Log>>;
169
170 #[rpc(name = "eth_getWork")]
172 fn work(&self) -> Result<Work>;
173
174 #[rpc(name = "eth_submitWork")]
176 fn submit_work(&self, _: H64, _: H256, _: H256) -> Result<bool>;
177
178 #[rpc(name = "eth_submitHashrate")]
180 fn submit_hashrate(&self, _: U256, _: H256) -> Result<bool>;
181}
182
183#[rpc(server)]
185pub trait EthFilterApi {
186 #[rpc(name = "eth_newFilter")]
188 fn new_filter(&self, _: Filter) -> Result<U256>;
189
190 #[rpc(name = "eth_newBlockFilter")]
192 fn new_block_filter(&self) -> Result<U256>;
193
194 #[rpc(name = "eth_newPendingTransactionFilter")]
196 fn new_pending_transaction_filter(&self) -> Result<U256>;
197
198 #[rpc(name = "eth_getFilterChanges")]
200 fn filter_changes(&self, _: Index) -> Result<FilterChanges>;
201
202 #[rpc(name = "eth_getFilterLogs")]
204 fn filter_logs(&self, _: Index) -> Result<Vec<Log>>;
205
206 #[rpc(name = "eth_uninstallFilter")]
208 fn uninstall_filter(&self, _: Index) -> Result<bool>;
209}