From 4c915c8f91f7bc558465895b3e581a65e9840135 Mon Sep 17 00:00:00 2001 From: woodenfurniture <125113430+woodenfurniture@users.noreply.github.com> Date: Thu, 14 Nov 2024 10:44:05 +1100 Subject: [PATCH] fix: import from wrong slice, prevent it from happening again --- .../LimitOrder/components/LimitOrderInput.tsx | 2 +- .../components/SharedApprovalDescription.tsx | 2 +- .../MultiHopTradeConfirm/components/FeeStep.tsx | 2 +- .../hooks/useIsApprovalInitiallyNeeded.tsx | 5 ++++- .../MultiHopTrade/components/TradeInput/TradeInput.tsx | 4 ++-- .../TradeInput/components/ConfirmSummary.tsx | 4 ++-- .../TradeInput/components/RecipientAddress.tsx | 2 +- .../TradeInput/components/TradeQuotes/TradeQuote.tsx | 10 ++++++---- .../TradeInput/components/TradeQuotes/TradeQuotes.tsx | 2 +- .../TradeInput/hooks/useTradeReceiveAddress.tsx | 2 +- .../components/VerifyAddresses/VerifyAddresses.tsx | 6 ++++-- src/components/MultiHopTrade/hooks/useAccountIds.tsx | 5 ++++- .../hooks/useGetTradeQuotes/useGetTradeQuotes.tsx | 8 +++++--- src/lib/tradeExecution.ts | 2 +- src/state/apis/swapper/helpers/validateTradeQuote.ts | 6 ++++-- src/state/slices/selectors.ts | 1 - 16 files changed, 38 insertions(+), 25 deletions(-) diff --git a/src/components/MultiHopTrade/components/LimitOrder/components/LimitOrderInput.tsx b/src/components/MultiHopTrade/components/LimitOrder/components/LimitOrderInput.tsx index f7568180a3b..21ab84442e3 100644 --- a/src/components/MultiHopTrade/components/LimitOrder/components/LimitOrderInput.tsx +++ b/src/components/MultiHopTrade/components/LimitOrder/components/LimitOrderInput.tsx @@ -20,6 +20,7 @@ import { limitOrderInput } from 'state/slices/limitOrderInputSlice/limitOrderInp import { selectBuyAccountId, selectHasUserEnteredAmount, + selectInputBuyAsset, selectInputSellAmountCryptoPrecision, selectInputSellAmountUsd, selectInputSellAmountUserCurrency, @@ -31,7 +32,6 @@ import { selectUserSlippagePercentageDecimal, } from 'state/slices/limitOrderInputSlice/selectors' import { - selectInputBuyAsset, selectIsAnyAccountMetadataLoadedForChainId, selectUserCurrencyToUsdRate, } from 'state/slices/selectors' diff --git a/src/components/MultiHopTrade/components/MultiHopTradeConfirm/components/ApprovalStep/components/SharedApprovalDescription.tsx b/src/components/MultiHopTrade/components/MultiHopTradeConfirm/components/ApprovalStep/components/SharedApprovalDescription.tsx index a3d556090be..4ff97c180a6 100644 --- a/src/components/MultiHopTrade/components/MultiHopTradeConfirm/components/ApprovalStep/components/SharedApprovalDescription.tsx +++ b/src/components/MultiHopTrade/components/MultiHopTradeConfirm/components/ApprovalStep/components/SharedApprovalDescription.tsx @@ -5,7 +5,7 @@ import { MiddleEllipsis } from 'components/MiddleEllipsis/MiddleEllipsis' import { Text } from 'components/Text' import { useSafeTxQuery } from 'hooks/queries/useSafeTx' import { getTxLink } from 'lib/getTxLink' -import { selectFirstHopSellAccountId } from 'state/slices/selectors' +import { selectFirstHopSellAccountId } from 'state/slices/tradeInputSlice/selectors' import { useAppSelector } from 'state/store' export type TxLineProps = { diff --git a/src/components/MultiHopTrade/components/MultiHopTradeConfirm/components/FeeStep.tsx b/src/components/MultiHopTrade/components/MultiHopTradeConfirm/components/FeeStep.tsx index bd87abd0570..731c521faad 100644 --- a/src/components/MultiHopTrade/components/MultiHopTradeConfirm/components/FeeStep.tsx +++ b/src/components/MultiHopTrade/components/MultiHopTradeConfirm/components/FeeStep.tsx @@ -9,7 +9,7 @@ import { useLocaleFormatter } from 'hooks/useLocaleFormatter/useLocaleFormatter' import { bnOrZero } from 'lib/bignumber/bignumber' import { THORSWAP_MAXIMUM_YEAR_TRESHOLD, THORSWAP_UNIT_THRESHOLD } from 'lib/fees/model' import { selectCalculatedFees, selectThorVotingPower } from 'state/apis/snapshot/selectors' -import { selectInputSellAmountUsd } from 'state/slices/selectors' +import { selectInputSellAmountUsd } from 'state/slices/tradeInputSlice/selectors' import { selectActiveQuoteAffiliateBps } from 'state/slices/tradeQuoteSlice/selectors' import { useAppSelector } from 'state/store' diff --git a/src/components/MultiHopTrade/components/MultiHopTradeConfirm/hooks/useIsApprovalInitiallyNeeded.tsx b/src/components/MultiHopTrade/components/MultiHopTradeConfirm/hooks/useIsApprovalInitiallyNeeded.tsx index 60c7daf5ea5..73060c92677 100644 --- a/src/components/MultiHopTrade/components/MultiHopTradeConfirm/hooks/useIsApprovalInitiallyNeeded.tsx +++ b/src/components/MultiHopTrade/components/MultiHopTradeConfirm/hooks/useIsApprovalInitiallyNeeded.tsx @@ -4,7 +4,10 @@ import { type TradeQuoteStep } from '@shapeshiftoss/swapper' import { useEffect, useMemo, useState } from 'react' import { useIsAllowanceApprovalRequired } from 'hooks/queries/useIsAllowanceApprovalRequired' import { useIsAllowanceResetRequired } from 'hooks/queries/useIsAllowanceResetRequired' -import { selectFirstHopSellAccountId, selectSecondHopSellAccountId } from 'state/slices/selectors' +import { + selectFirstHopSellAccountId, + selectSecondHopSellAccountId, +} from 'state/slices/tradeInputSlice/selectors' import { selectActiveQuote, selectFirstHop, diff --git a/src/components/MultiHopTrade/components/TradeInput/TradeInput.tsx b/src/components/MultiHopTrade/components/TradeInput/TradeInput.tsx index aaf1d7d019c..26a4bb7a48a 100644 --- a/src/components/MultiHopTrade/components/TradeInput/TradeInput.tsx +++ b/src/components/MultiHopTrade/components/TradeInput/TradeInput.tsx @@ -28,15 +28,15 @@ import { getMixPanel } from 'lib/mixpanel/mixPanelSingleton' import { MixPanelEvent } from 'lib/mixpanel/types' import { isKeplrHDWallet } from 'lib/utils' import { selectIsVotingPowerLoading } from 'state/apis/snapshot/selectors' +import { selectIsAnyAccountMetadataLoadedForChainId } from 'state/slices/selectors' import { selectHasUserEnteredAmount, selectInputBuyAsset, selectInputSellAmountCryptoPrecision, selectInputSellAmountUserCurrency, selectInputSellAsset, - selectIsAnyAccountMetadataLoadedForChainId, selectIsInputtingFiatSellAmount, -} from 'state/slices/selectors' +} from 'state/slices/tradeInputSlice/selectors' import { tradeInput } from 'state/slices/tradeInputSlice/tradeInputSlice' import { selectActiveQuote, diff --git a/src/components/MultiHopTrade/components/TradeInput/components/ConfirmSummary.tsx b/src/components/MultiHopTrade/components/TradeInput/components/ConfirmSummary.tsx index a5c0a0a48d7..9622b311184 100644 --- a/src/components/MultiHopTrade/components/TradeInput/components/ConfirmSummary.tsx +++ b/src/components/MultiHopTrade/components/TradeInput/components/ConfirmSummary.tsx @@ -20,8 +20,8 @@ import { useIsSmartContractAddress } from 'hooks/useIsSmartContractAddress/useIs import { useWallet } from 'hooks/useWallet/useWallet' import { isToken } from 'lib/utils' import { selectIsTradeQuoteApiQueryPending } from 'state/apis/swapper/selectors' +import { selectFeeAssetById } from 'state/slices/selectors' import { - selectFeeAssetById, selectHasUserEnteredAmount, selectInputBuyAsset, selectInputSellAmountUsd, @@ -29,7 +29,7 @@ import { selectIsManualReceiveAddressEditing, selectIsManualReceiveAddressValid, selectIsManualReceiveAddressValidating, -} from 'state/slices/selectors' +} from 'state/slices/tradeInputSlice/selectors' import { selectActiveQuote, selectActiveQuoteAffiliateBps, diff --git a/src/components/MultiHopTrade/components/TradeInput/components/RecipientAddress.tsx b/src/components/MultiHopTrade/components/TradeInput/components/RecipientAddress.tsx index 3f1b69b06ed..9031c59ab7c 100644 --- a/src/components/MultiHopTrade/components/TradeInput/components/RecipientAddress.tsx +++ b/src/components/MultiHopTrade/components/TradeInput/components/RecipientAddress.tsx @@ -1,5 +1,5 @@ import { useCallback } from 'react' -import { selectInputBuyAsset } from 'state/slices/selectors' +import { selectInputBuyAsset } from 'state/slices/tradeInputSlice/selectors' import { tradeInput } from 'state/slices/tradeInputSlice/tradeInputSlice' import { useAppDispatch, useAppSelector } from 'state/store' diff --git a/src/components/MultiHopTrade/components/TradeInput/components/TradeQuotes/TradeQuote.tsx b/src/components/MultiHopTrade/components/TradeInput/components/TradeQuotes/TradeQuote.tsx index eb5d2407087..3928b941992 100644 --- a/src/components/MultiHopTrade/components/TradeInput/components/TradeQuotes/TradeQuote.tsx +++ b/src/components/MultiHopTrade/components/TradeInput/components/TradeQuotes/TradeQuote.tsx @@ -19,14 +19,16 @@ import { type ApiQuote, TradeQuoteValidationError } from 'state/apis/swapper/typ import { selectFeeAssetByChainId, selectFeeAssetById, - selectInputBuyAsset, - selectInputSellAmountCryptoPrecision, - selectInputSellAsset, selectIsAssetWithoutMarketData, selectMarketDataByAssetIdUserCurrency, selectMarketDataByFilter, - selectUserSlippagePercentageDecimal, } from 'state/slices/selectors' +import { + selectInputBuyAsset, + selectInputSellAmountCryptoPrecision, + selectInputSellAsset, + selectUserSlippagePercentageDecimal, +} from 'state/slices/tradeInputSlice/selectors' import { getBuyAmountAfterFeesCryptoPrecision, getTotalNetworkFeeUserCurrencyPrecision, diff --git a/src/components/MultiHopTrade/components/TradeInput/components/TradeQuotes/TradeQuotes.tsx b/src/components/MultiHopTrade/components/TradeInput/components/TradeQuotes/TradeQuotes.tsx index fc399afd549..fab5d4c1a7c 100644 --- a/src/components/MultiHopTrade/components/TradeInput/components/TradeQuotes/TradeQuotes.tsx +++ b/src/components/MultiHopTrade/components/TradeInput/components/TradeQuotes/TradeQuotes.tsx @@ -21,7 +21,7 @@ import { Text } from 'components/Text' import { selectIsTradeQuoteApiQueryPending } from 'state/apis/swapper/selectors' import type { ApiQuote } from 'state/apis/swapper/types' import { TradeQuoteValidationError } from 'state/apis/swapper/types' -import { selectInputBuyAsset, selectInputSellAsset } from 'state/slices/selectors' +import { selectInputBuyAsset, selectInputSellAsset } from 'state/slices/tradeInputSlice/selectors' import { selectActiveQuoteMetaOrDefault, selectBuyAmountAfterFeesCryptoPrecision, diff --git a/src/components/MultiHopTrade/components/TradeInput/hooks/useTradeReceiveAddress.tsx b/src/components/MultiHopTrade/components/TradeInput/hooks/useTradeReceiveAddress.tsx index b39edb4d4e4..1af06f57a0f 100644 --- a/src/components/MultiHopTrade/components/TradeInput/hooks/useTradeReceiveAddress.tsx +++ b/src/components/MultiHopTrade/components/TradeInput/hooks/useTradeReceiveAddress.tsx @@ -4,7 +4,7 @@ import { selectInputBuyAsset, selectLastHopBuyAccountId, selectManualReceiveAddress, -} from 'state/slices/selectors' +} from 'state/slices/tradeInputSlice/selectors' import { useAppSelector } from 'state/store' export const useTradeReceiveAddress = () => { diff --git a/src/components/MultiHopTrade/components/VerifyAddresses/VerifyAddresses.tsx b/src/components/MultiHopTrade/components/VerifyAddresses/VerifyAddresses.tsx index ec8d6ae81d3..c52de7115ad 100644 --- a/src/components/MultiHopTrade/components/VerifyAddresses/VerifyAddresses.tsx +++ b/src/components/MultiHopTrade/components/VerifyAddresses/VerifyAddresses.tsx @@ -30,11 +30,13 @@ import { useWallet } from 'hooks/useWallet/useWallet' import { walletSupportsChain } from 'hooks/useWalletSupportsChain/useWalletSupportsChain' import { selectAccountIdsByChainIdFilter, + selectPortfolioAccountMetadataByAccountId, +} from 'state/slices/selectors' +import { selectInputBuyAsset, selectInputSellAsset, selectManualReceiveAddress, - selectPortfolioAccountMetadataByAccountId, -} from 'state/slices/selectors' +} from 'state/slices/tradeInputSlice/selectors' import { useAppSelector } from 'state/store' import { WithBackButton } from '../WithBackButton' diff --git a/src/components/MultiHopTrade/hooks/useAccountIds.tsx b/src/components/MultiHopTrade/hooks/useAccountIds.tsx index afd154b6fce..57d025698df 100644 --- a/src/components/MultiHopTrade/hooks/useAccountIds.tsx +++ b/src/components/MultiHopTrade/hooks/useAccountIds.tsx @@ -1,6 +1,9 @@ import type { AccountId } from '@shapeshiftoss/caip' import { useCallback, useMemo } from 'react' -import { selectFirstHopSellAccountId, selectLastHopBuyAccountId } from 'state/slices/selectors' +import { + selectFirstHopSellAccountId, + selectLastHopBuyAccountId, +} from 'state/slices/tradeInputSlice/selectors' import { tradeInput } from 'state/slices/tradeInputSlice/tradeInputSlice' import { useAppDispatch, useAppSelector } from 'state/store' diff --git a/src/components/MultiHopTrade/hooks/useGetTradeQuotes/useGetTradeQuotes.tsx b/src/components/MultiHopTrade/hooks/useGetTradeQuotes/useGetTradeQuotes.tsx index d48191972e3..911766ae0b4 100644 --- a/src/components/MultiHopTrade/hooks/useGetTradeQuotes/useGetTradeQuotes.tsx +++ b/src/components/MultiHopTrade/hooks/useGetTradeQuotes/useGetTradeQuotes.tsx @@ -28,6 +28,10 @@ import { } from 'state/apis/snapshot/selectors' import { swapperApi } from 'state/apis/swapper/swapperApi' import type { ApiQuote, TradeQuoteError } from 'state/apis/swapper/types' +import { + selectPortfolioAccountMetadataByAccountId, + selectUsdRateByAssetId, +} from 'state/slices/selectors' import { selectFirstHopSellAccountId, selectInputBuyAsset, @@ -35,10 +39,8 @@ import { selectInputSellAmountUsd, selectInputSellAsset, selectLastHopBuyAccountId, - selectPortfolioAccountMetadataByAccountId, - selectUsdRateByAssetId, selectUserSlippagePercentageDecimal, -} from 'state/slices/selectors' +} from 'state/slices/tradeInputSlice/selectors' import { selectActiveQuoteMetaOrDefault, selectIsAnyTradeQuoteLoading, diff --git a/src/lib/tradeExecution.ts b/src/lib/tradeExecution.ts index d5ca552ea41..36dd2d38f11 100644 --- a/src/lib/tradeExecution.ts +++ b/src/lib/tradeExecution.ts @@ -23,7 +23,7 @@ import { getConfig } from 'config' import EventEmitter from 'events' import { fetchIsSmartContractAddressQuery } from 'hooks/useIsSmartContractAddress/useIsSmartContractAddress' import { poll } from 'lib/poll/poll' -import { selectFirstHopSellAccountId } from 'state/slices/selectors' +import { selectFirstHopSellAccountId } from 'state/slices/tradeInputSlice/selectors' import { store } from 'state/store' import { assertGetCosmosSdkChainAdapter } from './utils/cosmosSdk' diff --git a/src/state/apis/swapper/helpers/validateTradeQuote.ts b/src/state/apis/swapper/helpers/validateTradeQuote.ts index bffe379239d..7a58f2a6c4f 100644 --- a/src/state/apis/swapper/helpers/validateTradeQuote.ts +++ b/src/state/apis/swapper/helpers/validateTradeQuote.ts @@ -21,11 +21,13 @@ import { import { selectAssets, selectFeeAssetById, + selectPortfolioAccountIdByNumberByChainId, +} from 'state/slices/selectors' +import { selectFirstHopSellAccountId, selectInputSellAmountCryptoPrecision, - selectPortfolioAccountIdByNumberByChainId, selectSecondHopSellAccountId, -} from 'state/slices/selectors' +} from 'state/slices/tradeInputSlice/selectors' import { getTotalProtocolFeeByAssetForStep } from 'state/slices/tradeQuoteSlice/helpers' import type { ErrorWithMeta } from '../types' diff --git a/src/state/slices/selectors.ts b/src/state/slices/selectors.ts index aadebf24da4..be35dcd9e9e 100644 --- a/src/state/slices/selectors.ts +++ b/src/state/slices/selectors.ts @@ -13,7 +13,6 @@ export * from './portfolioSlice/selectors' export * from './preferencesSlice/selectors' export * from './txHistorySlice/selectors' export * from './opportunitiesSlice/selectors' -export * from './tradeInputSlice/selectors' /** * some selectors span multiple business logic domains, e.g. portfolio and opportunities