@@ -133,28 +133,28 @@ runQueryProtocolParametersCmd
133133 , Cmd. outputFormat
134134 , Cmd. mOutFile
135135 } = do
136- AnyCardanoEra cEra <- fromExceptTCli $ determineEra nodeConnInfo
137- era <- fromExceptTCli $ supportedEra cEra
136+ anyCEra@ (AnyCardanoEra cEra) <- fromExceptTCli $ determineEra nodeConnInfo
137+ case forEraInEonMaybe cEra id of
138+ Nothing -> throwCliError $ QueryCmdEraNotSupported anyCEra
139+ Just sbe -> do
140+ let qInMode = QueryInEra $ QueryInShelleyBasedEra sbe Api. QueryProtocolParameters
138141
139- let sbe = convert era
140- qInMode = QueryInEra $ QueryInShelleyBasedEra sbe Api. QueryProtocolParameters
141-
142- pparams <-
143- fromExceptTCli $
144- executeQueryAnyMode nodeConnInfo qInMode
142+ pparams <-
143+ fromExceptTCli $
144+ executeQueryAnyMode nodeConnInfo qInMode
145145
146- let output =
147- Exp. obtainCommonConstraints era
148- $ outputFormat
149- & ( id
150- . Vary. on (\ FormatJson -> Json. encodeJson)
151- . Vary. on (\ FormatYaml -> Json. encodeYaml)
152- $ Vary. exhaustiveCase
153- )
154- $ pparams
146+ let output =
147+ shelleyBasedEraConstraints sbe
148+ $ outputFormat
149+ & ( id
150+ . Vary. on (\ FormatJson -> Json. encodeJson)
151+ . Vary. on (\ FormatYaml -> Json. encodeYaml)
152+ $ Vary. exhaustiveCase
153+ )
154+ $ pparams
155155
156- fromEitherIOCli @ (FileError () ) $
157- writeLazyByteStringOutput mOutFile output
156+ fromEitherIOCli @ (FileError () ) $
157+ writeLazyByteStringOutput mOutFile output
158158
159159-- | Calculate the percentage sync rendered as text: @min 1 (tipTime/nowTime)@
160160percentage
@@ -316,12 +316,13 @@ runQueryUTxOCmd
316316 ) = do
317317 fromEitherIOCli
318318 ( executeLocalStateQueryExpr nodeConnInfo target $ runExceptT $ do
319- AnyCardanoEra cEra <- easyRunQueryCurrentEra
319+ anyCEra @ ( AnyCardanoEra cEra) <- easyRunQueryCurrentEra
320320
321- era <- hoist liftIO $ supportedEra cEra
322-
323- utxo <- easyRunQuery (queryUtxo (convert era) queryFilter)
324- hoist liftIO $ writeFilteredUTxOs era outputFormat mOutFile utxo
321+ case forEraInEonMaybe cEra id of
322+ Nothing -> throwCliError $ QueryCmdEraNotSupported anyCEra
323+ Just sbe -> do
324+ utxo <- easyRunQuery (queryUtxo sbe queryFilter)
325+ hoist liftIO $ writeFilteredUTxOs sbe outputFormat mOutFile utxo
325326 )
326327 & fromEitherCIOCli
327328
@@ -1199,20 +1200,20 @@ writePoolState outputFormat mOutFile serialisedCurrentEpochState = do
11991200 $ writeLazyByteStringOutput mOutFile output
12001201
12011202writeFilteredUTxOs
1202- :: Exp. Era era
1203+ :: ShelleyBasedEra era
12031204 -> Vary [FormatCborBin , FormatCborHex , FormatJson , FormatText , FormatYaml ]
12041205 -> Maybe (File () Out )
12051206 -> UTxO era
12061207 -> ExceptT QueryCmdError IO ()
12071208writeFilteredUTxOs era format mOutFile utxo = do
12081209 let output =
1209- Exp. obtainCommonConstraints era $
1210+ shelleyBasedEraConstraints era $
12101211 format
12111212 & ( id
1212- . Vary. on (\ FormatCborBin -> CBOR. serialize $ toLedgerUTxO (convert era) utxo)
1213- . Vary. on (\ FormatCborHex -> Base16. encode . CBOR. serialize $ toLedgerUTxO (convert era) utxo)
1213+ . Vary. on (\ FormatCborBin -> CBOR. serialize $ toLedgerUTxO era utxo)
1214+ . Vary. on (\ FormatCborHex -> Base16. encode . CBOR. serialize $ toLedgerUTxO era utxo)
12141215 . Vary. on (\ FormatJson -> Json. encodeJson utxo)
1215- . Vary. on (\ FormatText -> strictTextToLazyBytestring $ filteredUTxOsToText (convert era) utxo)
1216+ . Vary. on (\ FormatText -> strictTextToLazyBytestring $ filteredUTxOsToText era utxo)
12161217 . Vary. on (\ FormatYaml -> Json. encodeYaml utxo)
12171218 $ Vary. exhaustiveCase
12181219 )
@@ -1221,26 +1222,71 @@ writeFilteredUTxOs era format mOutFile utxo = do
12211222 . newExceptT
12221223 $ writeLazyByteStringOutput mOutFile output
12231224
1224- filteredUTxOsToText :: Exp. Era era -> UTxO era -> Text
1225- filteredUTxOsToText era (UTxO utxo) = do
1225+ filteredUTxOsToText :: Api. ShelleyBasedEra era -> UTxO era -> Text
1226+ filteredUTxOsToText sbe (UTxO utxo) = do
12261227 mconcat
12271228 [ Text. unlines [title, Text. replicate (Text. length title + 2 ) " -" ]
1228- , Text. unlines $ case era of
1229- Exp. ConwayEra ->
1230- map (utxoToText era) $ toList utxo
1229+ , Text. unlines $ case sbe of
1230+ ShelleyBasedEraShelley ->
1231+ map (utxoToText sbe) $ toList utxo
1232+ ShelleyBasedEraAllegra ->
1233+ map (utxoToText sbe) $ toList utxo
1234+ ShelleyBasedEraMary ->
1235+ map (utxoToText sbe) $ toList utxo
1236+ ShelleyBasedEraAlonzo ->
1237+ map (utxoToText sbe) $ toList utxo
1238+ ShelleyBasedEraBabbage ->
1239+ map (utxoToText sbe) $ toList utxo
1240+ ShelleyBasedEraConway ->
1241+ map (utxoToText sbe) $ toList utxo
12311242 ]
12321243 where
12331244 title :: Text
12341245 title =
12351246 " TxHash TxIx Amount"
12361247
12371248utxoToText
1238- :: Exp. Era era
1249+ :: Api. ShelleyBasedEra era
12391250 -> (TxIn , TxOut CtxUTxO era )
12401251 -> Text
12411252utxoToText sbe txInOutTuple =
12421253 case sbe of
1243- Exp. ConwayEra ->
1254+ ShelleyBasedEraShelley ->
1255+ let (TxIn (TxId txhash) (TxIx index), TxOut _ value _ _) = txInOutTuple
1256+ in mconcat
1257+ [ Text. decodeLatin1 (hashToBytesAsHex txhash)
1258+ , textShowN 6 index
1259+ , " " <> printableValue value
1260+ ]
1261+ ShelleyBasedEraAllegra ->
1262+ let (TxIn (TxId txhash) (TxIx index), TxOut _ value _ _) = txInOutTuple
1263+ in mconcat
1264+ [ Text. decodeLatin1 (hashToBytesAsHex txhash)
1265+ , textShowN 6 index
1266+ , " " <> printableValue value
1267+ ]
1268+ ShelleyBasedEraMary ->
1269+ let (TxIn (TxId txhash) (TxIx index), TxOut _ value _ _) = txInOutTuple
1270+ in mconcat
1271+ [ Text. decodeLatin1 (hashToBytesAsHex txhash)
1272+ , textShowN 6 index
1273+ , " " <> printableValue value
1274+ ]
1275+ ShelleyBasedEraAlonzo ->
1276+ let (TxIn (TxId txhash) (TxIx index), TxOut _ value mDatum _) = txInOutTuple
1277+ in mconcat
1278+ [ Text. decodeLatin1 (hashToBytesAsHex txhash)
1279+ , textShowN 6 index
1280+ , " " <> printableValue value <> " + " <> Text. pack (show mDatum)
1281+ ]
1282+ ShelleyBasedEraBabbage ->
1283+ let (TxIn (TxId txhash) (TxIx index), TxOut _ value mDatum _) = txInOutTuple
1284+ in mconcat
1285+ [ Text. decodeLatin1 (hashToBytesAsHex txhash)
1286+ , textShowN 6 index
1287+ , " " <> printableValue value <> " + " <> Text. pack (show mDatum)
1288+ ]
1289+ ShelleyBasedEraConway ->
12441290 let (TxIn (TxId txhash) (TxIx index), TxOut _ value mDatum _) = txInOutTuple
12451291 in mconcat
12461292 [ Text. decodeLatin1 (hashToBytesAsHex txhash)
0 commit comments