aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-05-08 07:51:57 +0800
committerDan Finlay <dan@danfinlay.com>2017-05-08 07:51:57 +0800
commit80d8a4e73ef2d55dd9024f6e4f8cf94f263703cc (patch)
tree87d953841ac6b0d67833a852a20feb26d05cf2d5
parentf17c6b4eef8defe55e316ee782b499072e1e795a (diff)
downloadtangerine-wallet-browser-80d8a4e73ef2d55dd9024f6e4f8cf94f263703cc.tar
tangerine-wallet-browser-80d8a4e73ef2d55dd9024f6e4f8cf94f263703cc.tar.gz
tangerine-wallet-browser-80d8a4e73ef2d55dd9024f6e4f8cf94f263703cc.tar.bz2
tangerine-wallet-browser-80d8a4e73ef2d55dd9024f6e4f8cf94f263703cc.tar.lz
tangerine-wallet-browser-80d8a4e73ef2d55dd9024f6e4f8cf94f263703cc.tar.xz
tangerine-wallet-browser-80d8a4e73ef2d55dd9024f6e4f8cf94f263703cc.tar.zst
tangerine-wallet-browser-80d8a4e73ef2d55dd9024f6e4f8cf94f263703cc.zip
Input gas in gwei
Also enforces "safe low gas" minimum recommended by this article by eth-gas-station: https://medium.com/@ethgasstation/the-safe-low-gas-price-fb44fdc85b91 Fixes #1381
-rw-r--r--ui/app/components/pending-tx.js21
1 files changed, 14 insertions, 7 deletions
diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js
index 4b28ae099..c381066a9 100644
--- a/ui/app/components/pending-tx.js
+++ b/ui/app/components/pending-tx.js
@@ -15,7 +15,9 @@ const addressSummary = util.addressSummary
const nameForAddress = require('../../lib/contract-namer')
const HexInput = require('./hex-as-decimal-input')
-const MIN_GAS_PRICE_BN = new BN(20000000)
+const MIN_GAS_PRICE_GWEI_BN = new BN(2)
+const GWEI_FACTOR = new BN(Math.pow(10, 9))
+const MIN_GAS_PRICE_BN = MIN_GAS_PRICE_GWEI_BN.mul(GWEI_FACTOR)
const MIN_GAS_LIMIT_BN = new BN(21000)
module.exports = connect(mapStateToProps)(PendingTx)
@@ -39,16 +41,20 @@ PendingTx.prototype.render = function () {
const txMeta = this.gatherTxMeta()
const txParams = txMeta.txParams || {}
+ // Account Details
const address = txParams.from || props.selectedAddress
const identity = props.identities[address] || { address: address }
const account = props.accounts[address]
const balance = account ? account.balance : '0x0'
+ // Gas
const gas = txParams.gas
- const gasPrice = txParams.gasPrice
-
const gasBn = hexToBn(gas)
+
+ // Gas Price
+ const gasPrice = txParams.gasPrice || MIN_GAS_PRICE_BN.toString(16)
const gasPriceBn = hexToBn(gasPrice)
+ const gasPriceGweiBn = gasPriceBn.div(new BN(Math.pow(10, 9)))
const txFeeBn = gasBn.mul(gasPriceBn)
const valueBn = hexToBn(txParams.value)
@@ -187,17 +193,18 @@ PendingTx.prototype.render = function () {
}, [
h(HexInput, {
name: 'Gas Price',
- value: gasPrice,
- suffix: 'WEI',
- min: MIN_GAS_PRICE_BN.toString(10),
+ value: gasPriceGweiBn.toString(16),
+ suffix: 'GWEI',
+ min: MIN_GAS_PRICE_GWEI_BN.toString(10),
style: {
position: 'relative',
top: '5px',
},
onChange: (newHex) => {
log.info(`Gas price changed to: ${newHex}`)
+ const inWei = hexToBn(newHex).mul(GWEI_FACTOR)
const txMeta = this.gatherTxMeta()
- txMeta.txParams.gasPrice = newHex
+ txMeta.txParams.gasPrice = inWei.toString(16)
this.setState({ txData: txMeta })
},
ref: (hexInput) => { this.inputs.push(hexInput) },