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

ABI decoding of list of tuples

Open cusma opened this issue 3 years ago • 1 comments

Subject of the issue

Defined output type with PyTeal ABI to return a list of tuple, like:

output: abi.StaticArray[abi.Tuple2[abi.Address, abi.String], Literal[2]],

The decoded output returns a list of list instead.

Your environment

  • algod, 3.7.2.stable [rel/stable] (commit #e2f78420)
  • py-algorand-sdk, v1.15.0
  • pyteal, v0.13.0 (pointing to current /feature/abi branch)

Steps to reproduce

  1. Define a PyTeal contract with:
output: abi.StaticArray[abi.Tuple2[abi.Address, abi.String], Literal[2]],
  1. Print returned Logs.

Expected behaviour

Python list of tuple.

[('JUYTZVK2PL42FJDBLDUSI377RCABBRVICQQKGF73PXG7C2WSVG7JXYZ7SQ', 'foo'), ('MTFEO2IFDY23HL6JBV437WTDOK2QGEFCOKNTQT353KMRJUGXL3GKQZ3FG4', 'spam')]

Actual behaviour

Python list of list.

[[JUYTZVK2PL42FJDBLDUSI377RCABBRVICQQKGF73PXG7C2WSVG7JXYZ7SQ', 'foo'], ['MTFEO2IFDY23HL6JBV437WTDOK2QGEFCOKNTQT353KMRJUGXL3GKQZ3FG4', 'spam']]

cusma avatar Jun 28 '22 17:06 cusma

Would also be useful to decode ABI bytes types (ByteType, ArrayDynamicType, ArrayStaticType) to Python bytes instead of int / list[int].

cusma avatar Oct 23 '23 12:10 cusma