Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: display correct mana in implicit account details #8437

11 changes: 9 additions & 2 deletions packages/desktop/components/AccountManagementDetails.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,14 @@
$: hasMainAccountNegativeBIC = hasWalletMainAccountNegativeBIC($selectedWallet)
$: hasAccountNegativeBIC =
$selectedWallet?.balances?.blockIssuanceCredits?.[(selectedOutput.output as AccountOutput)?.accountId] < 0
$: selectedOutputPassiveMana = getPassiveManaForOutput(selectedOutput)

let selectedOutputPassiveMana: number
$: $selectedWallet, (selectedOutputPassiveMana = getPassiveManaForOutput(selectedOutput))

$: formattedManaBalance = selectedOutputPassiveMana
? formatTokenAmountBestMatch(Number(selectedOutputPassiveMana), DEFAULT_MANA)
: '-'

function getImplicitAccountBalance(outputData: OutputData): number | undefined {
return Number(outputData.output.amount)
}
Expand Down Expand Up @@ -219,7 +226,7 @@
<Tile>
<div class="flex flex-col space-y-2 items-center justify-center w-full">
<Text type={TextType.h3}>
{formatTokenAmountBestMatch(selectedOutputPassiveMana, DEFAULT_MANA)}</Text
{formattedManaBalance}</Text
>
<Text color="gray-600" fontWeight={FontWeight.medium} fontSize="12" type={TextType.p}
>{localize('views.accountManagement.details.mana')}</Text
Expand Down
4 changes: 4 additions & 0 deletions packages/desktop/views/dashboard/Dashboard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
clearBalanceSyncPoll,
syncBalancePoll,
hasWalletMainAccountNegativeBIC,
clearNodeInfoSyncPoll,
syncNodeInfoPoll,
} from '@core/wallet'
import { get } from 'svelte/store'
import features from '@features/features'
Expand Down Expand Up @@ -96,6 +98,7 @@

onMount(() => {
syncBalancePoll($selectedWalletId, true)
syncNodeInfoPoll()
Platform.onEvent('menu-logout', () => {
void logout()
})
Expand Down Expand Up @@ -140,6 +143,7 @@

onDestroy(() => {
clearBalanceSyncPoll()
clearNodeInfoSyncPoll()
Platform.DeepLinkManager.clearDeepLinkRequest()
Platform.removeListenersForEvent('deep-link-params')

Expand Down
1 change: 1 addition & 0 deletions packages/shared/lib/core/wallet/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ export * from './prepareMintNft'
export * from './prepareCreateNativeToken'
export * from './getNetworkMetrics'
export * from './getTotalWalletBalance'
export * from './syncNodeInfoPoll'
15 changes: 15 additions & 0 deletions packages/shared/lib/core/wallet/actions/syncNodeInfoPoll.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { DEFAULT_SECONDS_PER_SLOT, getAndUpdateNodeInfo } from '../../network'
import { MILLISECONDS_PER_SECOND } from '../../utils'

let nodeSyncInterval: number

export async function syncNodeInfoPoll(): Promise<void> {
await getAndUpdateNodeInfo()
nodeSyncInterval = window.setInterval(() => {
void getAndUpdateNodeInfo()
}, DEFAULT_SECONDS_PER_SLOT * MILLISECONDS_PER_SECOND)
}

export function clearNodeInfoSyncPoll(): void {
clearInterval(nodeSyncInterval)
}
Loading