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

Commit

Permalink
chore: asset teleportation example clean up (#818)
Browse files Browse the repository at this point in the history
  • Loading branch information
harrysolovay authored Mar 28, 2023
1 parent 8331e02 commit 691ae7f
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 86 deletions.
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
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.

0 comments on commit 691ae7f

Please sign in to comment.