Skip to content

FR: Make to_cbor return bytes, add to_cbor_hex #209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nielstron opened this issue Apr 16, 2023 · 2 comments
Closed

FR: Make to_cbor return bytes, add to_cbor_hex #209

nielstron opened this issue Apr 16, 2023 · 2 comments

Comments

@nielstron
Copy link
Contributor

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

@cffls
Copy link
Collaborator

cffls commented May 7, 2023

Addressed in #232

@cffls
Copy link
Collaborator

cffls commented May 7, 2023

Closing this as resolved in #232

@cffls cffls closed this as completed May 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants