Converting pysui TxInspectionResult into python objects

Hi,

I am attempting a simple operation to read afSUI price from the provided staked_sui_vault. I was able to read the data using devInspect through pysui via the following code:

txn = SyncTransaction(client=client, initial_sender = sender)

txn.move_call(target="0x7f6ce7ade63857c4fd16ef7783fed2dfc4d7fb7e40615abdb653030b76aef0c6::staked_sui_vault::afsui_to_sui",
              arguments = [ObjectID("0x2f8f6d5da7f13ea37daa397724280483ed062769813b6f31e9788e59cc88994d"),
                          ObjectID("0xeb685899830dd5837b47007809c76d91a098d52aabbf61e8ac467c59e5cc4610"),
                          SuiU64(1000000000)]
         )

res = txn.inspect_all()

the result is some kind of serialized u64:

results=[{‘returnValues’: [[[4, 85, 209, 61, 0, 0, 0, 0], ‘u64’]]}]

I looked in the pysui docs but wasn’t able to identify where the conversion methods would be that could convert this back to a python object.

A pointer in the right direction would be appreciated, happy to update the docs for future users with similar issues!

Follow-Up: I figured out how to do this manually:

from canoser import Struct, Uint8, Uint64
Uint64.decode_bytes(res.results[0]['returnValues'][0][0])
1 Like

Yes, but it would be more ideal if pysui was able to convert the outputs back into python objects generically. I was wondering if maybe the library already does this and I was just not aware of where that functionality was.

1 Like