Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

chore: asset teleportation example clean up #818

Merged
merged 2 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions examples/xcm/asset_teleportation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { alice, Rune } from "capi"
import { signature } from "capi/patterns/signature/polkadot.ts"
import { types, XcmPallet } from "zombienet/statemine.toml/alice/@latest/mod.js"
import { chain as parachain, System } from "zombienet/statemine.toml/collator/@latest/mod.js"
import { Event } from "zombienet/statemine.toml/collator/@latest/types/cumulus_pallet_parachain_system/pallet.js"
import { RuntimeEvent } from "zombienet/statemine.toml/collator/@latest/types/statemine_runtime.js"

const {
VersionedMultiAssets,
VersionedMultiLocation,
v2: {
NetworkId,
WeightLimit,
junction: { Junction },
multilocation: { Junctions },
multiasset: { AssetId, Fungibility },
},
} = types.xcm

const aliceBalance = System.Account
.value(alice.publicKey)
.unhandle(undefined)
.access("data", "free")

console.log("Alice balance before:", await aliceBalance.run())

XcmPallet
.limitedTeleportAssets({
dest: VersionedMultiLocation.V2(Rune.rec({
parents: 0,
interior: Junctions.X1(Junction.Parachain(1000)),
})),
beneficiary: VersionedMultiLocation.V2(Rune.rec({
parents: 0,
interior: Junctions.X1(Junction.AccountId32({
id: alice.publicKey,
network: NetworkId.Any(),
})),
})),
assets: VersionedMultiAssets.V2(Rune.array([Rune.rec({
id: AssetId.Concrete(Rune.rec({
parents: 0,
interior: Junctions.Here(),
})),
fun: Fungibility.Fungible(500_000_000_000_000n),
})])),
feeAssetItem: 0,
weightLimit: WeightLimit.Unlimited(),
})
.signed(signature({ sender: alice }))
.sent()
.dbgStatus()
.finalized()
.run()

// TODO: have the recipient associate the downward message with the sender
harrysolovay marked this conversation as resolved.
Show resolved Hide resolved
outer:
for await (const e of System.Events.value(undefined, parachain.latestBlock.hash).iter()) {
if (e) {
for (const { event } of e) {
if (RuntimeEvent.isParachainSystem(event) && Event.isDownwardMessagesProcessed(event.value)) {
console.log("Alice balance after:", await aliceBalance.run())
break outer
}
}
}
}
86 changes: 0 additions & 86 deletions examples/xcm_asset_teleportation.ts

This file was deleted.