Skip to content
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

Merged
merged 11 commits into from
Jan 25, 2021
Merged

chainid migration #2161

merged 11 commits into from
Jan 25, 2021

Conversation

estebanmino
Copy link
Contributor

Description

Write a short description of the changes included in this pull request.

Checklist

  • There is a related GitHub issue
  • Tests are included if applicable
  • Any added code is fully documented

Issue

Resolves #???

@estebanmino estebanmino requested a review from a team as a code owner January 23, 2021 17:51
app/store/migrations.js Outdated Show resolved Hide resolved
// 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));
Copy link
Member

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.

Comment on lines 39 to 42
// 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));
Copy link
Member

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;
Copy link
Contributor

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?

Copy link
Member

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

Copy link
Member

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!

@rekmarks
Copy link
Member

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.

Copy link
Contributor

@ibrahimtaveras00 ibrahimtaveras00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QA Passed 👍🏽

@ibrahimtaveras00 ibrahimtaveras00 added the QA Passed A successful QA run through has been done label Jan 25, 2021
@estebanmino estebanmino merged commit 99959d0 into develop Jan 25, 2021
@estebanmino estebanmino deleted the chainid-migration branch January 25, 2021 20:10
estebanmino added a commit that referenced this pull request Jan 25, 2021
* 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]>
@estebanmino estebanmino mentioned this pull request Feb 11, 2021
3 tasks
rickycodes pushed a commit that referenced this pull request Jan 31, 2022
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next release QA Passed A successful QA run through has been done
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants