diff --git a/packages/desktop/views/dashboard/send-flow/views/SelectTokenView.svelte b/packages/desktop/views/dashboard/send-flow/views/SelectTokenView.svelte index bbbc14b81c..858029629d 100644 --- a/packages/desktop/views/dashboard/send-flow/views/SelectTokenView.svelte +++ b/packages/desktop/views/dashboard/send-flow/views/SelectTokenView.svelte @@ -31,22 +31,21 @@ $: $selectedAccountTokens, searchValue, selectedTab, setFilteredTokenList() - let tokenError: string = '' + let tokenError = '' $: selectedToken, $sendFlowParameters, void setTokenError() async function setTokenError(): Promise { + let hasEnoughFunds = false if (selectedToken && isEvmNetwork(selectedToken.networkId)) { - const hasEnoughFunds = await canAccountMakeEvmTransaction( + hasEnoughFunds = await canAccountMakeEvmTransaction( $selectedAccountIndex, selectedToken.networkId, $sendFlowParameters?.type ) - tokenError = hasEnoughFunds ? '' : localize('error.send.insufficientFundsTransaction') } else if (selectedToken && isStardustNetwork(selectedToken.networkId)) { - const hasEnoughFunds = canAccountMakeStardustTransaction($selectedAccountIndex, $sendFlowParameters?.type) - tokenError = hasEnoughFunds ? '' : localize('error.send.insufficientFundsTransaction') - } else { - tokenError = '' + hasEnoughFunds = canAccountMakeStardustTransaction($selectedAccountIndex, $sendFlowParameters?.type) } + + tokenError = hasEnoughFunds ? '' : localize('error.send.insufficientFundsTransaction') } const tabs = [ diff --git a/packages/shared/src/lib/core/network/utils/canAccountMakeStardustTransaction.ts b/packages/shared/src/lib/core/network/utils/canAccountMakeStardustTransaction.ts index 111768a202..2f9f87d92b 100644 --- a/packages/shared/src/lib/core/network/utils/canAccountMakeStardustTransaction.ts +++ b/packages/shared/src/lib/core/network/utils/canAccountMakeStardustTransaction.ts @@ -5,7 +5,7 @@ import { SendFlowType } from '@core/wallet/enums' export function canAccountMakeStardustTransaction( accountIndex: number, sendFlowType: SendFlowType | undefined -): boolean | undefined { +): boolean { switch (sendFlowType) { case SendFlowType.BaseCoinTransfer: default: { @@ -14,7 +14,7 @@ export function canAccountMakeStardustTransaction( const baseTokenBalance = account?.balances.baseCoin return BigInt(baseTokenBalance?.available ?? 0) > BigInt(0) } else { - return undefined + return false } } }