-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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: enable STX by default with migration and notification #12857
base: main
Are you sure you want to change the base?
Conversation
- Enable STX for new users or those that have not enabled in settings - Preserves settings for users who explicitly opted out and have existing STX transactions - Adds a migration flag to track this change
…ror messages using team's established pattern.
- Mock Sentry error handling ensuring we can track when errors are captured - Setup `beforeEach()` restore/reset for all mocks - Define test cases for error handling - Each case has: invalid input state, expected error message, and description - Invalid States Test: how migration handles malformed data - Runs each invalid state test case - Verifies: Invalid state returns unchanged, Error is captured by Sentry, Error message matches expected format Also, Setup first test to ensure STX is enabled and migration flag is set when undefined opt-in status
- Null status test, similar to undefined opt-in status test - Tests migration with null status - Verifies that STX is enabled and migration flag is set
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. |
- create opt-out test - tests that users explicit opt-out is respected when STX transactions exist - verifies migration flag is set but preference is unchanged
- create opt-out test - tests that users explicit opt-out is respected when STX transactions exist - verifies migration flag is set but preference is unchanged
- tests that opt-out is overridden when user has no transaction history - verifies migration flag is set and preference is changed
- added test for initializing preferences - added test for when STX is already enabled - use `merge` with `initialRootState` consistently across all tests
- uses redux selectors to access the state - checks flags we need (opt-in status and migration applied) - Returns (isEnabled, isMigrationApplied) for our banner to use - Provides proper TypeScript types
- check default states - ensure proper state reading - handle partial states
- test conditional rendering - check text content - ensure close button functionality works - ensure link functionality works
- useSmartTransactionsEnabled enhanced to include dismiss functionality - add a dispatch action to update the smartTransactionsOptInStatus - remove external onClose prop from SmartTransactionsEnabledBanner in favor of using the hook's dismiss functionality - update component and hook tests to account for new functionality These changes require more changes in the next commit to add the smartTransactionsBannerDismissed field to our PreferencesController state as well to add a reducer case for SET_SMART_TRANSACTIONS_BANNER_DISMISSED and update any types/interfaces in our codebase that reference PreferencesController.
…nitialize it. Update the migration and test to account for the new change
...s/confirmations/components/SmartTransactionsEnabledBanner/SmartTransactionsEnabledBanner.tsx
Outdated
Show resolved
Hide resolved
app/components/hooks/useSmartTransactionsEnabled/useSmartTransactionsEnabled.ts
Outdated
Show resolved
Hide resolved
...irmations/components/SmartTransactionsEnabledBanner/SmartTransactionsEnabledBanner.styles.ts
Outdated
Show resolved
Hide resolved
…ask-mobile into feat/enable-stx-migration
…ask-mobile into feat/enable-stx-migration rename SmartTransactionsMigrationBanner
…tead. - Create new selectors file - Update the SmartTransactionsMigrationBanner component to use these selectors directly - Delete the hook file since its functionality would now be handled by selectors
...nfirmations/components/SmartTransactionsMigrationBanner/SmartTransactionsMigrationBanner.tsx
Outdated
Show resolved
Hide resolved
app/components/Views/confirmations/components/TransactionReview/index.js
Outdated
Show resolved
Hide resolved
…roller featureFlags - Move smartTransactionsMigrationApplied from PreferencesController root to featureFlags object - Aligns with existing pattern of using featureFlags for UI states - Maintains consistency with smartTransactionsBannerDismissed placement
I have read the CLA Document and I hereby sign the CLA |
Bitrise❌❌❌ Commit hash: ab77e91 Note
Tip
|
} | ||
onClose={dismissBanner} | ||
style={styles.banner} | ||
testID="smart-transactions-enabled-banner" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I would call it after the component's name, in this case: smart-transactions-migration-banner
- TransactionReview - Swaps Quote View
…thin featureFlags on component test
Bitrise✅✅✅ Commit hash: 6456e04 Note
|
Quality Gate passedIssues Measures |
Bitrise✅✅✅ Commit hash: 45524be Note
|
Description
This PR enables Smart Transactions (STX) in MetaMask Mobile by default through migration number (TBD) for users who have either opted out or haven't interacted with the STX toggle, provided they have no recorded STX activity.
How it works (if user does not have STX enabled or prior STX Transaction history:
In the case a user migrates from a previous version of the Mobile app and the migration runs and sets STX toggle "ON" in
Settings > Advanced > Smart Transactions
, they will receive an Alert on transaction confirmation screens until dismissed, or by clicking on the "Higher success rates" link within the alert. If they click on the link in the banner alert they will get sent to: What is 'Smart Transactions'? for more information. When returning to the confirmation they just navigated from the banner alert should not show and should never show again.Edge Cases:
If a user is new and setting up a wallet for the first time, they will not receive the Banner Alert. If a user imports a new wallet during a fresh install of the extension on a new browser or recovers a wallet, it's possible they may not see the alert if STX was on in a previous install. The STX Banner Alert is dismissed and will not show again if a user is in the state to get shown the banner and toggles STX off independently even if they do not physically dismiss the STX Banner Alert.
Migration Logic:
smartTransactionsOptInStatus
isnull
(new/never interacted)UI Components:
TBD, still exploring the Mobile UI for implementation solution.
Running Unit Tests
Migration Test:
yarn jest "./app/store/migrations/096.test.ts" --no-cache
Component Test:
yarn jest "./app/components/Views/confirmations/components/SmartTransactionsMigrationBanner/SmartTransactionsMigrationBanner.test.ts" --no-cache
Manual testing steps
Test Migration (using a wallet/account with no STX Transactions)
Start with an older repo version:
Terminal #1
yarn setup && yarn watch
Terminal #1
Import or setup a wallet without STX transactions, launch the wallet (do not enable STX if prompted), check that toggle is OFF in:
Settings > Advanced > Smart Transactions
Switch to feature branch and run app:
Terminal #1
yarn setup && yarn watch
Terminal #1
0.0001
ETH7 Ensure that Smart Transactions Banner Alert IS showing
0.0001
ETHScreenshots/Recordings
N/A yet...
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist