Open nullhashpixel opened 1 month ago
This issue will be resolved by this PR. I've tested in the custom branch and here is the output:
>>> from pycardano import *
>>> obj = IndefiniteList([1,2,3])
>>> ser = RawPlutusData.from_primitive(obj).to_cbor()
>>> ser.hex()
'9f010203ff'
>>> RawPlutusData.from_cbor(ser)
RawPlutusData(data=[1, 2, 3])
>>> raw = RawPlutusData.from_cbor(ser)
>>> raw.to_cbor_hex()
'9f010203ff'
I have a CBOR object, already serialized correctly to be part of a datum or redeemer structure. This comes from another library, which ideally should be independent of pycardano. The goal is to embed it into a more complex structure which is created with pycardano objects, so the external CBOR needs to be deserialized first, but if the outermost level is indefinite list (CBOR tag 0x9f), this fails.
a simple example which works (outermost level is CBORTag)
but for indefinite lists it doesn't work:
wrapping to objects into CBORTag also only helps for simple cases, for more complicated ones, like this one it creates CBOR, which Cardano does not like (len>64 bytestrings)
so 5f 58 40 (A) 58 40 (B) did turn into 5f 58 80 (AB) which is invalid.
Is there any way to deserialize arbitrary structures into a PlutusData/RawPlutusData object?