Skip to content

Commit

Permalink
fix: fix 3307 - Safe fails to load (#3308)
Browse files Browse the repository at this point in the history
* fix: filter out potential falsy connectors

* chore: throw when there's no connection found
  • Loading branch information
alfetopito authored Oct 31, 2023
1 parent 6f035c8 commit 3314974
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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('-'),
Expand Down
8 changes: 7 additions & 1 deletion libs/wallet/src/web3-react/utils/getWeb3ReactConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 3314974

Please sign in to comment.