From 48116954c3c2c3ccb23afff470f8e9d7360e4077 Mon Sep 17 00:00:00 2001 From: Daniel Isaac Geslin Date: Tue, 13 Aug 2024 10:05:20 +0200 Subject: [PATCH 1/2] Update query parameters so that it is no longer case-sensitive --- apps/connect/src/hooks/useFormatAssetParam.test.ts | 2 +- apps/connect/src/hooks/useFormatAssetParam.ts | 7 +++++-- apps/connect/src/hooks/useQueryParams.ts | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/connect/src/hooks/useFormatAssetParam.test.ts b/apps/connect/src/hooks/useFormatAssetParam.test.ts index 72b179ab7..2526e2ca2 100644 --- a/apps/connect/src/hooks/useFormatAssetParam.test.ts +++ b/apps/connect/src/hooks/useFormatAssetParam.test.ts @@ -9,7 +9,7 @@ describe("useFormatAssetParam", () => { it("should NOT get a formatted asset when key does NOT have an exact match", () => { const { result } = renderHook(() => useFormatAssetParam("eth")); - expect(result.current).toEqual(null); + expect(result.current).toEqual('ETH'); }); it("should get a formatted asset using an address", () => { diff --git a/apps/connect/src/hooks/useFormatAssetParam.ts b/apps/connect/src/hooks/useFormatAssetParam.ts index 976f58024..bb05cd882 100644 --- a/apps/connect/src/hooks/useFormatAssetParam.ts +++ b/apps/connect/src/hooks/useFormatAssetParam.ts @@ -10,8 +10,11 @@ function getFormatedAsset(asset: string | null): string | null { ...ENV.wormholeConnectConfig?.tokensConfig, }; if (allTokens && asset) { - const tokenParam = Object.values(allTokens).find( - (config) => config?.tokenId?.address === asset || config?.key === asset + const tokenParam = Object.values(allTokens).find((config) => + [ + config?.tokenId?.address?.toLowerCase?.(), + config?.key?.toLowerCase?.(), + ].includes(asset.toLowerCase()) ); if (tokenParam) { return tokenParam.key; diff --git a/apps/connect/src/hooks/useQueryParams.ts b/apps/connect/src/hooks/useQueryParams.ts index fa6b9f096..b25425000 100644 --- a/apps/connect/src/hooks/useQueryParams.ts +++ b/apps/connect/src/hooks/useQueryParams.ts @@ -6,7 +6,7 @@ const getChainValue = ( query: URLSearchParams, key: string ): ChainName | null => { - const sourceChain = query.get(key); + const sourceChain = query.get(key)?.toLowerCase?.(); if (sourceChain) { if (isChain(sourceChain)) { return coalesceChainName(sourceChain) as ChainName; From e7e113997dc44702da7918fd14937f94122b75cb Mon Sep 17 00:00:00 2001 From: Daniel Isaac Geslin Date: Tue, 13 Aug 2024 10:08:43 +0200 Subject: [PATCH 2/2] prettier --- apps/connect/src/hooks/useFormatAssetParam.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/connect/src/hooks/useFormatAssetParam.test.ts b/apps/connect/src/hooks/useFormatAssetParam.test.ts index 2526e2ca2..a845b50e8 100644 --- a/apps/connect/src/hooks/useFormatAssetParam.test.ts +++ b/apps/connect/src/hooks/useFormatAssetParam.test.ts @@ -9,7 +9,7 @@ describe("useFormatAssetParam", () => { it("should NOT get a formatted asset when key does NOT have an exact match", () => { const { result } = renderHook(() => useFormatAssetParam("eth")); - expect(result.current).toEqual('ETH'); + expect(result.current).toEqual("ETH"); }); it("should get a formatted asset using an address", () => {