From 06a8151ede4f895d7fb4630fcb6fdaa9cfde9964 Mon Sep 17 00:00:00 2001 From: Jordan Frankfurt Date: Wed, 12 Jan 2022 14:24:23 -0600 Subject: [PATCH] Revert "add error reporting component, INTEGRATION ERROR type, and Missing provider error (#3107)" (#3109) This reverts commit ac2642fedc8be9ea85201d341b3933983ab2ad36. --- src/lib/components/Error/ErrorDialog.tsx | 4 +--- src/lib/components/Error/ErrorReporter.tsx | 23 ---------------------- src/lib/components/Widget.tsx | 2 -- src/lib/hooks/useEnsureCorrectProps.ts | 11 ----------- src/lib/index.tsx | 2 +- src/lib/state/web3.ts | 2 -- 6 files changed, 2 insertions(+), 42 deletions(-) delete mode 100644 src/lib/components/Error/ErrorReporter.tsx delete mode 100644 src/lib/hooks/useEnsureCorrectProps.ts diff --git a/src/lib/components/Error/ErrorDialog.tsx b/src/lib/components/Error/ErrorDialog.tsx index 2a6e5eb32e..95db5a8eca 100644 --- a/src/lib/components/Error/ErrorDialog.tsx +++ b/src/lib/components/Error/ErrorDialog.tsx @@ -117,9 +117,7 @@ export default function ErrorDialog({ header, error, action, onAction }: ErrorDi - - {error.name}: {error.message} - + {error.message} {action} diff --git a/src/lib/components/Error/ErrorReporter.tsx b/src/lib/components/Error/ErrorReporter.tsx deleted file mode 100644 index c611c11a2c..0000000000 --- a/src/lib/components/Error/ErrorReporter.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { useAtomValue } from 'jotai/utils' -import { providerAtom } from 'lib/state/web3' -import { useEffect } from 'react' -import { EMPTY } from 'widgets-web3-react/empty' - -class IntegrationError extends Error { - constructor(message: string) { - super(message) - this.name = 'INTEGRATION ERROR' - } -} - -const missingProviderError = new IntegrationError('Missing provider') - -export default function ErrorReporter() { - const [connector] = useAtomValue(providerAtom) - useEffect(() => { - if (connector === EMPTY) { - throw missingProviderError - } - }, [connector]) - return null -} diff --git a/src/lib/components/Widget.tsx b/src/lib/components/Widget.tsx index 1d49b127f0..6691a75727 100644 --- a/src/lib/components/Widget.tsx +++ b/src/lib/components/Widget.tsx @@ -8,7 +8,6 @@ import { Provider as EthProvider } from 'widgets-web3-react/types' import { Provider as DialogProvider } from './Dialog' import ErrorBoundary, { ErrorHandler } from './Error/ErrorBoundary' -import ErrorReporter from './Error/ErrorReporter' import Web3Provider from './Web3Provider' const slideDown = keyframes` @@ -101,7 +100,6 @@ export default function Widget({ - {children} diff --git a/src/lib/hooks/useEnsureCorrectProps.ts b/src/lib/hooks/useEnsureCorrectProps.ts deleted file mode 100644 index 0ee3a2462c..0000000000 --- a/src/lib/hooks/useEnsureCorrectProps.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { WidgetProps } from 'lib/components/Widget' -import { missingProviderError } from 'lib/errors' -import { useEffect } from 'react' - -export function useEnsureCorrectProps(props: WidgetProps) { - useEffect(() => { - if (!props.provider) { - throw missingProviderError - } - }, [props]) -} diff --git a/src/lib/index.tsx b/src/lib/index.tsx index c996f2e9ce..4c31928be6 100644 --- a/src/lib/index.tsx +++ b/src/lib/index.tsx @@ -3,7 +3,7 @@ import Widget, { WidgetProps } from './components/Widget' export type SwapWidgetProps = WidgetProps -export function SwapWidget(props: SwapWidgetProps) { +export function SwapWidget({ ...props }: SwapWidgetProps) { return ( diff --git a/src/lib/state/web3.ts b/src/lib/state/web3.ts index 3a09c09d3c..c473abbf41 100644 --- a/src/lib/state/web3.ts +++ b/src/lib/state/web3.ts @@ -1,5 +1,4 @@ import { createMulticall } from '@uniswap/redux-multicall' -import { atom } from 'jotai' import { atomWithStore } from 'jotai/redux' import { atomWithDefault } from 'jotai/utils' import { createStore } from 'redux' @@ -13,7 +12,6 @@ export type Web3ReactState = [Connector, Web3ReactHooks] export const urlAtom = atomWithDefault(() => EMPTY_CONNECTOR) export const injectedAtom = atomWithDefault(() => EMPTY_CONNECTOR) -export const providerAtom = atom((get) => get(injectedAtom) || get(urlAtom)) export const multicall = createMulticall() const multicallStore = createStore(multicall.reducer)