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.
Co-authored-by: Ryan Lee <ryan@parity.io>
- Loading branch information
1 parent
76ba340
commit f819cc2
Showing
9 changed files
with
425 additions
and
15 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
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,70 @@ | ||
import { alice, bob, charlie, dave, MultiAddress, Rune } from "capi" | ||
import { VirtualMultisigRune } from "capi/patterns/multisig/mod.ts" | ||
import { Balances, chain, System, Utility } from "polkadot_dev/mod.ts" | ||
import { parse } from "../deps/std/flags.ts" | ||
|
||
let { state } = parse(Deno.args, { string: ["state"] }) | ||
if (!state) { | ||
state = await VirtualMultisigRune | ||
.deployment(chain, { | ||
founders: [alice.publicKey, bob.publicKey, charlie.publicKey], | ||
threshold: 2, | ||
deployer: alice, | ||
}) | ||
.hex | ||
.run() | ||
} | ||
|
||
console.log(`Virtual multisig state hex: ${state}`) | ||
|
||
const vMultisig = VirtualMultisigRune.hydrate(chain, state) | ||
|
||
const fundStash = Balances | ||
.transfer({ | ||
dest: vMultisig.stash.map(MultiAddress.Id), | ||
value: 20_000_000_000_000n, | ||
}) | ||
.signed({ sender: alice }) | ||
.sent() | ||
.dbgStatus("Fund Stash:") | ||
.finalized() | ||
|
||
const proposal = Balances.transfer({ | ||
dest: dave.address, | ||
value: 1_234_000_000_000n, | ||
}) | ||
|
||
const bobTx = Utility | ||
.batchAll({ | ||
// @ts-ignore: fix upon #656 | ||
calls: Rune.array([ | ||
vMultisig.fundMemberProxy(bob.publicKey, 20_000_000_000_000n), | ||
vMultisig.ratify(bob.publicKey, proposal), | ||
]), | ||
}) | ||
.signed({ sender: bob }) | ||
.sent() | ||
.dbgStatus("Bob fund & ratify:") | ||
.finalized() | ||
|
||
const charlieTx = Utility | ||
.batchAll({ | ||
// @ts-ignore: fix upon #656 | ||
calls: Rune.array([ | ||
vMultisig.fundMemberProxy(charlie.publicKey, 20_000_000_000_000n), | ||
vMultisig.ratify(charlie.publicKey, proposal), | ||
]), | ||
}) | ||
.signed({ sender: charlie }) | ||
.sent() | ||
.dbgStatus("Charlie fund & ratify:") | ||
.finalized() | ||
|
||
await Rune | ||
.chain(() => vMultisig) | ||
.chain(() => fundStash) | ||
.chain(() => System.Account.entry([dave.publicKey]).dbg("Dave Balance Before:")) | ||
.chain(() => bobTx) | ||
.chain(() => charlieTx) | ||
.chain(() => System.Account.entry([dave.publicKey]).dbg("Dave Balance After:")) | ||
.run() |
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
Oops, something went wrong.