-
Notifications
You must be signed in to change notification settings - Fork 25
cardano-rpc | Add decoded PlutusData and NativeScript in proto definition #947
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
base: master
Are you sure you want to change the base?
Conversation
2a68c4a
to
0da56f8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is all accurate except for the bigint representation, which I am sure you already considered. But I commented on the bits that I found suspicious, even though I think they are all correct
ScriptDataBytes bs -> | ||
defMessage & #boundedBytes .~ bs | ||
ScriptDataNumber int -> | ||
defMessage & #bigInt . #int .~ fromIntegral int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am guessing this is limited to 64bit, but provisionally should work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, actually good catch. I'm converting unbounded integer to uint64
here. I think we should safeguard ourselves from partial conversion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed a fix for that.
let constr = | ||
defMessage | ||
& #tag .~ fromIntegral tag | ||
& #fields .~ map inject args |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems this is missing any_constructor
, don't know whether that is important
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM however you should start implementing round trip tests for your Inject
instances and consider having a separate type class for these transformations.
I'll approve once the round trip tests are added.
PlutusScript PlutusScriptV3 ps -> | ||
defMessage & #plutusV3 .~ serialiseToRawBytes ps | ||
|
||
instance Inject SimpleScript (Proto UtxoRpc.NativeScript) where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on having separate (more rpc specific) type class for this instead of using Inject
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'll create specific conversion functions as per https://github.com/input-output-hk/cardano-node-wiki/wiki/ADR-014-Total-conversion-functions-conventions#explicit-conversion-functions
A type class feels a bit shoehorned here. Some conversions will be partial.
f857964
to
a345801
Compare
Changelog
Context
Previously,
NativeScript
andPlutusData
were omitted in the ReadUtxos query feature:This PR adds decoding of those values to the protobuf type. Using protobuf-defined values instead of CBOR blobs is advantageous, as it lets UTxO RPC consumers work with a single data format.
Checklist