Skip to content

Commit

Permalink
Fix teleport xcm types (#354)
Browse files Browse the repository at this point in the history
Fix for failed teleport in Rococo faucet bot 

![image](https://github.com/paritytech/polkadot-testnet-faucet/assets/1177472/363b0e21-d431-43f4-8221-cbf9e8b2e0d1)


I couldn't find any release notes regarding this change :(

just went to
https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frococo-rpc.polkadot.io#/extrinsics
and looked up the xcmPallet.limitedTeleportAssets method, where i saw
expected types, which helped to migrate

the only difference is that all networks (westend, polkadot, kusama)
except Rococo use similar types but without "Staging" prefix
Weird, but okay... if/when any other network also starts using Staging -
it'd be easy to fix by adding them to condition.. still wondering how
would I learn about this change in front
  • Loading branch information
mordamax authored Oct 19, 2023
1 parent 0cc808d commit 47ece98
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 47ece98

Please sign in to comment.