|
|
@ -1,18 +1,13 @@ |
|
|
|
import { useCallback, useMemo } from 'react'; |
|
|
|
import { useCallback, useMemo } from 'react'; |
|
|
|
import { useQuery } from 'urql'; |
|
|
|
import { useQuery } from 'urql'; |
|
|
|
|
|
|
|
|
|
|
|
import { |
|
|
|
|
|
|
|
isAddress, |
|
|
|
|
|
|
|
isValidTransactionHashCosmos, |
|
|
|
|
|
|
|
isValidTransactionHashEvm, |
|
|
|
|
|
|
|
} from '@hyperlane-xyz/utils'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { useMultiProvider } from '../../../store'; |
|
|
|
import { useMultiProvider } from '../../../store'; |
|
|
|
import { MessageStatus } from '../../../types'; |
|
|
|
import { MessageStatus } from '../../../types'; |
|
|
|
import { useInterval } from '../../../utils/useInterval'; |
|
|
|
import { useInterval } from '../../../utils/useInterval'; |
|
|
|
import { useScrapedDomains } from '../../chains/queries/useScrapedChains'; |
|
|
|
import { useScrapedDomains } from '../../chains/queries/useScrapedChains'; |
|
|
|
|
|
|
|
|
|
|
|
import { MessageIdentifierType, buildMessageQuery, buildMessageSearchQuery } from './build'; |
|
|
|
import { MessageIdentifierType, buildMessageQuery, buildMessageSearchQuery } from './build'; |
|
|
|
|
|
|
|
import { searchValueToPostgresBytea } from './encoding'; |
|
|
|
import { MessagesQueryResult, MessagesStubQueryResult } from './fragments'; |
|
|
|
import { MessagesQueryResult, MessagesStubQueryResult } from './fragments'; |
|
|
|
import { parseMessageQueryResult, parseMessageStubResult } from './parse'; |
|
|
|
import { parseMessageQueryResult, parseMessageStubResult } from './parse'; |
|
|
|
|
|
|
|
|
|
|
@ -21,13 +16,9 @@ const MSG_AUTO_REFRESH_DELAY = 10_000; // 10s |
|
|
|
const LATEST_QUERY_LIMIT = 100; |
|
|
|
const LATEST_QUERY_LIMIT = 100; |
|
|
|
const SEARCH_QUERY_LIMIT = 50; |
|
|
|
const SEARCH_QUERY_LIMIT = 50; |
|
|
|
|
|
|
|
|
|
|
|
export function isValidSearchQuery(input: string, allowAddress?: boolean) { |
|
|
|
export function isValidSearchQuery(input: string) { |
|
|
|
if (!input) return false; |
|
|
|
if (!input) return false; |
|
|
|
return !!( |
|
|
|
return !!searchValueToPostgresBytea(input); |
|
|
|
isValidTransactionHashEvm(input) || |
|
|
|
|
|
|
|
isValidTransactionHashCosmos(input) || |
|
|
|
|
|
|
|
(allowAddress && isAddress(input)) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function useMessageSearchQuery( |
|
|
|
export function useMessageSearchQuery( |
|
|
@ -40,7 +31,7 @@ export function useMessageSearchQuery( |
|
|
|
const { scrapedDomains: scrapedChains } = useScrapedDomains(); |
|
|
|
const { scrapedDomains: scrapedChains } = useScrapedDomains(); |
|
|
|
|
|
|
|
|
|
|
|
const hasInput = !!sanitizedInput; |
|
|
|
const hasInput = !!sanitizedInput; |
|
|
|
const isValidInput = hasInput ? isValidSearchQuery(sanitizedInput, true) : true; |
|
|
|
const isValidInput = !hasInput || isValidSearchQuery(sanitizedInput); |
|
|
|
|
|
|
|
|
|
|
|
// Assemble GraphQL query
|
|
|
|
// Assemble GraphQL query
|
|
|
|
const { query, variables } = buildMessageSearchQuery( |
|
|
|
const { query, variables } = buildMessageSearchQuery( |
|
|
|