@@ -10,8 +10,8 @@ use alloy_eips::eip2718::{Decodable2718, Eip2718Error, Encodable2718};
1010use alloy_primitives:: { Address , Bloom , Bytes , Log , Signature , TxHash , TxKind , B256 , U256 , U64 } ;
1111use alloy_rlp:: { length_of_length, Decodable , Encodable , Header } ;
1212use alloy_rpc_types:: {
13- request:: TransactionRequest , AccessList , AnyTransactionReceipt , ConversionError ,
14- Signature as RpcSignature , Transaction as RpcTransaction , TransactionReceipt ,
13+ request:: TransactionRequest , trace :: otterscan :: OtsReceipt , AccessList , AnyTransactionReceipt ,
14+ ConversionError , Signature as RpcSignature , Transaction as RpcTransaction , TransactionReceipt ,
1515} ;
1616use alloy_serde:: { OtherFields , WithOtherFields } ;
1717use bytes:: BufMut ;
@@ -70,7 +70,7 @@ pub fn transaction_request_to_typed(
7070 gas_limit : gas. unwrap_or_default ( ) ,
7171 is_system_tx : other. get_deserialized :: < bool > ( "isSystemTx" ) ?. ok ( ) ?,
7272 input : input. into_input ( ) . unwrap_or_default ( ) ,
73- } ) )
73+ } ) ) ;
7474 }
7575
7676 match (
@@ -198,7 +198,7 @@ impl MaybeImpersonatedTransaction {
198198 #[ cfg( feature = "impersonated-tx" ) ]
199199 pub fn recover ( & self ) -> Result < Address , alloy_primitives:: SignatureError > {
200200 if let Some ( sender) = self . impersonated_sender {
201- return Ok ( sender)
201+ return Ok ( sender) ;
202202 }
203203 self . transaction . recover ( )
204204 }
@@ -211,7 +211,7 @@ impl MaybeImpersonatedTransaction {
211211 pub fn hash ( & self ) -> B256 {
212212 if self . transaction . is_impersonated ( ) {
213213 if let Some ( sender) = self . impersonated_sender {
214- return self . transaction . impersonated_hash ( sender)
214+ return self . transaction . impersonated_hash ( sender) ;
215215 }
216216 }
217217 self . transaction . hash ( )
@@ -1016,7 +1016,7 @@ impl Decodable for TypedTransaction {
10161016
10171017 // Legacy TX
10181018 if header. list {
1019- return Ok ( TxEnvelope :: decode ( buf) ?. into ( ) )
1019+ return Ok ( TxEnvelope :: decode ( buf) ?. into ( ) ) ;
10201020 }
10211021
10221022 // Check byte after header
@@ -1062,7 +1062,7 @@ impl Encodable2718 for TypedTransaction {
10621062impl Decodable2718 for TypedTransaction {
10631063 fn typed_decode ( ty : u8 , buf : & mut & [ u8 ] ) -> Result < Self , Eip2718Error > {
10641064 if ty == 0x7E {
1065- return Ok ( Self :: Deposit ( DepositTransaction :: decode ( buf) ?) )
1065+ return Ok ( Self :: Deposit ( DepositTransaction :: decode ( buf) ?) ) ;
10661066 }
10671067 match TxEnvelope :: typed_decode ( ty, buf) ? {
10681068 TxEnvelope :: Eip2930 ( tx) => Ok ( Self :: EIP2930 ( tx) ) ,
@@ -1245,6 +1245,37 @@ impl<T> TypedReceipt<T> {
12451245 }
12461246}
12471247
1248+ impl < T > From < TypedReceipt < T > > for ReceiptWithBloom < T > {
1249+ fn from ( value : TypedReceipt < T > ) -> Self {
1250+ match value {
1251+ TypedReceipt :: Legacy ( r) |
1252+ TypedReceipt :: EIP1559 ( r) |
1253+ TypedReceipt :: EIP2930 ( r) |
1254+ TypedReceipt :: EIP4844 ( r) => r,
1255+ TypedReceipt :: Deposit ( r) => r. inner ,
1256+ }
1257+ }
1258+ }
1259+
1260+ impl From < TypedReceipt < alloy_rpc_types:: Log > > for OtsReceipt {
1261+ fn from ( value : TypedReceipt < alloy_rpc_types:: Log > ) -> Self {
1262+ let r#type = match value {
1263+ TypedReceipt :: Legacy ( _) => 0x00 ,
1264+ TypedReceipt :: EIP2930 ( _) => 0x01 ,
1265+ TypedReceipt :: EIP1559 ( _) => 0x02 ,
1266+ TypedReceipt :: EIP4844 ( _) => 0x03 ,
1267+ TypedReceipt :: Deposit ( _) => 0x7E ,
1268+ } as u8 ;
1269+ let receipt = ReceiptWithBloom :: < alloy_rpc_types:: Log > :: from ( value) ;
1270+ let status = receipt. status ( ) ;
1271+ let cumulative_gas_used = receipt. cumulative_gas_used ( ) as u64 ;
1272+ let logs = receipt. receipt . logs . into_iter ( ) . map ( |x| x. inner ) . collect ( ) ;
1273+ let logs_bloom = receipt. logs_bloom ;
1274+
1275+ Self { status, cumulative_gas_used, logs : Some ( logs) , logs_bloom : Some ( logs_bloom) , r#type }
1276+ }
1277+ }
1278+
12481279impl TypedReceipt {
12491280 pub fn cumulative_gas_used ( & self ) -> u128 {
12501281 self . as_receipt_with_bloom ( ) . cumulative_gas_used ( )
@@ -1395,7 +1426,7 @@ impl Encodable2718 for TypedReceipt {
13951426impl Decodable2718 for TypedReceipt {
13961427 fn typed_decode ( ty : u8 , buf : & mut & [ u8 ] ) -> Result < Self , Eip2718Error > {
13971428 if ty == 0x7E {
1398- return Ok ( Self :: Deposit ( DepositReceipt :: decode ( buf) ?) )
1429+ return Ok ( Self :: Deposit ( DepositReceipt :: decode ( buf) ?) ) ;
13991430 }
14001431 match ReceiptEnvelope :: typed_decode ( ty, buf) ? {
14011432 ReceiptEnvelope :: Eip2930 ( tx) => Ok ( Self :: EIP2930 ( tx) ) ,
0 commit comments