Skip to content

Commit

Permalink
fix: Incorrect timestamp for outgoing txs (#8280)
Browse files Browse the repository at this point in the history
  • Loading branch information
marc2332 authored Mar 28, 2024
1 parent a412bff commit bc3459b
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@ 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,
wallet: IWalletState
): Promise<IProcessedTransaction> {
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)

Expand All @@ -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: <IWrappedOutput[]>inputs,
}
Expand Down

0 comments on commit bc3459b

Please sign in to comment.