Skip to content

Commit

Permalink
Merge branch 'v3-next' of github.com:moonbeam-foundation/xcm-sdk into…
Browse files Browse the repository at this point in the history
… v3-docs
  • Loading branch information
mmaurello committed Jan 8, 2025
2 parents dd5a508 + b59227d commit 66ac895
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions examples/mrl-simple/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ async function main() {
const isAutomatic = false;

/**
* Set the tx hash to be redeemed if the transaction is not automatic
* Set the tx hash to be executed if the transaction is not automatic
*/
const txHashToBeRedeemed: string | undefined = undefined;
const txHashToBeExecuted: string | undefined = undefined;

if (txHashToBeRedeemed) {
await redeemInEvm(txHashToBeRedeemed, destination);
if (txHashToBeExecuted) {
await executeInEvm(txHashToBeExecuted, destination);
} else if (EvmChain.is(source)) {
await fromEvmChain(source, destination, asset, isAutomatic);
} else if (Parachain.is(source)) {
Expand Down Expand Up @@ -139,17 +139,17 @@ async function fromEvmChain(
transport: http(),
});

console.log('\nWaiting 30 seconds for tx to be confirmed before redeeming');
console.log('\nWaiting 30 seconds for tx to be confirmed before executing');
await new Promise((resolve) => setTimeout(resolve, 30000));

console.log(`Redeeming tx ${hash} in ${transferData.moonChain.chain.name}`);

const redeemData = await Mrl().getRedeemData({
const executeTransferData = await Mrl().getExecuteTransferData({
txId: hash,
chain: transferData.moonChain.chain,
});

await redeemData.redeem(redeemChainWalletClient);
await executeTransferData.executeTransfer(redeemChainWalletClient);
} else {
console.log(
`\nRedeeming will happen automatically for this tx ${hash} in ${transferData.moonChain.chain.name}`,
Expand Down Expand Up @@ -203,24 +203,24 @@ async function fromParachain(
`\nYou will have to manually complete the transaction in ${transferData.destination.chain.name} once the transaction is confirmed`,
);
console.log(
'This sdk does not yet return the tx hash that needs to be redeemed, so you will have to look it up in the explorer and paste it in the redeemInEvm function',
'This sdk does not yet return the tx hash that needs to be executed, so you will have to look it up in the explorer and paste it in the executeInEvm function',
);
}
}

async function redeemInEvm(txHashToBeRedeemed: string, destination: EvmChain) {
async function executeInEvm(txHashToBeExecuted: string, destination: EvmChain) {
const walletClient = createWalletClient({
account,
chain: destination.getViemChain(),
transport: http(),
});

const data = await Mrl().getRedeemData({
txId: txHashToBeRedeemed,
const data = await Mrl().getExecuteTransferData({
txId: txHashToBeExecuted,
chain: fantomTestnet,
});

console.log(`Redeeming tx ${txHashToBeRedeemed} in ${destination.name}`);
console.log(`Executing tx ${txHashToBeExecuted} in ${destination.name}`);

await data.redeem(walletClient as EvmSigner);
await data.executeTransfer(walletClient as EvmSigner);
}

0 comments on commit 66ac895

Please sign in to comment.