Skip to content

Commit

Permalink
portal-bridge-ui-issues#47 - fix prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianscatularo committed Feb 20, 2024
1 parent d51d5d1 commit 1bbfa95
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions apps/connect/src/hooks/useQueryParams.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { ChainName, coalesceChainName, isChain } from '@certusone/wormhole-sdk';
import { ChainName, coalesceChainName, isChain } from "@certusone/wormhole-sdk";
import { useMemo } from "react";

const isNumber = (str: string) => typeof str === 'string' && str.length > 0 && !isNaN(Number(str))
const isNumber = (str: string) =>
typeof str === "string" && str.length > 0 && !isNaN(Number(str));

function getChainValue(query: URLSearchParams, key: string): ChainName | null{
function getChainValue(query: URLSearchParams, key: string): ChainName | null {
const sourceChain = query.get(key);
if (sourceChain && isChain(sourceChain)) {
return coalesceChainName(sourceChain);
Expand All @@ -18,7 +19,7 @@ function getChainValue(query: URLSearchParams, key: string): ChainName | null{

function getTxHash(query: URLSearchParams): string | null {
const txHash = query.get("txHash");
const transactionId = query.get("transactionId");
const transactionId = query.get("transactionId");
if (txHash) {
return txHash;
} else if (transactionId) {
Expand All @@ -29,8 +30,14 @@ function getTxHash(query: URLSearchParams): string | null {

export function useQueryParams() {
const query = useMemo(() => new URLSearchParams(window.location.search), []);
const sourceChain = useMemo(() => getChainValue(query, "sourceChain"), [query]);
const targetChain = useMemo(() => getChainValue(query, "targetChain"), [query]);
const sourceChain = useMemo(
() => getChainValue(query, "sourceChain"),
[query]
);
const targetChain = useMemo(
() => getChainValue(query, "targetChain"),
[query]
);
const txHash = useMemo(() => getTxHash(query), [query]);
return {
txHash,
Expand Down

0 comments on commit 1bbfa95

Please sign in to comment.