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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
use serde::{Deserialize, Serialize};
use serde_json::Value;
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct JsonRpcRequest {
pub method: String,
pub params: Value,
pub id: String,
pub jsonrpc: String,
}
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
#[serde(untagged)]
pub enum JsonResult {
String(String),
JsonRpcResult(JsonRpcResult),
}
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
#[serde(untagged)]
pub enum TransactionResult {
String(String),
Transaction(Transaction),
}
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct JsonRpc {
#[serde(rename = "jsonrpc")]
pub json_rpc: String,
pub id: String,
pub result: Option<JsonResult>,
pub error: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct JsonRpcResult {
#[serde(rename = "baseFeePerGas")]
pub base_fee_per_gas: Option<String>,
pub difficulty: Option<String>,
#[serde(rename = "extraData")]
pub extra_data: Option<String>,
#[serde(rename = "gasLimit")]
pub gas_limit: Option<String>,
#[serde(rename = "gasUsed")]
pub gas_used: Option<String>,
pub hash: Option<String>,
#[serde(rename = "logsBloom")]
pub logs_bloom: Option<String>,
pub miner: Option<String>,
#[serde(rename = "mixHash")]
pub mix_hash: Option<String>,
pub nonce: Option<String>,
pub number: Option<String>,
#[serde(rename = "parentHash")]
pub parent_hash: Option<String>,
#[serde(rename = "receiptsRoot")]
pub receipts_root: Option<String>,
#[serde(rename = "sha3Uncles")]
pub sha3_uncles: Option<String>,
pub size: Option<String>,
#[serde(rename = "stateRoot")]
pub state_root: Option<String>,
pub timestamp: Option<String>,
#[serde(rename = "totalDifficulty")]
pub total_difficulty: Option<String>,
pub transactions: Option<Vec<TransactionResult>>,
#[serde(rename = "transactionsRoot")]
pub transactions_root: Option<String>,
pub uncles: Option<Vec<String>>,
#[serde(rename = "blockHash")]
pub block_hash: Option<String>,
#[serde(rename = "blockNumber")]
pub block_number: Option<String>,
#[serde(rename = "contractAddress")]
pub contract_address: Option<String>,
#[serde(rename = "cumulativeGasUsed")]
pub cumulative_gas_used: Option<String>,
#[serde(rename = "effectiveGasPrice")]
pub effective_gas_price: Option<String>,
pub from: Option<String>,
pub logs: Option<Vec<TransactionReceiptLogs>>,
pub status: Option<String>,
pub to: Option<String>,
#[serde(rename = "transactionHash")]
pub transaction_hash: Option<String>,
#[serde(rename = "transactionIndex")]
pub transaction_index: Option<String>,
pub r#type: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct Transaction {
#[serde(rename = "blockHash")]
pub block_hash: Option<String>,
#[serde(rename = "blockNumber")]
pub block_number: Option<String>,
pub from: Option<String>,
pub gas: Option<String>,
#[serde(rename = "gasPrice")]
pub gas_price: Option<String>,
#[serde(rename = "maxFeePerGas")]
pub max_fee_per_gas: Option<String>,
#[serde(rename = "maxPriorityFeePerGas")]
pub max_priority_fee_per_gas: Option<String>,
pub hash: Option<String>,
pub input: Option<String>,
pub nonce: Option<String>,
pub to: Option<String>,
#[serde(rename = "transactionIndex")]
pub transaction_index: Option<String>,
pub value: Option<String>,
pub r#type: Option<String>,
#[serde(rename = "accessList")]
pub access_list: Option<Vec<AccessList>>,
#[serde(rename = "chainId")]
pub chain_id: Option<String>,
pub v: Option<String>,
pub r: Option<String>,
pub s: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct TransactionReceiptLogs {
pub address: Option<String>,
pub topics: Option<Vec<String>>,
pub data: Option<String>,
#[serde(rename = "blockNumber")]
pub block_number: Option<String>,
#[serde(rename = "transactionHash")]
pub transaction_hash: Option<String>,
#[serde(rename = "transactionIndex")]
pub transaction_index: Option<String>,
#[serde(rename = "blockHash")]
pub block_hash: Option<String>,
#[serde(rename = "logIndex")]
pub log_index: Option<String>,
pub removed: Option<bool>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct AccessList {
pub address: String,
#[serde(rename = "storageKeys")]
pub storage_keys: Vec<String>,
}