From c6b90fb5cb411e2ff2e68c16612e14323e8e395b Mon Sep 17 00:00:00 2001 From: Mark Nardi Date: Fri, 3 May 2024 16:12:59 +0200 Subject: [PATCH] rename `formatTokenAmountBestMatch` to `formatTokenAmount` --- .../VerifyLedgerTransactionPopup.svelte | 4 +- .../components/TransakAccountPanel.svelte | 4 +- .../components/ManageVotingPowerPane.svelte | 6 +-- .../ProposalInformationPane.svelte | 6 +-- .../views/InputTokenAmountView.svelte | 4 +- .../components/EvmTransactionDetails.svelte | 6 +-- .../StardustTransactionDetails.svelte | 4 +- .../components/StorageDepositButton.svelte | 6 +-- .../components/AccountNetworkSummary.svelte | 7 +-- .../row-sections/ActivityFeeSection.svelte | 4 +- .../portfolio/components/TokenListRow.svelte | 6 +-- .../views/BalanceFinderView.svelte | 4 +- .../evm/info/EvmGenericInformation.svelte | 4 +- .../info/StardustGenericInformation.svelte | 4 +- .../info/StardustGovernanceInformation.svelte | 4 +- .../atoms/BalanceSummarySection.svelte | 4 +- .../components/inputs/TokenAmountInput.svelte | 6 +-- .../inputs/TokenAmountWithSliderInput.svelte | 8 +-- .../tiles/ShimmerClaimingAccountTile.svelte | 4 +- .../components/tiles/TokenAmountTile.svelte | 4 +- .../tiles/TokenAvailableBalanceTile.svelte | 4 +- .../actions/syncShimmerClaimingAccount.ts | 4 +- .../activity/utils/convertActvitiesToCsv.ts | 16 +++--- .../outputs/getFormattedAmountFromActivity.ts | 4 +- ...mattedVotingPowerFromGovernanceActivity.ts | 4 +- .../deconstructLedgerVerificationProps.ts | 4 +- .../constants/default-base-token.constant.ts | 2 - .../token/interfaces/base-token.interface.ts | 1 - .../token/tests/convertToRawAmount.test.ts | 41 +++++++-------- ...atch.test.ts => formatTokenAmount.test.ts} | 50 +++++++++---------- .../shared/test/mocks/profile-manager.mock.ts | 1 - 31 files changed, 109 insertions(+), 121 deletions(-) rename packages/shared/src/lib/core/token/tests/{formatTokenAmountBestMatch.test.ts => formatTokenAmount.test.ts} (65%) diff --git a/packages/desktop/components/popup/profileAuthPopups/VerifyLedgerTransactionPopup.svelte b/packages/desktop/components/popup/profileAuthPopups/VerifyLedgerTransactionPopup.svelte index a685fb4887..96201fd8e5 100644 --- a/packages/desktop/components/popup/profileAuthPopups/VerifyLedgerTransactionPopup.svelte +++ b/packages/desktop/components/popup/profileAuthPopups/VerifyLedgerTransactionPopup.svelte @@ -4,7 +4,7 @@ import { resetShowInternalVerificationPopup, showInternalVerificationPopup } from '@core/ledger' import { getBaseToken } from '@core/profile/actions' import { LedgerStatusIllustration, LedgerIllustrationVariant } from '@ui' - import { formatTokenAmountBestMatch } from '@core/token/utils' + import { formatTokenAmount } from '@core/token/utils' import { formatHexString } from '@core/utils' import { onDestroy } from 'svelte' import PopupTemplate from '../PopupTemplate.svelte' @@ -80,7 +80,7 @@ key: localize('general.maxFees'), value: !useBlindSigning && isEvmTransaction - ? formatTokenAmountBestMatch(maxGasFee, getBaseToken()) + ? formatTokenAmount(maxGasFee, getBaseToken()) : undefined, }, { diff --git a/packages/desktop/views/dashboard/buy-sell/components/TransakAccountPanel.svelte b/packages/desktop/views/dashboard/buy-sell/components/TransakAccountPanel.svelte index bd69c786b5..e4a16a29cb 100644 --- a/packages/desktop/views/dashboard/buy-sell/components/TransakAccountPanel.svelte +++ b/packages/desktop/views/dashboard/buy-sell/components/TransakAccountPanel.svelte @@ -6,7 +6,7 @@ import { formatCurrency } from '@core/i18n' import { getFiatValueFromTokenAmount } from '@core/market/actions' import { activeProfile } from '@core/profile/stores' - import { formatTokenAmountBestMatch } from '@core/token' + import { formatTokenAmount } from '@core/token' import { selectedAccountTokens } from '@core/token/stores' let tokenBalance: string = '' @@ -16,7 +16,7 @@ const tokens = $selectedAccountTokens?.[$activeProfile.network.id] const networkBaseCoin = tokens?.baseCoin if (!networkBaseCoin) return - tokenBalance = formatTokenAmountBestMatch(networkBaseCoin.balance.total, networkBaseCoin.metadata) + tokenBalance = formatTokenAmount(networkBaseCoin.balance.total, networkBaseCoin.metadata) fiatBalance = formatCurrency(getFiatValueFromTokenAmount(networkBaseCoin.balance.total, networkBaseCoin)) } diff --git a/packages/desktop/views/dashboard/governance/components/ManageVotingPowerPane.svelte b/packages/desktop/views/dashboard/governance/components/ManageVotingPowerPane.svelte index e6b7a9ac5f..c3390f9b8d 100644 --- a/packages/desktop/views/dashboard/governance/components/ManageVotingPowerPane.svelte +++ b/packages/desktop/views/dashboard/governance/components/ManageVotingPowerPane.svelte @@ -2,7 +2,7 @@ import { selectedAccount } from '@core/account/stores' import { localize } from '@core/i18n' import { activeProfile } from '@core/profile/stores' - import { formatTokenAmountBestMatch } from '@core/token' + import { formatTokenAmount } from '@core/token' import { visibleSelectedAccountTokens } from '@core/token/stores' import { PopupId, openPopup } from '@desktop/auxiliary/popup' import { Button, Text } from '@bloomwalletio/ui' @@ -13,8 +13,8 @@ $: votingPower = $selectedAccount?.votingPower $: maxVotingPower = $selectedAccount?.balances?.baseCoin?.available + votingPower - $: formattedVotingPower = formatTokenAmountBestMatch(votingPower, token?.metadata) - $: formattedMaxVotingPower = formatTokenAmountBestMatch(maxVotingPower, token?.metadata) + $: formattedVotingPower = formatTokenAmount(votingPower, token?.metadata) + $: formattedMaxVotingPower = formatTokenAmount(maxVotingPower, token?.metadata) $: hasTransactionInProgress = $selectedAccount?.hasVotingPowerTransactionInProgress || $selectedAccount?.hasVotingTransactionInProgress || diff --git a/packages/desktop/views/dashboard/governance/components/proposal-details/ProposalInformationPane.svelte b/packages/desktop/views/dashboard/governance/components/proposal-details/ProposalInformationPane.svelte index 59589886c1..512218dc05 100644 --- a/packages/desktop/views/dashboard/governance/components/proposal-details/ProposalInformationPane.svelte +++ b/packages/desktop/views/dashboard/governance/components/proposal-details/ProposalInformationPane.svelte @@ -13,7 +13,7 @@ import { formatDate, localize } from '@core/i18n' import { getL1Network } from '@core/network/stores' import { activeProfile } from '@core/profile/stores' - import { formatTokenAmountBestMatch } from '@core/token' + import { formatTokenAmount } from '@core/token' import { visibleSelectedAccountTokens } from '@core/token/stores' import { DATE_FORMAT, milestoneToDate, truncateString } from '@core/utils' import { EventStatus } from '@iota/sdk/out/types' @@ -93,11 +93,11 @@ }, { key: localize('views.governance.details.yourVote.power'), - value: formatTokenAmountBestMatch($selectedAccount?.votingPower, metadata), + value: formatTokenAmount($selectedAccount?.votingPower, metadata), }, { key: localize('views.governance.details.yourVote.total'), - value: formatTokenAmountBestMatch(totalVotes, metadata), + value: formatTokenAmount(totalVotes, metadata), }, { key: localize('views.governance.details.proposalInformation.eventId'), diff --git a/packages/desktop/views/dashboard/send-flow/views/InputTokenAmountView.svelte b/packages/desktop/views/dashboard/send-flow/views/InputTokenAmountView.svelte index b4a3a99f68..f1904a0851 100644 --- a/packages/desktop/views/dashboard/send-flow/views/InputTokenAmountView.svelte +++ b/packages/desktop/views/dashboard/send-flow/views/InputTokenAmountView.svelte @@ -1,6 +1,6 @@ diff --git a/packages/shared/src/components/activities/stardust/info/StardustGenericInformation.svelte b/packages/shared/src/components/activities/stardust/info/StardustGenericInformation.svelte index 7d58394385..b9db387564 100644 --- a/packages/shared/src/components/activities/stardust/info/StardustGenericInformation.svelte +++ b/packages/shared/src/components/activities/stardust/info/StardustGenericInformation.svelte @@ -5,7 +5,7 @@ import { time } from '@core/app/stores' import { getFormattedTimeStamp, localize } from '@core/i18n' import { ExplorerEndpoint, getDefaultExplorerUrl, getNetwork } from '@core/network' - import { formatTokenAmountBestMatch } from '@core/token' + import { formatTokenAmount } from '@core/token' import { buildUrl } from '@core/utils' import { getTimeDifference } from '@core/utils/time' import { NetworkLabel, ExpiredPill, TimelockPill, UnclaimedPill } from '@ui' @@ -31,7 +31,7 @@ } function formatAmount(amount: bigint | undefined): string | undefined { - return amount ? formatTokenAmountBestMatch(amount, getNetwork(activity.sourceNetworkId)?.baseToken) : undefined + return amount ? formatTokenAmount(amount, getNetwork(activity.sourceNetworkId)?.baseToken) : undefined } diff --git a/packages/shared/src/components/activities/stardust/info/StardustGovernanceInformation.svelte b/packages/shared/src/components/activities/stardust/info/StardustGovernanceInformation.svelte index 0f945bf9af..9cbcce9911 100644 --- a/packages/shared/src/components/activities/stardust/info/StardustGovernanceInformation.svelte +++ b/packages/shared/src/components/activities/stardust/info/StardustGovernanceInformation.svelte @@ -2,7 +2,7 @@ import { Table } from '@bloomwalletio/ui' import { getFormattedTimeStamp, localize } from '@core/i18n' import { getBaseToken } from '@core/profile/actions' - import { formatTokenAmountBestMatch } from '@core/token' + import { formatTokenAmount } from '@core/token' import { StardustGovernanceAction, StardustGovernanceActivity } from '@core/activity' export let activity: StardustGovernanceActivity @@ -23,7 +23,7 @@ key: isNewVotingPower ? localize('general.newVotingPower') : localize('general.votingPower'), value: activity?.votingPower !== undefined - ? formatTokenAmountBestMatch(activity?.votingPower, getBaseToken()) + ? formatTokenAmount(activity?.votingPower, getBaseToken()) : undefined, }, ]} diff --git a/packages/shared/src/components/atoms/BalanceSummarySection.svelte b/packages/shared/src/components/atoms/BalanceSummarySection.svelte index 09d5a7ed14..cb94de3571 100644 --- a/packages/shared/src/components/atoms/BalanceSummarySection.svelte +++ b/packages/shared/src/components/atoms/BalanceSummarySection.svelte @@ -3,7 +3,7 @@ import { formatCurrency, localize } from '@core/i18n' import { getFiatValueFromTokenAmount } from '@core/market/actions' import { activeProfile } from '@core/profile/stores' - import { formatTokenAmountBestMatch } from '@core/token' + import { formatTokenAmount } from '@core/token' import { selectedAccountTokens } from '@core/token/stores' import { BalanceSummaryRow } from '@ui' @@ -19,7 +19,7 @@ $: baseCoin = $selectedAccountTokens?.[$activeProfile?.network?.id]?.baseCoin function getAmount(amount: bigint): string { - return baseCoin?.metadata ? formatTokenAmountBestMatch(amount, baseCoin.metadata) : '' + return baseCoin?.metadata ? formatTokenAmount(amount, baseCoin.metadata) : '' } function getCurrencyAmount(amount: bigint): string { diff --git a/packages/shared/src/components/inputs/TokenAmountInput.svelte b/packages/shared/src/components/inputs/TokenAmountInput.svelte index bcaa8158a5..19d225765f 100644 --- a/packages/shared/src/components/inputs/TokenAmountInput.svelte +++ b/packages/shared/src/components/inputs/TokenAmountInput.svelte @@ -5,7 +5,7 @@ import { ITokenWithBalance, convertToRawAmount, - formatTokenAmountBestMatch, + formatTokenAmount, getMaxDecimalsFromTokenMetadata, validateTokenAmount, } from '@core/token' @@ -20,7 +20,7 @@ export let availableBalance: bigint export let inputtedAmount: string | undefined = rawAmount && token?.metadata - ? formatTokenAmountBestMatch(rawAmount, token.metadata, { withUnit: false, round: false }) + ? formatTokenAmount(rawAmount, token.metadata, { withUnit: false, round: false }) : undefined type InputFontSize = 'text-32' | 'text-48' | 'text-64' @@ -63,7 +63,7 @@ const allowedDecimalAmount = Math.min(decimalPlacesAmount, metadata.decimals) const integerLengthOfBalance = - formatTokenAmountBestMatch(availableBalance, metadata, { withUnit: false, round: false }).split( + formatTokenAmount(availableBalance, metadata, { withUnit: false, round: false }).split( decimalSeparator )?.[0]?.length ?? 0 diff --git a/packages/shared/src/components/inputs/TokenAmountWithSliderInput.svelte b/packages/shared/src/components/inputs/TokenAmountWithSliderInput.svelte index 3d33e24498..411ade30f9 100644 --- a/packages/shared/src/components/inputs/TokenAmountWithSliderInput.svelte +++ b/packages/shared/src/components/inputs/TokenAmountWithSliderInput.svelte @@ -1,6 +1,6 @@