Skip to content

FR: Make to_cbor return bytes, add to_cbor_hex #209

Closed
@nielstron

Description

@nielstron

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions