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

Rehandle and events #1134

Closed statictype closed 1 year ago

statictype commented 1 year ago

Not clear how to do something with the emitted events while also re-handling errors. If this is not a desired flow, it should not be possible to write the code.

The following code, although correct, produces an error at runtime if the transaction failed.

  const ratifyCall = multisig
    .ratify(user, call)
    .signed(signature({ sender }))
    .sent()
    .dbgStatus("Ratify")
    .finalizedEvents()
    .unhandleFailed()
    .rehandle(is(ExtrinsicError))
    .pipe(filterPureCreatedEvents)

  await ratifyCall.run()
Screenshot 2023-07-05 at 20 23 15

The following code appears to run successfully although there was an error

  const ratifyCall = multisig
    .ratify(user, call)
    .signed(signature({ sender }))
    .sent()
    .dbgStatus("Ratify")
    .finalizedEvents()
    .unhandleFailed()
    .pipe(filterPureCreatedEvents)
    .rehandle(is(ExtrinsicError))

  await ratifyCall.run()
Screenshot 2023-07-05 at 20 29 22

https://westend.subscan.io/block/0x6d71bb09f5c597518bd856ede5abc9fff28b753bc264f8e479bced248ef134ab

ryanleecode commented 1 year ago

likely missing the callback in rehandle as mentioned in https://github.com/paritytech/capi/issues/1133

statictype commented 1 year ago

please make sure the examples are up to date. why does this even work without a callback?

harrysolovay commented 1 year ago

It's supposed to work without a callback (@ryanleecode).