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

chore: migrate BridgeController to BaseController v2 #26109

Merged
merged 2 commits into from
Aug 15, 2024

Conversation

micaelae
Copy link
Member

@micaelae micaelae commented Jul 25, 2024

Description

Changes

  • split up bridge controller class into separate files
  • upgrade bridge controller implementation to extend BaseController V2

Open in GitHub Codespaces

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/METABRIDGE-866

Manual testing steps

  1. No user-facing changes so just verify that tests pass

Screenshots/Recordings

Before

N/A

After

N/A

Pre-merge author checklist

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.

@micaelae micaelae requested a review from a team as a code owner July 25, 2024 01:41
@micaelae micaelae marked this pull request as draft July 25, 2024 01:41
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

The migration of BridgeController to BaseController v2 introduces significant architectural updates to improve maintainability and scalability.

  • File Deletions and Additions:

    • Removed app/scripts/controllers/bridge.ts and bridge.test.ts.
    • Added app/scripts/controllers/bridge/bridge-controller.ts and bridge-controller.test.ts.
  • State Management:

    • Introduced app/scripts/controllers/bridge/constants.ts and types.ts for defining constants and types.
    • Updated app/scripts/lib/setupSentry.js and metamask-controller.js to integrate new state properties.
  • Testing Enhancements:

    • Modified test/e2e/default-fixture.js and mock-e2e.js to include new properties for network allowlists.
    • Added comprehensive unit tests in ui/ducks/bridge/selectors.test.ts.
  • Utility and Selector Updates:

    • Enhanced ui/pages/bridge/bridge.util.ts and bridge.util.test.ts for new feature flags.
    • Introduced new selectors in ui/ducks/bridge/selectors.ts.
  • Redux and Mock Store:

    • Updated ui/ducks/bridge/actions.ts, bridge.ts, and bridge.test.ts for new state management.
    • Enhanced test/jest/mock-store.js for flexible state customization.

24 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

@metamaskbot
Copy link
Collaborator

Builds ready [d035314]
Page Load Metrics (75 ± 11 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint681771062814
domContentLoaded96334157
load39129752311
domInteractive96334157
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 3.33 KiB (0.10%)
  • ui: 8.58 KiB (0.11%)
  • common: 1.03 KiB (0.02%)

@micaelae micaelae marked this pull request as ready for review July 25, 2024 23:52
ejwessel
ejwessel previously approved these changes Jul 26, 2024
},
};

export default class BridgeController extends BaseController<
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to keep this controller on the extension or should we move it to the core monorepo?

BZahory
BZahory previously approved these changes Jul 26, 2024
@micaelae micaelae force-pushed the mb867-bridge-feature-flagged-route-e2e-test branch from dda7956 to b4bf964 Compare August 6, 2024 19:53
@micaelae micaelae requested a review from a team as a code owner August 6, 2024 19:53
@micaelae micaelae force-pushed the mb866-bridge-controller-v2 branch 2 times, most recently from cfece3b to 23d035d Compare August 12, 2024 22:25
@micaelae micaelae removed the request for review from a team August 12, 2024 22:49
@metamaskbot
Copy link
Collaborator

Builds ready [23d035d]
Page Load Metrics (260 ± 234 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint683701296531
domContentLoaded10141483416
load421843260488234
domInteractive10141483416
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 3.33 KiB (0.09%)
  • ui: 8.58 KiB (0.12%)
  • common: 1.03 KiB (0.01%)

@micaelae micaelae force-pushed the mb867-bridge-feature-flagged-route-e2e-test branch from f467c34 to 2c2b366 Compare August 14, 2024 00:16
micaelae added a commit that referenced this pull request Aug 14, 2024
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**
This change adds a placeholder route for the cross-chain swaps
experience (roughly based on swaps page). Clicking on the Bridge button
should link to the route when the feature flag is turned on. Otherwise,
the portfolio bridge experience is loaded (current behavior)

New e2e tests: #25812

Migration to BaseController v2:
#26109

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/25481?quickstart=1)

## **Related issues**

