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: GenericTransactionV1,
39		block: Option<BlockId>,
40		state_overrides: Option<StateOverrideSetV1>,
41	) -> RpcResult<Bytes>;
42
43	/// Returns the chain ID of the current network.
44	#[method(name = "eth_chainId")]
45	async fn chain_id(&self) -> RpcResult<U256>;
46
47	/// Generates and returns an estimate of how much gas is necessary to allow the transaction to
48	/// complete.
49	#[method(name = "eth_estimateGas")]
50	async fn estimate_gas(
51		&self,
52		transaction: GenericTransactionV1,
53		block: Option<BlockNumberOrTag>,
54	) -> RpcResult<U256>;
55
56	/// Returns the current price per gas in wei.
57	#[method(name = "eth_gasPrice")]
58	async fn gas_price(&self) -> RpcResult<U256>;
59
60	/// Returns the balance of the account of given address.
61	#[method(name = "eth_getBalance")]
62	async fn get_balance(&self, address: Address, block: BlockId) -> 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<BlockV1>>;
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<BlockV1>>;
79
80	/// Returns the receipts of all transactions in a block.
81	#[method(name = "eth_getBlockReceipts")]
82	async fn get_block_receipts(&self, block: BlockId) -> RpcResult<Option<Vec<ReceiptInfo>>>;
83
84	/// Returns the number of transactions in a block from a block matching the given block hash.
85	#[method(name = "eth_getBlockTransactionCountByHash")]
86	async fn get_block_transaction_count_by_hash(
87		&self,
88		block_hash: Option<H256>,
89	) -> RpcResult<Option<U256>>;
90
91	/// Returns the number of transactions in a block matching the given block number.
92	#[method(name = "eth_getBlockTransactionCountByNumber")]
93	async fn get_block_transaction_count_by_number(
94		&self,
95		block: Option<BlockNumberOrTag>,
96	) -> RpcResult<Option<U256>>;
97
98	/// Returns code at a given address.
99	#[method(name = "eth_getCode")]
100	async fn get_code(&self, address: Address, block: BlockId) -> RpcResult<Bytes>;
101
102	/// Returns an array of all logs matching filter with given id.
103	#[method(name = "eth_getLogs")]
104	async fn get_logs(&self, filter: Option<Filter>) -> RpcResult<FilterResults>;
105
106	/// Returns the value from a storage position at a given address.
107	#[method(name = "eth_getStorageAt")]
108	async fn get_storage_at(
109		&self,
110		address: Address,
111		storage_slot: U256,
112		block: BlockId,
113	) -> RpcResult<Bytes>;
114
115	/// Returns information about a transaction by block hash and transaction index position.
116	#[method(name = "eth_getTransactionByBlockHashAndIndex")]
117	async fn get_transaction_by_block_hash_and_index(
118		&self,
119		block_hash: H256,
120		transaction_index: U256,
121	) -> RpcResult<Option<TransactionInfoV1>>;
122
123	/// Returns information about a transaction by block number and transaction index position.
124	#[method(name = "eth_getTransactionByBlockNumberAndIndex")]
125	async fn get_transaction_by_block_number_and_index(
126		&self,
127		block: BlockNumberOrTag,
128		transaction_index: U256,
129	) -> RpcResult<Option<TransactionInfoV1>>;
130
131	/// Returns the information about a transaction requested by transaction hash.
132	#[method(name = "eth_getTransactionByHash")]
133	async fn get_transaction_by_hash(
134		&self,
135		transaction_hash: H256,
136	) -> RpcResult<Option<TransactionInfoV1>>;
137
138	/// Returns the number of transactions sent from an address.
139	#[method(name = "eth_getTransactionCount")]
140	async fn get_transaction_count(&self, address: Address, block: BlockId) -> 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: GenericTransactionV1) -> 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
190	/// Creates a subscription to specific events, returning a subscription ID.
191	/// Notifications are sent for each event matching the subscription via
192	/// `eth_subscription`.
193	#[subscription(
194		name = "eth_subscribe" => "eth_subscription",
195		unsubscribe = "eth_unsubscribe",
196		item = SubscriptionItem
197	)]
198	async fn eth_subscribe(&self, kind: SubscriptionKind, options: Option<SubscriptionOptions>);
199}