Skip to content

Commit

Permalink
rename formatTokenAmountBestMatch to formatTokenAmount
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkNerdi committed May 3, 2024
1 parent bd5725b commit c6b90fb
Show file tree
Hide file tree
Showing 31 changed files with 109 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -80,7 +80,7 @@
key: localize('general.maxFees'),
value:
!useBlindSigning && isEvmTransaction
? formatTokenAmountBestMatch(maxGasFee, getBaseToken())
? formatTokenAmount(maxGasFee, getBaseToken())
: undefined,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand All @@ -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))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { localize } from '@core/i18n'
import { BASE_TOKEN_ID, ITokenWithBalance, formatTokenAmountBestMatch, getUnitFromTokenMetadata } from '@core/token'
import { BASE_TOKEN_ID, ITokenWithBalance, formatTokenAmount, getUnitFromTokenMetadata } from '@core/token'
import { getTokenFromSelectedAccountTokens } from '@core/token/stores'
import { SendFlowParameters, SendFlowType, sendFlowParameters, updateSendFlowParameters } from '@core/wallet'
import { TokenAmountInput, TokenAvailableBalanceTile } from '@ui'
Expand Down Expand Up @@ -35,7 +35,7 @@
}
const available = token.id === BASE_TOKEN_ID ? token.balance.available - gasFee : token.balance.available
if (token?.metadata?.decimals) {
amount = formatTokenAmountBestMatch(available, token?.metadata, { withUnit: false, round: false })
amount = formatTokenAmount(available, token?.metadata, { withUnit: false, round: false })
} else {
amount = available.toString() ?? '0'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { localize } from '@core/i18n'
import { NetworkId } from '@core/network'
import { getBaseToken } from '@core/profile/actions'
import { formatTokenAmountBestMatch } from '@core/token'
import { formatTokenAmount } from '@core/token'
import { NetworkLabel } from '@ui'
import { Table } from '@bloomwalletio/ui'
Expand All @@ -24,11 +24,11 @@
},
{
key: localize('general.estimatedFee'),
value: estimatedGasFee ? formatTokenAmountBestMatch(estimatedGasFee, getBaseToken()) : undefined,
value: estimatedGasFee ? formatTokenAmount(estimatedGasFee, getBaseToken()) : undefined,
},
{
key: localize('general.maxFees'),
value: maxGasFee ? formatTokenAmountBestMatch(maxGasFee, getBaseToken()) : undefined,
value: maxGasFee ? formatTokenAmount(maxGasFee, getBaseToken()) : undefined,
},
]}
/>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Table, TableRow } from '@bloomwalletio/ui'
import { localize } from '@core/i18n'
import { getBaseToken } from '@core/profile/actions'
import { formatTokenAmountBestMatch } from '@core/token'
import { formatTokenAmount } from '@core/token'
import { TimePeriod } from '@core/utils'
import { NetworkLabel } from '@ui'
import { NetworkId } from '@core/network'
Expand Down Expand Up @@ -35,7 +35,7 @@
},
{
key: localize('general.transactionFee'),
value: transactionFee ? formatTokenAmountBestMatch(transactionFee, getBaseToken()) : undefined,
value: transactionFee ? formatTokenAmount(transactionFee, getBaseToken()) : undefined,
tooltip: localize(localeKey + 'transactionFee'),
},
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Popover, Text, Toggle } from '@bloomwalletio/ui'
import { localize } from '@core/i18n'
import { getBaseToken } from '@core/profile/actions'
import { formatTokenAmountBestMatch } from '@core/token'
import { formatTokenAmount } from '@core/token'
import { fade } from 'svelte/transition'
export let storageDeposit: bigint
Expand All @@ -21,9 +21,7 @@
<button class="flex items-center justify-center {disabled ? 'cursor-default' : 'cursor-pointer'}" {disabled}>
<div class="flex flex-row items-center">
<Text textColor={disabled ? 'secondary' : 'brand'} type="base" fontWeight="medium">
{giftStorageDeposit
? localize('general.gifted')
: formatTokenAmountBestMatch(storageDeposit, getBaseToken())}
{giftStorageDeposit ? localize('general.gifted') : formatTokenAmount(storageDeposit, getBaseToken())}
</Text>
</div>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { checkActiveProfileAuth } from '@core/profile/actions'
import { activeProfile } from '@core/profile/stores'
import { DashboardRoute, dashboardRouter } from '@core/router'
import { formatTokenAmountBestMatch } from '@core/token'
import { formatTokenAmount } from '@core/token'
import { truncateString } from '@core/utils'
import { toggleDashboardDrawer } from '@desktop/auxiliary/drawer'
import { NetworkAvatar, NetworkStatusIndicator, NftAvatar, TokenAvatar } from '@ui'
Expand All @@ -28,10 +28,7 @@
$: health = network.health
$: tokens = $selectedAccountTokens?.[network.id]
$: nfts = $ownedNfts.filter((nft) => nft.networkId === network.id && !(nft.hidden || nft.isScam))
$: tokenBalance = formatTokenAmountBestMatch(
tokens?.baseCoin?.balance.total ?? BigInt(0),
tokens?.baseCoin?.metadata
)
$: tokenBalance = formatTokenAmount(tokens?.baseCoin?.balance.total ?? BigInt(0), tokens?.baseCoin?.metadata)
$: fiatBalance = tokens
? formatCurrency(getFiatValueFromTokenAmount(BigInt(tokens?.baseCoin?.balance.total ?? 0), tokens.baseCoin))
: ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Activity } from '@core/activity'
import { formatCurrency } from '@core/i18n'
import { getFiatValueFromTokenAmount } from '@core/market/actions'
import { formatTokenAmountBestMatch } from '@core/token'
import { formatTokenAmount } from '@core/token'
import { Text } from '@bloomwalletio/ui'
import { selectedAccountTokens } from '@core/token/stores'
import { getBaseToken } from '@core/profile/actions'
Expand All @@ -11,7 +11,7 @@
function getFormattedFee(_activity: Activity): string {
if (_activity.transactionFee) {
const amount = formatTokenAmountBestMatch(_activity.transactionFee, getBaseToken(), { decimals: 3 })
const amount = formatTokenAmount(_activity.transactionFee, getBaseToken(), { decimals: 3 })
return '- ' + amount
} else {
return '-'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { formatCurrency } from '@core/i18n'
import { getFiatValueFromTokenAmount, getMarketPriceForToken } from '@core/market/actions'
import { SupportedStardustNetworkId, TokenSupply, getActiveNetworkId } from '@core/network'
import { BASE_TOKEN_ID, ITokenWithBalance, formatTokenAmountBestMatch } from '@core/token'
import { BASE_TOKEN_ID, ITokenWithBalance, formatTokenAmount } from '@core/token'
import { truncateString } from '@core/utils'
import { PopupId, openPopup } from '@desktop/auxiliary/popup'
import { TokenAvatar, NetworkAvatar, NetworkTypePill } from '@ui'
Expand Down Expand Up @@ -84,15 +84,15 @@
</div>
<div class="flex flex-col items-end text-end">
<Text>
{token.metadata ? formatTokenAmountBestMatch(token.balance.available, token.metadata) : '-'}
{token.metadata ? formatTokenAmount(token.balance.available, token.metadata) : '-'}
</Text>
<Text textColor="secondary">
{getFormattedMarketPriceForTokenAvailable(token)}
</Text>
</div>
<div class="flex flex-col items-end text-end">
<Text>
{token.metadata ? formatTokenAmountBestMatch(token.balance.total, token.metadata) : '-'}
{token.metadata ? formatTokenAmount(token.balance.total, token.metadata) : '-'}
</Text>
<Text textColor="secondary">
{getFormattedMarketPriceForTokenTotal(token)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import { ProfileType } from '@core/profile'
import { RecoverAccountsPayload, createAccount, recoverAccounts } from '@core/profile-manager'
import { DEFAULT_ACCOUNT_RECOVERY_CONFIGURATION } from '@core/profile/constants'
import { formatTokenAmountBestMatch } from '@core/token'
import { formatTokenAmount } from '@core/token'
import { OnboardingLayout } from '@views/components'
import { onDestroy, onMount } from 'svelte'
import { restoreProfileRouter } from '../restore-profile-router'
Expand Down Expand Up @@ -122,7 +122,7 @@
const balance = await account.getBalance()
const baseToken = network?.baseToken
const baseCoinBalance = balance?.baseCoin?.total ?? BigInt(0)
const total = formatTokenAmountBestMatch(baseCoinBalance, baseToken)
const total = formatTokenAmount(baseCoinBalance, baseToken)
return { alias, total }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Table } from '@bloomwalletio/ui'
import { getFormattedTimeStamp, localize } from '@core/i18n'
import { NetworkId, getNetwork } from '@core/network'
import { formatTokenAmountBestMatch } from '@core/token'
import { formatTokenAmount } from '@core/token'
import { NetworkLabel } from '@ui'
export let time: Date
Expand All @@ -17,7 +17,7 @@
$: formattedTransactionFee = formatAmount(transactionFee)
function formatAmount(amount: bigint | undefined): string | undefined {
return amount ? formatTokenAmountBestMatch(amount, getNetwork(sourceNetworkId)?.baseToken) : undefined
return amount ? formatTokenAmount(amount, getNetwork(sourceNetworkId)?.baseToken) : undefined
}
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
}
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
},
]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions packages/shared/src/components/inputs/TokenAmountInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import {
ITokenWithBalance,
convertToRawAmount,
formatTokenAmountBestMatch,
formatTokenAmount,
getMaxDecimalsFromTokenMetadata,
validateTokenAmount,
} from '@core/token'
Expand All @@ -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'
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { localize, parseCurrency } from '@core/i18n'
import { ITokenWithBalance, convertToRawAmount, formatTokenAmountBestMatch } from '@core/token'
import { ITokenWithBalance, convertToRawAmount, formatTokenAmount } from '@core/token'
import { getMaxDecimalsFromTokenMetadata } from '@core/token/utils'
import { AmountInput, SliderInput, TokenLabel } from '@ui'
import { Error as ErrorComponent, Text } from '@bloomwalletio/ui'
Expand All @@ -22,7 +22,7 @@
function getTokenAmount(rawAmount: bigint): string | undefined {
return token?.metadata
? formatTokenAmountBestMatch(rawAmount, token?.metadata, { withUnit: false, round: false })
? formatTokenAmount(rawAmount, token?.metadata, { withUnit: false, round: false })
: undefined
}
Expand Down Expand Up @@ -76,9 +76,9 @@
<div class="flex flex-col mt-5">
<SliderInput bind:value={rawAmount} max={availableBalance} {disabled} />
<div class="flex flex-row justify-between">
<Text textColor="secondary">{formatTokenAmountBestMatch(BigInt(0), token?.metadata)}</Text>
<Text textColor="secondary">{formatTokenAmount(BigInt(0), token?.metadata)}</Text>
<Text textColor="secondary" type="sm">
{formatTokenAmountBestMatch(availableBalance, token?.metadata)}
{formatTokenAmount(availableBalance, token?.metadata)}
</Text>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Icon, IconName, Spinner, Text, Tile } from '@bloomwalletio/ui'
import { IShimmerClaimingAccount, ShimmerClaimingAccountState } from '@contexts/onboarding'
import { localize } from '@core/i18n'
import { IBaseToken, formatTokenAmountBestMatch } from '@core/token'
import { IBaseToken, formatTokenAmount } from '@core/token'
export let shimmerClaimingAccount: IShimmerClaimingAccount
export let baseToken: IBaseToken | undefined
Expand All @@ -24,7 +24,7 @@
</div>
<div class="flex flex-col justify-end items-end">
<Text type="body1" align="right">
{formatTokenAmountBestMatch(total, baseToken)}
{formatTokenAmount(total, baseToken)}
</Text>
{#if shimmerClaimingAccount?.state === ShimmerClaimingAccountState.Claiming}
<div class="flex justify-end items-center gap-1">
Expand Down
Loading

0 comments on commit c6b90fb

Please sign in to comment.