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/preferences controller smart tx opt in #3815

Merged
merged 8 commits into from
May 22, 2024

Conversation

infiniteflower
Copy link
Contributor

@infiniteflower infiniteflower commented Jan 22, 2024

Explanation

This PR introduces a new state property smartTransactionsOptInStatus to the PreferencesController. This property allows the user to opt in or opt out of smart transactions.

This is to match changes introduced by the patch in Mobile MetaMask/metamask-mobile#9448

Changes:

  1. Added smartTransactionsOptInStatus to the PreferencesController state.
  2. Added a new method smartTransactionsOptInStatus to update the smartTransactionsOptInStatus state.
  3. Updated the PreferencesController tests to include tests for smartTransactionsOptInStatus and to check the default state of smartTransactionsOptInStatus.

Test Plan:

  1. Run the updated tests for PreferencesController using the command yarn workspace @metamask/preferences-controller run test.
  2. Ensure all tests pass successfully.

References

Related to MetaMask/metamask-mobile#8337

Changelog

@metamask/preferences-controller

  • Added preference to enable smart transactions

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

@infiniteflower infiniteflower marked this pull request as ready for review April 30, 2024 15:57
@infiniteflower infiniteflower requested a review from a team as a code owner April 30, 2024 15:57
@infiniteflower infiniteflower force-pushed the feat/preferences-controller-smart-tx-opt-in branch from 5f7c06e to df58f16 Compare April 30, 2024 17:27
@infiniteflower infiniteflower requested a review from legobeat May 1, 2024 19:00
mikesposito
mikesposito previously approved these changes May 15, 2024
Copy link
Member

@mikesposito mikesposito left a comment

Choose a reason for hiding this comment

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

A couple of optional suggestions, but this looks good!

infiniteflower added a commit to MetaMask/metamask-mobile that referenced this pull request May 16, 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**

<!--
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?
-->

This PR only covers a smaller subset of the files from #9565 for ease of
reviewing. Please refer to that issue for videos. This PR is mostly for
Engine and the views for Smart Transactions (STX). Merging this PR will
cause changes to the functionality and behavior of the app, effectively
making the feature "live".

It covers the following areas:
1. `app/components`
2. `app/core`
3. `app/reducers`
4. `app/selectors`
5. `app/util/test`
6. `patches`
- `PreferencesController` ([PR
here](MetaMask/core#3815) to apply update to
`main`)
- `SwapsController` ([PR
here](MetaMask/swaps-controller#229) to apply
updates to `main`)

Also fixed an issue for network onboarding where it would never set
onboarded to `true`. This needed to be fixed so we could properly show
the STX Opt In Modal. We only show the Opt In modal if the user has
onboarded onto the network, to prevent multiple modals from showing up
at the same time. See discussion
#9448 (comment)

## **Related issues**

Fixes: n/a
- Targeting: #9442
- Broken out from: #9565

## **Manual testing steps**

Refer to #9565

## **Screenshots/Recordings**

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

Refer to #9565

### **Before**

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

### **After**

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

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.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-mobile/blob/main/.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.

---------

Co-authored-by: tommasini <[email protected]>
Co-authored-by: Vinicius Stevam <[email protected]>
Andepande pushed a commit to MetaMask/metamask-mobile that referenced this pull request May 21, 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**

<!--
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?
-->

This PR only covers a smaller subset of the files from #9565 for ease of
reviewing. Please refer to that issue for videos. This PR is mostly for
Engine and the views for Smart Transactions (STX). Merging this PR will
cause changes to the functionality and behavior of the app, effectively
making the feature "live".

It covers the following areas:
1. `app/components`
2. `app/core`
3. `app/reducers`
4. `app/selectors`
5. `app/util/test`
6. `patches`
- `PreferencesController` ([PR
here](MetaMask/core#3815) to apply update to
`main`)
- `SwapsController` ([PR
here](MetaMask/swaps-controller#229) to apply
updates to `main`)

Also fixed an issue for network onboarding where it would never set
onboarded to `true`. This needed to be fixed so we could properly show
the STX Opt In Modal. We only show the Opt In modal if the user has
onboarded onto the network, to prevent multiple modals from showing up
at the same time. See discussion
#9448 (comment)

## **Related issues**

Fixes: n/a
- Targeting: #9442
- Broken out from: #9565

## **Manual testing steps**

Refer to #9565

## **Screenshots/Recordings**

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

Refer to #9565

### **Before**

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

### **After**

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

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.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-mobile/blob/main/.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.

---------

Co-authored-by: tommasini <[email protected]>
Co-authored-by: Vinicius Stevam <[email protected]>
Copy link
Member

@mikesposito mikesposito left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@cryptodev-2s cryptodev-2s left a comment

Choose a reason for hiding this comment

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

LGTM!

@infiniteflower infiniteflower merged commit 7296d92 into main May 22, 2024
147 checks passed
@infiniteflower infiniteflower deleted the feat/preferences-controller-smart-tx-opt-in branch May 22, 2024 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants