aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/keyring-controller.js
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-11-23 15:16:36 +0800
committerDan Finlay <dan@danfinlay.com>2016-11-23 15:16:36 +0800
commit2efab79f5bea899764c08dfb317ce70b5bebbb55 (patch)
treec9a78fe812353e4909efb78d781ab0a669314cde /app/scripts/keyring-controller.js
parentec8b0148f0bf4114ab27d9bfe8ebca8a116e4b20 (diff)
downloadtangerine-wallet-browser-2efab79f5bea899764c08dfb317ce70b5bebbb55.tar
tangerine-wallet-browser-2efab79f5bea899764c08dfb317ce70b5bebbb55.tar.gz
tangerine-wallet-browser-2efab79f5bea899764c08dfb317ce70b5bebbb55.tar.bz2
tangerine-wallet-browser-2efab79f5bea899764c08dfb317ce70b5bebbb55.tar.lz
tangerine-wallet-browser-2efab79f5bea899764c08dfb317ce70b5bebbb55.tar.xz
tangerine-wallet-browser-2efab79f5bea899764c08dfb317ce70b5bebbb55.tar.zst
tangerine-wallet-browser-2efab79f5bea899764c08dfb317ce70b5bebbb55.zip
Asynced keyrings and started on controller
Diffstat (limited to 'app/scripts/keyring-controller.js')
-rw-r--r--app/scripts/keyring-controller.js44
1 files changed, 29 insertions, 15 deletions
diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js
index 68cf62f7a..1f58f3780 100644
--- a/app/scripts/keyring-controller.js
+++ b/app/scripts/keyring-controller.js
@@ -121,10 +121,13 @@ module.exports = class KeyringController extends EventEmitter {
this.password = password
const keyring = this.restoreKeyring(serialized)
this.keyrings.push(keyring)
- this.configManager.setSelectedAccount(keyring.getAccounts()[0])
- return this.persistAllKeyrings()
+ keyring.getAccounts()
+ .then((accounts) => {
+ this.configManager.setSelectedAccount(accounts[0])
+ return this.persistAllKeyrings()
+ })
}
- return
+ return Promise.resolve()
})
}
@@ -165,13 +168,18 @@ module.exports = class KeyringController extends EventEmitter {
placeSeedWords (cb) {
const firstKeyring = this.keyrings[0]
- const seedWords = firstKeyring.serialize().mnemonic
- this.configManager.setSeedWords(seedWords)
+ firstKeyring.serialize()
+ .then((serialized) => {
- if (cb) {
- cb()
- }
- this.emit('update')
+ const seedWords = serialized.mnemonic
+ this.configManager.setSeedWords(seedWords)
+
+ if (cb) {
+ cb()
+ }
+
+ this.emit('update')
+ })
}
submitPassword (password, cb) {
@@ -259,13 +267,19 @@ module.exports = class KeyringController extends EventEmitter {
}
persistAllKeyrings () {
- const serialized = this.keyrings.map((keyring) => {
- return {
- type: keyring.type,
- data: keyring.serialize(),
- }
+ Promise.all(this.keyrings.map((keyring) => {
+ return Promise.all([keyring.type, keyring.serialize()])
+ .then((serializedKeyringArray) => {
+ // Label the output values on each serialized Keyring:
+ return {
+ type: serializedKeyringArray[0],
+ data: serializedKeyringArray[1],
+ }
+ })
+ }))
+ .then((serializedKeyrings) => {
+ return this.encryptor.encrypt(this.password, serializedKeyrings)
})
- return this.encryptor.encrypt(this.password, serialized)
.then((encryptedString) => {
this.configManager.setVault(encryptedString)
return true