From a7c057e2df2e47a499dca7eaaee41e09b2a4c8f4 Mon Sep 17 00:00:00 2001 From: Skylar Barrera Date: Thu, 14 Dec 2023 14:58:18 -0500 Subject: [PATCH] swaps: revert entry point (#5247) --- .../ProfileActionButtonsRow.tsx | 25 +++++++++---------- .../sheet-action-buttons/SwapActionButton.js | 25 +++---------------- src/screens/ExchangeModal.tsx | 1 + 3 files changed, 17 insertions(+), 34 deletions(-) diff --git a/src/components/asset-list/RecyclerAssetList2/profile-header/ProfileActionButtonsRow.tsx b/src/components/asset-list/RecyclerAssetList2/profile-header/ProfileActionButtonsRow.tsx index 7c42236d482..6507212f870 100644 --- a/src/components/asset-list/RecyclerAssetList2/profile-header/ProfileActionButtonsRow.tsx +++ b/src/components/asset-list/RecyclerAssetList2/profile-header/ProfileActionButtonsRow.tsx @@ -23,12 +23,13 @@ import { import { CurrencySelectionTypes, ExchangeModalTypes } from '@/helpers'; import { useAccountProfile, + useAccountSettings, useSwapCurrencyHandlers, useWallets, } from '@/hooks'; import { delayNext } from '@/hooks/useMagicAutofocus'; import { useNavigation } from '@/navigation'; -import { watchingAlert } from '@/utils'; +import { ethereumUtils, watchingAlert } from '@/utils'; import Routes from '@rainbow-me/routes'; import showWalletErrorAlert from '@/helpers/support'; import { analytics } from '@/analytics'; @@ -36,6 +37,7 @@ import { useRecoilState } from 'recoil'; import config from '@/model/config'; import { useAccountAccentColor } from '@/hooks/useAccountAccentColor'; import { addressCopiedToastAtom } from '@/recoil/addressCopiedToastAtom'; +import { Network } from '@/networks/types'; export const ProfileActionButtonsRowHeight = 80; @@ -194,35 +196,32 @@ function BuyButton() { function SwapButton() { const { isReadOnlyWallet } = useWallets(); + const { accountAddress } = useAccountSettings(); const { navigate } = useNavigation(); - const { updateInputCurrency } = useSwapCurrencyHandlers({ - shouldUpdate: false, - type: ExchangeModalTypes.swap, - }); - - const handlePress = React.useCallback(() => { + const handlePress = React.useCallback(async () => { if (!isReadOnlyWallet || enableActionsOnReadOnlyWallet) { analytics.track('Tapped "Swap"', { category: 'home screen', }); android && delayNext(); + const mainnetEth = await ethereumUtils.getNativeAssetForNetwork( + Network.mainnet, + accountAddress + ); navigate(Routes.EXCHANGE_MODAL, { fromDiscover: true, params: { - fromDiscover: true, - onSelectCurrency: updateInputCurrency, - title: lang.t('swap.modal_types.swap'), - type: CurrencySelectionTypes.input, + inputAsset: mainnetEth, }, - screen: Routes.CURRENCY_SELECT_SCREEN, + screen: Routes.MAIN_EXCHANGE_SCREEN, }); } else { watchingAlert(); } - }, [isReadOnlyWallet, navigate, updateInputCurrency]); + }, [accountAddress, isReadOnlyWallet, navigate]); return ( diff --git a/src/components/sheet/sheet-action-buttons/SwapActionButton.js b/src/components/sheet/sheet-action-buttons/SwapActionButton.js index 009aa0ef196..561b37e0f36 100644 --- a/src/components/sheet/sheet-action-buttons/SwapActionButton.js +++ b/src/components/sheet/sheet-action-buttons/SwapActionButton.js @@ -33,41 +33,24 @@ function SwapActionButton({ if (params.outputAsset) { return { params: { - chainId: ethereumUtils.getChainIdFromType(asset.type), defaultOutputAsset: asset, - fromDiscover: true, - onSelectCurrency: updateInputCurrency, params: { - ...params, - ignoreInitialTypeCheck: true, outputAsset: asset, }, - showCoinIcon: true, - title: lang.t('swap.modal_types.get_symbol_with', { - symbol: params?.outputAsset?.symbol, - }), - type: CurrencySelectionTypes.input, }, - screen: Routes.CURRENCY_SELECT_SCREEN, + screen: Routes.MAIN_EXCHANGE_SCREEN, }; } else { + console.log(asset); return { params: { - chainId: ethereumUtils.getChainIdFromType(asset.type), defaultInputAsset: asset, - onSelectCurrency: updateOutputCurrency, - params: { - ...params, - ignoreInitialTypeCheck: true, - }, - title: lang.t('swap.modal_types.receive'), - type: CurrencySelectionTypes.output, }, - screen: Routes.CURRENCY_SELECT_SCREEN, + screen: Routes.MAIN_EXCHANGE_SCREEN, }; } }); - }, [asset, navigate, updateInputCurrency, updateOutputCurrency]); + }, [asset, navigate]); return (