From 360bcd6f361954af9980c6eca231db5d3daf4642 Mon Sep 17 00:00:00 2001 From: GuticaStefan Date: Thu, 17 Sep 2026 15:47:21 +0300 Subject: [PATCH 1/4] add nonce sc results nonce ordering --- src/common/indexer/elastic/elastic.indexer.service.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/indexer/elastic/elastic.indexer.service.ts b/src/common/indexer/elastic/elastic.indexer.service.ts index 20c68e760..d672d7266 100644 --- a/src/common/indexer/elastic/elastic.indexer.service.ts +++ b/src/common/indexer/elastic/elastic.indexer.service.ts @@ -772,12 +772,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); From 36cbc44cbd1299798fd9fcf85d0b24e9207863fe Mon Sep 17 00:00:00 2001 From: GuticaStefan Date: Thu, 17 Sep 2026 15:47:48 +0300 Subject: [PATCH 2/4] add support for sc results timestampMs --- src/endpoints/sc-results/entities/smart.contract.result.ts | 3 +++ src/endpoints/transactions/transaction.get.service.ts | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) 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..7e0a33cde 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 { From a17634a6678545f5fa529564b294bf5e1b3ee9f1 Mon Sep 17 00:00:00 2001 From: GuticaStefan Date: Thu, 17 Sep 2026 15:52:49 +0300 Subject: [PATCH 3/4] fix lint --- src/endpoints/transactions/transaction.get.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/endpoints/transactions/transaction.get.service.ts b/src/endpoints/transactions/transaction.get.service.ts index 7e0a33cde..e790cba36 100644 --- a/src/endpoints/transactions/transaction.get.service.ts +++ b/src/endpoints/transactions/transaction.get.service.ts @@ -105,7 +105,7 @@ export class TransactionGetService { if (!scResult.timestampMs) { scResult.timestampMs = scResult.timestamp * 1000; } - return ApiUtils.mergeObjects(new SmartContractResult(), scResult) + return ApiUtils.mergeObjects(new SmartContractResult(), scResult); }); } From 861267e1396e77f61a9535bc159cb5e4933da895 Mon Sep 17 00:00:00 2001 From: GuticaStefan Date: Thu, 17 Sep 2026 18:05:14 +0300 Subject: [PATCH 4/4] add extra sorting criterias --- src/common/indexer/elastic/elastic.indexer.service.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/common/indexer/elastic/elastic.indexer.service.ts b/src/common/indexer/elastic/elastic.indexer.service.ts index d672d7266..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 }, ]); @@ -805,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)); @@ -1279,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 }, ]);