+
+ Txn Hash |
+ Method |
+ Block |
+ Age |
+ From |
+ To |
+ Value |
+
-
-
+ |
+
);
export default React.memo(TransactionResultHeader);
diff --git a/src/useErigonHooks.ts b/src/useErigonHooks.ts
index 97060603..62d7694c 100644
--- a/src/useErigonHooks.ts
+++ b/src/useErigonHooks.ts
@@ -30,6 +30,7 @@ import {
TokenTransfer,
TransactionData,
} from "./types";
+import { useQuirks } from "./useQuirks";
import { formatter } from "./utils/formatter";
const TRANSFER_TOPIC =
@@ -420,13 +421,15 @@ export const useInternalOperations = (
}
const _t: InternalOperation[] = [];
- for (const t of data) {
- _t.push({
- type: t.type,
- from: formatter.address(getAddress(t.from)),
- to: formatter.address(getAddress(t.to)),
- value: formatter.bigInt(t.value),
- });
+ if (data) {
+ for (const t of data) {
+ _t.push({
+ type: t.type,
+ from: formatter.address(getAddress(t.from)),
+ to: formatter.address(getAddress(t.to)),
+ value: formatter.bigInt(t.value),
+ });
+ }
}
return _t;
}, [provider, data]);
@@ -782,6 +785,12 @@ export const useHasCode = (
blockTag: BlockTag = "latest",
): boolean | undefined => {
const fetcher = providerFetcher(provider);
+ const quirks = useQuirks(provider);
+ if (quirks?.isZilliqa1) {
+ // Zilliqa 1 requires that the tag be numeric, but ignores it, so we can
+ // use 0 and save ourselves a fetch.
+ blockTag = 0;
+ }
const { data, error } = useSWRImmutable(
["ots_hasCode", address, blockTag],
fetcher,
diff --git a/src/useQuirks.ts b/src/useQuirks.ts
new file mode 100644
index 00000000..73bdf420
--- /dev/null
+++ b/src/useQuirks.ts
@@ -0,0 +1,31 @@
+import { JsonRpcApiProvider } from "ethers";
+import { Fetcher } from "swr";
+import useSWRImmutable from "swr/immutable";
+
+export type Quirks = {
+ // Zilliqa 1 has so many odd quirks that we just have to declare it ..
+ isZilliqa1: boolean;
+};
+
+type ZilliqaVersion = {
+ Commit: string;
+ Version: string;
+};
+
+export const quirksFetcher =
+ (provider: JsonRpcApiProvider | undefined): Fetcher
=>
+ async (key) => {
+ const version = await provider?.send("GetVersion", []);
+ const isZilliqa1 = version?.Version.match(/^v9.[0-9]+/);
+ return {
+ isZilliqa1: !!isZilliqa1,
+ };
+ };
+
+export const useQuirks = (provider: JsonRpcApiProvider | undefined): Quirks => {
+ const { data: quirks } = useSWRImmutable(
+ "getVersion",
+ quirksFetcher(provider),
+ );
+ return quirks;
+};