Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
Display error when funds are insufficient in advanced tx.
Browse files Browse the repository at this point in the history
  • Loading branch information
conqeror committed Jan 11, 2021
1 parent 1ea86a8 commit a778e0f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/wallets/sendTransaction/SendAdvancedTransaction.tsx
Expand Up @@ -21,6 +21,7 @@ import {PropsWithWalletState, withStatusGuard} from '../../common/wallet-status-
import {getSendTransactionParams} from './ConfirmAdvancedTransaction'
import {asEther, asWei, Wei} from '../../common/units'
import {rendererLog} from '../../common/logger'
import {InlineError} from '../../common/InlineError'

interface SendAdvancedTransactionProps {
onSend: () => void
Expand Down Expand Up @@ -73,7 +74,7 @@ const _SendAdvancedTransaction = ({
totalAmount.isFinite() ? availableAmount.minus(totalAmount) : availableAmount,
)

const disableSend = remainingBalance.isNegative()
const hasInsufficientBalance = remainingBalance.isLessThan(0)

return (
<>
Expand All @@ -91,7 +92,7 @@ const _SendAdvancedTransaction = ({
}
onSend()
},
disabled: disableSend,
disabled: hasInsufficientBalance,
}}
onSetLoading={modalLocker.setLocked}
type="dark"
Expand All @@ -111,6 +112,9 @@ const _SendAdvancedTransaction = ({
rules: [txAmountValidator],
}}
/>
{hasInsufficientBalance && (
<InlineError errorMessage={t(['wallet', 'error', 'insufficientFunds'])} />
)}
<DialogColumns>
<DialogInput
label={t(['wallet', 'label', 'gasLimit'])}
Expand Down

0 comments on commit a778e0f

Please sign in to comment.