Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixed the bridgedTokenGroup case issue #196

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading