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

Swaps v2 cleanup duplicates / unused utils #6202

Merged
merged 4 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 0 additions & 4 deletions src/__swaps__/screens/Swap/components/AnimatedBlurView.tsx

This file was deleted.

8 changes: 4 additions & 4 deletions src/__swaps__/screens/Swap/components/EstimatedSwapGasFee.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { SharedValue, useAnimatedStyle, useDerivedValue, withRepeat, withSequenc
import { opacity } from '@/__swaps__/utils/swaps';
import { TIMING_CONFIGS } from '@/components/animations/animationConfigs';
import { useDelayedValue } from '@/hooks/reanimated/useDelayedValue';
import { pulsingConfig, sliderConfig } from '../constants';
import { GasSettings } from '../hooks/useCustomGas';
import { useSwapEstimatedGasFee } from '../hooks/useEstimatedGasFee';
import { useSwapContext } from '../providers/swap-provider';
import { pulsingConfig, sliderConfig } from '@/__swaps__/screens/Swap/constants';
import { GasSettings } from '@/__swaps__/screens/Swap/hooks/useCustomGas';
import { useSwapEstimatedGasFee } from '@/__swaps__/screens/Swap/hooks/useEstimatedGasFee';
import { useSwapContext } from '@/__swaps__/screens/Swap/providers/swap-provider';

type EstimatedSwapGasFeeProps = { gasSettings?: GasSettings } & Partial<
Pick<TextProps, 'align' | 'color' | 'size' | 'weight' | 'tabularNumbers'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { AddressZero } from '@ethersproject/constants';
import { ETH_ADDRESS } from '@/references';
import { DEVICE_WIDTH } from '@/utils/deviceUtils';
import { GestureHandlerButton } from './GestureHandlerButton';
import { convertAmountToNativeDisplayWorklet } from '@/__swaps__/utils/numbers';
import { convertAmountToNativeDisplayWorklet } from '@/helpers/utilities';
import { useAccountSettings } from '@/hooks';

export const ExchangeRateBubble = () => {
Expand Down
6 changes: 3 additions & 3 deletions src/__swaps__/screens/Swap/components/FlipButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Bleed, Box, IconContainer, Text, globalColors, useColorMode } from '@/d
import { SEPARATOR_COLOR } from '@/__swaps__/screens/Swap/constants';
import { getColorValueForThemeWorklet, opacity } from '@/__swaps__/utils/swaps';
import { IS_ANDROID, IS_IOS } from '@/env';
import { AnimatedBlurView } from '@/__swaps__/screens/Swap/components/AnimatedBlurView';
import { AnimatedBlurView } from '@/components/AnimatedComponents/AnimatedBlurView';
import { useSwapContext } from '@/__swaps__/screens/Swap/providers/swap-provider';
import { TIMING_CONFIGS } from '@/components/animations/animationConfigs';
import { SwapAssetType } from '@/__swaps__/types/swap';
Expand Down Expand Up @@ -90,7 +90,7 @@ export const FlipButton = () => {
return {
shadowColor: isDarkMode
? globalColors.grey100
: getColorValueForThemeWorklet(internalSelectedOutputAsset.value?.mixedShadowColor, false, true),
: getColorValueForThemeWorklet(internalSelectedOutputAsset.value?.mixedShadowColor, false),
};
});

