From 147b81068a643074a1fd7aa3e0488263a64961ad Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 4 Oct 2017 09:56:18 -0700 Subject: [PATCH 01/19] Include OS version --- app/scripts/platforms/extension.js | 4 ++++ ui/app/reducers.js | 2 ++ 2 files changed, 6 insertions(+) diff --git a/app/scripts/platforms/extension.js b/app/scripts/platforms/extension.js index 0afe04b74..83c77a77f 100644 --- a/app/scripts/platforms/extension.js +++ b/app/scripts/platforms/extension.js @@ -17,6 +17,10 @@ class ExtensionPlatform { return extension.runtime.getManifest().version } + getPlatformInfo () { + return extension.runtime.getPlatformInfo() + } + } module.exports = ExtensionPlatform diff --git a/ui/app/reducers.js b/ui/app/reducers.js index 6a2f44534..99cbda8aa 100644 --- a/ui/app/reducers.js +++ b/ui/app/reducers.js @@ -44,7 +44,9 @@ function rootReducer (state, action) { window.logState = function () { let state = window.METAMASK_CACHED_LOG_STATE const version = global.platform.getVersion() + const platform = global.platform.getPlatformInfo() state.version = version + state.platform = platform let stateString = JSON.stringify(state, removeSeedWords, 2) return stateString } From 2f135c2e68ae58e009212be862bf2318b55a1180 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 4 Oct 2017 09:56:40 -0700 Subject: [PATCH 02/19] Include browser version --- ui/app/reducers.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/app/reducers.js b/ui/app/reducers.js index 99cbda8aa..6307998c2 100644 --- a/ui/app/reducers.js +++ b/ui/app/reducers.js @@ -44,9 +44,11 @@ function rootReducer (state, action) { window.logState = function () { let state = window.METAMASK_CACHED_LOG_STATE const version = global.platform.getVersion() + const browser = global.navigator.userAgent() const platform = global.platform.getPlatformInfo() state.version = version state.platform = platform + state.browser = browser let stateString = JSON.stringify(state, removeSeedWords, 2) return stateString } From e64c64a0492aba377db6ef2c406bdb0bd1d10469 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 4 Oct 2017 10:00:07 -0700 Subject: [PATCH 03/19] change global to window --- ui/app/reducers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/app/reducers.js b/ui/app/reducers.js index 6307998c2..1224b4e92 100644 --- a/ui/app/reducers.js +++ b/ui/app/reducers.js @@ -44,7 +44,7 @@ function rootReducer (state, action) { window.logState = function () { let state = window.METAMASK_CACHED_LOG_STATE const version = global.platform.getVersion() - const browser = global.navigator.userAgent() + const browser = window.navigator.userAgent() const platform = global.platform.getPlatformInfo() state.version = version state.platform = platform From 3d80565339f02e1fa3e4bc0f8aaedbeea663a712 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 4 Oct 2017 10:55:10 -0700 Subject: [PATCH 04/19] Configured for callback-required function.' --- app/scripts/platforms/extension.js | 4 ++-- ui/app/config.js | 4 +++- ui/app/reducers.js | 17 +++++++++-------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/app/scripts/platforms/extension.js b/app/scripts/platforms/extension.js index 83c77a77f..5ed2fdc4f 100644 --- a/app/scripts/platforms/extension.js +++ b/app/scripts/platforms/extension.js @@ -17,8 +17,8 @@ class ExtensionPlatform { return extension.runtime.getManifest().version } - getPlatformInfo () { - return extension.runtime.getPlatformInfo() + getPlatformInfo (cb) { + return extension.runtime.getPlatformInfo(cb) } } diff --git a/ui/app/config.js b/ui/app/config.js index 0fe232c07..9ba00b3dd 100644 --- a/ui/app/config.js +++ b/ui/app/config.js @@ -113,7 +113,9 @@ ConfigScreen.prototype.render = function () { alignSelf: 'center', }, onClick (event) { - exportAsFile('MetaMask State Logs', window.logState()) + window.logState((result) => { + exportAsFile('MetaMask State Logs', result) + }) }, }, 'Download State Logs'), ]), diff --git a/ui/app/reducers.js b/ui/app/reducers.js index 1224b4e92..385cafdfa 100644 --- a/ui/app/reducers.js +++ b/ui/app/reducers.js @@ -41,16 +41,17 @@ function rootReducer (state, action) { return state } -window.logState = function () { +window.logState = function (cb) { let state = window.METAMASK_CACHED_LOG_STATE const version = global.platform.getVersion() - const browser = window.navigator.userAgent() - const platform = global.platform.getPlatformInfo() - state.version = version - state.platform = platform - state.browser = browser - let stateString = JSON.stringify(state, removeSeedWords, 2) - return stateString + const browser = window.navigator.userAgent + return global.platform.getPlatformInfo((platform) => { + state.version = version + state.platform = platform + state.browser = browser + let stateString = JSON.stringify(state, removeSeedWords, 2) + return cb(stateString) + }) } function removeSeedWords (key, value) { From b158d7fea03a34cc48677d272b2a411b6bbe67ab Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 4 Oct 2017 11:00:52 -0700 Subject: [PATCH 05/19] Rename to maintain API --- ui/app/config.js | 2 +- ui/app/reducers.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ui/app/config.js b/ui/app/config.js index 9ba00b3dd..75c3bcf13 100644 --- a/ui/app/config.js +++ b/ui/app/config.js @@ -113,7 +113,7 @@ ConfigScreen.prototype.render = function () { alignSelf: 'center', }, onClick (event) { - window.logState((result) => { + window.logStateString((result) => { exportAsFile('MetaMask State Logs', result) }) }, diff --git a/ui/app/reducers.js b/ui/app/reducers.js index 385cafdfa..8ffd572c0 100644 --- a/ui/app/reducers.js +++ b/ui/app/reducers.js @@ -41,7 +41,7 @@ function rootReducer (state, action) { return state } -window.logState = function (cb) { +window.logStateString = function (cb) { let state = window.METAMASK_CACHED_LOG_STATE const version = global.platform.getVersion() const browser = window.navigator.userAgent @@ -54,6 +54,12 @@ window.logState = function (cb) { }) } +window.logState() = function () { + return window.logStateString((result) => { + return result + }) +} + function removeSeedWords (key, value) { return key === 'seedWords' ? undefined : value } From 52aee7aa9ed468186c3125d79d910df3a30dfed3 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 4 Oct 2017 11:07:16 -0700 Subject: [PATCH 06/19] Further adjustment to maintain API --- ui/app/reducers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/app/reducers.js b/ui/app/reducers.js index 8ffd572c0..e7669b932 100644 --- a/ui/app/reducers.js +++ b/ui/app/reducers.js @@ -54,9 +54,9 @@ window.logStateString = function (cb) { }) } -window.logState() = function () { +window.logState = function () { return window.logStateString((result) => { - return result + console.log(result) }) } From bb9c2b3563938832e4b35b6623ef724017093fcb Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 4 Oct 2017 11:14:30 -0700 Subject: [PATCH 07/19] lint --- ui/app/reducers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/app/reducers.js b/ui/app/reducers.js index e7669b932..0af7ee81c 100644 --- a/ui/app/reducers.js +++ b/ui/app/reducers.js @@ -48,7 +48,7 @@ window.logStateString = function (cb) { return global.platform.getPlatformInfo((platform) => { state.version = version state.platform = platform - state.browser = browser + state.browser = browser let stateString = JSON.stringify(state, removeSeedWords, 2) return cb(stateString) }) From 15809894ff42bacc3babfb9aaba48389417907c0 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Thu, 5 Oct 2017 09:58:04 -0700 Subject: [PATCH 08/19] Add indicator for specified gas price --- app/scripts/controllers/transactions.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js index 94e04c429..481dd62a5 100644 --- a/app/scripts/controllers/transactions.js +++ b/app/scripts/controllers/transactions.js @@ -169,6 +169,7 @@ module.exports = class TransactionController extends EventEmitter { async addTxDefaults (txMeta) { const txParams = txMeta.txParams // ensure value + txMeta.gasPriceSpecified = Boolean(txParams.gasPrice) const gasPrice = txParams.gasPrice || await this.query.gasPrice() txParams.gasPrice = ethUtil.addHexPrefix(gasPrice.toString(16)) txParams.value = txParams.value || '0x0' From 106af9ec5b5671ec312117b1e2bd0ba5350d2085 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Thu, 5 Oct 2017 17:13:58 -0700 Subject: [PATCH 09/19] Catch an error if this is not defined. --- app/scripts/platforms/extension.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/scripts/platforms/extension.js b/app/scripts/platforms/extension.js index 5ed2fdc4f..f9e1d84b7 100644 --- a/app/scripts/platforms/extension.js +++ b/app/scripts/platforms/extension.js @@ -18,7 +18,14 @@ class ExtensionPlatform { } getPlatformInfo (cb) { - return extension.runtime.getPlatformInfo(cb) + var info + try { + info = extension.runtime.getPlatformInfo(cb) + } catch (e) { + log.debug(e) + info = undefined + } + return info } } From f6821781d2ee3b1562008f47d9581ed21efee3ef Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Thu, 5 Oct 2017 17:17:34 -0700 Subject: [PATCH 10/19] Simplify try catch --- app/scripts/platforms/extension.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/scripts/platforms/extension.js b/app/scripts/platforms/extension.js index f9e1d84b7..61d67e1b4 100644 --- a/app/scripts/platforms/extension.js +++ b/app/scripts/platforms/extension.js @@ -18,14 +18,12 @@ class ExtensionPlatform { } getPlatformInfo (cb) { - var info try { - info = extension.runtime.getPlatformInfo(cb) + return extension.runtime.getPlatformInfo(cb) } catch (e) { log.debug(e) - info = undefined + return undefined } - return info } } From 24a55cf7770a6154fe723cf13cdc9998e1759f3b Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Tue, 10 Oct 2017 08:36:15 -0700 Subject: [PATCH 11/19] Make the function callback friendly. --- app/scripts/platforms/extension.js | 8 ++++---- ui/app/config.js | 8 ++++++-- ui/app/reducers.js | 7 +++++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/scripts/platforms/extension.js b/app/scripts/platforms/extension.js index 61d67e1b4..2f47512eb 100644 --- a/app/scripts/platforms/extension.js +++ b/app/scripts/platforms/extension.js @@ -19,13 +19,13 @@ class ExtensionPlatform { getPlatformInfo (cb) { try { - return extension.runtime.getPlatformInfo(cb) + extension.runtime.getPlatformInfo((platform) => { + cb(null, platform) + }) } catch (e) { - log.debug(e) - return undefined + cb(e) } } - } module.exports = ExtensionPlatform diff --git a/ui/app/config.js b/ui/app/config.js index 75c3bcf13..c14fa1d28 100644 --- a/ui/app/config.js +++ b/ui/app/config.js @@ -113,8 +113,12 @@ ConfigScreen.prototype.render = function () { alignSelf: 'center', }, onClick (event) { - window.logStateString((result) => { - exportAsFile('MetaMask State Logs', result) + window.logStateString((err, result) => { + if (err) { + state.dispatch(actions.displayWarning('Error in retrieving state logs.')) + } else { + exportAsFile('MetaMask State Logs', result) + } }) }, }, 'Download State Logs'), diff --git a/ui/app/reducers.js b/ui/app/reducers.js index 0af7ee81c..3d0a58f81 100644 --- a/ui/app/reducers.js +++ b/ui/app/reducers.js @@ -45,12 +45,15 @@ window.logStateString = function (cb) { let state = window.METAMASK_CACHED_LOG_STATE const version = global.platform.getVersion() const browser = window.navigator.userAgent - return global.platform.getPlatformInfo((platform) => { + return global.platform.getPlatformInfo((err, platform) => { + if (err) { + return cb(err) + } state.version = version state.platform = platform state.browser = browser let stateString = JSON.stringify(state, removeSeedWords, 2) - return cb(stateString) + return cb(null, stateString) }) } From a387def701303e56f721fdc7c716e72641bfaf8f Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Tue, 10 Oct 2017 08:50:59 -0700 Subject: [PATCH 12/19] Changelog addition. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8bb48e9f..c8f5b3115 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Add new support for new eth_signTypedData method per EIP 712. - Fix bug where some transactions would be shown as pending forever, even after successfully mined. - Fix bug where a transaction might be shown as pending forever if another tx with the same nonce was mined. +- Add OS and browser version information to state log dump (for debugging purposes only). ## 3.10.9 2017-10-5 From a7424f0c0d134b730e7e5209612a3b26f990f75f Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 25 Oct 2017 20:06:26 -0700 Subject: [PATCH 13/19] 3.12.0 --- CHANGELOG.md | 2 ++ app/manifest.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 671bb7a6f..573627917 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Current Master +## 3.12.0 2017-10-25 + - Add support for alternative ENS TLDs (Ethereum Name Service Top-Level Domains). - Lower minimum gas price to 0.1 GWEI. - Remove web3 injection message from production (thanks to @ChainsawBaby) diff --git a/app/manifest.json b/app/manifest.json index eb499390a..b6ff3d1cb 100644 --- a/app/manifest.json +++ b/app/manifest.json @@ -1,7 +1,7 @@ { "name": "MetaMask", "short_name": "Metamask", - "version": "3.11.2", + "version": "3.12.0", "manifest_version": 2, "author": "https://metamask.io", "description": "Ethereum Browser Extension", From fc7ca17aa8c6cd343c150b980ab20e9b42f04e39 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Thu, 26 Oct 2017 16:23:18 -0700 Subject: [PATCH 14/19] Bump Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0529d3318..2e7f8fc06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Add support for alternative ENS TLDs (Ethereum Name Service Top-Level Domains). - Lower minimum gas price to 0.1 GWEI. - Remove web3 injection message from production (thanks to @ChainsawBaby) +- Add additional debugging info to our state logs, specifically OS version and browser version. ## 3.11.2 2017-10-21 From c89ea954e52aab3ac1f0f00826eea9219f8d4731 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Thu, 26 Oct 2017 16:23:58 -0700 Subject: [PATCH 15/19] Correct changelog. --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e7f8fc06..ee9548606 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,6 @@ - Add support for new eth_signTypedData method per EIP 712. - Fix bug where some transactions would be shown as pending forever, even after successfully mined. - Fix bug where a transaction might be shown as pending forever if another tx with the same nonce was mined. -- Add OS and browser version information to state log dump (for debugging purposes only). - Fix link to support article on token addresses. ## 3.10.9 2017-10-5 From 3deeb6df0b1335ed68a20734516f3bff790f84b1 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Thu, 26 Oct 2017 16:40:13 -0700 Subject: [PATCH 16/19] Add option to copy directly to clipboard. --- ui/app/reducers.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ui/app/reducers.js b/ui/app/reducers.js index 3d0a58f81..05136f70f 100644 --- a/ui/app/reducers.js +++ b/ui/app/reducers.js @@ -1,4 +1,5 @@ const extend = require('xtend') +const copyToClipboard = require('copy-to-clipboard') // // Sub-Reducers take in the complete state and return their sub-state @@ -57,9 +58,16 @@ window.logStateString = function (cb) { }) } -window.logState = function () { - return window.logStateString((result) => { - console.log(result) +window.logState = function (toClipboard) { + return window.logStateString((err, result) => { + if (err) { + console.error(err.message) + } else if (toClipboard) { + copyToClipboard(result) + console.log('State log copied') + } else { + console.log(result) + } }) } From 0bfa10e501f47197996002447a216f278d7e6eb5 Mon Sep 17 00:00:00 2001 From: Daijiro Wachi Date: Mon, 30 Oct 2017 20:04:44 +0100 Subject: [PATCH 17/19] Remove warning message when show import page Fixes: https://github.com/MetaMask/metamask-extension/issues/1192 --- ui/app/accounts/import/index.js | 1 + ui/app/reducers/app.js | 1 + 2 files changed, 2 insertions(+) diff --git a/ui/app/accounts/import/index.js b/ui/app/accounts/import/index.js index 97b387229..46260c3e7 100644 --- a/ui/app/accounts/import/index.js +++ b/ui/app/accounts/import/index.js @@ -72,6 +72,7 @@ AccountImportSubview.prototype.render = function () { } }), onChange: (opt) => { + props.dispatch(actions.showImportPage()) this.setState({ type: opt.value }) }, }), diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js index 6f08c6dc4..8558d6dca 100644 --- a/ui/app/reducers/app.js +++ b/ui/app/reducers/app.js @@ -122,6 +122,7 @@ function reduceApp (state, action) { name: 'import-menu', }, transForward: true, + warning: null, }) case actions.SHOW_INFO_PAGE: From 657449916556d3e8db24dbfbf0355e84a9ea0b09 Mon Sep 17 00:00:00 2001 From: Daijiro Wachi Date: Mon, 30 Oct 2017 20:08:10 +0100 Subject: [PATCH 18/19] Use const and fix lint warnings --- ui/app/reducers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/app/reducers.js b/ui/app/reducers.js index 05136f70f..70b7e71dc 100644 --- a/ui/app/reducers.js +++ b/ui/app/reducers.js @@ -43,7 +43,7 @@ function rootReducer (state, action) { } window.logStateString = function (cb) { - let state = window.METAMASK_CACHED_LOG_STATE + const state = window.METAMASK_CACHED_LOG_STATE const version = global.platform.getVersion() const browser = window.navigator.userAgent return global.platform.getPlatformInfo((err, platform) => { @@ -53,7 +53,7 @@ window.logStateString = function (cb) { state.version = version state.platform = platform state.browser = browser - let stateString = JSON.stringify(state, removeSeedWords, 2) + const stateString = JSON.stringify(state, removeSeedWords, 2) return cb(null, stateString) }) } From 41fea44af3105313b33d9882859935019b6a2410 Mon Sep 17 00:00:00 2001 From: "Dora E. Mondrian" Date: Mon, 6 Nov 2017 04:35:51 -0800 Subject: [PATCH 19/19] newUnaprovedTx => newUnapprovedTx This typo tripped me up when I was reading through the code and trying to understand what's going on. --- app/scripts/controllers/transactions.js | 2 +- app/scripts/metamask-controller.js | 2 +- test/unit/tx-controller-test.js | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js index d5fde033b..a861c0342 100644 --- a/app/scripts/controllers/transactions.js +++ b/app/scripts/controllers/transactions.js @@ -133,7 +133,7 @@ module.exports = class TransactionController extends EventEmitter { async newUnapprovedTransaction (txParams) { log.debug(`MetaMaskController newUnapprovedTransaction ${JSON.stringify(txParams)}`) const txMeta = await this.addUnapprovedTransaction(txParams) - this.emit('newUnaprovedTx', txMeta) + this.emit('newUnapprovedTx', txMeta) // listen for tx completion (success, fail) return new Promise((resolve, reject) => { this.txStateManager.once(`${txMeta.id}:finished`, (completedTx) => { diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index ad42a39fb..968589f6e 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -128,7 +128,7 @@ module.exports = class MetamaskController extends EventEmitter { blockTracker: this.blockTracker, ethQuery: this.ethQuery, }) - this.txController.on('newUnaprovedTx', opts.showUnapprovedTx.bind(opts)) + this.txController.on('newUnapprovedTx', opts.showUnapprovedTx.bind(opts)) // computed balances (accounting for pending transactions) this.balancesController = new BalancesController({ diff --git a/test/unit/tx-controller-test.js b/test/unit/tx-controller-test.js index bb51ab01f..aeefd5ec6 100644 --- a/test/unit/tx-controller-test.js +++ b/test/unit/tx-controller-test.js @@ -118,8 +118,8 @@ describe('Transaction Controller', function () { stub.restore() }) - it('should emit newUnaprovedTx event and pass txMeta as the first argument', function (done) { - txController.once('newUnaprovedTx', (txMetaFromEmit) => { + it('should emit newUnapprovedTx event and pass txMeta as the first argument', function (done) { + txController.once('newUnapprovedTx', (txMetaFromEmit) => { assert(txMetaFromEmit, 'txMeta is falsey') assert.equal(txMetaFromEmit.id, 1, 'the right txMeta was passed') done() @@ -129,7 +129,7 @@ describe('Transaction Controller', function () { }) it('should resolve when finished and status is submitted and resolve with the hash', function (done) { - txController.once('newUnaprovedTx', (txMetaFromEmit) => { + txController.once('newUnapprovedTx', (txMetaFromEmit) => { setTimeout(() => { txController.setTxHash(txMetaFromEmit.id, '0x0') txController.txStateManager.setTxStatusSubmitted(txMetaFromEmit.id) @@ -145,7 +145,7 @@ describe('Transaction Controller', function () { }) it('should reject when finished and status is rejected', function (done) { - txController.once('newUnaprovedTx', (txMetaFromEmit) => { + txController.once('newUnapprovedTx', (txMetaFromEmit) => { setTimeout(() => { txController.txStateManager.setTxStatusRejected(txMetaFromEmit.id) }, 10)