Skip to content

Commit

Permalink
fix: send token action msg direction (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
palace22 authored Jan 7, 2025
1 parent 818ef7a commit 9857f09
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/tricky-doors-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@folks-finance/xchain-sdk": patch
---

Fixed SendToken action message direction
7 changes: 5 additions & 2 deletions src/xchain/modules/folks-gmp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { FolksEvmGmp } from "../../chains/evm/spoke/modules/index.js";
import { getBridgeRouterSpokeContract } from "../../chains/evm/spoke/utils/contract.js";
import { ChainType } from "../../common/types/chain.js";
import { MessageDirection } from "../../common/types/gmp.js";
import { Action } from "../../common/types/message.js";
import {
assertAdapterSupportsCrossChainToken,
assertAdapterSupportsDataMessage,
Expand Down Expand Up @@ -57,6 +58,8 @@ export const prepare = {
) {
const folksChain = FolksCore.getSelectedFolksChain();
const payload = decodeMessagePayload(message.payload);
const messageDirection =
isHub || payload.action === Action.SendToken ? MessageDirection.HubToSpoke : MessageDirection.SpokeToHub;

const userAddress = getSignerGenericAddress({
signer: FolksCore.getFolksSigner().signer,
Expand All @@ -65,7 +68,7 @@ export const prepare = {

if (isHub) {
assertHubChainSelected(folksChain.folksChainId, folksChain.network);
assertRetryableAction(payload.action, MessageDirection.HubToSpoke);
assertRetryableAction(payload.action, messageDirection);

const hubChain = getHubChain(folksChain.network);
const provider = FolksCore.getProvider<ChainType.EVM>(folksChain.folksChainId);
Expand Down Expand Up @@ -94,7 +97,7 @@ export const prepare = {
getHubChain(folksChain.network),
);
} else {
assertRetryableAction(payload.action, MessageDirection.SpokeToHub);
assertRetryableAction(payload.action, messageDirection);

switch (folksChain.chainType) {
case ChainType.EVM: {
Expand Down

0 comments on commit 9857f09

Please sign in to comment.