@@ -63,24 +63,9 @@ export class ExplorerAnalytics {
6363 ) : Promise < ExplorerType . GenericTransactionClassification > {
6464 const em = this . orm . em . fork ( )
6565 if ( this . isNativeTransactionHash ( hash ) ) {
66- const logs = await em . find ( Entities . EvmLog , {
67- transaction : { hash } ,
68- name : { $in : VALID_EVENTS }
69- } )
70- return logs . map ( log => ( {
71- transactionHash : hash ,
72- eventName : ExplorerType . TransactionType [
73- this . eventNameToTransactionType ( log . name ) ]
74- } ) )
66+ return this . nativeTransactionClassification ( em , hash )
7567 } else if ( this . isRippleTransactionHash ( hash ) ) {
76- const resp = await em . getConnection ( 'read' ) . execute (
77- SQL . EVENT_FROM_UNDERLYING_HASH , [ hash ]
78- ) as { hash : string , name : string } [ ]
79- return resp . map ( ( { hash, name } ) => ( {
80- transactionHash : hash ,
81- eventName :ExplorerType . TransactionType [
82- this . eventNameToTransactionType ( name ) ]
83- } ) )
68+ return this . rippleTransactionClassification ( em , hash )
8469 }
8570 throw new Error ( `don't recognize transaction hash ${ hash } format` )
8671 }
@@ -313,6 +298,16 @@ export class ExplorerAnalytics {
313298 )
314299 }
315300
301+ protected async nativeTransactionClassification ( em : EntityManager , hash : string ) : Promise < ExplorerType . GenericTransactionClassification > {
302+ const logs = await em . find ( Entities . EvmLog , { transaction : { hash } , name : { $in : VALID_EVENTS } } )
303+ return logs . map ( log => ( { transactionHash : hash , eventName : log . name } ) )
304+ }
305+
306+ protected async rippleTransactionClassification ( em : EntityManager , hash : string ) : Promise < ExplorerType . GenericTransactionClassification > {
307+ const resp = await em . getConnection ( 'read' ) . execute ( SQL . EVENT_FROM_UNDERLYING_HASH , [ hash ] ) as { hash : string , name : string } [ ]
308+ return resp . map ( ( { hash, name } ) => ( { transactionHash : hash , eventName : name } ) )
309+ }
310+
316311 protected eventNameToTransactionType ( name : string ) : ExplorerType . TransactionType {
317312 switch ( name ) {
318313 case 'CollateralReserved' :
0 commit comments