Skip to content

Commit

Permalink
refactor: moved 'swr-strategies' to consts
Browse files Browse the repository at this point in the history
  • Loading branch information
solidovic committed Feb 26, 2024
1 parent 218bed6 commit a344724
Show file tree
Hide file tree
Showing 32 changed files with 36 additions and 36 deletions.
2 changes: 0 additions & 2 deletions utils/swrStrategies.ts → consts/swr-strategies.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import type { SWRConfiguration } from 'swr';

// TODO: move to consts

const MINUTE_MS = 1000 * 60;

type StrategyConfig<DataT = unknown> = Pick<
Expand Down
2 changes: 1 addition & 1 deletion features/rewards/components/stats/Stats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import EthSymbol from 'features/rewards/components/EthSymbol';
import NumberFormat from 'features/rewards/components/NumberFormat';
import { Big, BigDecimal } from 'features/rewards/helpers';
import { ETHER } from 'features/rewards/constants';
import { STRATEGY_LAZY } from 'utils/swrStrategies';
import { STRATEGY_LAZY } from 'consts/swr-strategies';
import { useMainnetStaticRpcProvider } from 'shared/hooks/use-mainnet-static-rpc-provider';

import { Item } from './Item';
Expand Down
2 changes: 1 addition & 1 deletion features/stake/stake-form/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { useLidoSWR, useSDK, useSTETHContractRPC } from '@lido-sdk/react';
import { getConfig } from 'config';
const { ESTIMATE_ACCOUNT, ESTIMATE_AMOUNT, STAKE_GASLIMIT_FALLBACK } =
getConfig();
import { STRATEGY_CONSTANT } from 'consts/swr-strategies';

import { STRATEGY_CONSTANT } from 'utils/swrStrategies';
import { applyGasLimitRatio } from './utils';

type UseStethSubmitGasLimit = () => BigNumber;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
import { useStakingLimitInfo } from 'shared/hooks/useStakingLimitInfo';
import { useMaxGasPrice } from 'shared/hooks';
import { useIsMultisig } from 'shared/hooks/useIsMultisig';
import { STRATEGY_LAZY } from 'utils/swrStrategies';
import { STRATEGY_LAZY } from 'consts/swr-strategies';

