aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorkumavis <kumavis@users.noreply.github.com>2017-01-19 04:15:58 +0800
committerGitHub <noreply@github.com>2017-01-19 04:15:58 +0800
commit28212d167cbd201f78e0253cf9c6fb676d71cb7a (patch)
treed278415f35a74e26459ca47f10798368e8b91403 /app
parent4a0f330a066ed2a557b4622163221b410b6b6e40 (diff)
parent3273f507f7a9cf33cfdbb4fffa243d75fde98b10 (diff)
downloadtangerine-wallet-browser-28212d167cbd201f78e0253cf9c6fb676d71cb7a.tar
tangerine-wallet-browser-28212d167cbd201f78e0253cf9c6fb676d71cb7a.tar.gz
tangerine-wallet-browser-28212d167cbd201f78e0253cf9c6fb676d71cb7a.tar.bz2
tangerine-wallet-browser-28212d167cbd201f78e0253cf9c6fb676d71cb7a.tar.lz
tangerine-wallet-browser-28212d167cbd201f78e0253cf9c6fb676d71cb7a.tar.xz
tangerine-wallet-browser-28212d167cbd201f78e0253cf9c6fb676d71cb7a.tar.zst
tangerine-wallet-browser-28212d167cbd201f78e0253cf9c6fb676d71cb7a.zip
Merge pull request #1022 from MetaMask/i715-AddImportMenu
Add ability to import private keys
Diffstat (limited to 'app')
-rw-r--r--app/scripts/keyring-controller.js5
-rw-r--r--app/scripts/keyrings/simple.js18
-rw-r--r--app/scripts/metamask-controller.js7
3 files changed, 22 insertions, 8 deletions
diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js
index 4be00a5a5..e609403cc 100644
--- a/app/scripts/keyring-controller.js
+++ b/app/scripts/keyring-controller.js
@@ -234,7 +234,10 @@ module.exports = class KeyringController extends EventEmitter {
addNewKeyring (type, opts) {
const Keyring = this.getKeyringClassForType(type)
const keyring = new Keyring(opts)
- return keyring.getAccounts()
+ return keyring.deserialize(opts)
+ .then(() => {
+ return keyring.getAccounts()
+ })
.then((accounts) => {
this.keyrings.push(keyring)
return this.setupAccounts(accounts)
diff --git a/app/scripts/keyrings/simple.js b/app/scripts/keyrings/simple.js
index d604430b8..46687fcaf 100644
--- a/app/scripts/keyrings/simple.js
+++ b/app/scripts/keyrings/simple.js
@@ -20,13 +20,19 @@ class SimpleKeyring extends EventEmitter {
}
deserialize (privateKeys = []) {
- this.wallets = privateKeys.map((privateKey) => {
- const stripped = ethUtil.stripHexPrefix(privateKey)
- const buffer = new Buffer(stripped, 'hex')
- const wallet = Wallet.fromPrivateKey(buffer)
- return wallet
+ return new Promise((resolve, reject) => {
+ try {
+ this.wallets = privateKeys.map((privateKey) => {
+ const stripped = ethUtil.stripHexPrefix(privateKey)
+ const buffer = new Buffer(stripped, 'hex')
+ const wallet = Wallet.fromPrivateKey(buffer)
+ return wallet
+ })
+ } catch (e) {
+ reject(e)
+ }
+ resolve()
})
- return Promise.resolve()
}
addAccounts (n = 1) {
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index b94b98eac..629216e42 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -115,7 +115,12 @@ module.exports = class MetamaskController extends EventEmitter {
.then((newState) => { cb(null, newState) })
.catch((reason) => { cb(reason) })
},
- addNewKeyring: nodeify(keyringController.addNewKeyring).bind(keyringController),
+ addNewKeyring: (type, opts, cb) => {
+ keyringController.addNewKeyring(type, opts)
+ .then(() => keyringController.fullUpdate())
+ .then((newState) => { cb(null, newState) })
+ .catch((reason) => { cb(reason) })
+ },
addNewAccount: nodeify(keyringController.addNewAccount).bind(keyringController),
setSelectedAccount: nodeify(keyringController.setSelectedAccount).bind(keyringController),
saveAccountLabel: nodeify(keyringController.saveAccountLabel).bind(keyringController),