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

refactor: Refactor isTestNet to accept chain ID #7156

Merged
merged 2 commits into from
Sep 7, 2023
Merged

Conversation

Gudahtt
Copy link
Member

@Gudahtt Gudahtt commented Sep 6, 2023

Development & PR Process

  1. Follow MetaMask Mobile Coding Standards
  2. Add release-xx label to identify the PR slated for a upcoming release (will be used in release discussion)
  3. Add needs-dev-review label when work is completed
  4. Add the appropiate QA label when dev review is completed
    • needs-qa: PR requires manual QA.
    • No QA/E2E only: PR does not require any manual QA effort. Prior to merging, ensure that you have successful end-to-end test runs in Bitrise.
    • Spot check on release build: PR does not require feature QA but needs non-automated verification. In the description section, provide test scenarios. Add screenshots, and or recordings of what was tested.
  5. Add QA Passed label when QA has signed off (Only required if the PR was labeled with needs-qa)
  6. Add your team's label, i.e. label starting with team- (or external-contributor label if your not a MetaMask employee)

Description

The isTestNet utility function now accepts a chain ID rather than a network ID. The chain ID is easier for us to access because we know the chain ID for all networks statically, as it's a required network configuration property. The network ID on the other hand is looked up at runtime, and is sometimes not present.

In practice we had already been passing in chain ID as network ID in many places. This hasn't caused issues because they are equivalent for most (though not all) networks.

Issue

This relates to https://github.com/MetaMask/mobile-planning/issues/1226

Checklist

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

@Gudahtt Gudahtt added needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) team-mobile-platform labels Sep 6, 2023
@Gudahtt Gudahtt force-pushed the refactor-is-testnet branch from a805805 to f26746e Compare September 6, 2023 18:07
@Gudahtt Gudahtt marked this pull request as ready for review September 6, 2023 18:07
@Gudahtt Gudahtt requested a review from a team as a code owner September 6, 2023 18:07
@Gudahtt Gudahtt force-pushed the refactor-is-testnet branch from f26746e to e4ed547 Compare September 6, 2023 18:28
@codecov-commenter
Copy link

codecov-commenter commented Sep 6, 2023

Codecov Report

Patch coverage: 83.33% and project coverage change: -0.01% ⚠️

Comparison is base (4ca68b4) 32.84% compared to head (4f7ae41) 32.83%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7156      +/-   ##
==========================================
- Coverage   32.84%   32.83%   -0.01%     
==========================================
  Files        1006     1006              
  Lines       32731    32727       -4     
  Branches     8399     8396       -3     
==========================================
- Hits        10749    10745       -4     
  Misses      21982    21982              
Files Changed Coverage Δ
...pp/components/UI/ApproveTransactionReview/index.js 2.87% <0.00%> (ø)
...actionReview/TransactionReviewInformation/index.js 36.48% <100.00%> (ø)
app/components/Views/SendFlow/Confirm/index.js 43.31% <100.00%> (ø)
app/util/networks/index.js 72.09% <100.00%> (-0.64%) ⬇️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Gudahtt
Copy link
Member Author

Gudahtt commented Sep 6, 2023

The `isTestNet` utility function now accepts a chain ID rather than a
network ID. The chain ID is easier for us to access because we know the
chain ID for all networks statically, as it's a required network
configuration property. The network ID on the other hand is looked up
at runtime, and is sometimes not present.

In practice we had already been passing in chain ID as network ID in
many places This hasn't caused issues because they are equivalent for
most (though not all) networks.

This relates to MetaMask/mobile-planning#1226
This snapshot wasn't expected to change, but it seems to have been
affected due to invalid test fixtures  which had been missing the
network ID.
@Gudahtt Gudahtt force-pushed the refactor-is-testnet branch from c1d0708 to 4f7ae41 Compare September 7, 2023 12:49
@sonarqubecloud
Copy link

sonarqubecloud bot commented Sep 7, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

Copy link
Contributor

@sethkfman sethkfman left a comment

Choose a reason for hiding this comment

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

LGTM

@Gudahtt Gudahtt added No QA Needed Apply this label when your PR does not need any QA effort. and removed needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) labels Sep 7, 2023
@Gudahtt
Copy link
Member Author

Gudahtt commented Sep 7, 2023

Applying the E2E only test case because the scope of this change is quite small, and the affected area is covered by some E2E tests (e.g. the Send ERC Token suite, which sends tokens on Sepolia)

@Gudahtt Gudahtt merged commit eafdda1 into main Sep 7, 2023
@Gudahtt Gudahtt deleted the refactor-is-testnet branch September 7, 2023 15:31
@github-actions github-actions bot locked and limited conversation to collaborators Sep 7, 2023
@metamaskbot metamaskbot added the release-7.8.0 Issue or pull request that will be included in release 7.8.0 label Sep 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
No QA Needed Apply this label when your PR does not need any QA effort. release-7.8.0 Issue or pull request that will be included in release 7.8.0 team-mobile-platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants