11import { unPrefix0x } from '@flarenetwork/mcc' ;
22import { Injectable } from '@nestjs/common' ;
33import { ConfigService } from '@nestjs/config' ;
4+ import { ApiDBVersion } from '../../dtos/indexer/ApiDbVersion.dto' ;
45import { EntityManager } from 'typeorm' ;
56import { IConfig , VerifierServerConfig } from '../../config/configuration' ;
67import { ApiDBBlock } from '../../dtos/indexer/ApiDbBlock.dto' ;
78import { ApiDBState } from '../../dtos/indexer/ApiDbState.dto' ;
89import { ApiDBTransaction } from '../../dtos/indexer/ApiDbTransaction.dto' ;
10+ import { Version } from '../../dtos/indexer/ApiDbVersion.dto' ;
911import { QueryBlock } from '../../dtos/indexer/QueryBlock.dto' ;
1012import { QueryTransaction } from '../../dtos/indexer/QueryTransaction.dto' ;
1113import {
@@ -20,7 +22,6 @@ import {
2022} from '../../entity/xrp-entity-definitions' ;
2123import { PaginatedList } from '../../utils/api-models/PaginatedList' ;
2224import { IIndexerEngineService } from '../common/base-indexer-engine-service' ;
23- import { ApiDBVersion } from 'src/dtos/indexer/ApiDbVersion.dto' ;
2425
2526@Injectable ( )
2627export class XrpExternalIndexerEngineService extends IIndexerEngineService {
@@ -72,16 +73,41 @@ export class XrpExternalIndexerEngineService extends IIndexerEngineService {
7273 return response ;
7374 }
7475
76+ /**
77+ * Gets the version of the indexer service.
78+ */
7579 public async getIndexerServiceVersion ( ) : Promise < ApiDBVersion > {
7680 const queryVersion = this . manager . createQueryBuilder (
7781 this . versionTable ,
7882 'version' ,
7983 ) ;
84+
8085 const resVersion = await queryVersion . getOne ( ) ;
8186 if ( ! resVersion ) {
8287 throw new Error ( 'No versions state found in the indexer database' ) ;
8388 }
84- return resVersion . toApiDBVersion ( ) ;
89+
90+ let versions = resVersion . toApiDBVersion ( ) ;
91+
92+ const [ gitTag , gitHash , buildDate ] = await Promise . all ( [
93+ XrpExternalIndexerEngineService . readVersionFile (
94+ '../../../PROJECT_VERSION' ,
95+ ) ,
96+ XrpExternalIndexerEngineService . readVersionFile (
97+ '../../../PROJECT_COMMIT_HASH' ,
98+ ) ,
99+ XrpExternalIndexerEngineService . readVersionFile (
100+ '../../../PROJECT_BUILD_DATE' ,
101+ ) ,
102+ ] ) ;
103+ const apiServerVersion : Version = {
104+ gitTag : gitTag || 'local' ,
105+ gitHash : gitHash || 'local' ,
106+ buildDate : Number ( buildDate ) || Math . floor ( Date . now ( ) / 1000 ) ,
107+ } ;
108+ versions . apiServer = apiServerVersion ;
109+
110+ return versions ;
85111 }
86112
87113 public async confirmedBlockAt (
0 commit comments