diff options
network - convert localhost from custom rpc to network type
-rw-r--r-- | app/scripts/config.js | 2 | ||||
-rw-r--r-- | app/scripts/controllers/network.js | 1 | ||||
-rw-r--r-- | app/scripts/metamask-controller.js | 7 | ||||
-rw-r--r-- | ui/app/actions.js | 23 | ||||
-rw-r--r-- | ui/app/app.js | 2 |
5 files changed, 12 insertions, 23 deletions
diff --git a/app/scripts/config.js b/app/scripts/config.js index c5f260583..1d4ff7c0d 100644 --- a/app/scripts/config.js +++ b/app/scripts/config.js @@ -2,11 +2,13 @@ const MAINET_RPC_URL = 'https://mainnet.infura.io/metamask' const ROPSTEN_RPC_URL = 'https://ropsten.infura.io/metamask' const KOVAN_RPC_URL = 'https://kovan.infura.io/metamask' const RINKEBY_RPC_URL = 'https://rinkeby.infura.io/metamask' +const LOCALHOST_RPC_URL = 'http://localhost:8545' global.METAMASK_DEBUG = 'GULP_METAMASK_DEBUG' module.exports = { network: { + localhost: LOCALHOST_RPC_URL, mainnet: MAINET_RPC_URL, ropsten: ROPSTEN_RPC_URL, kovan: KOVAN_RPC_URL, diff --git a/app/scripts/controllers/network.js b/app/scripts/controllers/network.js index 9e05afe75..9079e0653 100644 --- a/app/scripts/controllers/network.js +++ b/app/scripts/controllers/network.js @@ -10,6 +10,7 @@ const RPC_ADDRESS_LIST = require('../config.js').network const DEFAULT_RPC = RPC_ADDRESS_LIST['rinkeby'] module.exports = class NetworkController extends EventEmitter { + constructor (config) { super() config.provider.rpcTarget = this.getRpcAddressForType(config.provider.type, config.provider) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index fa6f1a245..eb978115d 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -336,7 +336,6 @@ module.exports = class MetamaskController extends EventEmitter { // network management setProviderType: nodeify(networkController.setProviderType, networkController), - setDefaultRpc: nodeify(this.setDefaultRpc, this), setCustomRpc: nodeify(this.setCustomRpc, this), // PreferencesController @@ -696,12 +695,6 @@ module.exports = class MetamaskController extends EventEmitter { // network - async setDefaultRpc () { - const localhost = 'http://localhost:8545' - this.networkController.setRpcTarget(localhost) - return localhost - } - async setCustomRpc (rpcTarget, rpcList) { this.networkController.setRpcTarget(rpcTarget) await this.preferencesController.updateFrequentRpcList(rpcTarget) diff --git a/ui/app/actions.js b/ui/app/actions.js index e793e6a21..4844dd56e 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -126,7 +126,6 @@ var actions = { showAddTokenPage, addToken, setRpcTarget: setRpcTarget, - setDefaultRpcTarget: setDefaultRpcTarget, setProviderType: setProviderType, // loading overlay SHOW_LOADING: 'SHOW_LOADING_INDICATION', @@ -706,16 +705,19 @@ function markAccountsFound () { // config // -// default rpc target refers to localhost:8545 in this instance. -function setDefaultRpcTarget () { - log.debug(`background.setDefaultRpcTarget`) +function setProviderType (type) { return (dispatch) => { - background.setDefaultRpc((err, result) => { + log.debug(`background.setProviderType`) + background.setProviderType(type, (err, result) => { if (err) { log.error(err) - return dispatch(self.displayWarning('Had a problem changing networks.')) + return dispatch(self.displayWarning('Had a problem changing networks!')) } }) + return { + type: actions.SET_PROVIDER_TYPE, + value: type, + } } } @@ -744,15 +746,6 @@ function addToAddressBook (recipient, nickname) { } } -function setProviderType (type) { - log.debug(`background.setProviderType`) - background.setProviderType(type) - return { - type: actions.SET_PROVIDER_TYPE, - value: type, - } -} - function useEtherscanProvider () { log.debug(`background.useEtherscanProvider`) background.useEtherscanProvider() diff --git a/ui/app/app.js b/ui/app/app.js index ee800ea90..50121b055 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -319,7 +319,7 @@ App.prototype.renderNetworkDropdown = function () { { key: 'default', closeMenu: () => this.setState({ isNetworkMenuOpen: !isOpen }), - onClick: () => props.dispatch(actions.setDefaultRpcTarget()), + onClick: () => props.dispatch(actions.setProviderType('localhost')), style: { fontSize: '18px', }, |