aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorjaredpereira <jaredp316@gmail.com>2017-03-08 11:55:56 +0800
committerGitHub <noreply@github.com>2017-03-08 11:55:56 +0800
commit52ee007fcb540fbc57f4846816be18ad2370a81b (patch)
tree7c657fc1ac001437c0624a0e54fb7c5eee10618b /app
parent4916331c530896bbcef13a71a8f6dc0164b43c01 (diff)
parentdba261db255d48f936eb2955bcb2cdb712768dd4 (diff)
downloadtangerine-wallet-browser-52ee007fcb540fbc57f4846816be18ad2370a81b.tar
tangerine-wallet-browser-52ee007fcb540fbc57f4846816be18ad2370a81b.tar.gz
tangerine-wallet-browser-52ee007fcb540fbc57f4846816be18ad2370a81b.tar.bz2
tangerine-wallet-browser-52ee007fcb540fbc57f4846816be18ad2370a81b.tar.lz
tangerine-wallet-browser-52ee007fcb540fbc57f4846816be18ad2370a81b.tar.xz
tangerine-wallet-browser-52ee007fcb540fbc57f4846816be18ad2370a81b.tar.zst
tangerine-wallet-browser-52ee007fcb540fbc57f4846816be18ad2370a81b.zip
Merge branch 'master' into i1118-IncreaseGasBuffer
Diffstat (limited to 'app')
-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..7669b9f8f 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 your are trying to import is a duplicate'))
+ default:
+ return Promise.resolve(newAccount)
+ }
+ })
+ }
+
+
// Add New Account
// @number keyRingNum
//