paritytech / capi

[WIP] A framework for crafting interactions with Substrate chains
https://docs.capi.dev
Apache License 2.0
105 stars 10 forks source link

multisig approval/cancellation event capture broken? #1139

Open harrysolovay opened 1 year ago

harrysolovay commented 1 year ago

@statictype has reported an issue in gamma 1 in which multisig approval/cancellation event capture is supposedly broken.

In resolving this, let's also create an example of multisig proposal cancellation.

peetzweg commented 1 year ago

Related comment: https://github.com/paritytech/capi-multisig-app/pull/217#issuecomment-1621232112

harrysolovay commented 1 year ago

I haven't attempted cancellation, but event extraction is seemingly working fine.

import { polkadotDev } from "@capi/polkadot-dev"
import { createDevUsers } from "capi"
import { MultisigRune } from "capi/patterns/multisig"
import { signature } from "capi/patterns/signature/polkadot"

const { alexa, billy, carol, david } = await createDevUsers()

const multisig = MultisigRune.from(polkadotDev, {
  signatories: [alexa, billy, carol].map(({ publicKey }) => publicKey),
  threshold: 3,
})

await multisig
  .fund(2_000_000_000_000n)
  .signed(signature({ sender: alexa }))
  .sent()
  .dbgStatus("Existential deposit")
  .finalized()
  .run()

const call = polkadotDev.Balances.transferKeepAlive({
  dest: david.address,
  value: 1_230_000_000_000n,
})

const firstProposalEvents = await multisig
  .ratify(alexa.address, call)
  .signed(signature({ sender: alexa }))
  .sent()
  .dbgStatus("Proposal:")
  .finalizedEvents()
  .run()
console.log("Proposal events", firstProposalEvents)

const finalApprovalEvents = await multisig
  .ratify(billy.address, call)
  .signed(signature({ sender: billy }))
  .sent()
  .dbgStatus("Final approval:")
  .finalizedEvents()
  .run()
console.log("Final approval events", finalApprovalEvents)

I'll follow up after I've had the chance to test within your chore-capi-beta47 branch.