From 96fa29ffbce841977ae02acaba2d8114436262d4 Mon Sep 17 00:00:00 2001 From: frankiebee Date: Mon, 12 Jun 2017 16:11:37 -0700 Subject: [PATCH 01/10] put tx resubmission on the block event --- app/scripts/controllers/transactions.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js index faccf1ab1..bf24523cc 100644 --- a/app/scripts/controllers/transactions.js +++ b/app/scripts/controllers/transactions.js @@ -9,7 +9,6 @@ const createId = require('../lib/random-id') const denodeify = require('denodeify') const RETRY_LIMIT = 200 -const RESUBMIT_INTERVAL = 10000 // Ten seconds module.exports = class TransactionController extends EventEmitter { constructor (opts) { @@ -26,6 +25,7 @@ module.exports = class TransactionController extends EventEmitter { this.query = opts.ethQuery this.txProviderUtils = new TxProviderUtil(this.query) this.blockTracker.on('block', this.checkForTxInBlock.bind(this)) + this.blockTracker.on('block', this.continuallyResubmitPendingTxs.bind(this)) this.signEthTx = opts.signTransaction this.nonceLock = Semaphore(1) @@ -34,8 +34,6 @@ module.exports = class TransactionController extends EventEmitter { this.store.subscribe(() => this._updateMemstore()) this.networkStore.subscribe(() => this._updateMemstore()) this.preferencesStore.subscribe(() => this._updateMemstore()) - - this.continuallyResubmitPendingTxs() } getState () { @@ -411,16 +409,13 @@ module.exports = class TransactionController extends EventEmitter { continuallyResubmitPendingTxs () { const pending = this.getTxsByMetaData('status', 'submitted') + // only try resubmitting if their are transactions to resubmit + if (!pending.length) return const resubmit = denodeify(this.resubmitTx.bind(this)) Promise.all(pending.map(txMeta => resubmit(txMeta))) .catch((reason) => { log.info('Problem resubmitting tx', reason) }) - .then(() => { - global.setTimeout(() => { - this.continuallyResubmitPendingTxs() - }, RESUBMIT_INTERVAL) - }) } resubmitTx (txMeta, cb) { From 5e03b69892375b24bf6b7a59bb3379aac2c126da Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Mon, 12 Jun 2017 16:56:37 -0700 Subject: [PATCH 02/10] Fix check icon appearing in inappropriate situations. --- ui/app/components/ens-input.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/ui/app/components/ens-input.js b/ui/app/components/ens-input.js index 43bb7ab22..52ad8943b 100644 --- a/ui/app/components/ens-input.js +++ b/ui/app/components/ens-input.js @@ -21,7 +21,6 @@ EnsInput.prototype.render = function () { const opts = extend(props, { list: 'addresses', onChange: () => { - this.setState({ ensResolution: '0x0000000000000000000000000000000000000000' }) const network = this.props.network const networkHasEnsSupport = getNetworkEnsSupport(network) if (!networkHasEnsSupport) return @@ -73,6 +72,7 @@ EnsInput.prototype.render = function () { EnsInput.prototype.componentDidMount = function () { const network = this.props.network const networkHasEnsSupport = getNetworkEnsSupport(network) + this.setState({ ensResolution: '0x0000000000000000000000000000000000000000' }) if (networkHasEnsSupport) { const provider = global.ethereumProvider @@ -85,14 +85,6 @@ EnsInput.prototype.lookupEnsName = function () { const recipient = document.querySelector('input[name="address"]').value const { ensResolution } = this.state - if (!this.ens) { - return this.setState({ - loadingEns: false, - ensFailure: true, - hoverText: 'ENS is not supported on your current network.', - }) - } - log.info(`ENS attempting to resolve name: ${recipient}`) this.ens.lookup(recipient.trim()) .then((address) => { @@ -124,7 +116,7 @@ EnsInput.prototype.componentDidUpdate = function (prevProps, prevState) { // If an address is sent without a nickname, meaning not from ENS or from // the user's own accounts, a default of a one-space string is used. const nickname = state.nickname || ' ' - if (ensResolution && this.props.onChange && + if (prevState && ensResolution && this.props.onChange && ensResolution !== prevState.ensResolution) { this.props.onChange(ensResolution, nickname) } @@ -143,7 +135,7 @@ EnsInput.prototype.ensIcon = function (recipient) { } EnsInput.prototype.ensIconContents = function (recipient) { - const { loadingEns, ensFailure, ensResolution } = this.state || {} + const { loadingEns, ensFailure, ensResolution } = this.state || { ensResolution: '0x0000000000000000000000000000000000000000'} if (loadingEns) { return h('img', { @@ -160,7 +152,7 @@ EnsInput.prototype.ensIconContents = function (recipient) { return h('i.fa.fa-warning.fa-lg.warning') } - if (ensResolution) { + if (ensResolution && (ensResolution !== '0x0000000000000000000000000000000000000000')) { return h('i.fa.fa-check-circle.fa-lg.cursor-pointer', { style: { color: 'green' }, onClick: (event) => { @@ -175,4 +167,3 @@ EnsInput.prototype.ensIconContents = function (recipient) { function getNetworkEnsSupport (network) { return Boolean(networkMap[network]) } - From e9e43637df0132804a4a1fe031d1734029c19bf5 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Mon, 12 Jun 2017 16:57:31 -0700 Subject: [PATCH 03/10] Bump changelog. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38aebcbd4..43aaa76d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - The default network on installation is now MainNet - Fix currency API URL from cryptonator. - Update gasLimit params with every new block seen. +- Fix ENS resolver symbol UI. ## 3.7.7 2017-6-8 From dbc48c3992b9592ae6984c0dc402f06ad60d7814 Mon Sep 17 00:00:00 2001 From: Thomas Huang Date: Mon, 12 Jun 2017 17:42:54 -0700 Subject: [PATCH 04/10] Make test Async --- test/unit/tx-controller-test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/unit/tx-controller-test.js b/test/unit/tx-controller-test.js index 3954300a8..f05ae479b 100644 --- a/test/unit/tx-controller-test.js +++ b/test/unit/tx-controller-test.js @@ -311,12 +311,13 @@ describe('Transaction Controller', function () { }) describe('#sign replay-protected tx', function () { - it('prepares a tx with the chainId set', function () { + it('prepares a tx with the chainId set', function (done) { txController.addTx({ id: '1', status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} }, noop) txController.signTransaction('1', (err, rawTx) => { if (err) return assert.fail('it should not fail') const ethTx = new EthTx(ethUtil.toBuffer(rawTx)) assert.equal(ethTx.getChainId(), currentNetworkId) + done() }) }) }) From ae7c296669ad5c81e85071de071e2b0f2b1d4463 Mon Sep 17 00:00:00 2001 From: Thomas Huang Date: Mon, 12 Jun 2017 17:44:11 -0700 Subject: [PATCH 05/10] Fix networkState in chain id --- app/scripts/controllers/transactions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js index faccf1ab1..d4603aafa 100644 --- a/app/scripts/controllers/transactions.js +++ b/app/scripts/controllers/transactions.js @@ -212,7 +212,7 @@ module.exports = class TransactionController extends EventEmitter { getChainId () { const networkState = this.networkStore.getState() - const getChainId = parseInt(networkState.network) + const getChainId = parseInt(networkState) if (Number.isNaN(getChainId)) { return 0 } else { From c0f07844af434666ae1e511e90e36ca493e8bb91 Mon Sep 17 00:00:00 2001 From: Thomas Huang Date: Mon, 12 Jun 2017 17:52:37 -0700 Subject: [PATCH 06/10] Finish async when failing async test --- test/unit/tx-controller-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/tx-controller-test.js b/test/unit/tx-controller-test.js index f05ae479b..f0d8a706e 100644 --- a/test/unit/tx-controller-test.js +++ b/test/unit/tx-controller-test.js @@ -314,7 +314,7 @@ describe('Transaction Controller', function () { it('prepares a tx with the chainId set', function (done) { txController.addTx({ id: '1', status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} }, noop) txController.signTransaction('1', (err, rawTx) => { - if (err) return assert.fail('it should not fail') + if (err) return done('it should not fail') const ethTx = new EthTx(ethUtil.toBuffer(rawTx)) assert.equal(ethTx.getChainId(), currentNetworkId) done() From ec3383c16275f8d4594323b7b4ec38b447844e68 Mon Sep 17 00:00:00 2001 From: frankiebee Date: Tue, 13 Jun 2017 09:50:01 -0700 Subject: [PATCH 07/10] rename continuallyResubmitPendingTxs to resubmitPendingTxs --- app/scripts/controllers/transactions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js index bf24523cc..9f621747f 100644 --- a/app/scripts/controllers/transactions.js +++ b/app/scripts/controllers/transactions.js @@ -25,7 +25,7 @@ module.exports = class TransactionController extends EventEmitter { this.query = opts.ethQuery this.txProviderUtils = new TxProviderUtil(this.query) this.blockTracker.on('block', this.checkForTxInBlock.bind(this)) - this.blockTracker.on('block', this.continuallyResubmitPendingTxs.bind(this)) + this.blockTracker.on('block', this.resubmitPendingTxs.bind(this)) this.signEthTx = opts.signTransaction this.nonceLock = Semaphore(1) @@ -407,7 +407,7 @@ module.exports = class TransactionController extends EventEmitter { this.memStore.updateState({ unapprovedTxs, selectedAddressTxList }) } - continuallyResubmitPendingTxs () { + resubmitPendingTxs () { const pending = this.getTxsByMetaData('status', 'submitted') // only try resubmitting if their are transactions to resubmit if (!pending.length) return From 790712e6fd4b76017e11de08ccfa474c9a7e4a6f Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Tue, 13 Jun 2017 13:38:27 -0700 Subject: [PATCH 08/10] Cleanup zero addresses. --- ui/app/components/ens-input.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ui/app/components/ens-input.js b/ui/app/components/ens-input.js index 52ad8943b..16c50db84 100644 --- a/ui/app/components/ens-input.js +++ b/ui/app/components/ens-input.js @@ -7,6 +7,7 @@ const copyToClipboard = require('copy-to-clipboard') const ENS = require('ethjs-ens') const networkMap = require('ethjs-ens/lib/network-map.json') const ensRE = /.+\.eth$/ +const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000' module.exports = EnsInput @@ -72,7 +73,7 @@ EnsInput.prototype.render = function () { EnsInput.prototype.componentDidMount = function () { const network = this.props.network const networkHasEnsSupport = getNetworkEnsSupport(network) - this.setState({ ensResolution: '0x0000000000000000000000000000000000000000' }) + this.setState({ ensResolution: ZERO_ADDRESS }) if (networkHasEnsSupport) { const provider = global.ethereumProvider @@ -88,7 +89,7 @@ EnsInput.prototype.lookupEnsName = function () { log.info(`ENS attempting to resolve name: ${recipient}`) this.ens.lookup(recipient.trim()) .then((address) => { - if (address === '0x0000000000000000000000000000000000000000') throw new Error('No address has been set for this name.') + if (address === ZERO_ADDRESS) throw new Error('No address has been set for this name.') if (address !== ensResolution) { this.setState({ loadingEns: false, @@ -103,7 +104,7 @@ EnsInput.prototype.lookupEnsName = function () { log.error(reason) return this.setState({ loadingEns: false, - ensResolution: '0x0000000000000000000000000000000000000000', + ensResolution: ZERO_ADDRESS, ensFailure: true, hoverText: reason.message, }) @@ -135,7 +136,7 @@ EnsInput.prototype.ensIcon = function (recipient) { } EnsInput.prototype.ensIconContents = function (recipient) { - const { loadingEns, ensFailure, ensResolution } = this.state || { ensResolution: '0x0000000000000000000000000000000000000000'} + const { loadingEns, ensFailure, ensResolution } = this.state || { ensResolution: ZERO_ADDRESS} if (loadingEns) { return h('img', { @@ -152,7 +153,7 @@ EnsInput.prototype.ensIconContents = function (recipient) { return h('i.fa.fa-warning.fa-lg.warning') } - if (ensResolution && (ensResolution !== '0x0000000000000000000000000000000000000000')) { + if (ensResolution && (ensResolution !== ZERO_ADDRESS)) { return h('i.fa.fa-check-circle.fa-lg.cursor-pointer', { style: { color: 'green' }, onClick: (event) => { From a8ababe2f495ef91bd51436d41709cadb7b2f48c Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 14 Jun 2017 10:13:07 -0700 Subject: [PATCH 09/10] Add a new warning for file import JSON --- ui/app/accounts/import/json.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/app/accounts/import/json.js b/ui/app/accounts/import/json.js index 5ed31ab0a..158a3c923 100644 --- a/ui/app/accounts/import/json.js +++ b/ui/app/accounts/import/json.js @@ -5,6 +5,8 @@ const connect = require('react-redux').connect const actions = require('../../actions') const FileInput = require('react-simple-file-input').default +const HELP_LINK = 'https://github.com/MetaMask/faq/blob/master/README.md#q-i-cant-use-the-import-feature-for-uploading-a-json-file-the-window-keeps-closing-when-i-try-to-select-a-file' + module.exports = connect(mapStateToProps)(JsonImportSubview) function mapStateToProps (state) { @@ -32,6 +34,7 @@ JsonImportSubview.prototype.render = function () { }, [ h('p', 'Used by a variety of different clients'), + h('a.warning', { href: HELP_LINK, target: '_blank' }, 'File import not working? Click here!'), h(FileInput, { readAs: 'text', From 74d15f5cb0bae86cfbc48019d40ac68943f72b18 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 14 Jun 2017 10:13:34 -0700 Subject: [PATCH 10/10] Bump changelog. --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8afa1eec4..7f99e680e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Current Master +- Add a warning to JSON file import. + ## 3.7.8 2017-6-12 - Add a `ethereum:` prefix to the QR code address