diff --git a/src/common/indexer/elastic/elastic.indexer.service.ts b/src/common/indexer/elastic/elastic.indexer.service.ts index 20c68e760..460c674ae 100644 --- a/src/common/indexer/elastic/elastic.indexer.service.ts +++ b/src/common/indexer/elastic/elastic.indexer.service.ts @@ -430,6 +430,7 @@ export class ElasticIndexerService implements IndexerInterface { .withSort([ { name: 'timestamp', order: ElasticSortOrder.ascending }, { name: 'timestampMs', order: ElasticSortOrder.ascending, missing: 0 }, + { name: 'nonce', order: ElasticSortOrder.ascending }, { name: 'uuid.keyword', order: ElasticSortOrder.ascending }, ]) .withMustMultiShouldCondition(transactionHashes, hash => QueryType.Match('originalTxHash', hash)); @@ -477,6 +478,7 @@ export class ElasticIndexerService implements IndexerInterface { .withSort([ { name: 'timestamp', order: ElasticSortOrder.descending }, { name: 'timestampMs', order: ElasticSortOrder.descending, missing: 0 }, + { name: 'nonce', order: ElasticSortOrder.descending }, { name: 'uuid.keyword', order: ElasticSortOrder.descending }, ]); @@ -514,6 +516,7 @@ export class ElasticIndexerService implements IndexerInterface { .withSort([ { name: 'timestamp', order: ElasticSortOrder.descending }, { name: 'timestampMs', order: ElasticSortOrder.descending, missing: 0 }, + { name: 'nonce', order: ElasticSortOrder.descending }, { name: 'uuid.keyword', order: ElasticSortOrder.descending }, ]); @@ -772,12 +775,13 @@ export class ElasticIndexerService implements IndexerInterface { const originalTxHashQuery = QueryType.Match('originalTxHash', txHash); const timestamp: ElasticSortProperty = { name: 'timestamp', order: ElasticSortOrder.ascending }; const timestampMs: ElasticSortProperty = { name: 'timestampMs', order: ElasticSortOrder.ascending, missing: 0 }; + const nonce: ElasticSortProperty = { name: 'nonce', order: ElasticSortOrder.ascending }; const uuid: ElasticSortProperty = { name: 'uuid.keyword', order: ElasticSortOrder.ascending }; const elasticQuerySc = ElasticQuery.create() .withMustMatchCondition('type', 'unsigned') .withPagination({ from: 0, size: 100 }) - .withSort([timestamp, timestampMs, uuid]) + .withSort([timestamp, timestampMs, nonce, uuid]) .withCondition(QueryConditionOptions.must, [originalTxHashQuery]); const results = await this.elasticService.getList('operations', 'hash', elasticQuerySc); @@ -804,6 +808,7 @@ export class ElasticIndexerService implements IndexerInterface { .withSort([ { name: 'timestamp', order: ElasticSortOrder.ascending }, { name: 'timestampMs', order: ElasticSortOrder.ascending, missing: 0 }, + { name: 'nonce', order: ElasticSortOrder.ascending }, { name: 'uuid.keyword', order: ElasticSortOrder.ascending } ]) .withMustMultiShouldCondition(hashes, hash => QueryType.Match('originalTxHash', hash)); @@ -1278,6 +1283,8 @@ export class ElasticIndexerService implements IndexerInterface { .withSort([ { name: 'timestamp', order: ElasticSortOrder.descending }, { name: 'timestampMs', order: ElasticSortOrder.descending, missing: 0 }, + { name: 'txOrder', order: ElasticSortOrder.descending, missing: 0 }, + { name: 'order', order: ElasticSortOrder.descending, missing: 0 }, { name: 'uuid.keyword', order: ElasticSortOrder.descending }, ]); diff --git a/src/endpoints/sc-results/entities/smart.contract.result.ts b/src/endpoints/sc-results/entities/smart.contract.result.ts index 1bb22920d..5900b7ef3 100644 --- a/src/endpoints/sc-results/entities/smart.contract.result.ts +++ b/src/endpoints/sc-results/entities/smart.contract.result.ts @@ -15,6 +15,9 @@ export class SmartContractResult { @ApiProperty({ type: Number }) timestamp: number = 0; + @ApiProperty({ type: Number }) + timestampMs: number = 0; + @ApiProperty({ type: Number }) nonce: number = 0; diff --git a/src/endpoints/transactions/transaction.get.service.ts b/src/endpoints/transactions/transaction.get.service.ts index 02b60b0a4..e790cba36 100644 --- a/src/endpoints/transactions/transaction.get.service.ts +++ b/src/endpoints/transactions/transaction.get.service.ts @@ -101,7 +101,12 @@ export class TransactionGetService { async getTransactionScResultsFromElastic(txHash: string): Promise { const scResults = await this.indexerService.getTransactionScResults(txHash); - return scResults.map(scResult => ApiUtils.mergeObjects(new SmartContractResult(), scResult)); + return scResults.map(scResult => { + if (!scResult.timestampMs) { + scResult.timestampMs = scResult.timestamp * 1000; + } + return ApiUtils.mergeObjects(new SmartContractResult(), scResult); + }); } async tryGetTransactionFromElastic(txHash: string, fields?: string[]): Promise {