Skip to content
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

[CHORE]: Remove Swaps V1 Dead Code #6181

Merged
merged 41 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
4d106b6
start on ripping out old swaps
walmat Oct 4, 2024
9de2d27
Update package.json
walmat Oct 9, 2024
bc0159c
clean up lint
walmat Oct 9, 2024
6817341
add pbx?
walmat Oct 9, 2024
1d6ab62
tslint is a liar
walmat Oct 10, 2024
942dc2b
fixed it
walmat Oct 10, 2024
5092fc2
add a few components back that are used in the expanded asset sheet
walmat Oct 10, 2024
82baa34
rm graph
walmat Oct 10, 2024
f16b2d3
chore: merge
walmat Oct 15, 2024
46b8d32
chore: merge
walmat Oct 16, 2024
e503b17
revert changes to pbx
walmat Oct 16, 2024
1cc9d12
chore: merge
walmat Oct 22, 2024
85bf5ff
Swaps v2 cleanup duplicates / unused utils (#6202)
walmat Oct 22, 2024
dbe91b6
reorder worklets
walmat Oct 22, 2024
c377f2e
remove getCrosschainSwapServiceTime from handlers/swap
walmat Oct 23, 2024
be8186a
remove ExchangeSearch
walmat Oct 23, 2024
41cc71b
remove unused NetworkSwitcher components
walmat Oct 23, 2024
d64be4e
rename useFeePanelInputRefs to useFeesPanelInputRefs
walmat Oct 23, 2024
fba8322
remove swapSearch and walletFilter
walmat Oct 23, 2024
ae8749d
delete unused useMinRefuelAmount hook
walmat Oct 23, 2024
797f5c9
delete unused exchangeModalTypes file
walmat Oct 23, 2024
5602a66
remove unused selectUserAssetsListByChainId selector
walmat Oct 23, 2024
2c11496
chore: merge
walmat Oct 23, 2024
22e0632
change getAddressAndChainIdFromUniqueId to work for both networks and…
walmat Oct 23, 2024
6905dce
remove duplicate buildLocalizedTimeUnitString util
walmat Oct 23, 2024
39db307
remove duplicate buildLocalizedTimeUnitString util
walmat Oct 23, 2024
7849a83
remove TokenSelectionButton
walmat Oct 23, 2024
0332f32
remove SendFab
walmat Oct 23, 2024
039345f
replace a couple accessors to native assets that could be sync
walmat Oct 24, 2024
190d962
chore: merge
walmat Oct 24, 2024
4a2ec01
remove unused fromChainId from useSearchCurrencyList
walmat Oct 25, 2024
67a7776
remove unused isCrosschainSearch from useSearchCurrencyList
walmat Oct 25, 2024
2b5468b
bring back navigation hook that prevents readOnly wallets from naviga…
walmat Oct 25, 2024
2d835f3
clean up crossChainServiceTime and remove traces
walmat Oct 25, 2024
664b42a
Merge branch 'develop' into feat/remove-swaps-v1
walmat Oct 25, 2024
95c19a0
add swaps v2 comment
walmat Oct 25, 2024
5f05caf
Merge branch 'develop' into feat/remove-swaps-v1
walmat Oct 28, 2024
32e48d9
chore: merge
walmat Oct 28, 2024
12880ea
fix initial asset missing on expanded state navigation (#6240)
walmat Oct 28, 2024
12635e4
fix gas button stuck on loading (#6241)
walmat Oct 30, 2024
4094a69
move unused vars to swaps util
walmat Oct 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5,767 changes: 5,767 additions & 0 deletions graph.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@
"@types/dedent": "0.7.0",
"@types/jest": "29.5.12",
"@types/mocha": "9.0.0",
"@types/node": "16.11.6",
"@types/node": "22.7.4",
"@types/qs": "6.9.7",
"@types/react": "18.2.65",
"@types/react-native-extra-dimensions-android": "1.2.3",
Expand Down Expand Up @@ -376,7 +376,7 @@
"ts-jest": "29.1.1",
"ts-loader": "9.5.1",
"ts-migrate": "0.1.26",
"typescript": "5.1.6",
"typescript": "5.6.2",
"typescript-coverage-report": "0.6.1",
"webpack": "5.94.0",
"webpack-cli": "5.1.4"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { useRoute } from '@react-navigation/native';
import React, { useCallback } from 'react';
import { delayNext } from '../../hooks/useMagicAutofocus';
import { BackButton } from '../header';
import { SheetHandleFixedToTop } from '../sheet';
import { delayNext } from '@/hooks/useMagicAutofocus';
import { BackButton } from '@/components/header';
import { SheetHandleFixedToTop } from '@/components/sheet';
import { Box, Inset, Text } from '@/design-system';
import { useNavigation } from '@/navigation';
import Routes from '@/navigation/routesNames';
import RainbowCoinIcon from '../coin-icon/RainbowCoinIcon';
import RainbowCoinIcon from '@/components/coin-icon/RainbowCoinIcon';
import { useTheme } from '@/theme';
import { chainsIdByName } from '@/chains';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React, { forwardRef, ForwardRefRenderFunction } from 'react';
import { SectionList } from 'react-native';
import { magicMemo } from '../../utils';
import { EmptyAssetList } from '../asset-list';
import { Centered } from '../layout';
import { NoResults } from '../list';
import { CurrencySelectModalHeaderHeight } from './CurrencySelectModalHeader';
import ExchangeAssetList from './ExchangeAssetList';
import { ExchangeSearchHeight } from './ExchangeSearch';
import { magicMemo } from '@/utils';
import { EmptyAssetList } from '@/components/asset-list';
import { Centered } from '@/components/layout';
import { NoResults } from '@/components/list';
import { CurrencySelectModalHeaderHeight } from '@/components/CurrencySelectModalHeader';
import ExchangeAssetList from '@/components/ExchangeAssetList';
import { ExchangeSearchHeight } from '@/components/ExchangeSearch';
import { Box } from '@/design-system';
import { EnrichedExchangeAsset } from '@/screens/CurrencySelectModal';
import { NoResultsType } from '../list/NoResults';
import { NoResultsType } from '@/components/list/NoResults';

interface CurrencySelectionListProps {
keyboardDismissMode?: 'none' | 'interactive' | 'on-drag';
Expand Down
3 changes: 1 addition & 2 deletions src/components/DappBrowser/BrowserTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import { Homepage } from './Homepage';
import { WebViewBorder } from './WebViewBorder';
import {
RAINBOW_HOME,
DEFAULT_TAB_URL,
TAB_SCREENSHOT_FILE_FORMAT,
TAB_SCREENSHOT_FASTER_IMAGE_CONFIG,
USER_AGENT,
Expand Down Expand Up @@ -196,7 +195,7 @@ const FreezableWebViewComponent = ({
const webViewRef = useRef<WebView>(null);

const isActiveTab = useBrowserStore(state => state.isTabActive(tabId));
const tabUrl = useBrowserStore(state => state.getTabData?.(tabId)?.url) || DEFAULT_TAB_URL;
const tabUrl = useBrowserStore(state => state.getTabData?.(tabId)?.url) || RAINBOW_HOME;
const isOnHomepage = tabUrl === RAINBOW_HOME;

const handleOnMessage = useCallback(
Expand Down
4 changes: 2 additions & 2 deletions src/components/DappBrowser/Homepage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { useBrowserContext } from './BrowserContext';
import { getNameFromFormattedUrl } from './utils';
import { useTrendingDApps } from '@/resources/metadata/trendingDapps';
import { DApp } from '@/graphql/__generated__/metadata';
import { DEFAULT_TAB_URL } from './constants';
import { RAINBOW_HOME } from './constants';
import { FeaturedResult } from '@/graphql/__generated__/arc';
import { useRemoteConfig } from '@/model/remoteConfig';
import { FEATURED_RESULTS, useExperimentalFlag } from '@/config';
Expand Down Expand Up @@ -175,7 +175,7 @@ const Favorites = ({ goToUrl, tabId }: { goToUrl: (url: string) => void; tabId:
({ currentGridSort, isActiveTab }: { currentGridSort: string[] | undefined; isActiveTab: boolean }) => {
'worklet';
const homepageTabsCount = currentlyOpenTabIds.value.filter(
tabId => !animatedTabUrls.value[tabId] || animatedTabUrls.value[tabId] === DEFAULT_TAB_URL
tabId => !animatedTabUrls.value[tabId] || animatedTabUrls.value[tabId] === RAINBOW_HOME
).length;
const inactiveAndMounted = !isActiveTab && currentGridSort !== undefined;

Expand Down
2 changes: 0 additions & 2 deletions src/components/DappBrowser/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ export const HTTP = 'http://';
export const HTTPS = 'https://';
export const RAINBOW_HOME = 'RAINBOW_HOME';

export const DEFAULT_TAB_URL = RAINBOW_HOME;

export const USER_AGENT = {
IOS: 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4.1 Mobile/15E148 Safari/604.1',
ANDROID: 'Mozilla/5.0 (Linux; Android 14) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.6533.103 Mobile Safari/537.36',
Expand Down
67 changes: 16 additions & 51 deletions src/components/DappBrowser/control-panel/ControlPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import { useSyncSharedValue } from '@/hooks/reanimated/useSyncSharedValue';
import { useBrowserStore } from '@/state/browser/browserStore';
import { colors } from '@/styles';
import { deviceUtils, watchingAlert } from '@/utils';
import ethereumUtils from '@/utils/ethereumUtils';
import { addressHashedEmoji } from '@/utils/profileUtils';
import { getHighContrastTextColorWorklet } from '@/worklets/colors';
import { TOP_INSET } from '../Dimensions';
Expand All @@ -45,19 +44,17 @@ import { useDispatch } from 'react-redux';
import store from '@/redux/store';
import { getDappHost } from '@/utils/connectedApps';
import WebView from 'react-native-webview';
import { Navigation, useNavigation } from '@/navigation';
import { useNavigation } from '@/navigation';
import Routes from '@/navigation/routesNames';
import { address } from '@/utils/abbreviations';
import { fontWithWidthWorklet } from '@/styles/buildTextStyles';
import { useAppSessionsStore } from '@/state/appSessions';
import { DEFAULT_TAB_URL, RAINBOW_HOME } from '../constants';
import { RAINBOW_HOME } from '../constants';
import { FavoritedSite, useFavoriteDappsStore } from '@/state/browser/favoriteDappsStore';
import WalletTypes from '@/helpers/walletTypes';
import { usePersistentDominantColorFromImage } from '@/hooks/usePersistentDominantColorFromImage';
import { findWalletWithAccount } from '@/helpers/findWalletWithAccount';
import { addressSetSelected, walletsSetSelected } from '@/redux/wallets';
import { getRemoteConfig } from '@/model/remoteConfig';
import { SWAPS_V2, useExperimentalFlag } from '@/config';
import { swapsStore } from '@/state/swaps/swapsStore';
import { userAssetsStore } from '@/state/assets/userAssets';
import { greaterThan } from '@/helpers/utilities';
Expand Down Expand Up @@ -89,7 +86,7 @@ export const ControlPanel = () => {
} = useRoute<RouteProp<ControlPanelParams, 'ControlPanel'>>();
const walletsWithBalancesAndNames = useWalletsWithBalancesAndNames();
const activeTabUrl = useBrowserStore(state => state.getActiveTabUrl());
const activeTabHost = getDappHost(activeTabUrl || '') || DEFAULT_TAB_URL;
const activeTabHost = getDappHost(activeTabUrl || '') || RAINBOW_HOME;
const updateActiveSessionNetwork = useAppSessionsStore(state => state.updateActiveSessionNetwork);
const updateActiveSession = useAppSessionsStore(state => state.updateActiveSession);
const addSession = useAppSessionsStore(state => state.addSession);
Expand Down Expand Up @@ -382,8 +379,6 @@ const HomePanel = ({
const dispatch = useDispatch();
const { navigate } = useNavigation();

const swapsV2Enabled = useExperimentalFlag(SWAPS_V2);

const actionButtonList = useMemo(() => {
const walletIcon = selectedWallet?.IconComponent || <></>;
const walletLabel = selectedWallet?.label || '';
Expand Down Expand Up @@ -444,57 +439,27 @@ const HomePanel = ({
const valid = await runWalletChecksBeforeSwapOrBridge();
if (!valid) return;

const { swaps_v2 } = getRemoteConfig();

if (swaps_v2 || swapsV2Enabled) {
swapsStore.setState({
inputAsset: userAssetsStore.getState().getHighestValueEth(),
});
InteractionManager.runAfterInteractions(() => {
navigate(Routes.SWAP);
});
return;
}

const mainnetEth = await ethereumUtils.getNativeAssetForNetwork({ chainId: ChainId.mainnet, address: selectedWallet?.uniqueId });
Navigation.handleAction(Routes.EXCHANGE_MODAL, {
fromDiscover: true,
params: {
inputAsset: mainnetEth,
},
screen: Routes.MAIN_EXCHANGE_SCREEN,
swapsStore.setState({
inputAsset: userAssetsStore.getState().getHighestValueEth(),
});
InteractionManager.runAfterInteractions(() => {
navigate(Routes.SWAP);
});
}, [navigate, runWalletChecksBeforeSwapOrBridge, selectedWallet?.uniqueId, swapsV2Enabled]);
}, [navigate, runWalletChecksBeforeSwapOrBridge]);

const handleOnPressBridge = useCallback(async () => {
const valid = await runWalletChecksBeforeSwapOrBridge();
if (!valid) return;

const { swaps_v2 } = getRemoteConfig();

if (swaps_v2 || swapsV2Enabled) {
// TODO: We need to set something in swapsStore that deliniates between a swap and bridge
// for now let's just treat it like a normal swap
swapsStore.setState({
inputAsset: userAssetsStore.getState().getHighestValueEth(),
});
InteractionManager.runAfterInteractions(() => {
navigate(Routes.SWAP);
});
return;
}

const mainnetEth = await ethereumUtils.getNativeAssetForNetwork({ chainId: ChainId.mainnet, address: selectedWallet?.uniqueId });
Navigation.handleAction(Routes.EXCHANGE_MODAL, {
fromDiscover: true,
params: {
inputAsset: mainnetEth,
},
screen: Routes.MAIN_EXCHANGE_SCREEN,
swapsStore.setState({
inputAsset: userAssetsStore.getState().getHighestValueEth(),
});
InteractionManager.runAfterInteractions(() => {
navigate(Routes.SWAP);
});
}, [navigate, runWalletChecksBeforeSwapOrBridge, selectedWallet?.uniqueId, swapsV2Enabled]);
}, [navigate, runWalletChecksBeforeSwapOrBridge]);

const isOnHomepage = useBrowserStore(state => (state.getActiveTabUrl() || DEFAULT_TAB_URL) === RAINBOW_HOME);
const isOnHomepage = useBrowserStore(state => (state.getActiveTabUrl() || RAINBOW_HOME) === RAINBOW_HOME);

return (
<Panel height={isOnHomepage ? HOME_PANEL_FULL_HEIGHT - HOME_PANEL_DAPP_SECTION : HOME_PANEL_FULL_HEIGHT}>
Expand Down
6 changes: 3 additions & 3 deletions src/components/DappBrowser/search-input/AccountIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { getDappHost } from '../handleProviderRequest';
import { ButtonPressAnimation } from '@/components/animations';
import { useBrowserStore } from '@/state/browser/browserStore';
import { useBrowserContext } from '../BrowserContext';
import { DEFAULT_TAB_URL, RAINBOW_HOME } from '../constants';
import { RAINBOW_HOME } from '../constants';

export const AccountIcon = React.memo(function AccountIcon() {
const { navigate } = useNavigation();
Expand All @@ -23,8 +23,8 @@ export const AccountIcon = React.memo(function AccountIcon() {
const [currentAddress, setCurrentAddress] = useState<string>(accountAddress);

const { activeTabRef } = useBrowserContext();
const activeTabHost = useBrowserStore(state => getDappHost(state.getActiveTabUrl())) || DEFAULT_TAB_URL;
const isOnHomepage = useBrowserStore(state => (state.getActiveTabUrl() || DEFAULT_TAB_URL) === RAINBOW_HOME);
const activeTabHost = useBrowserStore(state => getDappHost(state.getActiveTabUrl())) || RAINBOW_HOME;
const isOnHomepage = useBrowserStore(state => (state.getActiveTabUrl() || RAINBOW_HOME) === RAINBOW_HOME);
jinchung marked this conversation as resolved.
Show resolved Hide resolved
const hostSessions = useAppSessionsStore(state => state.getActiveSession({ host: activeTabHost }));
const currentSession = useMemo(
() =>
Expand Down
4 changes: 0 additions & 4 deletions src/components/DappBrowser/search/results/SearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,9 @@ const search = (query: string, dapps: Dapp[], numberOfResults = 4): Dapp[] => {
if (b?.trending === true && a?.trending !== true) return 1;
if (a?.trending === true && b?.trending !== true) return -1;

// @ts-expect-error: Need to fix these types
const relevanceDiff = b.relevance - a.relevance;
if (relevanceDiff === 0) {
// @ts-expect-error: Same here
const aWordCount = a.name.split(' ').length;
// @ts-expect-error: Same here
const bWordCount = b.name.split(' ').length;
return aWordCount - bWordCount;
}
Expand All @@ -74,7 +71,6 @@ const search = (query: string, dapps: Dapp[], numberOfResults = 4): Dapp[] => {
return [{ url: query, urlDisplay: query, name: query, isDirect: true } as unknown as Dapp, ...(dappResults as Dapp[])];
}

// @ts-expect-error: Same here
return filteredDapps;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,25 @@ import React, {
} from 'react';
import { InteractionManager, Keyboard, SectionList, SectionListData } from 'react-native';
import LinearGradient from 'react-native-linear-gradient';
import { ButtonPressAnimation } from '../animations';
import useAccountSettings from '../../hooks/useAccountSettings';
import FastCurrencySelectionRow from '../asset-list/RecyclerAssetList2/FastComponents/FastCurrencySelectionRow';
import { ContactRow } from '../contacts';
import DiscoverSheetContext from '../../screens/discover/DiscoverScreenContext';
import { GradientText } from '../text';
import { CopyToast, ToastPositionContainer } from '../toasts';
import contextMenuProps from './exchangeAssetRowContextMenuProps';
import { ButtonPressAnimation } from '@/components/animations';
import useAccountSettings from '@/hooks/useAccountSettings';
import FastCurrencySelectionRow from '@/components/asset-list/RecyclerAssetList2/FastComponents/FastCurrencySelectionRow';
import { ContactRow } from '@/components/contacts';
import DiscoverSheetContext from '@/screens/discover/DiscoverScreenContext';
import { GradientText } from '@/components/text';
import { CopyToast, ToastPositionContainer } from '@/components/toasts';
import contextMenuProps from '@/components/exchangeAssetRowContextMenuProps';
import { TokenSectionTypes } from '@/helpers';
import { useAndroidScrollViewGestureHandler, usePrevious } from '@/hooks';
import { useNavigation } from '@/navigation';
import store from '@/redux/store';
import Routes from '@/navigation/routesNames';
import styled from '@/styled-thing';
import { useTheme } from '@/theme';
import { abbreviations, deviceUtils, haptics, magicMemo } from '@/utils';
import { Box, Text } from '@/design-system';
import { colors, Colors } from '@/styles';
import { EnrichedExchangeAsset } from '@/screens/CurrencySelectModal';
import ExchangeTokenRow from './ExchangeTokenRow';
import ExchangeTokenRow from '@/components/ExchangeTokenRow';
import { SwappableAsset } from '@/entities';
import { toggleFavorite, useFavorites } from '@/resources/favorites';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { isEmpty } from 'lodash';
import React, { ForwardRefRenderFunction, MutableRefObject, useCallback, useContext, useEffect, useMemo, useRef } from 'react';
import LinearGradient from 'react-native-linear-gradient';
import Animated, { Easing, useAnimatedStyle, useSharedValue, withRepeat, withTiming } from 'react-native-reanimated';
import Spinner from '../../assets/chartSpinner.png';
import DiscoverSheetContext from '../../screens/discover/DiscoverScreenContext';
import { ClearInputDecorator, Input } from '../inputs';
import Spinner from '@/assets/chartSpinner.png';
walmat marked this conversation as resolved.
Show resolved Hide resolved
import DiscoverSheetContext from '@/screens/discover/DiscoverScreenContext';
import { ClearInputDecorator, Input } from '@/components/inputs';
import { analytics } from '@/analytics';
import { ImgixImage } from '@/components/images';
import styled from '@/styled-thing';
Expand All @@ -17,7 +17,6 @@ import { useTheme } from '@/theme';
import { Box, Text } from '@/design-system';
import { Source } from 'react-native-fast-image';
import { IS_TEST } from '@/env';
import { ChainId } from '@rainbow-me/swaps';

export const ExchangeSearchHeight = 40;
const DoneButtonWidth = 52;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import isEqual from 'react-fast-compare';
import { Box, Column, Columns, Inline, Stack, Text } from '@/design-system';
import { isNativeAsset } from '@/handlers/assets';
import { useAsset, useDimensions } from '@/hooks';
import { ButtonPressAnimation } from '../animations';
import { FloatingEmojis } from '../floating-emojis';
import { ButtonPressAnimation } from '@/components/animations';
import { FloatingEmojis } from '@/components/floating-emojis';
import { IS_IOS } from '@/env';
import { FavStar, Info } from '../asset-list/RecyclerAssetList2/FastComponents/FastCurrencySelectionRow';
import { FavStar, Info } from '@/components/asset-list/RecyclerAssetList2/FastComponents/FastCurrencySelectionRow';
import { View } from 'react-native';
import RainbowCoinIcon from '../coin-icon/RainbowCoinIcon';
import RainbowCoinIcon from '@/components/coin-icon/RainbowCoinIcon';
import { ChainId } from '@/chains/types';
import { ParsedAddressAsset } from '@/entities';

Expand Down
Loading
Loading