aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Finlay <flyswatter@users.noreply.github.com>2017-09-19 02:14:26 +0800
committerGitHub <noreply@github.com>2017-09-19 02:14:26 +0800
commit99856189ed463d5ff140b36399313993ffd5541c (patch)
treeaa8fcb04b00811363a4c5bb66e50e2fa062a8f4c
parent693655e2da7cacf5a5326b50bddc37bcece9422e (diff)
parenta22a2586abcca35d2a4bc1a0407aeaacc55f0a27 (diff)
downloadtangerine-wallet-browser-99856189ed463d5ff140b36399313993ffd5541c.tar
tangerine-wallet-browser-99856189ed463d5ff140b36399313993ffd5541c.tar.gz
tangerine-wallet-browser-99856189ed463d5ff140b36399313993ffd5541c.tar.bz2
tangerine-wallet-browser-99856189ed463d5ff140b36399313993ffd5541c.tar.lz
tangerine-wallet-browser-99856189ed463d5ff140b36399313993ffd5541c.tar.xz
tangerine-wallet-browser-99856189ed463d5ff140b36399313993ffd5541c.tar.zst
tangerine-wallet-browser-99856189ed463d5ff140b36399313993ffd5541c.zip
Merge pull request #2093 from MetaMask/max-validation
High GasLimit Validation Warning
-rw-r--r--CHANGELOG.md1
-rw-r--r--ui/app/components/pending-tx.js65
2 files changed, 41 insertions, 25 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1ba214cce..a82c3e149 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@
- Changed state logs to a file download than a clipboard copy.
- Fixed a long standing memory leak associated with filters installed by dapps
- Fix link to support center.
+- Warn users when a dapp proposes a high gas limit (90% of blockGasLimit or higher)
## 3.10.0 2017-9-11
diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js
index 3e53d47f9..c3350fcc1 100644
--- a/ui/app/components/pending-tx.js
+++ b/ui/app/components/pending-tx.js
@@ -52,7 +52,9 @@ PendingTx.prototype.render = function () {
const gas = txParams.gas
const gasBn = hexToBn(gas)
const gasLimit = new BN(parseInt(blockGasLimit))
- const safeGasLimit = this.bnMultiplyByFraction(gasLimit, 19, 20).toString(10)
+ const safeGasLimitBN = this.bnMultiplyByFraction(gasLimit, 19, 20)
+ const saferGasLimitBN = this.bnMultiplyByFraction(gasLimit, 18, 20)
+ const safeGasLimit = safeGasLimitBN.toString(10)
// Gas Price
const gasPrice = txParams.gasPrice || MIN_GAS_PRICE_BN.toString(16)
@@ -66,6 +68,8 @@ PendingTx.prototype.render = function () {
const balanceBn = hexToBn(balance)
const insufficientBalance = balanceBn.lt(maxCost)
+ const dangerousGasLimit = gasBn.gte(saferGasLimitBN)
+ const gasLimitSpecified = txMeta.gasLimitSpecified
const buyDisabled = insufficientBalance || !this.state.valid || !isValidAddress || this.state.submitting
const showRejectAll = props.unconfTxListLength > 1
@@ -263,33 +267,44 @@ PendingTx.prototype.render = function () {
text-transform: uppercase;
}
`),
+ h('.cell.row', {
+ style: {
+ textAlign: 'center',
+ },
+ }, [
+ txMeta.simulationFails ?
+ h('.error', {
+ style: {
+ fontSize: '0.9em',
+ },
+ }, 'Transaction Error. Exception thrown in contract code.')
+ : null,
- txMeta.simulationFails ?
- h('.error', {
- style: {
- marginLeft: 50,
- fontSize: '0.9em',
- },
- }, 'Transaction Error. Exception thrown in contract code.')
- : null,
+ !isValidAddress ?
+ h('.error', {
+ style: {
+ fontSize: '0.9em',
+ },
+ }, 'Recipient address is invalid. Sending this transaction will result in a loss of ETH.')
+ : null,
- !isValidAddress ?
- h('.error', {
- style: {
- marginLeft: 50,
- fontSize: '0.9em',
- },
- }, 'Recipient address is invalid. Sending this transaction will result in a loss of ETH.')
- : null,
+ insufficientBalance ?
+ h('span.error', {
+ style: {
+ fontSize: '0.9em',
+ },
+ }, 'Insufficient balance for transaction')
+ : null,
+
+ (dangerousGasLimit && !gasLimitSpecified) ?
+ h('span.error', {
+ style: {
+ fontSize: '0.9em',
+ },
+ }, 'Gas limit set dangerously high. Approving this transaction is likely to fail.')
+ : null,
+ ]),
- insufficientBalance ?
- h('span.error', {
- style: {
- marginLeft: 50,
- fontSize: '0.9em',
- },
- }, 'Insufficient balance for transaction')
- : null,
// send + cancel
h('.flex-row.flex-space-around.conf-buttons', {