mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
primitives: impl alloy_consensus::Transaction for Transaction (#11727)
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use crate::BlockHashOrNumber;
|
use crate::BlockHashOrNumber;
|
||||||
use alloy_eips::eip7702::SignedAuthorization;
|
use alloy_eips::eip7702::SignedAuthorization;
|
||||||
use alloy_primitives::{keccak256, Address, TxKind, B256, U256};
|
use alloy_primitives::{keccak256, Address, ChainId, TxKind, B256, U256};
|
||||||
|
|
||||||
use alloy_consensus::{SignableTransaction, TxEip1559, TxEip2930, TxEip4844, TxEip7702, TxLegacy};
|
use alloy_consensus::{SignableTransaction, TxEip1559, TxEip2930, TxEip4844, TxEip7702, TxLegacy};
|
||||||
use alloy_eips::{
|
use alloy_eips::{
|
||||||
@ -824,6 +824,188 @@ impl Encodable for Transaction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl alloy_consensus::Transaction for Transaction {
|
||||||
|
fn chain_id(&self) -> Option<ChainId> {
|
||||||
|
match self {
|
||||||
|
Self::Legacy(tx) => tx.chain_id(),
|
||||||
|
Self::Eip2930(tx) => tx.chain_id(),
|
||||||
|
Self::Eip1559(tx) => tx.chain_id(),
|
||||||
|
Self::Eip4844(tx) => tx.chain_id(),
|
||||||
|
Self::Eip7702(tx) => tx.chain_id(),
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
Self::Deposit(tx) => tx.chain_id(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn nonce(&self) -> u64 {
|
||||||
|
match self {
|
||||||
|
Self::Legacy(tx) => tx.nonce(),
|
||||||
|
Self::Eip2930(tx) => tx.nonce(),
|
||||||
|
Self::Eip1559(tx) => tx.nonce(),
|
||||||
|
Self::Eip4844(tx) => tx.nonce(),
|
||||||
|
Self::Eip7702(tx) => tx.nonce(),
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
Self::Deposit(tx) => tx.nonce(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn gas_limit(&self) -> u64 {
|
||||||
|
match self {
|
||||||
|
Self::Legacy(tx) => tx.gas_limit(),
|
||||||
|
Self::Eip2930(tx) => tx.gas_limit(),
|
||||||
|
Self::Eip1559(tx) => tx.gas_limit(),
|
||||||
|
Self::Eip4844(tx) => tx.gas_limit(),
|
||||||
|
Self::Eip7702(tx) => tx.gas_limit(),
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
Self::Deposit(tx) => tx.gas_limit(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn gas_price(&self) -> Option<u128> {
|
||||||
|
match self {
|
||||||
|
Self::Legacy(tx) => tx.gas_price(),
|
||||||
|
Self::Eip2930(tx) => tx.gas_price(),
|
||||||
|
Self::Eip1559(tx) => tx.gas_price(),
|
||||||
|
Self::Eip4844(tx) => tx.gas_price(),
|
||||||
|
Self::Eip7702(tx) => tx.gas_price(),
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
Self::Deposit(tx) => tx.gas_price(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn max_fee_per_gas(&self) -> u128 {
|
||||||
|
match self {
|
||||||
|
Self::Legacy(tx) => tx.max_fee_per_gas(),
|
||||||
|
Self::Eip2930(tx) => tx.max_fee_per_gas(),
|
||||||
|
Self::Eip1559(tx) => tx.max_fee_per_gas(),
|
||||||
|
Self::Eip4844(tx) => tx.max_fee_per_gas(),
|
||||||
|
Self::Eip7702(tx) => tx.max_fee_per_gas(),
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
Self::Deposit(tx) => tx.max_fee_per_gas(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn max_priority_fee_per_gas(&self) -> Option<u128> {
|
||||||
|
match self {
|
||||||
|
Self::Legacy(tx) => tx.max_priority_fee_per_gas(),
|
||||||
|
Self::Eip2930(tx) => tx.max_priority_fee_per_gas(),
|
||||||
|
Self::Eip1559(tx) => tx.max_priority_fee_per_gas(),
|
||||||
|
Self::Eip4844(tx) => tx.max_priority_fee_per_gas(),
|
||||||
|
Self::Eip7702(tx) => tx.max_priority_fee_per_gas(),
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
Self::Deposit(tx) => tx.max_priority_fee_per_gas(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn priority_fee_or_price(&self) -> u128 {
|
||||||
|
match self {
|
||||||
|
Self::Legacy(tx) => tx.priority_fee_or_price(),
|
||||||
|
Self::Eip2930(tx) => tx.priority_fee_or_price(),
|
||||||
|
Self::Eip1559(tx) => tx.priority_fee_or_price(),
|
||||||
|
Self::Eip4844(tx) => tx.priority_fee_or_price(),
|
||||||
|
Self::Eip7702(tx) => tx.priority_fee_or_price(),
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
Self::Deposit(tx) => tx.priority_fee_or_price(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn max_fee_per_blob_gas(&self) -> Option<u128> {
|
||||||
|
match self {
|
||||||
|
Self::Legacy(tx) => tx.max_fee_per_blob_gas(),
|
||||||
|
Self::Eip2930(tx) => tx.max_fee_per_blob_gas(),
|
||||||
|
Self::Eip1559(tx) => tx.max_fee_per_blob_gas(),
|
||||||
|
Self::Eip4844(tx) => tx.max_fee_per_blob_gas(),
|
||||||
|
Self::Eip7702(tx) => tx.max_fee_per_blob_gas(),
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
Self::Deposit(tx) => tx.max_fee_per_blob_gas(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn to(&self) -> TxKind {
|
||||||
|
match self {
|
||||||
|
Self::Legacy(tx) => tx.to(),
|
||||||
|
Self::Eip2930(tx) => tx.to(),
|
||||||
|
Self::Eip1559(tx) => tx.to(),
|
||||||
|
Self::Eip4844(tx) => tx.to(),
|
||||||
|
Self::Eip7702(tx) => tx.to(),
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
Self::Deposit(tx) => tx.to(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn value(&self) -> alloy_primitives::U256 {
|
||||||
|
match self {
|
||||||
|
Self::Legacy(tx) => tx.value(),
|
||||||
|
Self::Eip2930(tx) => tx.value(),
|
||||||
|
Self::Eip1559(tx) => tx.value(),
|
||||||
|
Self::Eip4844(tx) => tx.value(),
|
||||||
|
Self::Eip7702(tx) => tx.value(),
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
Self::Deposit(tx) => tx.value(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn input(&self) -> &[u8] {
|
||||||
|
match self {
|
||||||
|
Self::Legacy(tx) => tx.input(),
|
||||||
|
Self::Eip2930(tx) => tx.input(),
|
||||||
|
Self::Eip1559(tx) => tx.input(),
|
||||||
|
Self::Eip4844(tx) => tx.input(),
|
||||||
|
Self::Eip7702(tx) => tx.input(),
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
Self::Deposit(tx) => tx.input(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ty(&self) -> u8 {
|
||||||
|
match self {
|
||||||
|
Self::Legacy(tx) => tx.ty(),
|
||||||
|
Self::Eip2930(tx) => tx.ty(),
|
||||||
|
Self::Eip1559(tx) => tx.ty(),
|
||||||
|
Self::Eip4844(tx) => tx.ty(),
|
||||||
|
Self::Eip7702(tx) => tx.ty(),
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
Self::Deposit(tx) => tx.ty(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn access_list(&self) -> Option<&AccessList> {
|
||||||
|
match self {
|
||||||
|
Self::Legacy(tx) => tx.access_list(),
|
||||||
|
Self::Eip2930(tx) => tx.access_list(),
|
||||||
|
Self::Eip1559(tx) => tx.access_list(),
|
||||||
|
Self::Eip4844(tx) => tx.access_list(),
|
||||||
|
Self::Eip7702(tx) => tx.access_list(),
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
Self::Deposit(tx) => tx.access_list(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn blob_versioned_hashes(&self) -> Option<&[B256]> {
|
||||||
|
match self {
|
||||||
|
Self::Legacy(tx) => tx.blob_versioned_hashes(),
|
||||||
|
Self::Eip2930(tx) => tx.blob_versioned_hashes(),
|
||||||
|
Self::Eip1559(tx) => tx.blob_versioned_hashes(),
|
||||||
|
Self::Eip4844(tx) => tx.blob_versioned_hashes(),
|
||||||
|
Self::Eip7702(tx) => tx.blob_versioned_hashes(),
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
Self::Deposit(tx) => tx.blob_versioned_hashes(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn authorization_list(&self) -> Option<&[SignedAuthorization]> {
|
||||||
|
match self {
|
||||||
|
Self::Legacy(tx) => tx.authorization_list(),
|
||||||
|
Self::Eip2930(tx) => tx.authorization_list(),
|
||||||
|
Self::Eip1559(tx) => tx.authorization_list(),
|
||||||
|
Self::Eip4844(tx) => tx.authorization_list(),
|
||||||
|
Self::Eip7702(tx) => tx.authorization_list(),
|
||||||
|
#[cfg(feature = "optimism")]
|
||||||
|
Self::Deposit(tx) => tx.authorization_list(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Signed transaction without its Hash. Used type for inserting into the DB.
|
/// Signed transaction without its Hash. Used type for inserting into the DB.
|
||||||
///
|
///
|
||||||
/// This can by converted to [`TransactionSigned`] by calling [`TransactionSignedNoHash::hash`].
|
/// This can by converted to [`TransactionSigned`] by calling [`TransactionSignedNoHash::hash`].
|
||||||
|
|||||||
Reference in New Issue
Block a user