From 71cd332fb50caf4e3ea3fc07f099d861645daa2a Mon Sep 17 00:00:00 2001
From: Richard Watts
Date: Mon, 30 Sep 2024 14:56:50 +0100
Subject: [PATCH 1/5] (feat) Search instructions
---
README.zilliqa.md | 10 ++++++
src/Header.tsx | 64 ++++++++++++++++++++++++++++++++++-
src/components/InlineCode.tsx | 14 ++++++++
src/search/search.ts | 9 ++++-
4 files changed, 95 insertions(+), 2 deletions(-)
create mode 100644 src/components/InlineCode.tsx
diff --git a/README.zilliqa.md b/README.zilliqa.md
index f3b97d6a..8a3a0051 100644
--- a/README.zilliqa.md
+++ b/README.zilliqa.md
@@ -14,3 +14,13 @@ ignore changes to them, they are generated by `npm start` as well as
Be warned! If you use `vite` directly, you may end up with analysis
errors due to their absence.
+
+## Starting for development
+
+.. because I keep forgetting!
+
+```
+export VITE_ERIGON_URL=
+npm run assets-start
+npm start
+```
diff --git a/src/Header.tsx b/src/Header.tsx
index 4867fdad..27b9916a 100644
--- a/src/Header.tsx
+++ b/src/Header.tsx
@@ -1,4 +1,4 @@
-import { faQrcode } from "@fortawesome/free-solid-svg-icons";
+import { faQrcode, faQuestionCircle } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { FC, lazy, memo, useContext, useState } from "react";
import { Link } from "react-router-dom";
@@ -6,16 +6,20 @@ import PriceBox from "./PriceBox";
import SourcifyMenu from "./SourcifyMenu";
import { useGenericSearch } from "./search/search";
import { RuntimeContext } from "./useRuntime";
+import InlineCode from "./components/InlineCode";
// @ts-expect-error
import Otter from "./otter.png?w=128&h=128&webp";
const CameraScanner = lazy(() => import("./search/CameraScanner"));
type HeaderProps = { sourcifyPresent: boolean };
+// Should really move out to utils
+
const Header: FC = ({ sourcifyPresent }) => {
const { config, provider } = useContext(RuntimeContext);
const [searchRef, handleChange, handleSubmit] = useGenericSearch();
const [isScanning, setScanning] = useState(false);
+ const [isHelpOpen, setHelpOpen] = useState(false);
return (
<>
@@ -79,6 +83,14 @@ const Header: FC = ({ sourcifyPresent }) => {
>
+
+ - A bech32 address if it is in the right format.
- An address if we can (right length, starts with 0x or zil1).
- If a 32-character hex string we'll try to search as a transaction id
- If a > 40 character hex string, we'll think it's probably an address with leading 0s.
From d45bec1d502d880dda72d32c5eb0503dc12b5416 Mon Sep 17 00:00:00 2001
From: Richard Watts
Date: Mon, 30 Sep 2024 16:12:30 +0100
Subject: [PATCH 4/5] (fix ) prettier
---
src/Header.tsx | 122 ++++++++++++++++++++++++----------
src/components/InlineCode.tsx | 5 +-
src/search/search.ts | 3 +-
3 files changed, 90 insertions(+), 40 deletions(-)
diff --git a/src/Header.tsx b/src/Header.tsx
index 732267dd..6b17c61a 100644
--- a/src/Header.tsx
+++ b/src/Header.tsx
@@ -4,9 +4,9 @@ import { FC, lazy, memo, useContext, useState } from "react";
import { Link } from "react-router-dom";
import PriceBox from "./PriceBox";
import SourcifyMenu from "./SourcifyMenu";
+import InlineCode from "./components/InlineCode";
import { useGenericSearch } from "./search/search";
import { RuntimeContext } from "./useRuntime";
-import InlineCode from "./components/InlineCode";
// @ts-expect-error
import Otter from "./otter.png?w=128&h=128&webp";
@@ -84,13 +84,13 @@ const Header: FC = ({ sourcifyPresent }) => {
setHelpOpen(true)}
- title="Help with searching"
- >
-
-
+ 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)}
+ title="Help with searching"
+ >
+
+
= ({ sourcifyPresent }) => {
- { isHelpOpen && (
-
+ {isHelpOpen && (
+
-
+
-
+
+
+
-
+
Help Information
-
-
-
-
- Search terms are interpreted as..
-
-
-
- - A bech32 address if it is in the right format.
- - An address if we can (right length, starts with 0x or zil1).
- - If a 32-character hex string we'll try to search as a transaction id
- - If a > 40 character hex string, we'll think it's probably an address with leading 0s.
- - Then we'll attempt an BigInt and try to find a block number
- - Terms starting with # are treated as a DS block number for ZQ1
- - Terms like epoch:<number> are epochs.
- - Terms like validator:<number> are validator searches.
-
- If the search term does not match any of those rules, we interpret it as an ENS name.
-
-
-
+
+
+
+ Search terms are interpreted as..
+
+
+ -
+ {" "}
+ A bech32 address if it is in the right format.
+
+ -
+ {" "}
+ An address if we can (right length, starts with{" "}
+ 0x or{" "}
+ zil1).
+
+ -
+ {" "}
+ If a 32-character hex string we'll try to search as
+ a transaction id
+
+ -
+ {" "}
+ If a > 40 character hex string, we'll think it's
+ probably an address with leading 0s.
+
+ -
+ {" "}
+ Then we'll attempt an{" "}
+ BigInt and try to find a
+ block number
+
+ -
+ {" "}
+ Terms starting with # are
+ treated as a DS block number for ZQ1
+
+ -
+ {" "}
+ Terms like{" "}
+ epoch:<number> are
+ epochs.
+
+ -
+ {" "}
+ Terms like{" "}
+
+ validator:<number>
+ {" "}
+ are validator searches.
+
+
+
+ If the search term does not match any of those rules,
+ we interpret it as an ENS name.
+
+
+
@@ -153,7 +206,6 @@ const Header: FC
= ({ sourcifyPresent }) => {
)}
-
>
);
};
diff --git a/src/components/InlineCode.tsx b/src/components/InlineCode.tsx
index 857d2cd2..9dd552b8 100644
--- a/src/components/InlineCode.tsx
+++ b/src/components/InlineCode.tsx
@@ -1,14 +1,13 @@
-import React from 'react';
+import React from "react";
type InlineCodeProps = React.PropsWithChildren<{
children: React.RectNode;
}>;
-const InlineCode: React.FC
= ({children}) => (
+const InlineCode: React.FC = ({ children }) => (
{children}
);
export default React.memo(InlineCode);
-
diff --git a/src/search/search.ts b/src/search/search.ts
index 9793b908..f8731f89 100644
--- a/src/search/search.ts
+++ b/src/search/search.ts
@@ -1,3 +1,4 @@
+import { fromBech32Address } from "@zilliqa-js/crypto";
import {
JsonRpcApiProvider,
TransactionReceiptParams,
@@ -21,7 +22,6 @@ import {
import { PAGE_SIZE } from "../params";
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(
@@ -294,7 +294,6 @@ const doSearch = async (q: string, navigate: NavigateFunction) => {
return;
}
-
// Block number?
// If the number here is very large, parseInt() will return an fp number which
// will cause errors, so ..
From 9dbf9137f37f7db7802816cb5ea8317159505652 Mon Sep 17 00:00:00 2001
From: Richard Watts
Date: Mon, 30 Sep 2024 16:14:44 +0100
Subject: [PATCH 5/5] (fix) Fix variable reference in search.ts (fix) Fix types
in InlineCode
---
src/components/InlineCode.tsx | 2 +-
src/search/search.ts | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/components/InlineCode.tsx b/src/components/InlineCode.tsx
index 9dd552b8..9eeeb1b6 100644
--- a/src/components/InlineCode.tsx
+++ b/src/components/InlineCode.tsx
@@ -1,7 +1,7 @@
import React from "react";
type InlineCodeProps = React.PropsWithChildren<{
- children: React.RectNode;
+ children: React.ReactNode;
}>;
const InlineCode: React.FC = ({ children }) => (
diff --git a/src/search/search.ts b/src/search/search.ts
index f8731f89..7253a009 100644
--- a/src/search/search.ts
+++ b/src/search/search.ts
@@ -345,7 +345,7 @@ const doSearch = async (q: string, navigate: NavigateFunction) => {
const mayBeValidator = q.substring(10);
// Validator by index
if (mayBeValidator.match(/^\d+$/)) {
- console.log(`validator: ${validator}`);
+ console.log(`search: validator: ${mayBeValidator}`);
const validatorIndex = parseInt(mayBeValidator);
navigate(`/validator/${validatorIndex}`);
return;