Skip to content

Commit 4452b90

Browse files
committed
update
1 parent 0f0b91f commit 4452b90

File tree

9 files changed

+459
-493
lines changed

9 files changed

+459
-493
lines changed

apps/entropy-debug/components.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"$schema": "https://ui.shadcn.com/schema.json",
3+
"style": "default",
4+
"rsc": true,
5+
"tsx": true,
6+
"tailwind": {
7+
"config": "tailwind.config.ts",
8+
"css": "src/app/globals.css",
9+
"baseColor": "neutral",
10+
"cssVariables": true,
11+
"prefix": ""
12+
},
13+
"aliases": {
14+
"components": "@/components",
15+
"utils": "@/lib/utils",
16+
"ui": "@/components/ui",
17+
"lib": "@/lib",
18+
"hooks": "@/hooks"
19+
},
20+
"iconLibrary": "lucide"
21+
}

apps/entropy-debug/next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/// <reference types="next/image-types/global" />
33

44
// NOTE: This file should not be edited
5-
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
5+
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

apps/entropy-debug/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
"access": "public"
1313
},
1414
"scripts": {
15-
"dev": "next dev",
15+
"dev": "next dev --port 3005",
1616
"build": "next build",
17-
"start": "next start",
17+
"start": "next start --port 3005",
1818
"lint": "next lint"
1919
},
2020
"license": "Apache-2.0",
@@ -27,9 +27,9 @@
2727
"ethers": "^6.13.4",
2828
"highlight.js": "^11.10.0",
2929
"lucide-react": "^0.465.0",
30-
"next": "15.0.3",
31-
"react": "19.0.0-rc-66855b96-20241106",
32-
"react-dom": "19.0.0-rc-66855b96-20241106",
30+
"next": "catalog:",
31+
"react": "catalog:",
32+
"react-dom": "catalog:",
3333
"tailwind-merge": "^2.5.5",
3434
"tailwindcss-animate": "^1.0.7",
3535
"viem": "^2.21.53"
@@ -40,8 +40,8 @@
4040
"@cprussin/prettier-config": "catalog:",
4141
"@cprussin/tsconfig": "catalog:",
4242
"@types/node": "^20",
43-
"@types/react": "^18",
44-
"@types/react-dom": "^18",
43+
"@types/react": "catalog:",
44+
"@types/react-dom": "catalog:",
4545
"eslint": "^8",
4646
"eslint-config-next": "15.0.3",
4747
"postcss": "^8",
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/** @type {import('postcss-load-config').Config} */
2+
const config = {
3+
plugins: {
4+
tailwindcss: {},
5+
},
6+
};
7+
8+
export default config;

apps/entropy-debug/src/app/page.tsx

Lines changed: 62 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,58 @@
1-
"use client"
2-
3-
import * as React from "react"
4-
import { Switch } from "../components/ui/switch"
5-
import { Input } from "../components/ui/input"
6-
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../components/ui/select"
7-
import { useState, useMemo, useCallback, useEffect, useRef } from "react"
8-
import { EntropyDeployments } from "../store/EntropyDeployments"
9-
import { isValidTxHash } from "../lib/utils"
10-
import { requestCallback } from "../lib/revelation"
11-
import hljs from 'highlight.js/lib/core';
12-
import bash from 'highlight.js/lib/languages/bash';
13-
import 'highlight.js/styles/github-dark.css'; // You can choose different themes
1+
"use client";
2+
import * as React from "react";
3+
import { Switch } from "../components/ui/switch";
4+
import { Input } from "../components/ui/input";
5+
import {
6+
Select,
7+
SelectContent,
8+
SelectItem,
9+
SelectTrigger,
10+
SelectValue,
11+
} from "../components/ui/select";
12+
import { useState, useMemo, useCallback, useEffect, useRef } from "react";
13+
import { EntropyDeployments } from "../store/EntropyDeployments";
14+
import { isValidTxHash } from "../lib/utils";
15+
import { requestCallback } from "../lib/revelation";
16+
import hljs from "highlight.js/lib/core";
17+
import bash from "highlight.js/lib/languages/bash";
18+
import "highlight.js/styles/github-dark.css"; // You can choose different themes
1419

