From b1c0f29c73ddfa2c37895b07a2b94825e3a0fc97 Mon Sep 17 00:00:00 2001 From: cpl121 <100352899+cpl121@users.noreply.github.com> Date: Tue, 7 May 2024 12:29:34 +0200 Subject: [PATCH] fix: mana accuracy in transaction details (#8504) --- packages/shared/lib/core/api/interfaces/api.interface.ts | 2 ++ .../shared/lib/core/network/utils/getPassiveManaForOutput.ts | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/shared/lib/core/api/interfaces/api.interface.ts b/packages/shared/lib/core/api/interfaces/api.interface.ts index 8f7aec4c740..4b5329ff889 100644 --- a/packages/shared/lib/core/api/interfaces/api.interface.ts +++ b/packages/shared/lib/core/api/interfaces/api.interface.ts @@ -13,6 +13,7 @@ import type { ProtocolParameters, DecayedMana, DelegationId, + SlotIndex, } from '@iota/sdk/out/types' import { IWallet } from '@core/profile/interfaces' @@ -48,4 +49,5 @@ export interface IApi { computeOutputId(id: TransactionId, index: number): OutputId computeDelegationId(outputId: OutputId): DelegationId outputHexBytes(output: Output): HexEncodedString + computeSlotIndex(requestId: HexEncodedString): SlotIndex } diff --git a/packages/shared/lib/core/network/utils/getPassiveManaForOutput.ts b/packages/shared/lib/core/network/utils/getPassiveManaForOutput.ts index b85323c0d59..89dada5995d 100644 --- a/packages/shared/lib/core/network/utils/getPassiveManaForOutput.ts +++ b/packages/shared/lib/core/network/utils/getPassiveManaForOutput.ts @@ -20,9 +20,11 @@ export function getPassiveManaForOutput(output: OutputData, slotIndex?: number): : _nodeInfo.status?.latestConfirmedBlockSlot ?? undefined } if (slotIndex === undefined) return + + const includedSlot = api.computeSlotIndex(output.metadata.included.transactionId) const decayedMana = api.outputManaWithDecay( output.output, - output.metadata.included.slot, + includedSlot, slotIndex, _nodeInfo.protocolParameters[0].parameters )