aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/scripts/keyring-controller.js37
-rw-r--r--app/scripts/lib/config-manager.js11
2 files changed, 44 insertions, 4 deletions
diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js
index 246a45484..db7e5e61e 100644
--- a/app/scripts/keyring-controller.js
+++ b/app/scripts/keyring-controller.js
@@ -1,5 +1,7 @@
-const configManager = require('./lib/config-manager')
const EventEmitter = require('events').EventEmitter
+const encryptor = require('./lib/encryptor')
+const messageManager = require('./lib/message-manager')
+
module.exports = class KeyringController extends EventEmitter {
@@ -20,7 +22,7 @@ module.exports = class KeyringController extends EventEmitter {
if (!salt) {
salt = generateSalt(32)
- configManager.setSalt(salt)
+ this.configManager.setSalt(salt)
}
var logN = 14
@@ -42,7 +44,21 @@ module.exports = class KeyringController extends EventEmitter {
}
getState() {
- return {}
+ return {
+ isInitialized: !!this.key,
+ isUnlocked: !!this.key,
+ isConfirmed: true, // this.configManager.getConfirmed(),
+ isEthConfirmed: this.configManager.getShouldntShowWarning(),
+ unconfTxs: this.configManager.unconfirmedTxs(),
+ transactions: this.configManager.getTxList(),
+ unconfMsgs: messageManager.unconfirmedMsgs(),
+ messages: messageManager.getMsgList(),
+ selectedAddress: this.configManager.getSelectedAccount(),
+ shapeShiftTxList: this.configManager.getShapeShiftTxList(),
+ currentFiat: this.configManager.getCurrentFiat(),
+ conversionRate: this.configManager.getConversionRate(),
+ conversionDate: this.configManager.getConversionDate(),
+ }
}
setStore(ethStore) {
@@ -50,9 +66,22 @@ module.exports = class KeyringController extends EventEmitter {
}
createNewVault(password, entropy, cb) {
- cb()
+ encryptor.keyFromPassword(password)
+ .then((key) => {
+ this.key = key
+ return encryptor.encryptWithKey(key, {})
+ })
+ .then((encryptedString) => {
+ this.configManager.setVault(encryptedString)
+ cb(null, [])
+ })
+ .catch((err) => {
+ cb(err)
+ })
}
+
+
submitPassword(password, cb) {
cb()
}
diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js
index d775e73fd..1c0e3b696 100644
--- a/app/scripts/lib/config-manager.js
+++ b/app/scripts/lib/config-manager.js
@@ -110,6 +110,17 @@ ConfigManager.prototype.setWallet = function (wallet) {
this.setData(data)
}
+ConfigManager.prototype.setVault = function (encryptedString) {
+ var data = this.getData()
+ data.vault = encryptedString
+ this.setData(data)
+}
+
+ConfigManager.prototype.getVault = function () {
+ var data = this.getData()
+ return ('vault' in data) && data.vault
+}
+
ConfigManager.prototype.getKeychains = function () {
return this.migrator.getData().keychains || []
}