mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
96643c222a
Remove logs. Move HD render files to ui/app.
44 lines
932 B
JavaScript
44 lines
932 B
JavaScript
const IdentityStore = require('./idStore')
|
|
|
|
|
|
module.exports = class IdentityStoreMigrator {
|
|
|
|
constructor ({ configManager }) {
|
|
this.configManager = configManager
|
|
this.idStore = new IdentityStore({ configManager })
|
|
}
|
|
|
|
oldSeedForPassword( password ) {
|
|
const isOldVault = this.hasOldVault()
|
|
if (!isOldVault) {
|
|
return Promise.resolve(null)
|
|
}
|
|
|
|
return new Promise((resolve, reject) => {
|
|
this.idStore.submitPassword(password, (err) => {
|
|
if (err) return reject(err)
|
|
try {
|
|
resolve(this.serializeVault())
|
|
} catch (e) {
|
|
reject(e)
|
|
}
|
|
})
|
|
})
|
|
}
|
|
|
|
serializeVault() {
|
|
const mnemonic = this.idStore._idmgmt.getSeed()
|
|
const n = this.idStore._getAddresses().length
|
|
|
|
return {
|
|
type: 'HD Key Tree',
|
|
data: { mnemonic, n },
|
|
}
|
|
}
|
|
|
|
hasOldVault() {
|
|
const wallet = this.configManager.getWallet()
|
|
return wallet
|
|
}
|
|
}
|