Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete unnecessary calls to shelleyBasedEraConstraints #325

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cardano-api/internal/Cardano/Api/Eon/ShelleyBasedEra.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cardano-api/internal/Cardano/Api/Fees.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions cardano-api/internal/Cardano/Api/Query/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions cardano-api/internal/Cardano/Api/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 7 additions & 9 deletions cardano-api/internal/Cardano/Api/TxBody.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 =
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
]

Expand Down