Skip to content

Commit

Permalink
remove WebSocketProvider (Kwenta#1757)
Browse files Browse the repository at this point in the history
Get rid of WebSocketProvider
  • Loading branch information
koredefashokun authored Dec 15, 2022
1 parent 801ac65 commit 9e80139
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
10 changes: 5 additions & 5 deletions containers/Connector/Connector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ethers } from 'ethers';
import { keyBy } from 'lodash';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { createContainer } from 'unstated-next';
import { chain, useAccount, useNetwork, useSigner, useWebSocketProvider } from 'wagmi';
import { chain, useAccount, useNetwork, useSigner, useProvider } from 'wagmi';

import { sdk } from 'state/config';
import { useAppDispatch } from 'state/hooks';
Expand All @@ -30,8 +30,8 @@ const useConnector = () => {

const walletAddress = useMemo(() => address ?? null, [address]);

const provider = useWebSocketProvider({ chainId: network.id });
const l2Provider = useWebSocketProvider({ chainId: chain.optimism.id });
const provider = useProvider({ chainId: network.id });
const l2Provider = useProvider({ chainId: chain.optimism.id });
const { data: signer } = useSigner();

// Provides a default mainnet provider, irrespective of the current network
Expand Down Expand Up @@ -92,8 +92,8 @@ const useConnector = () => {
unsupportedNetwork,
isWalletConnected,
walletAddress,
provider: provider!,
l2Provider: l2Provider!,
provider,
l2Provider,
signer,
network,
synthsMap,
Expand Down
7 changes: 1 addition & 6 deletions containers/Connector/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Safe from 'components/Rainbowkit/Gnosis';
import Tally from 'components/Rainbowkit/Tally';
import { BLAST_NETWORK_LOOKUP } from 'constants/network';

const { chains, provider, webSocketProvider } = configureChains(
const { chains, provider } = configureChains(
[chain.optimism, chain.mainnet, chain.optimismGoerli, chain.goerli],
[
infuraProvider({
Expand All @@ -32,15 +32,11 @@ const { chains, provider, webSocketProvider } = configureChains(
return !BLAST_NETWORK_LOOKUP[networkChain.id]
? {
http: networkChain.rpcUrls.default,
webSocket: networkChain.rpcUrls.default.replace('https', 'wss'),
}
: {
http: `https://${BLAST_NETWORK_LOOKUP[networkChain.id]}.blastapi.io/${
process.env.NEXT_PUBLIC_BLASTAPI_PROJECT_ID
}`,
webSocket: `wss://${BLAST_NETWORK_LOOKUP[networkChain.id]}.blastapi.io/${
process.env.NEXT_PUBLIC_BLASTAPI_PROJECT_ID
}`,
};
},
stallTimeout: 5000,
Expand Down Expand Up @@ -78,7 +74,6 @@ export const wagmiClient = createClient({
autoConnect: true,
connectors,
provider,
webSocketProvider,
});

export { chains };
2 changes: 1 addition & 1 deletion state/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import KwentaSDK from 'sdk';

import { wagmiClient } from 'containers/Connector/config';

export const sdk = new KwentaSDK({ networkId: 10, provider: wagmiClient.webSocketProvider! });
export const sdk = new KwentaSDK({ networkId: 10, provider: wagmiClient.provider });

0 comments on commit 9e80139

Please sign in to comment.