Expand Down Expand Up @@ -162,7 +162,7 @@ const SpinnerComponent = () => {

const animatedColor = useDerivedValue(() => {
return withTiming(
getColorValueForThemeWorklet(internalSelectedOutputAsset.value?.highContrastColor, isDarkMode, true),
getColorValueForThemeWorklet(internalSelectedOutputAsset.value?.highContrastColor, isDarkMode),
TIMING_CONFIGS.slowFadeConfig
);
});
Expand Down
6 changes: 3 additions & 3 deletions src/__swaps__/screens/Swap/components/GasButton.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GasSpeed } from '@/__swaps__/types/gas';
import { weiToGwei } from '@/__swaps__/utils/ethereum';
import { weiToGwei } from '@/parsers';
import { getCachedCurrentBaseFee, useMeteorologySuggestions } from '@/__swaps__/utils/meteorology';
import { add, formatNumber } from '@/__swaps__/utils/numbers';
import { add, formatNumber } from '@/helpers/utilities';
import { getColorValueForThemeWorklet } from '@/__swaps__/utils/swaps';
import { ButtonPressAnimation } from '@/components/animations';
import { ContextMenu } from '@/components/context-menu';
Expand Down Expand Up @@ -217,7 +217,7 @@ export function ReviewGasButton() {

const animatedBorderColor = useAnimatedStyle(() => {
return {
borderColor: getColorValueForThemeWorklet(internalSelectedOutputAsset.value?.highContrastColor, isDarkMode, true),
borderColor: getColorValueForThemeWorklet(internalSelectedOutputAsset.value?.highContrastColor, isDarkMode),
};
});

Expand Down
5 changes: 2 additions & 3 deletions src/__swaps__/screens/Swap/components/GasPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { MIN_FLASHBOTS_PRIORITY_FEE, THICK_BORDER_WIDTH } from '@/__swaps__/scre
import { NavigationSteps, useSwapContext } from '@/__swaps__/screens/Swap/providers/swap-provider';
import { ChainId } from '@/chains/types';
import { GasSpeed } from '@/__swaps__/types/gas';
import { gweiToWei, weiToGwei } from '@/__swaps__/utils/ethereum';
import { gweiToWei, weiToGwei } from '@/parsers';
import {
getCachedCurrentBaseFee,
getSelectedSpeedSuggestion,
Expand All @@ -16,13 +16,12 @@ import {
useMeteorologySuggestion,
useMeteorologySuggestions,
} from '@/__swaps__/utils/meteorology';
import { add, formatNumber, greaterThan, multiply, subtract } from '@/__swaps__/utils/numbers';
import { add, greaterThan, multiply, subtract, lessThan, formatNumber } from '@/helpers/utilities';
import { opacity } from '@/__swaps__/utils/swaps';
import { ButtonPressAnimation } from '@/components/animations';
import { SPRING_CONFIGS } from '@/components/animations/animationConfigs';
import { Bleed, Box, Inline, Separator, Stack, Text, globalColors, useColorMode, useForegroundColor } from '@/design-system';
import { IS_ANDROID } from '@/env';
import { lessThan } from '@/helpers/utilities';
import { useNavigation } from '@/navigation';
import Routes from '@/navigation/routesNames';
import { createRainbowStore } from '@/state/internal/createRainbowStore';
Expand Down
7 changes: 1 addition & 6 deletions src/__swaps__/screens/Swap/components/ReviewPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ import { AnimatedChainImage } from '@/__swaps__/screens/Swap/components/Animated
import { ReviewGasButton } from '@/__swaps__/screens/Swap/components/GasButton';
import { GestureHandlerButton } from '@/__swaps__/screens/Swap/components/GestureHandlerButton';
import { useEstimatedTime } from '@/__swaps__/utils/meteorology';
import {
convertRawAmountToBalance,
convertRawAmountToBalanceWorklet,
handleSignificantDecimals,
multiply,
} from '@/__swaps__/utils/numbers';
import { convertRawAmountToBalance, convertRawAmountToBalanceWorklet, handleSignificantDecimals, multiply } from '@/helpers/utilities';
import { opacity } from '@/__swaps__/utils/swaps';
import { ButtonPressAnimation } from '@/components/animations';
import { SPRING_CONFIGS } from '@/components/animations/animationConfigs';
Expand Down
10 changes: 4 additions & 6 deletions src/__swaps__/screens/Swap/components/SwapActionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function SwapButton({
});

const secondaryTextStyles = useAnimatedStyle(() => {
const secondaryColor = getColorValueForThemeWorklet(asset.value?.textColor, isDarkMode, true);
const secondaryColor = getColorValueForThemeWorklet(asset.value?.textColor, isDarkMode);

let opacity = isDarkMode ? 0.76 : 0.8;
if (secondaryColor === globalColors.grey100) {
Expand All @@ -75,9 +75,7 @@ function SwapButton({

const buttonWrapperStyles = useAnimatedStyle(() => {
return {
backgroundColor: outline
? 'transparent'
: getColorValueForThemeWorklet(asset.value?.highContrastColor, isDarkMode, true) || fallbackColor,
backgroundColor: outline ? 'transparent' : getColorValueForThemeWorklet(asset.value?.highContrastColor, isDarkMode) || fallbackColor,
borderColor: outline ? separatorSecondary : undefined,
borderRadius: borderRadius ?? 24,
height: small ? 36 : 48,
Expand Down Expand Up @@ -169,7 +167,7 @@ const HoldProgress = ({ holdProgress }: { holdProgress: SharedValue<number> }) =
const { internalSelectedOutputAsset } = useSwapContext();

const [brightenedColor, setBrightenedColor] = useState<string>(
transformColor(getColorValueForThemeWorklet(internalSelectedOutputAsset.value?.highContrastColor, isDarkMode, true), false)
transformColor(getColorValueForThemeWorklet(internalSelectedOutputAsset.value?.highContrastColor, isDarkMode), false)
);

const holdProgressStyle = useAnimatedStyle(() => {
Expand All @@ -192,7 +190,7 @@ const HoldProgress = ({ holdProgress }: { holdProgress: SharedValue<number> }) =
() => internalSelectedOutputAsset.value?.highContrastColor,
(current, previous) => {
if (current && current !== previous) {
runOnJS(transformColor)(getColorValueForThemeWorklet(current, isDarkMode, true));
runOnJS(transformColor)(getColorValueForThemeWorklet(current, isDarkMode));
}
},
[]
Expand Down
8 changes: 4 additions & 4 deletions src/__swaps__/screens/Swap/components/SwapBackground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ export const SwapBackground = () => {
const { internalSelectedInputAsset, internalSelectedOutputAsset } = useSwapContext();

const animatedTopColor = useDerivedValue(() => {
if (IS_TEST) return getColorValueForThemeWorklet(DEFAULT_BACKGROUND_COLOR, isDarkMode, true);
if (IS_TEST) return getColorValueForThemeWorklet(DEFAULT_BACKGROUND_COLOR, isDarkMode);
return withTiming(
getColorValueForThemeWorklet(internalSelectedInputAsset.value?.tintedBackgroundColor || DEFAULT_BACKGROUND_COLOR, isDarkMode, true),
getColorValueForThemeWorklet(internalSelectedInputAsset.value?.tintedBackgroundColor || DEFAULT_BACKGROUND_COLOR, isDarkMode),
TIMING_CONFIGS.slowFadeConfig
);
});

const animatedBottomColor = useDerivedValue(() => {
if (IS_TEST) return getColorValueForThemeWorklet(DEFAULT_BACKGROUND_COLOR, isDarkMode, true);
if (IS_TEST) return getColorValueForThemeWorklet(DEFAULT_BACKGROUND_COLOR, isDarkMode);
return withTiming(
getColorValueForThemeWorklet(internalSelectedOutputAsset.value?.tintedBackgroundColor || DEFAULT_BACKGROUND_COLOR, isDarkMode, true),
getColorValueForThemeWorklet(internalSelectedOutputAsset.value?.tintedBackgroundColor || DEFAULT_BACKGROUND_COLOR, isDarkMode),
TIMING_CONFIGS.slowFadeConfig
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const SwapCoinIconTextFallback = ({ asset, height, width, style }: SwapCo

const backgroundColor = useAnimatedStyle(() => {
return {
backgroundColor: getColorValueForThemeWorklet(asset.value?.color, isDarkMode, true),
backgroundColor: getColorValueForThemeWorklet(asset.value?.color, isDarkMode),
};
});

Expand All @@ -61,7 +61,7 @@ export const SwapCoinIconTextFallback = ({ asset, height, width, style }: SwapCo
const animatedFontSize = useAnimatedStyle(() => {
return {
fontSize: buildFallbackFontSize(formattedSymbol.value, width),
color: getColorValueForThemeWorklet(asset.value?.textColor, isDarkMode, true),
color: getColorValueForThemeWorklet(asset.value?.textColor, isDarkMode),
};
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import { StyleSheet } from 'react-native';
import Animated, { Easing, SharedValue, useAnimatedStyle, withRepeat, withSequence, withTiming } from 'react-native-reanimated';
import { SLIDER_COLLAPSED_HEIGHT, SLIDER_HEIGHT, caretConfig } from '@/__swaps__/screens/Swap/constants';
import { equalWorklet } from '@/__swaps__/safe-math/SafeMath';
import { equalWorklet } from '@/safe-math/SafeMath';
import { NavigationSteps } from '@/__swaps__/screens/Swap/hooks/useSwapNavigation';
import { useSwapContext } from '@/__swaps__/screens/Swap/providers/swap-provider';
import { inputKeys } from '@/__swaps__/types/swap';
Expand Down Expand Up @@ -65,7 +65,7 @@ export function SwapInputValuesCaret({ inputCaretType, disabled }: { inputCaretT
const selectedAsset =
inputCaretType === 'inputAmount' || inputCaretType === 'inputNativeValue' ? internalSelectedInputAsset : internalSelectedOutputAsset;
return {
backgroundColor: getColorValueForThemeWorklet(selectedAsset.value?.highContrastColor, isDarkMode, true),
backgroundColor: getColorValueForThemeWorklet(selectedAsset.value?.highContrastColor, isDarkMode),
};
});

Expand Down
2 changes: 1 addition & 1 deletion src/__swaps__/screens/Swap/components/SwapNativeInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Animated, { runOnJS, useAnimatedStyle, useDerivedValue } from 'react-nati
import { SwapInputValuesCaret } from '@/__swaps__/screens/Swap/components/SwapInputValuesCaret';
import { GestureHandlerButton } from '@/__swaps__/screens/Swap/components/GestureHandlerButton';
import { useSwapContext } from '@/__swaps__/screens/Swap/providers/swap-provider';
import { equalWorklet } from '@/__swaps__/safe-math/SafeMath';
import { equalWorklet } from '@/safe-math/SafeMath';

export function SwapNativeInput({
nativeInputType,
Expand Down
2 changes: 1 addition & 1 deletion src/__swaps__/screens/Swap/components/SwapNumberPad.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Animated, {
} from 'react-native-reanimated';
import { supportedNativeCurrencies } from '@/references';
import { Bleed, Box, Columns, HitSlop, Separator, Text, useColorMode, useForegroundColor } from '@/design-system';
import { equalWorklet } from '@/__swaps__/safe-math/SafeMath';
import { equalWorklet } from '@/safe-math/SafeMath';
import { stripNonDecimalNumbers } from '@/__swaps__/utils/swaps';
import {
CUSTOM_KEYBOARD_HEIGHT,
Expand Down
14 changes: 7 additions & 7 deletions src/__swaps__/screens/Swap/components/SwapSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { SPRING_CONFIGS, TIMING_CONFIGS } from '@/components/animations/animatio
import { AnimatedText, Bleed, Box, Column, Columns, Inline, globalColors, useColorMode, useForegroundColor } from '@/design-system';
import { IS_IOS } from '@/env';
import { triggerHapticFeedback } from '@/screens/points/constants';
import { greaterThanWorklet } from '@/__swaps__/safe-math/SafeMath';
import { greaterThanWorklet } from '@/safe-math/SafeMath';
import {
SCRUBBER_WIDTH,
SLIDER_COLLAPSED_HEIGHT,
Expand Down Expand Up @@ -90,18 +90,18 @@ export const SwapSlider = ({
const colors = useDerivedValue(() => ({
inactiveColorLeft: opacityWorklet(
dualColor
? getColorValueForThemeWorklet(internalSelectedOutputAsset.value?.highContrastColor, isDarkMode, true)
: getColorValueForThemeWorklet(internalSelectedInputAsset.value?.highContrastColor, isDarkMode, true),
? getColorValueForThemeWorklet(internalSelectedOutputAsset.value?.highContrastColor, isDarkMode)
: getColorValueForThemeWorklet(internalSelectedInputAsset.value?.highContrastColor, isDarkMode),
0.9
),
activeColorLeft: dualColor
? getColorValueForThemeWorklet(internalSelectedOutputAsset.value?.highContrastColor, isDarkMode, true)
: getColorValueForThemeWorklet(internalSelectedInputAsset.value?.highContrastColor, isDarkMode, true),
? getColorValueForThemeWorklet(internalSelectedOutputAsset.value?.highContrastColor, isDarkMode)
: getColorValueForThemeWorklet(internalSelectedInputAsset.value?.highContrastColor, isDarkMode),
inactiveColorRight: dualColor
? opacityWorklet(getColorValueForThemeWorklet(internalSelectedInputAsset.value?.highContrastColor, isDarkMode, true), 0.9)
? opacityWorklet(getColorValueForThemeWorklet(internalSelectedInputAsset.value?.highContrastColor, isDarkMode), 0.9)
: separatorSecondary,
activeColorRight: dualColor
? getColorValueForThemeWorklet(internalSelectedInputAsset.value?.highContrastColor, isDarkMode, true)
? getColorValueForThemeWorklet(internalSelectedInputAsset.value?.highContrastColor, isDarkMode)
: fillSecondary,
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { ChainId } from '@/chains/types';
import { SearchAsset } from '@/__swaps__/types/search';
import { SwapAssetType } from '@/__swaps__/types/swap';
import { parseSearchAsset } from '@/__swaps__/utils/assets';
import { getChainColorWorklet, getStandardizedUniqueIdWorklet } from '@/__swaps__/utils/swaps';
import { getChainColorWorklet } from '@/__swaps__/utils/swaps';
import { getUniqueId } from '@/utils/ethereumUtils';
import { analyticsV2 } from '@/analytics';
import { AnimatedTextIcon } from '@/components/AnimatedComponents/AnimatedTextIcon';
import { TIMING_CONFIGS } from '@/components/animations/animationConfigs';
Expand Down Expand Up @@ -99,10 +100,7 @@ export const TokenToBuyList = () => {
const handleSelectToken = useCallback(
(token: SearchAsset) => {
runOnUI(() => {
if (
internalSelectedInputAsset.value &&
getStandardizedUniqueIdWorklet({ address: token.address, chainId: token.chainId }) !== internalSelectedOutputAsset.value?.uniqueId
) {
if (internalSelectedInputAsset.value && getUniqueId(token.address, token.chainId) !== internalSelectedOutputAsset.value?.uniqueId) {
isQuoteStale.value = 1;
isFetching.value = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ListEmpty } from '@/__swaps__/screens/Swap/components/TokenList/ListEmp
import { useSwapContext } from '@/__swaps__/screens/Swap/providers/swap-provider';
import { ParsedSearchAsset } from '@/__swaps__/types/assets';
import { SwapAssetType } from '@/__swaps__/types/swap';
import { getStandardizedUniqueIdWorklet } from '@/__swaps__/utils/swaps';
import { getUniqueId } from '@/utils/ethereumUtils';
import { analyticsV2 } from '@/analytics';
import { useDelayedMount } from '@/hooks/useDelayedMount';
import * as i18n from '@/languages';
Expand Down Expand Up @@ -45,10 +45,7 @@ const TokenToSellListComponent = () => {
if (!token) return;

runOnUI(() => {
if (
internalSelectedOutputAsset.value &&
getStandardizedUniqueIdWorklet({ address: token.address, chainId: token.chainId }) !== internalSelectedInputAsset.value?.uniqueId
) {
if (internalSelectedOutputAsset.value && getUniqueId(token.address, token.chainId) !== internalSelectedInputAsset.value?.uniqueId) {
isQuoteStale.value = 1;
isFetching.value = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/__swaps__/screens/Swap/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { gweiToWei } from '@/__swaps__/utils/ethereum';
import { gweiToWei } from '@/parsers';
import { getDefaultKeyboardHeight } from '@/redux/keyboardHeight';
import { deviceUtils, safeAreaInsetValues } from '@/utils';
import { Easing, WithSpringConfig, WithTimingConfig } from 'react-native-reanimated';
Expand Down
43 changes: 0 additions & 43 deletions src/__swaps__/screens/Swap/dummyValues.ts

This file was deleted.

Loading
Loading