From 998128d4dfd246ecf7bc206536f6143da4c97bbd Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Sun, 7 May 2017 15:20:56 -0700 Subject: allow copy(logState()) to copy to clipboard --- ui/app/reducers.js | 1 + 1 file changed, 1 insertion(+) (limited to 'ui/app') diff --git a/ui/app/reducers.js b/ui/app/reducers.js index c656af849..11efca529 100644 --- a/ui/app/reducers.js +++ b/ui/app/reducers.js @@ -44,6 +44,7 @@ function rootReducer (state, action) { window.logState = function () { var stateString = JSON.stringify(window.METAMASK_CACHED_LOG_STATE, removeSeedWords, 2) console.log(stateString) + return stateString } function removeSeedWords (key, value) { -- cgit v1.2.3 From f17c6b4eef8defe55e316ee782b499072e1e795a Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Sun, 7 May 2017 16:44:43 -0700 Subject: Fix ens iterated element without key error --- ui/app/components/ens-input.js | 1 + 1 file changed, 1 insertion(+) (limited to 'ui/app') diff --git a/ui/app/components/ens-input.js b/ui/app/components/ens-input.js index f1cf49998..001c227c4 100644 --- a/ui/app/components/ens-input.js +++ b/ui/app/components/ens-input.js @@ -63,6 +63,7 @@ EnsInput.prototype.render = function () { return h('option', { value: identity.address, label: identity.name, + key: identity.address, }) }), ]), -- cgit v1.2.3 From 80d8a4e73ef2d55dd9024f6e4f8cf94f263703cc Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Sun, 7 May 2017 16:51:57 -0700 Subject: 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 --- ui/app/components/pending-tx.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'ui/app') 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) }, -- cgit v1.2.3 From c7b2f2f2e986981496168dbf57cee787882ffd59 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 8 May 2017 13:34:01 -0700 Subject: Cleanup --- ui/app/components/pending-tx.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ui/app') diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js index c381066a9..71d4d767a 100644 --- a/ui/app/components/pending-tx.js +++ b/ui/app/components/pending-tx.js @@ -16,7 +16,7 @@ const nameForAddress = require('../../lib/contract-namer') const HexInput = require('./hex-as-decimal-input') const MIN_GAS_PRICE_GWEI_BN = new BN(2) -const GWEI_FACTOR = new BN(Math.pow(10, 9)) +const GWEI_FACTOR = new BN(1e9) const MIN_GAS_PRICE_BN = MIN_GAS_PRICE_GWEI_BN.mul(GWEI_FACTOR) const MIN_GAS_LIMIT_BN = new BN(21000) @@ -54,7 +54,7 @@ PendingTx.prototype.render = function () { // 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 gasPriceGweiBn = gasPriceBn.div(GWEI_FACTOR) const txFeeBn = gasBn.mul(gasPriceBn) const valueBn = hexToBn(txParams.value) -- cgit v1.2.3