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
1823class BaseError extends Error {
1924 constructor ( message : string ) {
20- super ( message )
21- this . name = "BaseError"
25+ super ( message ) ;
26+ this . name = "BaseError" ;
2227 }
2328}
2429
2530class 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-
3337enum TxStateType {
3438 NotLoaded ,
3539 Loading ,
3640 Success ,
37- Error
41+ Error ,
3842}
3943
4044const 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
4957export 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 ) }
0 commit comments