1520
// Register the bash language
16-
hljs.registerLanguage('bash', bash);
21+
hljs.registerLanguage("bash", bash);
1722

1823
class BaseError extends Error {
1924
constructor(message: string) {
20-
super(message)
21-
this.name = "BaseError"
25+
super(message);
26+
this.name = "BaseError";
2227
}
2328
}
2429

2530
class InvalidTxHashError extends BaseError {
2631
constructor(message: string) {
27-
super(message)
28-
this.name = "InvalidTxHashError"
32+
super(message);
33+
this.name = "InvalidTxHashError";
2934
}
3035
}
3136

32-
3337
enum TxStateType {
3438
NotLoaded,
3539
Loading,
3640
Success,
37-
Error
41+
Error,
3842
}
3943

4044
const TxState = {
41-
NotLoaded: () => ({status: TxStateType.NotLoaded as const}),
42-
Loading: () => ({status: TxStateType.Loading as const}),
43-
Success: (data: string) => ({status: TxStateType.Success as const, data}),
44-
Error: (error: unknown) => ({status: TxStateType.Error as const, error}),
45-
}
46-
47-
type TxStateContext = ReturnType<typeof TxState.NotLoaded> | ReturnType<typeof TxState.Loading> | ReturnType<typeof TxState.Success> | ReturnType<typeof TxState.Error>
45+
NotLoaded: () => ({ status: TxStateType.NotLoaded as const }),
46+
Loading: () => ({ status: TxStateType.Loading as const }),
47+
Success: (data: string) => ({ status: TxStateType.Success as const, data }),
48+
Error: (error: unknown) => ({ status: TxStateType.Error as const, error }),
49+
};
50+
51+
type TxStateContext =
52+
| ReturnType<typeof TxState.NotLoaded>
53+
| ReturnType<typeof TxState.Loading>
54+
| ReturnType<typeof TxState.Success>
55+
| ReturnType<typeof TxState.Error>;
4856

4957
export default function PythEntropyDebugApp() {
5058
const [state, setState] = useState<TxStateContext>(TxState.NotLoaded());
@@ -55,7 +63,11 @@ export default function PythEntropyDebugApp() {
5563

5664
const validateTxHash = (hash: string) => {
5765
if (!isValidTxHash(hash) && hash !== "") {
58-
setError(new InvalidTxHashError("Transaction hash must be 64 hexadecimal characters"));
66+
setError(
67+
new InvalidTxHashError(
68+
"Transaction hash must be 64 hexadecimal characters"
69+
)
70+
);
5971
} else {
6072
setError(null);
6173
}
@@ -64,7 +76,10 @@ export default function PythEntropyDebugApp() {
6476

6577
const availableChains = useMemo(() => {
6678
return Object.entries(EntropyDeployments)
67-
.filter(([, deployment]) => deployment.network === (isMainnet ? "mainnet" : "testnet"))
79+
.filter(
80+
([, deployment]) =>
81+
deployment.network === (isMainnet ? "mainnet" : "testnet")
82+
)
6883
.map(([key]) => key);
6984
}, [isMainnet]);
7085

@@ -79,7 +94,7 @@ export default function PythEntropyDebugApp() {
7994
});
8095
}, [txHash, selectedChain]);
8196

82-
const Info = ({state}: {state: TxStateContext}) => {
97+
const Info = ({ state }: { state: TxStateContext }) => {
8398
const preRef = useRef<HTMLPreElement>(null);
8499

85100
useEffect(() => {
@@ -90,13 +105,15 @@ export default function PythEntropyDebugApp() {
90105

91106
switch (state.status) {
92107
case TxStateType.NotLoaded:
93-
return <div>Not loaded</div>
108+
return <div>Not loaded</div>;
94109
case TxStateType.Loading:
95-
return <div>Loading...</div>
110+
return <div>Loading...</div>;
96111
case TxStateType.Success:
97112
return (
98113
<div className="mt-4 p-4 bg-gray-100 rounded w-full max-w-3xl">
99-
<p className="mb-2">Please run the following command in your terminal:</p>
114+
<p className="mb-2">
115+
Please run the following command in your terminal:
116+
</p>
100117
<div className="relative">
101118
<pre
102119
ref={preRef}
@@ -112,15 +129,15 @@ export default function PythEntropyDebugApp() {
112129
</button>
113130
</div>
114131
</div>
115-
)
132+
);
116133
case TxStateType.Error:
117134
return (
118135
<div className="mt-4 p-4 bg-red-100 border border-red-400 rounded">
119136
<div className="text-red-600">{String(state.error)}</div>
120137
</div>
121-
)
138+
);
122139
}
123-
}
140+
};
124141

125142
return (
126143
<div className="flex flex-col items-center justify-start h-screen">
@@ -136,25 +153,30 @@ export default function PythEntropyDebugApp() {
136153
<label htmlFor="network-mode">Mainnet</label>
137154
</div>
138155
<div className="mt-4">
139-
<Select onValueChange={setSelectedChain} value={selectedChain}>
156+
<Select onValueChange={setSelectedChain} value={selectedChain}>
140157
<SelectTrigger>
141158
<SelectValue placeholder="Select Chain" />
142159
</SelectTrigger>
143160
<SelectContent>
144161
{availableChains.map((chain) => (
145162
<SelectItem key={chain} value={chain}>
146-
{chain.charAt(0).toUpperCase() + chain.slice(1).replace(/-/g, ' ')}
163+
{chain.charAt(0).toUpperCase() +
164+
chain.slice(1).replace(/-/g, " ")}
147165
</SelectItem>
148166
))}
149167
</SelectContent>
150168
</Select>
151169
</div>
152170
<div className="mt-4">
153-
<label htmlFor="tx-hash" className="mr-2">Request Transaction Hash:</label>
171+
<label htmlFor="tx-hash" className="mr-2">
172+
Request Transaction Hash:
173+
</label>
154174
<Input
155175
minLength={64}
156176
id="tx-hash"
157-
className={`border rounded p-2 w-full ${error ? 'border-red-500' : ''}`}
177+
className={`border rounded p-2 w-full ${
178+
error ? "border-red-500" : ""
179+
}`}
158180
placeholder="Enter Request Transaction Hash:"
159181
value={txHash}
160182
onChange={(e) => validateTxHash(e.target.value)}

apps/entropy-debug/src/components/ui/button.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import * as React from "react"
2-
import { Slot } from "@radix-ui/react-slot"
3-
import { cva, type VariantProps } from "class-variance-authority"
1+
import * as React from "react";
2+
import { Slot } from "@radix-ui/react-slot";
3+
import { cva, type VariantProps } from "class-variance-authority";
44

5-
import { cn } from "../../lib/utils"
5+
import { cn } from "../../lib/utils";
66

77
const buttonVariants = cva(
88
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
@@ -31,26 +31,26 @@ const buttonVariants = cva(
3131
size: "default",
3232
},
3333
}
34-
)
34+
);
3535

3636
export interface ButtonProps
3737
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
3838
VariantProps<typeof buttonVariants> {
39-
asChild?: boolean
39+
asChild?: boolean;
4040
}
4141

4242
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
4343
({ className, variant, size, asChild = false, ...props }, ref) => {
44-
const Comp = asChild ? Slot : "button"
44+
const Comp = asChild ? Slot : "button";
4545
return (
4646
<Comp
4747
className={cn(buttonVariants({ variant, size, className }))}
4848
ref={ref}
4949
{...props}
5050
/>
51-
)
51+
);
5252
}
53-
)
54-
Button.displayName = "Button"
53+
);
54+
Button.displayName = "Button";
5555

56-
export { Button, buttonVariants }
56+
export { Button, buttonVariants };

0 commit comments

Comments
 (0)