Skip to content
Permalink
Browse files

add multivault detection to diagnostics reporting

  • Loading branch information...
kumavis committed Jun 5, 2018
1 parent 3b6e96b commit 6247e54fcc11d4d8d857a977d00eee8012afb92f
Showing with 33 additions and 0 deletions.
  1. +33 −0 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()
}

0 comments on commit 6247e54

Please sign in to comment.
You can’t perform that action at this time.