Skip to content

Commit

Permalink
chore: minor code cleanup(#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
dima-safin-2025 authored Jul 28, 2024
1 parent ae52d64 commit a50ebea
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 17 deletions.
14 changes: 5 additions & 9 deletions src/features/messages/queries/useMessageQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ import { isAddressEvm, isValidTransactionHashEvm } from '@hyperlane-xyz/utils';
import { useMultiProvider } from '../../../store';
import { MessageStatus } from '../../../types';
import { useInterval } from '../../../utils/useInterval';
import {
MessageIdentifierType,
buildMessageQuery,
buildMessageSearchQuery,
} from '../queries/build';
import { MessagesQueryResult, MessagesStubQueryResult } from '../queries/fragments';
import { parseMessageQueryResult, parseMessageStubResult } from '../queries/parse';

import { MessageIdentifierType, buildMessageQuery, buildMessageSearchQuery } from './build';
import { MessagesQueryResult, MessagesStubQueryResult } from './fragments';
import { parseMessageQueryResult, parseMessageStubResult } from './parse';

const SEARCH_AUTO_REFRESH_DELAY = 15_000; // 15s
const MSG_AUTO_REFRESH_DELAY = 10_000; // 10s
Expand All @@ -22,8 +19,7 @@ const SEARCH_QUERY_LIMIT = 50;
export function isValidSearchQuery(input: string, allowAddress?: boolean) {
if (!input) return false;
if (isValidTransactionHashEvm(input)) return true;
if (allowAddress && isAddressEvm(input)) return true;
return false;
return !!(allowAddress && isAddressEvm(input));
}

export function useMessageSearchQuery(
Expand Down
3 changes: 1 addition & 2 deletions src/utils/clipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ export async function tryClipboardSet(value: string) {
export async function tryClipboardGet() {
try {
// Note: doesn't work in firefox, which only allows extensions to read clipboard
const value = await navigator.clipboard.readText();
return value;
return await navigator.clipboard.readText();
} catch (error) {
logger.error('Failed to read from clipboard', error);
return null;
Expand Down
3 changes: 1 addition & 2 deletions src/utils/explorers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ async function queryExplorer<P>(
}

logger.debug('Querying explorer url:', url.toString());
const result = await executeQuery<P>(url);
return result;
return await executeQuery<P>(url);
}

async function executeQuery<P>(url: URL) {
Expand Down
3 changes: 1 addition & 2 deletions src/utils/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ export function tryUtf8DecodeBytes(value: string, fatal = true) {
if (!value) return undefined;
try {
const decoder = new TextDecoder('utf-8', { fatal });
const decodedBody = decoder.decode(Buffer.from(strip0x(value), 'hex'));
return decodedBody;
return decoder.decode(Buffer.from(strip0x(value), 'hex'));
} catch (error) {
return undefined;
}
Expand Down
3 changes: 1 addition & 2 deletions src/utils/useInterval.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useEffect, useRef } from 'react';
import { useLayoutEffect } from 'react';
import { useEffect, useLayoutEffect, useRef } from 'react';

const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;

Expand Down

0 comments on commit a50ebea

Please sign in to comment.