aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorKevin Serrano <kevgagser@gmail.com>2017-03-08 02:25:50 +0800
committerKevin Serrano <kevgagser@gmail.com>2017-03-08 02:25:50 +0800
commit2a98beb87877619ad123281facab3e22dec64fab (patch)
treedd9b41ec95d7cf96a1cb448d4c11940927d9f46e /ui
parente66035254f1778ec8e614cabecaf1a9493509888 (diff)
downloadtangerine-wallet-browser-2a98beb87877619ad123281facab3e22dec64fab.tar
tangerine-wallet-browser-2a98beb87877619ad123281facab3e22dec64fab.tar.gz
tangerine-wallet-browser-2a98beb87877619ad123281facab3e22dec64fab.tar.bz2
tangerine-wallet-browser-2a98beb87877619ad123281facab3e22dec64fab.tar.lz
tangerine-wallet-browser-2a98beb87877619ad123281facab3e22dec64fab.tar.xz
tangerine-wallet-browser-2a98beb87877619ad123281facab3e22dec64fab.tar.zst
tangerine-wallet-browser-2a98beb87877619ad123281facab3e22dec64fab.zip
Break out rpc update and rpclist into two reducers.
Diffstat (limited to 'ui')
-rw-r--r--ui/app/actions.js30
-rw-r--r--ui/app/app.js4
-rw-r--r--ui/app/reducers/metamask.js8
3 files changed, 31 insertions, 11 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js
index cda987cad..4172ea5df 100644
--- a/ui/app/actions.js
+++ b/ui/app/actions.js
@@ -112,11 +112,13 @@ var actions = {
// config screen
SHOW_CONFIG_PAGE: 'SHOW_CONFIG_PAGE',
SET_RPC_TARGET: 'SET_RPC_TARGET',
+ SET_DEFAULT_RPC_TARGET: 'SET_DEFAULT_RPC_TARGET',
SET_PROVIDER_TYPE: 'SET_PROVIDER_TYPE',
USE_ETHERSCAN_PROVIDER: 'USE_ETHERSCAN_PROVIDER',
useEtherscanProvider: useEtherscanProvider,
showConfigPage: showConfigPage,
setRpcTarget: setRpcTarget,
+ setDefaultRpcTarget: setDefaultRpcTarget,
setProviderType: setProviderType,
// loading overlay
SHOW_LOADING: 'SHOW_LOADING_INDICATION',
@@ -669,18 +671,34 @@ function markAccountsFound() {
// config
//
+// default rpc target refers to localhost:8545 in this instance.
+function setDefaultRpcTarget (rpcList) {
+ log.debug(`background.setDefaultRpcTarget`)
+ background.setRpcTarget('http://localhost:8545')
+ return (dispatch) => {
+ dispatch({
+ type: actions.SET_RPC_TARGET,
+ value: 'http://localhost:8545',
+ })
+ dispatch({
+ type: actions.SET_RPC_LIST,
+ value: rpcList,
+ })
+ }
+}
+
function setRpcTarget (newRpc) {
return (dispatch) => {
log.debug(`background.setRpcTarget`)
background.setRpcTarget(newRpc)
- background.updateFrequentRpcList(newRpc, (frequentRpcList) => {
- const value = {
- rpcTarget: newRpc,
- frequentRpcList,
- }
+ background.updateFrequentRpcList(newRpc, (rpcList) => {
dispatch({
type: actions.SET_RPC_TARGET,
- value,
+ value: newRpc,
+ })
+ dispatch({
+ type: actions.SET_RPC_LIST,
+ value: rpcList,
})
})
}
diff --git a/ui/app/app.js b/ui/app/app.js
index 20f948770..2bc92b54c 100644
--- a/ui/app/app.js
+++ b/ui/app/app.js
@@ -258,9 +258,7 @@ App.prototype.renderNetworkDropdown = function () {
h(DropMenuItem, {
label: 'Localhost 8545',
closeMenu: () => this.setState({ isNetworkMenuOpen: false }),
- action: () => {
- props.dispatch(actions.setRpcTarget('http://localhost:8545'))
- },
+ action: () => props.dispatch(actions.setDefaultRpcTarget(rpcList)),
icon: h('i.fa.fa-question-circle.fa-lg'),
activeNetworkRender: props.provider.rpcTarget,
}),
diff --git a/ui/app/reducers/metamask.js b/ui/app/reducers/metamask.js
index 7bf2969e7..c09556c91 100644
--- a/ui/app/reducers/metamask.js
+++ b/ui/app/reducers/metamask.js
@@ -53,12 +53,16 @@ function reduceMetamask (state, action) {
isUnlocked: false,
})
+ case actions.SET_RPC_LIST:
+ return extend(metamaskState, {
+ frequentRpcList: action.value,
+ })
+
case actions.SET_RPC_TARGET:
return extend(metamaskState, {
- frequentRpcList: action.value.frequentRpcList,
provider: {
type: 'rpc',
- rpcTarget: action.value.rpcTarget,
+ rpcTarget: action.value,
},
})