aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib
diff options
context:
space:
mode:
authorKevin Serrano <kevgagser@gmail.com>2016-10-31 07:02:11 +0800
committerKevin Serrano <kevgagser@gmail.com>2016-10-31 07:02:11 +0800
commitf9409793d8a4413c42e5d11ec0279c893c7c446c (patch)
tree632fbdeb190ae0676a5f5ed83a6fd625f016abe4 /app/scripts/lib
parent25c46a16364612cd4bcebe375af910c08862b17a (diff)
parent18e5173f061c2e21b5acb3e1b329343b5cffc558 (diff)
downloadtangerine-wallet-browser-f9409793d8a4413c42e5d11ec0279c893c7c446c.tar
tangerine-wallet-browser-f9409793d8a4413c42e5d11ec0279c893c7c446c.tar.gz
tangerine-wallet-browser-f9409793d8a4413c42e5d11ec0279c893c7c446c.tar.bz2
tangerine-wallet-browser-f9409793d8a4413c42e5d11ec0279c893c7c446c.tar.lz
tangerine-wallet-browser-f9409793d8a4413c42e5d11ec0279c893c7c446c.tar.xz
tangerine-wallet-browser-f9409793d8a4413c42e5d11ec0279c893c7c446c.tar.zst
tangerine-wallet-browser-f9409793d8a4413c42e5d11ec0279c893c7c446c.zip
Merge branch 'i328-MultiVault' of github.com:MetaMask/metamask-plugin into i328-MultiVault
Diffstat (limited to 'app/scripts/lib')
-rw-r--r--app/scripts/lib/idStore-migrator.js48
-rw-r--r--app/scripts/lib/idStore.js4
2 files changed, 51 insertions, 1 deletions
diff --git a/app/scripts/lib/idStore-migrator.js b/app/scripts/lib/idStore-migrator.js
new file mode 100644
index 000000000..f8f7cb51a
--- /dev/null
+++ b/app/scripts/lib/idStore-migrator.js
@@ -0,0 +1,48 @@
+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) {
+ console.log('does not seem to have old vault')
+ console.log('THE DATA:')
+ console.log(this.configManager.getData())
+ 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()
+ console.dir(this.idStore._idmgmt)
+ const n = this.idStore._getAddresses().length
+
+ return {
+ type: 'HD Key Tree',
+ data: { mnemonic, n },
+ }
+ }
+
+ hasOldVault() {
+ const wallet = this.configManager.getWallet()
+ console.log('found old wallet: ' + wallet)
+ return wallet
+ }
+}
diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js
index 756becce3..c566907b9 100644
--- a/app/scripts/lib/idStore.js
+++ b/app/scripts/lib/idStore.js
@@ -422,7 +422,9 @@ IdentityStore.prototype._loadIdentities = function () {
var addresses = this._getAddresses()
addresses.forEach((address, i) => {
// // add to ethStore
- this._ethStore.addAccount(ethUtil.addHexPrefix(address))
+ if (this._ethStore) {
+ this._ethStore.addAccount(ethUtil.addHexPrefix(address))
+ }
// add to identities
const defaultLabel = 'Account ' + (i + 1)
const nickname = configManager.nicknameForWallet(address)