aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app
diff options
context:
space:
mode:
Diffstat (limited to 'ui/app')
-rw-r--r--ui/app/actions.js21
-rw-r--r--ui/app/components/dropdowns/network-dropdown.js3
-rw-r--r--ui/app/components/pages/settings/settings-tab/settings-tab.component.js1
-rw-r--r--ui/app/components/pages/settings/settings-tab/settings-tab.container.js4
4 files changed, 22 insertions, 7 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js
index c2622d0a0..2b073e915 100644
--- a/ui/app/actions.js
+++ b/ui/app/actions.js
@@ -242,6 +242,7 @@ var actions = {
removeSuggestedTokens,
addKnownMethodData,
UPDATE_TOKENS: 'UPDATE_TOKENS',
+ updateAndSetCustomRpc: updateAndSetCustomRpc,
setRpcTarget: setRpcTarget,
delRpcTarget: delRpcTarget,
setProviderType: setProviderType,
@@ -1971,10 +1972,26 @@ function setPreviousProvider (type) {
}
}
-function setRpcTarget (newRpc, chainId, ticker = 'ETH', nickname = '') {
+function updateAndSetCustomRpc (newRpc, chainId, ticker = 'ETH', nickname) {
+ return (dispatch) => {
+ log.debug(`background.updateAndSetCustomRpc: ${newRpc} ${chainId} ${ticker} ${nickname}`)
+ background.updateAndSetCustomRpc(newRpc, chainId, ticker, nickname || newRpc, (err, result) => {
+ if (err) {
+ log.error(err)
+ return dispatch(actions.displayWarning('Had a problem changing networks!'))
+ }
+ dispatch({
+ type: actions.SET_RPC_TARGET,
+ value: newRpc,
+ })
+ })
+ }
+}
+
+function setRpcTarget (newRpc, chainId, ticker = 'ETH', nickname) {
return (dispatch) => {
log.debug(`background.setRpcTarget: ${newRpc} ${chainId} ${ticker} ${nickname}`)
- background.setCustomRpc(newRpc, chainId, ticker, nickname, (err, result) => {
+ background.setCustomRpc(newRpc, chainId, ticker, nickname || newRpc, (err, result) => {
if (err) {
log.error(err)
return dispatch(actions.displayWarning('Had a problem changing networks!'))
diff --git a/ui/app/components/dropdowns/network-dropdown.js b/ui/app/components/dropdowns/network-dropdown.js
index d4cc695a6..6e002219a 100644
--- a/ui/app/components/dropdowns/network-dropdown.js
+++ b/ui/app/components/dropdowns/network-dropdown.js
@@ -277,7 +277,6 @@ NetworkDropdown.prototype.getNetworkName = function () {
NetworkDropdown.prototype.renderCommonRpc = function (rpcListDetail, provider) {
const props = this.props
const reversedRpcListDetail = rpcListDetail.slice().reverse()
- const network = props.network
return reversedRpcListDetail.map((entry) => {
const rpc = entry.rpcUrl
@@ -288,7 +287,7 @@ NetworkDropdown.prototype.renderCommonRpc = function (rpcListDetail, provider) {
if ((rpc === 'http://localhost:8545') || currentRpcTarget) {
return null
} else {
- const chainId = entry.chainId || network
+ const chainId = entry.chainId
return h(
DropdownMenuItem,
{
diff --git a/ui/app/components/pages/settings/settings-tab/settings-tab.component.js b/ui/app/components/pages/settings/settings-tab/settings-tab.component.js
index 16afa85cb..8cd596423 100644
--- a/ui/app/components/pages/settings/settings-tab/settings-tab.component.js
+++ b/ui/app/components/pages/settings/settings-tab/settings-tab.component.js
@@ -230,7 +230,6 @@ export default class SettingsTab extends PureComponent {
validateRpc (newRpc, chainId, ticker = 'ETH', nickname) {
const { setRpcTarget, displayWarning } = this.props
-
if (validUrl.isWebUri(newRpc)) {
if (!!chainId && Number.isNaN(parseInt(chainId))) {
return displayWarning(`${this.context.t('invalidInput')} chainId`)
diff --git a/ui/app/components/pages/settings/settings-tab/settings-tab.container.js b/ui/app/components/pages/settings/settings-tab/settings-tab.container.js
index b6c33a5b2..d5fd8416a 100644
--- a/ui/app/components/pages/settings/settings-tab/settings-tab.container.js
+++ b/ui/app/components/pages/settings/settings-tab/settings-tab.container.js
@@ -4,7 +4,7 @@ import { connect } from 'react-redux'
import { withRouter } from 'react-router-dom'
import {
setCurrentCurrency,
- setRpcTarget,
+ updateAndSetCustomRpc,
displayWarning,
revealSeedConfirmation,
setUseBlockie,
@@ -50,7 +50,7 @@ const mapStateToProps = state => {
const mapDispatchToProps = dispatch => {
return {
setCurrentCurrency: currency => dispatch(setCurrentCurrency(currency)),
- setRpcTarget: (newRpc, chainId, ticker, nickname) => dispatch(setRpcTarget(newRpc, chainId, ticker, nickname)),
+ setRpcTarget: (newRpc, chainId, ticker, nickname) => dispatch(updateAndSetCustomRpc(newRpc, chainId, ticker, nickname)),
displayWarning: warning => dispatch(displayWarning(warning)),
revealSeedConfirmation: () => dispatch(revealSeedConfirmation()),
setUseBlockie: value => dispatch(setUseBlockie(value)),