Skip to content

Commit

Permalink
Merge pull request #196 from bnb-chain/hotfix/1213
Browse files Browse the repository at this point in the history
fix: Fixed the bridgedTokenGroup case issue
  • Loading branch information
wenty22 authored Dec 13, 2024
2 parents 6cec12f + 4992f44 commit d8b4f23
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .release/.changeset/wild-spoons-sip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bnb-chain/canonical-bridge-widget": patch
---

Fixed the bridgedTokenGroup case issue
4 changes: 4 additions & 0 deletions packages/canonical-bridge-widget/src/core/utils/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<T, P = unknown> {
fromChainId: number;
Expand Down Expand Up @@ -274,7 +275,9 @@ export abstract class BaseAdapter<G extends object, C = unknown, T = unknown> {

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());
Expand Down

0 comments on commit d8b4f23

Please sign in to comment.