Fixes:
[METABRIDGE-867](https://consensyssoftware.atlassian.net/browse/METABRIDGE-867)

## **Manual testing steps**

1. Build locally and set `BRIDGE_USE_DEV_APIS=1`
2. Check that bridge-api getAllFeatureFlags is fetched
3. Verify that bridgeState FF  is set to true in state logs
3. Click on Bridge button and verify Bridge page is visible
5. Build locally and set `BRIDGE_USE_DEV_APIS=0`
6. Wait ~10 minutes
7. Reload and Check that bridge-api getAllFeatureFlags is fetched
3. Verify that bridgeState FF  is set to false in state logs
8. Click on Bridge button and verify Portfolio URL is opened in a new
tab

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**
N/A

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->
![Screenshot 2024-07-12 at 3 44
34 PM](https://github.com/user-attachments/assets/9490eb40-8239-4aad-9a28-ed5624e2b51e)

## **Pre-merge author checklist**

- [X] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [X] I've completed the PR template to the best of my ability
- [X] I’ve included tests if applicable
- [X] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ X] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **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.


[METABRIDGE-867]:
https://consensyssoftware.atlassian.net/browse/METABRIDGE-867?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
@micaelae micaelae force-pushed the mb867-bridge-feature-flagged-route-e2e-test branch from 2c2b366 to eff057b Compare August 14, 2024 19:01
@micaelae micaelae changed the base branch from mb867-bridge-feature-flagged-route-e2e-test to develop August 14, 2024 19:10
@micaelae micaelae dismissed stale reviews from BZahory and ejwessel August 14, 2024 19:10

The base branch was changed.

@micaelae micaelae changed the base branch from develop to mb867-bridge-feature-flagged-route-e2e-test August 14, 2024 19:10
@metamaskbot
Copy link
Collaborator

Builds ready [e118e91]
Page Load Metrics (77 ± 15 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint652731124421
domContentLoaded97930199
load41176773115
domInteractive97930199
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 9.88 KiB (0.27%)
  • ui: 18 Bytes (0.00%)
  • common: -7.91 KiB (-0.11%)

Copy link

codecov bot commented Aug 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.03%. Comparing base (bf01aaf) to head (bc0be06).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #26109   +/-   ##
========================================
  Coverage    70.02%   70.03%           
========================================
  Files         1425     1426    +1     
  Lines        50029    50036    +7     
  Branches     13883    13883           
========================================
+ Hits         35032    35039    +7     
  Misses       14997    14997           

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

@micaelae micaelae force-pushed the mb867-bridge-feature-flagged-route-e2e-test branch from eff057b to 54a78d0 Compare August 14, 2024 19:47
Base automatically changed from mb867-bridge-feature-flagged-route-e2e-test to develop August 14, 2024 21:21
@metamaskbot
Copy link
Collaborator

Builds ready [65c14a6]
Page Load Metrics (76 ± 12 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint922591133517
domContentLoaded166434147
load46172762512
domInteractive166434147
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 9.88 KiB (0.27%)
  • ui: 18 Bytes (0.00%)
  • common: -8.06 KiB (-0.11%)

Copy link

sonarcloud bot commented Aug 14, 2024

@metamaskbot
Copy link
Collaborator

Builds ready [bc0be06]
Page Load Metrics (241 ± 228 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint833791156330
domContentLoaded1094312110
load491657241474228
domInteractive1094312110
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 9.88 KiB (0.27%)
  • ui: 18 Bytes (0.00%)
  • common: -8.06 KiB (-0.11%)

@micaelae micaelae merged commit c37451d into develop Aug 15, 2024
77 of 78 checks passed
@micaelae micaelae deleted the mb866-bridge-controller-v2 branch August 15, 2024 00:25
@github-actions github-actions bot locked and limited conversation to collaborators Aug 15, 2024
@metamaskbot metamaskbot added the release-12.4.0 Issue or pull request that will be included in release 12.4.0 label Aug 15, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [bc0be06]
Page Load Metrics (158 ± 158 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint763661176029
domContentLoaded167933168
load451577158329158
domInteractive167933168
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 9.88 KiB (0.27%)
  • ui: 18 Bytes (0.00%)
  • common: -8.06 KiB (-0.11%)

@gauthierpetetin gauthierpetetin added release-12.3.0 Issue or pull request that will be included in release 12.3.0 and removed release-12.4.0 Issue or pull request that will be included in release 12.4.0 labels Sep 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.3.0 Issue or pull request that will be included in release 12.3.0 team-bridge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants