paritytech / capi

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

refactor: event and error selection #1143

Closed harrysolovay closed 1 year ago

harrysolovay commented 1 year ago

Closes #635 Closes #1131 Closes #1133 Closes #1134

Allows for simpler selection of specific event types.

const transferEvents = await chain
  .transfer({ /* ... */ })
  .signed(signature({ sender }))
  .sent()
  .finalizedEvents("Balances", "Transfer")
  .run()

And errors.

const errors = await chain
  .transfer({ /* ... */ })
  .signed(signature({ sender }))
  .sent()
  .finalizedErrors()
  .run()

Put them together...

const sent = chain
  .transfer({ /* ... */ })
  .signed(signature({ sender }))
  .sent()

const [transferEvents, errors] = await Rune
  .tuple([
    sent.finalizedEvents("Balances", "Transfer"),
    sent.finalizedErrors(),
  ])
  .run()