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

BlockResponse class incorrectly modeled

Open SilentRhetoric opened this issue 1 year ago • 1 comments

Subject of the issue

The BlockResponse.from_obj_for_encoding() returns a class object that has incorrect typing.

  • Software version: 2.7.0

Steps to reproduce

const blockRespRaw = algodClient.block(12345).do()

const incorrectTypedBlockResponse = modelsv2.BlockResponse.from_object_for_encoding(blockResponseRaw)

Expected behaviour

Passing the algodClient.block() through modelsv2.BlockResponse.from_obj_for_encoding() should produce an object in which the block property is a Block and not a BlockHeader.

Actual behaviour

Instead, the block property of the BlockResponse class is typed as a BlockHeader and thus does not allow accessing the rest of the block contents.

https://github.com/algorand/js-algorand-sdk/blob/e947e3395bb074fb496fbdda91650137b5670127/src/client/v2/algod/models/types.ts#L1877

SilentRhetoric avatar Dec 25 '23 02:12 SilentRhetoric

Good point, this type is not accurate

jasonpaulos avatar Jan 03 '24 19:01 jasonpaulos

Fixed by #875

jasonpaulos avatar Jun 27 '24 16:06 jasonpaulos