Add MAX_SAFE_CHAIN_ID and refactor chain ID validation#10224
Merged
Add MAX_SAFE_CHAIN_ID and refactor chain ID validation#10224
Conversation
Adds chainId validation to NetworkController.setRpcTarget. Currently we validate custom network chainIds in the UI, but we would do well to add some redundancy in the background. Also updates some network controller error messages.
Collaborator
Builds ready [b150a5a]
Page Load Metrics (537 ± 67 ms)
|
Gudahtt
reviewed
Jan 21, 2021
| sufficientBalance, | ||
| isPrefixedFormattedHexString, | ||
| } from '../../../app/scripts/lib/util' | ||
| import { isPrefixedFormattedHexString } from '../../../shared/modules/utils' |
Member
There was a problem hiding this comment.
Nit: These tests should be moved to a different file 😅
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MAX_SAFE_CHAIN_IDconstant toshared/constantsshared/modules/utils.jsisSafeChainIdfunction to this fileisPrefixedFormattedHexStringto this fileisSafeChainIdvalidation to UI chain ID validationisSafeChainIdvalidation calls to network controllersetRpcTargetis called in a number of places, and for the safety of our users, we should ensure they can't switch to networks without valid chain IDs.