From 4992f4479bc17742cd9e25954ee6ba300aefd783 Mon Sep 17 00:00:00 2001 From: wenty22 Date: Fri, 13 Dec 2024 15:11:12 +0800 Subject: [PATCH] fix: Fixed the bridgedTokenGroup case issue --- .release/.changeset/wild-spoons-sip.md | 5 +++++ packages/canonical-bridge-widget/src/core/utils/string.ts | 4 ++++ .../src/modules/aggregator/shared/BaseAdapter.ts | 5 ++++- 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 .release/.changeset/wild-spoons-sip.md diff --git a/.release/.changeset/wild-spoons-sip.md b/.release/.changeset/wild-spoons-sip.md new file mode 100644 index 00000000..9df0d48a --- /dev/null +++ b/.release/.changeset/wild-spoons-sip.md @@ -0,0 +1,5 @@ +--- +"@bnb-chain/canonical-bridge-widget": patch +--- + +Fixed the bridgedTokenGroup case issue diff --git a/packages/canonical-bridge-widget/src/core/utils/string.ts b/packages/canonical-bridge-widget/src/core/utils/string.ts index ad4d98ac..78c9278a 100644 --- a/packages/canonical-bridge-widget/src/core/utils/string.ts +++ b/packages/canonical-bridge-widget/src/core/utils/string.ts @@ -49,3 +49,7 @@ export function utf8ToHex(utf8Str: any) { .map((char: any) => char.charCodeAt(0).toString(16).padStart(2, '0')) .join(''); } + +export function includesIgnoreCase(strArr: string[], target: string) { + return !!strArr?.find((e) => e.toUpperCase() === target?.toUpperCase()); +} diff --git a/packages/canonical-bridge-widget/src/modules/aggregator/shared/BaseAdapter.ts b/packages/canonical-bridge-widget/src/modules/aggregator/shared/BaseAdapter.ts index 4dd25425..23c4c3e8 100644 --- a/packages/canonical-bridge-widget/src/modules/aggregator/shared/BaseAdapter.ts +++ b/packages/canonical-bridge-widget/src/modules/aggregator/shared/BaseAdapter.ts @@ -3,6 +3,7 @@ import { BridgeType } from '@bnb-chain/canonical-bridge-sdk'; import { IBridgeTokenBaseInfo, IExternalChain, INativeCurrency } from '@/modules/aggregator/types'; import { isSameAddress } from '@/core/utils/address'; +import { includesIgnoreCase } from '@/core/utils/string'; export interface ITransferTokenPair { fromChainId: number; @@ -274,7 +275,9 @@ export abstract class BaseAdapter { let toToken = tokenMap?.get(fromTokenSymbol); if (!toToken) { - const bridgedGroup = this.bridgedTokenGroups.find((group) => group.includes(fromTokenSymbol)); + const bridgedGroup = this.bridgedTokenGroups.find((group) => + includesIgnoreCase(group, fromTokenSymbol), + ); const nextToken = bridgedGroup?.find((item) => item.toUpperCase() !== fromTokenSymbol); if (nextToken) { toToken = tokenMap?.get(nextToken?.toUpperCase());