From 1b5576dfd348905ba212c7fc14029937113ce4c5 Mon Sep 17 00:00:00 2001 From: cpl121 <100352899+cpl121@users.noreply.github.com> Date: Tue, 19 Mar 2024 16:53:43 +0100 Subject: [PATCH 1/6] feat: show BIC balance in account details (#8151) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: show BIC balance in account details * fix: bic mana * some improvements * fix: keep things simple * feat: update blockIssuanceCredits text * fix: add logic to get BIC if there are explicit accounts to build wallet state --------- Co-authored-by: marc2332 Co-authored-by: Begoña Álvarez de la Cruz --- .../AccountManagementDetails.svelte | 36 +++++++++++++------ .../popups/BalanceBreakdownPopup.svelte | 4 +-- .../FundConfirmationView.svelte | 2 +- .../profile/stores/active-wallets.store.ts | 4 +-- .../core/wallet/actions/buildWalletState.ts | 4 ++- .../handleTransactionInclusionEvent.ts | 8 ++--- .../lib/core/wallet/actions/getBicBalance.ts | 15 ++++++++ .../wallet/actions/getBicWalletBalance.ts | 14 -------- .../lib/core/wallet/actions/getClient.ts | 6 ++-- .../wallet/actions/getTotalWalletBalance.ts | 13 +++++++ .../shared/lib/core/wallet/actions/index.ts | 3 +- .../lib/core/wallet/actions/syncBalance.ts | 19 +++++----- .../interfaces/extended-balance.interface.ts | 3 +- packages/shared/locales/en.json | 1 + 14 files changed, 82 insertions(+), 50 deletions(-) create mode 100644 packages/shared/lib/core/wallet/actions/getBicBalance.ts delete mode 100644 packages/shared/lib/core/wallet/actions/getBicWalletBalance.ts create mode 100644 packages/shared/lib/core/wallet/actions/getTotalWalletBalance.ts diff --git a/packages/desktop/components/AccountManagementDetails.svelte b/packages/desktop/components/AccountManagementDetails.svelte index 78b971b4fd2..c0d6885b56c 100644 --- a/packages/desktop/components/AccountManagementDetails.svelte +++ b/packages/desktop/components/AccountManagementDetails.svelte @@ -167,16 +167,19 @@ {/if}
- -
- - {formattedBalance} - - {localize('views.accountManagement.details.balance')} -
-
+ + {#if !accountId} + +
+ + {formattedBalance} + + {localize('views.accountManagement.details.balance')} +
+
+ {/if} {#if hasStakingFeature} @@ -188,6 +191,19 @@
{/if} + + {#if accountId} + +
+ + {$selectedWallet?.balances?.blockIssuanceCredits?.[accountId] || 0} + + {localize('views.accountManagement.details.blockIssuanceCredits')} +
+
+ {/if} {#if accountId}
diff --git a/packages/desktop/components/popups/BalanceBreakdownPopup.svelte b/packages/desktop/components/popups/BalanceBreakdownPopup.svelte index 5013f82be2f..8fcadb86552 100644 --- a/packages/desktop/components/popups/BalanceBreakdownPopup.svelte +++ b/packages/desktop/components/popups/BalanceBreakdownPopup.svelte @@ -54,12 +54,12 @@ function getManaBreakdown(): BalanceBreakdown { const totalBalanceWithoutBic = getManaBalance(walletBalance?.mana?.total) const availableBalance = getManaBalance(walletBalance?.mana?.available) - const totalBalance = totalBalanceWithoutBic + walletBalance.blockIssuanceCredits + const totalBalance = totalBalanceWithoutBic + walletBalance.totalWalletBic const subBreakdown = { availableMana: { amount: availableBalance }, lockedMana: { amount: totalBalanceWithoutBic - availableBalance }, - bicMana: { amount: walletBalance.blockIssuanceCredits }, + bicMana: { amount: walletBalance.totalWalletBic }, } return { amount: totalBalance, subBreakdown, isBaseToken: false } } diff --git a/packages/desktop/views/dashboard/wallet/views/implicit-account-creation-multistep/FundConfirmationView.svelte b/packages/desktop/views/dashboard/wallet/views/implicit-account-creation-multistep/FundConfirmationView.svelte index 940eeaf1af6..aacb27dee03 100644 --- a/packages/desktop/views/dashboard/wallet/views/implicit-account-creation-multistep/FundConfirmationView.svelte +++ b/packages/desktop/views/dashboard/wallet/views/implicit-account-creation-multistep/FundConfirmationView.svelte @@ -42,7 +42,7 @@ function getTotalAvailableMana(): number { return ( getManaBalance($selectedWallet?.balances?.mana?.available) + - ($selectedWallet?.balances.blockIssuanceCredits ?? 0) - + $selectedWallet?.balances.totalWalletBic - getImplicitAccountsMana($selectedWallet?.implicitAccountOutputs, [outputId]) ) } diff --git a/packages/shared/lib/core/profile/stores/active-wallets.store.ts b/packages/shared/lib/core/profile/stores/active-wallets.store.ts index b25e6133a2f..095eb6509cd 100644 --- a/packages/shared/lib/core/profile/stores/active-wallets.store.ts +++ b/packages/shared/lib/core/profile/stores/active-wallets.store.ts @@ -8,8 +8,8 @@ export function getActiveWallets(): IWalletState[] { return get(activeWallets) } -export function getActiveWalletById(walletId: string): IWalletState | undefined { - return get(activeWallets).find((wallet) => wallet.id === walletId) +export function getWalletById(walletId: string): IWalletState | undefined { + return getActiveWallets().find((wallet) => wallet.id === walletId) } export function removeWalletFromActiveWallets(walletId: string): void { diff --git a/packages/shared/lib/core/wallet/actions/buildWalletState.ts b/packages/shared/lib/core/wallet/actions/buildWalletState.ts index 2f6a8d332a9..142ecc05b1c 100644 --- a/packages/shared/lib/core/wallet/actions/buildWalletState.ts +++ b/packages/shared/lib/core/wallet/actions/buildWalletState.ts @@ -4,6 +4,7 @@ import { updateWalletPersistedDataOnActiveProfile } from '@core/profile' import { IPersistedWalletData } from '../interfaces/persisted-wallet-data.interface' import { IWalletState } from '../interfaces/wallet-state.interface' import { AddressConverter, getBlockIssuerAccounts } from '../utils' +import { DEFAULT_SYNC_OPTIONS, getTotalWalletBalance } from '..' export async function buildWalletState( wallet: IWallet, @@ -48,8 +49,9 @@ export async function buildWalletState( let depositAddress = '' try { - balances = await wallet.getBalance() + await wallet.sync(DEFAULT_SYNC_OPTIONS) accountOutputs = await wallet.accounts() + balances = await getTotalWalletBalance(wallet.id, accountOutputs) // check if the mainAccountId is still valid if ( walletPersistedData.mainAccountId && diff --git a/packages/shared/lib/core/wallet/actions/events-handlers/handleTransactionInclusionEvent.ts b/packages/shared/lib/core/wallet/actions/events-handlers/handleTransactionInclusionEvent.ts index 7133ab089f2..5378ea07cec 100644 --- a/packages/shared/lib/core/wallet/actions/events-handlers/handleTransactionInclusionEvent.ts +++ b/packages/shared/lib/core/wallet/actions/events-handlers/handleTransactionInclusionEvent.ts @@ -17,7 +17,7 @@ import { InclusionState, WalletApiEventHandler, } from '@core/wallet' -import { getActiveWalletById, updateActiveWallet } from '@core/profile' +import { getWalletById, updateActiveWallet } from '@core/profile' export function handleTransactionInclusionEvent(walletId: string): WalletApiEventHandler { return (error: Error, rawEvent: WalletEvent) => { @@ -37,7 +37,7 @@ export function handleTransactionInclusionEventInternal( updateActivityByTransactionId(walletId, transactionId, { inclusionState }) if (inclusionState === InclusionState.Confirmed) { - const wallet = getActiveWalletById(walletId) + const wallet = getWalletById(walletId) if (wallet) { const hasMainAccountOutput = wallet.accountOutputs.find( (output) => (output.output as AccountOutput).accountId === wallet.mainAccountId @@ -83,7 +83,7 @@ function handleGovernanceTransactionInclusionEvent( // TODO: move this closePopup(true) - const wallet = getActiveWalletById(walletId) + const wallet = getWalletById(walletId) if (!wallet) { return } @@ -108,7 +108,7 @@ function handleConsolidationTransactionInclusionEvent(walletId: string, inclusio // With output consolidation we wait for the transaction confirmation to improve the UX of the vesting tab // we should think about making this consistent in the future updateActiveWallet(walletId, { isTransferring: false }) - const wallet = getActiveWalletById(walletId) + const wallet = getWalletById(walletId) if (!wallet) { return } diff --git a/packages/shared/lib/core/wallet/actions/getBicBalance.ts b/packages/shared/lib/core/wallet/actions/getBicBalance.ts new file mode 100644 index 00000000000..dd606da079f --- /dev/null +++ b/packages/shared/lib/core/wallet/actions/getBicBalance.ts @@ -0,0 +1,15 @@ +import { getClient } from './getClient' +import { AccountOutput, OutputData } from '@iota/sdk/out/types' + +export async function getBicBalance(walletId: string, accountsOutputs: OutputData[]): Promise> { + const client = await getClient(walletId) + const result: Record = {} + if (accountsOutputs?.length && client) { + for (const { output } of accountsOutputs) { + const { accountId } = output as AccountOutput + const bic = await client.getAccountCongestion(accountId) + result[accountId] = bic ? Number(bic.blockIssuanceCredits) : 0 + } + } + return result +} diff --git a/packages/shared/lib/core/wallet/actions/getBicWalletBalance.ts b/packages/shared/lib/core/wallet/actions/getBicWalletBalance.ts deleted file mode 100644 index 2d2ac011455..00000000000 --- a/packages/shared/lib/core/wallet/actions/getBicWalletBalance.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { getWallet } from '../../profile' -import { getClient } from './getClient' -import { AccountOutput } from '@iota/sdk' - -export async function getBicWalletBalance(walletId: string): Promise { - const accountOutputs = await (await getWallet(walletId))?.accounts() - const client = await getClient() - if (!accountOutputs || !client) return null - const accountsCongestion = await Promise.all( - accountOutputs.map((account) => client.getAccountCongestion((account.output as AccountOutput).accountId)) - ) - const totalBic = accountsCongestion.reduce((acc, bic) => acc + Number(bic.blockIssuanceCredits), 0) - return totalBic -} diff --git a/packages/shared/lib/core/wallet/actions/getClient.ts b/packages/shared/lib/core/wallet/actions/getClient.ts index 4b78b614bed..674cd86a5bb 100644 --- a/packages/shared/lib/core/wallet/actions/getClient.ts +++ b/packages/shared/lib/core/wallet/actions/getClient.ts @@ -3,8 +3,6 @@ import { selectedWalletId } from '@core/wallet/stores' import { api } from '@core/api' import { get } from 'svelte/store' -export function getClient(): Promise { - const selectedWallet = get(selectedWalletId) - - return api.getClientFromWallet(selectedWallet) +export function getClient(walletId: string = get(selectedWalletId)): Promise { + return api.getClientFromWallet(walletId) } diff --git a/packages/shared/lib/core/wallet/actions/getTotalWalletBalance.ts b/packages/shared/lib/core/wallet/actions/getTotalWalletBalance.ts new file mode 100644 index 00000000000..5da80690440 --- /dev/null +++ b/packages/shared/lib/core/wallet/actions/getTotalWalletBalance.ts @@ -0,0 +1,13 @@ +import { OutputData } from '@iota/sdk/out/types' +import { IBalance, getBicBalance } from '..' +import { getBalance } from './getBalance' + +export async function getTotalWalletBalance(walletId: string, accountOutputs: OutputData[]): Promise { + const balances = await getBalance(walletId) + const blockIssuanceCredits = await getBicBalance(walletId, accountOutputs) + const totalWalletBic = Object.values(blockIssuanceCredits).reduce((acc, bic) => acc + Number(bic), 0) + return { + ...balances, + ...{ totalWalletBic, blockIssuanceCredits }, + } +} diff --git a/packages/shared/lib/core/wallet/actions/index.ts b/packages/shared/lib/core/wallet/actions/index.ts index d0088061793..8dde6d065e0 100644 --- a/packages/shared/lib/core/wallet/actions/index.ts +++ b/packages/shared/lib/core/wallet/actions/index.ts @@ -11,7 +11,7 @@ export * from './sendOutput' export * from './setOutgoingAsyncActivitiesToClaimed' export * from './mintNft' export * from './createNativeToken' -export * from './getBicWalletBalance' +export * from './getBicBalance' export * from './getOrRequestAssetFromPersistedAssets' export * from './activities' export * from './subscribeToWalletApiEvents' @@ -40,3 +40,4 @@ export * from './setNextSelectedWallet' export * from './restoreBackup' export * from './getOutputRewards' export * from './getCommitteInfo' +export * from './getTotalWalletBalance' diff --git a/packages/shared/lib/core/wallet/actions/syncBalance.ts b/packages/shared/lib/core/wallet/actions/syncBalance.ts index 367295a3027..47df7bf8fb8 100644 --- a/packages/shared/lib/core/wallet/actions/syncBalance.ts +++ b/packages/shared/lib/core/wallet/actions/syncBalance.ts @@ -1,18 +1,17 @@ -import { getBalance } from './getBalance' import { get } from 'svelte/store' -import { selectedWalletId } from '../stores/selected-wallet-id.store' -import { updateSelectedWallet } from '../stores/selected-wallet.store' -import { updateActiveWallet } from '@core/profile/stores' -import { getBicWalletBalance } from './getBicWalletBalance' +import { selectedWalletId, updateSelectedWallet } from '../stores/' +import { getWalletById, updateActiveWallet } from '@core/profile/stores' import { IBalance } from '../interfaces' +import { getTotalWalletBalance } from '..' +import { OutputData } from '@iota/sdk/out/types' export async function syncBalance(walletId: string, syncCongestion: boolean): Promise { - const balances = await getBalance(walletId) - const blockIssuanceCredits = syncCongestion ? await getBicWalletBalance(walletId) : 0 - const totalBalance: IBalance = { - ...balances, - ...(syncCongestion && !!blockIssuanceCredits && { blockIssuanceCredits }), + let accountOutputs: OutputData[] = [] + if (syncCongestion) { + const wallet = getWalletById(walletId) + accountOutputs = wallet?.accountOutputs ?? [] } + const totalBalance: IBalance = await getTotalWalletBalance(walletId, accountOutputs) if (get(selectedWalletId) === walletId) { updateSelectedWallet({ balances: totalBalance }) } else { diff --git a/packages/shared/lib/core/wallet/interfaces/extended-balance.interface.ts b/packages/shared/lib/core/wallet/interfaces/extended-balance.interface.ts index 8299f9ea007..13750f9f683 100644 --- a/packages/shared/lib/core/wallet/interfaces/extended-balance.interface.ts +++ b/packages/shared/lib/core/wallet/interfaces/extended-balance.interface.ts @@ -1,5 +1,6 @@ import { Balance } from '@iota/sdk/out/types' export interface IBalance extends Balance { - blockIssuanceCredits?: number + blockIssuanceCredits: { [accountId: string]: number } + totalWalletBic: number } diff --git a/packages/shared/locales/en.json b/packages/shared/locales/en.json index ed0e90642ea..59481157606 100644 --- a/packages/shared/locales/en.json +++ b/packages/shared/locales/en.json @@ -698,6 +698,7 @@ }, "details": { "balance": "Balance", + "blockIssuanceCredits": "Block Issuance Credit (BIC)", "address": "Address", "staked": "Staked", "mana": "Mana", From 2f614ea957bac4deb8d1f23fce9bd7cf8163b53f Mon Sep 17 00:00:00 2001 From: evavirseda Date: Thu, 21 Mar 2024 10:00:03 +0100 Subject: [PATCH 2/6] feat: update `startBackgroundSync` & `DEFAULT_SYNC_OPTIONS` (#8232) --- .../core/profile/actions/active-profile/login.ts | 10 ++++------ .../actions/events-handlers/handleNewOutputEvent.ts | 13 +------------ .../constants/default-sync-options.constant.ts | 1 + 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/packages/shared/lib/core/profile/actions/active-profile/login.ts b/packages/shared/lib/core/profile/actions/active-profile/login.ts index 2bb95a39c51..9ff704f02bb 100644 --- a/packages/shared/lib/core/profile/actions/active-profile/login.ts +++ b/packages/shared/lib/core/profile/actions/active-profile/login.ts @@ -14,6 +14,8 @@ import { isStrongholdUnlocked, refreshWalletAssetsForActiveProfile, setSelectedWallet, + setStrongholdPasswordClearInterval, + startBackgroundSync, } from '@core/wallet/actions' import { get } from 'svelte/store' import { CHECK_PREVIOUS_WALLETS_ARE_DESTROYED_TIMEOUT } from '../../constants' @@ -34,7 +36,7 @@ import { logout } from './logout' import { subscribeToWalletApiEventsForActiveProfile } from './subscribeToWalletApiEventsForActiveProfile' import { checkAndUpdateActiveProfileNetwork } from './checkAndUpdateActiveProfileNetwork' import { checkAndRemoveProfilePicture } from './checkAndRemoveProfilePicture' -import { setStrongholdPasswordClearInterval, startBackgroundSync } from '@core/wallet/actions' +import { DEFAULT_SYNC_OPTIONS } from '@core/wallet/constants' export async function login(loginOptions?: ILoginOptions): Promise { const loginRouter = get(routerManager).getRouterForAppContext(AppContext.Login) @@ -94,11 +96,7 @@ export async function login(loginOptions?: ILoginOptions): Promise { incrementLoginProgress() subscribeToWalletApiEventsForActiveProfile() - await startBackgroundSync({ - syncIncomingTransactions: true, - syncImplicitAccounts: true, - account: { nftOutputs: true }, - }) + await startBackgroundSync(DEFAULT_SYNC_OPTIONS) // Step 8: finish login incrementLoginProgress() diff --git a/packages/shared/lib/core/wallet/actions/events-handlers/handleNewOutputEvent.ts b/packages/shared/lib/core/wallet/actions/events-handlers/handleNewOutputEvent.ts index 1ca81af3028..0e2d230f58c 100644 --- a/packages/shared/lib/core/wallet/actions/events-handlers/handleNewOutputEvent.ts +++ b/packages/shared/lib/core/wallet/actions/events-handlers/handleNewOutputEvent.ts @@ -17,7 +17,6 @@ import { preprocessGroupedOutputs, syncBalance, validateWalletApiEvent, - DEFAULT_SYNC_OPTIONS, } from '@core/wallet' import { AccountAddress, @@ -47,20 +46,10 @@ export async function handleNewOutputEventInternal(walletId: string, payload: Ne const output = outputData.output const isNftOutput = output.type === OutputType.Nft - let _isDelegationOutput = isDelegationOutput(outputData) + const _isDelegationOutput = isDelegationOutput(outputData) const address = outputData.address ? AddressConverter.addressToBech32(outputData.address) : undefined - // TODO: Improve this logic when the delegation output is received -> https://github.com/iotaledger/firefly/issues/8187 - if (wallet?.hasDelegationTransactionInProgress) { - const prevDelegationOutputs = wallet.walletUnspentOutputs?.filter(isDelegationOutput) || [] - await wallet.sync(DEFAULT_SYNC_OPTIONS) - const postDelegationOutputs = (await wallet.unspentOutputs())?.filter(isDelegationOutput) || [] - if (prevDelegationOutputs.length < postDelegationOutputs.length) { - _isDelegationOutput = true - } - } - // The basic outputs of the faucet dont have an address const isBasicOutput = output.type === OutputType.Basic if ( diff --git a/packages/shared/lib/core/wallet/constants/default-sync-options.constant.ts b/packages/shared/lib/core/wallet/constants/default-sync-options.constant.ts index 91b34de95fd..2a73d2fede6 100644 --- a/packages/shared/lib/core/wallet/constants/default-sync-options.constant.ts +++ b/packages/shared/lib/core/wallet/constants/default-sync-options.constant.ts @@ -20,4 +20,5 @@ export const DEFAULT_SYNC_OPTIONS: SyncOptions = { }, syncIncomingTransactions: true, syncNativeTokenFoundries: true, + syncImplicitAccounts: true, } From 58cbb06f155a345b46b28e00d1e17156dcbe7835 Mon Sep 17 00:00:00 2001 From: cpl121 <100352899+cpl121@users.noreply.github.com> Date: Thu, 21 Mar 2024 12:36:10 +0100 Subject: [PATCH 3/6] feat: check if the validator address belongs to the validator committee (#8178) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: modify name column by delegationId * feat: rename "address" column header to "delegated to" * feat: rename epoch by epochs * feat: update epochs logic * feat: check if the validator address belongs to the validator committee * feat: improve delegation list * fix: error to show PingingBadge * chore: rename var --------- Co-authored-by: Begoña Álvarez de la Cruz --- .../dashboard/delegation/Delegation.svelte | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/packages/desktop/views/dashboard/delegation/Delegation.svelte b/packages/desktop/views/dashboard/delegation/Delegation.svelte index 9ae02f6c067..4fb6ef64d46 100644 --- a/packages/desktop/views/dashboard/delegation/Delegation.svelte +++ b/packages/desktop/views/dashboard/delegation/Delegation.svelte @@ -13,6 +13,7 @@ ButtonSize, CopyableBox, BoxedIconWithText, + PingingBadge, TextHintVariant, } from '@ui' import { activeProfile, checkActiveProfileAuth } from '@core/profile' @@ -35,6 +36,7 @@ let delegationData: IDelegationTable[] = [] let currentEpoch = 0 + let committeeAddresses: string[] = [] enum Header { DelegationId = 'delegationId', @@ -56,7 +58,7 @@ $: delegationOutputs = $selectedWallet?.walletUnspentOutputs?.filter((output) => output?.output?.type === OutputType.Delegation) || [] - $: delegationOutputs?.length > 0 && setCurrentEpoch() + $: delegationOutputs?.length > 0 && setCurrentEpochAndCommittee() $: delegationOutputs?.length > 0 && currentEpoch && buildMappedDelegationData(delegationOutputs) $: ({ baseCoin } = $selectedWalletAssets[$activeProfile?.network.id]) @@ -92,9 +94,10 @@ delegationData = await Promise.all(result) } - async function setCurrentEpoch(): Promise { - const committee = await getCommitteeInfo() - currentEpoch = committee.epoch + async function setCurrentEpochAndCommittee(): Promise { + const committeeResponse = await getCommitteeInfo() + currentEpoch = committeeResponse?.epoch + committeeAddresses = committeeResponse?.committee?.map((committee) => committee.address) || [] } function handleDelegate(): void { @@ -126,7 +129,7 @@ }) } - function renderCellValue(value: any, header: string): { component: any; props: any; text?: string } { + function renderCellValue(value: any, header: string): { component: any; props: any; text?: string; slot?: any } { switch (header as Header) { case Header.DelegationId: return { @@ -180,7 +183,19 @@ isCopyable: true, clearBoxPadding: true, clearBackground: true, - classes: 'text-gray-600 dark:text-white text-xs font-medium', + classes: 'flex flex-row items-center text-gray-600 dark:text-white text-xs font-medium gap-2', + }, + slot: { + component: PingingBadge, + props: { + classes: 'relative', + innerColor: committeeAddresses?.some((address) => address === value) + ? 'green-600' + : 'red-500', + outerColor: committeeAddresses?.some((address) => address === value) + ? 'green-400' + : 'red-300', + }, }, text: truncateString(value, 5, 5, 3), } @@ -262,6 +277,12 @@ {#if renderCell.text} + {#if renderCell.slot} + + {/if} {renderCell.text} {:else} From 3a9283aaf38ae95a12b049cc4da11659955987e2 Mon Sep 17 00:00:00 2001 From: cpl121 <100352899+cpl121@users.noreply.github.com> Date: Thu, 21 Mar 2024 12:39:51 +0100 Subject: [PATCH 4/6] feat: update network interfaces (#8210) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: update network interfaces WIP * fix: metrics in node info popup * fix: update network metrics store * fix: update node info interface --------- Co-authored-by: Begoña Álvarez de la Cruz --- .../components/popups/NodeInfoPopup.svelte | 53 +++++++++++-------- .../actions/getAndUpdateNetworkMetrics.ts | 19 +++++++ .../shared/lib/core/network/actions/index.ts | 1 + .../core/network/actions/network-polling.ts | 7 ++- .../helpers/getNetworkStatusFromNodeInfo.ts | 11 ++-- .../shared/lib/core/network/stores/index.ts | 1 + .../network/stores/network-metrics.store.ts | 8 +++ .../network/stores/network-status.store.ts | 7 +-- .../core/wallet/actions/getNetworkMetrics.ts | 7 +++ .../shared/lib/core/wallet/actions/index.ts | 1 + 10 files changed, 84 insertions(+), 31 deletions(-) create mode 100644 packages/shared/lib/core/network/actions/getAndUpdateNetworkMetrics.ts create mode 100644 packages/shared/lib/core/network/stores/network-metrics.store.ts create mode 100644 packages/shared/lib/core/wallet/actions/getNetworkMetrics.ts diff --git a/packages/desktop/components/popups/NodeInfoPopup.svelte b/packages/desktop/components/popups/NodeInfoPopup.svelte index f16f1f1c511..1fd875b78b3 100644 --- a/packages/desktop/components/popups/NodeInfoPopup.svelte +++ b/packages/desktop/components/popups/NodeInfoPopup.svelte @@ -2,12 +2,12 @@ import { onMount } from 'svelte' import { Button, Checkbox, CopyableBox, Spinner, Text } from '@ui' import { formatNumber, localize } from '@core/i18n' - import { INode } from '@core/network' + import { INode, INodeInfoResponse } from '@core/network' import { closePopup } from '@auxiliary/popup' import { showAppNotification } from '@auxiliary/notification' import { resolveObjectPath, setClipboard } from '@core/utils' - import { INodeInfo } from '@iota/sdk/out/types' - import { getNodeInfo } from '@core/wallet/actions' + import { NetworkMetricsResponse } from '@iota/sdk/out/types' + import { getNetworkMetrics, getNodeInfo } from '@core/wallet' enum NodeInfoTab { General = 'general', @@ -31,17 +31,12 @@ // features: { localeKey: 'general.features', nodeInfoPath: 'features' }, }, [NodeInfoTab.Metrics]: { - blocksPerSecond: { localeKey: 'metrics.blocksPerSecond', nodeInfoPath: 'metrics.blocksPerSecond' }, + blocksPerSecond: { localeKey: 'metrics.blocksPerSecond', nodeInfoPath: 'blocksPerSecond' }, confirmedBlocksPerSecond: { localeKey: 'metrics.confirmedBlocksPerSecond', - nodeInfoPath: 'metrics.confirmedBlocksPerSecond', + nodeInfoPath: 'confirmedBlocksPerSecond', }, - confirmationRate: { localeKey: 'metrics.confirmationRate', nodeInfoPath: 'metrics.confirmationRate' }, - // latestSlot: { localeKey: 'metrics.latestSlot', nodeInfoPath: 'status.latestSlot.index' }, - // confirmedSlot: { - // localeKey: 'metrics.confirmedSlot', - // nodeInfoPath: 'status.confirmedSlot.index', - // }, + confirmationRate: { localeKey: 'metrics.confirmationRate', nodeInfoPath: 'confirmationRate' }, }, [NodeInfoTab.Protocol]: { network: { localeKey: 'protocol.network', nodeInfoPath: 'protocolParameters[0].parameters.networkName' }, @@ -69,7 +64,8 @@ }, } - let nodeInfo: INodeInfo + let nodeInfo: INodeInfoResponse + let networkMetrics: NetworkMetricsResponse function processNodeInfoMapTab( _nodeInfoTab: NodeInfoTab, @@ -80,20 +76,20 @@ let nodeInfoValue = '' if (key === 'url') { nodeInfoValue = node.url - } else { - nodeInfoValue = resolveObjectPath(nodeInfo, nodeInfoTabObject[key]?.nodeInfoPath, null) - if (key === 'confirmationRate' || key === 'blocksPerSecond' || key === 'confirmedBlocksPerSecond') { - const numberValue = Number(nodeInfoValue) - if (numberValue >= 0) { - if (key === 'confirmationRate') { - nodeInfoValue = `${formatNumber(Math.min(numberValue, 100), 1, 1)}%` - } else { - nodeInfoValue = formatNumber(numberValue, 1, 1) - } + } else if (_nodeInfoTab === NodeInfoTab.Metrics) { + nodeInfoValue = resolveObjectPath(networkMetrics, nodeInfoTabObject[key]?.nodeInfoPath, null) + const numberValue = Number(nodeInfoValue) + if (numberValue >= 0) { + if (key === 'confirmationRate') { + nodeInfoValue = `${formatNumber(Math.min(numberValue, 100), 1, 1)}%` } else { - nodeInfoValue = '' + nodeInfoValue = formatNumber(numberValue, 1, 1) } + } else { + nodeInfoValue = '' } + } else { + nodeInfoValue = resolveObjectPath(nodeInfo, nodeInfoTabObject[key]?.nodeInfoPath, null) } return { @@ -124,6 +120,17 @@ message: localize(err.error), }) }) + getNetworkMetrics() + .then((networkMetricsResponse) => { + networkMetrics = networkMetricsResponse + }) + .catch((err) => { + closePopup() + showAppNotification({ + type: 'error', + message: localize(err.error), + }) + }) }) diff --git a/packages/shared/lib/core/network/actions/getAndUpdateNetworkMetrics.ts b/packages/shared/lib/core/network/actions/getAndUpdateNetworkMetrics.ts new file mode 100644 index 00000000000..3056deacbaa --- /dev/null +++ b/packages/shared/lib/core/network/actions/getAndUpdateNetworkMetrics.ts @@ -0,0 +1,19 @@ +import { getNetworkMetrics } from '@core/wallet/actions' +import { NetworkMetricsResponse } from '@iota/sdk' +import { setNetworkMetrics } from '../stores' + +export async function getAndUpdateNetworkMetrics(forwardErrors = false): Promise { + let networkMetricsResponse: NetworkMetricsResponse + try { + networkMetricsResponse = await getNetworkMetrics() + setNetworkMetrics(networkMetricsResponse) + return networkMetricsResponse + } catch (err) { + setNetworkMetrics(undefined) + if (forwardErrors) { + return Promise.reject(err) + } else { + console.error(err) + } + } +} diff --git a/packages/shared/lib/core/network/actions/index.ts b/packages/shared/lib/core/network/actions/index.ts index 061e6dc7779..fae6b8ddc6c 100644 --- a/packages/shared/lib/core/network/actions/index.ts +++ b/packages/shared/lib/core/network/actions/index.ts @@ -8,3 +8,4 @@ export * from './showNetworkIssueNotification' export * from './toggleDisabledNodeInClientOptions' export * from './togglePrimaryNodeInClientOptions' export * from './updateClientOptions' +export * from './getAndUpdateNetworkMetrics' diff --git a/packages/shared/lib/core/network/actions/network-polling.ts b/packages/shared/lib/core/network/actions/network-polling.ts index 3da4d89331b..f190a07f22e 100644 --- a/packages/shared/lib/core/network/actions/network-polling.ts +++ b/packages/shared/lib/core/network/actions/network-polling.ts @@ -1,4 +1,5 @@ import { NETWORK_STATUS_POLL_INTERVAL } from '../constants' +import { getAndUpdateNetworkMetrics } from './getAndUpdateNetworkMetrics' import { getAndUpdateNodeInfo } from './getAndUpdateNodeInfo' let pollInterval: number @@ -8,7 +9,11 @@ let pollInterval: number */ export async function pollNetworkStatus(): Promise { await getAndUpdateNodeInfo() - pollInterval = window.setInterval(() => void getAndUpdateNodeInfo(), NETWORK_STATUS_POLL_INTERVAL) + await getAndUpdateNetworkMetrics() + pollInterval = window.setInterval(() => { + getAndUpdateNodeInfo() + getAndUpdateNetworkMetrics() + }, NETWORK_STATUS_POLL_INTERVAL) } export function clearNetworkPoll(): void { diff --git a/packages/shared/lib/core/network/helpers/getNetworkStatusFromNodeInfo.ts b/packages/shared/lib/core/network/helpers/getNetworkStatusFromNodeInfo.ts index c993c604b7c..129df88cec2 100644 --- a/packages/shared/lib/core/network/helpers/getNetworkStatusFromNodeInfo.ts +++ b/packages/shared/lib/core/network/helpers/getNetworkStatusFromNodeInfo.ts @@ -1,7 +1,7 @@ import { MILLISECONDS_PER_SECOND, SECONDS_PER_MINUTE } from '@core/utils' import { NetworkHealth } from '../enums' import { INetworkStatus } from '../interfaces' -import { INodeInfo } from '@iota/sdk/out/types' +import { INodeInfo, NetworkMetricsResponse } from '@iota/sdk/out/types' import { getUnixTimestampFromNodeInfoAndSlotIndex } from './getSlotInfoFromNodeProtocolParameters' /** @@ -11,7 +11,10 @@ import { getUnixTimestampFromNodeInfoAndSlotIndex } from './getSlotInfoFromNodeP * @param {IStardustNodeInfo} nodeInfo * @returns {INetworkStatus} */ -export function getNetworkStatusFromNodeInfo(nodeInfo: INodeInfo): INetworkStatus { +export function getNetworkStatusFromNodeInfo( + nodeInfo: INodeInfo, + networkMetrics: NetworkMetricsResponse +): INetworkStatus { let health = NetworkHealth.Down const unixTimestamp = getUnixTimestampFromNodeInfoAndSlotIndex( nodeInfo.protocolParameters[0].parameters, @@ -31,8 +34,8 @@ export function getNetworkStatusFromNodeInfo(nodeInfo: INodeInfo): INetworkStatu } return { - messagesPerSecond: nodeInfo.metrics.blocksPerSecond, - confirmationRate: nodeInfo.metrics.confirmationRate, + messagesPerSecond: networkMetrics.blocksPerSecond, + confirmationRate: networkMetrics.confirmationRate, health, currentSlot: nodeInfo.status.latestConfirmedBlockSlot, } diff --git a/packages/shared/lib/core/network/stores/index.ts b/packages/shared/lib/core/network/stores/index.ts index 953591a9fe9..e7d86760a6a 100644 --- a/packages/shared/lib/core/network/stores/index.ts +++ b/packages/shared/lib/core/network/stores/index.ts @@ -1,2 +1,3 @@ export * from './network-status.store' export * from './node-info.store' +export * from './network-metrics.store' diff --git a/packages/shared/lib/core/network/stores/network-metrics.store.ts b/packages/shared/lib/core/network/stores/network-metrics.store.ts new file mode 100644 index 00000000000..ee5664ce39b --- /dev/null +++ b/packages/shared/lib/core/network/stores/network-metrics.store.ts @@ -0,0 +1,8 @@ +import { NetworkMetricsResponse } from '@iota/sdk/out/types' +import { writable } from 'svelte/store' + +export const networkMetrics = writable(undefined) + +export function setNetworkMetrics(newNetworkMetrics: NetworkMetricsResponse | undefined): void { + return networkMetrics.set(newNetworkMetrics) +} diff --git a/packages/shared/lib/core/network/stores/network-status.store.ts b/packages/shared/lib/core/network/stores/network-status.store.ts index 436eda5891f..b6f6c4afd21 100644 --- a/packages/shared/lib/core/network/stores/network-status.store.ts +++ b/packages/shared/lib/core/network/stores/network-status.store.ts @@ -3,10 +3,11 @@ import { SLOT_NOT_FOUND } from '../constants' import { NetworkHealth } from '../enums/network-health.enum' import { getNetworkStatusFromNodeInfo } from '../helpers' import { nodeInfo } from './node-info.store' +import { networkMetrics } from './network-metrics.store' -export const networkStatus = derived([nodeInfo], ([$nodeInfo]) => { - if ($nodeInfo) { - return getNetworkStatusFromNodeInfo($nodeInfo) +export const networkStatus = derived([nodeInfo, networkMetrics], ([$nodeInfo, $networkMetrics]) => { + if ($nodeInfo && $networkMetrics) { + return getNetworkStatusFromNodeInfo($nodeInfo, $networkMetrics) } else { return { messagesPerSecond: 0, diff --git a/packages/shared/lib/core/wallet/actions/getNetworkMetrics.ts b/packages/shared/lib/core/wallet/actions/getNetworkMetrics.ts new file mode 100644 index 00000000000..d15fcc86d01 --- /dev/null +++ b/packages/shared/lib/core/wallet/actions/getNetworkMetrics.ts @@ -0,0 +1,7 @@ +import { NetworkMetricsResponse } from '@iota/sdk/out/types' +import { getClient } from './getClient' + +export async function getNetworkMetrics(): Promise { + const client = await getClient() + return client.getNetworkMetrics() +} diff --git a/packages/shared/lib/core/wallet/actions/index.ts b/packages/shared/lib/core/wallet/actions/index.ts index 8dde6d065e0..4007985c487 100644 --- a/packages/shared/lib/core/wallet/actions/index.ts +++ b/packages/shared/lib/core/wallet/actions/index.ts @@ -40,4 +40,5 @@ export * from './setNextSelectedWallet' export * from './restoreBackup' export * from './getOutputRewards' export * from './getCommitteInfo' +export * from './getNetworkMetrics' export * from './getTotalWalletBalance' From ee06e132d164420d2829169f98a170dc4c8413cd Mon Sep 17 00:00:00 2001 From: cpl121 <100352899+cpl121@users.noreply.github.com> Date: Thu, 21 Mar 2024 17:51:40 +0100 Subject: [PATCH 5/6] feat: add mana cost everywhere (#8202) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: implement logic to allow tx or not based on mana cost for the X slots * fixes and clean up * feat: add mana cost to mint, burn, send and implicitTransition * feat: improvements in mana box component * feat: add mana cost to claim activity * feat: add mana cost to create delegation * feat: add mana cost to claim shimmer * fixes * fix: add conditional chaining * fix: update mana box with new transactionInfo interface * fix: json literal and seconds in fund confirmation view * fix: minor improvements --------- Co-authored-by: marc2332 Co-authored-by: Begoña Álvarez de la Cruz --- packages/desktop/components/ManaBox.svelte | 88 +++++++++++++++++++ packages/desktop/components/index.js | 1 + .../popups/ActivityDetailsPopup.svelte | 57 ++++++++---- .../BurnNativeTokensConfirmationPopup.svelte | 25 +++++- .../popups/CreateDelegationPopup.svelte | 25 +++++- .../MintNativeTokenConfirmationPopup.svelte | 24 ++++- .../popups/MintNftConfirmationPopup.svelte | 18 +++- .../popups/send/SendConfirmationPopup.svelte | 88 +++++-------------- .../components/popups/send/SendNftForm.svelte | 6 +- .../popups/send/SendTokenForm.svelte | 6 +- .../FundConfirmationView.svelte | 24 ++++- .../views/ClaimFinderView.svelte | 65 +++++++++++++- .../lib/core/network/interfaces/index.ts | 1 + ...n-info-to-calculate-mana-cost.interface.ts | 6 ++ .../core/wallet/actions/createNativeToken.ts | 20 ++--- .../shared/lib/core/wallet/actions/index.ts | 2 + .../actions/prepareCreateNativeToken.ts | 25 ++++++ .../lib/core/wallet/actions/prepareMintNft.ts | 36 ++++++++ packages/shared/locales/en.json | 4 +- 19 files changed, 398 insertions(+), 123 deletions(-) create mode 100644 packages/desktop/components/ManaBox.svelte create mode 100644 packages/shared/lib/core/network/interfaces/transaction-info-to-calculate-mana-cost.interface.ts create mode 100644 packages/shared/lib/core/wallet/actions/prepareCreateNativeToken.ts create mode 100644 packages/shared/lib/core/wallet/actions/prepareMintNft.ts diff --git a/packages/desktop/components/ManaBox.svelte b/packages/desktop/components/ManaBox.svelte new file mode 100644 index 00000000000..7eafc6bed68 --- /dev/null +++ b/packages/desktop/components/ManaBox.svelte @@ -0,0 +1,88 @@ + + +
+ + + {#if !hasEnoughMana} + + {localize('general.insufficientMana', { + values: { + availableMana: formatTokenAmountBestMatch(availableMana, mana.metadata), + }, + })} + + {:else if showCountdown} + + {localize('general.secondsToRefreshManaCost', { + values: { + seconds: secondsToRefreshManaCost, + }, + })} + + {/if} +
diff --git a/packages/desktop/components/index.js b/packages/desktop/components/index.js index 8ec7fe87ce8..20d9e2a9a43 100644 --- a/packages/desktop/components/index.js +++ b/packages/desktop/components/index.js @@ -23,3 +23,4 @@ export { default as VotingPower } from './VotingPower.svelte' export { default as VestingSchedule } from './VestingSchedule.svelte' export { default as AccountManagementDetails } from './AccountManagementDetails.svelte' export { default as AccountManagementList } from './AccountManagementList.svelte' +export { default as ManaBox } from './ManaBox.svelte' diff --git a/packages/desktop/components/popups/ActivityDetailsPopup.svelte b/packages/desktop/components/popups/ActivityDetailsPopup.svelte index 47fe5716f8b..dd01ec35a94 100644 --- a/packages/desktop/components/popups/ActivityDetailsPopup.svelte +++ b/packages/desktop/components/popups/ActivityDetailsPopup.svelte @@ -2,7 +2,7 @@ import { PopupId, closePopup, openPopup } from '@auxiliary/popup' import { openUrlInBrowser } from '@core/app' import { localize } from '@core/i18n' - import { ExplorerEndpoint } from '@core/network' + import { ExplorerEndpoint, ITransactionInfoToCalculateManaCost } from '@core/network' import { getOfficialExplorerUrl } from '@core/network/utils' import { activeProfile, checkActiveProfileAuth } from '@core/profile' import { setClipboard, truncateString } from '@core/utils' @@ -12,6 +12,7 @@ ActivityType, claimActivity, rejectActivity, + selectedWallet, selectedWalletActivities, } from '@core/wallet' import { @@ -29,12 +30,16 @@ } from '@ui' import { TextHintVariant } from '@ui/enums' import { onMount } from 'svelte' + import { ManaBox } from '@components' export let activityId: string export let _onMount: (..._: any[]) => Promise = async () => {} const explorerUrl = getOfficialExplorerUrl($activeProfile?.network?.id) + const transactionInfo: ITransactionInfoToCalculateManaCost = {} + let hasEnoughMana = false + $: activity = $selectedWalletActivities?.find((_activity) => _activity.id === activityId) $: isTimelocked = activity?.asyncData?.asyncStatus === ActivityAsyncStatus.Timelocked $: isActivityIncomingAndUnclaimed = @@ -69,6 +74,14 @@ await checkActiveProfileAuth(claim, { stronghold: true, ledger: false }) } + async function prepareClaimOutput(): Promise { + try { + transactionInfo.preparedTransaction = await $selectedWallet?.prepareClaimOutputs([activity.outputId]) + } catch (error) { + transactionInfo.preparedTransactionError = error + } + } + function onRejectClick(): void { openPopup({ id: PopupId.Confirmation, @@ -94,6 +107,9 @@ onMount(async () => { try { await _onMount() + if (!isTimelocked && isActivityIncomingAndUnclaimed) { + await prepareClaimOutput() + } } catch (err) { console.error(err) } @@ -139,24 +155,27 @@ {#if !isTimelocked && isActivityIncomingAndUnclaimed} - - - - +
+ + + + + +
{/if} {/if} diff --git a/packages/desktop/components/popups/BurnNativeTokensConfirmationPopup.svelte b/packages/desktop/components/popups/BurnNativeTokensConfirmationPopup.svelte index c1d403635f7..864a6097e96 100644 --- a/packages/desktop/components/popups/BurnNativeTokensConfirmationPopup.svelte +++ b/packages/desktop/components/popups/BurnNativeTokensConfirmationPopup.svelte @@ -2,17 +2,22 @@ import { Button, Text, TextHint, FontWeight, TextType, ButtonVariant, KeyValueBox } from '@ui' import { localize } from '@core/i18n' import { closePopup, openPopup, PopupId } from '@auxiliary/popup' - import { burnAsset, formatTokenAmountBestMatch, IAsset } from '@core/wallet' + import { burnAsset, formatTokenAmountBestMatch, getDefaultTransactionOptions, IAsset } from '@core/wallet' import { checkActiveProfileAuth } from '@core/profile' import { handleError } from '@core/error/handlers' import { onMount } from 'svelte' import { selectedWallet } from '@core/wallet' import { TextHintVariant } from '@ui/enums' + import { ManaBox } from '@components' + import { ITransactionInfoToCalculateManaCost } from '@core/network' export let asset: IAsset export let rawAmount: string export let _onMount: (..._: any[]) => Promise = async () => {} + const transactionInfo: ITransactionInfoToCalculateManaCost = {} + let hasEnoughMana = false + $: formattedAmount = formatTokenAmountBestMatch(Number(rawAmount), asset?.metadata) function onBackClick(): void { @@ -36,9 +41,24 @@ } } + async function prepareBurnFoundryTransaction(): Promise { + if (asset && $selectedWallet && rawAmount) { + try { + transactionInfo.preparedTransaction = await $selectedWallet.prepareBurnNativeToken( + asset.id, + BigInt(rawAmount), + getDefaultTransactionOptions() + ) + } catch (error) { + transactionInfo.preparedTransactionError = error + } + } + } + onMount(async () => { try { await _onMount() + await prepareBurnFoundryTransaction() } catch (err) { handleError(err) } @@ -57,6 +77,7 @@ +
@@ -64,7 +85,7 @@ classes="w-full" variant={ButtonVariant.Warning} isBusy={$selectedWallet?.isTransferring} - disabled={$selectedWallet?.isTransferring} + disabled={$selectedWallet?.isTransferring || !hasEnoughMana} onClick={onBurnTokenClick} > {localize('actions.burnToken')} diff --git a/packages/desktop/components/popups/CreateDelegationPopup.svelte b/packages/desktop/components/popups/CreateDelegationPopup.svelte index 4825c28432e..586a6fd381c 100644 --- a/packages/desktop/components/popups/CreateDelegationPopup.svelte +++ b/packages/desktop/components/popups/CreateDelegationPopup.svelte @@ -13,7 +13,9 @@ } from '@core/wallet' import { AccountAddress, CreateDelegationParams } from '@iota/sdk/out/types' import { Text, TextType, AssetAmountInput, TextInput, Button, HTMLButtonType } from '@ui' + import { ManaBox } from '@components' import { onMount } from 'svelte' + import { ITransactionInfoToCalculateManaCost } from '@core/network' export let _onMount: (..._: any[]) => Promise = async () => {} export let rawAmount: string = $selectedWallet?.balances?.baseCoin?.available?.toString() @@ -23,6 +25,9 @@ let amount: string let confirmDisabled = false + const transactionInfo: ITransactionInfoToCalculateManaCost = {} + let hasEnoughMana = false + $: asset = $visibleSelectedWalletAssets[$activeProfile?.network?.id].baseCoin $: hasTransactionInProgress = $selectedWallet?.hasConsolidatingOutputsTransactionInProgress || @@ -36,7 +41,7 @@ return } const convertedSliderAmount = convertToRawAmount(amount, asset?.metadata)?.toString() - confirmDisabled = convertedSliderAmount === rawAmount || hasTransactionInProgress + confirmDisabled = convertedSliderAmount === rawAmount || hasTransactionInProgress || !hasEnoughMana } async function onSubmit(): Promise { @@ -67,6 +72,22 @@ } } + async function prepareDelegationOutput(): Promise { + const params: CreateDelegationParams = { + address: AddressConverter.addressToBech32(new AccountAddress($selectedWallet?.mainAccountId)), + delegatedAmount: rawAmount, + validatorAddress: new AccountAddress(AddressConverter.parseBech32Address(accountAddress)), + } + try { + transactionInfo.preparedTransaction = await $selectedWallet?.prepareCreateDelegation( + params, + getDefaultTransactionOptions() + ) + } catch (error) { + transactionInfo.preparedTransactionError = error + } + } + function onCancelClick(): void { closePopup() } @@ -74,6 +95,7 @@ onMount(async () => { try { await _onMount() + await prepareDelegationOutput() } catch (err) { handleError(err.error) } @@ -99,6 +121,7 @@ placeholder={localize('popups.createDelegation.account.title')} label={localize('popups.createDelegation.account.description')} /> +
@@ -158,7 +173,12 @@ - diff --git a/packages/desktop/components/popups/MintNftConfirmationPopup.svelte b/packages/desktop/components/popups/MintNftConfirmationPopup.svelte index 44479f4449c..d828112e03d 100644 --- a/packages/desktop/components/popups/MintNftConfirmationPopup.svelte +++ b/packages/desktop/components/popups/MintNftConfirmationPopup.svelte @@ -1,14 +1,16 @@
- + {localize('popups.mintNftForm.title')}
@@ -134,6 +143,7 @@ isPreText /> {/if} +
@@ -143,7 +153,7 @@
{#if surplus} diff --git a/packages/desktop/components/popups/send/SendNftForm.svelte b/packages/desktop/components/popups/send/SendNftForm.svelte index 5422a436b69..8d31bb5869f 100644 --- a/packages/desktop/components/popups/send/SendNftForm.svelte +++ b/packages/desktop/components/popups/send/SendNftForm.svelte @@ -79,20 +79,16 @@ } }) - async function buildPreparedOutput(): Promise<{ preparedOutput: Output; allotmentManaCost: number }> { + async function buildPreparedOutput(): Promise<{ preparedOutput: Output }> { try { const details = get(newTransactionDetails) isPreparingOutput = true const outputParams = await getOutputParameters(details) const preparedOutput = await prepareOutput($selectedWallet.id, outputParams, getDefaultTransactionOptions()) - const prepareTx = await $selectedWallet.prepareSendOutputs([preparedOutput], getDefaultTransactionOptions()) - const allotmentManaCost = - prepareTx?._preparedData?.transaction?.allotments?.reduce((acc, { mana }) => acc + mana, 0) || 0 return { preparedOutput, - allotmentManaCost, } } catch (err) { handleError(err) diff --git a/packages/desktop/components/popups/send/SendTokenForm.svelte b/packages/desktop/components/popups/send/SendTokenForm.svelte index e8d4706d6bf..b64e1677dfe 100644 --- a/packages/desktop/components/popups/send/SendTokenForm.svelte +++ b/packages/desktop/components/popups/send/SendTokenForm.svelte @@ -69,18 +69,14 @@ $: showLayer2 = features?.network?.layer2?.enabled && ($activeProfile.isDeveloperProfile || isBaseTokenTransfer) $: asset, !showLayer2 && networkInput?.reset() - async function buildPreparedOutput(): Promise<{ preparedOutput: Output; allotmentManaCost: number }> { + async function buildPreparedOutput(): Promise<{ preparedOutput: Output }> { try { const details = get(newTransactionDetails) isPreparingOutput = true const outputParams = await getOutputParameters(details) const preparedOutput = await prepareOutput($selectedWallet.id, outputParams, getDefaultTransactionOptions()) - const prepareTx = await $selectedWallet.prepareSendOutputs([preparedOutput], getDefaultTransactionOptions()) - const allotmentManaCost = - prepareTx?._preparedData?.transaction?.allotments?.reduce((acc, { mana }) => acc + mana, 0) || 0 return { preparedOutput, - allotmentManaCost, } } catch (err) { handleError(err) diff --git a/packages/desktop/views/dashboard/wallet/views/implicit-account-creation-multistep/FundConfirmationView.svelte b/packages/desktop/views/dashboard/wallet/views/implicit-account-creation-multistep/FundConfirmationView.svelte index aacb27dee03..90ce524ff0a 100644 --- a/packages/desktop/views/dashboard/wallet/views/implicit-account-creation-multistep/FundConfirmationView.svelte +++ b/packages/desktop/views/dashboard/wallet/views/implicit-account-creation-multistep/FundConfirmationView.svelte @@ -1,10 +1,16 @@