This repository has been archived by the owner on Sep 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: asset teleportation example clean up (#818)
- Loading branch information
1 parent
8331e02
commit 691ae7f
Showing
2 changed files
with
67 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.