From 2e6ddfb6056a697d1a233b6c42680f6d901f2958 Mon Sep 17 00:00:00 2001 From: Richard Watts Date: Mon, 9 Dec 2024 19:45:21 +0000 Subject: [PATCH] (fix) Fix formatting --- src/App.tsx | 2 +- src/ConnectionErrorPanel.tsx | 8 +- src/Footer.tsx | 20 +-- src/Header.tsx | 4 +- src/Home.tsx | 1 - src/components/Timestamp.tsx | 2 +- src/execution/AddressMainPage.tsx | 3 +- src/execution/Transaction.tsx | 8 +- .../address/AddressTransactionResults.tsx | 4 +- src/execution/address/Contracts.tsx | 169 +++++++++--------- .../address/contract/ReadContract.tsx | 16 +- src/execution/transaction/LogEntry.tsx | 48 ++--- src/execution/transaction/Logs.tsx | 34 ++-- src/highlight-init.ts | 2 +- src/search/PendingResults.tsx | 1 - src/search/search.ts | 4 +- src/useConfig.ts | 12 +- src/useErigonHooks.ts | 8 +- src/useLatestBlock.ts | 2 - src/useQuirks.ts | 6 +- src/useRuntime.ts | 4 +- src/useZilliqa.ts | 24 +-- src/utils/utils.ts | 1 - vite.config.ts | 2 +- 24 files changed, 190 insertions(+), 195 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index a025ec20..6eea11ec 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -33,7 +33,7 @@ import { getTransactionQuery, searchTransactionsQuery } from "./search/search"; import { ConnectionStatus } from "./types"; import { ChainInfoContext, populateChainInfo } from "./useChainInfo"; import { loadOtterscanConfig, OtterscanConfig } from "./useConfig"; -import { getBalanceQuery, getCodeQuery, hasCodeQuery, useHasCode } from "./useErigonHooks"; +import { getBalanceQuery, getCodeQuery, hasCodeQuery } from "./useErigonHooks"; import { createRuntime, RuntimeContext } from "./useRuntime"; import WarningHeader from "./WarningHeader"; diff --git a/src/ConnectionErrorPanel.tsx b/src/ConnectionErrorPanel.tsx index d070570f..8742a3fe 100644 --- a/src/ConnectionErrorPanel.tsx +++ b/src/ConnectionErrorPanel.tsx @@ -27,8 +27,8 @@ const ConnectionErrorPanel: FC = ({

Make sure your browser can access the URL above.

- If you want to customize the Zilliqa rpc endpoint, please - follow the instructions in the README.md. + If you want to customize the Zilliqa rpc endpoint, please follow + the instructions in the README.md.

)} @@ -36,7 +36,7 @@ const ConnectionErrorPanel: FC = ({ <> - Make sure your Zilliqa node is up and running. + Make sure your Zilliqa node is up and running. )} @@ -47,7 +47,7 @@ const ConnectionErrorPanel: FC = ({ type="error" msg="It does not seem to contain up-to-date Otterscan patches" > - Check your Zilliqa node version. + Check your Zilliqa node version. )} diff --git a/src/Footer.tsx b/src/Footer.tsx index adc616eb..1122e32a 100644 --- a/src/Footer.tsx +++ b/src/Footer.tsx @@ -10,17 +10,17 @@ const Footer: React.FC = () => { className={`w-full border-t border-t-gray-100 px-2 py-1 text-xs ${ provider._network.chainId === 1n ? "bg-link-blue dark:bg-link-blue-light text-gray-200 dark:text-gray-800" - : "bg-zq-lightblue text-white font-bold" - } flex justify-between items-center`} + : "bg-zq-lightblue text-white font-bold" + } flex justify-between items-center`} > -
- {provider ? ( - <>Using Zilliqa node at {config?.erigonURL} - ) : ( - <>Waiting for the provider... - )} -
-
zq otterscan {config?.version}
+
+ {provider ? ( + <>Using Zilliqa node at {config?.erigonURL} + ) : ( + <>Waiting for the provider... + )} +
+
zq otterscan {config?.version}
); diff --git a/src/Header.tsx b/src/Header.tsx index b2bb5b30..272cc97f 100644 --- a/src/Header.tsx +++ b/src/Header.tsx @@ -79,8 +79,8 @@ const Header: FC = ({ sourcifyPresent }) => { title="Scan an ETH address using your camera" > - - - - ))} - - - - {selected && ( - <> - {match.metadata.sources[selected].content ? ( - - ) : ( - - )} - - )} - - )} - - )} + Open in Remix + + + )} + +
+ + {Object.entries(match.metadata.sources).map(([k]) => ( + + + + ))} + +
+ + {selected && ( + <> + {match.metadata.sources[selected].content ? ( + + ) : ( + + )} + + )} + + )} + + )} )}
{code === undefined && Getting contract bytecode...} {scillaCode && ( - + )} {!scillaCode && code && ( <> diff --git a/src/execution/address/contract/ReadContract.tsx b/src/execution/address/contract/ReadContract.tsx index 36d98dc1..5055ca75 100644 --- a/src/execution/address/contract/ReadContract.tsx +++ b/src/execution/address/contract/ReadContract.tsx @@ -1,14 +1,14 @@ import { FunctionFragment } from "ethers"; -import React, { useState, useContext } from "react"; +import React, { useContext, useState } from "react"; import ContentFrame from "../../../components/ContentFrame"; import LabeledSwitch from "../../../components/LabeledSwitch"; import StandardSelectionBoundary from "../../../selection/StandardSelectionBoundary"; import { Match, MatchType } from "../../../sourcify/useSourcify"; +import { RuntimeContext } from "../../../useRuntime"; import { usePageTitle } from "../../../useTitle"; +import { useIsScillaCode } from "../../../useZilliqa"; import WhatsabiWarning from "../WhatsabiWarning"; import ReadFunction from "./ReadFunction"; -import { useIsScillaCode } from "../../../useZilliqa"; -import { RuntimeContext } from "../../../useRuntime"; type ContractsProps = { checksummedAddress: string; @@ -42,10 +42,14 @@ const ReadContract: React.FC = ({ const withScilla = ( - This is a scilla contract; use the state read option in the Contract tab to read the state for now + + This is a scilla contract; use the state read option in the Contract + tab to read the state for now + - ); - + + ); + const withCode = ( diff --git a/src/execution/transaction/LogEntry.tsx b/src/execution/transaction/LogEntry.tsx index d49015c5..da398f42 100644 --- a/src/execution/transaction/LogEntry.tsx +++ b/src/execution/transaction/LogEntry.tsx @@ -195,37 +195,41 @@ const LogEntry: FC = ({ log }) => { if (scillaLogDesc !== null && scillaLogDesc !== undefined) { scillaLog = ( ) + eventName={scillaLogDesc.eventName} + address={scillaLogDesc.address} + params={scillaLogDesc.params} + /> + ); } else if (topic0ScillaEncapsLogDesc !== undefined) { - scillaLog = () + scillaLog = ( + + ); } - let logDescElem = (Waiting for data...); + let logDescElem = Waiting for data...; if (resolvedLogDesc !== undefined) { if (resolvedLogDesc === null) { if (scillaLog !== undefined) { logDescElem = scillaLog; } else { - logDescElem = (Cannot decode data); + logDescElem = Cannot decode data; } } else { - logDescElem = ( - - - - ) + logDescElem = ( + + + + + ); } - }; + } return (
@@ -246,9 +250,7 @@ const LogEntry: FC = ({ log }) => { - - { logDescElem } - + {logDescElem} diff --git a/src/execution/transaction/Logs.tsx b/src/execution/transaction/Logs.tsx index 607b372e..8bc7cffb 100644 --- a/src/execution/transaction/Logs.tsx +++ b/src/execution/transaction/Logs.tsx @@ -25,22 +25,24 @@ const Logs: FC = ({ logs }) => { }, [logs]); return ( -
- {" "} - {logs && ( - <> - {logs.length > 0 ? ( - <> - {logs.map((l, i) => ( - - ))} - - ) : ( -
Transaction did not emit any logs
- )} - - )}{" "} -
+
+ {" "} + {logs && ( + <> + {logs.length > 0 ? ( + <> + {logs.map((l, i) => ( + + ))} + + ) : ( +
+ Transaction did not emit any logs +
+ )} + + )}{" "} +
); }; diff --git a/src/highlight-init.ts b/src/highlight-init.ts index f8318eb2..fcc1b4e0 100644 --- a/src/highlight-init.ts +++ b/src/highlight-init.ts @@ -11,4 +11,4 @@ import hljsDefineSolidity from "highlightjs-solidity"; hljsDefineSolidity(hljs); hljs.registerLanguage("json", json); -export { SyntaxHighlighter, docco }; +export { docco, SyntaxHighlighter }; diff --git a/src/search/PendingResults.tsx b/src/search/PendingResults.tsx index 7c1038e4..40be4038 100644 --- a/src/search/PendingResults.tsx +++ b/src/search/PendingResults.tsx @@ -65,5 +65,4 @@ export const PendingChainInfoResults: React.FC = React.memo(() => (
)); - export default React.memo(PendingResults); diff --git a/src/search/search.ts b/src/search/search.ts index fc434c0a..b4be67ab 100644 --- a/src/search/search.ts +++ b/src/search/search.ts @@ -1,3 +1,4 @@ +import { fromBech32Address } from "@zilliqa-js/crypto"; import { JsonRpcApiProvider, TransactionReceiptParams, @@ -22,9 +23,6 @@ import { PAGE_SIZE } from "../params"; import { queryClient } from "../queryClient"; import { ProcessedTransaction, TransactionChunk } from "../types"; import { formatter } from "../utils/formatter"; -import { fromBech32Address } from "@zilliqa-js/crypto"; - - export const rawToProcessed = (provider: JsonRpcApiProvider, _rawRes: any) => { const _res: TransactionResponse[] = _rawRes.txs.map( diff --git a/src/useConfig.ts b/src/useConfig.ts index 43b25cca..d390d9ab 100644 --- a/src/useConfig.ts +++ b/src/useConfig.ts @@ -1,7 +1,3 @@ -import { useEffect, useMemo } from "react"; -import useSWRImmutable from "swr/immutable"; -import { jsonFetcherWithErrorHandling } from "./fetcher"; - /** * Defines a set of metadata for a certain chain. * @@ -207,7 +203,7 @@ export type OtterscanConfig = { /** Version number */ - version: string; + version: string; }; /** @@ -248,11 +244,11 @@ export const loadOtterscanConfig = async (): Promise => { if (import.meta.env.DEV) { config.erigonURL = import.meta.env.VITE_ERIGON_URL ?? config.erigonURL; config.beaconAPI = - import.meta.env.VITE_BEACON_API_URL ?? config.beaconAPI; + import.meta.env.VITE_BEACON_API_URL ?? config.beaconAPI; config.assetsURLPrefix = - import.meta.env.VITE_ASSETS_URL ?? config.assetsURLPrefix; + import.meta.env.VITE_ASSETS_URL ?? config.assetsURLPrefix; config.experimental = - import.meta.env.VITE_EXPERIMENTAL ?? config.experimental; + import.meta.env.VITE_EXPERIMENTAL ?? config.experimental; if (import.meta.env.VITE_EXPERIMENTAL_FIXED_CHAIN_ID !== undefined) { config.experimentalFixedChainId = parseInt( import.meta.env.VITE_EXPERIMENTAL_FIXED_CHAIN_ID, diff --git a/src/useErigonHooks.ts b/src/useErigonHooks.ts index 8d2ced6c..8354bc4e 100644 --- a/src/useErigonHooks.ts +++ b/src/useErigonHooks.ts @@ -884,7 +884,6 @@ export const useHasCode = ( return hasCode; }; - export const hasCodeQuery = ( provider: JsonRpcApiProvider, address: ChecksummedAddress | undefined, @@ -915,14 +914,13 @@ export const useGetRawReceipt = ( return data as string | undefined; }; - export const getTransactionReceiptQuery = ( provider: JsonRpcApiProvider, - address: Address + address: Address, ) => ({ - queryKey: [ "eth_getTransactionReceipt", address ], + queryKey: ["eth_getTransactionReceipt", address], queryFn: () => { - return provider.send("eth_getTransactionReceipt", [ address ]); + return provider.send("eth_getTransactionReceipt", [address]); }, }); diff --git a/src/useLatestBlock.ts b/src/useLatestBlock.ts index 4e7c73a3..6d1719a9 100644 --- a/src/useLatestBlock.ts +++ b/src/useLatestBlock.ts @@ -6,7 +6,6 @@ import { formatter } from "./utils/formatter"; const refreshRate = 30000; // In milliseconds - /** * Returns the latest block header AND hook an internal listener * that'll update and trigger a component render as a side effect @@ -132,7 +131,6 @@ export const useBCInfoStateInfo = ( return state; }; - /** * Returns the latest block number AND hook an internal listener * that'll update and trigger a component render as a side effect diff --git a/src/useQuirks.ts b/src/useQuirks.ts index d59830ef..4bdfd2cb 100644 --- a/src/useQuirks.ts +++ b/src/useQuirks.ts @@ -1,7 +1,5 @@ import { useQuery } from "@tanstack/react-query"; 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 .. @@ -21,8 +19,8 @@ export const useQuirks = (provider: JsonRpcApiProvider | undefined): Quirks => { }; }; -export const getVersionQuery = ( provider: JsonRpcApiProvider ) => ({ - queryKey: [ "GetVersion" ], +export const getVersionQuery = (provider: JsonRpcApiProvider) => ({ + queryKey: ["GetVersion"], queryFn: () => { return provider.send("GetVersion", []); }, diff --git a/src/useRuntime.ts b/src/useRuntime.ts index 3604c82c..05d23624 100644 --- a/src/useRuntime.ts +++ b/src/useRuntime.ts @@ -58,7 +58,7 @@ export const createRuntime = async ( provider: new JsonRpcProvider(effectiveConfig.erigonURL, network, { staticNetwork: network, }), - zilliqa: createZilliqa(effectiveConfig.erigonURL) + zilliqa: createZilliqa(effectiveConfig.erigonURL), }; } @@ -67,7 +67,7 @@ export const createRuntime = async ( return { config: effectiveConfig, provider, - zilliqa + zilliqa, }; }; diff --git a/src/useZilliqa.ts b/src/useZilliqa.ts index 2ede8f7e..17d3711d 100644 --- a/src/useZilliqa.ts +++ b/src/useZilliqa.ts @@ -1,30 +1,32 @@ +import { useQuery } from "@tanstack/react-query"; import { Zilliqa } from "@zilliqa-js/zilliqa"; +import { JsonRpcApiProvider, toUtf8String } from "ethers"; import { useMemo } from "react"; -import { useQuery } from "@tanstack/react-query"; -import { JsonRpcApiProvider } from "ethers"; import { getCodeQuery } from "./useErigonHooks"; -import { toUtf8String } from "ethers"; - export const createZilliqa = (erigonURL?: string): Zilliqa | undefined => { return new Zilliqa(erigonURL); -} +}; -export const useIsScillaCode = (provider: JsonRpcApiProvider | undefined, checksummedAddress?: string) => { - const { data : code } = useQuery( - getCodeQuery(provider, checksummedAddress, "latest")); +export const useIsScillaCode = ( + provider: JsonRpcApiProvider | undefined, + checksummedAddress?: string, +) => { + const { data: code } = useQuery( + getCodeQuery(provider, checksummedAddress, "latest"), + ); const scillaCode = useMemo(() => { - try { + try { if (code) { let s = toUtf8String(code); if (s.startsWith("scilla_version")) { return s; } } - } catch (err) { + } catch (err) { // Silently ignore on purpose return undefined; } }, [code]); return scillaCode; -} +}; diff --git a/src/utils/utils.ts b/src/utils/utils.ts index a00a91a0..2665f2ae 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -97,7 +97,6 @@ export function commify(value: string | number | bigint): string { return negative + formatted.join(",") + suffix; } - export const zilliqaToOtterscanTimestamp = (timestamp: string): number => { return Math.trunc(parseInt(timestamp, 10) / 1000000); }; diff --git a/vite.config.ts b/vite.config.ts index 68a99a86..eddce9de 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -6,7 +6,7 @@ import viteCompression from "vite-plugin-compression"; // https://vitejs.dev/config/ export default defineConfig({ define: { - global: "globalThis", + global: "globalThis", }, plugins: [ react(),