kadena-community/kadena.js

[@kadena/client] Commandbuilder: null proof in continuation

Closed this issue · 5 comments

Please confirm the following:

  • I have read the Code of Conduct
  • The bug was not reported before
  • I am using the latest version of the relevant package(s)

What operating system are you using? And what version?

Linux

What environment or browser are you using? And what version?

Node.js

What package is the bug report about?

@kadena/client

Describe the bug

The commandBuilder does not allow using null proof.

Example:

const cmd = Pact.builder.continuation({pactId:"4UdU0LY5hNCNQuuuRAmXKGHf2Q2S4OUAYnEo5X7B60Y", step:0, rollback:true, proof:null})

This does not work.
Is looks like the issue come from:

clone.proof = clone.proof.replace(/\"/gi, '');

Supporting null proofs is absolutely necessary, because Pact expects to have JSON null when the (defpact) takes place on a single chain without yielded value.

Steps to reproduce the behavior

...

What did you expect to happen?

When using proof:null with the commandBuilder, I would expect to obtain a null is the resulting transaction, without having an exception being thrown.

Participation

  • I am willing to submit a pull request for this issue.

I suppose this issue needs to be resolved before kadena.js can be used with Marmalade.

I suppose this issue needs to be resolved before kadena.js can be used with Marmalade.

Yes, you're right. I would be better....

But in the meantime, I found out a workaround (I'm not very proud of it)

https://github.com/CryptoPascal31/marmalade-ng-sweep-bot/blob/44d1d817992225f40adf9c3e55141981beb2295e/marmalade_ng_client.js#L4

Based on the api specification it says the proof could be only a base64 string if presented.
https://api.chainweb.com/openapi/pact.html#tag/model-payload
So if there is no proof you don't need to pass the proof field

const cmd = Pact.builder.continuation({
  pactId:"4UdU0LY5hNCNQuuuRAmXKGHf2Q2S4OUAYnEo5X7B60Y", 
  step:0, 
  rollback:true
})

if this throws an exception then we need to update the api specification as well
Could you please check if not passing proof solves the issue?

According to the Pact code:
https://github.com/kadena-io/pact/blob/445af04190793a1d8fbbfad626e25fb7f4a0c02c/src/Pact/Types/RPC.hs#L98

the field proof is mandatory: Aeson's .: operator.

btw: this should be confirmed by an Haskell/Aeson guru

I haven't tested until now.
But the merged PR should fix the issue => I'm closing.