From 147b81068a643074a1fd7aa3e0488263a64961ad Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 4 Oct 2017 09:56:18 -0700 Subject: [PATCH 01/14] 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/14] 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/14] 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/14] 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/14] 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/14] 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/14] 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 106af9ec5b5671ec312117b1e2bd0ba5350d2085 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Thu, 5 Oct 2017 17:13:58 -0700 Subject: [PATCH 08/14] 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 09/14] 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 10/14] 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 11/14] 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 fc7ca17aa8c6cd343c150b980ab20e9b42f04e39 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Thu, 26 Oct 2017 16:23:18 -0700 Subject: [PATCH 12/14] 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 13/14] 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 14/14] 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) + } }) }