From efd36adaac9b7740bd8c94b06d78c28b20658d30 Mon Sep 17 00:00:00 2001 From: Erik Marks <25517051+rekmarks@users.noreply.github.com> Date: Thu, 5 Nov 2020 14:57:11 -0800 Subject: [PATCH] Never disable save button if props chain ID is invalid (#9808) --- .../network-form/network-form.component.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/ui/app/pages/settings/networks-tab/network-form/network-form.component.js b/ui/app/pages/settings/networks-tab/network-form/network-form.component.js index 83d506420..055e95d49 100644 --- a/ui/app/pages/settings/networks-tab/network-form/network-form.component.js +++ b/ui/app/pages/settings/networks-tab/network-form/network-form.component.js @@ -198,7 +198,13 @@ export default class NetworkForm extends PureComponent { } stateIsUnchanged() { - const { rpcUrl, ticker, networkName, blockExplorerUrl } = this.props + const { + rpcUrl, + chainId: propsChainId, + ticker, + networkName, + blockExplorerUrl, + } = this.props const { rpcUrl: stateRpcUrl, @@ -208,9 +214,17 @@ export default class NetworkForm extends PureComponent { blockExplorerUrl: stateBlockExplorerUrl, } = this.state + // These added conditions are in case the saved chainId is invalid, which + // was possible in versions <8.1 of the extension. + // Basically, we always want to be able to overwrite an invalid chain ID. + const chainIdIsUnchanged = + typeof propsChainId === 'string' && + propsChainId.toLowerCase().startsWith('0x') && + stateChainId === this.getDisplayChainIdFromProps() + return ( stateRpcUrl === rpcUrl && - stateChainId === this.getDisplayChainIdFromProps() && + chainIdIsUnchanged && stateTicker === ticker && stateNetworkName === networkName && stateBlockExplorerUrl === blockExplorerUrl