js-algorand-sdk icon indicating copy to clipboard operation
js-algorand-sdk copied to clipboard

Fix incorrect stateproof representation

Open jasonpaulos opened this issue 1 year ago • 0 comments

Currently the stateproof transaction fields are incorrect: https://github.com/algorand/js-algorand-sdk/blob/6fdfa116f0e47e68982281028fdc817577c6aab7/src/transaction.ts#L209-L211

stateProof and stateProofMessage are not byte arrays, the are objects.

Additionally, the block header type contains an invalid representation of state proof tracking info: https://github.com/algorand/js-algorand-sdk/blob/6fdfa116f0e47e68982281028fdc817577c6aab7/src/types/blockHeader.ts#L80

It is not possible to decode a Map object from JSON or msgpack, and the value type should be an object, not a byte array.

It remains to be seen whether the best approach is to fully type stateproof objects, or reference then generically, but something must be done to improve this.

Additionally, the stateproof types use integers as map keys, so it will be difficult to get these to encode and decode properly.

jasonpaulos avatar Jan 29 '24 22:01 jasonpaulos