w3up
w3up copied to clipboard
feat: add ucan receipts capability
This PR adds support for getting receipts from executed task (and optionally follow task effects and also get receipts already available).
Capability
Called it ucan/receipt
and put it together with ucan/*
capabilities. However, I am not entirely sure this would be the expected scope, or maybe the name needs a better feeling of being a getter.
Return type
It is not trivial to define the return type here, so would like feedback. For now, opted for simply mapping what ucanto
does, even though I was first considering something like:
interface ReceiptRecord {
receipt: Receipt
joinReceipt?: ReceiptRecord
forkReceipts?: ReceiptRecord[]
}
which ended up feeling weird to me if chain is not complete.
Encoding
At first, I tried to rely on ReceiptRecord
above as the return type of the invocation, which of course means that on the client side Receipt instance is lost. We could capture information enough to re-create it on the client, but I ended up just mimic what ucanto
does behind the scenes and encode this as a Message (which given it goes through ucanto
, will be a message inside a message 😅 ). However, it felt the cleaner and nicer approach to give back to user Receipts.