pod_types/ledger/
transaction.rs

1use alloy_consensus::{SignableTransaction, TxEip1559};
2use alloy_primitives::Address;
3use alloy_sol_types::SolValue;
4
5use crate::cryptography::{
6    hash::{Hash, Hashable},
7    merkle_tree::{MerkleBuilder, Merkleizable},
8};
9
10pub type Transaction = TxEip1559;
11
12impl Merkleizable for Transaction {
13    fn append_leaves(&self, builder: &mut MerkleBuilder) {
14        builder.add_field("to", self.to.to().unwrap_or(&Address::ZERO).hash_custom());
15        builder.add_field("nonce", self.nonce.abi_encode().hash_custom());
16        builder.add_field("value", self.value.abi_encode().hash_custom());
17        builder.add_field("gas_limit", self.gas_limit.abi_encode().hash_custom());
18        builder.add_field(
19            "max_fee_per_gas",
20            self.max_fee_per_gas.abi_encode().hash_custom(),
21        );
22        builder.add_field(
23            "max_priority_fee_per_gas",
24            self.max_priority_fee_per_gas.abi_encode().hash_custom(),
25        );
26        builder.add_field("call_data", self.input.hash_custom());
27        // TODO: figure out how to handle access list
28    }
29}
30
31impl Hashable for Transaction {
32    fn hash_custom(&self) -> Hash {
33        self.signature_hash()
34    }
35}