aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2018-05-01 00:30:01 +0800
committerDan <danjm.com@gmail.com>2018-05-01 00:30:01 +0800
commit4a8c3194c2a4742d448d9fa9240c56a1e3319601 (patch)
treec4531fee76b374accb71a44296ec475f12c82047 /ui/app/components
parentbc145dc6a64ef5536bcbd263707b4cee071aea3b (diff)
downloadtangerine-wallet-browser-4a8c3194c2a4742d448d9fa9240c56a1e3319601.tar
tangerine-wallet-browser-4a8c3194c2a4742d448d9fa9240c56a1e3319601.tar.gz
tangerine-wallet-browser-4a8c3194c2a4742d448d9fa9240c56a1e3319601.tar.bz2
tangerine-wallet-browser-4a8c3194c2a4742d448d9fa9240c56a1e3319601.tar.lz
tangerine-wallet-browser-4a8c3194c2a4742d448d9fa9240c56a1e3319601.tar.xz
tangerine-wallet-browser-4a8c3194c2a4742d448d9fa9240c56a1e3319601.tar.zst
tangerine-wallet-browser-4a8c3194c2a4742d448d9fa9240c56a1e3319601.zip
Use constants for send screen errors messages.
Diffstat (limited to 'ui/app/components')
-rw-r--r--ui/app/components/send_/send-content/send-to-row/send-to-row.selectors.js2
-rw-r--r--ui/app/components/send_/send-content/send-to-row/send-to-row.utils.js8
-rw-r--r--ui/app/components/send_/send.constants.js17
-rw-r--r--ui/app/components/send_/send.utils.js11
4 files changed, 29 insertions, 9 deletions
diff --git a/ui/app/components/send_/send-content/send-to-row/send-to-row.selectors.js b/ui/app/components/send_/send-content/send-to-row/send-to-row.selectors.js
index c741aad84..8919014be 100644
--- a/ui/app/components/send_/send-content/send-to-row/send-to-row.selectors.js
+++ b/ui/app/components/send_/send-content/send-to-row/send-to-row.selectors.js
@@ -10,5 +10,5 @@ function getToDropdownOpen (state) {
}
function sendToIsInError (state) {
- return Boolean(state.metamask.send.errors.to)
+ return Boolean(state.send.errors.to)
}
diff --git a/ui/app/components/send_/send-content/send-to-row/send-to-row.utils.js b/ui/app/components/send_/send-content/send-to-row/send-to-row.utils.js
index d290bf461..22e2e1f34 100644
--- a/ui/app/components/send_/send-content/send-to-row/send-to-row.utils.js
+++ b/ui/app/components/send_/send-content/send-to-row/send-to-row.utils.js
@@ -1,12 +1,16 @@
+const {
+ REQUIRED_ERROR,
+ INVALID_RECIPIENT_ADDRESS_ERROR,
+} = require('../../send.constants')
const { isValidAddress } = require('../../../../util')
function getToErrorObject (to) {
let toError = null
if (!to) {
- toError = 'required'
+ toError = REQUIRED_ERROR
} else if (!isValidAddress(to)) {
- toError = 'invalidAddressRecipient'
+ toError = INVALID_RECIPIENT_ADDRESS_ERROR
}
return { to: toError }
diff --git a/ui/app/components/send_/send.constants.js b/ui/app/components/send_/send.constants.js
index b3ee0899a..d047ed704 100644
--- a/ui/app/components/send_/send.constants.js
+++ b/ui/app/components/send_/send.constants.js
@@ -22,12 +22,23 @@ const MIN_GAS_TOTAL = multiplyCurrencies(MIN_GAS_LIMIT_HEX, MIN_GAS_PRICE_HEX, {
const TOKEN_TRANSFER_FUNCTION_SIGNATURE = '0xa9059cbb'
+const INSUFFICIENT_FUNDS_ERROR = 'insufficientFunds'
+const INSUFFICIENT_TOKENS_ERROR = 'insufficientTokens'
+const NEGATIVE_ETH_ERROR = 'negativeETH'
+const INVALID_RECIPIENT_ADDRESS_ERROR = 'invalidAddressRecipient'
+const REQUIRED_ERROR = 'required'
+
module.exports = {
+ INSUFFICIENT_FUNDS_ERROR,
+ INSUFFICIENT_TOKENS_ERROR,
+ INVALID_RECIPIENT_ADDRESS_ERROR,
+ MIN_GAS_LIMIT_DEC,
+ MIN_GAS_LIMIT_HEX,
+ MIN_GAS_PRICE_DEC,
MIN_GAS_PRICE_GWEI,
MIN_GAS_PRICE_HEX,
- MIN_GAS_PRICE_DEC,
- MIN_GAS_LIMIT_HEX,
- MIN_GAS_LIMIT_DEC,
MIN_GAS_TOTAL,
+ NEGATIVE_ETH_ERROR,
+ REQUIRED_ERROR,
TOKEN_TRANSFER_FUNCTION_SIGNATURE,
}
diff --git a/ui/app/components/send_/send.utils.js b/ui/app/components/send_/send.utils.js
index 2e17b04a3..e537d5624 100644
--- a/ui/app/components/send_/send.utils.js
+++ b/ui/app/components/send_/send.utils.js
@@ -10,6 +10,11 @@ const {
const {
conversionGreaterThan,
} = require('../../conversion-util')
+const {
+ INSUFFICIENT_FUNDS_ERROR,
+ INSUFFICIENT_TOKENS_ERROR,
+ NEGATIVE_ETH_ERROR,
+} = require('./send.constants')
module.exports = {
calcGasTotal,
@@ -125,11 +130,11 @@ function getAmountErrorObject ({
let amountError = null
if (insufficientFunds) {
- amountError = 'insufficientFunds'
+ amountError = INSUFFICIENT_FUNDS_ERROR
} else if (inSufficientTokens) {
- amountError = 'insufficientTokens'
+ amountError = INSUFFICIENT_TOKENS_ERROR
} else if (amountLessThanZero) {
- amountError = 'negativeETH'
+ amountError = NEGATIVE_ETH_ERROR
}
return { amount: amountError }