Skip to content

Commit

Permalink
Never disable save button if props chain ID is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
rekmarks committed Nov 5, 2020
1 parent 3dbf5db commit 929a140
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit 929a140

Please sign in to comment.