Skip to content

Commit 4e83260

Browse files
committed
Remove HasCallStack from Dijkstra-era placeholders, fix error messages
Dijkstra-era error placeholders don't need HasCallStack since the error messages already identify the function. Fix error messages that were missing the function name (fromShelleyMultiSig, fromAllegraTimelock, getPlutusDatum, getAnchorDataFromCertificate).
1 parent f7a6ab5 commit 4e83260

8 files changed

Lines changed: 17 additions & 32 deletions

File tree

cardano-api/src/Cardano/Api/Certificate/Internal.hs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ import Data.Text qualified as Text
109109
import Data.Text.Encoding qualified as Text
110110
import Data.Typeable
111111
import GHC.Exts (IsList (..), fromString)
112-
import GHC.Stack (HasCallStack)
113112
import Network.Socket (PortNumber)
114113

115114
-- ----------------------------------------------------------------------------
@@ -813,8 +812,7 @@ instance Error AnchorDataFromCertificateError where
813812
-- | Get anchor data url and hash from a certificate. A return value of `Nothing`
814813
-- means that the certificate does not contain anchor data.
815814
getAnchorDataFromCertificate
816-
:: HasCallStack
817-
=> Certificate era
815+
:: Certificate era
818816
-> Either AnchorDataFromCertificateError (Maybe Ledger.Anchor)
819817
getAnchorDataFromCertificate c =
820818
case c of
@@ -828,7 +826,7 @@ getAnchorDataFromCertificate c =
828826
Ledger.RetirePoolTxCert _ _ -> return Nothing
829827
Ledger.GenesisDelegTxCert{} -> return Nothing
830828
Ledger.MirTxCert _ -> return Nothing
831-
_ -> error "dijkstra"
829+
_ -> error "getAnchorDataFromCertificate: Dijkstra era not supported"
832830
ConwayCertificate ceo ccert ->
833831
conwayEraOnwardsConstraints ceo $
834832
case ccert of
@@ -845,7 +843,7 @@ getAnchorDataFromCertificate c =
845843
Ledger.UpdateDRepTxCert _ mAnchor -> return $ Ledger.strictMaybeToMaybe mAnchor
846844
Ledger.AuthCommitteeHotKeyTxCert _ _ -> return Nothing
847845
Ledger.ResignCommitteeColdTxCert _ mAnchor -> return $ Ledger.strictMaybeToMaybe mAnchor
848-
_ -> error "dijkstra"
846+
_ -> error "getAnchorDataFromCertificate: Dijkstra era not supported"
849847
where
850848
anchorDataFromPoolMetadata
851849
:: MonadError AnchorDataFromCertificateError m

cardano-api/src/Cardano/Api/Experimental/Tx/Internal/AnyWitness.hs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import Cardano.Api.Tx.Internal.TxIn
3131
import Cardano.Ledger.Core qualified as L
3232

3333
import Data.Type.Equality
34-
import GHC.Stack (HasCallStack)
3534

3635
-- | Here we consider three types of witnesses in Cardano:
3736
-- * key witnesses
@@ -122,11 +121,11 @@ getAnyWitnessScript ss@(AnySimpleScriptWitness{}) = getAnyWitnessSimpleScript ss
122121
getAnyWitnessScript ps@(AnyPlutusScriptWitness{}) = getAnyWitnessPlutusScript ps
123122

124123
getPlutusDatum
125-
:: HasCallStack => L.SLanguage lang -> PlutusScriptDatum lang purpose -> Maybe HashableScriptData
124+
:: L.SLanguage lang -> PlutusScriptDatum lang purpose -> Maybe HashableScriptData
126125
getPlutusDatum L.SPlutusV1 (SpendingScriptDatum d) = Just d
127126
getPlutusDatum L.SPlutusV2 (SpendingScriptDatum d) = Just d
128127
getPlutusDatum L.SPlutusV3 (SpendingScriptDatum d) = d
129-
getPlutusDatum L.SPlutusV4 (SpendingScriptDatum _d) = error "dijkstra"
128+
getPlutusDatum L.SPlutusV4 (SpendingScriptDatum _d) = error "getPlutusDatum: Dijkstra era not supported"
130129
getPlutusDatum _ InlineDatum = Nothing
131130
getPlutusDatum _ NoScriptDatum = Nothing
132131

