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

feat: stx optInModalMinVersion feature flag - UI part #24727

Closed
wants to merge 12 commits into from

Conversation

dbrans
Copy link
Contributor

@dbrans dbrans commented May 22, 2024

Note

This PR is intended to be cherry-picked into v11.16.x

Description

The smartTransactions.optInModalMinVersion feature flag on the swaps api is a string of the form "major.minor.patch". The stx opt-in modal is blocked unless optInModalMinVersion is:

  1. present and
  2. valid and
  3. the extension version >= optInModalMinVersion.

To support this new feature flag, this PR also makes the following material changes:

The reason we have been loading swaps feature flags in the ui - and not the background - is unclear. I will ask @dan437 when he is back.

Open in GitHub Codespaces

Related issues

Fixes:

Manual testing steps

  1. overrode the swaps api response in chrome devtools with different optInModalMinVersion values.
  2. Confirmed we either show the What's New popup or the stx opt-in modal as expected, based on the value of optInModalMinVersion.

Screenshots/Recordings

Before

After

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've completed the PR template to the best of my ability
  • 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.

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.

@dbrans dbrans added the team-transactions Transactions team label May 22, 2024
@dbrans dbrans marked this pull request as ready for review May 22, 2024 21:21
@dbrans dbrans requested a review from a team as a code owner May 22, 2024 21:21
## **Description**
Bump transaction controller to get a couple fixes in.

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

## **Related issues**

Fixes: #24586
Fixes: #24183
Related: #24359
@keithchew to verify

## **Manual testing steps**

1. Go to this page...
2.
3.

## **Screenshots/Recordings**

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

### **Before**

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

### **After**

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

## **Pre-merge author checklist**

- [ ] I’ve followed [MetaMask Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] 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.
Copy link
Contributor

@legobeat legobeat left a comment

Choose a reason for hiding this comment

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

This failing unit test looks related:

$ yarn test:coverage:jest

[...] 

