@@ -20,6 +20,7 @@ import { TransactionOperationType } from "./entities/transaction.operation.type"
2020import { QueryPagination } from "src/common/entities/query.pagination" ;
2121import { NftFilter } from "../nfts/entities/nft.filter" ;
2222import { TokenAccount } from "src/common/indexer/entities" ;
23+ import { ApiConfigService } from "../../common/api-config/api.config.service" ;
2324
2425@Injectable ( )
2526export class TransactionGetService {
@@ -30,6 +31,7 @@ export class TransactionGetService {
3031 private readonly gatewayService : GatewayService ,
3132 @Inject ( forwardRef ( ( ) => TokenTransferService ) )
3233 private readonly tokenTransferService : TokenTransferService ,
34+ private readonly apiConfigService : ApiConfigService ,
3335 ) { }
3436
3537 private async tryGetTransactionFromElasticBySenderAndNonce ( sender : string , nonce : number ) : Promise < TransactionDetailed | undefined > {
@@ -51,8 +53,22 @@ export class TransactionGetService {
5153 return result . map ( x => ApiUtils . mergeObjects ( new TransactionLog ( ) , x ) ) ;
5254 }
5355
54- private async getTransactionLogsFromElasticInternal ( hashes : string [ ] ) : Promise < any [ ] > {
55- const rawHits = await this . indexerService . getTransactionLogs ( hashes ) ;
56+ private async getTransactionLogsFromElasticInternal ( hashes : string [ ] ) {
57+ const esMigratedIndices = this . apiConfigService . getElasticMigratedIndicesConfig ( ) ;
58+ const index = esMigratedIndices ?. [ 'logs' ] ?? 'logs' ;
59+ if ( index === 'events' ) {
60+ return await this . getTransactionLogsFromElasticInternalEventsIndex ( hashes ) ;
61+ }
62+
63+ return await this . getTransactionLogsFromElasticInternalLogsIndex ( hashes ) ;
64+ }
65+
66+ private async getTransactionLogsFromElasticInternalLogsIndex ( hashes : string [ ] ) : Promise < any [ ] > {
67+ return await this . indexerService . getTransactionLogs ( hashes , 'logs' , '_id' ) ;
68+ }
69+
70+ private async getTransactionLogsFromElasticInternalEventsIndex ( hashes : string [ ] ) : Promise < any [ ] > {
71+ const rawHits = await this . indexerService . getTransactionLogs ( hashes , 'events' , 'txHash' ) ;
5672
5773 const logsMap : Map < string , TransactionLog > = new Map ( ) ;
5874
0 commit comments