Skip to content

Commit c914343

Browse files
committed
Remove redundant AsType constructors usages
1 parent a3dde17 commit c914343

File tree

4 files changed

+31
-23
lines changed

4 files changed

+31
-23
lines changed

cardano-node/src/Cardano/Node/Protocol/Shelley.hs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ readLeaderCredentialsSingleton
150150
shelleyKESFile = Just kesFile
151151
} = do
152152
vrfSKey <-
153-
firstExceptT FileError (newExceptT $ readFileTextEnvelope (AsSigningKey AsVrfKey) (File vrfFile))
153+
firstExceptT FileError (newExceptT $ readFileTextEnvelope (File vrfFile))
154154

155155
(opCert, kesSKey) <- opCertKesKeyCheck (File kesFile) (File opCertFile)
156156

@@ -172,9 +172,9 @@ opCertKesKeyCheck
172172
-> ExceptT PraosLeaderCredentialsError IO (OperationalCertificate, SigningKey KesKey)
173173
opCertKesKeyCheck kesFile certFile = do
174174
opCert <-
175-
firstExceptT FileError (newExceptT $ readFileTextEnvelope AsOperationalCertificate certFile)
175+
firstExceptT FileError (newExceptT $ readFileTextEnvelope certFile)
176176
kesSKey <-
177-
firstExceptT FileError (newExceptT $ readFileTextEnvelope (AsSigningKey AsKesKey) kesFile)
177+
firstExceptT FileError (newExceptT $ readFileTextEnvelope kesFile)
178178
let opCertSpecifiedKesKeyhash = verificationKeyHash $ getHotKey opCert
179179
suppliedKesKeyHash = verificationKeyHash $ getVerificationKey kesSKey
180180
-- Specified KES key in operational certificate should match the one
@@ -201,9 +201,9 @@ readLeaderCredentialsBulk ProtocolFilepaths { shelleyBulkCredsFile = mfp } =
201201
-> ExceptT PraosLeaderCredentialsError IO (ShelleyLeaderCredentials StandardCrypto)
202202
parseShelleyCredentials ShelleyCredentials { scCert, scVrf, scKes } = do
203203
mkPraosLeaderCredentials
204-
<$> parseEnvelope AsOperationalCertificate scCert
205-
<*> parseEnvelope (AsSigningKey AsVrfKey) scVrf
206-
<*> parseEnvelope (AsSigningKey AsKesKey) scKes
204+
<$> parseEnvelope scCert
205+
<*> parseEnvelope scVrf
206+
<*> parseEnvelope scKes
207207

208208
readBulkFile
209209
:: Maybe FilePath
@@ -246,12 +246,11 @@ mkPraosLeaderCredentials
246246

247247
parseEnvelope ::
248248
HasTextEnvelope a
249-
=> AsType a
250-
-> (TextEnvelope, String)
249+
=> (TextEnvelope, String)
251250
-> ExceptT PraosLeaderCredentialsError IO a
252-
parseEnvelope as (te, loc) =
251+
parseEnvelope (te, loc) =
253252
firstExceptT (FileError . Api.FileError loc) . hoistEither $
254-
deserialiseFromTextEnvelope as te
253+
deserialiseFromTextEnvelope te
255254

256255

257256
------------------------------------------------------------------------------

cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Query.hs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ hprop_cli_queries = integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> H.
128128
-- leadership-schedule
129129
do
130130
let spoKeys = Defaults.defaultSpoKeys 1
131-
spoVerificationKey :: VerificationKey StakePoolKey <- readVerificationKeyFromFile AsStakePoolKey work $ verificationKey $ poolNodeKeysCold spoKeys
131+
spoVerificationKey :: VerificationKey StakePoolKey <- readVerificationKeyFromFile work $ verificationKey $ poolNodeKeysCold spoKeys
132132
H.noteM_ $ execCli' execConfig [ eraName, "query", "leadership-schedule"
133133
, "--genesis", shelleyGeneisFile
134134
, "--stake-pool-verification-key", T.unpack $ serialiseToBech32 spoVerificationKey
@@ -244,7 +244,7 @@ hprop_cli_queries = integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> H.
244244
fileQueryAmount <- H.evalMaybe $ fileQueryResult ^? Aeson.nth 0 . Aeson.nth 1 . Aeson._Number
245245

