Skip to content

JSON output for cardano-cli #3548

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
wants to merge 13 commits into from
Closed

JSON output for cardano-cli #3548

wants to merge 13 commits into from

Conversation

cblp
Copy link
Contributor

@cblp cblp commented Jan 28, 2022

Fixes #3213

Changes (planned)

  • query utxo
    • --out-file writes JSON
  • transaction view
    • --out-file writes JSON
  • transaction calculate-min-fee
    • --out-file writes JSON

@cblp cblp changed the title cardano-cli query utxo: Fix JSON output description CLI improvements for formatting and consistency Jan 28, 2022
@cblp cblp force-pushed the json-output branch 6 times, most recently from f8082a6 to fd90892 Compare May 26, 2022 16:07
@cblp cblp marked this pull request as ready for review May 26, 2022 16:08
@cblp cblp changed the title CLI improvements for formatting and consistency JSON output for cardano-cli May 26, 2022
@gitmachtl
Copy link
Contributor

the 'query kes-period-info' output is super strange. its a mix of colored cleartext with a json part attached. so a --json switch would totally make sense for that one.

@euonymos
Copy link

Voting up! It's a pity it looks stalled.

@newhoggy newhoggy force-pushed the json-output branch 3 times, most recently from 30ae7e6 to 2824a1a Compare April 11, 2023 01:06
@newhoggy newhoggy dismissed Jimbo4350’s stale review April 11, 2023 01:14

Comments addressed

@@ -105,6 +109,52 @@ instance ToCBOR Certificate where
instance FromCBOR Certificate where
fromCBOR = fromShelleyCertificate <$> fromCBOR

instance ToJSON Certificate where
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if it would be possible here to change constructors to records and then use genericToJSON with constructorTagModifier instead of manual instances?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we prefer explicit instances. @Jimbo4350 do you have an opinion on genericToJSON?

@newhoggy newhoggy force-pushed the json-output branch 4 times, most recently from 032ac17 to a1cb8ac Compare April 21, 2023 02:02
newhoggy and others added 13 commits May 11, 2023 00:32
* Certificate
* MIRTarget
* StakePoolParameters
* StakePoolRelay
* StakePoolMetadataReference
* ProtocolParametersUpdate
* UpdateProposal
* WitVKey 'Witness crypto
* KeyWitness era
* PlutusScriptVersion lang
* Script lang
* ScriptInEra era
* PlutusScript lang
* TxAuxScripts era
* TxBodyContent ViewTx era
* TxCertificates ViewTx era
* TxExtraKeyWitnesses era
* TxFee era
* TxInsCollateral era
* TxInsReference build era
* TxMetadataInEra era
* TxMintValue ViewTx era
* TxReturnCollateral CtxTx era
* TxScriptValidity era
* TxTotalCollateral era
* TxUpdateProposal era
* TxValidityLowerBound era
* TxValidityUpperBound era
* TxWithdrawals ViewTx era
instance ToJSON ProtocolParametersUpdate where
toJSON ref =
object $
( ("protocolVersion" ..=? protocolUpdateProtocolVersion ref)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have Generic instance available here already, why not use genericToJSON? 😃

@@ -868,6 +898,13 @@ instance FromCBOR UpdateProposal where
<$> fromCBOR
<*> fromCBOR

instance ToJSON UpdateProposal where
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not convert UpdateProposal to a record and then use genericToJSON?

{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE UndecidableInstances #-}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if there is a way to avoid using Undecidableinstances here? Maybe this could be solved by OVERLAPPING / OVERLAPPABLE?

@@ -281,6 +280,8 @@ import Cardano.Api.Utils
import Cardano.Api.Value
import Cardano.Api.ValueParser

-- import Cardano.Chain.UTxO (Tx (..))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover comment?

@newhoggy newhoggy closed this Dec 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FR] - CLI improvements for formatting and consistency
6 participants