Add API level check
This commit is contained in:
parent
da7b039c22
commit
81f14dc0b6
|
@ -66,10 +66,10 @@ const ConnectionErrorPanel: React.FC<ConnectionErrorPanelProps> = ({
|
||||||
<Step type="ok" msg="It is an Erigon node" />
|
<Step type="ok" msg="It is an Erigon node" />
|
||||||
<Step
|
<Step
|
||||||
type="error"
|
type="error"
|
||||||
msg="It does not seem to contain Otterscan patches"
|
msg="It does not seem to contain up-to-date Otterscan patches"
|
||||||
>
|
>
|
||||||
Make sure you compiled rpcdaemon with Otterscan patches and
|
Make sure you compiled rpcdaemon with compatible Otterscan patches
|
||||||
enabled <strong>ots_</strong> namespace according to the{" "}
|
and enabled <strong>ots_</strong> namespace according to the{" "}
|
||||||
<a
|
<a
|
||||||
href="https://github.com/wmitsuda/otterscan#install-otterscan-patches-on-top-of-erigon"
|
href="https://github.com/wmitsuda/otterscan#install-otterscan-patches-on-top-of-erigon"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
|
export const MIN_API_LEVEL = 1;
|
||||||
|
|
||||||
export const PAGE_SIZE = 25;
|
export const PAGE_SIZE = 25;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { ethers } from "ethers";
|
import { ethers } from "ethers";
|
||||||
import { ConnectionStatus } from "./types";
|
import { ConnectionStatus } from "./types";
|
||||||
|
import { MIN_API_LEVEL } from "./params";
|
||||||
|
|
||||||
export const DEFAULT_ERIGON_URL = "http://127.0.0.1:8545";
|
export const DEFAULT_ERIGON_URL = "http://127.0.0.1:8545";
|
||||||
|
|
||||||
|
@ -60,12 +61,14 @@ export const useProvider = (
|
||||||
|
|
||||||
// Check if it has Otterscan patches by probing a lightweight method
|
// Check if it has Otterscan patches by probing a lightweight method
|
||||||
try {
|
try {
|
||||||
// TODO: replace by a custom made method that works in all networks
|
const level = await provider.send("ots_getApiLevel", []);
|
||||||
await provider.send("ots_getTransactionTransfers", [
|
if (level < MIN_API_LEVEL) {
|
||||||
"0x793e079fbc427cba0857b4e878194ab508f33983f45415e50af3c3c0e662fdf3",
|
setConnStatus(ConnectionStatus.NOT_OTTERSCAN_PATCHED);
|
||||||
]);
|
setProvider(undefined);
|
||||||
setConnStatus(ConnectionStatus.CONNECTED);
|
} else {
|
||||||
setProvider(provider);
|
setConnStatus(ConnectionStatus.CONNECTED);
|
||||||
|
setProvider(provider);
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
setConnStatus(ConnectionStatus.NOT_OTTERSCAN_PATCHED);
|
setConnStatus(ConnectionStatus.NOT_OTTERSCAN_PATCHED);
|
||||||
|
|
Loading…
Reference in New Issue