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

fix: Network not updating when changing account connected the first time on a DAPP #9021

Merged
merged 3 commits into from
Mar 22, 2024

Conversation

tommasini
Copy link
Contributor

@tommasini tommasini commented Mar 21, 2024

Description

Updating the conditional case on BackgroundBridge onStateUpdate function to trigger notifyChainChanged, when the chainId changes and when the network changes, it will allow for both properties being sent when they are called more than once and they are miss matching. That was happening on the first switch of the network and causing the bug.

This fixes this issue: #9006

Related issues

Fixes:

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

https://recordit.co/FEycCcnZ92

Before

After

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've clearly explained what problem this PR is solving and how it is solved.
  • I've linked related issues
  • I've included manual testing steps
  • I've included screenshots/recordings if applicable
  • I’ve included tests if applicable
  • I’ve documented my code using JSDoc format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
  • I’ve properly set the pull request status:
    • In case it's not yet "ready for review", I've set it to "draft".
    • In case it's "ready for review", I've changed it from "draft" to "non-draft".

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@tommasini tommasini marked this pull request as ready for review March 21, 2024 11:53
@tommasini tommasini requested a review from a team as a code owner March 21, 2024 11:53
Copy link

sonarcloud bot commented Mar 21, 2024

Copy link
Contributor

@Cal-L Cal-L left a comment

Choose a reason for hiding this comment

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

Could you elaborate on how the network controller bump affected this logic?

@tommasini
Copy link
Contributor Author

Yes, the NetworkController changed the logic on how the state was being updated on version 12, and that seems to be impacting how the dapp receive data, what's happening is that the dapp is receiving data with the networkId and chainId on different times, because the networkId at certain point in time is null when the network changes (Because it's still being fetched) and because of that was not updating on the first change.

On NetworkController V13 (Next Major version) the core repo will not expose the networkId in the network state, so where we need this networkId data we will need to fetch it
This how extension does it: https://github.com/MetaMask/metamask-extension/blob/4604c23100adf406aea764e19fa3087f5263bfdd/app/scripts/metamask-controller.js#L2773

Copy link
Contributor

@Cal-L Cal-L left a comment

Choose a reason for hiding this comment

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

LGTM

@tommasini tommasini added the Run Smoke E2E Triggers smoke e2e on Bitrise label Mar 21, 2024
Copy link
Contributor

github-actions bot commented Mar 21, 2024

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: cc811ee
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/5cac29cd-4ec8-4ac2-bfd8-e1c2d893144d

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

@tommasini tommasini merged commit 370fd81 into main Mar 22, 2024
37 checks passed
@tommasini tommasini deleted the fix/9006-network-not-updating-dapp branch March 22, 2024 00:54
@github-actions github-actions bot locked and limited conversation to collaborators Mar 22, 2024
@metamaskbot metamaskbot added the release-7.20.0 Issue or pull request that will be included in release 7.20.0 label Mar 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-7.20.0 Issue or pull request that will be included in release 7.20.0 Run Smoke E2E Triggers smoke e2e on Bitrise team-mobile-platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants