mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Use constants for send screen errors messages.
This commit is contained in:
parent
bc145dc6a6
commit
4a8c3194c2
@ -10,5 +10,5 @@ function getToDropdownOpen (state) {
|
||||
}
|
||||
|
||||
function sendToIsInError (state) {
|
||||
return Boolean(state.metamask.send.errors.to)
|
||||
return Boolean(state.send.errors.to)
|
||||
}
|
||||
|
@ -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 }
|
||||
|
@ -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,
|
||||
}
|
||||
|
@ -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 }
|
||||
|
Loading…
Reference in New Issue
Block a user