Skip to content

Commit a8dafce

Browse files
authored
Add normalizeTimestampMs method for timestamp conversion (#1519)
1 parent b12917e commit a8dafce

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/endpoints/transactions/transaction.service.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,9 @@ export class TransactionService {
348348
}
349349

350350
async processTransactions(transactions: Transaction[], options: { withScamInfo: boolean, withUsername: boolean, withActionTransferValue: boolean }): Promise<void> {
351+
352+
this.normalizeTimestampMs(transactions);
353+
351354
try {
352355
await this.pluginsService.processTransactions(transactions, options.withScamInfo);
353356
} catch (error) {
@@ -372,6 +375,15 @@ export class TransactionService {
372375
await this.applyAssets(transactions, { withUsernameAssets: options.withUsername });
373376
}
374377

378+
379+
private normalizeTimestampMs(transactions: Transaction[]): void {
380+
for (const transaction of transactions) {
381+
if ((!transaction.timestampMs || transaction.timestampMs === 0) && transaction.timestamp) {
382+
transaction.timestampMs = transaction.timestamp * 1000;
383+
}
384+
}
385+
}
386+
375387
private async getPendingResults(transaction: Transaction): Promise<boolean | undefined> {
376388
const twentyMinutes = Constants.oneMinute() * 20 * 1000;
377389
const timestampLimit = (new Date().getTime() - twentyMinutes) / 1000;

0 commit comments

Comments
 (0)