cardano-api/src/Cardano/Api/Experimental/Tx/Internal/BodyContent/New.hs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,11 @@ import Data.Sequence.Strict qualified as Seq
143143
import Data.Set (Set)
144144
import Data.Set qualified as Set
145145
import GHC.Exts (IsList (..))
146-
import GHC.Stack (HasCallStack)
147146
import Lens.Micro
148147

149148
makeUnsignedTx
150149
:: forall era
151-
. HasCallStack
152-
=> Era era
150+
. Era era
153151
-> TxBodyContent (LedgerEra era)
154152
-> UnsignedTx (LedgerEra era)
155153
makeUnsignedTx DijkstraEra _ = error "makeUnsignedTx: Dijkstra era not supported yet"
@@ -675,8 +673,7 @@ extractWitnessableWithdrawals txWithDrawals =
675673

676674
extractWitnessableVotes
677675
:: forall era
678-
. HasCallStack
679-
=> IsEra era
676+
. IsEra era
680677
=> Maybe (TxVotingProcedures (LedgerEra era))
681678
-> [(Witnessable VoterItem (LedgerEra era), AnyWitness (LedgerEra era))]
682679
extractWitnessableVotes Nothing = []

cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Certificate.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ import Data.Array.Byte (ByteArray)
5959
import Data.ByteString.Short qualified as SBS
6060
import Data.MemPack.Buffer (byteArrayToShortByteString)
6161
import Data.String (IsString (fromString))
62-
import GHC.Stack (HasCallStack)
6362

6463
makeStakeAddressDelegationCertificate
6564
:: forall era
@@ -191,8 +190,7 @@ makeStakeAddressAndDRepDelegationCertificate cred delegatee deposit =
191190
-- -------------------------------------
192191

193192
getAnchorDataFromCertificate
194-
:: HasCallStack
195-
=> Era era
193+
:: Era era
196194
-> Certificate (LedgerEra era)
197195
-> Either AnchorDataFromCertificateError (Maybe Ledger.Anchor)
198196
getAnchorDataFromCertificate ConwayEra (Certificate c) =

cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Certificate/Compatible.hs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ import Cardano.Api.Plutus.Internal.Script
4646

4747
import Cardano.Ledger.Keys qualified as Ledger
4848

49-
import GHC.Stack (HasCallStack)
50-
5149
type family Delegatee era where
5250
Delegatee DijkstraEra = Ledger.Delegatee
5351
Delegatee ConwayEra = Ledger.Delegatee
@@ -59,8 +57,7 @@ type family Delegatee era where
5957

6058
makeStakeAddressDelegationCertificate
6159
:: forall era
62-
. HasCallStack
63-
=> IsShelleyBasedEra era
60+
. IsShelleyBasedEra era
6461
=> StakeCredential
6562
-> Delegatee era
6663
-> Certificate (ShelleyLedgerEra era)

cardano-api/src/Cardano/Api/Plutus/Internal/Script.hs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ import Data.Type.Equality (TestEquality (..), (:~:) (Refl))
175175
import Data.Vector (Vector)
176176
import Formatting qualified as B
177177
import GHC.Exts (IsList (..))
178-
import GHC.Stack (HasCallStack)
179178
import Numeric.Natural (Natural)
180179
import Prettyprinter
181180

@@ -1235,7 +1234,7 @@ scriptArityForWitCtx WitCtxStake = 2
12351234
-- Conversion functions
12361235
--
12371236

1238-
toShelleyScript :: HasCallStack => ScriptInEra era -> Ledger.Script (ShelleyLedgerEra era)
1237+
toShelleyScript :: ScriptInEra era -> Ledger.Script (ShelleyLedgerEra era)
12391238
toShelleyScript (ScriptInEra langInEra (SimpleScript script)) =
12401239
case langInEra of
12411240
SimpleScriptInShelley -> either (error . show) id (toShelleyMultiSig script)
@@ -1418,7 +1417,7 @@ toShelleyMultiSig = go
14181417

14191418
-- | Conversion for the 'Shelley.MultiSig' language used by the Shelley era.
14201419
fromShelleyMultiSig
1421-
:: HasCallStack => Shelley.MultiSig (ShelleyLedgerEra ShelleyEra) -> SimpleScript
1420+
:: Shelley.MultiSig (ShelleyLedgerEra ShelleyEra) -> SimpleScript
14221421
fromShelleyMultiSig = go
14231422
where
14241423
go (Shelley.RequireSignature kh) =
@@ -1427,7 +1426,7 @@ fromShelleyMultiSig = go
14271426
go (Shelley.RequireAllOf s) = RequireAllOf (map go $ toList s)
14281427
go (Shelley.RequireAnyOf s) = RequireAnyOf (map go $ toList s)
14291428
go (Shelley.RequireMOf m s) = RequireMOf m (map go $ toList s)
1430-
go _ = error ""
1429+
go _ = error "fromShelleyMultiSig: Dijkstra era not supported"
14311430

