aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/keyring-controller.js
diff options
context:
space:
mode:
authorKevin Serrano <kevgagser@gmail.com>2017-03-09 01:28:36 +0800
committerGitHub <noreply@github.com>2017-03-09 01:28:36 +0800
commit86f71d504cc3acd758958f883520fe913903a2c2 (patch)
tree7d6bcabbde524f5bad1d6f45802af77a12778c07 /app/scripts/keyring-controller.js
parent0ee8ca178e9240ab25454bafc88c58ebef6b69c3 (diff)
parentde5a30c5ff3acbcda7a46a3caba70a622308dbb2 (diff)
downloadtangerine-wallet-browser-86f71d504cc3acd758958f883520fe913903a2c2.tar.gz
tangerine-wallet-browser-86f71d504cc3acd758958f883520fe913903a2c2.tar.zst
tangerine-wallet-browser-86f71d504cc3acd758958f883520fe913903a2c2.zip
Merge branch 'master' into i1144-moarrpc
Diffstat (limited to 'app/scripts/keyring-controller.js')
-rw-r--r--app/scripts/keyring-controller.js23
1 files changed, 22 insertions, 1 deletions
diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js
index e1b1c4335..72f613641 100644
--- a/app/scripts/keyring-controller.js
+++ b/app/scripts/keyring-controller.js
@@ -164,8 +164,11 @@ class KeyringController extends EventEmitter {
return keyring.getAccounts()
})
.then((accounts) => {
+ return this.checkForDuplicate(type, accounts)
+ })
+ .then((checkedAccounts) => {
this.keyrings.push(keyring)
- return this.setupAccounts(accounts)
+ return this.setupAccounts(checkedAccounts)
})
.then(() => this.persistAllKeyrings())
.then(() => this.fullUpdate())
@@ -175,6 +178,24 @@ class KeyringController extends EventEmitter {
})
}
+ // For now just checks for simple key pairs
+ // but in the future
+ // should possibly add HD and other types
+ //
+ checkForDuplicate (type, newAccount) {
+ return this.getAccounts()
+ .then((accounts) => {
+ switch (type) {
+ case 'Simple Key Pair':
+ let isNotIncluded = !accounts.find((key) => key === newAccount[0] || key === ethUtil.stripHexPrefix(newAccount[0]))
+ return (isNotIncluded) ? Promise.resolve(newAccount) : Promise.reject(new Error('The account you\'re are trying to import is a duplicate'))
+ default:
+ return Promise.resolve(newAccount)
+ }
+ })
+ }
+
+
// Add New Account
// @number keyRingNum
//