diff --git a/crates/consensus/src/transaction/deposit.rs b/crates/consensus/src/transaction/deposit.rs index d0cf7d17..75149600 100644 --- a/crates/consensus/src/transaction/deposit.rs +++ b/crates/consensus/src/transaction/deposit.rs @@ -236,10 +236,6 @@ impl Transaction for TxDeposit { None } - fn is_create(&self) -> bool { - self.to.is_create() - } - fn nonce(&self) -> u64 { 0u64 } @@ -280,6 +276,10 @@ impl Transaction for TxDeposit { self.to } + fn is_create(&self) -> bool { + self.to.is_create() + } + fn value(&self) -> U256 { self.value } diff --git a/crates/consensus/src/transaction/envelope.rs b/crates/consensus/src/transaction/envelope.rs index b9392fd9..42c4e92d 100644 --- a/crates/consensus/src/transaction/envelope.rs +++ b/crates/consensus/src/transaction/envelope.rs @@ -103,16 +103,6 @@ impl Transaction for OpTxEnvelope { } } - fn is_create(&self) -> bool { - match self { - Self::Legacy(tx) => tx.tx().is_create(), - Self::Eip2930(tx) => tx.tx().is_create(), - Self::Eip1559(tx) => tx.tx().is_create(), - Self::Eip7702(tx) => tx.tx().is_create(), - Self::Deposit(tx) => tx.is_create(), - } - } - fn nonce(&self) -> u64 { match self { Self::Legacy(tx) => tx.tx().nonce(), @@ -183,13 +173,23 @@ impl Transaction for OpTxEnvelope { } } - fn to(&self) -> Option
{ + fn effective_gas_price(&self, base_fee: Option) -> u128 { match self { - Self::Legacy(tx) => tx.tx().to(), - Self::Eip2930(tx) => tx.tx().to(), - Self::Eip1559(tx) => tx.tx().to(), - Self::Eip7702(tx) => tx.tx().to(), - Self::Deposit(tx) => tx.to(), + Self::Legacy(tx) => tx.tx().effective_gas_price(base_fee), + Self::Eip2930(tx) => tx.tx().effective_gas_price(base_fee), + Self::Eip1559(tx) => tx.tx().effective_gas_price(base_fee), + Self::Eip7702(tx) => tx.tx().effective_gas_price(base_fee), + Self::Deposit(tx) => tx.effective_gas_price(base_fee), + } + } + + fn is_dynamic_fee(&self) -> bool { + match self { + Self::Legacy(tx) => tx.tx().is_dynamic_fee(), + Self::Eip2930(tx) => tx.tx().is_dynamic_fee(), + Self::Eip1559(tx) => tx.tx().is_dynamic_fee(), + Self::Eip7702(tx) => tx.tx().is_dynamic_fee(), + Self::Deposit(tx) => tx.is_dynamic_fee(), } } @@ -203,6 +203,26 @@ impl Transaction for OpTxEnvelope { } } + fn is_create(&self) -> bool { + match self { + Self::Legacy(tx) => tx.tx().is_create(), + Self::Eip2930(tx) => tx.tx().is_create(), + Self::Eip1559(tx) => tx.tx().is_create(), + Self::Eip7702(tx) => tx.tx().is_create(), + Self::Deposit(tx) => tx.is_create(), + } + } + + fn to(&self) -> Option
{ + match self { + Self::Legacy(tx) => tx.tx().to(), + Self::Eip2930(tx) => tx.tx().to(), + Self::Eip1559(tx) => tx.tx().to(), + Self::Eip7702(tx) => tx.tx().to(), + Self::Deposit(tx) => tx.to(), + } + } + fn value(&self) -> U256 { match self { Self::Legacy(tx) => tx.tx().value(), @@ -252,26 +272,6 @@ impl Transaction for OpTxEnvelope { Self::Deposit(tx) => tx.authorization_list(), } } - - fn is_dynamic_fee(&self) -> bool { - match self { - Self::Legacy(tx) => tx.tx().is_dynamic_fee(), - Self::Eip2930(tx) => tx.tx().is_dynamic_fee(), - Self::Eip1559(tx) => tx.tx().is_dynamic_fee(), - Self::Eip7702(tx) => tx.tx().is_dynamic_fee(), - Self::Deposit(tx) => tx.is_dynamic_fee(), - } - } - - fn effective_gas_price(&self, base_fee: Option) -> u128 { - match self { - Self::Legacy(tx) => tx.tx().effective_gas_price(base_fee), - Self::Eip2930(tx) => tx.tx().effective_gas_price(base_fee), - Self::Eip1559(tx) => tx.tx().effective_gas_price(base_fee), - Self::Eip7702(tx) => tx.tx().effective_gas_price(base_fee), - Self::Deposit(tx) => tx.effective_gas_price(base_fee), - } - } } impl OpTxEnvelope { diff --git a/crates/consensus/src/transaction/typed.rs b/crates/consensus/src/transaction/typed.rs index eda32684..d223f471 100644 --- a/crates/consensus/src/transaction/typed.rs +++ b/crates/consensus/src/transaction/typed.rs @@ -138,16 +138,6 @@ impl Transaction for OpTypedTransaction { } } - fn is_create(&self) -> bool { - match self { - Self::Legacy(tx) => tx.is_create(), - Self::Eip2930(tx) => tx.is_create(), - Self::Eip1559(tx) => tx.is_create(), - Self::Eip7702(tx) => tx.is_create(), - Self::Deposit(tx) => tx.is_create(), - } - } - fn nonce(&self) -> u64 { match self { Self::Legacy(tx) => tx.nonce(), @@ -218,13 +208,23 @@ impl Transaction for OpTypedTransaction { } } - fn to(&self) -> Option
{ + fn effective_gas_price(&self, base_fee: Option) -> u128 { match self { - Self::Legacy(tx) => tx.to(), - Self::Eip2930(tx) => tx.to(), - Self::Eip1559(tx) => tx.to(), - Self::Eip7702(tx) => tx.to(), - Self::Deposit(tx) => tx.to(), + Self::Legacy(tx) => tx.effective_gas_price(base_fee), + Self::Eip2930(tx) => tx.effective_gas_price(base_fee), + Self::Eip1559(tx) => tx.effective_gas_price(base_fee), + Self::Eip7702(tx) => tx.effective_gas_price(base_fee), + Self::Deposit(tx) => tx.effective_gas_price(base_fee), + } + } + + fn is_dynamic_fee(&self) -> bool { + match self { + Self::Legacy(tx) => tx.is_dynamic_fee(), + Self::Eip2930(tx) => tx.is_dynamic_fee(), + Self::Eip1559(tx) => tx.is_dynamic_fee(), + Self::Eip7702(tx) => tx.is_dynamic_fee(), + Self::Deposit(tx) => tx.is_dynamic_fee(), } } @@ -238,6 +238,26 @@ impl Transaction for OpTypedTransaction { } } + fn is_create(&self) -> bool { + match self { + Self::Legacy(tx) => tx.is_create(), + Self::Eip2930(tx) => tx.is_create(), + Self::Eip1559(tx) => tx.is_create(), + Self::Eip7702(tx) => tx.is_create(), + Self::Deposit(tx) => tx.is_create(), + } + } + + fn to(&self) -> Option
{ + match self { + Self::Legacy(tx) => tx.to(), + Self::Eip2930(tx) => tx.to(), + Self::Eip1559(tx) => tx.to(), + Self::Eip7702(tx) => tx.to(), + Self::Deposit(tx) => tx.to(), + } + } + fn value(&self) -> alloy_primitives::U256 { match self { Self::Legacy(tx) => tx.value(), @@ -287,26 +307,6 @@ impl Transaction for OpTypedTransaction { Self::Deposit(tx) => tx.authorization_list(), } } - - fn is_dynamic_fee(&self) -> bool { - match self { - Self::Legacy(tx) => tx.is_dynamic_fee(), - Self::Eip2930(tx) => tx.is_dynamic_fee(), - Self::Eip1559(tx) => tx.is_dynamic_fee(), - Self::Eip7702(tx) => tx.is_dynamic_fee(), - Self::Deposit(tx) => tx.is_dynamic_fee(), - } - } - - fn effective_gas_price(&self, base_fee: Option) -> u128 { - match self { - Self::Legacy(tx) => tx.effective_gas_price(base_fee), - Self::Eip2930(tx) => tx.effective_gas_price(base_fee), - Self::Eip1559(tx) => tx.effective_gas_price(base_fee), - Self::Eip7702(tx) => tx.effective_gas_price(base_fee), - Self::Deposit(tx) => tx.effective_gas_price(base_fee), - } - } } #[cfg(feature = "serde")] diff --git a/crates/rpc-types/src/transaction.rs b/crates/rpc-types/src/transaction.rs index 9a3d19c4..81504d5b 100644 --- a/crates/rpc-types/src/transaction.rs +++ b/crates/rpc-types/src/transaction.rs @@ -40,10 +40,6 @@ impl alloy_consensus::Transaction for Transaction { self.inner.chain_id() } - fn is_create(&self) -> bool { - self.inner.is_create() - } - fn nonce(&self) -> u64 { self.inner.nonce() } @@ -84,6 +80,10 @@ impl alloy_consensus::Transaction for Transaction { self.inner.kind() } + fn is_create(&self) -> bool { + self.inner.is_create() + } + fn to(&self) -> Option
{ self.inner.to() }