Closed
Description
Is your feature request related to a problem? Please describe.
The current implementation of to_cbor allows for an argument that determines the type of the output (hex or bytes). The default is a hexadecimal string representation of the cbor.
This entails three problems
- type checkers get confused
- in opshin, I would like to natively support
serialiseData
by mapping the to_cbor function in PlutusData - but opshin requires strict typing, which is incompatible. even if I force omitting the parameter I will get hex string which requires expensive extra compute on chain - there is some extra compute involved for people that just pass the cbor between functions
- the naming convention is a bit odd, since cbor is always bytes and the hex representation of it is usually called cbor_hex in the cardano node
Describe the solution you'd like
Make to_cbor just return bytes. Add to_cbor_hex as a convenience function.
Describe alternatives you've considered
To solve the nuisance with opshin it would be enough to change the default encoding to bytes. This is already a breaking change though, so why not fix up the types entirely while we're at it.
Additional context
serialiseData is also PlutusData -> bytes