Add support for ws communication with erigon

This commit is contained in:
Willian Mitsuda 2021-08-01 03:16:11 -03:00
parent b24e3d35d4
commit 7600605103

View File

@ -33,7 +33,12 @@ export const useProvider = (
setConnStatus(ConnectionStatus.CONNECTING);
const tryToConnect = async () => {
const provider = new ethers.providers.JsonRpcProvider(erigonURL);
let provider: ethers.providers.JsonRpcProvider;
if (erigonURL?.startsWith("ws://") || erigonURL?.startsWith("wss://")) {
provider = new ethers.providers.WebSocketProvider(erigonURL);
} else {
provider = new ethers.providers.JsonRpcProvider(erigonURL);
}
// Check if it is at least a regular ETH node
let blockNumber: number = 0;