Skip to content

Commit

Permalink
Fix teleport xcm types
Browse files Browse the repository at this point in the history
  • Loading branch information
mordamax committed Oct 18, 2023
1 parent 0cc808d commit d007b14
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions src/dripper/polkadot/PolkadotActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,41 +98,46 @@ export class PolkadotActions {
async teleportTokens(dripAmount: bigint, address: string, parachain_id: string): Promise<DripResponse> {
logger.info("💸 teleporting tokens");

const dest = polkadotApi.createType("XcmVersionedMultiLocation", {
V3: polkadotApi.createType("MultiLocationV2", {
interior: polkadotApi.createType("JunctionsV2", {
X1: polkadotApi.createType("JunctionV2", { Parachain: polkadotApi.createType("Compact<u32>", parachain_id) }),
const prefix = networkName === "rococo" ? "Staging" : "";

const dest = polkadotApi.createType(`${prefix}XcmVersionedMultiLocation`, {
V3: polkadotApi.createType(`${prefix}XcmV3MultiLocation`, {
interior: polkadotApi.createType(`${prefix}XcmV3Junctions`, {
X1: polkadotApi.createType(`${prefix}XcmV3Junction`, {
Parachain: polkadotApi.createType("Compact<u32>", parachain_id),
}),
}),
parents: 0,
}),
});

const beneficiary = polkadotApi.createType("XcmVersionedMultiLocation", {
V3: polkadotApi.createType("MultiLocationV2", {
interior: polkadotApi.createType("JunctionsV2", {
X1: polkadotApi.createType("JunctionV2", {
AccountId32: { id: address, network: polkadotApi.createType("NetworkId", "Any") },
const addressHex = polkadotApi.registry.createType("AccountId", address).toHex();
const beneficiary = polkadotApi.createType(`${prefix}XcmVersionedMultiLocation`, {
V3: polkadotApi.createType(`${prefix}XcmV3MultiLocation`, {
interior: polkadotApi.createType(`${prefix}XcmV3Junctions`, {
X1: polkadotApi.createType(`${prefix}XcmV3Junction`, {
AccountId32: { id: addressHex, network: polkadotApi.createType(`${prefix}XcmV3JunctionNetworkId`) },
}),
}),
parents: 0,
}),
});

const assets = polkadotApi.createType("XcmVersionedMultiAssets", {
const assets = polkadotApi.createType(`${prefix}XcmVersionedMultiAssets`, {
V3: [
polkadotApi.createType("XcmV2MultiAsset", {
fun: polkadotApi.createType("FungibilityV2", { Fungible: dripAmount }),
id: polkadotApi.createType("XcmAssetId", {
Concrete: polkadotApi.createType("MultiLocationV2", {
interior: polkadotApi.createType("JunctionsV2", "Here"),
polkadotApi.createType(`${prefix}XcmV3MultiAsset`, {
fun: polkadotApi.createType(`${prefix}XcmV3MultiassetFungibility`, { Fungible: dripAmount }),
id: polkadotApi.createType(`${prefix}XcmV3MultiassetAssetId`, {
Concrete: polkadotApi.createType(`${prefix}XcmV3MultiLocation`, {
interior: polkadotApi.createType(`${prefix}XcmV3Junctions`, "Here"),
parents: 0,
}),
}),
}),
],
});

const weightLimit = polkadotApi.createType("XcmV3WeightLimit", { Unlimited: null });
const weightLimit = polkadotApi.createType(`${prefix}XcmV3WeightLimit`, { Unlimited: null });

const feeAssetItem = 0;

Expand Down

0 comments on commit d007b14

Please sign in to comment.