import { useStethSubmitGasLimit } from '../hooks';
import {
Expand Down
2 changes: 1 addition & 1 deletion features/stake/stake-form/stake-form-info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { useContractSWR, useSTETHContractRPC } from '@lido-sdk/react';
import { Zero } from '@ethersproject/constants';

import { DATA_UNAVAILABLE } from 'consts/text';
import { STRATEGY_CONSTANT } from 'consts/swr-strategies';
import { FormatPrice, FormatToken } from 'shared/formatters';
import { useEthUsd } from 'shared/hooks/use-eth-usd';
import { STRATEGY_CONSTANT } from 'utils/swrStrategies';

import { StakeFormInput, useStakeFormData } from './stake-form-context';

Expand Down
2 changes: 1 addition & 1 deletion features/stake/stake-form/wallet/wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { FormatToken } from 'shared/formatters';
import { useLidoApr } from 'shared/hooks';
import { CardAccount, CardBalance, CardRow, Fallback } from 'shared/wallet';
import type { WalletComponentType } from 'shared/wallet/types';
import { STRATEGY_LAZY } from 'utils/swrStrategies';
import { STRATEGY_LAZY } from 'consts/swr-strategies';

import { LimitMeter } from './limit-meter';
import { FlexCenter, LidoAprStyled, StyledCard } from './styles';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { OPEN_OCEAN_REFERRAL_ADDRESS } from 'consts/external-links';
import { getConfig } from 'config';
const { enableQaHelpers } = getConfig();

import { STRATEGY_LAZY } from 'utils/swrStrategies';
import { STRATEGY_LAZY } from 'consts/swr-strategies';
import { getOpenOceanRate } from 'utils/get-open-ocean-rate';

import { Wrap, TextWrap, OpenOceanIcon, OverlayLink } from './styles';
Expand Down
5 changes: 3 additions & 2 deletions features/withdrawals/hooks/contract/useLidoShareRate.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { BigNumber } from 'ethers';
import {
useSDK,
useLidoSWR,
SWRResponse,
useSTETHContractRPC,
} from '@lido-sdk/react';
import { BigNumber } from 'ethers';

import { STRATEGY_CONSTANT } from 'consts/swr-strategies';
import { calcShareRate } from 'features/withdrawals/utils/calc-share-rate';
import { STRATEGY_CONSTANT } from 'utils/swrStrategies';

export const useLidoShareRate = (): SWRResponse<BigNumber> => {
const { chainId } = useSDK();
Expand Down
2 changes: 1 addition & 1 deletion features/withdrawals/hooks/contract/useUnfinalizedSteth.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useContractSWR } from '@lido-sdk/react';

import { useWithdrawalsContract } from './useWithdrawalsContract';
import { STRATEGY_LAZY } from 'utils/swrStrategies';
import { STRATEGY_LAZY } from 'consts/swr-strategies';

export const useUnfinalizedStETH = () => {
const { contractRpc } = useWithdrawalsContract();
Expand Down
5 changes: 3 additions & 2 deletions features/withdrawals/hooks/contract/useWithdrawalsBaseData.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { useSDK, useLidoSWR, SWRResponse } from '@lido-sdk/react';
import { BigNumber } from 'ethers';
import { useSDK, useLidoSWR, SWRResponse } from '@lido-sdk/react';

import { STRATEGY_CONSTANT } from 'consts/swr-strategies';

import { useWithdrawalsContract } from './useWithdrawalsContract';
import { STRATEGY_CONSTANT } from 'utils/swrStrategies';

type useWithdrawalsBaseDataResult = {
maxAmount: BigNumber;
Expand Down
2 changes: 1 addition & 1 deletion features/withdrawals/hooks/contract/useWithdrawalsData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
RequestStatusPending,
} from 'features/withdrawals/types/request-status';
import { MAX_SHOWN_REQUEST_PER_TYPE } from 'features/withdrawals/withdrawals-constants';
import { STRATEGY_LAZY } from 'utils/swrStrategies';
import { STRATEGY_LAZY } from 'consts/swr-strategies';

// import { calcExpectedRequestEth } from 'features/withdrawals/utils/calc-expected-request-eth';

Expand Down
2 changes: 1 addition & 1 deletion features/withdrawals/hooks/useEthAmountByStethWsteth.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BigNumber } from 'ethers';
import { useContractSWR, useWSTETHContractRPC } from '@lido-sdk/react';

import { STRATEGY_LAZY } from 'utils/swrStrategies';
import { STRATEGY_LAZY } from 'consts/swr-strategies';

type useEthAmountByInputProps = {
isSteth: boolean;
Expand Down
2 changes: 1 addition & 1 deletion features/withdrawals/hooks/useWaitingTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { SWRResponse, useLidoSWR } from '@lido-sdk/react';

import { getConfig } from 'config';
const { wqAPIBasePath } = getConfig();
import { STRATEGY_EAGER } from 'consts/swr-strategies';

import { useDebouncedValue } from 'shared/hooks';
import { encodeURLQuery } from 'utils/encodeURLQuery';
import { standardFetcher } from 'utils/standardFetcher';
import { STRATEGY_EAGER } from 'utils/swrStrategies';
import { FetcherError } from 'utils/fetcherError';

import { useWithdrawals } from 'features/withdrawals/contexts/withdrawals-context';
Expand Down
2 changes: 1 addition & 1 deletion features/withdrawals/hooks/useWithdrawTxPrice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ const {
WITHDRAWAL_QUEUE_REQUEST_WSTETH_APPROVED_GAS_LIMIT_DEFAULT,
wqAPIBasePath,
} = getConfig();
import { STRATEGY_LAZY } from 'consts/swr-strategies';

import { MAX_REQUESTS_COUNT } from 'features/withdrawals/withdrawals-constants';
import { useTxCostInUsd } from 'shared/hooks/txCost';
import { useDebouncedValue } from 'shared/hooks/useDebouncedValue';
import { encodeURLQuery } from 'utils/encodeURLQuery';
import { STRATEGY_LAZY } from 'utils/swrStrategies';
import { standardFetcher } from 'utils/standardFetcher';

import { useWithdrawalsContract } from './contract/useWithdrawalsContract';
Expand Down
2 changes: 1 addition & 1 deletion features/withdrawals/hooks/useWithdrawalRates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { CHAINS, getTokenAddress, TOKENS } from '@lido-sdk/constants';
import { useLidoSWR } from '@lido-sdk/react';

import { useDebouncedValue } from 'shared/hooks/useDebouncedValue';
import { STRATEGY_LAZY } from 'utils/swrStrategies';
import { STRATEGY_LAZY } from 'consts/swr-strategies';

import { RequestFormInputType } from '../request/request-form-context';
import { getOpenOceanRate } from 'utils/get-open-ocean-rate';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useClaimData } from 'features/withdrawals/contexts/claim-data-context';
import { useWithdrawals } from 'features/withdrawals/contexts/withdrawals-context';
import { useUnfinalizedStETH } from 'features/withdrawals/hooks';
import { useCallback, useMemo } from 'react';
import { STRATEGY_LAZY } from 'utils/swrStrategies';
import { STRATEGY_LAZY } from 'consts/swr-strategies';

// Provides all data fetching for form to function
export const useRequestFormDataContextValue = () => {
Expand Down
2 changes: 1 addition & 1 deletion features/wsteth/shared/wallet/wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { useWstethBySteth, useStethByWsteth } from 'shared/hooks';
import type { WalletComponentType } from 'shared/wallet/types';
import { CardBalance, CardRow, CardAccount, Fallback } from 'shared/wallet';
import { StyledCard } from './styles';
import { STRATEGY_LAZY } from 'utils/swrStrategies';
import { STRATEGY_LAZY } from 'consts/swr-strategies';

const WalletComponent: WalletComponentType = (props) => {
const { account } = useSDK();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useCallback, useMemo } from 'react';
import { useIsMultisig } from 'shared/hooks/useIsMultisig';
import { useSTETHBalance, useWSTETHBalance } from '@lido-sdk/react';
import { STRATEGY_LAZY } from 'utils/swrStrategies';
import { STRATEGY_LAZY } from 'consts/swr-strategies';

export const useUnwrapFormNetworkData = () => {
const { isMultisig } = useIsMultisig();
Expand Down
2 changes: 1 addition & 1 deletion features/wsteth/unwrap/hooks/use-unwrap-gas-limit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { ESTIMATE_ACCOUNT, ESTIMATE_AMOUNT } = getConfig();
import { UNWRAP_GAS_LIMIT } from 'consts/tx';

import { useCurrentStaticRpcProvider } from 'shared/hooks/use-current-static-rpc-provider';
import { STRATEGY_LAZY } from 'utils/swrStrategies';
import { STRATEGY_LAZY } from 'consts/swr-strategies';

export const useUnwrapGasLimit = () => {
const wsteth = useWSTETHContractRPC();
Expand Down
2 changes: 1 addition & 1 deletion features/wsteth/wrap/hooks/use-approve-gas-limit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '@lido-sdk/react';

import { WSTETH_APPROVE_GAS_LIMIT } from 'consts/tx';
import { STRATEGY_IMMUTABLE } from 'utils/swrStrategies';
import { STRATEGY_IMMUTABLE } from 'consts/swr-strategies';

import { getConfig } from 'config';
const { ESTIMATE_ACCOUNT, ESTIMATE_AMOUNT } = getConfig();
Expand Down
2 changes: 1 addition & 1 deletion features/wsteth/wrap/hooks/use-wrap-form-network-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useIsMultisig } from 'shared/hooks/useIsMultisig';
import { useTokenMaxAmount } from 'shared/hooks/use-token-max-amount';
import { useMaxGasPrice, useStakingLimitInfo } from 'shared/hooks';

import { STRATEGY_LAZY } from 'utils/swrStrategies';
import { STRATEGY_LAZY } from 'consts/swr-strategies';

import { useWrapGasLimit } from './use-wrap-gas-limit';

Expand Down
2 changes: 1 addition & 1 deletion providers/ipfs-info-box-statuses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { SETTINGS_PATH } from 'consts/urls';

import { useCSPViolation } from 'features/ipfs/csp-violation-box/use-csp-violation';
import { useRouterPath } from 'shared/hooks/use-router-path';
import { STRATEGY_LAZY } from 'utils/swrStrategies';
import { STRATEGY_LAZY } from 'consts/swr-strategies';
import { checkRpcUrl } from 'utils/check-rpc-url';

type IPFSInfoBoxStatusesContextValue = {
Expand Down
2 changes: 1 addition & 1 deletion shared/hooks/use-eth-usd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useMemo } from 'react';

import { useEthPrice } from '@lido-sdk/react';
import { weiToEth } from 'utils/weiToEth';
import { STRATEGY_LAZY } from 'utils/swrStrategies';
import { STRATEGY_LAZY } from 'consts/swr-strategies';

export const useEthUsd = (amount?: BigNumber): number | undefined => {
const { data: price } = useEthPrice(STRATEGY_LAZY);
Expand Down
2 changes: 1 addition & 1 deletion shared/hooks/useApprove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { getFeeData } from 'utils/getFeeData';
import { runWithTransactionLogger } from 'utils';

import { useCurrentStaticRpcProvider } from './use-current-static-rpc-provider';
import { STRATEGY_LAZY } from 'utils/swrStrategies';
import { STRATEGY_LAZY } from 'consts/swr-strategies';

type ApproveOptions =
| {
Expand Down
2 changes: 1 addition & 1 deletion shared/hooks/useIsContract.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEthereumSWR } from '@lido-sdk/react';
import { STRATEGY_IMMUTABLE } from 'utils/swrStrategies';
import { STRATEGY_IMMUTABLE } from 'consts/swr-strategies';

export const useIsContract = (
account?: string | null,
Expand Down
2 changes: 1 addition & 1 deletion shared/hooks/useLidoApr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { CHAINS } from '@lido-sdk/constants';

import { getConfig } from 'config';
const { ethAPIBasePath } = getConfig();
import { STRATEGY_LAZY } from 'consts/swr-strategies';

import { standardFetcher } from 'utils/standardFetcher';
import { STRATEGY_LAZY } from 'utils/swrStrategies';

type SMA_APR_RESPONSE = {
data: {
Expand Down
2 changes: 1 addition & 1 deletion shared/hooks/useLidoStats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { ipfsMode, widgetApiBasePathForIpfs } = getConfig();
import { DATA_UNAVAILABLE } from 'consts/text';
import { prependBasePath } from 'utils';
import { standardFetcher } from 'utils/standardFetcher';
import { STRATEGY_LAZY } from 'utils/swrStrategies';
import { STRATEGY_LAZY } from 'consts/swr-strategies';

export type ResponseData = {
uniqueAnytimeHolders: string;
Expand Down
2 changes: 1 addition & 1 deletion shared/hooks/useMaxGasPrice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useLidoSWR } from '@lido-sdk/react';
import { BigNumber } from 'ethers';

import { getFeeData } from 'utils/getFeeData';
import { STRATEGY_LAZY } from 'utils/swrStrategies';
import { STRATEGY_LAZY } from 'consts/swr-strategies';

import { useCurrentStaticRpcProvider } from './use-current-static-rpc-provider';

Expand Down
3 changes: 1 addition & 2 deletions shared/hooks/useStakingLimitInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import { useSDK, useSTETHContractRPC } from '@lido-sdk/react';

import { getConfig } from 'config';
const { enableQaHelpers } = getConfig();

import { STRATEGY_LAZY } from 'utils/swrStrategies';
import { STRATEGY_LAZY } from 'consts/swr-strategies';
import { LIMIT_LEVEL } from 'types';

export type StakeLimitFullInfo = {
Expand Down
2 changes: 1 addition & 1 deletion shared/hooks/useStethByWsteth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useContractSWR, useWSTETHContractRPC } from '@lido-sdk/react';
import { BigNumber } from 'ethers';
import { STRATEGY_LAZY } from 'utils/swrStrategies';
import { STRATEGY_LAZY } from 'consts/swr-strategies';

export const useStethByWsteth = (
wsteth: BigNumber | undefined,
Expand Down
2 changes: 1 addition & 1 deletion shared/hooks/useWstethBySteth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useContractSWR, useWSTETHContractRPC } from '@lido-sdk/react';
import { BigNumber } from 'ethers';
import { STRATEGY_LAZY } from 'utils/swrStrategies';
import { STRATEGY_LAZY } from 'consts/swr-strategies';

export const useWstethBySteth = (
steth: BigNumber | undefined,
Expand Down
3 changes: 2 additions & 1 deletion shared/wallet/button/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import { MODAL } from 'providers';
import { useModal } from 'shared/hooks';
import { useEthereumBalance, useSDK } from '@lido-sdk/react';
import { FormatToken } from 'shared/formatters';
import { STRATEGY_LAZY } from 'consts/swr-strategies';

import { AddressBadge } from '../components/address-badge/address-badge';
import {
WalledButtonStyle,
WalledButtonWrapperStyle,
WalledButtonBalanceStyle,
WalledButtonLoaderStyle,
} from './styles';
import { STRATEGY_LAZY } from 'utils/swrStrategies';

export const Button: FC<ButtonProps> = (props) => {
const { onClick, ...rest } = props;
Expand Down

0 comments on commit a344724

Please sign in to comment.