Skip to content

Commit

Permalink
fix: adapter address
Browse files Browse the repository at this point in the history
  • Loading branch information
palace22 committed May 29, 2024
1 parent f586e90 commit d76124b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
25 changes: 11 additions & 14 deletions src/common/utils/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ import { ChainType } from "../types/chain.js";
import { AdapterType } from "../types/message.js";

import { convertFromGenericAddress } from "./address.js";
import { getAdapterAddress, getFolksChain } from "./chain.js";
import { getFolksChain } from "./chain.js";

import type { FolksChainId, NetworkType } from "../types/chain.js";
import type {
FolksChainId,
GenericAddress,
NetworkType,
} from "../types/chain.js";
import type { FolksProvider } from "../types/core.js";
import type { WormholeData } from "../types/gmp.js";
import type {
Expand Down Expand Up @@ -47,6 +51,8 @@ export async function estimateReceiveGasLimit(
destFolksChainProvider: FolksProvider,
network: NetworkType,
adapters: MessageAdapters,
sourceAdapterAddress: GenericAddress,
destAdapterAddress: GenericAddress,
messageBuilderParams: MessageBuilderParams,
receiverValue = BigInt(0),
returnGasLimit = BigInt(0),
Expand All @@ -62,16 +68,7 @@ export async function estimateReceiveGasLimit(
getWormholeData(destFolksChainId).wormholeRelayer,
ChainType.EVM,
);
const wormholeDataAdapterAddress = getAdapterAddress(
destFolksChainId,
network,
adapters.adapterId,
);
const sourceWormholeDataAdapterAddress = getAdapterAddress(
sourceFolksChainId,
network,
adapters.adapterId,
);

return await estimateEVMWormholeDataGasLimit(
// eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style
destFolksChainProvider as EVMProvider,
Expand All @@ -80,8 +77,8 @@ export async function estimateReceiveGasLimit(
returnGasLimit,
sourceWormholeChainId,
wormholeRelayer,
wormholeDataAdapterAddress,
sourceWormholeDataAdapterAddress,
destAdapterAddress,
sourceAdapterAddress,
);
}
case AdapterType.WORMHOLE_CCTP: {
Expand Down
18 changes: 17 additions & 1 deletion src/xchain/modules/folks-account.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { FolksHubAccount } from "../../chains/evm/hub/modules/index.js";
import { getHubChain } from "../../chains/evm/hub/utils/chain.js";
import {
getHubChain,
getHubChainAdapterAddress,
} from "../../chains/evm/hub/utils/chain.js";
import { FolksEvmAccount } from "../../chains/evm/spoke/modules/index.js";
import { ChainType } from "../../common/types/chain.js";
import { Action } from "../../common/types/message.js";
Expand All @@ -9,6 +12,7 @@ import {
assertSpokeChainSupported,
getSignerGenericAddress,
getSpokeChain,
getSpokeChainAdapterAddress,
} from "../../common/utils/chain.js";
import {
buildMessageToSend,
Expand Down Expand Up @@ -66,12 +70,24 @@ export const prepare = {
};
const feeParams: OptionalMessageParams = {};

const sourceAdapterAddress = getSpokeChainAdapterAddress(
folksChain.folksChainId,
folksChain.network,
adapters.adapterId,
);
const destAdapterAddress = getHubChainAdapterAddress(
folksChain.network,
adapters.adapterId,
);

feeParams.gasLimit = await estimateReceiveGasLimit(
folksChain.folksChainId,
hubChain.folksChainId,
FolksCore.getHubProvider(),
folksChain.network,
adapters,
sourceAdapterAddress,
destAdapterAddress,
messageBuilderParams,
);

Expand Down

0 comments on commit d76124b

Please sign in to comment.