aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/actions.js
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-01-19 07:17:08 +0800
committerDan Finlay <dan@danfinlay.com>2017-01-19 07:20:48 +0800
commitb52346388b8d4518ffb2eb34236c6d17579085f3 (patch)
treed5748386adc015b8ab1d9e28d1b5c68fab5c728e /ui/app/actions.js
parent28212d167cbd201f78e0253cf9c6fb676d71cb7a (diff)
downloadtangerine-wallet-browser-b52346388b8d4518ffb2eb34236c6d17579085f3.tar
tangerine-wallet-browser-b52346388b8d4518ffb2eb34236c6d17579085f3.tar.gz
tangerine-wallet-browser-b52346388b8d4518ffb2eb34236c6d17579085f3.tar.bz2
tangerine-wallet-browser-b52346388b8d4518ffb2eb34236c6d17579085f3.tar.lz
tangerine-wallet-browser-b52346388b8d4518ffb2eb34236c6d17579085f3.tar.xz
tangerine-wallet-browser-b52346388b8d4518ffb2eb34236c6d17579085f3.tar.zst
tangerine-wallet-browser-b52346388b8d4518ffb2eb34236c6d17579085f3.zip
Added new modular private key import system
Now any strategy for importing a private key that can be described as a pure function can be very easily turned into a MetaMask import strategy. I've created a generic and reusable UI action called `importNewAccount(strategy, args)`. The `strategy` is a unique identifier defined in `app/scripts/account-import-strategies`, and the `args` will be passed to the member of the `strategies` array whose key matches the strategy string. Strategies return private key hex strings, and are used by the metamask-controller to create a new keyring, and select that new account, before calling back. This also implements @frankiebee's idea of showing the imported account when it's been imported (my oversight!). This commit only moves us to this architecture, keeping feature parity for private key import, but has some untested code for importing geth-style JSON files as well!
Diffstat (limited to 'ui/app/actions.js')
-rw-r--r--ui/app/actions.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js
index 7934a329a..36efa4bc6 100644
--- a/ui/app/actions.js
+++ b/ui/app/actions.js
@@ -43,6 +43,7 @@ var actions = {
createNewVaultAndRestore: createNewVaultAndRestore,
createNewVaultInProgress: createNewVaultInProgress,
addNewKeyring,
+ importNewAccount,
addNewAccount,
NEW_ACCOUNT_SCREEN: 'NEW_ACCOUNT_SCREEN',
navigateToNewAccountScreen,
@@ -264,6 +265,21 @@ function addNewKeyring (type, opts) {
}
}
+function importNewAccount (strategy, args) {
+ return (dispatch) => {
+ dispatch(actions.showLoadingIndication())
+ background.importAccountWithStrategy(strategy, args, (err, newState) => {
+ dispatch(actions.hideLoadingIndication())
+ if (err) return dispatch(actions.displayWarning(err.message))
+ dispatch(actions.updateMetamaskState(newState))
+ dispatch({
+ type: actions.SHOW_ACCOUNT_DETAIL,
+ value: newState.selectedAccount,
+ })
+ })
+ }
+}
+
function navigateToNewAccountScreen() {
return {
type: this.NEW_ACCOUNT_SCREEN,