aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2018-06-06 02:15:58 +0800
committerkumavis <aaron@kumavis.me>2018-06-06 02:15:58 +0800
commit6247e54fcc11d4d8d857a977d00eee8012afb92f (patch)
tree264fa602632cfe77df1e92aa0533712dcd2c64d8 /app
parent3b6e96bac918925c4edc674e26dba8cc5feb1324 (diff)
downloadtangerine-wallet-browser-6247e54fcc11d4d8d857a977d00eee8012afb92f.tar
tangerine-wallet-browser-6247e54fcc11d4d8d857a977d00eee8012afb92f.tar.gz
tangerine-wallet-browser-6247e54fcc11d4d8d857a977d00eee8012afb92f.tar.bz2
tangerine-wallet-browser-6247e54fcc11d4d8d857a977d00eee8012afb92f.tar.lz
tangerine-wallet-browser-6247e54fcc11d4d8d857a977d00eee8012afb92f.tar.xz
tangerine-wallet-browser-6247e54fcc11d4d8d857a977d00eee8012afb92f.tar.zst
tangerine-wallet-browser-6247e54fcc11d4d8d857a977d00eee8012afb92f.zip
add multivault detection to diagnostics reporting
Diffstat (limited to 'app')
-rw-r--r--app/scripts/metamask-controller.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index c753fc06f..ad1d6d6a7 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -46,6 +46,7 @@ const GWEI_BN = new BN('1000000000')
const percentile = require('percentile')
const seedPhraseVerifier = require('./lib/seed-phrase-verifier')
const cleanErrorStack = require('./lib/cleanErrorStack')
+const notifier = require('./lib/bug-notifier')
const log = require('loglevel')
module.exports = class MetamaskController extends EventEmitter {
@@ -64,6 +65,9 @@ module.exports = class MetamaskController extends EventEmitter {
const initState = opts.initState || {}
this.recordFirstTimeInfo(initState)
+ // metamask diagnostics reporter
+ this.notifier = opts.notifier || notifier
+
// platform-specific api
this.platform = opts.platform
@@ -487,6 +491,35 @@ module.exports = class MetamaskController extends EventEmitter {
await this.keyringController.submitPassword(password)
const accounts = await this.keyringController.getAccounts()
+ // verify keyrings
+ try {
+ const nonSimpleKeyrings = this.keyringController.keyrings.filter(keyring => keyring.type !== 'Simple Key Pair')
+ if (nonSimpleKeyrings.length > 1) {
+ const keyrings = await Promise.all(nonSimpleKeyrings.map(async (keyring, index) => {
+ return {
+ index,
+ type: keyring.type,
+ accounts: await keyring.getAccounts()
+ }
+ }))
+ // unexpected number of keyrings, report to diagnostics
+ const uri = 'https://diagnostics.metamask.io/v1/orphanedAccounts'
+ const firstTimeInfo = this.getFirstTimeInfo ? this.getFirstTimeInfo() : {}
+ await this.notifier.notify(uri, {
+ accounts: [],
+ metadata: {
+ type: 'keyrings',
+ keyrings,
+ version,
+ firstTimeInfo,
+ },
+ })
+ }
+ } catch (err) {
+ console.error('Keyring validation error:')
+ console.error(err)
+ }
+
await this.preferencesController.syncAddresses(accounts)
return this.keyringController.fullUpdate()
}