aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/keyrings
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/keyrings
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/keyrings')
-rw-r--r--app/scripts/keyrings/hd.js17
-rw-r--r--app/scripts/keyrings/simple.js18
2 files changed, 18 insertions, 17 deletions
diff --git a/app/scripts/keyrings/hd.js b/app/scripts/keyrings/hd.js
index a28ef6736..cfec56561 100644
--- a/app/scripts/keyrings/hd.js
+++ b/app/scripts/keyrings/hd.js
@@ -21,10 +21,10 @@ class HdKeyring extends EventEmitter {
}
serialize () {
- return {
+ return Promise.resolve({
mnemonic: this.mnemonic,
numberOfAccounts: this.wallets.length,
- }
+ })
}
deserialize (opts = {}) {
@@ -40,6 +40,8 @@ class HdKeyring extends EventEmitter {
if ('numberOfAccounts' in opts) {
this.addAccounts(opts.numberOfAccounts)
}
+
+ return Promise.resolve()
}
addAccounts (numberOfAccounts = 1) {
@@ -55,11 +57,12 @@ class HdKeyring extends EventEmitter {
newWallets.push(wallet)
this.wallets.push(wallet)
}
- return newWallets.map(w => w.getAddress().toString('hex'))
+ const hexWallets = newWallets.map(w => w.getAddress().toString('hex'))
+ return Promise.resolve(hexWallets)
}
getAccounts () {
- return this.wallets.map(w => w.getAddress().toString('hex'))
+ return Promise.resolve(this.wallets.map(w => w.getAddress().toString('hex')))
}
// tx is an instance of the ethereumjs-transaction class.
@@ -67,7 +70,7 @@ class HdKeyring extends EventEmitter {
const wallet = this._getWalletForAccount(address)
var privKey = wallet.getPrivateKey()
tx.sign(privKey)
- return tx
+ return Promise.resolve(tx)
}
// For eth_sign, we need to sign transactions:
@@ -77,12 +80,12 @@ class HdKeyring extends EventEmitter {
var privKey = wallet.getPrivateKey()
var msgSig = ethUtil.ecsign(new Buffer(message, 'hex'), privKey)
var rawMsgSig = ethUtil.bufferToHex(sigUtil.concatSig(msgSig.v, msgSig.r, msgSig.s))
- return rawMsgSig
+ return Promise.resolve(rawMsgSig)
}
exportAccount (address) {
const wallet = this._getWalletForAccount(address)
- return wallet.getPrivateKey().toString('hex')
+ return Promise.resolve(wallet.getPrivateKey().toString('hex'))
}
diff --git a/app/scripts/keyrings/simple.js b/app/scripts/keyrings/simple.js
index 4fdccc4f7..8f339cf80 100644
--- a/app/scripts/keyrings/simple.js
+++ b/app/scripts/keyrings/simple.js
@@ -8,10 +8,6 @@ class SimpleKeyring extends EventEmitter {
/* PUBLIC METHODS */
- static type () {
- return type
- }
-
constructor (opts) {
super()
this.type = type
@@ -20,7 +16,7 @@ class SimpleKeyring extends EventEmitter {
}
serialize () {
- return this.wallets.map(w => w.getPrivateKey().toString('hex'))
+ return Promise.resolve(this.wallets.map(w => w.getPrivateKey().toString('hex')))
}
deserialize (wallets = []) {
@@ -29,6 +25,7 @@ class SimpleKeyring extends EventEmitter {
const wallet = Wallet.fromPrivateKey(b)
return wallet
})
+ return Promise.resolve()
}
addAccounts (n = 1) {
@@ -37,11 +34,12 @@ class SimpleKeyring extends EventEmitter {
newWallets.push(Wallet.generate())
}
this.wallets = this.wallets.concat(newWallets)
- return newWallets.map(w => w.getAddress().toString('hex'))
+ const hexWallets = newWallets.map(w => w.getAddress().toString('hex'))
+ return Promise.resolve(hexWallets)
}
getAccounts () {
- return this.wallets.map(w => w.getAddress().toString('hex'))
+ return Promise.resolve(this.wallets.map(w => w.getAddress().toString('hex')))
}
// tx is an instance of the ethereumjs-transaction class.
@@ -49,7 +47,7 @@ class SimpleKeyring extends EventEmitter {
const wallet = this._getWalletForAccount(address)
var privKey = wallet.getPrivateKey()
tx.sign(privKey)
- return tx
+ return Promise.resolve(tx)
}
// For eth_sign, we need to sign transactions:
@@ -59,12 +57,12 @@ class SimpleKeyring extends EventEmitter {
var privKey = wallet.getPrivateKey()
var msgSig = ethUtil.ecsign(new Buffer(message, 'hex'), privKey)
var rawMsgSig = ethUtil.bufferToHex(sigUtil.concatSig(msgSig.v, msgSig.r, msgSig.s))
- return rawMsgSig
+ return Promise.resolve(rawMsgSig)
}
exportAccount (address) {
const wallet = this._getWalletForAccount(address)
- return wallet.getPrivateKey().toString('hex')
+ return Promise.resolve(wallet.getPrivateKey().toString('hex'))
}