Skip to content

Commit 0e6dd71

Browse files
authored
Merge pull request #2950 from pyth-network/cprussin/entropy-explorer-feedback
feat(entropy-explorer): implement some feedback items
2 parents 2a543d4 + 488ff7c commit 0e6dd71

File tree

11 files changed

+272
-146
lines changed

11 files changed

+272
-146
lines changed

apps/entropy-explorer/src/components/Address/index.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { Link } from "@pythnetwork/component-library/Link";
33
import { useMemo } from "react";
44

55
import styles from "./index.module.scss";
6-
import { EntropyDeployments } from "../../entropy-deployments";
6+
import type { EntropyDeployment } from "../../entropy-deployments";
77
import { truncate } from "../../truncate";
88

99
type Props = {
1010
value: string;
11-
chain: keyof typeof EntropyDeployments;
11+
chain: EntropyDeployment;
1212
isAccount?: boolean | undefined;
1313
};
1414

@@ -21,11 +21,9 @@ export const Transaction = (props: Omit<Props, "isAccount">) => (
2121
);
2222

2323
const Address = ({ value, chain, isAccount }: Props) => {
24-
const { explorerTxTemplate, explorerAccountTemplate } =
25-
EntropyDeployments[chain];
2624
const explorerTemplate = isAccount
27-
? explorerAccountTemplate
28-
: explorerTxTemplate;
25+
? chain.explorerAccountTemplate
26+
: chain.explorerTxTemplate;
2927
const truncatedValue = useMemo(() => truncate(value), [value]);
3028
return (
3129
<div className={styles.address}>

apps/entropy-explorer/src/components/Home/search-controls.module.scss renamed to apps/entropy-explorer/src/components/Home/chain-tag.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@use "@pythnetwork/component-library/theme";
22

3-
.chainSelectItem {
3+
.chainTag {
44
display: grid;
55
grid-template-columns: max-content 1fr;
66
gap: theme.spacing(2);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import clsx from "clsx";
2+
import Image from "next/image";
3+
import type { ComponentProps } from "react";
4+
5+
import styles from "./chain-tag.module.scss";
6+
import type { EntropyDeployment } from "../../entropy-deployments";
7+
8+
export const ChainTag = ({
9+
chain,
10+
className,
11+
...props
12+
}: { chain: EntropyDeployment } & ComponentProps<"div">) => (
13+
<div className={clsx(styles.chainTag, className)} {...props}>
14+
<Image alt="" src={chain.icon} width={20} height={20} />
15+
{chain.name}
16+
</div>
17+
);

apps/entropy-explorer/src/components/Home/index.module.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
width: 100%;
2828

2929
@include theme.breakpoint("lg") {
30+
width: theme.spacing(80);
31+
}
32+
33+
@include theme.breakpoint("xl") {
3034
width: theme.spacing(100);
3135
}
3236
}

apps/entropy-explorer/src/components/Home/index.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
ChainSelect,
1313
StatusSelect,
1414
} from "./search-controls";
15-
import { isValidDeployment } from "../../entropy-deployments";
15+
import { parseChainSlug } from "../../entropy-deployments";
1616
import type { Args } from "../../requests";
1717
import { getRequests, ResultType } from "../../requests";
1818

@@ -94,12 +94,7 @@ const Results = async (props: Props) => {
9494
searchParams.search,
9595
searchParams.status,
9696
].join(",")}
97-
chain={
98-
searchParams.chain !== undefined &&
99-
isValidDeployment(searchParams.chain)
100-
? searchParams.chain
101-
: undefined
102-
}
97+
chain={parseChainSlug(searchParams.chain)}
10398
search={searchParams.search}
10499
currentPage={results.currentPage}
105100
now={new Date()}

apps/entropy-explorer/src/components/Home/request-drawer.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { useNumberFormatter } from "react-aria";
1313
import TimeAgo from "react-timeago";
1414

1515
import styles from "./request-drawer.module.scss";
16-
import { EntropyDeployments } from "../../entropy-deployments";
1716
import { getErrorDetails } from "../../errors";
1817
import type {
1918
Request,
@@ -25,6 +24,7 @@ import { truncate } from "../../truncate";
2524
import { Account, Transaction } from "../Address";
2625
import { Status as StatusComponent } from "../Status";
2726
import { Timestamp } from "../Timestamp";
27+
import { ChainTag } from "./chain-tag";
2828

2929
export const mkRequestDrawer = (
3030
request: Request,
@@ -97,6 +97,11 @@ const RequestDrawerBody = ({
9797
},
9898
]}
9999
rows={[
100+
{
101+
id: "chain",
102+
field: "Chain",
103+
value: <ChainTag chain={request.chain} />,
104+
},
100105
{
101106
id: "requestTimestamp",
102107
field: "Request Timestamp",
@@ -244,8 +249,7 @@ const RequestDrawerBody = ({
244249
};
245250

246251
const CallbackErrorInfo = ({ request }: { request: CallbackErrorRequest }) => {
247-
const deployment = EntropyDeployments[request.chain];
248-
const retryCommand = `cast send ${deployment.address} 'revealWithCallback(address, uint64, bytes32, bytes32)' ${request.provider} ${request.sequenceNumber.toString()} ${request.userContribution} ${request.randomNumber} -r ${deployment.rpc} --private-key <YOUR_PRIVATE_KEY>`;
252+
const retryCommand = `cast send ${request.chain.address} 'revealWithCallback(address, uint64, bytes32, bytes32)' ${request.provider} ${request.sequenceNumber.toString()} ${request.userContribution} ${request.randomNumber} -r ${request.chain.rpc} --private-key <YOUR_PRIVATE_KEY>`;
249253

250254
return (
251255
<>
@@ -268,7 +272,7 @@ const CallbackErrorInfo = ({ request }: { request: CallbackErrorRequest }) => {
268272
Help
269273
</Button>
270274
<div className={styles.failureMessage}>
271-
<CallbackFailureMessage reason={request.returnValue} />
275+
<FailureMessage reason={request.returnValue} />
272276
</div>
273277
</InfoBox>
274278
<InfoBox
@@ -288,7 +292,7 @@ const CallbackErrorInfo = ({ request }: { request: CallbackErrorRequest }) => {
288292
marginTop: "16px",
289293
}}
290294
>
291-
<CopyButton text={retryCommand}>Copy Forge Command</CopyButton>
295+
<CopyButton text={retryCommand}>Copy Cast Command</CopyButton>
292296
<Button
293297
size="sm"
294298
variant="ghost"
@@ -327,7 +331,7 @@ const RevealFailedInfo = ({ request }: { request: FailedRequest }) => (
327331
Help
328332
</Button>
329333
<div className={styles.failureMessage}>
330-
<CallbackFailureMessage reason={request.reason} />
334+
<FailureMessage reason={request.reason} />
331335
</div>
332336
</InfoBox>
333337
);
@@ -340,7 +344,7 @@ const getHelpLink = (reason: string) => {
340344
);
341345
};
342346

343-
const CallbackFailureMessage = ({ reason }: { reason: string }) => {
347+
const FailureMessage = ({ reason }: { reason: string }) => {
344348
const details = getErrorDetails(reason);
345349
return details ? (
346350
<>
@@ -350,6 +354,8 @@ const CallbackFailureMessage = ({ reason }: { reason: string }) => {
350354
</p>
351355
</>
352356
) : (
353-
reason
357+
<>
358+
<b>Error response:</b> {reason}
359+
</>
354360
);
355361
};

apps/entropy-explorer/src/components/Home/results.module.scss

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@
2222

2323
.chain {
2424
@include theme.text("sm", "medium");
25-
26-
display: flex;
27-
flex-flow: row nowrap;
28-
gap: theme.spacing(2);
29-
align-items: center;
3025
}
3126

3227
.timestamp {

apps/entropy-explorer/src/components/Home/results.tsx

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ import { NoResults as NoResultsImpl } from "@pythnetwork/component-library/NoRes
55
import type { RowConfig } from "@pythnetwork/component-library/Table";
66
import { Table } from "@pythnetwork/component-library/Table";
77
import { useDrawer } from "@pythnetwork/component-library/useDrawer";
8-
import Image from "next/image";
98
import type { ComponentProps } from "react";
109
import { useMemo } from "react";
1110

11+
import { ChainTag } from "./chain-tag";
1212
import { mkRequestDrawer } from "./request-drawer";
1313
import styles from "./results.module.scss";
14+
import type { ChainSlug } from "../../entropy-deployments";
1415
import { EntropyDeployments } from "../../entropy-deployments";
1516
import type { Request } from "../../requests";
1617
import { Status } from "../../requests";
@@ -24,7 +25,7 @@ type Props = {
2425
search?: string | undefined;
2526
isUpdating?: boolean | undefined;
2627
now: Date;
27-
chain?: keyof typeof EntropyDeployments | undefined;
28+
chain: ChainSlug;
2829
};
2930

3031
export const Results = ({
@@ -44,7 +45,7 @@ export const Results = ({
4445
drawer.open(mkRequestDrawer(request, now));
4546
},
4647
data: {
47-
chain: <Chain chain={request.chain} />,
48+
chain: <ChainTag className={styles.chain} chain={request.chain} />,
4849
timestamp: (
4950
<div className={styles.timestamp}>
5051
<Timestamp timestamp={request.requestTimestamp} now={now} />
@@ -86,7 +87,7 @@ type ResultsImplProps =
8687
}
8788
| {
8889
isLoading?: false | undefined;
89-
chain?: keyof typeof EntropyDeployments | undefined;
90+
chain: ChainSlug;
9091
rows: (RowConfig<(typeof defaultProps)["columns"][number]["id"]> & {
9192
textValue: string;
9293
})[];
@@ -132,7 +133,7 @@ const ResultsImpl = (props: ResultsImplProps) => (
132133

133134
type NoResultsProps = {
134135
search?: string | undefined;
135-
chain?: keyof typeof EntropyDeployments | undefined;
136+
chain: ChainSlug;
136137
};
137138

138139
const NoResults = ({ search, chain }: NoResultsProps) => {
@@ -143,7 +144,7 @@ const NoResults = ({ search, chain }: NoResultsProps) => {
143144
<>
144145
<p>
145146
We couldn{"'"}t find any results for your query on{" "}
146-
{chain ? EntropyDeployments[chain].name : "any chain"}.
147+
<ChainName chain={chain} />
147148
</p>
148149
<p>Would you like to try your search on a different chain?</p>
149150
<ChainSelect
@@ -159,14 +160,18 @@ const NoResults = ({ search, chain }: NoResultsProps) => {
159160
);
160161
};
161162

162-
const Chain = ({ chain }: { chain: keyof typeof EntropyDeployments }) => {
163-
const chainInfo = EntropyDeployments[chain];
164-
return (
165-
<div className={styles.chain}>
166-
<Image alt="" src={chainInfo.icon} width={20} height={20} />
167-
{chainInfo.name}
168-
</div>
169-
);
163+
const ChainName = ({ chain }: { chain: ChainSlug }) => {
164+
switch (chain) {
165+
case "all-mainnet": {
166+
return "any mainnet chain";
167+
}
168+
case "all-testnet": {
169+
return "any testnet chain";
170+
}
171+
default: {
172+
return EntropyDeployments[chain].name;
173+
}
174+
}
170175
};
171176

172177
const defaultProps = {
@@ -185,6 +190,7 @@ const defaultProps = {
185190
name: "SEQUENCE NUMBER",
186191
alignment: "center",
187192
width: 20,
193+
isRowHeader: true,
188194
},
189195
{
190196
id: "timestamp" as const,

0 commit comments

Comments
 (0)