mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
add multivault detection to diagnostics reporting
This commit is contained in:
parent
3b6e96bac9
commit
6247e54fcc
@ -46,6 +46,7 @@ const GWEI_BN = new BN('1000000000')
|
|||||||
const percentile = require('percentile')
|
const percentile = require('percentile')
|
||||||
const seedPhraseVerifier = require('./lib/seed-phrase-verifier')
|
const seedPhraseVerifier = require('./lib/seed-phrase-verifier')
|
||||||
const cleanErrorStack = require('./lib/cleanErrorStack')
|
const cleanErrorStack = require('./lib/cleanErrorStack')
|
||||||
|
const notifier = require('./lib/bug-notifier')
|
||||||
const log = require('loglevel')
|
const log = require('loglevel')
|
||||||
|
|
||||||
module.exports = class MetamaskController extends EventEmitter {
|
module.exports = class MetamaskController extends EventEmitter {
|
||||||
@ -64,6 +65,9 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
const initState = opts.initState || {}
|
const initState = opts.initState || {}
|
||||||
this.recordFirstTimeInfo(initState)
|
this.recordFirstTimeInfo(initState)
|
||||||
|
|
||||||
|
// metamask diagnostics reporter
|
||||||
|
this.notifier = opts.notifier || notifier
|
||||||
|
|
||||||
// platform-specific api
|
// platform-specific api
|
||||||
this.platform = opts.platform
|
this.platform = opts.platform
|
||||||
|
|
||||||
@ -487,6 +491,35 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
await this.keyringController.submitPassword(password)
|
await this.keyringController.submitPassword(password)
|
||||||
const accounts = await this.keyringController.getAccounts()
|
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)
|
await this.preferencesController.syncAddresses(accounts)
|
||||||
return this.keyringController.fullUpdate()
|
return this.keyringController.fullUpdate()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user