Skip to content

Commit

Permalink
Fix JSON output for utxo command
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimbo4350 committed Feb 1, 2021
1 parent d38e7a7 commit 25329bb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
13 changes: 11 additions & 2 deletions cardano-api/src/Cardano/Api/TxBody.hs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ import qualified Data.Sequence.Strict as Seq
import qualified Data.Set as Set
import Data.String (IsString)
import qualified Data.Text as Text
import qualified Data.Text.Encoding as Text
import Data.Word (Word64)
import GHC.Generics

Expand Down Expand Up @@ -236,7 +237,12 @@ data TxIn = TxIn TxId TxIx

deriving instance ToJSON TxIn
instance ToJSONKey TxIn where
toJSONKey = toJSONKeyText (Text.pack . show)
toJSONKey = toJSONKeyText
(\(TxIn txId (TxIx txIx))
-> Text.decodeUtf8 (serialiseToRawBytesHex txId)
<> "#"
<> Text.pack (show txIx)
)

newtype TxIx = TxIx Word
deriving stock (Eq, Ord, Show)
Expand Down Expand Up @@ -611,9 +617,12 @@ data TxOutValue era where

deriving instance Eq (TxOutValue era)
deriving instance Show (TxOutValue era)
deriving instance ToJSON (TxOutValue era)
deriving instance Generic (TxOutValue era)

instance ToJSON (TxOutValue era) where
toJSON (TxOutAdaOnly _ (Lovelace int)) = Aeson.Number $ fromInteger int
toJSON (TxOutValue _ val) = Aeson.String . Text.pack $ show val

-- ----------------------------------------------------------------------------
-- Transaction fees
--
Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/Shelley/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ renderShelleyClientCmdError cmd err =
where
renderError :: ShelleyCommand -> (a -> Text) -> a -> Text
renderError shelleyCmd renderer shelCliCmdErr =
mconcat [ "Shelley command failed: "
mconcat [ "Command failed: "
, renderShelleyCommand shelleyCmd
, " Error: "
, renderer shelCliCmdErr
Expand Down
4 changes: 2 additions & 2 deletions cardano-cli/src/Cardano/CLI/Shelley/Run/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ renderShelleyQueryCmdError err =
"Consensus mode and era mismatch. Consensus mode: " <> show cMode <>
" Era: " <> show era
ShelleyQueryCmdEraMismatch (EraMismatch ledgerEra queryEra) ->
"An error mismatch occured. Specified query era: " <> queryEra <>
"Current ledger era: " <> ledgerEra
"\nAn error mismatch occured." <> "\nSpecified query era: " <> queryEra <>
"\nCurrent ledger era: " <> ledgerEra

runQueryCmd :: QueryCmd -> ExceptT ShelleyQueryCmdError IO ()
runQueryCmd cmd =
Expand Down

0 comments on commit 25329bb

Please sign in to comment.