11//! Transaction related types
22use alloy_consensus:: {
3+ Receipt , ReceiptEnvelope , ReceiptWithBloom , Signed , Transaction , TxEip1559 , TxEip2930 ,
4+ TxEnvelope , TxLegacy , TxReceipt , Typed2718 ,
35 transaction:: {
4- eip4844:: { TxEip4844 , TxEip4844Variant , TxEip4844WithSidecar } ,
56 Recovered , TxEip7702 ,
7+ eip4844:: { TxEip4844 , TxEip4844Variant , TxEip4844WithSidecar } ,
68 } ,
7- Receipt , ReceiptEnvelope , ReceiptWithBloom , Signed , Transaction , TxEip1559 , TxEip2930 ,
8- TxEnvelope , TxLegacy , TxReceipt , Typed2718 ,
99} ;
1010use alloy_eips:: eip2718:: { Decodable2718 , Eip2718Error , Encodable2718 } ;
1111use alloy_network:: { AnyReceiptEnvelope , AnyRpcTransaction , AnyTransactionReceipt , AnyTxEnvelope } ;
12- use alloy_primitives:: { Address , Bloom , Bytes , Log , Signature , TxHash , TxKind , B256 , U256 , U64 } ;
13- use alloy_rlp:: { length_of_length , Decodable , Encodable , Header } ;
12+ use alloy_primitives:: { Address , B256 , Bloom , Bytes , Log , Signature , TxHash , TxKind , U64 , U256 } ;
13+ use alloy_rlp:: { Decodable , Encodable , Header , length_of_length } ;
1414use alloy_rpc_types:: {
15- request :: TransactionRequest , trace :: otterscan :: OtsReceipt , AccessList , ConversionError ,
16- Transaction as RpcTransaction , TransactionReceipt ,
15+ AccessList , ConversionError , Transaction as RpcTransaction , TransactionReceipt ,
16+ request :: TransactionRequest , trace :: otterscan :: OtsReceipt ,
1717} ;
1818use alloy_serde:: { OtherFields , WithOtherFields } ;
1919use bytes:: BufMut ;
2020use foundry_evm:: traces:: CallTraceNode ;
21- use op_alloy_consensus:: { TxDeposit , DEPOSIT_TX_TYPE_ID } ;
22- use op_revm:: { transaction:: deposit:: DepositTransactionParts , OpTransaction } ;
21+ use op_alloy_consensus:: { DEPOSIT_TX_TYPE_ID , TxDeposit } ;
22+ use op_revm:: { OpTransaction , transaction:: deposit:: DepositTransactionParts } ;
2323use revm:: { context:: TxEnv , interpreter:: InstructionResult } ;
2424use serde:: { Deserialize , Serialize } ;
2525use std:: ops:: { Deref , Mul } ;
@@ -97,8 +97,8 @@ pub fn transaction_request_to_typed(
9797 to,
9898 ) {
9999 // legacy transaction
100- ( Some ( 0 ) , _, None , None , None , None , None , None , _) |
101- ( None , Some ( _) , None , None , None , None , None , None , _) => {
100+ ( Some ( 0 ) , _, None , None , None , None , None , None , _)
101+ | ( None , Some ( _) , None , None , None , None , None , None , _) => {
102102 Some ( TypedTransactionRequest :: Legacy ( TxLegacy {
103103 nonce : nonce. unwrap_or_default ( ) ,
104104 gas_price : gas_price. unwrap_or_default ( ) ,
@@ -110,8 +110,8 @@ pub fn transaction_request_to_typed(
110110 } ) )
111111 }
112112 // EIP2930
113- ( Some ( 1 ) , _, None , None , _, None , None , None , _) |
114- ( None , _, None , None , Some ( _) , None , None , None , _) => {
113+ ( Some ( 1 ) , _, None , None , _, None , None , None , _)
114+ | ( None , _, None , None , Some ( _) , None , None , None , _) => {
115115 Some ( TypedTransactionRequest :: EIP2930 ( TxEip2930 {
116116 nonce : nonce. unwrap_or_default ( ) ,
117117 gas_price : gas_price. unwrap_or_default ( ) ,
@@ -124,10 +124,10 @@ pub fn transaction_request_to_typed(
124124 } ) )
125125 }
126126 // EIP1559
127- ( Some ( 2 ) , None , _, _, _, _, None , None , _) |
128- ( None , None , Some ( _) , _, _, _, None , None , _) |
129- ( None , None , _, Some ( _) , _, _, None , None , _) |
130- ( None , None , None , None , None , _, None , None , _) => {
127+ ( Some ( 2 ) , None , _, _, _, _, None , None , _)
128+ | ( None , None , Some ( _) , _, _, _, None , None , _)
129+ | ( None , None , _, Some ( _) , _, _, None , None , _)
130+ | ( None , None , None , None , None , _, None , None , _) => {
131131 // Empty fields fall back to the canonical transaction schema.
132132 Some ( TypedTransactionRequest :: EIP1559 ( TxEip1559 {
133133 nonce : nonce. unwrap_or_default ( ) ,
@@ -173,9 +173,9 @@ pub fn transaction_request_to_typed(
173173}
174174
175175pub fn has_optimism_fields ( other : & OtherFields ) -> bool {
176- other. contains_key ( "sourceHash" ) &&
177- other. contains_key ( "mint" ) &&
178- other. contains_key ( "isSystemTx" )
176+ other. contains_key ( "sourceHash" )
177+ && other. contains_key ( "mint" )
178+ && other. contains_key ( "isSystemTx" )
179179}
180180
181181#[ derive( Clone , Debug , PartialEq , Eq ) ]
@@ -225,7 +225,7 @@ impl MaybeImpersonatedTransaction {
225225 /// Returns the hash of the transaction
226226 pub fn hash ( & self ) -> B256 {
227227 if let Some ( sender) = self . impersonated_sender {
228- return self . transaction . impersonated_hash ( sender)
228+ return self . transaction . impersonated_hash ( sender) ;
229229 }
230230 self . transaction . hash ( )
231231 }
@@ -1006,7 +1006,7 @@ impl Encodable2718 for TypedTransaction {
10061006impl Decodable2718 for TypedTransaction {
10071007 fn typed_decode ( ty : u8 , buf : & mut & [ u8 ] ) -> Result < Self , Eip2718Error > {
10081008 if ty == 0x7E {
1009- return Ok ( Self :: Deposit ( TxDeposit :: decode ( buf) ?) )
1009+ return Ok ( Self :: Deposit ( TxDeposit :: decode ( buf) ?) ) ;
10101010 }
10111011 match TxEnvelope :: typed_decode ( ty, buf) ? {
10121012 TxEnvelope :: Eip2930 ( tx) => Ok ( Self :: EIP2930 ( tx) ) ,
@@ -1081,12 +1081,12 @@ pub struct DepositReceipt<T = Receipt<alloy_primitives::Log>> {
10811081
10821082impl DepositReceipt {
10831083 fn payload_len ( & self ) -> usize {
1084- self . inner . receipt . status . length ( ) +
1085- self . inner . receipt . cumulative_gas_used . length ( ) +
1086- self . inner . logs_bloom . length ( ) +
1087- self . inner . receipt . logs . length ( ) +
1088- self . deposit_nonce . map_or ( 0 , |n| n. length ( ) ) +
1089- self . deposit_receipt_version . map_or ( 0 , |n| n. length ( ) )
1084+ self . inner . receipt . status . length ( )
1085+ + self . inner . receipt . cumulative_gas_used . length ( )
1086+ + self . inner . logs_bloom . length ( )
1087+ + self . inner . receipt . logs . length ( )
1088+ + self . deposit_nonce . map_or ( 0 , |n| n. length ( ) )
1089+ + self . deposit_receipt_version . map_or ( 0 , |n| n. length ( ) )
10901090 }
10911091
10921092 /// Returns the rlp header for the receipt payload.
@@ -1186,11 +1186,11 @@ pub enum TypedReceipt<T = Receipt<alloy_primitives::Log>> {
11861186impl < T > TypedReceipt < T > {
11871187 pub fn as_receipt_with_bloom ( & self ) -> & ReceiptWithBloom < T > {
11881188 match self {
1189- Self :: Legacy ( r) |
1190- Self :: EIP1559 ( r) |
1191- Self :: EIP2930 ( r) |
1192- Self :: EIP4844 ( r) |
1193- Self :: EIP7702 ( r) => r,
1189+ Self :: Legacy ( r)
1190+ | Self :: EIP1559 ( r)
1191+ | Self :: EIP2930 ( r)
1192+ | Self :: EIP4844 ( r)
1193+ | Self :: EIP7702 ( r) => r,
11941194 Self :: Deposit ( r) => & r. inner ,
11951195 }
11961196 }
@@ -1199,11 +1199,11 @@ impl<T> TypedReceipt<T> {
11991199impl < T > From < TypedReceipt < T > > for ReceiptWithBloom < T > {
12001200 fn from ( value : TypedReceipt < T > ) -> Self {
12011201 match value {
1202- TypedReceipt :: Legacy ( r) |
1203- TypedReceipt :: EIP1559 ( r) |
1204- TypedReceipt :: EIP2930 ( r) |
1205- TypedReceipt :: EIP4844 ( r) |
1206- TypedReceipt :: EIP7702 ( r) => r,
1202+ TypedReceipt :: Legacy ( r)
1203+ | TypedReceipt :: EIP1559 ( r)
1204+ | TypedReceipt :: EIP2930 ( r)
1205+ | TypedReceipt :: EIP4844 ( r)
1206+ | TypedReceipt :: EIP7702 ( r) => r,
12071207 TypedReceipt :: Deposit ( r) => r. inner ,
12081208 }
12091209 }
@@ -1371,11 +1371,11 @@ impl Encodable2718 for TypedReceipt {
13711371 out. put_u8 ( ty) ;
13721372 }
13731373 match self {
1374- Self :: Legacy ( r) |
1375- Self :: EIP2930 ( r) |
1376- Self :: EIP1559 ( r) |
1377- Self :: EIP4844 ( r) |
1378- Self :: EIP7702 ( r) => r. encode ( out) ,
1374+ Self :: Legacy ( r)
1375+ | Self :: EIP2930 ( r)
1376+ | Self :: EIP1559 ( r)
1377+ | Self :: EIP4844 ( r)
1378+ | Self :: EIP7702 ( r) => r. encode ( out) ,
13791379 Self :: Deposit ( r) => r. encode ( out) ,
13801380 }
13811381 }
@@ -1463,7 +1463,7 @@ pub fn convert_to_anvil_receipt(receipt: AnyTransactionReceipt) -> Option<Receip
14631463#[ cfg( test) ]
14641464mod tests {
14651465 use super :: * ;
1466- use alloy_primitives:: { b256 , hex , LogData } ;
1466+ use alloy_primitives:: { LogData , b256 , hex } ;
14671467 use std:: str:: FromStr ;
14681468
14691469 // <https://github.com/foundry-rs/foundry/issues/10852>
0 commit comments