Skip to content

Commit

Permalink
(fix) Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
rrw-zilliqa committed Dec 9, 2024
1 parent 1b13add commit 2e6ddfb
Show file tree
Hide file tree
Showing 24 changed files with 190 additions and 195 deletions.
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
8 changes: 4 additions & 4 deletions src/ConnectionErrorPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ const ConnectionErrorPanel: FC<ConnectionErrorPanelProps> = ({
<Step type="error" msg="It does not seem to be a Zilliqa node">
<p>Make sure your browser can access the URL above.</p>
<p>
If you want to customize the Zilliqa rpc endpoint, please
follow the instructions in the <code>README.md</code>.
If you want to customize the Zilliqa rpc endpoint, please follow
the instructions in the <code>README.md</code>.
</p>
</Step>
)}
{connStatus === ConnectionStatus.NOT_ERIGON && (
<>
<Step type="ok" msg="It is a Zilliqa node" />
<Step type="error" msg="It does not seem to be a Zilliqa node">
Make sure your Zilliqa node is up and running.
Make sure your Zilliqa node is up and running.
</Step>
</>
)}
Expand All @@ -47,7 +47,7 @@ const ConnectionErrorPanel: FC<ConnectionErrorPanelProps> = ({
type="error"
msg="It does not seem to contain up-to-date Otterscan patches"
>
Check your Zilliqa node version.
Check your Zilliqa node version.
</Step>
</>
)}
Expand Down
20 changes: 10 additions & 10 deletions src/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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`}
>
<div className="flex-grow text-center">
{provider ? (
<>Using Zilliqa node at {config?.erigonURL}</>
) : (
<>Waiting for the provider...</>
)}
</div>
<div className="flex-shrink-0 ml-2">zq otterscan {config?.version}</div>
<div className="flex-grow text-center">
{provider ? (
<>Using Zilliqa node at {config?.erigonURL}</>
) : (
<>Waiting for the provider...</>
)}
</div>
<div className="flex-shrink-0 ml-2">zq otterscan {config?.version}</div>
</div>
</>
);
Expand Down
4 changes: 2 additions & 2 deletions src/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ const Header: FC<HeaderProps> = ({ sourcifyPresent }) => {
title="Scan an ETH address using your camera"
>
<FontAwesomeIcon icon={faQrcode} />
</button>
<button
</button>
<button
className="border bg-skin-button-fill px-2 py-1 text-sm text-skin-button hover:bg-skin-button-hover-fill focus:outline-none"
type="button"
onClick={() => setHelpOpen(true)}
Expand Down
1 change: 0 additions & 1 deletion src/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { FC, lazy, memo, useContext, useState } from "react";
import { NavLink, useSearchParams } from "react-router-dom";
import Header from "./Header";
import Logo from "./Logo";
import SourcifyMenu from "./SourcifyMenu";
import Timestamp from "./components/Timestamp";
import ChainInfo from "./execution/ChainInfo";
import RecentBlocks from "./execution/block/RecentBlocks";
Expand Down
2 changes: 1 addition & 1 deletion src/components/Timestamp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const Timestamp: React.FC<TimestampProps> = ({ value, age }) => {
<span>
<TimestampAge timestamp={value} /> ({tsString})
</span>
);
);
} else {
snippet = <span>{tsString}</span>;
}
Expand Down
3 changes: 1 addition & 2 deletions src/execution/AddressMainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { TabGroup, TabList, TabPanels } from "@headlessui/react";
import { fromBech32Address } from "@zilliqa-js/crypto";
import { validation } from "@zilliqa-js/util";
import { useQuery } from "@tanstack/react-query";
import React, { useCallback, useContext } from "react";
import {
Outlet,
Expand All @@ -20,7 +19,7 @@ import SourcifyLogo from "../sourcify/SourcifyLogo";
import { Match, useSourcifyMetadata } from "../sourcify/useSourcify";
import { useWhatsabiMetadata } from "../sourcify/useWhatsabi";
import { ChecksummedAddress } from "../types";
import { hasCodeQuery, useHasCode } from "../useErigonHooks";
import { useHasCode } from "../useErigonHooks";
import { useAddressOrENS } from "../useResolvedAddresses";
import { RuntimeContext } from "../useRuntime";
import AddressSubtitle from "./address/AddressSubtitle";
Expand Down
8 changes: 4 additions & 4 deletions src/execution/Transaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ const Transaction: FC = () => {
{` (${txData.confirmedData?.logs?.length ?? 0})`}
</NavTab>
)}
<NavTab href="trace">Trace</NavTab>
<NavTab href="receipt">Receipt</NavTab>
<NavTab href="trace">Trace</NavTab>
<NavTab href="receipt">Receipt</NavTab>
<NavTab href="statediff">State Diff</NavTab>
</TabList>
</TabGroup>
Expand All @@ -65,8 +65,8 @@ const Transaction: FC = () => {
path="logs"
element={<Logs logs={txData.confirmedData?.logs} />}
/>
<Route path="trace" element={<Trace txData={txData} />} />
<Route path="receipt" element={<Receipt txData={txData} />} />
<Route path="trace" element={<Trace txData={txData} />} />
<Route path="receipt" element={<Receipt txData={txData} />} />
<Route
path="statediff"
element={<StateDiff txData={txData} />}
Expand Down
4 changes: 2 additions & 2 deletions src/execution/address/AddressTransactionResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ const AddressTransactionResults: FC = () => {
<PendingPage rows={1} cols={8} />
)}
</StandardScrollableTable>
<NavBar address={address} page={page} controller={controller} />
<PendingTransactionResults />
<NavBar address={address} page={page} controller={controller} />
<PendingTransactionResults />
</StandardSelectionBoundary>
</ContentFrame>
);
Expand Down
169 changes: 85 additions & 84 deletions src/execution/address/Contracts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { faChevronDown } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { Menu, MenuButton, MenuItem, MenuItems } from "@headlessui/react";
import { useQuery } from "@tanstack/react-query";
import { toUtf8String } from "ethers";
import React, { lazy, useContext, useEffect, useMemo, useState } from "react";
import React, { lazy, useContext, useEffect, useState } from "react";
import ContentFrame from "../../components/ContentFrame";
import ExternalLink from "../../components/ExternalLink";
import InfoRow from "../../components/InfoRow";
Expand All @@ -13,12 +12,12 @@ import { openInRemixURL } from "../../url";
import { getCodeQuery } from "../../useErigonHooks";
import { RuntimeContext } from "../../useRuntime";
import { usePageTitle } from "../../useTitle";
import { useIsScillaCode } from "../../useZilliqa";
import { commify } from "../../utils/utils";
import ContractFromRepo from "./ContractFromRepo";
import ScillaContract from "./ScillaContract";
import WhatsabiWarning from "./WhatsabiWarning";
import ContractABI from "./contract/ContractABI";
import { useIsScillaCode } from "../../useZilliqa";

const HighlightedSolidity = lazy(
() => import("./contract/HighlightedSolidity"),
Expand Down Expand Up @@ -52,7 +51,9 @@ const Contracts: React.FC<ContractsProps> = ({ checksummedAddress, match }) => {

return (
<ContentFrame tabs>
{match && match.type === MatchType.WHATSABI_GUESS && !scillaCode && <WhatsabiWarning />}
{match && match.type === MatchType.WHATSABI_GUESS && !scillaCode && (
<WhatsabiWarning />
)}
{match && match.type !== MatchType.WHATSABI_GUESS && (
<>
{match.metadata.settings?.compilationTarget && (
Expand Down Expand Up @@ -85,93 +86,93 @@ const Contracts: React.FC<ContractsProps> = ({ checksummedAddress, match }) => {
</>
)}
{!scillaCode && (
<div className="py-5">
{match === undefined && (
<span>Getting data from Sourcify repository...</span>
)}
{match === null && (
<span>
Address is not a contract or could not find contract metadata in
Sourcify repository.
<div className="py-5">
{match === undefined && (
<span>Getting data from Sourcify repository...</span>
)}
{match === null && (
<span>
Address is not a contract or could not find contract metadata in
Sourcify repository.
</span>
)}
{match !== undefined && match !== null && (
<>
{match.metadata.output.abi && (
<ContractABI
abi={match.metadata.output.abi}
unknownSelectors={match.unknownSelectors}
/>
)}
{match.type !== MatchType.WHATSABI_GUESS && (
<div>
<Menu>
<div className="flex items-baseline justify-between space-x-2">
<MenuButton className="flex space-x-2 rounded-t border-l border-r border-t px-2 py-1 text-sm">
<span>{selected}</span>
<span className="self-center">
<FontAwesomeIcon icon={faChevronDown} size="xs" />
</span>
</MenuButton>
{provider && (
<div className="text-sm">
<ExternalLink
href={openInRemixURL(
checksummedAddress,
provider._network.chainId,
)}
>
Open in Remix
</ExternalLink>
</div>
)}
</div>
<div className="relative">
<MenuItems className="absolute z-10 flex flex-col rounded-b border bg-white p-1">
{Object.entries(match.metadata.sources).map(([k]) => (
<MenuItem key={k}>
<button
className={`flex px-2 py-1 text-sm ${
selected === k
? "bg-gray-200 font-bold text-gray-500"
: "text-gray-400 transition-colors duration-75 hover:text-gray-500"
}`}
onClick={() => setSelected(k)}
)}
{match !== undefined && match !== null && (
<>
{match.metadata.output.abi && (
<ContractABI
abi={match.metadata.output.abi}
unknownSelectors={match.unknownSelectors}
/>
)}
{match.type !== MatchType.WHATSABI_GUESS && (
<div>
<Menu>
<div className="flex items-baseline justify-between space-x-2">
<MenuButton className="flex space-x-2 rounded-t border-l border-r border-t px-2 py-1 text-sm">
<span>{selected}</span>
<span className="self-center">
<FontAwesomeIcon icon={faChevronDown} size="xs" />
</span>
</MenuButton>
{provider && (
<div className="text-sm">
<ExternalLink
href={openInRemixURL(
checksummedAddress,
provider._network.chainId,
)}
>
{k}
</button>
</MenuItem>
))}
</MenuItems>
</div>
</Menu>
{selected && (
<>
{match.metadata.sources[selected].content ? (
<HighlightedSolidity
source={match.metadata.sources[selected].content}
/>
) : (
<ContractFromRepo
checksummedAddress={checksummedAddress}
networkId={provider!._network.chainId}
filename={selected}
fileHash={match.metadata.sources[selected].keccak256}
type={match.type}
/>
)}
</>
)}
</div>
)}
</>
)}
Open in Remix
</ExternalLink>
</div>
)}
</div>
<div className="relative">
<MenuItems className="absolute z-10 flex flex-col rounded-b border bg-white p-1">
{Object.entries(match.metadata.sources).map(([k]) => (
<MenuItem key={k}>
<button
className={`flex px-2 py-1 text-sm ${
selected === k
? "bg-gray-200 font-bold text-gray-500"
: "text-gray-400 transition-colors duration-75 hover:text-gray-500"
}`}
onClick={() => setSelected(k)}
>
{k}
</button>
</MenuItem>
))}
</MenuItems>
</div>
</Menu>
{selected && (
<>
{match.metadata.sources[selected].content ? (
<HighlightedSolidity
source={match.metadata.sources[selected].content}
/>
) : (
<ContractFromRepo
checksummedAddress={checksummedAddress}
networkId={provider!._network.chainId}
filename={selected}
fileHash={match.metadata.sources[selected].keccak256}
type={match.type}
/>
)}
</>
)}
</div>
)}
</>
)}
</div>
)}
<div className="py-5">
{code === undefined && <span>Getting contract bytecode...</span>}
{scillaCode && (
<ScillaContract address={checksummedAddress} content={scillaCode} />
<ScillaContract address={checksummedAddress} content={scillaCode} />
)}
{!scillaCode && code && (
<>
Expand Down
16 changes: 10 additions & 6 deletions src/execution/address/contract/ReadContract.tsx
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -42,10 +42,14 @@ const ReadContract: React.FC<ContractsProps> = ({
const withScilla = (
<StandardSelectionBoundary>
<ContentFrame tabs>
<span>This is a scilla contract; use the state read option in the Contract tab to read the state for now</span>
<span>
This is a scilla contract; use the state read option in the Contract
tab to read the state for now
</span>
</ContentFrame>
</StandardSelectionBoundary>);

</StandardSelectionBoundary>
);

const withCode = (
<StandardSelectionBoundary>
<ContentFrame tabs>
Expand Down
Loading

0 comments on commit 2e6ddfb

Please sign in to comment.