From a3a64afdd5b2ed6bbed8c8dba5cc0f14d4a1ad99 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Wed, 21 Dec 2016 17:20:14 -0800 Subject: Return undefined when vault is uninitialized --- app/scripts/lib/config-manager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/scripts/lib') diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js index d36ccf0db..ede877b76 100644 --- a/app/scripts/lib/config-manager.js +++ b/app/scripts/lib/config-manager.js @@ -121,7 +121,7 @@ ConfigManager.prototype.setVault = function (encryptedString) { ConfigManager.prototype.getVault = function () { var data = this.getData() - return ('vault' in data) && data.vault + return data.vault } ConfigManager.prototype.getKeychains = function () { -- cgit v1.2.3 From ebeaf3b3d6cf79e2e0f251b9b2da765f0fe6d0e1 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Wed, 21 Dec 2016 17:21:10 -0800 Subject: Restructured migration Migrator now returns a lostAccount array that includes objects these objects include keys of address and privateKey, this allows the MetamaskController to restore the lost accounts even without customizing the idStore or the KeyringController. Also includes a patch that allows idStore to synchronously export private keys. --- app/scripts/lib/idStore-migrator.js | 7 ++++++- app/scripts/lib/idStore.js | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'app/scripts/lib') diff --git a/app/scripts/lib/idStore-migrator.js b/app/scripts/lib/idStore-migrator.js index 2e9418376..655aed0af 100644 --- a/app/scripts/lib/idStore-migrator.js +++ b/app/scripts/lib/idStore-migrator.js @@ -63,7 +63,12 @@ module.exports = class IdentityStoreMigrator { return { serialized, - lostAccounts, + lostAccounts: lostAccounts.map((address) => { + return { + address, + privateKey: this.idStore.exportAccount(address), + } + }), } }) } diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js index cf4353e48..66e5d966c 100644 --- a/app/scripts/lib/idStore.js +++ b/app/scripts/lib/idStore.js @@ -202,7 +202,8 @@ IdentityStore.prototype.submitPassword = function (password, cb) { IdentityStore.prototype.exportAccount = function (address, cb) { var privateKey = this._idmgmt.exportPrivateKey(address) - cb(null, privateKey) + if (cb) cb(null, privateKey) + return privateKey } // -- cgit v1.2.3 From 98527c1c254fe2d438191c73053dcf3223062ef3 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 22 Dec 2016 14:43:00 -0800 Subject: Fix account injection bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It seems `selectedAddress` was removed from the keyring-controller’s state, and is used to populate the injected current account. I couldn't help myself, I dug around, I found a PR named [changed all instances of selectedAddress to selectedAccount](https://github.com/MetaMask/metamask-plugin/commit/f5b0795ac5582dd53de728479cf47c43eabfe67c) by @Zanibas. Sorry, Kevin! Had you actually changed all instances, this bug would not have happened. Fixes #908 --- app/scripts/lib/inpage-provider.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'app/scripts/lib') diff --git a/app/scripts/lib/inpage-provider.js b/app/scripts/lib/inpage-provider.js index 30fcbcb66..ccb592693 100644 --- a/app/scripts/lib/inpage-provider.js +++ b/app/scripts/lib/inpage-provider.js @@ -72,13 +72,13 @@ MetamaskInpageProvider.prototype.send = function (payload) { case 'eth_accounts': // read from localStorage - selectedAccount = self.publicConfigStore.get('selectedAddress') + selectedAccount = self.publicConfigStore.get('selectedAccount') result = selectedAccount ? [selectedAccount] : [] break case 'eth_coinbase': // read from localStorage - selectedAccount = self.publicConfigStore.get('selectedAddress') + selectedAccount = self.publicConfigStore.get('selectedAccount') result = selectedAccount || '0x0000000000000000000000000000000000000000' break @@ -119,6 +119,7 @@ function remoteStoreWithLocalStorageCache (storageKey) { var store = new RemoteStore(initState) // cache the latest state locally store.subscribe(function (state) { + console.log('received state update %s of %s', storageKey, state) localStorage[storageKey] = JSON.stringify(state) }) -- cgit v1.2.3 From 1861bf8e2b29552cf9b4a04107c5392f13a8ddce Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 22 Dec 2016 14:46:14 -0800 Subject: Remove log --- app/scripts/lib/inpage-provider.js | 1 - 1 file changed, 1 deletion(-) (limited to 'app/scripts/lib') diff --git a/app/scripts/lib/inpage-provider.js b/app/scripts/lib/inpage-provider.js index ccb592693..a64c745ce 100644 --- a/app/scripts/lib/inpage-provider.js +++ b/app/scripts/lib/inpage-provider.js @@ -119,7 +119,6 @@ function remoteStoreWithLocalStorageCache (storageKey) { var store = new RemoteStore(initState) // cache the latest state locally store.subscribe(function (state) { - console.log('received state update %s of %s', storageKey, state) localStorage[storageKey] = JSON.stringify(state) }) -- cgit v1.2.3