From d8bee4f5992c5a1d0851e87c49e13c97d9279411 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 10 May 2016 15:37:13 -0700 Subject: Make default providers more easiliy configurable for metamask devs No longer do our `mainnet` and `testnet` buttons set specific RPC urls. Now they set `provider.type`, which gets interpreted with code. Currently the provider types of `mainnet` and `testnet` point to our new scalable backends, but these could be re-interpreted to use any other provider, be it etherscan, peer to peer, or otherwise. Makes it easier for us to upgrade our infrastructure without incorporating migration logic into the program. --- ui/app/config.js | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'ui/app/config.js') 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) ]) } -- cgit v1.2.3