Skip to content

Commit

Permalink
convert network accessors to functions (#6219)
Browse files Browse the repository at this point in the history
* convert network accessors to functions

* backend networks store

* wrote a couple worklet functions to get swaps working

* fix other calls

* Update package.json

* Update ios/Podfile.lock

* move all functions into backendNetworksStore and replace calls

* refresh podlock

* no clue what happened during merge

* fix: APP-2021

* fix: APP-2022

* fix build and lint
  • Loading branch information
walmat authored and greg-schrammel committed Dec 17, 2024
1 parent 5bb2a0f commit e67803c
Show file tree
Hide file tree
Showing 212 changed files with 1,230 additions and 694 deletions.
2 changes: 1 addition & 1 deletion src/__swaps__/screens/Swap/Swap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { SwapInputAsset } from '@/__swaps__/screens/Swap/components/SwapInputAss
import { SwapNavbar } from '@/__swaps__/screens/Swap/components/SwapNavbar';
import { SwapOutputAsset } from '@/__swaps__/screens/Swap/components/SwapOutputAsset';
import { SwapSheetGestureBlocker } from '@/__swaps__/screens/Swap/components/SwapSheetGestureBlocker';
import { ChainId } from '@/chains/types';
import { ChainId } from '@/state/backendNetworks/types';
import { SwapAssetType } from '@/__swaps__/types/swap';
import { parseSearchAsset } from '@/__swaps__/utils/assets';
import { AbsolutePortalRoot } from '@/components/AbsolutePortal';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const OptimismBadge = require('@/assets/badges/optimism.png');
const PolygonBadge = require('@/assets/badges/polygon.png');
const ZoraBadge = require('@/assets/badges/zora.png');

import { ChainId } from '@/chains/types';
import { ChainId } from '@/state/backendNetworks/types';
import { globalColors } from '@/design-system';
import { PIXEL_RATIO } from '@/utils/deviceUtils';
import { useSwapsStore } from '@/state/swaps/swapsStore';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Image, StyleSheet, View } from 'react-native';

import { ChainId } from '@/chains/types';
import { ChainId } from '@/state/backendNetworks/types';
import { useAnimatedProps, useDerivedValue } from 'react-native-reanimated';
import { AnimatedFasterImage } from '@/components/AnimatedComponents/AnimatedFasterImage';
import { DEFAULT_FASTER_IMAGE_CONFIG } from '@/components/images/ImgixImage';
Expand Down
11 changes: 6 additions & 5 deletions src/__swaps__/screens/Swap/components/CoinRow.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BalancePill } from '@/__swaps__/screens/Swap/components/BalancePill';
import { CoinRowButton } from '@/__swaps__/screens/Swap/components/CoinRowButton';
import { AddressOrEth, ParsedSearchAsset } from '@/__swaps__/types/assets';
import { ChainId } from '@/chains/types';
import { AddressOrEth, ParsedSearchAsset, UniqueId } from '@/__swaps__/types/assets';
import { ChainId } from '@/state/backendNetworks/types';
import { SearchAsset } from '@/__swaps__/types/search';
import { ButtonPressAnimation } from '@/components/animations';
import { ContextMenuButton } from '@/components/context-menu';
Expand All @@ -17,7 +17,7 @@ import React, { useCallback, useMemo } from 'react';
import { GestureResponderEvent } from 'react-native';
import { OnPressMenuItemEventObject } from 'react-native-ios-context-menu';
import { SwapCoinIcon } from './SwapCoinIcon';
import { SUPPORTED_CHAIN_IDS } from '@/chains';
import { useBackendNetworksStore } from '@/state/backendNetworks/backendNetworks';

export const COIN_ROW_WITH_PADDING_HEIGHT = 56;

Expand All @@ -44,7 +44,7 @@ interface InputCoinRowProps {
nativePriceChange?: string;
onPress: (asset: ParsedSearchAsset | null) => void;
output?: false | undefined;
uniqueId: string;
uniqueId: UniqueId;
testID?: string;
}

