From 5f1f345a5d7f428c939a6ab3cbf9d5ac56cb58ed Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 30 Mar 2018 10:59:39 -0700 Subject: network - use providerType for localhost --- ui/app/actions.js | 5 +++-- ui/app/components/dropdowns/network-dropdown.js | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'ui/app') diff --git a/ui/app/actions.js b/ui/app/actions.js index 58240054d..ad4270cef 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -1300,7 +1300,7 @@ function retryTransaction (txId) { function setProviderType (type) { return (dispatch) => { - log.debug(`background.setProviderType`) + log.debug(`background.setProviderType`, type) background.setProviderType(type, (err, result) => { if (err) { log.error(err) @@ -1321,13 +1321,14 @@ function updateProviderType (type) { } function setRpcTarget (newRpc) { - log.debug(`background.setRpcTarget: ${newRpc}`) return (dispatch) => { + log.debug(`background.setRpcTarget: ${newRpc}`) background.setCustomRpc(newRpc, (err, result) => { if (err) { log.error(err) return dispatch(self.displayWarning('Had a problem changing networks!')) } + dispatch(actions.setSelectedToken()) }) } } diff --git a/ui/app/components/dropdowns/network-dropdown.js b/ui/app/components/dropdowns/network-dropdown.js index 94e5d967b..9e47f38ef 100644 --- a/ui/app/components/dropdowns/network-dropdown.js +++ b/ui/app/components/dropdowns/network-dropdown.js @@ -203,18 +203,18 @@ NetworkDropdown.prototype.render = function () { { key: 'default', closeMenu: () => this.props.hideNetworkDropdown(), - onClick: () => props.setRpcTarget('http://localhost:8545'), + onClick: () => props.setProviderType('localhost'), style: dropdownMenuItemStyle, }, [ - activeNetwork === 'http://localhost:8545' ? h('i.fa.fa-check') : h('.network-check__transparent', '✓'), + providerType === 'localhost' ? h('i.fa.fa-check') : h('.network-check__transparent', '✓'), h(NetworkDropdownIcon, { - isSelected: activeNetwork === 'http://localhost:8545', + isSelected: providerType === 'localhost', innerBorder: '1px solid #9b9b9b', }), h('span.network-name-item', { style: { - color: activeNetwork === 'http://localhost:8545' ? '#ffffff' : '#9b9b9b', + color: providerType === 'localhost' ? '#ffffff' : '#9b9b9b', }, }, this.context.t('localhost')), ] -- cgit v1.2.3 From 9f7b63bb6a03d79a00a8e47b7b8866bbba7bb810 Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 30 Mar 2018 21:45:49 -0700 Subject: identicon - set blockies height and width to identicon diameter --- ui/app/components/identicon.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'ui/app') diff --git a/ui/app/components/identicon.js b/ui/app/components/identicon.js index 7cc5a4de0..dce9b0449 100644 --- a/ui/app/components/identicon.js +++ b/ui/app/components/identicon.js @@ -105,9 +105,8 @@ IdenticonComponent.prototype.componentDidUpdate = function () { function _generateBlockie (container, address, diameter) { const img = new Image() img.src = toDataUrl(address) - const dia = !diameter || diameter < 50 ? 50 : diameter - img.height = dia * 1.25 - img.width = dia * 1.25 + img.height = diameter + img.width = diameter container.appendChild(img) } -- cgit v1.2.3 From 1dc3c51b5445996e9111cabe863fb0eef65dcfc5 Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 2 Apr 2018 16:26:19 -0230 Subject: UpdateSendErrors only called when balance defined, recalled if balance updates. --- ui/app/components/pending-tx/confirm-send-ether.js | 37 ++++++++++++++++----- ui/app/components/pending-tx/confirm-send-token.js | 38 +++++++++++++++++----- 2 files changed, 59 insertions(+), 16 deletions(-) (limited to 'ui/app') diff --git a/ui/app/components/pending-tx/confirm-send-ether.js b/ui/app/components/pending-tx/confirm-send-ether.js index 2474516d4..eae70b279 100644 --- a/ui/app/components/pending-tx/confirm-send-ether.js +++ b/ui/app/components/pending-tx/confirm-send-ether.js @@ -109,16 +109,37 @@ function ConfirmSendEther () { this.onSubmit = this.onSubmit.bind(this) } -ConfirmSendEther.prototype.componentWillMount = function () { - const { updateSendErrors } = this.props +ConfirmSendEther.prototype.updateComponentSendErrors = function (prevProps) { + const { + balance: oldBalance, + conversionRate: oldConversionRate, + } = prevProps + const { + updateSendErrors, + balance, + conversionRate, + } = this.props const txMeta = this.gatherTxMeta() - const balanceIsSufficient = this.isBalanceSufficient(txMeta) - updateSendErrors({ - insufficientFunds: balanceIsSufficient - ? false - : this.context.t('insufficientFunds'), - }) + const shouldUpdateBalanceSendErrors = balance && [ + balance !== oldBalance, + conversionRate !== oldConversionRate, + ].some(x => Boolean(x)) + + if (shouldUpdateBalanceSendErrors) { + const balanceIsSufficient = this.isBalanceSufficient(txMeta) + updateSendErrors({ + insufficientFunds: balanceIsSufficient ? false : this.context.t('insufficientFunds'), + }) + } +} + +ConfirmSendEther.prototype.componentWillMount = function () { + this.updateComponentSendErrors({}) +} + +ConfirmSendEther.prototype.componentDidUpdate = function (prevProps) { + this.updateComponentSendErrors(prevProps) } ConfirmSendEther.prototype.getAmount = function () { diff --git a/ui/app/components/pending-tx/confirm-send-token.js b/ui/app/components/pending-tx/confirm-send-token.js index dd9fdc23f..814386c5c 100644 --- a/ui/app/components/pending-tx/confirm-send-token.js +++ b/ui/app/components/pending-tx/confirm-send-token.js @@ -147,21 +147,43 @@ function ConfirmSendToken () { this.onSubmit = this.onSubmit.bind(this) } -ConfirmSendToken.prototype.componentWillMount = function () { - const { tokenContract, selectedAddress, updateSendErrors} = this.props +ConfirmSendToken.prototype.updateComponentSendErrors = function (prevProps) { + const { + balance: oldBalance, + conversionRate: oldConversionRate, + } = prevProps + const { + updateSendErrors, + balance, + conversionRate, + } = this.props const txMeta = this.gatherTxMeta() - const balanceIsSufficient = this.isBalanceSufficient(txMeta) + + const shouldUpdateBalanceSendErrors = balance && [ + balance !== oldBalance, + conversionRate !== oldConversionRate, + ].some(x => Boolean(x)) + + if (shouldUpdateBalanceSendErrors) { + const balanceIsSufficient = this.isBalanceSufficient(txMeta) + updateSendErrors({ + insufficientFunds: balanceIsSufficient ? false : this.context.t('insufficientFunds'), + }) + } +} + +ConfirmSendToken.prototype.componentWillMount = function () { + const { tokenContract, selectedAddress } = this.props tokenContract && tokenContract .balanceOf(selectedAddress) .then(usersToken => { }) this.props.updateTokenExchangeRate() + this.updateComponentSendErrors({}) +} - updateSendErrors({ - insufficientFunds: balanceIsSufficient - ? false - : this.context.t('insufficientFunds'), - }) +ConfirmSendToken.prototype.componentDidUpdate = function (prevProps) { + this.updateComponentSendErrors(prevProps) } ConfirmSendToken.prototype.getAmount = function () { -- cgit v1.2.3 From 7ccf6163fd4dda52d4c75f57cb36d1f4b05b50ea Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 2 Apr 2018 16:29:35 -0230 Subject: Adds simulation failure error messages to confirm screen. --- ui/app/components/pending-tx/confirm-send-ether.js | 15 +++++++++++++++ ui/app/components/pending-tx/confirm-send-token.js | 15 +++++++++++++++ ui/app/css/itcss/components/confirm.scss | 11 +++++++++++ 3 files changed, 41 insertions(+) (limited to 'ui/app') diff --git a/ui/app/components/pending-tx/confirm-send-ether.js b/ui/app/components/pending-tx/confirm-send-ether.js index eae70b279..d007e6661 100644 --- a/ui/app/components/pending-tx/confirm-send-ether.js +++ b/ui/app/components/pending-tx/confirm-send-ether.js @@ -118,6 +118,11 @@ ConfirmSendEther.prototype.updateComponentSendErrors = function (prevProps) { updateSendErrors, balance, conversionRate, + send: { + errors: { + simulationFails, + }, + }, } = this.props const txMeta = this.gatherTxMeta() @@ -132,6 +137,14 @@ ConfirmSendEther.prototype.updateComponentSendErrors = function (prevProps) { insufficientFunds: balanceIsSufficient ? false : this.context.t('insufficientFunds'), }) } + + const shouldUpdateSimulationSendError = Boolean(txMeta.simulationFails) !== Boolean(simulationFails) + + if (shouldUpdateSimulationSendError) { + updateSendErrors({ + simulationFails: !txMeta.simulationFails ? false : this.context.t('transactionError'), + }) + } } ConfirmSendEther.prototype.componentWillMount = function () { @@ -478,8 +491,10 @@ ConfirmSendEther.prototype.render = function () { ]), h('form#pending-tx-form', { + className: 'confirm-screen-form', onSubmit: this.onSubmit, }, [ + this.renderErrorMessage('simulationFails'), h('.page-container__footer', [ // Cancel Button h('button.btn-cancel.page-container__footer-button.allcaps', { diff --git a/ui/app/components/pending-tx/confirm-send-token.js b/ui/app/components/pending-tx/confirm-send-token.js index 814386c5c..19e591fd6 100644 --- a/ui/app/components/pending-tx/confirm-send-token.js +++ b/ui/app/components/pending-tx/confirm-send-token.js @@ -156,6 +156,11 @@ ConfirmSendToken.prototype.updateComponentSendErrors = function (prevProps) { updateSendErrors, balance, conversionRate, + send: { + errors: { + simulationFails, + }, + }, } = this.props const txMeta = this.gatherTxMeta() @@ -170,6 +175,14 @@ ConfirmSendToken.prototype.updateComponentSendErrors = function (prevProps) { insufficientFunds: balanceIsSufficient ? false : this.context.t('insufficientFunds'), }) } + + const shouldUpdateSimulationSendError = Boolean(txMeta.simulationFails) !== Boolean(simulationFails) + + if (shouldUpdateSimulationSendError) { + updateSendErrors({ + simulationFails: !txMeta.simulationFails ? false : this.context.t('transactionError'), + }) + } } ConfirmSendToken.prototype.componentWillMount = function () { @@ -489,8 +502,10 @@ ConfirmSendToken.prototype.render = function () { ]), h('form#pending-tx-form', { + className: 'confirm-screen-form', onSubmit: this.onSubmit, }, [ + this.renderErrorMessage('simulationFails'), h('.page-container__footer', [ // Cancel Button h('button.btn-cancel.page-container__footer-button.allcaps', { diff --git a/ui/app/css/itcss/components/confirm.scss b/ui/app/css/itcss/components/confirm.scss index 85ff14e6e..47762e8de 100644 --- a/ui/app/css/itcss/components/confirm.scss +++ b/ui/app/css/itcss/components/confirm.scss @@ -312,6 +312,17 @@ section .confirm-screen-account-number, } } +.confirm-screen-form { + position: relative; + + .confirm-screen-error { + right: 0; + width: 100%; + margin-top: 7px; + text-align: center; + } +} + .confirm-screen-confirm-button { height: 50px; border-radius: 4px; -- cgit v1.2.3 From d166cb2b1b0d8313c2b645b620d5270d9cf93b2d Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 2 Apr 2018 16:38:51 -0230 Subject: Ensure txParams are prefixed with 0x when sending. --- ui/app/send-v2.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'ui/app') diff --git a/ui/app/send-v2.js b/ui/app/send-v2.js index bcc5cb03d..0f2997fb2 100644 --- a/ui/app/send-v2.js +++ b/ui/app/send-v2.js @@ -635,6 +635,10 @@ SendTransactionScreen.prototype.onSubmit = function (event) { txParams.to = to } + Object.keys(txParams).forEach(key => { + txParams[key] = ethUtil.addHexPrefix(txParams[key]) + }) + selectedToken ? signTokenTx(selectedToken.address, to, amount, txParams) : signTx(txParams) -- cgit v1.2.3