14321431
-- | Conversion for the 'Timelock.Timelock' language that is shared between the
14331432
-- Allegra and Mary eras.
@@ -1451,8 +1450,7 @@ toAllegraTimelock = go
14511450
-- | Conversion for the 'Timelock.Timelock' language that is shared between the
14521451
-- Allegra and Mary eras.
14531452
fromAllegraTimelock
1454-
:: HasCallStack
1455-
=> Allegra.AllegraEraScript era
1453+
:: Allegra.AllegraEraScript era
14561454
=> Ledger.NativeScript era -> SimpleScript
14571455
fromAllegraTimelock = go
14581456
where
@@ -1462,7 +1460,7 @@ fromAllegraTimelock = go
14621460
go (Shelley.RequireAllOf s) = RequireAllOf (map go (toList s))
14631461
go (Shelley.RequireAnyOf s) = RequireAnyOf (map go (toList s))
14641462
go (Shelley.RequireMOf i s) = RequireMOf i (map go (toList s))
1465-
go _ = error "dijkstra"
1463+
go _ = error "fromAllegraTimelock: Dijkstra era not supported"
14661464

14671465
type family ToLedgerPlutusLanguage lang where
14681466
ToLedgerPlutusLanguage PlutusScriptV1 = Plutus.PlutusV1

cardano-api/src/Cardano/Api/Tx/Internal/Body.hs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,7 +2103,7 @@ mkCommonTxBody sbe txIns txOuts txFee txWithdrawals txAuxData =
21032103
#-}
21042104
makeShelleyTransactionBody
21052105
:: forall era
2106-
. HasCallStack
2106+
. ()
21072107
=> ShelleyBasedEra era
21082108
-> TxBodyContent BuildTx era
21092109
-> Either TxBodyError (TxBody era)
@@ -3099,8 +3099,7 @@ extractWitnessableMints aeon txMintValue =
30993099
getMints (TxMintValue _ txms) = toList txms
31003100

31013101
extractWitnessableVotes
3102-
:: HasCallStack
3103-
=> ConwayEraOnwards era
3102+
:: ConwayEraOnwards era
31043103
-> Maybe (Featured eon era (TxVotingProcedures BuildTx era))
31053104
-> [(Witnessable VoterItem (ShelleyLedgerEra era), BuildTxWith BuildTx (Witness WitCtxStake era))]
31063105
extractWitnessableVotes ConwayEraOnwardsDijkstra _ = error "extractWitnessableVotes: Dijkstra era not supported"

cardano-api/src/Cardano/Api/Tx/Internal/Body/Lens.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ import Cardano.Ledger.TxIn qualified as L
6868
import Data.OSet.Strict qualified as L
6969
import Data.Sequence.Strict qualified as L
7070
import Data.Set (Set)
71-
import GHC.Stack (HasCallStack)
7271
import Lens.Micro
7372

7473
newtype LedgerTxBody era = LedgerTxBody
@@ -166,7 +165,7 @@ collateralInputsTxBodyL
166165
collateralInputsTxBodyL w = alonzoEraOnwardsConstraints w $ txBodyL . L.collateralInputsTxBodyL
167166

168167
reqSignerHashesTxBodyL
169-
:: HasCallStack => AlonzoEraOnwards era -> Lens' (LedgerTxBody era) (Set (L.KeyHash L.Guard))
168+
:: AlonzoEraOnwards era -> Lens' (LedgerTxBody era) (Set (L.KeyHash L.Guard))
170169
reqSignerHashesTxBodyL w@AlonzoEraOnwardsAlonzo = alonzoEraOnwardsConstraints w $ txBodyL . L.reqSignerHashesTxBodyL
171170
reqSignerHashesTxBodyL w@AlonzoEraOnwardsBabbage = alonzoEraOnwardsConstraints w $ txBodyL . L.reqSignerHashesTxBodyL
172171
reqSignerHashesTxBodyL w@AlonzoEraOnwardsConway = alonzoEraOnwardsConstraints w $ txBodyL . L.reqSignerHashesTxBodyL

0 commit comments

Comments
 (0)