aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorkumavis <kumavis@users.noreply.github.com>2018-10-30 09:47:07 +0800
committerGitHub <noreply@github.com>2018-10-30 09:47:07 +0800
commit310229d22e5e916e8d6e3b1a469b9b196e0f70c2 (patch)
tree518bd3f5fb01c792fe2e44db3aace1c20f22c7e1 /ui
parent1bb4a8428c73c1f1137793b25900db159eec3fa8 (diff)
parent9b42416fc0d92662d1a21759db357e7f439d7a7b (diff)
downloadtangerine-wallet-browser-310229d22e5e916e8d6e3b1a469b9b196e0f70c2.tar
tangerine-wallet-browser-310229d22e5e916e8d6e3b1a469b9b196e0f70c2.tar.gz
tangerine-wallet-browser-310229d22e5e916e8d6e3b1a469b9b196e0f70c2.tar.bz2
tangerine-wallet-browser-310229d22e5e916e8d6e3b1a469b9b196e0f70c2.tar.lz
tangerine-wallet-browser-310229d22e5e916e8d6e3b1a469b9b196e0f70c2.tar.xz
tangerine-wallet-browser-310229d22e5e916e8d6e3b1a469b9b196e0f70c2.tar.zst
tangerine-wallet-browser-310229d22e5e916e8d6e3b1a469b9b196e0f70c2.zip
Merge pull request #5567 from MetaMask/HowardBraham-develop
Feature: Warn when attempting to send tx with data to non-contract
Diffstat (limited to 'ui')
-rw-r--r--ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.component.js2
-rw-r--r--ui/app/components/send/send.utils.js4
-rw-r--r--ui/app/constants/error-keys.js1
-rw-r--r--ui/app/helpers/transactions.util.js4
4 files changed, 8 insertions, 3 deletions
diff --git a/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.component.js b/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.component.js
index c92867afe..7d01aaffb 100644
--- a/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.component.js
+++ b/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.component.js
@@ -136,7 +136,7 @@ export default class ConfirmTransactionBase extends Component {
if (simulationFails) {
return {
valid: true,
- errorKey: TRANSACTION_ERROR_KEY,
+ errorKey: simulationFails.errorKey ? simulationFails.errorKey : TRANSACTION_ERROR_KEY,
}
}
diff --git a/ui/app/components/send/send.utils.js b/ui/app/components/send/send.utils.js
index a18a9e4b3..eb1667c63 100644
--- a/ui/app/components/send/send.utils.js
+++ b/ui/app/components/send/send.utils.js
@@ -215,7 +215,9 @@ 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') {
+ // Geth will return '0x', and ganache-core v2.2.1 will return '0x0'
+ const codeIsEmpty = !code || code === '0x' || code === '0x0'
+ if (codeIsEmpty) {
return SIMPLE_GAS_COST
}
} else if (selectedToken && !to) {
diff --git a/ui/app/constants/error-keys.js b/ui/app/constants/error-keys.js
index f70ed3b19..704064c96 100644
--- a/ui/app/constants/error-keys.js
+++ b/ui/app/constants/error-keys.js
@@ -1,3 +1,4 @@
export const INSUFFICIENT_FUNDS_ERROR_KEY = 'insufficientFunds'
export const GAS_LIMIT_TOO_LOW_ERROR_KEY = 'gasLimitTooLow'
export const TRANSACTION_ERROR_KEY = 'transactionError'
+export const TRANSACTION_NO_CONTRACT_ERROR_KEY = 'transactionErrorNoContract'
diff --git a/ui/app/helpers/transactions.util.js b/ui/app/helpers/transactions.util.js
index 64ec82225..2f4b1d095 100644
--- a/ui/app/helpers/transactions.util.js
+++ b/ui/app/helpers/transactions.util.js
@@ -125,7 +125,9 @@ export function getLatestSubmittedTxWithNonce (transactions = [], nonce = '0x0')
export async function isSmartContractAddress (address) {
const code = await global.eth.getCode(address)
- return code && code !== '0x'
+ // Geth will return '0x', and ganache-core v2.2.1 will return '0x0'
+ const codeIsEmpty = !code || code === '0x' || code === '0x0'
+ return !codeIsEmpty
}
export function sumHexes (...args) {