referrerpolicy=no-referrer-when-downgrade

pallet_revive_eth_rpc/apis/
execution_apis.rs

1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
5
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// 	http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18//! Generated JSON-RPC methods.
19#![allow(missing_docs)]
20
21use crate::*;
22use jsonrpsee::{core::RpcResult, proc_macros::rpc};
23
24#[rpc(server, client)]
25pub trait EthRpc {
26	/// Returns a list of addresses owned by client.
27	#[method(name = "eth_accounts")]
28	async fn accounts(&self) -> RpcResult<Vec<Address>>;
29
30	/// Returns the number of most recent block.
31	#[method(name = "eth_blockNumber")]
32	async fn block_number(&self) -> RpcResult<U256>;
33
34	/// Executes a new message call immediately without creating a transaction on the block chain.
35	#[method(name = "eth_call")]
36	async fn call(
37		&self,
38		transaction: GenericTransaction,
39		block: Option<BlockNumberOrTagOrHash>,
40	) -> RpcResult<Bytes>;
41
42	/// Returns the chain ID of the current network.
43	#[method(name = "eth_chainId")]
44	async fn chain_id(&self) -> RpcResult<U256>;
45
46	/// Generates and returns an estimate of how much gas is necessary to allow the transaction to
47	/// complete.
48	#[method(name = "eth_estimateGas")]
49	async fn estimate_gas(
50		&self,
51		transaction: GenericTransaction,
52		block: Option<BlockNumberOrTag>,
53	) -> RpcResult<U256>;
54
55	/// Returns the current price per gas in wei.
56	#[method(name = "eth_gasPrice")]
57	async fn gas_price(&self) -> RpcResult<U256>;
58
59	/// Returns the balance of the account of given address.
60	#[method(name = "eth_getBalance")]
61	async fn get_balance(&self, address: Address, block: BlockNumberOrTagOrHash)
62		-> RpcResult<U256>;
63
64	/// Returns information about a block by hash.
65	#[method(name = "eth_getBlockByHash")]
66	async fn get_block_by_hash(
67		&self,
68		block_hash: H256,
69		hydrated_transactions: bool,
70	) -> RpcResult<Option<Block>>;
71
72	/// Returns information about a block by number.
73	#[method(name = "eth_getBlockByNumber")]
74	async fn get_block_by_number(
75		&self,
76		block: BlockNumberOrTag,
77		hydrated_transactions: bool,
78	) -> RpcResult<Option<Block>>;
79
80	/// Returns the number of transactions in a block from a block matching the given block hash.
81	#[method(name = "eth_getBlockTransactionCountByHash")]
82	async fn get_block_transaction_count_by_hash(
83		&self,
84		block_hash: Option<H256>,
85	) -> RpcResult<Option<U256>>;
86
87	/// Returns the number of transactions in a block matching the given block number.
88	#[method(name = "eth_getBlockTransactionCountByNumber")]
89	async fn get_block_transaction_count_by_number(
90		&self,
91		block: Option<BlockNumberOrTag>,
92	) -> RpcResult<Option<U256>>;
93
94	/// Returns code at a given address.
95	#[method(name = "eth_getCode")]
96	async fn get_code(&self, address: Address, block: BlockNumberOrTagOrHash) -> RpcResult<Bytes>;
97
98	/// Returns an array of all logs matching filter with given id.
99	#[method(name = "eth_getLogs")]
100	async fn get_logs(&self, filter: Option<Filter>) -> RpcResult<FilterResults>;
101
102	/// Returns the value from a storage position at a given address.
103	#[method(name = "eth_getStorageAt")]
104	async fn get_storage_at(
105		&self,
106		address: Address,
107		storage_slot: U256,
108		block: BlockNumberOrTagOrHash,
109	) -> RpcResult<Bytes>;
110
111	/// Returns information about a transaction by block hash and transaction index position.
112	#[method(name = "eth_getTransactionByBlockHashAndIndex")]
113	async fn get_transaction_by_block_hash_and_index(
114		&self,
115		block_hash: H256,
116		transaction_index: U256,
117	) -> RpcResult<Option<TransactionInfo>>;
118
119	/// Returns information about a transaction by block number and transaction index position.
120	#[method(name = "eth_getTransactionByBlockNumberAndIndex")]
121	async fn get_transaction_by_block_number_and_index(
122		&self,
123		block: BlockNumberOrTag,
124		transaction_index: U256,
125	) -> RpcResult<Option<TransactionInfo>>;
126
127	/// Returns the information about a transaction requested by transaction hash.
128	#[method(name = "eth_getTransactionByHash")]
129	async fn get_transaction_by_hash(
130		&self,
131		transaction_hash: H256,
132	) -> RpcResult<Option<TransactionInfo>>;
133
134	/// Returns the number of transactions sent from an address.
135	#[method(name = "eth_getTransactionCount")]
136	async fn get_transaction_count(
137		&self,
138		address: Address,
139		block: BlockNumberOrTagOrHash,
140	) -> RpcResult<U256>;
141
142	/// Returns the receipt of a transaction by transaction hash.
143	#[method(name = "eth_getTransactionReceipt")]
144	async fn get_transaction_receipt(
145		&self,
146		transaction_hash: H256,
147	) -> RpcResult<Option<ReceiptInfo>>;
148
149	/// Returns the current maxPriorityFeePerGas per gas in wei.
150	#[method(name = "eth_maxPriorityFeePerGas")]
151	async fn max_priority_fee_per_gas(&self) -> RpcResult<U256>;
152
153	/// Submits a raw transaction. For EIP-4844 transactions, the raw form must be the network form.
154	/// This means it includes the blobs, KZG commitments, and KZG proofs.
155	#[method(name = "eth_sendRawTransaction")]
156	async fn send_raw_transaction(&self, transaction: Bytes) -> RpcResult<H256>;
157
158	/// Signs and submits a transaction.
159	#[method(name = "eth_sendTransaction")]
160	async fn send_transaction(&self, transaction: GenericTransaction) -> RpcResult<H256>;
161
162	/// Returns an object with data about the sync status or false.
163	#[method(name = "eth_syncing")]
164	async fn syncing(&self) -> RpcResult<SyncingStatus>;
165
166	/// Returns true when the client is actively listening for network connections, otherwise false
167	#[method(name = "net_listening")]
168	async fn net_listening(&self) -> RpcResult<bool>;
169
170	/// The string value of current network id
171	#[method(name = "net_version")]
172	async fn net_version(&self) -> RpcResult<String>;
173
174	/// The string value of the current client version
175	#[method(name = "web3_clientVersion")]
176	async fn web3_client_version(&self) -> RpcResult<String>;
177
178	/// Returns transaction base fee per gas and effective priority fee per gas for the
179	/// requested/supported block range.
180	///
181	/// Transaction fee history, which is introduced in EIP-1159.
182	#[method(name = "eth_feeHistory")]
183	async fn fee_history(
184		&self,
185		block_count: U256,
186		newest_block: BlockNumberOrTag,
187		reward_percentiles: Option<Vec<f64>>,
188	) -> RpcResult<FeeHistoryResult>;
189}