246246
-- Query individual SPO using SPOs bech32 of key and compare to previous result
247-
delegatorVKey :: VerificationKey StakePoolKey <- readVerificationKeyFromFile AsStakePoolKey work spoKey
247+
delegatorVKey :: VerificationKey StakePoolKey <- readVerificationKeyFromFile work spoKey
248248
keyQueryResult :: Aeson.Value <- execCliStdoutToJson execConfig [ eraName, "query", "spo-stake-distribution"
249249
, "--spo-verification-key", T.unpack $ serialiseToBech32 delegatorVKey
250250
]
@@ -449,6 +449,10 @@ hprop_cli_queries = integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> H.
449449
-- TODO @cardano-cli team
450450
pure ()
451451

452+
TestQueryEraHistoryCmd -> do
453+
-- TODO @cardano-cli team
454+
pure ()
455+
452456
where
453457
-- | Wait for the part of the epoch when futurePParams are known
454458
waitForFuturePParamsToStabilise
@@ -482,13 +486,19 @@ hprop_cli_queries = integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> H.
482486
minSlotInThisEpochToWaitTo = firstSlotOfEpoch + slotsInEpochToWaitOut + 1
483487
in slotNo >= minSlotInThisEpochToWaitTo
484488

485-
readVerificationKeyFromFile :: (HasCallStack, MonadIO m, MonadCatch m, MonadTest m, HasTextEnvelope (VerificationKey keyrole), SerialiseAsBech32 (VerificationKey keyrole))
486-
=> AsType keyrole
487-
-> FilePath
489+
readVerificationKeyFromFile
490+
:: ( HasCallStack
491+
, MonadIO m
492+
, MonadCatch m
493+
, MonadTest m
494+
, HasTextEnvelope (VerificationKey keyrole)
495+
, SerialiseAsBech32 (VerificationKey keyrole)
496+
)
497+
=> FilePath
488498
-> File content direction
489499
-> m (VerificationKey keyrole)
490-
readVerificationKeyFromFile asKey work =
491-
H.evalEitherM . liftIO . runExceptT . readVerificationKeyOrFile asKey . VerificationKeyFilePath . File . (work </>) . unFile
500+
readVerificationKeyFromFile work =
501+
H.evalEitherM . liftIO . runExceptT . readVerificationKeyOrFile . VerificationKeyFilePath . File . (work </>) . unFile
492502

493503
_verificationStakeKeyToStakeAddress :: Int -> VerificationKey StakeKey -> StakeAddress
494504
_verificationStakeKeyToStakeAddress testnetMagic delegatorVKey =

cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Transaction.hs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ hprop_transaction = integrationRetryWorkspace 2 "simple transaction build" $ \te
5252

5353
let
5454
sbe = ShelleyBasedEraConway
55-
txEra = AsConwayEra
5655
era = toCardanoEra sbe
5756
cEra = AnyCardanoEra era
5857
tempBaseAbsPath = makeTmpBaseAbsPath $ TmpAbsolutePath tempAbsPath'
@@ -93,8 +92,8 @@ hprop_transaction = integrationRetryWorkspace 2 "simple transaction build" $ \te
9392
, "--out-file", txbodyFp
9493
]
9594
cddlUnwitnessedTx <- H.readJsonFileOk txbodyFp
96-
apiTx <- H.evalEither $ deserialiseFromTextEnvelope (AsTx txEra) cddlUnwitnessedTx
97-
let txFee = L.unCoin $ extractTxFee apiTx
95+
apiTx <- H.evalEither $ deserialiseFromTextEnvelope cddlUnwitnessedTx
96+
let txFee = L.unCoin $ extractTxFee sbe apiTx
9897

9998
-- This is the current calculated fee.
10099
-- It's a sanity check to see if anything has
@@ -133,6 +132,6 @@ hprop_transaction = integrationRetryWorkspace 2 "simple transaction build" $ \te
133132
txOutValue :: TxOut ctx era -> TxOutValue era
134133
txOutValue (TxOut _ v _ _) = v
135134

136-
extractTxFee :: Tx era -> L.Coin
137-
extractTxFee (ShelleyTx sbe ledgerTx) =
135+
extractTxFee :: ShelleyBasedEra era -> Tx era -> L.Coin
136+
extractTxFee _ (ShelleyTx sbe ledgerTx) =
138137
shelleyBasedEraConstraints sbe $ ledgerTx ^. (L.bodyTxL . L.feeTxBodyL)

cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/NoConfidence.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ hprop_gov_no_confidence = integrationWorkspace "no-confidence" $ \tempAbsBasePat
9797

9898
CommitteeColdKeyHash comKeyHash1 <-
9999
H.evalEither
100-
$ deserialiseFromRawBytesHex (AsHash AsCommitteeColdKey)
100+
$ deserialiseFromRawBytesHex
101101
$ BSC.pack comKeyHash1Str
102102

103103
let comKeyCred1 = L.KeyHashObj comKeyHash1

0 commit comments

Comments
 (0)