Summary of all failing tests
FAIL ui/pages/routes/routes.component.test.js (25.163 s)
  ● Routes Component › render during send flow › should render when send transaction is not active

    TypeError: Cannot read properties of undefined (reading 'isFeatureFlagLoaded')

      249 |
      250 | export const getIsFeatureFlagLoaded = (state) =>
    > 251 |   state.swaps.isFeatureFlagLoaded;
          |               ^
      252 |
      253 | export const getSwapsSTXLoading = (state) => state.swaps.swapsSTXLoading;
      254 |

      at isFeatureFlagLoaded (ui/ducks/swaps/swaps.js:251:15)
      at Function.mapStateToProps [as mapToProps] (ui/pages/home/home.container.js:155:27)
      at mapToPropsProxy (node_modules/react-redux/lib/connect/wrapMapToProps.js:53:92)
      at Function.detectFactoryAndVerify (node_modules/react-redux/lib/connect/wrapMapToProps.js:62:19)
      at mapToPropsProxy (node_modules/react-redux/lib/connect/wrapMapToProps.js:53:46)
      at handleFirstCall (node_modules/react-redux/lib/connect/selectorFactory.js:34:18)
      at pureFinalPropsSelector (node_modules/react-redux/lib/connect/selectorFactory.js:75:81)
      at node_modules/react-redux/lib/components/connectAdvanced.js:333:16
      at mountMemo (node_modules/react-dom/cjs/react-dom.development.js:16833:19)
      at Object.useMemo (node_modules/react-dom/cjs/react-dom.development.js:17152:16)
      at useMemo (node_modules/react/cjs/react.development.js:1521:21)
      at ConnectFunction (node_modules/react-redux/lib/components/connectAdvanced.js:318:30)
      at renderWithHooks (node_modules/react-dom/cjs/react-dom.development.js:16260:18)
      at updateFunctionComponent (node_modules/react-dom/cjs/react-dom.development.js:18347:20)
      at updateSimpleMemoComponent (node_modules/react-dom/cjs/react-dom.development.js:18285:10)
      at updateMemoComponent (node_modules/react-dom/cjs/react-dom.development.js:18188:14)
      at beginWork$1 (node_modules/react-dom/cjs/react-dom.development.js:20248:16)
      at HTMLUnknownElement.callCallback (node_modules/react-dom/cjs/react-dom.development.js:336:14)
      at Object.invokeGuardedCallbackDev (node_modules/react-dom/cjs/react-dom.development.js:385:16)
      at invokeGuardedCallback (node_modules/react-dom/cjs/react-dom.development.js:440:31)
      at beginWork$$1 (node_modules/react-dom/cjs/react-dom.development.js:25780:7)
      at performUnitOfWork (node_modules/react-dom/cjs/react-dom.development.js:24698:12)
      at workLoopSync (node_modules/react-dom/cjs/react-dom.development.js:24671:22)
      at performSyncWorkOnRoot (node_modules/react-dom/cjs/react-dom.development.js:24270:11)
      at scheduleUpdateOnFiber (node_modules/react-dom/cjs/react-dom.development.js:23698:7)
      at updateContainer (node_modules/react-dom/cjs/react-dom.development.js:27103:3)
      at node_modules/react-dom/cjs/react-dom.development.js:27528:7
      at unbatchedUpdates (node_modules/react-dom/cjs/react-dom.development.js:24433:12)
      at legacyRenderSubtreeIntoContainer (node_modules/react-dom/cjs/react-dom.development.js:27527:5)
      at Object.render (node_modules/react-dom/cjs/react-dom.development.js:27608:10)
      at node_modules/@testing-library/react/dist/pure.js:100:25
      at batchedUpdates$1 (node_modules/react-dom/cjs/react-dom.development.js:24386:12)
      at act (node_modules/react-dom/cjs/react-dom-test-utils.development.js:1092:14)
      at render (node_modules/@testing-library/react/dist/pure.js:96:26)
      at renderWithProvider (test/jest/rendering.js:61:16)
      at ui/pages/routes/routes.component.test.js:79:45
      at batchedUpdates$1 (node_modules/react-dom/cjs/react-dom.development.js:24386:12)
      at act (node_modules/react-dom/cjs/react-dom-test-utils.development.js:1092:14)
      at render (ui/pages/routes/routes.component.test.js:78:12)
      at Object.render (ui/pages/routes/routes.component.test.js:180:37)


Test Suites: 1 failed, 92 passed, 93 total
Tests:       1 failed, 551 passed, 552 total
Snapshots:   62 passed, 62 total
Time:        107.588 s
Ran all test suites.

@dbrans dbrans marked this pull request as draft May 23, 2024 00:56
@dbrans dbrans marked this pull request as ready for review May 23, 2024 17:36
@metamaskbot
Copy link
Collaborator

Builds ready [a99f9db]
Page Load Metrics (1074 ± 584 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint602201154522
domContentLoaded98021178
load49290510741217584
domInteractive98020178
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 170 Bytes (0.00%)
  • common: 1.69 KiB (0.03%)

Copy link

codecov bot commented May 23, 2024

Codecov Report

Attention: Patch coverage is 82.50000% with 7 lines in your changes are missing coverage. Please review.

Project coverage is 66.01%. Comparing base (38199bb) to head (b7810eb).
Report is 3 commits behind head on develop.

Files Patch % Lines
shared/modules/feature-flags.ts 50.00% 3 Missing ⚠️
ui/index.js 0.00% 2 Missing ⚠️
shared/lib/semversion.ts 92.31% 1 Missing ⚠️
shared/modules/selectors/feature-flags.ts 66.67% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #24727      +/-   ##
===========================================
+ Coverage    66.01%   66.01%   +0.01%     
===========================================
  Files         1348     1349       +1     
  Lines        52499    52535      +36     
  Branches     13493    13500       +7     
===========================================
+ Hits         34652    34680      +28     
- Misses       17847    17855       +8     

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

@danjm
Copy link
Contributor

danjm commented Jun 27, 2024

Closing for now, we can re-open if we again decide we want something like this

@danjm danjm closed this Jun 27, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jun 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
team-transactions Transactions team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants