From 2efab79f5bea899764c08dfb317ce70b5bebbb55 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 22 Nov 2016 23:16:36 -0800 Subject: Asynced keyrings and started on controller --- app/scripts/keyrings/hd.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'app/scripts/keyrings/hd.js') 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')) } -- cgit v1.2.3