Expand Down Expand Up @@ -178,7 +178,8 @@ export function CoinRow({ isFavorite, onPress, output, uniqueId, testID, ...asse
}

const InfoButton = ({ address, chainId }: { address: string; chainId: ChainId }) => {
const supportedChain = SUPPORTED_CHAIN_IDS.includes(chainId);
const getSupportedChainIds = useBackendNetworksStore(state => state.getSupportedChainIds);
const supportedChain = getSupportedChainIds().includes(chainId);

const handleCopy = useCallback(() => {
haptics.selection();
Expand Down
2 changes: 1 addition & 1 deletion src/__swaps__/screens/Swap/components/FlipButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { TIMING_CONFIGS } from '@/components/animations/animationConfigs';
import { SwapAssetType } from '@/__swaps__/types/swap';
import { GestureHandlerButton } from './GestureHandlerButton';
import { useSwapsStore } from '@/state/swaps/swapsStore';
import { ChainId } from '@/chains/types';
import { ChainId } from '@/state/backendNetworks/types';

export const FlipButton = () => {
const { isDarkMode } = useColorMode();
Expand Down
2 changes: 1 addition & 1 deletion src/__swaps__/screens/Swap/components/GasButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { NavigationSteps, useSwapContext } from '../providers/swap-provider';
import { EstimatedSwapGasFee, EstimatedSwapGasFeeSlot } from './EstimatedSwapGasFee';
import { GestureHandlerButton } from './GestureHandlerButton';
import { UnmountOnAnimatedReaction } from './UnmountOnAnimatedReaction';
import { ChainId } from '@/chains/types';
import { ChainId } from '@/state/backendNetworks/types';

const { SWAP_GAS_ICONS } = gasUtils;
const GAS_BUTTON_HIT_SLOP = 16;
Expand Down
2 changes: 1 addition & 1 deletion src/__swaps__/screens/Swap/components/GasPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Animated, { runOnJS, useAnimatedReaction, useAnimatedStyle, withDelay, wi

import { THICK_BORDER_WIDTH } from '@/__swaps__/screens/Swap/constants';
import { NavigationSteps, useSwapContext } from '@/__swaps__/screens/Swap/providers/swap-provider';
import { ChainId } from '@/chains/types';
import { ChainId } from '@/state/backendNetworks/types';
import { GasSpeed } from '@/__swaps__/types/gas';
import { gweiToWei, weiToGwei } from '@/parsers';
import {
Expand Down
10 changes: 7 additions & 3 deletions src/__swaps__/screens/Swap/components/ReviewPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ import { useSelectedGasSpeed } from '../hooks/useSelectedGas';
import { NavigationSteps, useSwapContext } from '../providers/swap-provider';
import { EstimatedSwapGasFee, EstimatedSwapGasFeeSlot } from './EstimatedSwapGasFee';
import { UnmountOnAnimatedReaction } from './UnmountOnAnimatedReaction';
import { chainsLabel, chainsNativeAsset } from '@/chains';
import { ChainId } from '@/chains/types';
import { getChainsLabelWorklet, useBackendNetworksStore } from '@/state/backendNetworks/backendNetworks';
import { ChainId } from '@/state/backendNetworks/types';

const UNKNOWN_LABEL = i18n.t(i18n.l.swap.unknown);
const REVIEW_LABEL = i18n.t(i18n.l.expanded_state.swap_details.review);
Expand Down Expand Up @@ -245,14 +245,17 @@ export const SlippageRow = () => {
export function ReviewPanel() {
const { navigate } = useNavigation();
const { isDarkMode } = useColorMode();
const backendNetworks = useBackendNetworksStore(state => state.backendNetworksSharedValue);
const { configProgress, lastTypedInput, internalSelectedInputAsset, internalSelectedOutputAsset, quote } = useSwapContext();

const labelTertiary = useForegroundColor('labelTertiary');
const separator = useForegroundColor('separator');

const unknown = i18n.t(i18n.l.swap.unknown);

const chainName = useDerivedValue(() => chainsLabel[internalSelectedInputAsset.value?.chainId ?? ChainId.mainnet]);
const chainName = useDerivedValue(
() => getChainsLabelWorklet(backendNetworks)[internalSelectedInputAsset.value?.chainId ?? ChainId.mainnet]
);

const minReceivedOrMaxSoldLabel = useDerivedValue(() => {
const isInputBasedTrade = lastTypedInput.value === 'inputAmount' || lastTypedInput.value === 'inputNativeValue';
Expand Down Expand Up @@ -281,6 +284,7 @@ export function ReviewPanel() {
});

const openGasExplainer = useCallback(async () => {
const chainsNativeAsset = useBackendNetworksStore.getState().getChainsNativeAsset();
const nativeAsset = chainsNativeAsset[swapsStore.getState().inputAsset?.chainId ?? ChainId.mainnet];
navigate(Routes.EXPLAIN_SHEET, {
chainId: swapsStore.getState().inputAsset?.chainId ?? ChainId.mainnet,
Expand Down
2 changes: 1 addition & 1 deletion src/__swaps__/screens/Swap/components/SwapCoinIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { FallbackIcon as CoinIconTextFallback, isETH } from '@/utils';
import { FastFallbackCoinIconImage } from '@/components/asset-list/RecyclerAssetList2/FastComponents/FastFallbackCoinIconImage';
import Animated from 'react-native-reanimated';
import FastImage, { Source } from 'react-native-fast-image';
import { ChainId } from '@/chains/types';
import { ChainId } from '@/state/backendNetworks/types';

// TODO: Delete this and replace with RainbowCoinIcon
// ⚠️ When replacing this component with RainbowCoinIcon, make sure
Expand Down
2 changes: 1 addition & 1 deletion src/__swaps__/screens/Swap/components/SwapOutputAsset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { TokenList } from '@/__swaps__/screens/Swap/components/TokenList/TokenLi
import { BASE_INPUT_WIDTH, INPUT_INNER_WIDTH, INPUT_PADDING, THICK_BORDER_WIDTH } from '@/__swaps__/screens/Swap/constants';
import { IS_ANDROID, IS_IOS } from '@/env';
import { useSwapContext } from '@/__swaps__/screens/Swap/providers/swap-provider';
import { ChainId } from '@/chains/types';
import { ChainId } from '@/state/backendNetworks/types';
import * as i18n from '@/languages';
import { useNavigation } from '@/navigation';
import Routes from '@/navigation/routesNames';
Expand Down
17 changes: 10 additions & 7 deletions src/__swaps__/screens/Swap/components/TokenList/ChainSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Text as RNText, StyleSheet } from 'react-native';
import Animated, { useDerivedValue, useSharedValue } from 'react-native-reanimated';

import { useSwapContext } from '@/__swaps__/screens/Swap/providers/swap-provider';
import { ChainId } from '@/chains/types';
import { ChainId } from '@/state/backendNetworks/types';
import { opacity } from '@/__swaps__/utils/swaps';
import { analyticsV2 } from '@/analytics';
import { ChainImage } from '@/components/coin-icon/ChainImage';
Expand All @@ -18,7 +18,7 @@ import { userAssetsStore, useUserAssetsStore } from '@/state/assets/userAssets';
import { swapsStore } from '@/state/swaps/swapsStore';
import { showActionSheetWithOptions } from '@/utils';
import { OnPressMenuItemEventObject } from 'react-native-ios-context-menu';
import { chainsLabel, chainsName } from '@/chains';
import { getChainsLabelWorklet, getChainsNameWorklet, useBackendNetworksStore } from '@/state/backendNetworks/backendNetworks';

type ChainSelectionProps = {
allText?: string;
Expand All @@ -29,6 +29,7 @@ export const ChainSelection = memo(function ChainSelection({ allText, output }:
const { isDarkMode } = useColorMode();
const { accentColor: accountColor } = useAccountAccentColor();
const { selectedOutputChainId, setSelectedOutputChainId } = useSwapContext();
const backendNetworks = useBackendNetworksStore(state => state.backendNetworksSharedValue);

// chains sorted by balance on output, chains without balance hidden on input
const { balanceSortedChainList, filter } = useUserAssetsStore(state => ({
Expand All @@ -47,11 +48,13 @@ export const ChainSelection = memo(function ChainSelection({ allText, output }:
}, [accountColor, isDarkMode]);

const chainName = useDerivedValue(() => {
const chainLabels = getChainsLabelWorklet(backendNetworks);

return output
? chainsLabel[selectedOutputChainId.value]
? chainLabels[selectedOutputChainId.value]
: inputListFilter.value === 'all'
? allText
: chainsLabel[inputListFilter.value as ChainId];
: chainLabels[inputListFilter.value as ChainId];
});

const handleSelectChain = useCallback(
Expand All @@ -78,11 +81,11 @@ export const ChainSelection = memo(function ChainSelection({ allText, output }:
const supportedChains = balanceSortedChainList.map(chainId => {
return {
actionKey: `${chainId}`,
actionTitle: chainsLabel[chainId],
actionTitle: getChainsLabelWorklet(backendNetworks)[chainId],
icon: {
iconType: 'ASSET',
// NOTE: chainsName[chainId] for mainnet is 'mainnet' and we need it to be 'ethereum'
iconValue: chainId === ChainId.mainnet ? 'ethereumBadge' : `${chainsName[chainId]}BadgeNoShadow`,
iconValue: chainId === ChainId.mainnet ? 'ethereumBadge' : `${getChainsNameWorklet(backendNetworks)[chainId]}BadgeNoShadow`,
},
};
});
Expand All @@ -101,7 +104,7 @@ export const ChainSelection = memo(function ChainSelection({ allText, output }:
return {
menuItems: supportedChains,
};
}, [balanceSortedChainList, output]);
}, [backendNetworks, balanceSortedChainList, output]);

const onShowActionSheet = useCallback(() => {
const chainTitles = menuConfig.menuItems.map(chain => chain.actionTitle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { COIN_ROW_WITH_PADDING_HEIGHT, CoinRow } from '@/__swaps__/screens/Swap/
import { ListEmpty } from '@/__swaps__/screens/Swap/components/TokenList/ListEmpty';
import { AssetToBuySectionId, useSearchCurrencyLists } from '@/__swaps__/screens/Swap/hooks/useSearchCurrencyLists';
import { useSwapContext } from '@/__swaps__/screens/Swap/providers/swap-provider';
import { ChainId } from '@/chains/types';
import { ChainId } from '@/state/backendNetworks/types';
import { SearchAsset } from '@/__swaps__/types/search';
import { SwapAssetType } from '@/__swaps__/types/swap';
import { parseSearchAsset } from '@/__swaps__/utils/assets';
Expand Down
2 changes: 1 addition & 1 deletion src/__swaps__/screens/Swap/hooks/useCustomGas.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChainId } from '@/chains/types';
import { ChainId } from '@/state/backendNetworks/types';
import { createRainbowStore } from '@/state/internal/createRainbowStore';

export type EIP1159GasSettings = {
Expand Down
2 changes: 1 addition & 1 deletion src/__swaps__/screens/Swap/hooks/useEstimatedGasFee.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChainId } from '@/chains/types';
import { ChainId } from '@/state/backendNetworks/types';
import { weiToGwei } from '@/parsers';
import { convertAmountToNativeDisplayWorklet, formatNumber, multiply } from '@/helpers/utilities';
import { useNativeAsset } from '@/utils/ethereumUtils';
Expand Down
2 changes: 1 addition & 1 deletion src/__swaps__/screens/Swap/hooks/useSearchCurrencyLists.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TokenSearchResult, useTokenSearch } from '@/__swaps__/screens/Swap/resources/search/search';
import { ChainId } from '@/chains/types';
import { ChainId } from '@/state/backendNetworks/types';
import { SearchAsset, TokenSearchAssetKey, TokenSearchThreshold } from '@/__swaps__/types/search';
import { addHexPrefix } from '@/handlers/web3';
import { isLowerCaseMatch, filterList } from '@/utils';
Expand Down
2 changes: 1 addition & 1 deletion src/__swaps__/screens/Swap/hooks/useSelectedGas.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChainId } from '@/chains/types';
import { ChainId } from '@/state/backendNetworks/types';
import { GasSpeed } from '@/__swaps__/types/gas';
import { getCachedGasSuggestions, useMeteorologySuggestions } from '@/__swaps__/utils/meteorology';
import { createRainbowStore } from '@/state/internal/createRainbowStore';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { CrosschainQuote, Quote, QuoteError, SwapType } from '@rainbow-me/swaps'
import { useQuery } from '@tanstack/react-query';

import { ParsedSearchAsset } from '@/__swaps__/types/assets';
import { ChainId } from '@/chains/types';
import { ChainId } from '@/state/backendNetworks/types';
import { estimateUnlockAndCrosschainSwap } from '@/raps/actions/crosschainSwap';
import { estimateUnlockAndSwap } from '@/raps/actions/swap';
import { QueryConfigWithSelect, QueryFunctionArgs, QueryFunctionResult, createQueryKey } from '@/react-query';
Expand Down
10 changes: 5 additions & 5 deletions src/__swaps__/screens/Swap/hooks/useSwapInputsController.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { divWorklet, equalWorklet, greaterThanWorklet, isNumberStringWorklet, mulWorklet, toFixedWorklet } from '@/safe-math/SafeMath';
import { SCRUBBER_WIDTH, SLIDER_WIDTH, snappySpringConfig } from '@/__swaps__/screens/Swap/constants';
import { ExtendedAnimatedAssetWithColors } from '@/__swaps__/types/assets';
import { ChainId } from '@/chains/types';
import { ChainId } from '@/state/backendNetworks/types';
import { RequestNewQuoteParams, inputKeys, inputMethods, inputValuesType } from '@/__swaps__/types/swap';
import { valueBasedDecimalFormatter } from '@/__swaps__/utils/decimalFormatter';
import { getInputValuesForSliderPositionWorklet, updateInputValuesAfterFlip } from '@/__swaps__/utils/flipAssets';
Expand Down Expand Up @@ -686,20 +686,20 @@ export function useSwapInputsController({
() => ({
assetToBuyId: internalSelectedOutputAsset.value?.uniqueId,
assetToSellId: internalSelectedInputAsset.value?.uniqueId,
assetToSellNetwork: internalSelectedInputAsset.value?.chainId,
assetToSellChainId: internalSelectedInputAsset.value?.chainId,
}),
(current, previous) => {
const didInputAssetChange = current.assetToSellId !== previous?.assetToSellId;
const didOutputAssetChange = current.assetToBuyId !== previous?.assetToBuyId;

if (!didInputAssetChange && !didOutputAssetChange) return;

if (current.assetToSellNetwork !== previous?.assetToSellNetwork) {
const previousDefaultSlippage = getDefaultSlippageWorklet(previous?.assetToSellNetwork || ChainId.mainnet, REMOTE_CONFIG);
if (current.assetToSellChainId !== previous?.assetToSellChainId) {
const previousDefaultSlippage = getDefaultSlippageWorklet(previous?.assetToSellChainId || ChainId.mainnet, REMOTE_CONFIG);

// If the user has not overridden the default slippage, update it
if (slippage.value === previousDefaultSlippage) {
const newSlippage = getDefaultSlippageWorklet(current.assetToSellNetwork || ChainId.mainnet, REMOTE_CONFIG);
const newSlippage = getDefaultSlippageWorklet(current.assetToSellChainId || ChainId.mainnet, REMOTE_CONFIG);
slippage.value = newSlippage;
runOnJS(setSlippage)(newSlippage);
}
Expand Down
12 changes: 9 additions & 3 deletions src/__swaps__/screens/Swap/hooks/useSwapOutputQuotesDisabled.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { SharedValue, useDerivedValue } from 'react-native-reanimated';
import { ExtendedAnimatedAssetWithColors } from '@/__swaps__/types/assets';
import { supportedSwapExactOutputChainIds, supportedBridgeExactOutputChainIds } from '@/chains';
import {
useBackendNetworksStore,
getSwapExactOutputSupportedChainIdsWorklet,
getBridgeExactOutputSupportedChainIdsWorklet,
} from '@/state/backendNetworks/backendNetworks';

export const useSwapOutputQuotesDisabled = ({
inputAsset,
Expand All @@ -9,13 +13,15 @@ export const useSwapOutputQuotesDisabled = ({
inputAsset: SharedValue<ExtendedAnimatedAssetWithColors | null>;
outputAsset: SharedValue<ExtendedAnimatedAssetWithColors | null>;
}): SharedValue<boolean> => {
const backendNetworks = useBackendNetworksStore(state => state.backendNetworksSharedValue);

const outputQuotesAreDisabled = useDerivedValue(() => {
if (!inputAsset.value || !outputAsset.value) return false;

if (inputAsset.value.chainId === outputAsset.value.chainId) {
return !supportedSwapExactOutputChainIds.includes(inputAsset.value.chainId);
return !getSwapExactOutputSupportedChainIdsWorklet(backendNetworks).includes(inputAsset.value.chainId);
} else {
return !supportedBridgeExactOutputChainIds.includes(inputAsset.value.chainId);
return !getBridgeExactOutputSupportedChainIdsWorklet(backendNetworks).includes(inputAsset.value.chainId);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
toScaledIntegerWorklet,
} from '@/safe-math/SafeMath';
import { ExtendedAnimatedAssetWithColors } from '@/__swaps__/types/assets';
import { ChainId } from '@/chains/types';
import { ChainId } from '@/state/backendNetworks/types';
import { ParsedAddressAsset } from '@/entities';
import { useUserNativeNetworkAsset } from '@/resources/assets/useUserAsset';
import { CrosschainQuote, Quote, QuoteError } from '@rainbow-me/swaps';
Expand Down
7 changes: 4 additions & 3 deletions src/__swaps__/screens/Swap/providers/swap-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { useSwapTextStyles } from '@/__swaps__/screens/Swap/hooks/useSwapTextSty
import { SwapWarningType, useSwapWarning } from '@/__swaps__/screens/Swap/hooks/useSwapWarning';
import { userAssetsQueryKey as swapsUserAssetsQueryKey } from '@/__swaps__/screens/Swap/resources/assets/userAssets';
import { AddressOrEth, ExtendedAnimatedAssetWithColors, ParsedSearchAsset } from '@/__swaps__/types/assets';
import { ChainId } from '@/chains/types';
import { ChainId } from '@/state/backendNetworks/types';
import { SwapAssetType, inputKeys } from '@/__swaps__/types/swap';
import { clamp, getDefaultSlippageWorklet, parseAssetAndExtend } from '@/__swaps__/utils/swaps';
import { analyticsV2 } from '@/analytics';
Expand Down Expand Up @@ -58,7 +58,7 @@ import { SyncGasStateToSharedValues, SyncQuoteSharedValuesToState } from './Sync
import { performanceTracking, Screens, TimeToSignOperation } from '@/state/performance/performance';
import { getRemoteConfig } from '@/model/remoteConfig';
import { useConnectedToHardhatStore } from '@/state/connectedToHardhat';
import { chainsNativeAsset } from '@/chains';
import { useBackendNetworksStore, getChainsNativeAssetWorklet } from '@/state/backendNetworks/backendNetworks';
import { getSwapsNavigationParams } from '../navigateToSwaps';
import { LedgerSigner } from '@/handlers/LedgerSigner';

Expand Down Expand Up @@ -154,6 +154,7 @@ const getInitialSliderXPosition = ({
export const SwapProvider = ({ children }: SwapProviderProps) => {
const { nativeCurrency } = useAccountSettings();

const backendNetworks = useBackendNetworksStore(state => state.backendNetworksSharedValue);
const initialValues = getSwapsNavigationParams();

const isFetching = useSharedValue(false);
Expand Down Expand Up @@ -792,7 +793,7 @@ export const SwapProvider = ({ children }: SwapProviderProps) => {
}

if (hasEnoughFundsForGas.value === false) {
const nativeCurrency = chainsNativeAsset[sellAsset?.chainId || ChainId.mainnet];
const nativeCurrency = getChainsNativeAssetWorklet(backendNetworks)[sellAsset?.chainId || ChainId.mainnet];
return {
label: `${insufficient} ${nativeCurrency.symbol}`,
disabled: true,
Expand Down
Loading

0 comments on commit e67803c

Please sign in to comment.