Skip to content

Commit 500c415

Browse files
committed
Propagate HasCallStack to callers
Propagate HasCallStack constraints to callers of the error-site functions: tx signing, tx body construction and output, fee calculation, and query and genesis conversion.
1 parent c77670e commit 500c415

11 files changed

Lines changed: 25 additions & 7 deletions

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import Cardano.Protocol.Crypto (StandardCrypto)
3737
import Cardano.Protocol.TPraos.OCert qualified as Shelley
3838

3939
import Data.Word
40+
import GHC.Stack (HasCallStack)
4041

4142
-- ----------------------------------------------------------------------------
4243
-- Operational certificates
@@ -107,7 +108,8 @@ instance Error OperationalCertIssueError where
107108
-- TODO: include key ids
108109

109110
issueOperationalCertificate
110-
:: VerificationKey KesKey
111+
:: HasCallStack
112+
=> VerificationKey KesKey
111113
-> Either
112114
AnyStakePoolSigningKey
113115
(SigningKey GenesisDelegateExtendedKey)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,8 @@ hashTxBody
261261
hashTxBody = L.extractHash . L.hashAnnotated
262262

263263
makeKeyWitness
264-
:: Era era
264+
:: HasCallStack
265+
=> Era era
265266
-> UnsignedTx (LedgerEra era)
266267
-> ShelleyWitnessSigningKey
267268
-> L.WitVKey L.Witness

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ 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)
146147
import Lens.Micro
147148

148149
makeUnsignedTx
@@ -373,7 +374,8 @@ legacyDatumToDatum OldApi.TxOutDatumNone = Nothing
373374

374375
fromLegacyTxOut
375376
:: forall era
376-
. IsEra era
377+
. HasCallStack
378+
=> IsEra era
377379
=> OldApi.TxOut CtxTx era
378380
-> Either DatumDecodingError (TxOut (LedgerEra era), Map L.DataHash (L.Data (LedgerEra era)))
379381
fromLegacyTxOut tOut@(OldApi.TxOut _ _ d _) = do

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,8 @@ instance Error FeeCalculationError where
745745
-- In practice convergence occurs within 2–3 iterations.
746746
calcMinFeeRecursive
747747
:: forall era
748-
. IsEra era
748+
. HasCallStack
749+
=> IsEra era
749750
=> L.Addr
750751
-- ^ Change address. Any surplus value (ADA and/or native tokens) is
751752
-- sent to a new output at this address, appended at the end of the

cardano-api/src/Cardano/Api/Genesis/Internal/Parameters.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import Cardano.Slotting.Slot (EpochSize (..))
2525

2626
import Data.Time (NominalDiffTime, UTCTime)
2727
import Data.Word (Word64)
28+
import GHC.Stack (HasCallStack)
2829

2930
-- ----------------------------------------------------------------------------
3031
-- Genesis parameters
@@ -74,7 +75,7 @@ data GenesisParameters era
7475
-- Conversion functions
7576
--
7677

77-
fromShelleyGenesis :: Shelley.ShelleyGenesis -> GenesisParameters ShelleyEra
78+
fromShelleyGenesis :: HasCallStack => Shelley.ShelleyGenesis -> GenesisParameters ShelleyEra
7879
fromShelleyGenesis
7980
sg@Shelley.ShelleyGenesis
8081
{ Shelley.sgSystemStart

cardano-api/src/Cardano/Api/Query/Internal/Type/QueryInMode.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ fromShelleyRewardAccounts =
545545
toConsensusQuery
546546
:: forall block result
547547
. ()
548+
=> HasCallStack
548549
=> Consensus.CardanoBlock StandardCrypto ~ block
549550
=> QueryInMode result
550551
-> Some (Consensus.Query block)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,6 +1518,7 @@ maxShelleyTxInIx = fromIntegral $ maxBound @Word16
15181518
{-# DEPRECATED createAndValidateTransactionBody "Use createTransactionBody instead" #-}
15191519
createAndValidateTransactionBody
15201520
:: ()
1521+
=> HasCallStack
15211522
=> ShelleyBasedEra era
15221523
-> TxBodyContent BuildTx era
15231524
-> Either TxBodyError (TxBody era)
@@ -2104,6 +2105,7 @@ mkCommonTxBody sbe txIns txOuts txFee txWithdrawals txAuxData =
21042105
makeShelleyTransactionBody
21052106
:: forall era
21062107
. ()
2108+
=> HasCallStack
21072109
=> ShelleyBasedEra era
21082110
-> TxBodyContent BuildTx era
21092111
-> Either TxBodyError (TxBody era)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@ import Data.Map.Strict qualified as Map
3434
import Data.Set (Set)
3535
import Data.Text qualified as Text
3636
import GHC.Exts (IsList (..))
37+
import GHC.Stack (HasCallStack)
3738

3839
-- | Construct a balanced transaction.
3940
-- See Cardano.Api.Query.Internal.Convenience.queryStateForBalancedTx for a
4041
-- convenient way of querying the node to get the required arguements
4142
-- for constructBalancedTx.
4243
constructBalancedTx
4344
:: ()
45+
=> HasCallStack
4446
=> ShelleyBasedEra era
4547
-> TxBodyContent BuildTx era
4648
-> AddressInEra era

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ instance Error (AutoBalanceError era) where
124124
AutoBalanceCalculationError e -> prettyError e
125125

126126
estimateOrCalculateBalancedTxBody
127-
:: ShelleyBasedEra era
127+
:: HasCallStack
128+
=> ShelleyBasedEra era
128129
-> FeeEstimationMode era
129130
-> L.PParams (ShelleyLedgerEra era)
130131
-> TxBodyContent BuildTx era

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,7 @@ data WitnessNetworkIdOrByronAddress
10881088
makeShelleyBootstrapWitness
10891089
:: forall era
10901090
. ()
1091+
=> HasCallStack
10911092
=> ShelleyBasedEra era
10921093
-> WitnessNetworkIdOrByronAddress
10931094
-> TxBody era
@@ -1100,6 +1101,7 @@ makeShelleyBootstrapWitness sbe nwOrAddr txBody sk =
11001101
makeShelleyBasedBootstrapWitness
11011102
:: forall era
11021103
. ()
1104+
=> HasCallStack
11031105
=> ShelleyBasedEra era
11041106
-> WitnessNetworkIdOrByronAddress
11051107
-> Ledger.TxBody Ledger.TopTx (ShelleyLedgerEra era)
@@ -1183,6 +1185,7 @@ makeShelleyBasedBootstrapWitness sbe nwOrAddr txbody (ByronSigningKey sk) =
11831185
makeShelleyKeyWitness
11841186
:: forall era
11851187
. ()
1188+
=> HasCallStack
11861189
=> ShelleyBasedEra era
11871190
-> TxBody era
11881191
-> ShelleyWitnessSigningKey
@@ -1193,6 +1196,7 @@ makeShelleyKeyWitness sbe (ShelleyTxBody _ txBody _ _ _ _) =
11931196
makeShelleyKeyWitness'
11941197
:: forall era
11951198
. ()
1199+
=> HasCallStack
11961200
=> ShelleyBasedEra era
11971201
-> L.TxBody L.TopTx (ShelleyLedgerEra era)
11981202
-> ShelleyWitnessSigningKey

0 commit comments

Comments
 (0)