Skip to content

Commit

Permalink
added reserve asset transfer script
Browse files Browse the repository at this point in the history
  • Loading branch information
x3c41a committed Dec 23, 2024
1 parent 83b7509 commit 94d7802
Showing 1 changed file with 97 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -387,3 +387,100 @@ test("Initiate Teleport with remote fees", async () => {
const r = await ahToWnd.signAndSubmit(aliceSigner);
expect(r).toBeTruthy();
})

test("Withdraw USDT from Alice to Bob", async () => {

const msg = Enum('V5', [
XcmV4Instruction.WithdrawAsset([
{
id: {
parents: 1,
interior: XcmV3Junctions.Here(),
},
fun: XcmV3MultiassetFungibility.Fungible(3_000_000_000_000n),
},
]),
Enum('PayFees', {
asset: {
id: {
parents: 1,
interior: XcmV3Junctions.Here(),
},
fun: XcmV3MultiassetFungibility.Fungible(1_000_000_000_000n),
}
}),
XcmV4Instruction.TransferReserveAsset({
assets: [
{
id: {
parents: 0,
interior: XcmV3Junctions.X2([
XcmV3Junction.PalletInstance(50),
XcmV3Junction.GeneralIndex(1984n)]),
},
fun: XcmV3MultiassetFungibility.Fungible(100_000_000n),
},
{
id: {
parents: 1,
interior: XcmV3Junctions.Here(),
},
fun: XcmV3MultiassetFungibility.Fungible(2_000_000_000_000n),
},
],
dest: {
parents: 1,
interior: XcmV3Junctions.X1(
XcmV3Junction.Parachain(2042),
),
},
xcm: [
Enum('PayFees', {
asset: {
id: {
parents: 1,
interior: XcmV3Junctions.Here(),
},
fun: XcmV3MultiassetFungibility.Fungible(1_000_000_000_000n),
}
}),
XcmV4Instruction.DepositAsset({
assets: XcmV3MultiassetMultiAssetFilter.Wild({
type: 'All',
value: undefined,
}),
// granular version
// assets: XcmV4AssetAssetFilter.Definite([{
// id: {
// parents: 1,
// // interior: XcmV3Junctions.Here(),
// interior: XcmV3Junctions.X3([
// XcmV3Junction.Parachain(1000),
// XcmV3Junction.PalletInstance(50),
// XcmV3Junction.GeneralIndex(1984n)]),
// },
// // fun: XcmV3MultiassetFungibility.Fungible(1_000_000_000_000n),
// fun: XcmV3MultiassetFungibility.Fungible(100_000_000n),
// }]),
beneficiary: {
parents: 0,
interior: XcmV3Junctions.X1(XcmV3Junction.AccountId32({
network: undefined,
id: Binary.fromBytes(hdkdKeyPairAlice.publicKey),
})),
},
}),
],
}),
]);


const ahToWnd = AHApi.tx.PolkadotXcm.execute({
message: msg,
// max_weight: { ref_time: weight.value.ref_time, proof_size: weight.value.proof_size },
max_weight: { ref_time: 81834380000n, proof_size: 823193n },
},
);
const r = await ahToWnd.signAndSubmit(aliceSigner);
expect(r).toBeTruthy();
})

0 comments on commit 94d7802

Please sign in to comment.