agent-js
agent-js copied to clipboard
feat: call returns raw certificate, if requested
Description
It is possible to speed up inter-canister calls in some scenarios, if delegate making the call and transferring the response to the user. For example, you've make an ICRC-1 token transfer to some dApp. This dApp, instead of making its own inter-canister call to token's index canister, would ask the user itself to fetch the block from the index and pass the certified response back to one of its own canisters, which can then verify the response.
Such an optimization requires being able to make a call and simultaneously retrieve the raw certificate client-side. This PR adds this feature in a clean non-breaking way.
Also, there was an accidentally discovered bug related to pollForResponse
function. It was invoked with blsVerify
parameter in place of request
parameter. Maybe it did nothing, but it seemed suspicious. This wasn't catched by Typescript, because request
parameter is of type any
.
Note
- The certificate is only returned when
CallConfig.returnCertificate
is set totrue
. In that case, instead of justreply
the method will return{ result: reply, cert: rawCertificate }
. IfCallConfig.returnCertificate
is unset offalse
- nothing changes, everything works as usual. - The certificate is only returned for
update
calls. Forquery
calls empty buffer is returned like this{ result: reply, cert: emptyBuf }
. This is done to: a) comply with method signature change (ActorMethod interface is the same for query and update calls); b) enable replica signature/certificate to be returned the same way for queries in future. - I was not able to run e2e tests - could not find any scripts mentioned in the docs. Also, docs on local development seem outdated. Please, take action.
How Has This Been Tested?
Added a unit-test to actor.test.ts
testcase.