You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 = bytes.fromhex('9fd87b9f015820276c628281b8513437da6143542dedb497c381e32b0799f4148f6cb6fcd14c465820720c2344d1bc140e926fda330ab4b6d5390e2fa98d30df57f0f72cff5270e8ebffff')
pycardano.plutus.RawPlutusData.from_cbor(a)
a simple example which works (outermost level is CBORTag)
>>> obj = IndefiniteList([1,2,3])
>>> ser = RawPlutusData.from_primitive(obj).to_cbor()
>>> ser.hex()
'9f010203ff'
>>> RawPlutusData.from_cbor(ser)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "venv/lib/python3.8/site-packages/pycardano/serialization.py", line 485, in from_cbor
return cls.from_primitive(value)
File "venv/lib/python3.8/site-packages/pycardano/serialization.py", line 159, in wrapper
raise DeserializeException(
pycardano.exception.DeserializeException: ['PlutusData', 'dict', 'int', 'bytes', 'IndefiniteList', 'RawCBOR', 'CBORTag'] typed value is required for deserialization. Got <class 'list'>: [1, 2, 3]
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)
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?
The text was updated successfully, but these errors were encountered: