-
Notifications
You must be signed in to change notification settings - Fork 724
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
Wire up outstanding new IPC queries to the cli #2290
Conversation
4f63c04
to
67db64f
Compare
be36ba2
to
ec658d4
Compare
56c7a9b
to
da28b27
Compare
da28b27
to
5f7ff36
Compare
25329bb
to
e3f8b18
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.
Definitely going in the right direction.
Main thing is to look more closely at the ToJSON instances you're providing. Where we do provide ToJSON instances they should be sane machine-readable choices, and reflect the surface structure of the types, not revealing lots of internals (so not using Generic or Show).
ef64b98
to
250cf11
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.
Nearly there!
instance ToJSON TxIn where | ||
toJSON (TxIn txId (TxIx ix)) = | ||
Aeson.String ( Text.decodeUtf8 (serialiseToRawBytesHex txId) | ||
<> "#" | ||
<> Text.pack (show ix) | ||
) |
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 what happened to the ToJSONKey
instance? Perhaps I misread and you only have the ToJSONKey
for the underlying Shelley type.
We should provide it for the surface type because it's directly useful and so we can use the simple instance for UTxO above.
The ToJSONKey
instance should use this rendering as a single string with the #, but the ToJSON
should still give us an object with two fieldstxid
and txix
.
-- Orphan instances involved in the JSON output of the API queries. | ||
-- We will remove/replace these as we provide more API wrapper types |
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.
Mmm. This does make me a little nervous. Where do we still need these? Is this for the ToJSON instance for the ledger state? Otherwise I think we should be able to do everything with JSON instances only for the API surface types.
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.
Yes these are for the LedgerState
and ProtocolState
which are just type wrappers around the underlying ledger-specs types. We could do something similar for them (e.g the api's UTxO
and having conversion function from the underlying ledger types) but I figured implementing JSON instances would be less time consuming and OK for now as these are used in rendering the output for protocol-state
and ledger-state
cli commands.
:: Query.SerialisedLedgerState era | ||
-> Either LBS.ByteString (Query.LedgerState era) | ||
decodeLedgerState (Query.SerialisedLedgerState (Serialised ls)) = | ||
first (const ls) (decodeFull ls) |
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.
We should probably provide something like thisin the API itself to get from the SerialisedLedgerState
to a LedgerState
(or error), rather than having to know the underlying details of how it works here.
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'll add this to my TODO list or I can delegate this as a small task. This might be a good task for John or Yuri to get their feet wet in the API.
250cf11
to
03783fe
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.
LGTM!
Lets squash the last three patches into a single "review fixes for JSON output" patch, and merge.
5ddada9
to
f3088d7
Compare
bors r+ |
Build succeeded: |
Depends on #2275
The following cli commands were updated with the new IPC.
tip
utxo
ledger-state
protocol-state