1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#![cfg_attr(not(feature = "std"), no_std)]
use sp_core::{H160, H256, U256};
use ethereum::{Log, Block as EthereumBlock};
use ethereum_types::Bloom;
use codec::{Encode, Decode};
use sp_std::vec::Vec;
#[derive(Eq, PartialEq, Clone, Encode, Decode, sp_runtime::RuntimeDebug)]
pub struct TransactionStatus {
pub transaction_hash: H256,
pub transaction_index: u32,
pub from: H160,
pub to: Option<H160>,
pub contract_address: Option<H160>,
pub logs: Vec<Log>,
pub logs_bloom: Bloom,
}
impl Default for TransactionStatus {
fn default() -> Self {
TransactionStatus {
transaction_hash: H256::default(),
transaction_index: 0 as u32,
from: H160::default(),
to: None,
contract_address: None,
logs: Vec::new(),
logs_bloom: Bloom::default(),
}
}
}
sp_api::decl_runtime_apis! {
pub trait EthereumRuntimeRPCApi {
fn chain_id() -> u64;
fn account_basic(address: H160) -> fp_evm::Account;
fn gas_price() -> U256;
fn account_code_at(address: H160) -> Vec<u8>;
fn author() -> H160;
fn storage_at(address: H160, index: U256) -> H256;
#[skip_initialize_block]
fn call(
from: H160,
to: H160,
data: Vec<u8>,
value: U256,
gas_limit: U256,
gas_price: Option<U256>,
nonce: Option<U256>,
estimate: bool,
) -> Result<fp_evm::CallInfo, sp_runtime::DispatchError>;
#[skip_initialize_block]
fn create(
from: H160,
data: Vec<u8>,
value: U256,
gas_limit: U256,
gas_price: Option<U256>,
nonce: Option<U256>,
estimate: bool,
) -> Result<fp_evm::CreateInfo, sp_runtime::DispatchError>;
fn current_block() -> Option<EthereumBlock>;
fn current_receipts() -> Option<Vec<ethereum::Receipt>>;
fn current_transaction_statuses() -> Option<Vec<TransactionStatus>>;
fn current_all() -> (
Option<EthereumBlock>,
Option<Vec<ethereum::Receipt>>,
Option<Vec<TransactionStatus>>
);
}
}
pub trait ConvertTransaction<E> {
fn convert_transaction(&self, transaction: ethereum::Transaction) -> E;
}