aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/scripts/controllers/transactions/tx-gas-utils.js11
-rw-r--r--old-ui/app/components/pending-tx.js2
-rw-r--r--ui/app/components/send/send.utils.js2
-rw-r--r--ui/app/helpers/transactions.util.js2
4 files changed, 9 insertions, 8 deletions
diff --git a/app/scripts/controllers/transactions/tx-gas-utils.js b/app/scripts/controllers/transactions/tx-gas-utils.js
index 5ec728085..ac57dfe1d 100644
--- a/app/scripts/controllers/transactions/tx-gas-utils.js
+++ b/app/scripts/controllers/transactions/tx-gas-utils.js
@@ -63,14 +63,15 @@ class TxGasUtil {
const hasRecipient = Boolean(recipient)
if (hasRecipient) {
- let code = await this.query.getCode(recipient)
+ const code = await this.query.getCode(recipient)
// If there's data in the params, but there's no code, it's not a valid contract
- // For no code, Infura will return '0x', and Ganache will return '0x0'
+ // For no code, Infura will return '0x', and ganache-core v2.2.1 will return '0x0'
if (txParams.data && (!code || code === '0x' || code === '0x0')) {
- throw {errorKey: TRANSACTION_NO_CONTRACT_ERROR_KEY}
- }
- else if (!code) {
+ const err = new Error()
+ err.errorKey = TRANSACTION_NO_CONTRACT_ERROR_KEY
+ throw err
+ } else if (!code) {
txParams.gas = SIMPLE_GAS_COST // For a standard ETH send, gas is 21k max
txMeta.simpleSend = true // Prevents buffer addition
return SIMPLE_GAS_COST
diff --git a/old-ui/app/components/pending-tx.js b/old-ui/app/components/pending-tx.js
index 7d8c94699..d8d2334a4 100644
--- a/old-ui/app/components/pending-tx.js
+++ b/old-ui/app/components/pending-tx.js
@@ -489,7 +489,7 @@ PendingTx.prototype.verifyGasParams = function () {
}
PendingTx.prototype._notZeroOrEmptyString = function (obj) {
- return obj !== '' && obj !== '0x0' && obj !== '0x' // The '0x' case might not ever happen, but it seems safest to protect against it
+ return obj !== '' && obj !== '0x0' && obj !== '0x' // '0x' means null
}
PendingTx.prototype.bnMultiplyByFraction = function (targetBN, numerator, denominator) {
diff --git a/ui/app/components/send/send.utils.js b/ui/app/components/send/send.utils.js
index 05ba6b88f..af7b3823f 100644
--- a/ui/app/components/send/send.utils.js
+++ b/ui/app/components/send/send.utils.js
@@ -215,7 +215,7 @@ async function estimateGas ({
// if recipient has no code, gas is 21k max:
if (!selectedToken && !data) {
const code = Boolean(to) && await global.eth.getCode(to)
- if (!code || code === '0x' || code === '0x0') { // Infura will return '0x', and Ganache will return '0x0'
+ if (!code || code === '0x' || code === '0x0') { // Infura will return '0x', and ganache-core v2.2.1 will return '0x0'
return SIMPLE_GAS_COST
}
} else if (selectedToken && !to) {
diff --git a/ui/app/helpers/transactions.util.js b/ui/app/helpers/transactions.util.js
index 0eb7972d6..b2c617384 100644
--- a/ui/app/helpers/transactions.util.js
+++ b/ui/app/helpers/transactions.util.js
@@ -114,7 +114,7 @@ export function getLatestSubmittedTxWithNonce (transactions = [], nonce = '0x0')
export async function isSmartContractAddress (address) {
const code = await global.eth.getCode(address)
- return code && code !== '0x' && code !== '0x0'; // Infura will return '0x', and Ganache will return '0x0'
+ return code && code !== '0x' && code !== '0x0' // Infura will return '0x', and ganache-core v2.2.1 will return '0x0'
}
export function sumHexes (...args) {