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

feat: virtual multisigs #661

Merged
merged 24 commits into from
Mar 1, 2023
Merged

feat: virtual multisigs #661

merged 24 commits into from
Mar 1, 2023

Conversation

harrysolovay
Copy link
Contributor

@harrysolovay harrysolovay commented Feb 26, 2023

Closes #658
Closes #555

This PR takes the learnings from #555 and integrates them into a VirtualMultisigRune. One can deploy a VirtualMultisigRune like so:

import { alice, bob, charlie, hex } from "capi"
import { VirtualMultisig } from "capi/patterns/multisig/mod.ts"
import { chain } from "polkadot_dev/mod.ts"

const state = await VirtualMultisigRune
  .deployment(chain, {
    founders: [alice.publicKey, bob.publicKey, charlie.publicKey],
    threshold: 2,
    deployer: alice,
  })
  .hex
  .run()

await Deno.writeTextFile("persist_this.txt", state)

To hydrate from the state hex, we do the following.

const vMultisig = VirtualMultisigRune.hydrate(chain, state)

To ratify a call from the stash account (signatory -> signatory proxy -> multisig -> stash), we can use virtual multisig's ratify method.

await vMultisig
  .ratify(bob.publicKey, proposal)
  .signed({ sender: bob })
  .sent()
  .dbgStatus("Bob ratify:")
  .finalized()
  .run()

Note: ensure that you've funded the proxy (as it's initialized with no more than the existential deposit –– fundMemberProxy)

Open questions:

  • Should VirtualMultisig depend on mappings from the member accounts to the proxy accounts? This would allow us to avoid the DX of passing signatory index into the ratify method.
  • Voting signatories in and out (how might we elegantly persist this data?)
  • Validation such as threshold and existing member of vmultisig

@harrysolovay harrysolovay changed the title feat: virtual multisig creation feat: virtual multisigs Feb 27, 2023
return Rune.resolve(events).map((events) =>
events
.map((e) => e.event)
.filter((event): event is RuntimeEvent.Proxy => event.type === "Proxy")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dont we have codegen guard for these?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid using codegened runtime code in patterns, as it makes them unusable to consuming NodeJS projects (for now).

@tjjfvi
Copy link
Contributor

tjjfvi commented Feb 27, 2023

Closes #658
Closes #555

Can we go ahead and close those now, for housekeeping purposes?

This was referenced Feb 27, 2023
@harrysolovay harrysolovay force-pushed the multisig-proxy-patterns branch from 04b5b9a to 2d3fc4e Compare February 27, 2023 15:59
}

ratify<X>(...[senderIndex, call]: RunicArgs<X, [number, Chain.Call<C>]>) {
const call_ = this.chain.extrinsic(Rune.rec({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proxy call needs to happen outside of ratify. We can't assume every ratify call will interact with the stash

@ryanleecode ryanleecode marked this pull request as ready for review February 28, 2023 15:43
@harrysolovay harrysolovay force-pushed the multisig-proxy-patterns branch from b322af3 to d9fe4ce Compare February 28, 2023 16:09
@ryanleecode ryanleecode force-pushed the multisig-proxy-patterns branch from 0126374 to ba69b0e Compare February 28, 2023 22:12
@harrysolovay harrysolovay merged commit f819cc2 into main Mar 1, 2023
@harrysolovay harrysolovay deleted the multisig-proxy-patterns branch March 1, 2023 16:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants