-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(fix) Temporarily add a fixed version number until I work out how to …
…increment the real one. (fix) Don't pass "latest" to ots_getCode() in ZQ1 - it errors out if you do this. (feat) A quirks feature to check (badly!) if we are Zilliqa 1.
- Loading branch information
1 parent
70f27fb
commit bd85bab
Showing
5 changed files
with
60 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { | ||
JsonRpcApiProvider | ||
} from "ethers"; | ||
import { useEffect, useMemo, useState } from "react"; | ||
import useSWR, { 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<any,Quirks> => async (key) =>{ | ||
const version = await provider?.send("GetVersion", []); | ||
const isZilliqa1 = version?.Version.match(/^v9.[0-9]+/); | ||
console.log(`version ${JSON.stringify(version)} is Zilliqa 1? {isZilliqa1}`); | ||
return { | ||
isZilliqa1 | ||
} | ||
} | ||
|
||
export const useQuirks = (provider: JsonRpcApiProvider | undefined) : Quirks => { | ||
const { data : quirks } = useSWRImmutable("getVersion", quirksFetcher(provider)); | ||
return quirks; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,3 +102,4 @@ export const useBlockChainInfo = ( | |
} | ||
return { data, isLoading }; | ||
}; | ||
|