From d24a0590d363dbe88d383c8faec8eb28809242f0 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 21 Mar 2018 22:11:47 -0230 Subject: i18n redux solution doesn't require importing t() and passing state to each t() call; t is just available on props. --- ui/app/send-v2.js | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'ui/app/send-v2.js') diff --git a/ui/app/send-v2.js b/ui/app/send-v2.js index 31118378d..49947a11c 100644 --- a/ui/app/send-v2.js +++ b/ui/app/send-v2.js @@ -1,7 +1,6 @@ const { inherits } = require('util') const PersistentForm = require('../lib/persistent-form') const h = require('react-hyperscript') -const t = require('../i18n') const ethAbi = require('ethereumjs-abi') const ethUtil = require('ethereumjs-util') @@ -189,9 +188,9 @@ SendTransactionScreen.prototype.renderHeader = function () { return h('div.page-container__header', [ - h('div.page-container__title', selectedToken ? t('sendTokens') : t('sendETH')), + h('div.page-container__title', selectedToken ? this.props.t('sendTokens') : this.props.t('sendETH')), - h('div.page-container__subtitle', t('onlySendToEtherAddress')), + h('div.page-container__subtitle', this.props.t('onlySendToEtherAddress')), h('div.page-container__header-close', { onClick: () => { @@ -262,11 +261,11 @@ SendTransactionScreen.prototype.handleToChange = function (to) { let toError = null if (!to) { - toError = t('required') + toError = this.props.t('required') } else if (!isValidAddress(to)) { - toError = t('invalidAddressRecipient') + toError = this.props.t('invalidAddressRecipient') } else if (to === from) { - toError = t('fromToSame') + toError = this.props.t('fromToSame') } updateSendTo(to) @@ -282,9 +281,9 @@ SendTransactionScreen.prototype.renderToRow = function () { h('div.send-v2__form-label', [ - t('to'), + this.props.t('to'), - this.renderErrorMessage(t('to')), + this.renderErrorMessage(this.props.t('to')), ]), @@ -382,11 +381,11 @@ SendTransactionScreen.prototype.validateAmount = function (value) { ) if (conversionRate && !sufficientBalance) { - amountError = t('insufficientFunds') + amountError = this.props.t('insufficientFunds') } else if (verifyTokenBalance && !sufficientTokens) { - amountError = t('insufficientTokens') + amountError = this.props.t('insufficientTokens') } else if (amountLessThanZero) { - amountError = t('negativeETH') + amountError = this.props.t('negativeETH') } updateSendErrors({ amount: amountError }) @@ -416,7 +415,7 @@ SendTransactionScreen.prototype.renderAmountRow = function () { setMaxModeTo(true) this.setAmountToMax() }, - }, [ !maxModeOn ? t('max') : '' ]), + }, [ !maxModeOn ? this.props.t('max') : '' ]), ]), h('div.send-v2__form-field', [ @@ -514,11 +513,11 @@ SendTransactionScreen.prototype.renderFooter = function () { clearSend() goHome() }, - }, t('cancel')), + }, this.props.t('cancel')), h('button.btn-clear.page-container__footer-button', { disabled: !noErrors || !gasTotal || missingTokenBalance, onClick: event => this.onSubmit(event), - }, t('next')), + }, this.props.t('next')), ]) } -- cgit From 252d69228245f26f9ff2a2ba22db5b17074c009e Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 27 Mar 2018 03:40:34 -0230 Subject: Prefixes to addresses with 0x before sending. --- ui/app/send-v2.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'ui/app/send-v2.js') diff --git a/ui/app/send-v2.js b/ui/app/send-v2.js index 620da73f8..67a470956 100644 --- a/ui/app/send-v2.js +++ b/ui/app/send-v2.js @@ -597,7 +597,7 @@ SendTransactionScreen.prototype.onSubmit = function (event) { event.preventDefault() const { from: {address: from}, - to, + to: _to, amount, gasLimit: gas, gasPrice, @@ -616,6 +616,8 @@ SendTransactionScreen.prototype.onSubmit = function (event) { return } + const to = ethUtil.addHexPrefix(_to) + this.addToAddressBookIfNew(to, toNickname) if (editingTransactionId) { -- cgit From 8e6ab7df052a5ca43b15edc9c308c626bb23e64c Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 27 Mar 2018 22:38:04 -0230 Subject: Checking for sufficient balance in confirm ether screen; includes error messages for user. --- ui/app/send-v2.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'ui/app/send-v2.js') diff --git a/ui/app/send-v2.js b/ui/app/send-v2.js index 620da73f8..497d0b147 100644 --- a/ui/app/send-v2.js +++ b/ui/app/send-v2.js @@ -27,6 +27,7 @@ const { const { isBalanceSufficient, isTokenBalanceSufficient, + getGasTotal, } = require('./components/send/send-utils') const { isValidAddress } = require('./util') @@ -128,7 +129,7 @@ SendTransactionScreen.prototype.updateGas = function () { estimateGas(estimateGasParams), ]) .then(([gasPrice, gas]) => { - const newGasTotal = this.getGasTotal(gas, gasPrice) + const newGasTotal = getGasTotal(gas, gasPrice) updateGasTotal(newGasTotal) this.setState({ gasLoadingError: false }) }) @@ -136,19 +137,11 @@ SendTransactionScreen.prototype.updateGas = function () { this.setState({ gasLoadingError: true }) }) } else { - const newGasTotal = this.getGasTotal(gasLimit, gasPrice) + const newGasTotal = getGasTotal(gasLimit, gasPrice) updateGasTotal(newGasTotal) } } -SendTransactionScreen.prototype.getGasTotal = function (gasLimit, gasPrice) { - return multiplyCurrencies(gasLimit, gasPrice, { - toNumericBase: 'hex', - multiplicandBase: 16, - multiplierBase: 16, - }) -} - SendTransactionScreen.prototype.componentDidUpdate = function (prevProps) { const { from: { balance }, -- cgit From 0a711f0de0e342b24988a5da4ca5c64342153210 Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 29 Mar 2018 12:30:44 -0230 Subject: Removes t from props via metamask-connect and instead places it on context via a provider. --- ui/app/send-v2.js | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'ui/app/send-v2.js') diff --git a/ui/app/send-v2.js b/ui/app/send-v2.js index 52b8bb273..910312b47 100644 --- a/ui/app/send-v2.js +++ b/ui/app/send-v2.js @@ -1,4 +1,5 @@ const { inherits } = require('util') +const PropTypes = require('prop-types') const PersistentForm = require('../lib/persistent-form') const h = require('react-hyperscript') @@ -29,6 +30,10 @@ const { } = require('./components/send/send-utils') const { isValidAddress } = require('./util') +SendTransactionScreen.contextTypes = { + t: PropTypes.func, +} + module.exports = SendTransactionScreen inherits(SendTransactionScreen, PersistentForm) @@ -188,9 +193,9 @@ SendTransactionScreen.prototype.renderHeader = function () { return h('div.page-container__header', [ - h('div.page-container__title', selectedToken ? this.props.t('sendTokens') : this.props.t('sendETH')), + h('div.page-container__title', selectedToken ? this.context.t('sendTokens') : this.context.t('sendETH')), - h('div.page-container__subtitle', this.props.t('onlySendToEtherAddress')), + h('div.page-container__subtitle', this.context.t('onlySendToEtherAddress')), h('div.page-container__header-close', { onClick: () => { @@ -261,11 +266,11 @@ SendTransactionScreen.prototype.handleToChange = function (to, nickname = '') { let toError = null if (!to) { - toError = this.props.t('required') + toError = this.context.t('required') } else if (!isValidAddress(to)) { - toError = this.props.t('invalidAddressRecipient') + toError = this.context.t('invalidAddressRecipient') } else if (to === from) { - toError = this.props.t('fromToSame') + toError = this.context.t('fromToSame') } updateSendTo(to, nickname) @@ -281,9 +286,9 @@ SendTransactionScreen.prototype.renderToRow = function () { h('div.send-v2__form-label', [ - this.props.t('to'), + this.context.t('to'), - this.renderErrorMessage(this.props.t('to')), + this.renderErrorMessage(this.context.t('to')), ]), @@ -384,11 +389,11 @@ SendTransactionScreen.prototype.validateAmount = function (value) { ) if (conversionRate && !sufficientBalance) { - amountError = this.props.t('insufficientFunds') + amountError = this.context.t('insufficientFunds') } else if (verifyTokenBalance && !sufficientTokens) { - amountError = this.props.t('insufficientTokens') + amountError = this.context.t('insufficientTokens') } else if (amountLessThanZero) { - amountError = this.props.t('negativeETH') + amountError = this.context.t('negativeETH') } updateSendErrors({ amount: amountError }) @@ -418,7 +423,7 @@ SendTransactionScreen.prototype.renderAmountRow = function () { setMaxModeTo(true) this.setAmountToMax() }, - }, [ !maxModeOn ? this.props.t('max') : '' ]), + }, [ !maxModeOn ? this.context.t('max') : '' ]), ]), h('div.send-v2__form-field', [ @@ -447,7 +452,7 @@ SendTransactionScreen.prototype.renderGasRow = function () { return h('div.send-v2__form-row', [ - h('div.send-v2__form-label', h('gasFee')), + h('div.send-v2__form-label', this.context.t('gasFee')), h('div.send-v2__form-field', [ @@ -517,11 +522,11 @@ SendTransactionScreen.prototype.renderFooter = function () { clearSend() goHome() }, - }, this.props.t('cancel')), + }, this.context.t('cancel')), h('button.btn-primary--lg.page-container__footer-button', { disabled: !noErrors || !gasTotal || missingTokenBalance, onClick: event => this.onSubmit(event), - }, this.props.t('next')), + }, this.context.t('next')), ]) } -- cgit 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/send-v2.js') 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 From 2199b3720c9422af06fe26cf8de19b79be36987a Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 4 Apr 2018 21:52:12 -0230 Subject: Allow from and to address to be the same in new-ui. --- ui/app/send-v2.js | 3 --- 1 file changed, 3 deletions(-) (limited to 'ui/app/send-v2.js') diff --git a/ui/app/send-v2.js b/ui/app/send-v2.js index 0f2997fb2..c3b81da5b 100644 --- a/ui/app/send-v2.js +++ b/ui/app/send-v2.js @@ -254,7 +254,6 @@ SendTransactionScreen.prototype.handleToChange = function (to, nickname = '') { const { updateSendTo, updateSendErrors, - from: {address: from}, } = this.props let toError = null @@ -262,8 +261,6 @@ SendTransactionScreen.prototype.handleToChange = function (to, nickname = '') { toError = this.context.t('required') } else if (!isValidAddress(to)) { toError = this.context.t('invalidAddressRecipient') - } else if (to === from) { - toError = this.context.t('fromToSame') } updateSendTo(to, nickname) -- cgit From 418926ffdfabe8aaefbba5abbf44ebbfd838bbfc Mon Sep 17 00:00:00 2001 From: Alexander Tseung Date: Thu, 5 Apr 2018 01:04:12 -0700 Subject: Fix populating txParams with undefined data --- ui/app/send-v2.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'ui/app/send-v2.js') diff --git a/ui/app/send-v2.js b/ui/app/send-v2.js index c3b81da5b..094743ff0 100644 --- a/ui/app/send-v2.js +++ b/ui/app/send-v2.js @@ -576,12 +576,17 @@ SendTransactionScreen.prototype.getEditedTx = function () { data, }) } else { - const data = unapprovedTxs[editingTransactionId].txParams.data + const { data } = unapprovedTxs[editingTransactionId].txParams + Object.assign(editingTx.txParams, { value: ethUtil.addHexPrefix(amount), to: ethUtil.addHexPrefix(to), data, }) + + if (typeof editingTx.txParams.data === 'undefined') { + delete editingTx.txParams.data + } } return editingTx -- cgit