Skip to content

Commit

Permalink
feat(TXL-435): turn smart transactions on by default for new users (#…
Browse files Browse the repository at this point in the history
…27885)

## **Description**
This PR:
* enables smart transactions by default for new users
* prevents the smart transaction opt-in modal from appearing

To enable stx by default, we needed to replace the
`getSmartTransactionsOptInStatus` selector with two distinct selectors:

- `getSmartTransactionsOptInStatusForMetrics`
- `getSmartTransactionsPreferenceEnabled` 

Previously, the `getSmartTransactionsOptInStatus` selector was doing
double duty for the user's opt-in status and deciding whether the
preference was enabled. Since the feature was disabled by default, and a
user that has not opted-in or out of smart transactions has an opt-in
status of null, this did not pose a problem.

However, since we decided to enable smart transactions by default, we
needed a separate selector for checking the preference for deciding to
enable stx.

### Why not keep the `getSmartTransactionsOptInStatus` selector as-is
and just add a new one?
We considered keeping the `getSmartTransactionsOptInStatus` selector and
adding a new one. However, by renaming it to
`getSmartTransactionsOptInStatusForMetrics`, we avoid any confusion and
make it clear that it is used for metrics collection and not for user
preference handling.

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

## **Related issues**

Fixes: https://consensyssoftware.atlassian.net/browse/TXL-435

## **Manual testing steps**

1. add an account with funds on mainnet
2. opt-in modal does not display
3. transfer 0ETH to yourself uses smart transaction
4. preferences toggle starts enabled
5. set preferences toggle off
6. transfer 0ETH to yourself uses regular transaction

## **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 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).
- [ ] 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.
  • Loading branch information
dbrans authored Oct 17, 2024
1 parent dc48117 commit 93fbaaf
Show file tree
Hide file tree
Showing 23 changed files with 426 additions and 265 deletions.
4 changes: 2 additions & 2 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ import {
getIsSmartTransaction,
isHardwareWallet,
getFeatureFlagsByChainId,
getSmartTransactionsOptInStatus,
getCurrentChainSupportsSmartTransactions,
getHardwareWalletType,
getSmartTransactionsPreferenceEnabled,
} from '../../shared/modules/selectors';
import { createCaipStream } from '../../shared/modules/caip-stream';
import { BaseUrl } from '../../shared/constants/urls';
Expand Down Expand Up @@ -1904,7 +1904,7 @@ export default class MetamaskController extends EventEmitter {
isResubmitEnabled: () => {
const state = this._getMetaMaskState();
return !(
getSmartTransactionsOptInStatus(state) &&
getSmartTransactionsPreferenceEnabled(state) &&
getCurrentChainSupportsSmartTransactions(state)
);
},
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@
"@babel/preset-react": "^7.22.15",
"@babel/preset-typescript": "^7.23.2",
"@babel/register": "^7.22.15",
"@jest/globals": "^29.7.0",
"@lavamoat/allow-scripts": "^3.0.4",
"@lavamoat/lavadome-core": "0.0.10",
"@lavamoat/lavapack": "^6.1.0",
Expand Down
Loading

0 comments on commit 93fbaaf

Please sign in to comment.