diff --git a/src/components/Swap/index.tsx b/src/components/Swap/index.tsx index 582bea08b..01e47120a 100644 --- a/src/components/Swap/index.tsx +++ b/src/components/Swap/index.tsx @@ -1,10 +1,8 @@ -import { JsonRpcProvider } from '@ethersproject/providers' import { Trans } from '@lingui/macro' -import { Provider as Eip1193Provider } from '@web3-react/types' import BrandedFooter from 'components/BrandedFooter' import Wallet from 'components/ConnectWallet' import { SwapInfoProvider } from 'hooks/swap/useSwapInfo' -import useSyncController, { SwapController, SwapSettingsController } from 'hooks/swap/useSyncController' +import useSyncController, { SwapController } from 'hooks/swap/useSyncController' import useSyncConvenienceFee, { FeeOptions } from 'hooks/swap/useSyncConvenienceFee' import useSyncSwapEventHandlers, { SwapEventHandlers } from 'hooks/swap/useSyncSwapEventHandlers' import useSyncTokenDefaults, { TokenDefaults } from 'hooks/swap/useSyncTokenDefaults' @@ -31,17 +29,20 @@ import useValidate from './useValidate' // since the wallet connection component exists within the Swap component. // This includes useSyncWidgetEventHandlers. // TODO(zzmp): refactor WalletConnection outside of Swap component -export interface SwapProps extends BrandingSettings, FeeOptions, SwapEventHandlers, TokenDefaults, WidgetEventHandlers { +export interface SwapProps + extends BrandingSettings, + FeeOptions, + SwapController, + SwapEventHandlers, + TokenDefaults, + WidgetEventHandlers { hideConnectionUI?: boolean - provider?: Eip1193Provider | JsonRpcProvider routerUrl?: string - settings?: SwapSettingsController - value?: SwapController } export default function Swap(props: SwapProps) { useValidate(props) - useSyncController(props) + useSyncController(props as SwapController) useSyncConvenienceFee(props as FeeOptions) useSyncSwapEventHandlers(props as SwapEventHandlers) useSyncTokenDefaults(props as TokenDefaults) diff --git a/src/components/Widget.tsx b/src/components/Widget.tsx index 7f2779239..809d34b41 100644 --- a/src/components/Widget.tsx +++ b/src/components/Widget.tsx @@ -5,7 +5,6 @@ import { ALL_SUPPORTED_CHAIN_IDS, SupportedChainId } from 'constants/chains' import { DEFAULT_LOCALE, SUPPORTED_LOCALES, SupportedLocale } from 'constants/locales' import { TransactionEventHandlers, TransactionsUpdater } from 'hooks/transactions' import { BlockNumberProvider } from 'hooks/useBlockNumber' -import { BrandingSettings } from 'hooks/useSyncBrandingSetting' import { TokenListProvider } from 'hooks/useTokenList' import { Provider as Web3ReactProvider } from 'hooks/web3' import { JsonRpcConnectionMap } from 'hooks/web3/useJsonRpcUrlsMap' @@ -95,7 +94,7 @@ export const DialogWrapper = styled.div` } ` -export interface WidgetProps extends BrandingSettings, TransactionEventHandlers { +export interface WidgetProps extends TransactionEventHandlers { theme?: Theme locale?: SupportedLocale provider?: Eip1193Provider | JsonRpcProvider | null diff --git a/src/hooks/swap/useSyncController.ts b/src/hooks/swap/useSyncController.ts index 22a76f7e9..27fe852ac 100644 --- a/src/hooks/swap/useSyncController.ts +++ b/src/hooks/swap/useSyncController.ts @@ -3,16 +3,12 @@ import { useEffect, useRef } from 'react' import { controlledAtom as swapAtom, Swap } from 'state/swap' import { controlledAtom as settingsAtom, Settings } from 'state/swap/settings' -export type SwapSettingsController = Settings -export type SwapController = Swap +export interface SwapController { + value?: Swap + settings?: Settings +} -export default function useSyncController({ - value, - settings, -}: { - value?: SwapController - settings?: SwapSettingsController -}): void { +export default function useSyncController({ value, settings }: SwapController): void { // Log an error if the component changes from uncontrolled to controlled (or vice versa). const isSwapControlled = useRef(Boolean(value)) const isSettingsControlled = useRef(Boolean(settings)) diff --git a/src/index.tsx b/src/index.tsx index 990276b1b..77a18f365 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -15,7 +15,7 @@ export { SwapWidgetSkeleton } from 'components/Swap/Skeleton' export { SupportedChainId } from 'constants/chains' export type { SupportedLocale } from 'constants/locales' export { DEFAULT_LOCALE, SUPPORTED_LOCALES } from 'constants/locales' -export type { SwapController, SwapSettingsController } from 'hooks/swap/useSyncController' +export type { SwapController } from 'hooks/swap/useSyncController' export type { FeeOptions } from 'hooks/swap/useSyncConvenienceFee' export type { DefaultAddress, TokenDefaults } from 'hooks/swap/useSyncTokenDefaults' export type { OnTxFail, OnTxSubmit, OnTxSuccess, TransactionEventHandlers } from 'hooks/transactions'