diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index f3f518e41b..e4c7f57433 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -259,7 +259,6 @@ library transformers-except ^>=0.1.3, unliftio-core, utf8-string, - vector, yaml, executable cardano-cli @@ -337,7 +336,7 @@ test-suite cardano-cli-test Test.Cli.Governance.DRep Test.Cli.Governance.Hash Test.Cli.ITN - Test.Cli.JSON + Test.Cli.Json Test.Cli.MonadWarning Test.Cli.Pioneers.Exercise1 Test.Cli.Pioneers.Exercise2 diff --git a/cardano-cli/src/Cardano/CLI/Byron/Tx.hs b/cardano-cli/src/Cardano/CLI/Byron/Tx.hs index 2a57161cb3..517dcc26bd 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Tx.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Tx.hs @@ -107,7 +107,7 @@ genesisUTxOTxIn gc vk genAddr = where initialUtxo :: Map Common.Address (UTxO.TxIn, UTxO.TxOut) initialUtxo = - Map.fromList + fromList . mapMaybe (\(inp, out) -> mkEntry inp genAddr <$> keyMatchesUTxO vk out) . fromCompactTxInTxOutList . toList diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs index 652d35591c..a3309d3ce0 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs @@ -35,14 +35,13 @@ import Data.Foldable import Data.Functor (($>)) import qualified Data.IP as IP import Data.List.NonEmpty (NonEmpty) -import qualified Data.List.NonEmpty as NE import Data.Maybe -import qualified Data.Set as Set import Data.Text (Text) import qualified Data.Text as Text import Data.Time.Clock (UTCTime) import Data.Time.Format (defaultTimeLocale, parseTimeOrError) import Data.Word +import GHC.Exts (IsList (..)) import GHC.Natural (Natural) import Network.Socket (PortNumber) import Options.Applicative hiding (help, str) @@ -328,7 +327,7 @@ readVerificationKey asType = Opt.eitherReader deserialiseFromBech32OrHex where keyFormats :: NonEmpty (InputFormat (VerificationKey keyrole)) - keyFormats = NE.fromList [InputFormatBech32, InputFormatHex] + keyFormats = fromList [InputFormatBech32, InputFormatHex] deserialiseFromBech32OrHex :: String @@ -2747,7 +2746,7 @@ pQueryUTxOFilter = ] pQueryUTxOByAddress :: Parser QueryUTxOFilter - pQueryUTxOByAddress = QueryUTxOByAddress . Set.fromList <$> some pByAddress + pQueryUTxOByAddress = QueryUTxOByAddress . fromList <$> some pByAddress pByAddress :: Parser AddressAny pByAddress = @@ -2759,7 +2758,7 @@ pQueryUTxOFilter = ] pQueryUTxOByTxIn :: Parser QueryUTxOFilter - pQueryUTxOByTxIn = QueryUTxOByTxIn . Set.fromList <$> some pByTxIn + pQueryUTxOByTxIn = QueryUTxOByTxIn . fromList <$> some pByTxIn pByTxIn :: Parser TxIn pByTxIn = diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs index d0e5b8ed0a..1a6e2edf23 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs @@ -370,7 +370,7 @@ generateShelleyNodeSecrets shelleyDelegateKeys shelleyGenesisvkeys = do -> (Hash GenesisKey, (Hash GenesisDelegateKey, Hash VrfKey)) hashKeys (genesis, delegate, vrf) = (verificationKeyHash genesis, (verificationKeyHash delegate, verificationKeyHash vrf)) delegateMap :: Map (Hash GenesisKey) (Hash GenesisDelegateKey, Hash VrfKey) - delegateMap = Map.fromList . map hashKeys $ combinedMap + delegateMap = fromList . map hashKeys $ combinedMap return (delegateMap, vrfKeys, kesKeys, opCerts) @@ -806,7 +806,7 @@ updateOutputTemplate L.Coin minUtxoVal = sgProtocolParams ^. L.ppMinUTxOValueL shelleyDelKeys = - Map.fromList + fromList [ (gh, L.GenDelegPair gdh h) | ( GenesisKeyHash gh , (GenesisDelegateKeyHash gdh, VrfKeyHash h) @@ -956,7 +956,7 @@ buildPoolParams nw dir index specifiedRelays = do lookupPoolRelay m = case index of Nothing -> mempty - Just index' -> maybe mempty Seq.fromList (Map.lookup index' m) + Just index' -> maybe mempty fromList (Map.lookup index' m) strIndex = maybe "" show index poolColdVKF = File $ dir "cold" ++ strIndex ++ ".vkey" @@ -1133,7 +1133,7 @@ updateTemplate L.Coin minUtxoVal = sgProtocolParams template ^. L.ppMinUTxOValueL shelleyDelKeys = - Map.fromList + fromList [ (gh, L.GenDelegPair gdh h) | ( GenesisKeyHash gh , (GenesisDelegateKeyHash gdh, VrfKeyHash h) @@ -1218,7 +1218,7 @@ readGenDelegsMap gendir deldir = do (Hash GenesisKey) (Hash GenesisDelegateKey, Hash VrfKey) delegsMap = - Map.fromList + fromList [ (gh, (dh, vh)) | (g, (d, v)) <- Map.elems combinedMap , let gh = verificationKeyHash g @@ -1243,7 +1243,7 @@ readGenesisKeys gendir = do , takeExtension file == ".vkey" ] firstExceptT GenesisCmdTextEnvReadFileError $ - Map.fromList + fromList <$> sequence [ (,) ix <$> readKey (File file) | (file, ix) <- fileIxs @@ -1268,7 +1268,7 @@ readDelegateKeys deldir = do , takeExtensions file == ".vkey" ] firstExceptT GenesisCmdTextEnvReadFileError $ - Map.fromList + fromList <$> sequence [ (,) ix <$> readKey (File file) | (file, ix) <- fileIxs @@ -1293,7 +1293,7 @@ readDelegateVrfKeys deldir = do , takeExtensions file == ".vrf.vkey" ] firstExceptT GenesisCmdTextEnvReadFileError $ - Map.fromList + fromList <$> sequence [ (,) ix <$> readKey (File file) | (file, ix) <- fileIxs diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis/CreateTestnetData.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis/CreateTestnetData.hs index f12c6c7588..d7e8514470 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis/CreateTestnetData.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis/CreateTestnetData.hs @@ -58,7 +58,7 @@ import Data.Bifunctor (Bifunctor (..)) import qualified Data.ByteString.Lazy.Char8 as LBS import Data.ListMap (ListMap (..)) import qualified Data.ListMap as ListMap -import Data.Map.Strict (Map, fromList, toList) +import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map import Data.Maybe (fromMaybe) import qualified Data.Sequence.Strict as Seq @@ -66,6 +66,7 @@ import Data.String (fromString) import qualified Data.Text as Text import Data.Tuple (swap) import Data.Word (Word64) +import GHC.Exts (IsList (..)) import GHC.Generics (Generic) import GHC.Num (Natural) import Lens.Micro ((^.)) @@ -627,7 +628,7 @@ buildPoolParams nw dir index specifiedRelays = do } where lookupPoolRelay :: Map Word [L.StakePoolRelay] -> Seq.StrictSeq L.StakePoolRelay - lookupPoolRelay m = Seq.fromList $ Map.findWithDefault [] index m + lookupPoolRelay m = fromList $ Map.findWithDefault [] index m poolColdVKF = File $ dir "cold.vkey" poolVrfVKF = File $ dir "vrf.vkey" poolRewardVKF = File $ dir "staking-reward.vkey" @@ -754,7 +755,7 @@ updateOutputTemplate where L.Coin minUtxoVal = sgProtocolParams ^. L.ppMinUTxOValueL shelleyDelKeys = - Map.fromList + fromList [ (gh, L.GenDelegPair gdh h) | ( GenesisKeyHash gh , (GenesisDelegateKeyHash gdh, VrfKeyHash h) @@ -811,7 +812,7 @@ readGenDelegsMap genesisKeys delegateKeys delegateVrfKeys = do (Hash GenesisKey) (Hash GenesisDelegateKey, Hash VrfKey) delegsMap = - Map.fromList + fromList [ (gh, (dh, vh)) | (g, (d, v)) <- Map.elems combinedMap , let gh = verificationKeyHash g @@ -832,7 +833,7 @@ readKeys -> ExceptT GenesisCmdError IO (Map k a) readKeys asType genesisVKeys = do firstExceptT GenesisCmdTextEnvReadFileError $ - Map.fromList + fromList <$> sequence [ (,) ix <$> readKey (File file) | (ix, file) <- toList genesisVKeys diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance.hs index 328cefd02c..18bd606d4d 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance.hs @@ -31,7 +31,7 @@ import Cardano.CLI.Types.Errors.GovernanceCmdError import Control.Monad import Data.Function -import qualified Data.Map.Strict as Map +import GHC.Exts (IsList (..)) runGovernanceCmds :: () @@ -84,7 +84,7 @@ runGovernanceMIRCertificatePayStakeAddrs w mirPot sAddrs rwdAmts oFp = do let sCreds = map stakeAddressCredential sAddrs mirTarget = L.StakeAddressesMIR $ - Map.fromList + fromList [ (toShelleyStakeCredential scred, L.toDeltaCoin rwdAmt) | (scred, rwdAmt) <- zip sCreds rwdAmts ] diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs index 69a4484253..2302e18836 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs @@ -699,7 +699,7 @@ runQueryPoolStateCmd let poolFilter = case allOrOnlyPoolIds of All -> Nothing - Only poolIds -> Just $ Set.fromList poolIds + Only poolIds -> Just $ fromList poolIds result <- lift (queryPoolState beo poolFilter) @@ -836,7 +836,7 @@ runQueryStakeSnapshotCmd let poolFilter = case allOrOnlyPoolIds of All -> Nothing - Only poolIds -> Just $ Set.fromList poolIds + Only poolIds -> Just $ fromList poolIds beo <- requireEon BabbageEra era @@ -1104,16 +1104,17 @@ writePoolState mOutFile serialisedCurrentEpochState = do pure (decodePoolState serialisedCurrentEpochState) & onLeft (left . QueryCmdPoolStateDecodeError) - let hks = + let hks :: [L.KeyHash L.StakePool StandardCrypto] + hks = toList $ - Set.fromList $ + fromList @(Set (L.KeyHash L.StakePool StandardCrypto)) $ Map.keys (L.psStakePoolParams poolState) <> Map.keys (L.psFutureStakePoolParams poolState) <> Map.keys (L.psRetiring poolState) let poolStates :: Map (L.KeyHash 'L.StakePool StandardCrypto) (Params StandardCrypto) poolStates = - Map.fromList $ + fromList $ hks <&> ( \hk -> ( hk @@ -1644,13 +1645,13 @@ runQueryDRepState let drepHashSources = case drepHashSources' of All -> []; Only l -> l drepCreds <- modifyError QueryCmdDRepKeyError $ mapM readDRepCredential drepHashSources - drepState <- runQuery localNodeConnInfo target $ queryDRepState eon $ Set.fromList drepCreds + drepState <- runQuery localNodeConnInfo target $ queryDRepState eon $ fromList drepCreds drepStakeDistribution <- case includeStake of Cmd.WithStake -> runQuery localNodeConnInfo target $ - queryDRepStakeDistribution eon (Set.fromList $ L.DRepCredential <$> drepCreds) + queryDRepStakeDistribution eon (fromList $ L.DRepCredential <$> drepCreds) Cmd.NoStake -> return mempty let assocs :: [(L.Credential L.DRepRole StandardCrypto, L.DRepState StandardCrypto)] = Map.assocs drepState @@ -1694,7 +1695,7 @@ runQueryDRepStakeDistribution drepHashSources = case drepHashSources' of All -> [] Only l -> l - dreps <- Set.fromList <$> mapM drepFromSource drepHashSources + dreps <- fromList <$> mapM drepFromSource drepHashSources drepStakeDistribution <- runQuery localNodeConnInfo target $ queryDRepStakeDistribution eon dreps writeOutput mOutFile $ @@ -1720,16 +1721,16 @@ runQueryCommitteeMembersState let coldKeysFromVerKeyHashOrFile = modifyError QueryCmdCommitteeColdKeyError . readVerificationKeyOrHashOrFileOrScriptHash AsCommitteeColdKey unCommitteeColdKeyHash - coldKeys <- Set.fromList <$> mapM coldKeysFromVerKeyHashOrFile coldCredKeys + coldKeys <- fromList <$> mapM coldKeysFromVerKeyHashOrFile coldCredKeys let hotKeysFromVerKeyHashOrFile = modifyError QueryCmdCommitteeHotKeyError . readVerificationKeyOrHashOrFileOrScriptHash AsCommitteeHotKey unCommitteeHotKeyHash - hotKeys <- Set.fromList <$> mapM hotKeysFromVerKeyHashOrFile hotCredKeys + hotKeys <- fromList <$> mapM hotKeysFromVerKeyHashOrFile hotCredKeys committeeState <- runQuery localNodeConnInfo target $ - queryCommitteeMembersState eon coldKeys hotKeys (Set.fromList memberStatuses) + queryCommitteeMembersState eon coldKeys hotKeys (fromList memberStatuses) writeOutput mOutFile $ A.toJSON committeeState runQueryTreasuryValue diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs index d2a01e37dc..b62cd7c91c 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs @@ -65,7 +65,7 @@ import qualified Data.ByteString as Data.Bytestring import qualified Data.ByteString.Char8 as BS import qualified Data.ByteString.Lazy.Char8 as LBS import Data.Data ((:~:) (..)) -import Data.Foldable (Foldable (..)) +import qualified Data.Foldable as Foldable import Data.Function ((&)) import qualified Data.List as List import Data.Map.Strict (Map) @@ -76,6 +76,7 @@ import qualified Data.Set as Set import qualified Data.Text as Text import qualified Data.Text.IO as Text import Data.Type.Equality (TestEquality (..)) +import GHC.Exts (IsList (..)) import Lens.Micro ((^.)) import qualified System.Exit as IO import qualified System.IO as IO @@ -198,7 +199,7 @@ runTransactionBuildCmd <$> readTxGovernanceActions eon proposalFiles -- the same collateral input can be used for several plutus scripts - let filteredTxinsc = toList $ Set.fromList txinsc + let filteredTxinsc = toList @(Set _) $ fromList txinsc let allReferenceInputs = getAllReferenceInputs @@ -376,7 +377,7 @@ runTransactionBuildEstimateCmd -- TODO change type txOuts <- mapM (toTxOutInAnyEra sbe) txouts -- the same collateral input can be used for several plutus scripts - let filteredTxinsc = toList $ Set.fromList txInsCollateral + let filteredTxinsc = toList @(Set _) $ fromList txInsCollateral -- Conway related votingProceduresAndMaybeScriptWits <- @@ -429,12 +430,12 @@ runTransactionBuildEstimateCmd -- TODO change type votingProceduresAndMaybeScriptWits proposals currentTreasuryValueAndDonation - let stakeCredentialsToDeregisterMap = Map.fromList $ catMaybes [getStakeDeregistrationInfo cert | (cert, _) <- certsAndMaybeScriptWits] - drepsToDeregisterMap = Map.fromList $ catMaybes [getDRepDeregistrationInfo cert | (cert, _) <- certsAndMaybeScriptWits] - poolsToDeregister = Set.fromList $ catMaybes [getPoolDeregistrationInfo cert | (cert, _) <- certsAndMaybeScriptWits] + let stakeCredentialsToDeregisterMap = fromList $ catMaybes [getStakeDeregistrationInfo cert | (cert, _) <- certsAndMaybeScriptWits] + drepsToDeregisterMap = fromList $ catMaybes [getDRepDeregistrationInfo cert | (cert, _) <- certsAndMaybeScriptWits] + poolsToDeregister = fromList $ catMaybes [getPoolDeregistrationInfo cert | (cert, _) <- certsAndMaybeScriptWits] totCol = fromMaybe 0 plutusCollateral pScriptExecUnits = - Map.fromList + fromList [ (sWitIndex, execUnits) | (sWitIndex, AnyScriptWitness (PlutusScriptWitness _ _ _ _ _ execUnits)) <- collectTxBodyScriptWitnesses sbe txBodyContent @@ -615,7 +616,7 @@ runTransactionBuildRawCmd txOuts <- mapM (toTxOutInAnyEra eon) txouts -- the same collateral input can be used for several plutus scripts - let filteredTxinsc = toList $ Set.fromList txInsCollateral + let filteredTxinsc = toList @(Set _) $ fromList txInsCollateral -- Conway related votingProceduresAndMaybeScriptWits <- @@ -1072,7 +1073,7 @@ convertCertificates sbe certsAndScriptWitnesses = TxCertificates sbe certs $ BuildTxWith reqWits where certs = map fst certsAndScriptWitnesses - reqWits = Map.fromList $ mapMaybe convert certsAndScriptWitnesses + reqWits = fromList $ mapMaybe convert certsAndScriptWitnesses convert :: (Certificate era, Maybe (ScriptWitness WitCtxStake era)) -> Maybe (StakeCredential, Witness WitCtxStake era) @@ -1160,16 +1161,16 @@ getAllReferenceInputs votesWitByRefInputs = [getReferenceInput sWit | (_, Just sWit) <- votingProceduresAndMaybeScriptWits] propsWitByRefInputs = [getReferenceInput sWit | (_, Just sWit) <- propProceduresAnMaybeScriptWits] - catMaybes $ - concat - [ txinsWitByRefInputs - , mintingRefInputs - , certsWitByRefInputs - , withdrawalsWitByRefInputs - , votesWitByRefInputs - , propsWitByRefInputs - , map Just readOnlyRefIns - ] + concatMap + catMaybes + [ txinsWitByRefInputs + , mintingRefInputs + , certsWitByRefInputs + , withdrawalsWitByRefInputs + , votesWitByRefInputs + , propsWitByRefInputs + , map Just readOnlyRefIns + ] where getReferenceInput :: ScriptWitness witctx era -> Maybe TxIn @@ -1333,10 +1334,10 @@ createTxMintValue era (val, scriptWitnesses) = -- The set of policy ids for which we need witnesses: let witnessesNeededSet :: Set PolicyId witnessesNeededSet = - Set.fromList [pid | (AssetId pid _, _) <- valueToList val] + fromList [pid | (AssetId pid _, _) <- valueToList val] let witnessesProvidedMap :: Map PolicyId (ScriptWitness WitCtxMint era) - witnessesProvidedMap = Map.fromList $ gatherMintingWitnesses scriptWitnesses + witnessesProvidedMap = fromList $ gatherMintingWitnesses scriptWitnesses witnessesProvidedSet = Map.keysSet witnessesProvidedMap -- Check not too many, nor too few: @@ -1519,8 +1520,8 @@ runTransactionCalculateMinFeeCmd shelleyBasedEraConstraints sbe $ calculateByronWitnessFees (lpparams ^. L.ppMinFeeAL) nByronKeyWitnesses - let L.Coin fee = shelleyfee + byronfee - textToWrite = Text.pack ((show fee :: String) <> " Lovelace") + let fee = shelleyfee + byronfee + textToWrite = docToText $ pretty fee jsonToWrite = encodePretty $ Aeson.object ["fee" .= fee] case (newOutputFormat outputFormat outFile, outFile) of @@ -1614,7 +1615,7 @@ partitionSomeWitnesses -> ( [ShelleyBootstrapWitnessSigningKeyData] , [ShelleyWitnessSigningKey] ) -partitionSomeWitnesses = reversePartitionedWits . foldl' go mempty +partitionSomeWitnesses = reversePartitionedWits . Foldable.foldl' go mempty where reversePartitionedWits (bw, skw) = (reverse bw, reverse skw) diff --git a/cardano-cli/src/Cardano/CLI/Json/Friendly.hs b/cardano-cli/src/Cardano/CLI/Json/Friendly.hs index b9cf5c6fe1..0d7db1f89a 100644 --- a/cardano-cli/src/Cardano/CLI/Json/Friendly.hs +++ b/cardano-cli/src/Cardano/CLI/Json/Friendly.hs @@ -5,6 +5,9 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeOperators #-} +{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} + +{-# HLINT ignore "Redundant bracket" #-} -- | User-friendly pretty-printing for textual user interfaces (TUI) module Cardano.CLI.Json.Friendly @@ -39,7 +42,7 @@ import Cardano.Api as Api import Cardano.Api.Byron (KeyWitness (ByronKeyWitness)) import qualified Cardano.Api.Ledger as L import Cardano.Api.Shelley (Address (ShelleyAddress), Hash (..), - KeyWitness (ShelleyBootstrapWitness, ShelleyKeyWitness), Proposal (Proposal), + KeyWitness (ShelleyBootstrapWitness, ShelleyKeyWitness), Proposal (..), ShelleyLedgerEra, StakeAddress (..), fromShelleyPaymentCredential, fromShelleyStakeReference, toShelleyStakeCredential) @@ -62,10 +65,9 @@ import Data.Char (isAscii) import Data.Function ((&)) import Data.Functor ((<&>)) import qualified Data.Map.Strict as Map -import Data.Maybe (catMaybes, isJust, maybeToList) +import Data.Maybe import Data.Ratio (numerator) import qualified Data.Text as Text -import qualified Data.Vector as Vector import Data.Yaml (array) import Data.Yaml.Pretty (setConfCompare) import qualified Data.Yaml.Pretty as Yaml @@ -73,9 +75,6 @@ import GHC.Exts (IsList (..)) import GHC.Real (denominator) import GHC.Unicode (isAlphaNum) -{- HLINT ignore "Redundant bracket" -} -{- HLINT ignore "Move brackets to avoid $" -} - data FriendlyFormat = FriendlyJson | FriendlyYaml viewOutputFormatToFriendlyFormat :: ViewOutputFormat -> FriendlyFormat @@ -251,7 +250,7 @@ friendlyTxBodyImpl Nothing -> [] Just (Featured _ TxProposalProceduresNone) -> [] Just (Featured _ (TxProposalProcedures lProposals _witnesses)) -> - ["governance actions" .= (friendlyLedgerProposals cOnwards $ toList lProposals)] + ["governance actions" .= friendlyLedgerProposals cOnwards (toList lProposals)] ) ) ++ ( monoidForEraInEon @ConwayEraOnwards @@ -277,7 +276,7 @@ friendlyTxBodyImpl friendlyLedgerProposals :: ConwayEraOnwards era -> [L.ProposalProcedure (ShelleyLedgerEra era)] -> Aeson.Value friendlyLedgerProposals cOnwards proposalProcedures = - Array $ Vector.fromList $ map (friendlyLedgerProposal cOnwards) proposalProcedures + Array $ fromList $ map (friendlyLedgerProposal cOnwards) proposalProcedures friendlyLedgerProposal :: ConwayEraOnwards era -> L.ProposalProcedure (ShelleyLedgerEra era) -> Aeson.Value @@ -703,7 +702,7 @@ friendlyFee = \case TxFeeExplicit _ fee -> friendlyLovelace fee friendlyLovelace :: L.Coin -> Aeson.Value -friendlyLovelace (L.Coin value) = String $ textShow value <> " Lovelace" +friendlyLovelace value = String $ docToText (pretty value) friendlyMintValue :: TxMintValue ViewTx era -> Aeson.Value friendlyMintValue = \case diff --git a/cardano-cli/src/Cardano/CLI/Types/Key.hs b/cardano-cli/src/Cardano/CLI/Types/Key.hs index 5fb56aa5fe..1f96066b00 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Key.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Key.hs @@ -50,9 +50,9 @@ import Cardano.CLI.Types.Common import Data.Bifunctor (Bifunctor (..)) import qualified Data.ByteString as BS -import qualified Data.List.NonEmpty as NE import Data.Text (Text) import qualified Data.Text.Encoding as Text +import GHC.Exts (IsList (..)) ------------------------------------------------------------------------------ -- Verification key deserialisation @@ -94,7 +94,7 @@ readVerificationKeyOrFile asType verKeyOrFile = hoistIOEither $ readKeyFile (AsVerificationKey asType) - (NE.fromList [InputFormatBech32, InputFormatHex, InputFormatTextEnvelope]) + (fromList [InputFormatBech32, InputFormatHex, InputFormatTextEnvelope]) fp -- | Read a verification key or verification key file and return a diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Genesis/Create.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Genesis/Create.hs index 49b1012715..cdec6c7ed3 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Genesis/Create.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Genesis/Create.hs @@ -42,7 +42,7 @@ parseSystemStart :: J.Value -> J.Parser String parseSystemStart = J.withObject "Object" $ \o -> o J..: "systemStart" parseHashMap :: J.Value -> J.Parser (HM.HashMap String J.Value) -parseHashMap (J.Object hm) = pure $ HM.fromList $ fmap (first J.toString) (toList hm) +parseHashMap (J.Object hm) = pure $ fromList $ fmap (first J.toString) (toList hm) parseHashMap v = J.typeMismatch "Object" v parseDelegateCount :: J.Value -> J.Parser Int @@ -134,12 +134,12 @@ hprop_golden_shelleyGenesisCreate = propertyOnce $ do -- required for stake pool rewards. -- Check uniqueness and count of hash keys - S.size (S.fromList actualHashKeys) === length actualHashKeys -- This isn't strictly necessary because we use aeson which guarantees uniqueness of keys - S.size (S.fromList actualHashKeys) === delegateCount + S.size (fromList actualHashKeys) === length actualHashKeys -- This isn't strictly necessary because we use aeson which guarantees uniqueness of keys + S.size (fromList actualHashKeys) === delegateCount -- Check uniqueness and count of hash keys - S.size (S.fromList actualDelegateKeys) === length actualDelegateKeys - S.size (S.fromList actualDelegateKeys) === delegateCount + S.size (fromList actualDelegateKeys) === length actualDelegateKeys + S.size (fromList actualDelegateKeys) === delegateCount for_ [1 .. delegateCount] $ \i -> do -- Check Genesis keys @@ -230,12 +230,12 @@ hprop_golden_shelleyGenesisCreate = propertyOnce $ do -- We don't use the entire supply so there is ada in the treasury. This is -- required for stake pool rewards. -- Check uniqueness and count of hash keys - S.size (S.fromList actualHashKeys) === length actualHashKeys -- This isn't strictly necessary because we use aeson which guarantees uniqueness of keys - S.size (S.fromList actualHashKeys) === delegateCount + S.size (fromList actualHashKeys) === length actualHashKeys -- This isn't strictly necessary because we use aeson which guarantees uniqueness of keys + S.size (fromList actualHashKeys) === delegateCount -- Check uniqueness and count of hash keys - S.size (S.fromList actualDelegateKeys) === length actualDelegateKeys - S.size (S.fromList actualDelegateKeys) === delegateCount + S.size (fromList actualDelegateKeys) === length actualDelegateKeys + S.size (fromList actualDelegateKeys) === delegateCount for_ [1 .. delegateCount] $ \i -> do -- Check Genesis keys diff --git a/cardano-cli/test/cardano-cli-test/Test/Cli/JSON.hs b/cardano-cli/test/cardano-cli-test/Test/Cli/Json.hs similarity index 93% rename from cardano-cli/test/cardano-cli-test/Test/Cli/JSON.hs rename to cardano-cli/test/cardano-cli-test/Test/Cli/Json.hs index e199661b5c..3c3c8f483e 100644 --- a/cardano-cli/test/cardano-cli-test/Test/Cli/JSON.hs +++ b/cardano-cli/test/cardano-cli-test/Test/Cli/Json.hs @@ -1,6 +1,6 @@ {-# LANGUAGE NumericUnderscores #-} -module Test.Cli.JSON +module Test.Cli.Json ( hprop_json_roundtrip_delegations_and_rewards , hprop_roundtrip_kes_period_info_output_JSON ) @@ -12,10 +12,10 @@ import Cardano.CLI.Types.Common import Cardano.CLI.Types.Output (QueryKesPeriodInfoOutput (..), createOpCertIntervalInfo) import Data.Aeson -import qualified Data.Map.Strict as Map import Data.Time import Data.Time.Clock.POSIX (posixSecondsToUTCTime) import Data.Word (Word64) +import GHC.Exts (IsList (..)) import Test.Gen.Cardano.Api.Typed (genLovelace, genSlotNo, genStakeAddress, genVerificationKeyHash) @@ -36,9 +36,9 @@ genDelegationsAndRewards = do let r = Range.constant 0 3 sAddrs <- Gen.list r genStakeAddress sLovelace <- Gen.list r genLovelace - let delegMapAmt = Map.fromList $ zip sAddrs sLovelace + let delegMapAmt = fromList $ zip sAddrs sLovelace poolIDs <- Gen.list r genPoolId - let delegMapPool = Map.fromList $ zip sAddrs poolIDs + let delegMapPool = fromList $ zip sAddrs poolIDs return $ DelegationsAndRewards (delegMapAmt, delegMapPool) genOpCertIntervalInformation :: Gen OpCertIntervalInformation