|
|
@ -1,8 +1,10 @@ |
|
|
|
import { useState } from 'react'; |
|
|
|
import { useQuery } from '@tanstack/react-query'; |
|
|
|
|
|
|
|
import { useCallback, useState } from 'react'; |
|
|
|
|
|
|
|
|
|
|
|
import { Fade } from '../../components/animation/Fade'; |
|
|
|
import { Fade } from '../../components/animation/Fade'; |
|
|
|
import { SearchBar } from '../../components/search/SearchBar'; |
|
|
|
import { SearchBar } from '../../components/search/SearchBar'; |
|
|
|
import { |
|
|
|
import { |
|
|
|
|
|
|
|
NoSearchError, |
|
|
|
SearchEmptyError, |
|
|
|
SearchEmptyError, |
|
|
|
SearchInvalidError, |
|
|
|
SearchInvalidError, |
|
|
|
SearchUnknownError, |
|
|
|
SearchUnknownError, |
|
|
@ -13,6 +15,8 @@ import useDebounce from '../../utils/debounce'; |
|
|
|
import { sanitizeString } from '../../utils/string'; |
|
|
|
import { sanitizeString } from '../../utils/string'; |
|
|
|
import { isValidSearchQuery } from '../search/utils'; |
|
|
|
import { isValidSearchQuery } from '../search/utils'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { debugMessageForHash } from './debugMessage'; |
|
|
|
|
|
|
|
|
|
|
|
export function TxDebugger() { |
|
|
|
export function TxDebugger() { |
|
|
|
const environment = useStore((s) => s.environment); |
|
|
|
const environment = useStore((s) => s.environment); |
|
|
|
|
|
|
|
|
|
|
@ -21,11 +25,15 @@ export function TxDebugger() { |
|
|
|
const debouncedSearchInput = useDebounce(searchInput, 750); |
|
|
|
const debouncedSearchInput = useDebounce(searchInput, 750); |
|
|
|
const hasInput = !!debouncedSearchInput; |
|
|
|
const hasInput = !!debouncedSearchInput; |
|
|
|
const sanitizedInput = sanitizeString(debouncedSearchInput); |
|
|
|
const sanitizedInput = sanitizeString(debouncedSearchInput); |
|
|
|
const isValidInput = hasInput ? isValidSearchQuery(sanitizedInput, false) : true; |
|
|
|
const isValidInput = isValidSearchQuery(sanitizedInput, false); |
|
|
|
|
|
|
|
|
|
|
|
const fetching = false; |
|
|
|
// Debugger query
|
|
|
|
const hasError = false; |
|
|
|
const query = useCallback(() => { |
|
|
|
const txResult = {}; |
|
|
|
if (!isValidInput || !sanitizedInput) return null; |
|
|
|
|
|
|
|
else return debugMessageForHash(sanitizedInput, environment); |
|
|
|
|
|
|
|
}, [isValidInput, sanitizedInput, environment]); |
|
|
|
|
|
|
|
const { isLoading: fetching, error, data } = useQuery(['debugMessage'], query); |
|
|
|
|
|
|
|
const hasError = !!error; |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<> |
|
|
|
<> |
|
|
@ -36,19 +44,19 @@ export function TxDebugger() { |
|
|
|
placeholder="Search transaction hash to debug message" |
|
|
|
placeholder="Search transaction hash to debug message" |
|
|
|
/> |
|
|
|
/> |
|
|
|
<div className="w-full h-[38.05rem] mt-5 bg-white shadow-md border border-blue-50 rounded overflow-auto relative"> |
|
|
|
<div className="w-full h-[38.05rem] mt-5 bg-white shadow-md border border-blue-50 rounded overflow-auto relative"> |
|
|
|
{/* Content header and filter bar */} |
|
|
|
|
|
|
|
<div className="px-2 py-3 sm:px-4 md:px-5 md:py-3 flex items-center justify-between border-b border-gray-100"> |
|
|
|
<div className="px-2 py-3 sm:px-4 md:px-5 md:py-3 flex items-center justify-between border-b border-gray-100"> |
|
|
|
<h2 className="text-gray-600">{`Transaction Debugger (${envDisplayValue[environment]})`}</h2> |
|
|
|
<h2 className="text-gray-600">{`Transaction Debugger (${envDisplayValue[environment]})`}</h2> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
{/* Message list */} |
|
|
|
|
|
|
|
<Fade show={!hasError && isValidInput && !!txResult}>{JSON.stringify(txResult)}</Fade> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<SearchInvalidError show={!isValidInput} /> |
|
|
|
<Fade show={isValidInput && !hasError && !!data}>{JSON.stringify(data)}</Fade> |
|
|
|
<SearchUnknownError show={isValidInput && hasError} /> |
|
|
|
|
|
|
|
<SearchEmptyError |
|
|
|
<SearchEmptyError |
|
|
|
show={isValidInput && !hasError && !fetching && !txResult} |
|
|
|
show={isValidInput && !hasError && !fetching && !data} |
|
|
|
hasInput={hasInput} |
|
|
|
hasInput={hasInput} |
|
|
|
|
|
|
|
allowAddress={false} |
|
|
|
/> |
|
|
|
/> |
|
|
|
|
|
|
|
<NoSearchError show={!hasInput && !hasError} /> |
|
|
|
|
|
|
|
<SearchInvalidError show={hasInput && !hasError && !isValidInput} allowAddress={false} /> |
|
|
|
|
|
|
|
<SearchUnknownError show={hasInput && hasError} /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</> |
|
|
|
</> |
|
|
|
); |
|
|
|
); |
|
|
|