Skip to content

Commit

Permalink
fix: cross chain token adapter check (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
palace22 authored Nov 5, 2024
1 parent 78cc55a commit decfce7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/friendly-swans-act.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@folks-finance/xchain-sdk": patch
---

Fixed check on cross chain token adapter when the chain is the hub
9 changes: 6 additions & 3 deletions src/common/utils/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,19 @@ export function assertAdapterSupportsTokenMessage(folksChainId: FolksChainId, ad

export function doesAdapterSupportCrossChainToken(
crossChainToken: CrossChainTokenType,
folksChainId: FolksChainId,
adapterId: AdapterType,
): boolean {
return crossChainToken.adapters.includes(adapterId);
const isHub = isHubChain(folksChainId, FolksCore.getSelectedNetwork());
return (isHub && adapterId === AdapterType.HUB) || (!isHub && crossChainToken.adapters.includes(adapterId));
}

export function assertCrossChainTokenSupportedByAdapter(
crossChainToken: CrossChainTokenType,
folksChainId: FolksChainId,
adapterId: AdapterType,
): void {
if (!doesAdapterSupportCrossChainToken(crossChainToken, adapterId))
if (!doesAdapterSupportCrossChainToken(crossChainToken, folksChainId, adapterId))
throw Error(`Adapter ${adapterId} does not support cross chain token: ${crossChainToken.address}`);
}

Expand All @@ -57,7 +60,7 @@ export function assertAdapterSupportsCrossChainToken(
adapterId: AdapterType,
): void {
assertAdapterSupportsTokenMessage(folksChainId, adapterId);
assertCrossChainTokenSupportedByAdapter(crossChainToken, adapterId);
assertCrossChainTokenSupportedByAdapter(crossChainToken, folksChainId, adapterId);
}

export function doesAdapterSupportReceiverValue(folksChainId: FolksChainId, adapterId: AdapterType): boolean {
Expand Down

0 comments on commit decfce7

Please sign in to comment.