Skip to content

Commit

Permalink
(fix) Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
rrw-zilliqa committed Jan 23, 2025
1 parent f65c94b commit 779e4b8
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 52 deletions.
6 changes: 3 additions & 3 deletions README.zilliqa.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ These are overridden if we select network from your hostname.

There are some extra config options - see `public/config.json` for an example. In particular, `connections` is a list of potential connections, each of which is a dictionary:

* `menuName` - name that will appear in the connection menu for this option
* `url` - the URL to query
* `hostnames` - an array of hostnames. If the `window.location` hostname has one of these as a prefix, the `url` will be force-selected and the connections menu will not appear.
- `menuName` - name that will appear in the connection menu for this option
- `url` - the URL to query
- `hostnames` - an array of hostnames. If the `window.location` hostname has one of these as a prefix, the `url` will be force-selected and the connections menu will not appear.

## Starting for development

Expand Down
17 changes: 10 additions & 7 deletions src/ConnectionErrorPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,16 @@ const ConnectionErrorPanel: FC<ConnectionErrorPanelProps> = ({
</Step>
</>
)}
{ config?.displayConnectionMenu ? (
<div className="flex space-x-2 mt-2">
<span className="text-blue-600">
<FontAwesomeIcon icon={faBarsProgress} size="1x" />
</span>
<NetworkMenuWithConfig config={config} />
</div>) : (<div />) }
{config?.displayConnectionMenu ? (
<div className="flex space-x-2 mt-2">
<span className="text-blue-600">
<FontAwesomeIcon icon={faBarsProgress} size="1x" />
</span>
<NetworkMenuWithConfig config={config} />
</div>
) : (
<div />
)}
</div>
</div>
);
Expand Down
10 changes: 7 additions & 3 deletions src/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ const Header: FC<HeaderProps> = ({ sourcifyPresent }) => {
</div>
</Link>
</div>
{ config.displayConnectionMenu ? (<div className="pt-2 flex items-center justify-center">
<NetworkMenu />
</div>) : (<div />) }
{config.displayConnectionMenu ? (
<div className="pt-2 flex items-center justify-center">
<NetworkMenu />
</div>
) : (
<div />
)}
<div className="flex items-baseline gap-x-3">
{(provider._network.chainId === 1n ||
config.priceOracleInfo?.nativeTokenPrice?.ethUSDOracleAddress) && (
Expand Down
59 changes: 31 additions & 28 deletions src/execution/address/ScillaState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const ScillaState: FC<ScillaStateProps> = ({
const { data, isLoading } = useSmartContractState(
loadContractState ? zilliqa : undefined,
address,
loadContractState ?? 0
loadContractState ?? 0,
);
if (data && contractState == null) {
setContractState(data);
Expand All @@ -67,34 +67,37 @@ export const ScillaState: FC<ScillaStateProps> = ({

return (
<div className="mt-6">
<button
className="text-link-blue hover:text-link-blue-hover"
onClick={() => { setContractState(null); setLoadContractState((prev : number) => prev + 1); }}
>
Refresh
</button>
<button
className="text-link-blue hover:text-link-blue-hover"
onClick={() => {
setContractState(null);
setLoadContractState((prev: number) => prev + 1);
}}
>
Refresh
</button>

<div className={isLoading ? "opacity-50": ""}>
<table className="w-ful border">
<thead>
<tr className="grid grid-cols-12 gap-x-2 bg-gray-100 py-2 text-left">
<th className="col-span-3 pl-1">name</th>
<th className="col-span-8 pr-1">value</th>
</tr>
</thead>
<tbody className="divide-y">
{contractState
? Object.keys(contractState).map((val) => (
<ScillaStateParamRow
key={val}
name={val}
value={formatJsonValue(contractState[val])}
/>
))
: undefined}
</tbody>
</table>
</div>
<div className={isLoading ? "opacity-50" : ""}>
<table className="w-ful border">
<thead>
<tr className="grid grid-cols-12 gap-x-2 bg-gray-100 py-2 text-left">
<th className="col-span-3 pl-1">name</th>
<th className="col-span-8 pr-1">value</th>
</tr>
</thead>
<tbody className="divide-y">
{contractState
? Object.keys(contractState).map((val) => (
<ScillaStateParamRow
key={val}
name={val}
value={formatJsonValue(contractState[val])}
/>
))
: undefined}
</tbody>
</table>
</div>
</div>
);
};
16 changes: 8 additions & 8 deletions src/useConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ export type OtterscanConfig = {
* strings.
*/
backendFormat?: string;

};

/**
Expand All @@ -209,7 +208,6 @@ export type OtterscanConfig = {
* a trailing forward slash, e.g. "https://sepolia.otterscan.io".
*/
l1ExplorerURL?: string;

};

/**
Expand Down Expand Up @@ -331,7 +329,9 @@ export const loadOtterscanConfig = async (): Promise<OtterscanConfig> => {
const data = await res.json();
// Override config for local dev
var config: OtterscanConfig = { ...data };
console.log(`DEV = ${import.meta.env.DEV} ${import.meta.env.VITE_ERIGON_URL}`);
console.log(
`DEV = ${import.meta.env.DEV} ${import.meta.env.VITE_ERIGON_URL}`,
);
if (import.meta.env.DEV) {
config.erigonURL = import.meta.env.VITE_ERIGON_URL ?? config.erigonURL;
config.beaconAPI =
Expand Down Expand Up @@ -362,7 +362,7 @@ export const loadOtterscanConfig = async (): Promise<OtterscanConfig> => {
}
//console.log(JSON.stringify(config));
var storageConfiguration: any = {};
var hostForcesConnection : boolean = false;
var hostForcesConnection: boolean = false;
try {
var storage = window["localStorage"];
if (storage !== undefined) {
Expand All @@ -378,7 +378,7 @@ export const loadOtterscanConfig = async (): Promise<OtterscanConfig> => {
try {
var host = window.location.host;
// Ignore locally stored connections when matching hostnames.
var connections : ChainConnection[] | undefined = config.connections;
var connections: ChainConnection[] | undefined = config.connections;
if (connections !== undefined) {
for (var c of connections) {
const hosts = c.hostnames;
Expand All @@ -399,7 +399,7 @@ export const loadOtterscanConfig = async (): Promise<OtterscanConfig> => {
// If we've still not got a connection, use the first one.
try {
if (config.erigonURL === undefined || config.erigonURL == null) {
var connections : ChainConnection[] | undefined =
var connections: ChainConnection[] | undefined =
storageConfiguration["connections"] ?? config.connections;
if (connections !== undefined) {
if (!("erigonURL" in storageConfiguration)) {
Expand All @@ -420,7 +420,7 @@ export const loadOtterscanConfig = async (): Promise<OtterscanConfig> => {
if (params.has("network")) {
const url = params.get("network");
storageConfiguration["erigonURL"] = url;
var connections: ChainConnection[] | undefined =
var connections: ChainConnection[] | undefined =
storageConfiguration["connections"] ?? config.connections;
var found = false;
if (connections) {
Expand Down Expand Up @@ -471,7 +471,7 @@ export const loadOtterscanConfig = async (): Promise<OtterscanConfig> => {
// config file and is no longer there.
config.displayConnectionMenu = !hostForcesConnection;
console.log(JSON.stringify(config));

console.info("Loaded app config");
console.info(config);
return config;
Expand Down
7 changes: 4 additions & 3 deletions src/useZilliqaHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
DsBlockObj,
} from "@zilliqa-js/core/dist/types/src/types";
import { Zilliqa } from "@zilliqa-js/zilliqa";
import { mutate, Fetcher } from "swr";
import { Fetcher } from "swr";
import useSWRImmutable from "swr/immutable";
import useSWRInfinite from "swr/infinite";

Expand Down Expand Up @@ -155,7 +155,9 @@ export const useSmartContractState = (
generation: number,
): { data: ContractState | undefined; isLoading: boolean } => {
const { data, error, isLoading } = useSWRImmutable(
zilliqa !== undefined ? [zilliqa, "useSmartContractState", address, generation] : null,
zilliqa !== undefined
? [zilliqa, "useSmartContractState", address, generation]
: null,
smartContractStateFetcher,
{ keepPreviousData: true },
);
Expand All @@ -164,4 +166,3 @@ export const useSmartContractState = (
}
return { data, isLoading };
};

0 comments on commit 779e4b8

Please sign in to comment.