From 1e5f701e9cb57583c98d87d15d4b2406514d0c1b Mon Sep 17 00:00:00 2001 From: evavirseda Date: Thu, 21 Mar 2024 10:54:25 +0100 Subject: [PATCH 1/7] feat: manage pending and main account when bic is negative --- packages/desktop/components/AccountManagementDetails.svelte | 5 ++++- .../desktop/components/modals/AccountManagementMenu.svelte | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/desktop/components/AccountManagementDetails.svelte b/packages/desktop/components/AccountManagementDetails.svelte index c0d6885b56c..0290e38dced 100644 --- a/packages/desktop/components/AccountManagementDetails.svelte +++ b/packages/desktop/components/AccountManagementDetails.svelte @@ -152,7 +152,10 @@ {/if} {#if isImplicitAccount} - {/if} diff --git a/packages/desktop/components/modals/AccountManagementMenu.svelte b/packages/desktop/components/modals/AccountManagementMenu.svelte index 09a0c65c608..59968e1c79b 100644 --- a/packages/desktop/components/modals/AccountManagementMenu.svelte +++ b/packages/desktop/components/modals/AccountManagementMenu.svelte @@ -38,7 +38,7 @@ icon={Icon.Star} title={localize('views.accountManagement.details.modal.setMainAccount')} onClick={setAsMainAccount} - disabled={accountId === $selectedWallet.mainAccountId} + disabled={accountId === $selectedWallet.mainAccountId || $selectedWallet?.balances?.totalWalletBic < 0} /> From 619f93a212cb99dae2b3c89713ca45dfce7523cb Mon Sep 17 00:00:00 2001 From: evavirseda Date: Thu, 21 Mar 2024 15:35:44 +0100 Subject: [PATCH 2/7] fix: add negative bic of an account --- .../AccountManagementDetails.svelte | 227 +++++++++--------- .../modals/AccountManagementMenu.svelte | 3 +- .../desktop/views/dashboard/Dashboard.svelte | 9 +- .../utils/getNetworkIdFromNetworkName.ts | 1 + packages/shared/locales/en.json | 3 +- 5 files changed, 128 insertions(+), 115 deletions(-) diff --git a/packages/desktop/components/AccountManagementDetails.svelte b/packages/desktop/components/AccountManagementDetails.svelte index 0290e38dced..d32fe3e8ed1 100644 --- a/packages/desktop/components/AccountManagementDetails.svelte +++ b/packages/desktop/components/AccountManagementDetails.svelte @@ -14,6 +14,8 @@ Pill, Button, ButtonSize, + TextHint, + TextHintVariant, } from '@ui' import { Icon as IconEnum } from '@auxiliary/icon' import { AccountManagementMenu } from './modals' @@ -59,6 +61,7 @@ $: formattedStakedAmount = formatTokenAmountBestMatch(rawStakedAmount, getBaseToken()) $: primaryKey = $selectedWallet?.primaryKey $: listBlockKeysFeature(selectedOutput) + $: hasMainAccountNegativeBIC = $selectedWallet?.balances?.blockIssuanceCredits[$selectedWallet?.mainAccountId] < 0 function getAccountBalance(outputData: OutputData, isImplicitAccount: boolean): number | undefined { if (isImplicitAccount) { @@ -123,129 +126,131 @@ - - - - - {localize('views.accountManagement.list.tile.title')} + + + + + + {localize('views.accountManagement.list.tile.title')} + {#if isImplicitAccount} + {localize('views.accountManagement.list.tile.pill.pending')} + {:else if isMainAccount} + {localize('views.accountManagement.list.tile.pill.main')} + + {/if} + + + {#if accountId} + + + + + {/if} {#if isImplicitAccount} - {localize('views.accountManagement.list.tile.pill.pending')}{localize('views.implicit-account-creation.steps.step2.view.action')} - {:else if isMainAccount} - {localize('views.accountManagement.list.tile.pill.main')} - {/if} - - - {#if accountId} - - - - - {/if} - {#if isImplicitAccount} - + {#if selectedOutput.outputId} + + {/if} + +
+ + {#if !accountId} + +
+ + {formattedBalance} + + {localize('views.accountManagement.details.balance')} +
+
{/if} - - {#if selectedOutput.outputId} - - {/if} - -
- - {#if !accountId} - -
- - {formattedBalance} - - {localize('views.accountManagement.details.balance')} -
-
- {/if} - {#if hasStakingFeature} - -
- {formattedStakedAmount} - {localize('views.accountManagement.details.staked')} -
-
- {/if} + {#if hasStakingFeature} + +
+ {formattedStakedAmount} + {localize('views.accountManagement.details.staked')} +
+
+ {/if} + {#if accountId} + +
+ + {$selectedWallet?.balances?.blockIssuanceCredits?.[accountId] || 0} + + {localize('views.accountManagement.details.blockIssuanceCredits')} +
+
+ {/if} +
{#if accountId} - -
- - {$selectedWallet?.balances?.blockIssuanceCredits?.[accountId] || 0} - - {localize('views.accountManagement.details.blockIssuanceCredits')} + {localize('views.accountManagement.details.address')} + + {address} -
-
+ + +
{/if} - - {#if accountId} -
- {localize('views.accountManagement.details.address')} - + {#if isImplicitAccount} +
+ {localize('views.accountManagement.details.mana')} {address}{selectedOutput.output?.mana} - - -
- {/if} - {#if isImplicitAccount} -
- {localize('views.accountManagement.details.mana')} - {selectedOutput.output?.mana} -
- {/if} - {#if accountId && primaryKey} -
- {localize('views.accountManagement.details.key')} - {primaryKey} -
+
+ {/if} + {#if accountId && primaryKey} +
+ {localize('views.accountManagement.details.key')} + {primaryKey} +
+ {/if} + + {#if isMainAccount && hasMainAccountNegativeBIC} + {/if}
diff --git a/packages/desktop/components/modals/AccountManagementMenu.svelte b/packages/desktop/components/modals/AccountManagementMenu.svelte index 59968e1c79b..a3c5ecd98f7 100644 --- a/packages/desktop/components/modals/AccountManagementMenu.svelte +++ b/packages/desktop/components/modals/AccountManagementMenu.svelte @@ -38,7 +38,8 @@ icon={Icon.Star} title={localize('views.accountManagement.details.modal.setMainAccount')} onClick={setAsMainAccount} - disabled={accountId === $selectedWallet.mainAccountId || $selectedWallet?.balances?.totalWalletBic < 0} + disabled={accountId === $selectedWallet.mainAccountId || + $selectedWallet?.balances?.blockIssuanceCredits[accountId] < 0} /> diff --git a/packages/desktop/views/dashboard/Dashboard.svelte b/packages/desktop/views/dashboard/Dashboard.svelte index 0e0e1904e4e..c3198ef5508 100644 --- a/packages/desktop/views/dashboard/Dashboard.svelte +++ b/packages/desktop/views/dashboard/Dashboard.svelte @@ -9,7 +9,7 @@ logout, reflectLockedStronghold, } from '@core/profile' - import { appRouter, dashboardRoute } from '@core/router' + import { appRouter, DashboardRoute, dashboardRoute, dashboardRouter } from '@core/router' import { Idle } from '@ui' import { stopPollingLedgerNanoStatus } from '@core/ledger' import { removeDisplayNotification, showAppNotification } from '@auxiliary/notification' @@ -28,7 +28,7 @@ resetNftDownloadQueue, selectedWalletNfts, } from '@core/nfts' - import { selectedWalletId } from '@core/wallet' + import { selectedWallet, selectedWalletId } from '@core/wallet' import { get } from 'svelte/store' import features from '@features/features' import { isAwareOfMetricSystemDrop } from '@contexts/dashboard/stores' @@ -53,6 +53,11 @@ $: $nftDownloadQueue, downloadNextNftInQueue() $: $downloadingNftId && interruptNftDownloadAfterTimeout(get(selectedWalletId)) $: addselectedWalletNftsToDownloadQueue($selectedWalletId) + $: hasMainAccountNegativeBIC = $selectedWallet?.balances?.blockIssuanceCredits[$selectedWallet?.mainAccountId] < 0 + + $: if (hasMainAccountNegativeBIC) { + $dashboardRouter.goTo(DashboardRoute.AccountManagement) + } $: if (features.analytics.dashboardRoute.enabled && $dashboardRoute) Platform.trackEvent('dashboard-route', { route: $dashboardRoute }) diff --git a/packages/shared/lib/core/network/utils/getNetworkIdFromNetworkName.ts b/packages/shared/lib/core/network/utils/getNetworkIdFromNetworkName.ts index e9078c25d84..1ce424985ae 100644 --- a/packages/shared/lib/core/network/utils/getNetworkIdFromNetworkName.ts +++ b/packages/shared/lib/core/network/utils/getNetworkIdFromNetworkName.ts @@ -15,6 +15,7 @@ export function getNetworkIdFromNetworkName(networkName: string): NetworkId { case 'testnet-2': case 'docker': case 'docker-1709894432': + case 'docker-1711022286': return NetworkId.Testnet default: return NetworkId.Custom diff --git a/packages/shared/locales/en.json b/packages/shared/locales/en.json index 59481157606..477c36bbcac 100644 --- a/packages/shared/locales/en.json +++ b/packages/shared/locales/en.json @@ -711,7 +711,8 @@ "primary": "Primary key", "setAsPrimary": "Set as primary", "unsetAsPrimary": "Unset as primary" - } + }, + "hint": "Your main account has a negative Block Issuance Credit (BIC). Please select another account as the main one to operate smoothly." }, "notification": "Activate one account to access the dashboard.", "emptyAccounts": "There are no accounts to show, activate one first." From dd88594468d43c9ef4143473315e380b8561619a Mon Sep 17 00:00:00 2001 From: evavirseda Date: Thu, 21 Mar 2024 15:53:41 +0100 Subject: [PATCH 3/7] fix hint message --- packages/shared/locales/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/shared/locales/en.json b/packages/shared/locales/en.json index 477c36bbcac..43be0d459f8 100644 --- a/packages/shared/locales/en.json +++ b/packages/shared/locales/en.json @@ -712,7 +712,7 @@ "setAsPrimary": "Set as primary", "unsetAsPrimary": "Unset as primary" }, - "hint": "Your main account has a negative Block Issuance Credit (BIC). Please select another account as the main one to operate smoothly." + "hint": "Your main account has a negative Block Issuance Credit (BIC). Please select another account as the main one." }, "notification": "Activate one account to access the dashboard.", "emptyAccounts": "There are no accounts to show, activate one first." From f8a77d371922a21c96a424f49f264c97b39970f2 Mon Sep 17 00:00:00 2001 From: evavirseda Date: Fri, 22 Mar 2024 10:25:44 +0100 Subject: [PATCH 4/7] feat: improvements --- .../components/AccountManagementDetails.svelte | 16 +++++----------- .../desktop/views/dashboard/Dashboard.svelte | 6 +++++- packages/shared/locales/en.json | 3 ++- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/packages/desktop/components/AccountManagementDetails.svelte b/packages/desktop/components/AccountManagementDetails.svelte index d32fe3e8ed1..5f134cd3129 100644 --- a/packages/desktop/components/AccountManagementDetails.svelte +++ b/packages/desktop/components/AccountManagementDetails.svelte @@ -54,22 +54,17 @@ $: accountId = isAccountOutput(selectedOutput) ? (selectedOutput.output as AccountOutput)?.accountId : null $: address = accountId ? AddressConverter.addressToBech32(new AccountAddress(accountId)) : null $: isMainAccount = accountId && accountId === $selectedWalletMainAccountId - $: balance = getAccountBalance(selectedOutput, isImplicitAccount) + $: balance = getImplicitAccountBalance(selectedOutput) $: formattedBalance = balance ? formatTokenAmountBestMatch(balance, getBaseToken()) : '-' $: hasStakingFeature = hasOutputStakingFeature(selectedOutput) $: rawStakedAmount = getStakedAmount(selectedOutput) $: formattedStakedAmount = formatTokenAmountBestMatch(rawStakedAmount, getBaseToken()) $: primaryKey = $selectedWallet?.primaryKey $: listBlockKeysFeature(selectedOutput) - $: hasMainAccountNegativeBIC = $selectedWallet?.balances?.blockIssuanceCredits[$selectedWallet?.mainAccountId] < 0 + $: hasMainAccountNegativeBIC = $selectedWallet?.balances?.blockIssuanceCredits?.[$selectedWallet?.mainAccountId] < 0 - function getAccountBalance(outputData: OutputData, isImplicitAccount: boolean): number | undefined { - if (isImplicitAccount) { - return Number(outputData.output.amount) - } else { - // TODO: Calculate the balance of an account output https://github.com/iotaledger/firefly/issues/8080 - return undefined - } + function getImplicitAccountBalance(outputData: OutputData): number | undefined { + return Number(outputData.output.amount) } function onExplorerClick(): void { @@ -171,8 +166,7 @@ {/if}
- - {#if !accountId} + {#if isImplicitAccount}
diff --git a/packages/desktop/views/dashboard/Dashboard.svelte b/packages/desktop/views/dashboard/Dashboard.svelte index c3198ef5508..1b46359ff96 100644 --- a/packages/desktop/views/dashboard/Dashboard.svelte +++ b/packages/desktop/views/dashboard/Dashboard.svelte @@ -53,10 +53,14 @@ $: $nftDownloadQueue, downloadNextNftInQueue() $: $downloadingNftId && interruptNftDownloadAfterTimeout(get(selectedWalletId)) $: addselectedWalletNftsToDownloadQueue($selectedWalletId) - $: hasMainAccountNegativeBIC = $selectedWallet?.balances?.blockIssuanceCredits[$selectedWallet?.mainAccountId] < 0 + $: hasMainAccountNegativeBIC = $selectedWallet?.balances?.blockIssuanceCredits?.[$selectedWallet?.mainAccountId] < 0 $: if (hasMainAccountNegativeBIC) { $dashboardRouter.goTo(DashboardRoute.AccountManagement) + showAppNotification({ + type: 'error', + message: localize('views.accountManagement.bicNotification'), + }) } $: if (features.analytics.dashboardRoute.enabled && $dashboardRoute) diff --git a/packages/shared/locales/en.json b/packages/shared/locales/en.json index caa43da9fe1..f305e27ad72 100644 --- a/packages/shared/locales/en.json +++ b/packages/shared/locales/en.json @@ -715,7 +715,8 @@ "hint": "Your main account has a negative Block Issuance Credit (BIC). Please select another account as the main one." }, "notification": "Activate one account to access the dashboard.", - "emptyAccounts": "There are no accounts to show, activate one first." + "emptyAccounts": "There are no accounts to show, activate one first.", + "bicNotification": "There is a problem with your account BIC." }, "delegation": { "title": "Delegation", From 0fc16972b504052e57612bdc302d1c42b968cf4c Mon Sep 17 00:00:00 2001 From: evavirseda Date: Mon, 25 Mar 2024 09:47:48 +0100 Subject: [PATCH 5/7] feat: minor improvements --- .../desktop/components/AccountManagementDetails.svelte | 8 +++++--- packages/desktop/views/dashboard/Dashboard.svelte | 2 +- packages/shared/locales/en.json | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/desktop/components/AccountManagementDetails.svelte b/packages/desktop/components/AccountManagementDetails.svelte index 5f134cd3129..b514c519667 100644 --- a/packages/desktop/components/AccountManagementDetails.svelte +++ b/packages/desktop/components/AccountManagementDetails.svelte @@ -54,8 +54,10 @@ $: accountId = isAccountOutput(selectedOutput) ? (selectedOutput.output as AccountOutput)?.accountId : null $: address = accountId ? AddressConverter.addressToBech32(new AccountAddress(accountId)) : null $: isMainAccount = accountId && accountId === $selectedWalletMainAccountId - $: balance = getImplicitAccountBalance(selectedOutput) - $: formattedBalance = balance ? formatTokenAmountBestMatch(balance, getBaseToken()) : '-' + $: implicitAccountBalance = getImplicitAccountBalance(selectedOutput) + $: formattedImplicitAccountBalance = implicitAccountBalance + ? formatTokenAmountBestMatch(implicitAccountBalance, getBaseToken()) + : '-' $: hasStakingFeature = hasOutputStakingFeature(selectedOutput) $: rawStakedAmount = getStakedAmount(selectedOutput) $: formattedStakedAmount = formatTokenAmountBestMatch(rawStakedAmount, getBaseToken()) @@ -170,7 +172,7 @@
- {formattedBalance} + {formattedImplicitAccountBalance} {localize('views.accountManagement.details.balance')} Date: Mon, 25 Mar 2024 18:23:10 +0100 Subject: [PATCH 6/7] feat: update locales, prevent to redirect and improvements --- .../components/AccountManagementDetails.svelte | 15 +++++++++++++-- packages/desktop/views/dashboard/Dashboard.svelte | 5 ++--- packages/shared/locales/en.json | 5 +++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/packages/desktop/components/AccountManagementDetails.svelte b/packages/desktop/components/AccountManagementDetails.svelte index b514c519667..96c6509f17e 100644 --- a/packages/desktop/components/AccountManagementDetails.svelte +++ b/packages/desktop/components/AccountManagementDetails.svelte @@ -54,7 +54,7 @@ $: accountId = isAccountOutput(selectedOutput) ? (selectedOutput.output as AccountOutput)?.accountId : null $: address = accountId ? AddressConverter.addressToBech32(new AccountAddress(accountId)) : null $: isMainAccount = accountId && accountId === $selectedWalletMainAccountId - $: implicitAccountBalance = getImplicitAccountBalance(selectedOutput) + $: implicitAccountBalance = isImplicitAccount ? getImplicitAccountBalance(selectedOutput) : undefined $: formattedImplicitAccountBalance = implicitAccountBalance ? formatTokenAmountBestMatch(implicitAccountBalance, getBaseToken()) : '-' @@ -64,6 +64,8 @@ $: primaryKey = $selectedWallet?.primaryKey $: listBlockKeysFeature(selectedOutput) $: hasMainAccountNegativeBIC = $selectedWallet?.balances?.blockIssuanceCredits?.[$selectedWallet?.mainAccountId] < 0 + $: hasAccountNegativeBIC = + $selectedWallet?.balances?.blockIssuanceCredits?.[(selectedOutput.output as AccountOutput)?.accountId] < 0 function getImplicitAccountBalance(outputData: OutputData): number | undefined { return Number(outputData.output.amount) @@ -246,7 +248,16 @@ {/if} {#if isMainAccount && hasMainAccountNegativeBIC} - + + {/if} + {#if !isMainAccount && hasAccountNegativeBIC} + {/if} diff --git a/packages/desktop/views/dashboard/Dashboard.svelte b/packages/desktop/views/dashboard/Dashboard.svelte index d7c9ae882ea..412198b31ab 100644 --- a/packages/desktop/views/dashboard/Dashboard.svelte +++ b/packages/desktop/views/dashboard/Dashboard.svelte @@ -9,7 +9,7 @@ logout, reflectLockedStronghold, } from '@core/profile' - import { appRouter, DashboardRoute, dashboardRoute, dashboardRouter } from '@core/router' + import { appRouter, dashboardRoute } from '@core/router' import { Idle } from '@ui' import { stopPollingLedgerNanoStatus } from '@core/ledger' import { removeDisplayNotification, showAppNotification } from '@auxiliary/notification' @@ -56,10 +56,9 @@ $: hasMainAccountNegativeBIC = $selectedWallet?.balances?.blockIssuanceCredits?.[$selectedWallet?.mainAccountId] < 0 $: if (hasMainAccountNegativeBIC) { - $dashboardRouter.goTo(DashboardRoute.AccountManagement) showAppNotification({ type: 'warning', - message: localize('views.accountManagement.bicNotification'), + message: localize('views.accountManagement.hasMainAccountNegativeBIC'), }) } diff --git a/packages/shared/locales/en.json b/packages/shared/locales/en.json index 4a23185299f..c0d4f5ab11a 100644 --- a/packages/shared/locales/en.json +++ b/packages/shared/locales/en.json @@ -712,11 +712,12 @@ "setAsPrimary": "Set as primary", "unsetAsPrimary": "Unset as primary" }, - "hint": "Your main account has a negative Block Issuance Credit (BIC). Please select another account as the main one." + "mainAccountNegativeBICHint": "Your main account has a negative Block Issuance Credit (BIC). Please select another account as the main one.", + "accountNegativeBICHint": "This account has a negative Block Issuance Credit (BIC)." }, "notification": "Activate one account to access the dashboard.", "emptyAccounts": "There are no accounts to show, activate one first.", - "bicNotification": "There is a problem with the BIC of your account." + "hasMainAccountNegativeBIC": "There is a problem with the BIC of your account." }, "delegation": { "title": "Delegation", From 4d4d7ab86a9b28d51829eb37c4969815959cbf23 Mon Sep 17 00:00:00 2001 From: evavirseda Date: Tue, 26 Mar 2024 09:27:24 +0100 Subject: [PATCH 7/7] feat: not allow to send if bic is negative --- .../components/popups/send/SendConfirmationPopup.svelte | 6 ++++++ packages/shared/locales/en.json | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/desktop/components/popups/send/SendConfirmationPopup.svelte b/packages/desktop/components/popups/send/SendConfirmationPopup.svelte index d8a62d4303e..397d0c7ac0b 100644 --- a/packages/desktop/components/popups/send/SendConfirmationPopup.svelte +++ b/packages/desktop/components/popups/send/SendConfirmationPopup.svelte @@ -227,6 +227,8 @@ function onCancelClick(): void { closePopup() } + + $: hasMainAccountNegativeBIC = $selectedWallet?.balances?.blockIssuanceCredits?.[$selectedWallet?.mainAccountId] < 0 @@ -271,6 +273,9 @@ {#if surplus} {/if} + {#if hasMainAccountNegativeBIC} + + {/if} {#if disableBack}