Skip to content

Commit

Permalink
chore: reorder impl fns (#342)
Browse files Browse the repository at this point in the history
use same order as trait
  • Loading branch information
mattsse authored Dec 14, 2024
1 parent f7c5270 commit d5b9014
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 80 deletions.
8 changes: 4 additions & 4 deletions crates/consensus/src/transaction/deposit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,6 @@ impl Transaction for TxDeposit {
None
}

fn is_create(&self) -> bool {
self.to.is_create()
}

fn nonce(&self) -> u64 {
0u64
}
Expand Down Expand Up @@ -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
}
Expand Down
72 changes: 36 additions & 36 deletions crates/consensus/src/transaction/envelope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -183,13 +173,23 @@ impl Transaction for OpTxEnvelope {
}
}

fn to(&self) -> Option<Address> {
fn effective_gas_price(&self, base_fee: Option<u64>) -> 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(),
}
}

Expand All @@ -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<Address> {
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(),
Expand Down Expand Up @@ -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<u64>) -> 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 {
Expand Down
72 changes: 36 additions & 36 deletions crates/consensus/src/transaction/typed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -218,13 +208,23 @@ impl Transaction for OpTypedTransaction {
}
}

fn to(&self) -> Option<Address> {
fn effective_gas_price(&self, base_fee: Option<u64>) -> 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(),
}
}

Expand All @@ -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<Address> {
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(),
Expand Down Expand Up @@ -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<u64>) -> 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")]
Expand Down
8 changes: 4 additions & 4 deletions crates/rpc-types/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down Expand Up @@ -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<Address> {
self.inner.to()
}
Expand Down

0 comments on commit d5b9014

Please sign in to comment.