aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/scripts/keyring-controller.js18
-rw-r--r--app/scripts/lib/config-manager.js15
-rw-r--r--app/scripts/lib/idStore-migrator.js5
-rw-r--r--app/scripts/metamask-controller.js1
4 files changed, 29 insertions, 10 deletions
diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js
index e7b9612bf..ee6445121 100644
--- a/app/scripts/keyring-controller.js
+++ b/app/scripts/keyring-controller.js
@@ -47,6 +47,7 @@ module.exports = class KeyringController extends EventEmitter {
getState() {
return {
+ seedWords: this.configManager.getSeedWords(),
isInitialized: !!this.configManager.getVault(),
isUnlocked: !!this.key,
isConfirmed: true, // AUDIT this.configManager.getConfirmed(),
@@ -90,10 +91,14 @@ module.exports = class KeyringController extends EventEmitter {
this.configManager.setVault(encryptedString)
if (!serialized) {
- // TEMPORARY SINGLE-KEYRING CONFIG:
- return this.addNewKeyring('HD Key Tree', null, (err, newState) => {
- const firstAccount = this.keyrings[0].getAccounts()[0]
- autoFaucet(ethUtil.addHexPrefix(firstAccount))
+ this.addNewKeyring('HD Key Tree', null, (err, newState) => {
+ const firstKeyring = this.keyrings[0]
+ const firstAccount = firstKeyring.getAccounts()[0]
+ const hexAccount = ethUtil.addHexPrefix(firstAccount)
+ const seedWords = firstKeyring.serialize().mnemonic
+ this.configManager.setSelectedAccount(hexAccount)
+ this.configManager.setSeedWords(seedWords)
+ autoFaucet(hexAccount)
cb(err, newState)
})
} else {
@@ -470,6 +475,11 @@ module.exports = class KeyringController extends EventEmitter {
return ethUtil.addHexPrefix(result.toString(16))
}
+ clearSeedWordCache(cb) {
+ this.configManager.setSeedWords(null)
+ cb(null, this.configManager.getSelectedAccount())
+ }
+
}
function noop () {}
diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js
index abe5dfc87..8f5590738 100644
--- a/app/scripts/lib/config-manager.js
+++ b/app/scripts/lib/config-manager.js
@@ -2,6 +2,7 @@ const Migrator = require('pojo-migrator')
const MetamaskConfig = require('../config.js')
const migrations = require('./migrations')
const rp = require('request-promise')
+const ethUtil = require('ethereumjs-util')
const TESTNET_RPC = MetamaskConfig.network.testnet
const MAINNET_RPC = MetamaskConfig.network.mainnet
@@ -138,7 +139,7 @@ ConfigManager.prototype.getSelectedAccount = function () {
ConfigManager.prototype.setSelectedAccount = function (address) {
var config = this.getConfig()
- config.selectedAccount = address
+ config.selectedAccount = ethUtil.addHexPrefix(address)
this.setConfig(config)
}
@@ -153,11 +154,23 @@ ConfigManager.prototype.setShowSeedWords = function (should) {
this.setData(data)
}
+
ConfigManager.prototype.getShouldShowSeedWords = function () {
var data = this.migrator.getData()
return data.showSeedWords
}
+ConfigManager.prototype.setSeedWords = function (words) {
+ var data = this.getData()
+ data.seedWords = words
+ this.setData(data)
+}
+
+ConfigManager.prototype.getSeedWords = function () {
+ var data = this.getData()
+ return ('seedWords' in data) && data.seedWords
+}
+
ConfigManager.prototype.getCurrentRpcAddress = function () {
var provider = this.getProvider()
if (!provider) return null
diff --git a/app/scripts/lib/idStore-migrator.js b/app/scripts/lib/idStore-migrator.js
index f8f7cb51a..c81e7ddfe 100644
--- a/app/scripts/lib/idStore-migrator.js
+++ b/app/scripts/lib/idStore-migrator.js
@@ -11,9 +11,6 @@ module.exports = class IdentityStoreMigrator {
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)
}
@@ -31,7 +28,6 @@ module.exports = class IdentityStoreMigrator {
serializeVault() {
const mnemonic = this.idStore._idmgmt.getSeed()
- console.dir(this.idStore._idmgmt)
const n = this.idStore._getAddresses().length
return {
@@ -42,7 +38,6 @@ module.exports = class IdentityStoreMigrator {
hasOldVault() {
const wallet = this.configManager.getWallet()
- console.log('found old wallet: ' + wallet)
return wallet
}
}
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index a7d9a8ec2..48c56d915 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -60,6 +60,7 @@ module.exports = class MetamaskController {
// forward directly to keyringController
createNewVault: keyringController.createNewVault.bind(keyringController),
+ clearSeedWordCache: keyringController.clearSeedWordCache.bind(keyringController),
addNewKeyring: keyringController.addNewKeyring.bind(keyringController),
addNewAccount: keyringController.addNewAccount.bind(keyringController),
submitPassword: keyringController.submitPassword.bind(keyringController),