pallet_revive/evm/api/
block.rs1use super::{Bytes, Bytes8, Bytes256, HashesOrTransactionInfos};
19use alloc::vec::Vec;
20use codec::{Decode, Encode};
21use ethereum_types::*;
22use pallet_revive_types::runtime_api::*;
23use scale_info::TypeInfo;
24
25#[derive(Debug, Default, Clone, Eq, PartialEq, TypeInfo, Encode, Decode)]
27#[allow(missing_docs)]
28pub struct Block {
29 pub base_fee_per_gas: U256,
31 pub blob_gas_used: U256,
33 pub difficulty: U256,
35 pub excess_blob_gas: U256,
37 pub extra_data: Bytes,
39 pub gas_limit: U256,
41 pub gas_used: U256,
43 pub hash: H256,
45 pub logs_bloom: Bytes256,
47 pub miner: Address,
49 pub mix_hash: H256,
51 pub nonce: Bytes8,
53 pub number: U256,
55 pub parent_beacon_block_root: Option<H256>,
57 pub parent_hash: H256,
59 pub receipts_root: H256,
61 pub requests_hash: Option<H256>,
63 pub sha_3_uncles: H256,
65 pub size: U256,
67 pub state_root: H256,
69 pub timestamp: U256,
71 pub total_difficulty: Option<U256>,
73 pub transactions: HashesOrTransactionInfos,
74 pub transactions_root: H256,
76 pub uncles: Vec<H256>,
78 pub withdrawals: Vec<Withdrawal>,
80 pub withdrawals_root: H256,
82}
83
84impl From<Block> for BlockV1 {
85 fn from(value: Block) -> Self {
86 Self {
87 base_fee_per_gas: value.base_fee_per_gas,
88 blob_gas_used: value.blob_gas_used,
89 difficulty: value.difficulty,
90 excess_blob_gas: value.excess_blob_gas,
91 extra_data: value.extra_data,
92 gas_limit: value.gas_limit,
93 gas_used: value.gas_used,
94 hash: value.hash,
95 logs_bloom: value.logs_bloom,
96 miner: value.miner,
97 mix_hash: value.mix_hash,
98 nonce: value.nonce,
99 number: value.number,
100 parent_beacon_block_root: value.parent_beacon_block_root,
101 parent_hash: value.parent_hash,
102 receipts_root: value.receipts_root,
103 requests_hash: value.requests_hash,
104 sha_3_uncles: value.sha_3_uncles,
105 size: value.size,
106 state_root: value.state_root,
107 timestamp: value.timestamp,
108 total_difficulty: value.total_difficulty,
109 transactions: value.transactions.into(),
110 transactions_root: value.transactions_root,
111 uncles: value.uncles,
112 withdrawals: value.withdrawals.into_iter().map(Into::into).collect(),
113 withdrawals_root: value.withdrawals_root,
114 }
115 }
116}
117
118#[derive(Debug, Default, Clone, Eq, PartialEq, TypeInfo, Encode, Decode)]
120pub struct Withdrawal {
121 pub address: Address,
123 pub amount: U256,
125 pub index: U256,
127 pub validator_index: U256,
129}
130
131impl From<Withdrawal> for WithdrawalV1 {
132 fn from(value: Withdrawal) -> Self {
133 Self {
134 address: value.address,
135 amount: value.amount,
136 index: value.index,
137 validator_index: value.validator_index,
138 }
139 }
140}