aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/send_/send.utils.js
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2018-06-30 01:19:40 +0800
committerDan <danjm.com@gmail.com>2018-07-05 02:39:29 +0800
commit0796fc58e4638df9e448654b199b661cb2a492aa (patch)
tree291e007e368129180cacf0c117fe147de4b5b08b /ui/app/components/send_/send.utils.js
parente467eda4f720fa89141ded2e709566102402479b (diff)
downloadtangerine-wallet-browser-0796fc58e4638df9e448654b199b661cb2a492aa.tar
tangerine-wallet-browser-0796fc58e4638df9e448654b199b661cb2a492aa.tar.gz
tangerine-wallet-browser-0796fc58e4638df9e448654b199b661cb2a492aa.tar.bz2
tangerine-wallet-browser-0796fc58e4638df9e448654b199b661cb2a492aa.tar.lz
tangerine-wallet-browser-0796fc58e4638df9e448654b199b661cb2a492aa.tar.xz
tangerine-wallet-browser-0796fc58e4638df9e448654b199b661cb2a492aa.tar.zst
tangerine-wallet-browser-0796fc58e4638df9e448654b199b661cb2a492aa.zip
Improve send token error ux.
Diffstat (limited to 'ui/app/components/send_/send.utils.js')
-rw-r--r--ui/app/components/send_/send.utils.js33
1 files changed, 31 insertions, 2 deletions
diff --git a/ui/app/components/send_/send.utils.js b/ui/app/components/send_/send.utils.js
index 34275248f..c4537f335 100644
--- a/ui/app/components/send_/send.utils.js
+++ b/ui/app/components/send_/send.utils.js
@@ -30,6 +30,7 @@ module.exports = {
estimateGasPriceFromRecentBlocks,
generateTokenTransferData,
getAmountErrorObject,
+ getGasFeeErrorObject,
getToAddressForGasUpdate,
isBalanceSufficient,
isTokenBalanceSufficient,
@@ -110,9 +111,9 @@ function getAmountErrorObject ({
tokenBalance,
}) {
let insufficientFunds = false
- if (gasTotal && conversionRate) {
+ if (gasTotal && conversionRate && !selectedToken) {
insufficientFunds = !isBalanceSufficient({
- amount: selectedToken ? '0x0' : amount,
+ amount,
amountConversionRate,
balance,
conversionRate,
@@ -149,6 +150,34 @@ function getAmountErrorObject ({
return { amount: amountError }
}
+function getGasFeeErrorObject ({
+ amount,
+ amountConversionRate,
+ balance,
+ conversionRate,
+ gasTotal,
+ primaryCurrency,
+}) {
+ let gasFeeError = null
+
+ if (gasTotal && conversionRate) {
+ const insufficientFunds = !isBalanceSufficient({
+ amount: '0x0',
+ amountConversionRate,
+ balance,
+ conversionRate,
+ gasTotal,
+ primaryCurrency,
+ })
+
+ if (insufficientFunds) {
+ gasFeeError = INSUFFICIENT_FUNDS_ERROR
+ }
+ }
+
+ return { gasFee: gasFeeError }
+}
+
function calcTokenBalance ({ selectedToken, usersToken }) {
const { decimals } = selectedToken || {}
return calcTokenAmount(usersToken.balance.toString(), decimals) + ''