Skip to content

Commit c7f91eb

Browse files
committed
fix: updated Money hub convert to mUSD button to redirect to custom convert screen
1 parent e632cc6 commit c7f91eb

2 files changed

Lines changed: 18 additions & 8 deletions

File tree

app/components/Views/CashTokensFullView/CashTokensFullView.test.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -443,27 +443,32 @@ describe('CashTokensFullView', () => {
443443
});
444444
});
445445

446-
it('calls initiateMaxConversion on first conversionToken via handleConvertPress', async () => {
446+
it('calls initiateCustomConversion with preferredPaymentToken via handleConvertPress', async () => {
447447
mockSelectMoneyHubEnabledFlag.mockReturnValue(true);
448448
const token = { address: '0xabc', chainId: '0x1' } as AssetType;
449449
mockUseMusdConversionTokens.mockReturnValue({ tokens: [token] });
450-
mockInitiateMaxConversion.mockResolvedValue(undefined);
450+
mockInitiateCustomConversion.mockResolvedValue(undefined);
451451

452452
renderWithProvider(<CashTokensFullView />);
453453

454454
await act(async () => {
455455
fireEvent.press(screen.getByText('Convert to mUSD'));
456456
});
457457

458-
expect(mockInitiateMaxConversion).toHaveBeenCalledWith(token);
458+
expect(mockInitiateCustomConversion).toHaveBeenCalledWith({
459+
preferredPaymentToken: {
460+
address: '0xabc',
461+
chainId: '0x1',
462+
},
463+
});
459464
});
460465

461466
it('logs error when handleConvertPress fails', async () => {
462467
mockSelectMoneyHubEnabledFlag.mockReturnValue(true);
463468
const token = { address: '0xabc', chainId: '0x1' } as AssetType;
464469
mockUseMusdConversionTokens.mockReturnValue({ tokens: [token] });
465470
const error = new Error('convert CTA failed');
466-
mockInitiateMaxConversion.mockRejectedValue(error);
471+
mockInitiateCustomConversion.mockRejectedValue(error);
467472
const loggerSpy = jest.spyOn(
468473
jest.requireMock('../../../util/Logger').default,
469474
'error',
@@ -493,8 +498,8 @@ describe('CashTokensFullView', () => {
493498
// so we test the early return by having tokens initially then not.
494499
// Actually, the early return is only hit if conversionTokens[0] is falsy.
495500
// Since the CTA only renders when hasConversionTokens, we just verify
496-
// the convert press calls initiateMaxConversion above.
497-
expect(mockInitiateMaxConversion).not.toHaveBeenCalled();
501+
// the convert press calls initiateCustomConversion above.
502+
expect(mockInitiateCustomConversion).not.toHaveBeenCalled();
498503
});
499504

500505
it('calls goToSwaps when Swap button is pressed', () => {

app/components/Views/CashTokensFullView/CashTokensFullView.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,18 @@ const CashTokensFullView = () => {
131131
const topToken = conversionTokens[0];
132132
if (!topToken) return;
133133
try {
134-
await initiateMaxConversion(topToken);
134+
await initiateCustomConversion({
135+
preferredPaymentToken: {
136+
address: topToken.address as Hex,
137+
chainId: topToken.chainId as Hex,
138+
},
139+
});
135140
} catch (error) {
136141
Logger.error(error as Error, {
137142
message: '[CashTokensFullView] Failed to initiate convert CTA',
138143
});
139144
}
140-
}, [conversionTokens, initiateMaxConversion]);
145+
}, [conversionTokens, initiateCustomConversion]);
141146

142147
const handleLearnMorePress = useCallback(() => {
143148
Linking.openURL(AppConstants.URLS.MUSD_LEARN_MORE);

0 commit comments

Comments
 (0)