From bc3459b0519acdfcb759c10612c0b56e47480d29 Mon Sep 17 00:00:00 2001 From: Marc Espin Date: Thu, 28 Mar 2024 17:15:47 +0100 Subject: [PATCH] fix: Incorrect timestamp for outgoing txs (#8280) --- .../utils/outputs/preprocessOutgoingTransaction.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/shared/lib/core/wallet/utils/outputs/preprocessOutgoingTransaction.ts b/packages/shared/lib/core/wallet/utils/outputs/preprocessOutgoingTransaction.ts index 86b555726a9..9ae481372d1 100644 --- a/packages/shared/lib/core/wallet/utils/outputs/preprocessOutgoingTransaction.ts +++ b/packages/shared/lib/core/wallet/utils/outputs/preprocessOutgoingTransaction.ts @@ -4,6 +4,9 @@ import { computeOutputId } from './computeOutputId' import { getOutputIdFromTransactionIdAndIndex } from './getOutputIdFromTransactionIdAndIndex' import { getDirectionFromOutgoingTransaction } from '../transactions' import { IWalletState } from '@core/wallet/interfaces' +import { MILLISECONDS_PER_SECOND } from '@core/utils' +import { getUnixTimestampFromNodeInfoAndSlotIndex, nodeInfoProtocolParameters } from '@core/network' +import { get } from 'svelte/store' export async function preprocessOutgoingTransaction( transaction: TransactionWithMetadata, @@ -11,6 +14,10 @@ export async function preprocessOutgoingTransaction( ): Promise { const regularTransactionEssence = transaction.payload.transaction const transactionId = transaction?.transactionId?.toString() + const nodeProtocolParameters = get(nodeInfoProtocolParameters) + const slotUnixTimestamp = nodeProtocolParameters + ? getUnixTimestampFromNodeInfoAndSlotIndex(nodeProtocolParameters, regularTransactionEssence.creationSlot) + : 0 const outputs = convertTransactionsOutputTypesToWrappedOutputs(transactionId, regularTransactionEssence.outputs) @@ -28,7 +35,7 @@ export async function preprocessOutgoingTransaction( outputs: outputs, transactionId, direction, - time: new Date(Number(transaction.timestamp)), + time: new Date(slotUnixTimestamp * MILLISECONDS_PER_SECOND), inclusionState: transaction.inclusionState, wrappedInputs: inputs, }