From 08cc7d5f678dd3a0c4389b15f2d2aa5f1db76427 Mon Sep 17 00:00:00 2001 From: John Ky Date: Thu, 19 Oct 2023 11:41:07 +1100 Subject: [PATCH] Delete unnecessary calls to shelleyBasedEraConstraints --- .../internal/Cardano/Api/Eon/ShelleyBasedEra.hs | 2 +- cardano-api/internal/Cardano/Api/Fees.hs | 2 +- .../Api/Governance/Actions/ProposalProcedure.hs | 2 +- cardano-api/internal/Cardano/Api/Query/Types.hs | 4 ++-- cardano-api/internal/Cardano/Api/Tx.hs | 12 ++++++------ cardano-api/internal/Cardano/Api/TxBody.hs | 16 +++++++--------- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/cardano-api/internal/Cardano/Api/Eon/ShelleyBasedEra.hs b/cardano-api/internal/Cardano/Api/Eon/ShelleyBasedEra.hs index f5a98c8247..c4ed9b0124 100644 --- a/cardano-api/internal/Cardano/Api/Eon/ShelleyBasedEra.hs +++ b/cardano-api/internal/Cardano/Api/Eon/ShelleyBasedEra.hs @@ -287,7 +287,7 @@ anyShelleyBasedEra :: () => ShelleyBasedEra era -> AnyShelleyBasedEra anyShelleyBasedEra sbe = - shelleyBasedEraConstraints sbe $ AnyShelleyBasedEra sbe + AnyShelleyBasedEra sbe -- | This pairs up some era-dependent type with a 'ShelleyBasedEra' value that -- tells us what era it is, but hides the era type. This is useful when the era diff --git a/cardano-api/internal/Cardano/Api/Fees.hs b/cardano-api/internal/Cardano/Api/Fees.hs index 9bac30a656..bc29900877 100644 --- a/cardano-api/internal/Cardano/Api/Fees.hs +++ b/cardano-api/internal/Cardano/Api/Fees.hs @@ -951,7 +951,7 @@ makeTransactionBodyAutoBalance sbe systemstart history lpp@(LedgerProtocolParame calcReturnAndTotalCollateral _ _ _ TxInsCollateralNone _ _ _ _= (TxReturnCollateralNone, TxTotalCollateralNone) calcReturnAndTotalCollateral _ _ _ _ rc@TxReturnCollateral{} tc@TxTotalCollateral{} _ _ = (rc,tc) calcReturnAndTotalCollateral retColSup fee pp' (TxInsCollateral _ collIns) txReturnCollateral txTotalCollateral cAddr (UTxO utxo') = - shelleyBasedEraConstraints sbe $ do + do let colPerc = pp' ^. Ledger.ppCollateralPercentageL -- We must first figure out how much lovelace we have committed -- as collateral and we must determine if we have enough lovelace at our diff --git a/cardano-api/internal/Cardano/Api/Governance/Actions/ProposalProcedure.hs b/cardano-api/internal/Cardano/Api/Governance/Actions/ProposalProcedure.hs index 88f133eab3..a5280f9302 100644 --- a/cardano-api/internal/Cardano/Api/Governance/Actions/ProposalProcedure.hs +++ b/cardano-api/internal/Cardano/Api/Governance/Actions/ProposalProcedure.hs @@ -162,7 +162,7 @@ createProposalProcedure -> Ledger.Anchor StandardCrypto -> Proposal era createProposalProcedure sbe nw dep (StakeKeyHash retAddrh) govAct anchor = - shelleyBasedEraConstraints sbe $ shelleyBasedEraConstraints sbe $ + shelleyBasedEraConstraints sbe $ Proposal Gov.ProposalProcedure { Gov.pProcDeposit = toShelleyLovelace dep , Gov.pProcReturnAddr = L.mkRwdAcnt nw (L.KeyHashObj retAddrh) diff --git a/cardano-api/internal/Cardano/Api/Query/Types.hs b/cardano-api/internal/Cardano/Api/Query/Types.hs index 9a61230d30..602c02e012 100644 --- a/cardano-api/internal/Cardano/Api/Query/Types.hs +++ b/cardano-api/internal/Cardano/Api/Query/Types.hs @@ -30,10 +30,10 @@ instance IsShelleyBasedEra era => FromCBOR (DebugLedgerState era) where instance IsShelleyBasedEra era => ToJSON (DebugLedgerState era) where toJSON = let sbe = shelleyBasedEra @era in - shelleyBasedEraConstraints sbe $ object . toDebugLedgerStatePair sbe + object . toDebugLedgerStatePair sbe toEncoding = let sbe = shelleyBasedEra @era in - shelleyBasedEraConstraints sbe $ Aeson.pairs . mconcat . toDebugLedgerStatePair sbe + Aeson.pairs . mconcat . toDebugLedgerStatePair sbe toDebugLedgerStatePair :: () => Aeson.KeyValue a diff --git a/cardano-api/internal/Cardano/Api/Tx.hs b/cardano-api/internal/Cardano/Api/Tx.hs index f9a6cdf6c6..66f0694183 100644 --- a/cardano-api/internal/Cardano/Api/Tx.hs +++ b/cardano-api/internal/Cardano/Api/Tx.hs @@ -273,13 +273,13 @@ instance Eq (KeyWitness era) where (==) (ByronKeyWitness wA) (ByronKeyWitness wB) = wA == wB - (==) (ShelleyBootstrapWitness sbe wA) - (ShelleyBootstrapWitness _ wB) = - shelleyBasedEraConstraints sbe $ wA == wB + (==) (ShelleyBootstrapWitness _ wA) + (ShelleyBootstrapWitness _ wB) = + wA == wB - (==) (ShelleyKeyWitness sbe wA) - (ShelleyKeyWitness _ wB) = - shelleyBasedEraConstraints sbe $ wA == wB + (==) (ShelleyKeyWitness _ wA) + (ShelleyKeyWitness _ wB) = + wA == wB (==) _ _ = False diff --git a/cardano-api/internal/Cardano/Api/TxBody.hs b/cardano-api/internal/Cardano/Api/TxBody.hs index 42681ee074..8f12256f41 100644 --- a/cardano-api/internal/Cardano/Api/TxBody.hs +++ b/cardano-api/internal/Cardano/Api/TxBody.hs @@ -1547,8 +1547,7 @@ instance IsCardanoEra era => SerialiseAsCBOR (TxBody era) where recoverBytes txbody serialiseToCBOR (ShelleyTxBody sbe txbody txscripts redeemers txmetadata scriptValidity) = - shelleyBasedEraConstraints sbe $ - serialiseShelleyBasedTxBody sbe txbody txscripts redeemers txmetadata scriptValidity + serialiseShelleyBasedTxBody sbe txbody txscripts redeemers txmetadata scriptValidity deserialiseFromCBOR _ bs = caseByronOrShelleyBasedEra @@ -2632,7 +2631,7 @@ convReturnCollateral convReturnCollateral sbe txReturnCollateral = case txReturnCollateral of TxReturnCollateralNone -> SNothing - TxReturnCollateral _ colTxOut -> SJust $ shelleyBasedEraConstraints sbe $ toShelleyTxOutAny sbe colTxOut + TxReturnCollateral _ colTxOut -> SJust $ toShelleyTxOutAny sbe colTxOut convTotalCollateral :: TxTotalCollateral era -> StrictMaybe Ledger.Coin convTotalCollateral txTotalCollateral = @@ -2650,10 +2649,9 @@ convCertificates :: ShelleyBasedEra era -> TxCertificates build era -> Seq.StrictSeq (Shelley.TxCert (ShelleyLedgerEra era)) -convCertificates sbe txCertificates = shelleyBasedEraConstraints sbe $ - case txCertificates of - TxCertificatesNone -> Seq.empty - TxCertificates _ cs _ -> Seq.fromList (map toShelleyCertificate cs) +convCertificates _ = \case + TxCertificatesNone -> Seq.empty + TxCertificates _ cs _ -> Seq.fromList (map toShelleyCertificate cs) convWithdrawals :: TxWithdrawals build era -> L.Withdrawals StandardCrypto @@ -3351,7 +3349,7 @@ fromAlonzoRdmrPtr (Alonzo.RdmrPtr tag n) = collectTxBodyScriptWitnesses :: forall era. ShelleyBasedEra era -> TxBodyContent BuildTx era -> [(ScriptWitnessIndex, AnyScriptWitness era)] -collectTxBodyScriptWitnesses sbe TxBodyContent { +collectTxBodyScriptWitnesses _ TxBodyContent { txIns, txWithdrawals, txCertificates, @@ -3394,7 +3392,7 @@ collectTxBodyScriptWitnesses sbe TxBodyContent { -- The certs are indexed in list order | (ix, cert) <- zip [0..] certs , ScriptWitness _ witness <- maybeToList $ do - stakecred <- shelleyBasedEraConstraints sbe $ selectStakeCredential cert + stakecred <- selectStakeCredential cert Map.lookup stakecred witnesses ]