-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chainid migration #2161
chainid migration #2161
Conversation
Co-authored-by: Erik Marks <[email protected]>
app/store/migrations.js
Outdated
// If provider is rpc, check if the current network has a valid chainId | ||
const storedChainId = typeof provider.chainId === 'string' ? provider.chainId : ''; | ||
const isDecimalString = /^[1-9]\d*$/u.test(storedChainId); | ||
const isCustomRpcWithInvalidChainId = !isDecimalString || !isSafeChainId(parseInt(storedChainId, 10)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be renamed to hasInvalidChainId
since it's not only for custom networks.
app/store/migrations.js
Outdated
// If provider is rpc, check if the current network has a valid chainId | ||
const storedChainId = typeof provider.chainId === 'string' ? provider.chainId : ''; | ||
const isDecimalString = /^[1-9]\d*$/u.test(storedChainId); | ||
const isCustomRpcWithInvalidChainId = !isDecimalString || !isSafeChainId(parseInt(storedChainId, 10)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that we should change migration 2 at this point. I think it introduces more uncertainty for no benefit, since migration 3 will take care of any issues with migration 2.
At least in the extension, we've never changed a migration that's run in production, AFAIK.
@@ -47,7 +48,31 @@ export const migrations = { | |||
}; | |||
} | |||
return state; | |||
}, | |||
3: state => { | |||
const provider = state.engine.backgroundState.NetworkController.provider; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there ever a chance provider
will be undefined
? my guess is no, but maybe it'd be safer to use optional chaining for this property? eg:
state.engine.backgroundState.NetworkController?.provider
wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it'll ever be anything other than an object, but investigating the matter did lead me to this discovery: #2164
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding optional chaining is obviously harmless so I'm fine with it either way!
My requested changes have been addressed, by I'll let a mobile dev approve, because there are changes unrelated to the migration that I don't understand. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QA Passed 👍🏽
This reverts commit cdceb58.
…le into chainid-migration
* chainidmigration * Update app/store/migrations.js Co-authored-by: Erik Marks <[email protected]> * migration2 * bump * logs * migrations * bump * circle * Revert "bump" This reverts commit cdceb58. Co-authored-by: Erik Marks <[email protected]>
* chainidmigration * Update app/store/migrations.js Co-authored-by: Erik Marks <[email protected]> * migration2 * bump * logs * migrations * bump * circle * Revert "bump" This reverts commit cdceb58. Co-authored-by: Erik Marks <[email protected]>
Description
Write a short description of the changes included in this pull request.
Checklist
Issue
Resolves #???