Skip to content

Commit

Permalink
feat: Enable smart transactions for new users (MetaMask#12148)
Browse files Browse the repository at this point in the history
## **Description**

This PR:
- Removes the Smart Transactions Opt In modal
- New users will have STX toggled on by default once we use this change
from @metamask/preferences-controller:
MetaMask/core#4885

## **Related issues**

Fixes:

## **Manual testing steps**

1. After installing the app a user will not see the STX opt in modal
2. In Advanced Settings Smart Transactions will be on. A user can turn
them off if they want

## **Screenshots/Recordings**

Smart Transactions enabled by default in Advanced settings for new
users:

![image](https://github.com/user-attachments/assets/e08f9dc5-5df6-4de6-a3fc-1c3cbc293e4c)

### **Before**

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

### **After**

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

## **Pre-merge author checklist**

- [ ] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.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-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.
  • Loading branch information
dan437 authored Nov 19, 2024
1 parent 95fbed4 commit 1bfc731
Show file tree
Hide file tree
Showing 42 changed files with 90 additions and 1,131 deletions.
5 changes: 0 additions & 5 deletions app/components/Nav/App/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ import OnboardingGeneralSettings from '../../Views/OnboardingSuccess/OnboardingG
import OnboardingAssetsSettings from '../../Views/OnboardingSuccess/OnboardingAssetsSettings';
import OnboardingSecuritySettings from '../../Views/OnboardingSuccess/OnboardingSecuritySettings';
import BasicFunctionalityModal from '../../UI/BasicFunctionality/BasicFunctionalityModal/BasicFunctionalityModal';
import SmartTransactionsOptInModal from '../../Views/SmartTransactionsOptInModal/SmartTranactionsOptInModal';
import ProfileSyncingModal from '../../UI/ProfileSyncing/ProfileSyncingModal/ProfileSyncingModal';
import ResetNotificationsModal from '../../UI/Notification/ResetNotificationsModal';
import NFTAutoDetectionModal from '../../../../app/components/Views/NFTAutoDetectionModal/NFTAutoDetectionModal';
Expand Down Expand Up @@ -389,10 +388,6 @@ const RootModalFlow = () => (
name={Routes.MODAL.MODAL_MANDATORY}
component={ModalMandatory}
/>
<Stack.Screen
name={Routes.MODAL.SMART_TRANSACTIONS_OPT_IN}
component={SmartTransactionsOptInModal}
/>
<Stack.Screen
name={Routes.SHEET.ACCOUNT_SELECTOR}
component={AccountSelector}
Expand Down
2 changes: 1 addition & 1 deletion app/components/Views/LedgerConnect/Scan.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ describe('Scan', () => {
const onDeviceSelected = jest.fn();

const navigateMock = {
navigate: jest.fn().mockImplementation(() => {onDeviceSelected(device2)}),
navigate: jest.fn().mockImplementation(() => {onDeviceSelected(device2);}),
} as unknown as NavigationProp<ParamListBase>;
jest.mocked(useNavigation).mockReturnValue(navigateMock);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ exports[`AdvancedSettings should render correctly 1`] = `
}
thumbTintColor="#ffffff"
tintColor="#bbc0c566"
value={false}
value={true}
/>
</View>
</View>
Expand Down
8 changes: 4 additions & 4 deletions app/components/Views/Settings/AdvancedSettings/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('AdvancedSettings', () => {
Device.isIos = jest.fn().mockReturnValue(true);
Device.isAndroid = jest.fn().mockReturnValue(false);

it('should render smart transactions opt in switch off by default', async () => {
it('should render smart transactions opt in switch on by default', async () => {
const { findByLabelText } = renderWithProvider(
<AdvancedSettings
navigation={{ navigate: mockNavigate, setOptions: jest.fn() }}
Expand All @@ -86,7 +86,7 @@ describe('AdvancedSettings', () => {
const switchElement = await findByLabelText(
strings('app_settings.smart_transactions_opt_in_heading'),
);
expect(switchElement.props.value).toBe(false);
expect(switchElement.props.value).toBe(true);
});
it('should update smartTransactionsOptInStatus when smart transactions opt in is pressed', async () => {
const { findByLabelText } = renderWithProvider(
Expand All @@ -102,9 +102,9 @@ describe('AdvancedSettings', () => {
strings('app_settings.smart_transactions_opt_in_heading'),
);

fireEvent(switchElement, 'onValueChange', true);
fireEvent(switchElement, 'onValueChange', false);

expect(mockSetSmartTransactionsOptInStatus).toBeCalledWith(true);
expect(mockSetSmartTransactionsOptInStatus).toBeCalledWith(false);
});
});
});

This file was deleted.

Loading

0 comments on commit 1bfc731

Please sign in to comment.