mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: remove txext trait (#12760)
This commit is contained in:
@ -29,7 +29,7 @@ pub use transaction::{
|
||||
execute::FillTxEnv,
|
||||
signed::{FullSignedTx, SignedTransaction},
|
||||
tx_type::{FullTxType, TxType},
|
||||
FullTransaction, Transaction, TransactionExt,
|
||||
FullTransaction, Transaction,
|
||||
};
|
||||
|
||||
mod integer_list;
|
||||
|
||||
@ -4,16 +4,13 @@ pub mod execute;
|
||||
pub mod signed;
|
||||
pub mod tx_type;
|
||||
|
||||
use crate::{InMemorySize, MaybeArbitrary, MaybeCompact, MaybeSerde};
|
||||
use core::{fmt, hash::Hash};
|
||||
|
||||
use alloy_primitives::B256;
|
||||
|
||||
use crate::{FullTxType, InMemorySize, MaybeArbitrary, MaybeCompact, MaybeSerde, TxType};
|
||||
|
||||
/// Helper trait that unifies all behaviour required by transaction to support full node operations.
|
||||
pub trait FullTransaction: Transaction<Type: FullTxType> + MaybeCompact {}
|
||||
pub trait FullTransaction: Transaction + MaybeCompact {}
|
||||
|
||||
impl<T> FullTransaction for T where T: Transaction<Type: FullTxType> + MaybeCompact {}
|
||||
impl<T> FullTransaction for T where T: Transaction + MaybeCompact {}
|
||||
|
||||
/// Abstraction of a transaction.
|
||||
pub trait Transaction:
|
||||
@ -26,7 +23,7 @@ pub trait Transaction:
|
||||
+ Eq
|
||||
+ PartialEq
|
||||
+ Hash
|
||||
+ TransactionExt
|
||||
+ alloy_consensus::Transaction
|
||||
+ InMemorySize
|
||||
+ MaybeSerde
|
||||
+ MaybeArbitrary
|
||||
@ -43,25 +40,9 @@ impl<T> Transaction for T where
|
||||
+ Eq
|
||||
+ PartialEq
|
||||
+ Hash
|
||||
+ TransactionExt
|
||||
+ alloy_consensus::Transaction
|
||||
+ InMemorySize
|
||||
+ MaybeSerde
|
||||
+ MaybeArbitrary
|
||||
{
|
||||
}
|
||||
|
||||
/// Extension trait of [`alloy_consensus::Transaction`].
|
||||
#[auto_impl::auto_impl(&, Arc)]
|
||||
pub trait TransactionExt: alloy_consensus::Transaction {
|
||||
/// Transaction envelope type ID.
|
||||
type Type: TxType;
|
||||
|
||||
/// Heavy operation that return signature hash over rlp encoded transaction.
|
||||
/// It is only for signature signing or signer recovery.
|
||||
fn signature_hash(&self) -> B256;
|
||||
|
||||
/// Returns the transaction type.
|
||||
fn tx_type(&self) -> Self::Type {
|
||||
Self::Type::try_from(self.ty()).expect("should decode tx type id")
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,25 +1,15 @@
|
||||
//! API of a signed transaction.
|
||||
|
||||
use crate::{FillTxEnv, InMemorySize, MaybeArbitrary, MaybeCompact, MaybeSerde, TxType};
|
||||
use alloc::fmt;
|
||||
use core::hash::Hash;
|
||||
|
||||
use alloy_eips::eip2718::{Decodable2718, Encodable2718};
|
||||
use alloy_primitives::{keccak256, Address, PrimitiveSignature, TxHash, B256};
|
||||
|
||||
use crate::{
|
||||
FillTxEnv, FullTransaction, InMemorySize, MaybeArbitrary, MaybeCompact, MaybeSerde, Transaction,
|
||||
};
|
||||
use core::hash::Hash;
|
||||
|
||||
/// Helper trait that unifies all behaviour required by block to support full node operations.
|
||||
pub trait FullSignedTx:
|
||||
SignedTransaction<Transaction: FullTransaction> + FillTxEnv + MaybeCompact
|
||||
{
|
||||
}
|
||||
pub trait FullSignedTx: SignedTransaction + FillTxEnv + MaybeCompact {}
|
||||
|
||||
impl<T> FullSignedTx for T where
|
||||
T: SignedTransaction<Transaction: FullTransaction> + FillTxEnv + MaybeCompact
|
||||
{
|
||||
}
|
||||
impl<T> FullSignedTx for T where T: SignedTransaction + FillTxEnv + MaybeCompact {}
|
||||
|
||||
/// A signed transaction.
|
||||
#[auto_impl::auto_impl(&, Arc)]
|
||||
@ -42,15 +32,17 @@ pub trait SignedTransaction:
|
||||
+ MaybeArbitrary
|
||||
+ InMemorySize
|
||||
{
|
||||
/// Unsigned transaction type.
|
||||
type Transaction: Transaction;
|
||||
/// Transaction envelope type ID.
|
||||
type Type: TxType;
|
||||
|
||||
/// Returns the transaction type.
|
||||
fn tx_type(&self) -> Self::Type {
|
||||
Self::Type::try_from(self.ty()).expect("should decode tx type id")
|
||||
}
|
||||
|
||||
/// Returns reference to transaction hash.
|
||||
fn tx_hash(&self) -> &TxHash;
|
||||
|
||||
/// Returns reference to transaction.
|
||||
fn transaction(&self) -> &Self::Transaction;
|
||||
|
||||
/// Returns reference to signature.
|
||||
fn signature(&self) -> &PrimitiveSignature;
|
||||
|
||||
@ -78,15 +70,3 @@ pub trait SignedTransaction:
|
||||
keccak256(self.encoded_2718())
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper trait used in testing.
|
||||
#[cfg(feature = "test-utils")]
|
||||
pub trait SignedTransactionTesting: SignedTransaction {
|
||||
/// Create a new signed transaction from a transaction and its signature.
|
||||
///
|
||||
/// This will also calculate the transaction hash using its encoding.
|
||||
fn from_transaction_and_signature(
|
||||
transaction: Self::Transaction,
|
||||
signature: PrimitiveSignature,
|
||||
) -> Self;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user