diff --git a/apps/cowswap-frontend/src/legacy/components/Web3Provider/index.tsx b/apps/cowswap-frontend/src/legacy/components/Web3Provider/index.tsx index 934d45baf0..3187fba40a 100644 --- a/apps/cowswap-frontend/src/legacy/components/Web3Provider/index.tsx +++ b/apps/cowswap-frontend/src/legacy/components/Web3Provider/index.tsx @@ -11,7 +11,9 @@ export default function Web3Provider({ children }: { children: ReactNode }) { useEagerlyConnect() const connections = useOrderedConnections() - const connectors: [Connector, Web3ReactHooks][] = connections.map(({ hooks, connector }) => [connector, hooks]) + const connectors: [Connector, Web3ReactHooks][] = connections + .filter(Boolean) + .map(({ hooks, connector }) => [connector, hooks]) const key = useMemo( () => connections.map(({ type }: Web3ReactConnection) => getConnectionName(type)).join('-'), diff --git a/libs/wallet/src/web3-react/utils/getWeb3ReactConnection.ts b/libs/wallet/src/web3-react/utils/getWeb3ReactConnection.ts index 85251539cb..9085cc59bf 100644 --- a/libs/wallet/src/web3-react/utils/getWeb3ReactConnection.ts +++ b/libs/wallet/src/web3-react/utils/getWeb3ReactConnection.ts @@ -41,5 +41,11 @@ export function getWeb3ReactConnection(c: Connector | ConnectionType): Web3React return connection } - return connectionTypeToConnection[c] + const connection = connectionTypeToConnection[c] + + if (!connection) { + throw Error('unsupported connector') + } + + return connection }