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 {
    /// Method
    pub method: String,
    /// Params
    pub params: Value,
    /// Id
    pub id: String,
    /// JsonRpc
    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 {
    /// JSON RPC Version
    #[serde(rename = "jsonrpc")]
    pub json_rpc: String,
    /// Chain Id
    pub id: String,
    /// Json RPC Results
    pub result: Option<JsonResult>,
    /// Json RPC Result Error
    pub error: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct JsonRpcResult {
    /// base fee per gas
    #[serde(rename = "baseFeePerGas")]
    pub base_fee_per_gas: Option<String>,
    /// difficulty
    pub difficulty: Option<String>,
    /// extra Data
    #[serde(rename = "extraData")]
    pub extra_data: Option<String>,
    /// gas Limit
    #[serde(rename = "gasLimit")]
    pub gas_limit: Option<String>,
    /// gas Used
    #[serde(rename = "gasUsed")]
    pub gas_used: Option<String>,
    /// hash
    pub hash: Option<String>,
    /// logs Bloom
    #[serde(rename = "logsBloom")]
    pub logs_bloom: Option<String>,
    /// miner
    pub miner: Option<String>,
    /// mix hash
    #[serde(rename = "mixHash")]
    pub mix_hash: Option<String>,
    /// nonce
    pub nonce: Option<String>,
    /// number
    pub number: Option<String>,
    /// parent Hash
    #[serde(rename = "parentHash")]
    pub parent_hash: Option<String>,
    /// receipts Root
    #[serde(rename = "receiptsRoot")]
    pub receipts_root: Option<String>,
    /// sha3Uncles
    #[serde(rename = "sha3Uncles")]
    pub sha3_uncles: Option<String>,
    /// size
    pub size: Option<String>,
    /// stateRoot
    #[serde(rename = "stateRoot")]
    pub state_root: Option<String>,
    /// timestamp
    pub timestamp: Option<String>,
    /// totalDifficulty
    #[serde(rename = "totalDifficulty")]
    pub total_difficulty: Option<String>,
    /// transactions
    pub transactions: Option<Vec<TransactionResult>>,
    /// transactionsRoot
    #[serde(rename = "transactionsRoot")]
    pub transactions_root: Option<String>,
    /// uncles
    pub uncles: Option<Vec<String>>,
    /// blockHash
    #[serde(rename = "blockHash")]
    pub block_hash: Option<String>,
    /// blockNumber
    #[serde(rename = "blockNumber")]
    pub block_number: Option<String>,
    /// contractAddress
    #[serde(rename = "contractAddress")]
    pub contract_address: Option<String>,
    /// cumulativeGasUsed
    #[serde(rename = "cumulativeGasUsed")]
    pub cumulative_gas_used: Option<String>,
    /// effectiveGasPrice
    #[serde(rename = "effectiveGasPrice")]
    pub effective_gas_price: Option<String>,
    /// from
    pub from: Option<String>,
    /// logs
    pub logs: Option<Vec<TransactionReceiptLogs>>,
    /// status
    pub status: Option<String>,
    /// to
    pub to: Option<String>,
    /// transactionHash
    #[serde(rename = "transactionHash")]
    pub transaction_hash: Option<String>,
    /// transactionIndex
    #[serde(rename = "transactionIndex")]
    pub transaction_index: Option<String>,
    /// type
    pub r#type: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct Transaction {
    /// Block Hash
    #[serde(rename = "blockHash")]
    pub block_hash: Option<String>,
    /// Block Number
    #[serde(rename = "blockNumber")]
    pub block_number: Option<String>,
    /// from
    pub from: Option<String>,
    /// gas
    pub gas: Option<String>,
    /// gas Price
    #[serde(rename = "gasPrice")]
    pub gas_price: Option<String>,
    /// max fee per gas
    #[serde(rename = "maxFeePerGas")]
    pub max_fee_per_gas: Option<String>,
    ///max Priority Fee Per Gas
    #[serde(rename = "maxPriorityFeePerGas")]
    pub max_priority_fee_per_gas: Option<String>,
    /// hash
    pub hash: Option<String>,
    /// input
    pub input: Option<String>,
    /// nonce
    pub nonce: Option<String>,
    /// to
    pub to: Option<String>,
    /// transactionIndex
    #[serde(rename = "transactionIndex")]
    pub transaction_index: Option<String>,
    /// value
    pub value: Option<String>,
    /// type
    pub r#type: Option<String>,
    /// accessList
    #[serde(rename = "accessList")]
    pub access_list: Option<Vec<AccessList>>,
    /// chainId
    #[serde(rename = "chainId")]
    pub chain_id: Option<String>,
    /// v
    pub v: Option<String>,
    /// r
    pub r: Option<String>,
    /// s
    pub s: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct TransactionReceiptLogs {
    /// address
    pub address: Option<String>,
    /// topics
    pub topics: Option<Vec<String>>,
    /// data
    pub data: Option<String>,
    /// blockNumber
    #[serde(rename = "blockNumber")]
    pub block_number: Option<String>,
    /// transactionHash
    #[serde(rename = "transactionHash")]
    pub transaction_hash: Option<String>,
    /// transactionIndex
    #[serde(rename = "transactionIndex")]
    pub transaction_index: Option<String>,
    /// blockHash
    #[serde(rename = "blockHash")]
    pub block_hash: Option<String>,
    /// logIndex
    #[serde(rename = "logIndex")]
    pub log_index: Option<String>,
    /// removed
    pub removed: Option<bool>,
}

#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct AccessList {
    /// Address
    pub address: String,
    /// storage Keys
    #[serde(rename = "storageKeys")]
    pub storage_keys: Vec<String>,
}