From 0984def22e920143e9cf32d38e377aa80712ee56 Mon Sep 17 00:00:00 2001 From: Mario J Maurello Date: Mon, 16 Dec 2024 13:16:47 +0100 Subject: [PATCH] enable sending only remote execution in MRL --- 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 ac80beb0..3c796b44 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; }