From 35ca7e83bdffe4dbf9efbcd161e9f80e5530c86a Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 24 Oct 2017 15:08:22 -0700 Subject: Reduce minimum gas price to 100 MWEI Also now representing gas price in MWEI, because our current bn inputs actually aren't tolerant of minimums less than 1 unit. --- ui/app/components/pending-tx.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'ui/app/components') diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js index c3350fcc1..6a657d81e 100644 --- a/ui/app/components/pending-tx.js +++ b/ui/app/components/pending-tx.js @@ -15,9 +15,9 @@ const addressSummary = util.addressSummary const nameForAddress = require('../../lib/contract-namer') const BNInput = require('./bn-as-decimal-input') -const MIN_GAS_PRICE_GWEI_BN = new BN(1) -const GWEI_FACTOR = new BN(1e9) -const MIN_GAS_PRICE_BN = MIN_GAS_PRICE_GWEI_BN.mul(GWEI_FACTOR) +const MIN_GAS_PRICE_MWEI_BN = new BN('100') +const MWEI_FACTOR = new BN(1e6) +const MIN_GAS_PRICE_BN = MIN_GAS_PRICE_MWEI_BN.mul(MWEI_FACTOR) const MIN_GAS_LIMIT_BN = new BN(21000) module.exports = PendingTx @@ -197,10 +197,10 @@ PendingTx.prototype.render = function () { h(BNInput, { name: 'Gas Price', value: gasPriceBn, - precision: 9, - scale: 9, - suffix: 'GWEI', - min: MIN_GAS_PRICE_GWEI_BN.toString(10), + precision: 6, + scale: 6, + suffix: 'MWEI', + min: MIN_GAS_PRICE_MWEI_BN.toString(10), style: { position: 'relative', top: '5px', -- cgit v1.2.3 From 98d8275743344826e81ee59ba7435ca75b43f2cd Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Tue, 24 Oct 2017 16:43:03 -0700 Subject: Fix for gas price to be lowered. --- ui/app/components/bn-as-decimal-input.js | 14 ++++++++------ ui/app/components/pending-tx.js | 10 +++++----- 2 files changed, 13 insertions(+), 11 deletions(-) (limited to 'ui/app/components') diff --git a/ui/app/components/bn-as-decimal-input.js b/ui/app/components/bn-as-decimal-input.js index d84834d06..db5af1f46 100644 --- a/ui/app/components/bn-as-decimal-input.js +++ b/ui/app/components/bn-as-decimal-input.js @@ -31,6 +31,8 @@ BnAsDecimalInput.prototype.render = function () { const suffix = props.suffix const style = props.style const valueString = value.toString(10) + const newMin = min && this.downsize(min.toString(10), scale) + const newMax = max && this.downsize(max.toString(10), scale) const newValue = this.downsize(valueString, scale) return ( @@ -47,8 +49,8 @@ BnAsDecimalInput.prototype.render = function () { type: 'number', step: 'any', required: true, - min, - max, + min: newMin, + max: newMax, style: extend({ display: 'block', textAlign: 'right', @@ -128,15 +130,15 @@ BnAsDecimalInput.prototype.updateValidity = function (event) { } BnAsDecimalInput.prototype.constructWarning = function () { - const { name, min, max } = this.props + const { name, min, max, scale } = this.props let message = name ? name + ' ' : '' if (min && max) { - message += `must be greater than or equal to ${min} and less than or equal to ${max}.` + message += `must be greater than or equal to ${this.downsize(min.toString(10), scale)} and less than or equal to ${this.downsize(max.toString(10), scale)}.` } else if (min) { - message += `must be greater than or equal to ${min}.` + message += `must be greater than or equal to ${this.downsize(min.toString(10), scale)}.` } else if (max) { - message += `must be less than or equal to ${max}.` + message += `must be less than or equal to ${this.downsize(max.toString(10), scale)}.` } else { message += 'Invalid input.' } diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js index c3350fcc1..431a5a0cb 100644 --- a/ui/app/components/pending-tx.js +++ b/ui/app/components/pending-tx.js @@ -15,9 +15,9 @@ const addressSummary = util.addressSummary const nameForAddress = require('../../lib/contract-namer') const BNInput = require('./bn-as-decimal-input') -const MIN_GAS_PRICE_GWEI_BN = new BN(1) -const GWEI_FACTOR = new BN(1e9) -const MIN_GAS_PRICE_BN = MIN_GAS_PRICE_GWEI_BN.mul(GWEI_FACTOR) +const MIN_GAS_PRICE_MWEI_BN = new BN(100) +const MWEI_FACTOR = new BN(1e6) +const MIN_GAS_PRICE_BN = MIN_GAS_PRICE_MWEI_BN.mul(MWEI_FACTOR) const MIN_GAS_LIMIT_BN = new BN(21000) module.exports = PendingTx @@ -57,7 +57,7 @@ PendingTx.prototype.render = function () { const safeGasLimit = safeGasLimitBN.toString(10) // Gas Price - const gasPrice = txParams.gasPrice || MIN_GAS_PRICE_BN.toString(16) + const gasPrice = txParams.gasPrice || MIN_GAS_PRICE_BN.toString(10) const gasPriceBn = hexToBn(gasPrice) const txFeeBn = gasBn.mul(gasPriceBn) @@ -200,7 +200,7 @@ PendingTx.prototype.render = function () { precision: 9, scale: 9, suffix: 'GWEI', - min: MIN_GAS_PRICE_GWEI_BN.toString(10), + min: MIN_GAS_PRICE_BN.toString(10), style: { position: 'relative', top: '5px', -- cgit v1.2.3 From cb7d07ebae142de1712e36b082398f58fba1659a Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 25 Oct 2017 11:32:38 -0700 Subject: Fix mismatched decimal/hex conversion in pending-tx --- ui/app/components/pending-tx.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui/app/components') diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js index 79323d6eb..c4f215d19 100644 --- a/ui/app/components/pending-tx.js +++ b/ui/app/components/pending-tx.js @@ -57,7 +57,7 @@ PendingTx.prototype.render = function () { const safeGasLimit = safeGasLimitBN.toString(10) // Gas Price - const gasPrice = txParams.gasPrice || MIN_GAS_PRICE_BN.toString(10) + const gasPrice = txParams.gasPrice || MIN_GAS_PRICE_BN.toString(16) const gasPriceBn = hexToBn(gasPrice) const txFeeBn = gasBn.mul(gasPriceBn) -- cgit v1.2.3 From e1b9734cbfdf032a21ce75ac8f480f6ba4668bd2 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 25 Oct 2017 11:35:18 -0700 Subject: Move upsize conversions for input warning at front of fn. --- ui/app/components/bn-as-decimal-input.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'ui/app/components') diff --git a/ui/app/components/bn-as-decimal-input.js b/ui/app/components/bn-as-decimal-input.js index db5af1f46..d3658b202 100644 --- a/ui/app/components/bn-as-decimal-input.js +++ b/ui/app/components/bn-as-decimal-input.js @@ -131,14 +131,16 @@ BnAsDecimalInput.prototype.updateValidity = function (event) { BnAsDecimalInput.prototype.constructWarning = function () { const { name, min, max, scale } = this.props + const newMin = this.downsize(min.toString(10), scale) + const newMax = this.downsize(max.toString(10), scale) let message = name ? name + ' ' : '' if (min && max) { - message += `must be greater than or equal to ${this.downsize(min.toString(10), scale)} and less than or equal to ${this.downsize(max.toString(10), scale)}.` + message += `must be greater than or equal to ${newMin} and less than or equal to ${newMax}.` } else if (min) { - message += `must be greater than or equal to ${this.downsize(min.toString(10), scale)}.` + message += `must be greater than or equal to ${newMin}.` } else if (max) { - message += `must be less than or equal to ${this.downsize(max.toString(10), scale)}.` + message += `must be less than or equal to ${newMax}.` } else { message += 'Invalid input.' } -- cgit v1.2.3 From dee172fb3a3fd0442ff94d1afc0bc0c4c2a81ae5 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 25 Oct 2017 11:36:12 -0700 Subject: Remove unneeded toString conversions. --- ui/app/components/pending-tx.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ui/app/components') diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js index c4f215d19..7d907ca18 100644 --- a/ui/app/components/pending-tx.js +++ b/ui/app/components/pending-tx.js @@ -175,7 +175,7 @@ PendingTx.prototype.render = function () { precision: 0, scale: 0, // The hard lower limit for gas. - min: MIN_GAS_LIMIT_BN.toString(10), + min: MIN_GAS_LIMIT_BN, max: safeGasLimit, suffix: 'UNITS', style: { @@ -200,7 +200,7 @@ PendingTx.prototype.render = function () { precision: 9, scale: 9, suffix: 'GWEI', - min: MIN_GAS_PRICE_BN.toString(10), + min: MIN_GAS_PRICE_BN, style: { position: 'relative', top: '5px', -- cgit v1.2.3 From 7f093f67a7da3e67f077dc3e5a66d765aa6794c0 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 25 Oct 2017 11:38:32 -0700 Subject: Cut out intermediary wei steps. --- ui/app/components/pending-tx.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'ui/app/components') diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js index 7d907ca18..6621e2483 100644 --- a/ui/app/components/pending-tx.js +++ b/ui/app/components/pending-tx.js @@ -15,10 +15,8 @@ const addressSummary = util.addressSummary const nameForAddress = require('../../lib/contract-namer') const BNInput = require('./bn-as-decimal-input') -const MIN_GAS_PRICE_MWEI_BN = new BN('100') -const MWEI_FACTOR = new BN(1e6) -const MIN_GAS_PRICE_BN = MIN_GAS_PRICE_MWEI_BN.mul(MWEI_FACTOR) -const MIN_GAS_LIMIT_BN = new BN(21000) +const MIN_GAS_PRICE_BN = new BN('100000000') +const MIN_GAS_LIMIT_BN = new BN('21000') module.exports = PendingTx inherits(PendingTx, Component) -- cgit v1.2.3 From b3b9e16ec0d2eced756a63caa6d9c2e851c60d0e Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 25 Oct 2017 11:40:07 -0700 Subject: Add clarifying comment about wei conversion. --- ui/app/components/pending-tx.js | 1 + 1 file changed, 1 insertion(+) (limited to 'ui/app/components') diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js index 6621e2483..5b1b367c6 100644 --- a/ui/app/components/pending-tx.js +++ b/ui/app/components/pending-tx.js @@ -15,6 +15,7 @@ const addressSummary = util.addressSummary const nameForAddress = require('../../lib/contract-namer') const BNInput = require('./bn-as-decimal-input') +// corresponds with 0.1 GWEI const MIN_GAS_PRICE_BN = new BN('100000000') const MIN_GAS_LIMIT_BN = new BN('21000') -- cgit v1.2.3 From e7a22fc62bc8063ed89ddbaccd34e6311e2a6017 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 25 Oct 2017 11:47:40 -0700 Subject: Account for non-submitted mins and max --- ui/app/components/bn-as-decimal-input.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ui/app/components') diff --git a/ui/app/components/bn-as-decimal-input.js b/ui/app/components/bn-as-decimal-input.js index d3658b202..000ac22c8 100644 --- a/ui/app/components/bn-as-decimal-input.js +++ b/ui/app/components/bn-as-decimal-input.js @@ -131,8 +131,8 @@ BnAsDecimalInput.prototype.updateValidity = function (event) { BnAsDecimalInput.prototype.constructWarning = function () { const { name, min, max, scale } = this.props - const newMin = this.downsize(min.toString(10), scale) - const newMax = this.downsize(max.toString(10), scale) + const newMin = min && this.downsize(min.toString(10), scale) + const newMax = max && this.downsize(max.toString(10), scale) let message = name ? name + ' ' : '' if (min && max) { -- cgit v1.2.3 From 4903f3e71a0b2a8b4b0d212b61d6efae78f29f8f Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 25 Oct 2017 11:52:16 -0700 Subject: Add labels to clarify warning. --- ui/app/components/bn-as-decimal-input.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ui/app/components') diff --git a/ui/app/components/bn-as-decimal-input.js b/ui/app/components/bn-as-decimal-input.js index 000ac22c8..22e37602e 100644 --- a/ui/app/components/bn-as-decimal-input.js +++ b/ui/app/components/bn-as-decimal-input.js @@ -130,17 +130,17 @@ BnAsDecimalInput.prototype.updateValidity = function (event) { } BnAsDecimalInput.prototype.constructWarning = function () { - const { name, min, max, scale } = this.props + const { name, min, max, scale, suffix } = this.props const newMin = min && this.downsize(min.toString(10), scale) const newMax = max && this.downsize(max.toString(10), scale) let message = name ? name + ' ' : '' if (min && max) { - message += `must be greater than or equal to ${newMin} and less than or equal to ${newMax}.` + message += `must be greater than or equal to ${newMin} ${suffix} and less than or equal to ${newMax} ${suffix}.` } else if (min) { - message += `must be greater than or equal to ${newMin}.` + message += `must be greater than or equal to ${newMin} ${suffix}.` } else if (max) { - message += `must be less than or equal to ${newMax}.` + message += `must be less than or equal to ${newMax} ${suffix}.` } else { message += 'Invalid input.' } -- cgit v1.2.3