diff options
Diffstat (limited to 'ui')
-rw-r--r-- | ui/app/actions.js | 10 | ||||
-rw-r--r-- | ui/app/config.js | 29 | ||||
-rw-r--r-- | ui/app/reducers/metamask.js | 12 |
3 files changed, 45 insertions, 6 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js index 5c5805c29..dbcf3e577 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -77,10 +77,12 @@ var actions = { // config screen SHOW_CONFIG_PAGE: 'SHOW_CONFIG_PAGE', SET_RPC_TARGET: 'SET_RPC_TARGET', + SET_PROVIDER_TYPE: 'SET_PROVIDER_TYPE', USE_ETHERSCAN_PROVIDER: 'USE_ETHERSCAN_PROVIDER', useEtherscanProvider: useEtherscanProvider, showConfigPage: showConfigPage, setRpcTarget: setRpcTarget, + setProviderType: setProviderType, // hacky - need a way to get a reference to account manager _setAccountManager: _setAccountManager, // loading overlay @@ -369,6 +371,14 @@ function setRpcTarget(newRpc) { } } +function setProviderType(type) { + _accountManager.setProviderType(type) + return { + type: this.SET_PROVIDER_TYPE, + value: type, + } +} + function useEtherscanProvider() { _accountManager.useEtherscanProvider() return { diff --git a/ui/app/config.js b/ui/app/config.js index ded065bf8..ddf158325 100644 --- a/ui/app/config.js +++ b/ui/app/config.js @@ -84,7 +84,7 @@ ConfigScreen.prototype.render = function() { }, onClick(event) { event.preventDefault() - state.dispatch(actions.setRpcTarget('https://rpc.metamask.io/')) + state.dispatch(actions.setProviderType('mainnet')) } }, 'Use Main Network') ]), @@ -96,7 +96,7 @@ ConfigScreen.prototype.render = function() { }, onClick(event) { event.preventDefault() - state.dispatch(actions.setRpcTarget('https://testrpc.metamask.io/')) + state.dispatch(actions.setProviderType('testnet')) } }, 'Use Morden Test Network') ]), @@ -120,9 +120,28 @@ ConfigScreen.prototype.render = function() { } function currentProviderDisplay(metamaskState) { - var rpc = metamaskState.provider.rpcTarget + var provider = metamaskState.provider + var title, value + + switch (provider.type) { + + case 'mainnet': + title = 'Current Network' + value = 'Main Ethereum Network' + break + + case 'testnet': + title = 'Current Network' + value = 'Morden Test Network' + break + + default: + title = 'Current RPC' + value = metamaskState.provider.rpcTarget + } + return h('div', [ - h('span', {style: { fontWeight: 'bold', paddingRight: '10px'}}, 'Current RPC'), - h('span', rpc) + h('span', {style: { fontWeight: 'bold', paddingRight: '10px'}}, title), + h('span', value) ]) } diff --git a/ui/app/reducers/metamask.js b/ui/app/reducers/metamask.js index 2fe96c453..9398f1497 100644 --- a/ui/app/reducers/metamask.js +++ b/ui/app/reducers/metamask.js @@ -38,7 +38,17 @@ function reduceMetamask(state, action) { case actions.SET_RPC_TARGET: return extend(metamaskState, { - rpcTarget: action.value, + provider: { + type: 'rpc', + rpcTarget: action.value, + }, + }) + + case actions.SET_PROVIDER_TYPE: + return extend(metamaskState, { + provider: { + type: action.value, + }, }) case actions.COMPLETED_TX: |