Skip to content

Commit 97f945e

Browse files
authored
refactor: Remove all external references to legacy Swaps routes (MetaMask#23108)
<!-- 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** The main goal of this PR is to remove all references to `Routes.SWAPS` from the codebase (apart from the legacy Swaps View directory which will be handled in a different PR). <!-- 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? --> ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: null ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/jira/software/c/projects/SWAPS/boards/1566?quickFilter=1772&selectedIssue=SWAPS-3472 ## **Manual testing steps** ```gherkin Ensure that users can navigate to swaps when they click the swap button next to a token in Browser view (see attached recording) ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** https://github.com/user-attachments/assets/df2961dc-a1f3-4da1-b135-52fdb69cd83e <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [x] 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). - [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. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Replaces all external uses of legacy Swaps routes with Bridge navigation and updates related handlers, constants, and tests. > > - **Navigation**: > - Removed `Swaps` screens and imports from `app/components/Nav/Main/MainNavigator.js`. > - Added `BridgeView` import and ensured Bridge stacks (`Routes.BRIDGE.ROOT`, `Routes.BRIDGE.MODALS.ROOT`) are the sole trade route entries. > - **Transactions UI**: > - In `SmartTransactionStatus.tsx`, `createNewSwap` now navigates to `Routes.BRIDGE.ROOT` instead of `Routes.SWAPS`. > - **Deeplinks & SDK**: > - `SwapHandler` now navigates to `Routes.BRIDGE.ROOT` → `Routes.BRIDGE.BRIDGE_VIEW` with params `{ sourceToken, destToken, sourceAmount, chainId }`. > - `handleCustomRpcCalls` routes `target: 'swap'` to `Routes.BRIDGE.ROOT`. > - **Routes/Constants**: > - Removed `Routes.SWAPS` and `Routes.SWAPS_AMOUNT_VIEW`; retained/used Bridge route keys. > - **Tests/Snapshots**: > - Updated `SmartTransactionStatus.test.tsx` to expect Bridge navigation. > - Updated `SwapHandler.test.ts` to expect Bridge navigation and param key changes. > - Snapshot `MainNavigator.test.tsx.snap` updated to remove `Swaps` screen. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 7eea25c. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent f93f627 commit 97f945e

8 files changed

Lines changed: 19 additions & 49 deletions

File tree

app/components/Nav/Main/MainNavigator.js

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ import ActivityView from '../../Views/ActivityView';
5353
import RewardsNavigator from '../../UI/Rewards/RewardsNavigator';
5454
import TrendingView from '../../Views/TrendingView/TrendingView';
5555
import SitesListView from '../../Views/TrendingView/SitesListView';
56-
import SwapsAmountView from '../../UI/Swaps';
57-
import SwapsQuotesView from '../../UI/Swaps/QuotesView';
5856
import CollectiblesDetails from '../../UI/CollectibleModal';
5957
import OptinMetrics from '../../UI/OptinMetrics';
6058

@@ -133,6 +131,7 @@ import {
133131
TOKEN,
134132
} from '../../Views/AddAsset/AddAsset.constants';
135133
import { strings } from '../../../../locales/i18n';
134+
import BridgeView from '../../UI/Bridge/Views/BridgeView';
136135

137136
const Stack = createStackNavigator();
138137
const Tab = createBottomTabNavigator();
@@ -339,16 +338,6 @@ const BrowserFlow = (props) => (
339338
component={Asset}
340339
initialParams={props.route.params}
341340
/>
342-
<Stack.Screen
343-
name="SwapsAmountView"
344-
component={SwapsAmountView}
345-
options={SwapsAmountView.navigationOptions}
346-
/>
347-
<Stack.Screen
348-
name="SwapsQuotesView"
349-
component={SwapsQuotesView}
350-
options={SwapsQuotesView.navigationOptions}
351-
/>
352341
</Stack.Navigator>
353342
);
354343

@@ -874,21 +863,6 @@ const NotificationsModeView = (props) => (
874863
</Stack.Navigator>
875864
);
876865

877-
const Swaps = () => (
878-
<Stack.Navigator>
879-
<Stack.Screen
880-
name="SwapsAmountView"
881-
component={SwapsAmountView}
882-
options={SwapsAmountView.navigationOptions}
883-
/>
884-
<Stack.Screen
885-
name="SwapsQuotesView"
886-
component={SwapsQuotesView}
887-
options={SwapsQuotesView.navigationOptions}
888-
/>
889-
</Stack.Navigator>
890-
);
891-
892866
const SetPasswordFlow = () => (
893867
<Stack.Navigator>
894868
<Stack.Screen
@@ -1099,7 +1073,6 @@ const MainNavigator = () => {
10991073
{() => <RampRoutes rampType={RampType.SELL} />}
11001074
</Stack.Screen>
11011075
<Stack.Screen name={Routes.DEPOSIT.ID} component={DepositRoutes} />
1102-
<Stack.Screen name="Swaps" component={Swaps} />
11031076
<Stack.Screen name={Routes.BRIDGE.ROOT} component={BridgeScreenStack} />
11041077
<Stack.Screen
11051078
name={Routes.BRIDGE.MODALS.ROOT}

app/components/Nav/Main/__snapshots__/MainNavigator.test.tsx.snap

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,6 @@ exports[`MainNavigator matches rendered snapshot 1`] = `
163163
component={[Function]}
164164
name="Deposit"
165165
/>
166-
<Screen
167-
component={[Function]}
168-
name="Swaps"
169-
/>
170166
<Screen
171167
component={[Function]}
172168
name="Bridge"

app/components/Views/transactions/SmartTransactionStatus/SmartTransactionStatus.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ describe('SmartTransactionStatus', () => {
496496
}),
497497
);
498498
fireEvent.press(primaryButton);
499-
expect(mockNavigate).toHaveBeenCalledWith(Routes.SWAPS);
499+
expect(mockNavigate).toHaveBeenCalledWith(Routes.BRIDGE.ROOT);
500500
});
501501
it('should navigate to Activity page on press of secondary button', () => {
502502
const { getByText } = renderWithProvider(
@@ -659,7 +659,7 @@ describe('SmartTransactionStatus', () => {
659659
strings('smart_transactions.try_again'),
660660
);
661661
fireEvent.press(primaryButton);
662-
expect(mockNavigate).toHaveBeenCalledWith(Routes.SWAPS);
662+
expect(mockNavigate).toHaveBeenCalledWith(Routes.BRIDGE.ROOT);
663663
});
664664
it('should navigate to Activity page on press of secondary button', () => {
665665
const { getByText } = renderWithProvider(

app/components/Views/transactions/SmartTransactionStatus/SmartTransactionStatus.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ const SmartTransactionStatus = ({
299299

300300
const createNewSwap = () => {
301301
onConfirm();
302-
navigation.navigate(Routes.SWAPS);
302+
navigation.navigate(Routes.BRIDGE.ROOT);
303303
};
304304

305305
const createNewSend = () => {

app/constants/navigation/Routes.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,6 @@ const Routes = {
234234
},
235235
ADD_NETWORK: 'AddNetwork',
236236
EDIT_NETWORK: 'EditNetwork',
237-
SWAPS: 'Swaps',
238-
SWAPS_AMOUNT_VIEW: 'SwapsAmountView',
239237
BRIDGE: {
240238
ROOT: 'Bridge',
241239
BRIDGE_VIEW: 'BridgeView',

app/core/DeeplinkManager/handlers/v2/SwapHandler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ export class SwapHandler extends BaseHandler {
3838
link.params;
3939

4040
// Navigate to swap screen with parameters
41-
this.navigate(context, Routes.SWAPS, {
42-
screen: Routes.SWAPS_AMOUNT_VIEW,
41+
this.navigate(context, Routes.BRIDGE.ROOT, {
42+
screen: Routes.BRIDGE.BRIDGE_VIEW,
4343
params: {
4444
sourceToken,
45-
destinationToken,
45+
destToken: destinationToken,
4646
sourceAmount,
4747
chainId: chain,
4848
},

app/core/DeeplinkManager/handlers/v2/__tests__/SwapHandler.test.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,18 @@ describe('SwapHandler', () => {
3535
const result = await handler.handle(link, mockContext);
3636

3737
expect(result.handled).toBe(true);
38-
expect(mockContext.navigation.navigate).toHaveBeenCalledWith(Routes.SWAPS, {
39-
screen: Routes.SWAPS_AMOUNT_VIEW,
40-
params: {
41-
sourceToken: 'ETH',
42-
destinationToken: 'USDC',
43-
sourceAmount: '1',
44-
chainId: undefined,
38+
expect(mockContext.navigation.navigate).toHaveBeenCalledWith(
39+
Routes.BRIDGE.ROOT,
40+
{
41+
screen: Routes.BRIDGE.BRIDGE_VIEW,
42+
params: {
43+
sourceToken: 'ETH',
44+
destToken: 'USDC',
45+
sourceAmount: '1',
46+
chainId: undefined,
47+
},
4548
},
46-
});
49+
);
4750
});
4851

4952
it('requires authentication for swap', async () => {

app/core/SDKConnect/handlers/handleCustomRpcCalls.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export const handleCustomRpcCalls = async ({
115115
DevLogger.log(
116116
`[handleCustomRpcCalls] targetToken=${targetToken} amount=${targetAmount}`,
117117
);
118-
navigation?.navigate(Routes.SWAPS);
118+
navigation?.navigate(Routes.BRIDGE.ROOT);
119119
} else {
120120
navigation?.navigate(...createBuyNavigationDetails());
121121
}

0 commit comments

Comments
 (0)