Skip to content

Commit

Permalink
(fix) Fix build issues (though log entry display might bite us later)
Browse files Browse the repository at this point in the history
  • Loading branch information
rrw-zilliqa committed Dec 9, 2024
1 parent 2e6ddfb commit 4bafc29
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion scripts/gen-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ else
# Changes
REPORT="${COMMIT}+"
fi
echo "export const OTTERSCAN_VERSION=\"${REPORT}\"" >$1
echo "export const OTTERSCAN_VERSION = \"${REPORT}\";" >$1
5 changes: 3 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { loader as searchLoader } from "./Search";
import { getTransactionQuery, searchTransactionsQuery } from "./search/search";
import { ConnectionStatus } from "./types";
import { ChainInfoContext, populateChainInfo } from "./useChainInfo";
import { useQuirks } from "./useQuirks";
import { loadOtterscanConfig, OtterscanConfig } from "./useConfig";
import { getBalanceQuery, getCodeQuery, hasCodeQuery } from "./useErigonHooks";
import { createRuntime, RuntimeContext } from "./useRuntime";
Expand Down Expand Up @@ -108,12 +109,12 @@ const loader: LoaderFunction = async () => {
const addressLoader: LoaderFunction = async ({ params }) => {
runtime.then((rt) => {
if (isAddress(params.addressOrName)) {
const quirks = useQuirks(provider);
const quirks = useQuirks(rt.provider);
let blockTag = "latest";
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;
blockTag = "0";
}
const query = hasCodeQuery(rt.provider, params.addressOrName, blockTag);
queryClient.prefetchQuery(query);
Expand Down
6 changes: 3 additions & 3 deletions src/execution/transaction/LogEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ const LogEntry: FC<LogEntryProps> = ({ log }) => {
} else {
logDescElem = (
<TwoColumnPanel>
<DecodedLogSignature event={resolvedLogDesc.fragment} />
<DecodedLogSignature event={(resolvedLogDesc as any).fragment} />
<DecodedParamsTable
args={resolvedLogDesc.args}
paramTypes={resolvedLogDesc.fragment.inputs}
args={(resolvedLogDesc as any).args}
paramTypes={(resolvedLogDesc as any).fragment.inputs}
hasParamNames={resolvedLogDesc === logDesc}
/>
</TwoColumnPanel>
Expand Down
2 changes: 1 addition & 1 deletion src/storybook/util.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const mockProvider: JsonRpcProvider = new JsonRpcProvider(

export const runtimeDecorator: Decorator<unknown> = (Story) => (
<RuntimeContext.Provider
value={{ config: mockConfig, provider: mockProvider }}
value={{ config: mockConfig, provider: mockProvider }}
>
<AppConfigContext.Provider
value={{
Expand Down
2 changes: 1 addition & 1 deletion src/useConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export type OtterscanConfig = {

/** Version number
*/
version: string;
version?: string;
};

/**
Expand Down
6 changes: 3 additions & 3 deletions src/useErigonHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -907,16 +907,16 @@ export const getCodeQuery = (
});

export const useGetRawReceipt = (
provider: JsonRpcApiProvider | undefined,
address: ChecksummedAddress | undefined,
provider: JsonRpcApiProvider,
address: ChecksummedAddress,
): string | undefined => {
const { data } = useQuery(getTransactionReceiptQuery(provider, address));
return data as string | undefined;
};

export const getTransactionReceiptQuery = (
provider: JsonRpcApiProvider,
address: Address,
address: ChecksummedAddress,
) => ({
queryKey: ["eth_getTransactionReceipt", address],
queryFn: () => {
Expand Down
2 changes: 1 addition & 1 deletion src/useQuirks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type ZilliqaVersion = {
Version: string;
};

export const useQuirks = (provider: JsonRpcApiProvider | undefined): Quirks => {
export const useQuirks = (provider: JsonRpcApiProvider): Quirks => {
const { data: version } = useQuery(getVersionQuery(provider));
const isZilliqa1 = version?.Version.match(/^v9.[0-9]+/);
return {
Expand Down
6 changes: 3 additions & 3 deletions src/useRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export type OtterscanRuntime = {
* Zilliqa object; may be undefined if not ready because of config fetching,
* probing occurring, etc.
*/
zilliqa: Zilliqa;
zilliqa?: Zilliqa;
};

/**
Expand All @@ -58,11 +58,11 @@ export const createRuntime = async (
provider: new JsonRpcProvider(effectiveConfig.erigonURL, network, {
staticNetwork: network,
}),
zilliqa: createZilliqa(effectiveConfig.erigonURL),
zilliqa: createZilliqa(effectiveConfig.erigonURL!),
};
}

const zilliqa = createZilliqa(effectiveConfig?.erigonURL);
const zilliqa = createZilliqa(effectiveConfig.erigonURL!);
const provider = await createAndProbeProvider(effectiveConfig.erigonURL);
return {
config: effectiveConfig,
Expand Down
4 changes: 2 additions & 2 deletions src/useZilliqa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { JsonRpcApiProvider, toUtf8String } from "ethers";
import { useMemo } from "react";
import { getCodeQuery } from "./useErigonHooks";

export const createZilliqa = (erigonURL?: string): Zilliqa | undefined => {
export const createZilliqa = (erigonURL: string): Zilliqa => {
return new Zilliqa(erigonURL);
};

export const useIsScillaCode = (
provider: JsonRpcApiProvider | undefined,
provider: JsonRpcApiProvider,
checksummedAddress?: string,
) => {
const { data: code } = useQuery(
Expand Down

0 comments on commit 4bafc29

Please sign in to comment.