From b094a2408c4af4a42f3f21bc1fa428f371ceef25 Mon Sep 17 00:00:00 2001 From: mmaurello <93129175+mmaurello@users.noreply.github.com> Date: Tue, 17 Dec 2024 12:10:43 +0100 Subject: [PATCH] enable sending only remote execution in MRL (#407) --- packages/builder/src/mrl/MrlBuilder.interfaces.ts | 1 + .../wormhole/extrinsic/polkadotXcm/polkadotXcm.ts | 8 ++++++-- packages/mrl/src/getTransferData/getTransferData.ts | 2 ++ packages/mrl/src/getTransferData/getTransferData.utils.ts | 3 +++ packages/mrl/src/mrl.interfaces.ts | 1 + 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/mrl/MrlBuilder.interfaces.ts b/packages/builder/src/mrl/MrlBuilder.interfaces.ts index a3c83f3f..44392f96 100644 --- a/packages/builder/src/mrl/MrlBuilder.interfaces.ts +++ b/packages/builder/src/mrl/MrlBuilder.interfaces.ts @@ -26,6 +26,7 @@ export interface MrlBuilderParams extends BuilderParams { moonAsset: ChainAsset; moonChain: EvmParachain; moonGasLimit?: bigint; + sendOnlyRemoteExecution?: boolean; transact?: Transact; } diff --git a/packages/builder/src/mrl/providers/wormhole/extrinsic/polkadotXcm/polkadotXcm.ts b/packages/builder/src/mrl/providers/wormhole/extrinsic/polkadotXcm/polkadotXcm.ts index 7f74d5de..ac110c0e 100644 --- a/packages/builder/src/mrl/providers/wormhole/extrinsic/polkadotXcm/polkadotXcm.ts +++ b/packages/builder/src/mrl/providers/wormhole/extrinsic/polkadotXcm/polkadotXcm.ts @@ -30,6 +30,7 @@ export function polkadotXcm() { moonAsset, moonChain, moonApi, + sendOnlyRemoteExecution, source, sourceAddress, sourceApi, @@ -85,11 +86,14 @@ export function polkadotXcm() { transact, }); - // TODO add here ability to only send the remote execution (only `send`) + const transactionsToSend = sendOnlyRemoteExecution + ? [send] + : [...assetTransferTxs, send]; + return new ExtrinsicConfig({ module: 'utility', func: 'batchAll', - getArgs: () => [[...assetTransferTxs, send]], + getArgs: () => [transactionsToSend], }); }, }), diff --git a/packages/mrl/src/getTransferData/getTransferData.ts b/packages/mrl/src/getTransferData/getTransferData.ts index fb675777..d56ffcb6 100644 --- a/packages/mrl/src/getTransferData/getTransferData.ts +++ b/packages/mrl/src/getTransferData/getTransferData.ts @@ -110,6 +110,7 @@ export async function getTransferData({ isAutomatic, { evmSigner, polkadotSigner }: Partial, statusCallback, + sendOnlyRemoteExecution, ): Promise { const source = route.source.chain; @@ -130,6 +131,7 @@ export async function getTransferData({ feeAsset, isAutomatic, route, + sendOnlyRemoteExecution, sourceAddress, }); diff --git a/packages/mrl/src/getTransferData/getTransferData.utils.ts b/packages/mrl/src/getTransferData/getTransferData.utils.ts index d9223a44..e6293943 100644 --- a/packages/mrl/src/getTransferData/getTransferData.utils.ts +++ b/packages/mrl/src/getTransferData/getTransferData.utils.ts @@ -102,6 +102,7 @@ export interface BuildTransferParams { feeAsset: AssetAmount; isAutomatic: boolean; route: AssetRoute; + sendOnlyRemoteExecution?: boolean; sourceAddress: string; } @@ -133,6 +134,7 @@ export async function getMrlBuilderParams({ feeAsset, isAutomatic, route, + sendOnlyRemoteExecution, sourceAddress, }: BuildTransferParams): Promise { if (!route.mrl) { @@ -162,6 +164,7 @@ export async function getMrlBuilderParams({ moonApi, moonAsset: moonChain.nativeAsset, moonChain, + sendOnlyRemoteExecution, source, sourceAddress, sourceApi, diff --git a/packages/mrl/src/mrl.interfaces.ts b/packages/mrl/src/mrl.interfaces.ts index 441d6dfe..64564602 100644 --- a/packages/mrl/src/mrl.interfaces.ts +++ b/packages/mrl/src/mrl.interfaces.ts @@ -26,6 +26,7 @@ export interface TransferData { isAutomatic: boolean, signers: Signers, statusCallback?: (params: ISubmittableResult) => void, + sendOnlyRemoteExecution?: boolean, ): Promise; }