@@ -36,6 +36,7 @@ module Testnet.Components.Query
36
36
, checkDRepsNumber
37
37
, checkDRepState
38
38
, assertNewEpochState
39
+ , getProtocolParams
39
40
, getGovActionLifetime
40
41
, getKeyDeposit
41
42
, getDelegationState
@@ -44,8 +45,9 @@ module Testnet.Components.Query
44
45
45
46
import Cardano.Api as Api
46
47
import Cardano.Api.Ledger (Credential , DRepState , EpochInterval (.. ), KeyRole (DRepRole ))
47
- import Cardano.Api.Shelley (ShelleyLedgerEra )
48
48
import qualified Cardano.Api.Ledger as L
49
+ import Cardano.Api.Shelley (LedgerProtocolParameters (.. ), ShelleyLedgerEra )
50
+ import qualified Cardano.Api.Tx.UTxO as Utxo
49
51
50
52
import Cardano.Crypto.Hash (hashToStringAsHex )
51
53
import Cardano.Ledger.Api (ConwayGovState )
@@ -65,7 +67,6 @@ import Data.IORef
65
67
import Data.List (sortOn )
66
68
import qualified Data.Map as Map
67
69
import Data.Map.Strict (Map )
68
- import qualified Data.Map.Strict as M
69
70
import Data.Maybe
70
71
import Data.Ord (Down (.. ))
71
72
import Data.Text (Text )
@@ -301,11 +302,11 @@ findAllUtxos
301
302
=> MonadTest m
302
303
=> EpochStateView
303
304
-> ShelleyBasedEra era
304
- -> m (Map TxIn ( TxOut CtxUTxO era ) )
305
+ -> m (UTxO era )
305
306
findAllUtxos epochStateView sbe = withFrozenCallStack $ do
306
307
AnyNewEpochState sbe' _ tbs <- getEpochState epochStateView
307
308
Refl <- H. leftFail $ assertErasEqual sbe sbe'
308
- pure $ getLedgerTablesUTxOValues sbe' tbs
309
+ pure . UTxO $ getLedgerTablesUTxOValues sbe' tbs
309
310
310
311
-- | Retrieve utxos from the epoch state view for an address.
311
312
findUtxosWithAddress
@@ -316,7 +317,7 @@ findUtxosWithAddress
316
317
=> EpochStateView
317
318
-> ShelleyBasedEra era
318
319
-> Text -- ^ Address
319
- -> m (Map TxIn ( TxOut CtxUTxO era ) )
320
+ -> m (UTxO era )
320
321
findUtxosWithAddress epochStateView sbe address = withFrozenCallStack $ do
321
322
utxos <- findAllUtxos epochStateView sbe
322
323
H. note_ $ " Finding UTxOs for " <> T. unpack address
@@ -327,7 +328,7 @@ findUtxosWithAddress epochStateView sbe address = withFrozenCallStack $ do
327
328
maybeToEither (" Could not deserialize address: " <> T. unpack address)
328
329
(deserialiseAddress AsAddressAny address)
329
330
330
- let utxos' = M .filter (\ (TxOut txAddr _ _ _) -> txAddr == address') utxos
331
+ let utxos' = Utxo .filter (\ (TxOut txAddr _ _ _) -> txAddr == address') utxos
331
332
H. note_ $ unlines (map show $ toList utxos')
332
333
pure utxos'
333
334
where
@@ -344,7 +345,7 @@ findLargestUtxoWithAddress
344
345
-> Text -- ^ Address
345
346
-> m (Maybe (TxIn , TxOut CtxUTxO era ))
346
347
findLargestUtxoWithAddress epochStateView sbe address = withFrozenCallStack $ do
347
- utxos <- M. assocs <$> findUtxosWithAddress epochStateView sbe address
348
+ utxos <- toList <$> findUtxosWithAddress epochStateView sbe address
348
349
pure
349
350
. listToMaybe
350
351
$ sortOn (\ (_, TxOut _ txOutValue _ _) -> Down $ txOutValueToLovelace txOutValue) utxos
@@ -558,6 +559,15 @@ assertNewEpochState epochStateView sbe maxWait lens expected = withFrozenCallSta
558
559
Refl <- H. leftFail $ assertErasEqual sbe actualEra
559
560
pure $ newEpochState ^. lens
560
561
562
+ -- | Return current protocol parameters from the governance state
563
+ getProtocolParams :: (H. MonadAssertion m , MonadTest m , MonadIO m )
564
+ => EpochStateView
565
+ -> ConwayEraOnwards era
566
+ -> m (LedgerProtocolParameters era )
567
+ getProtocolParams epochStateView ceo = conwayEraOnwardsConstraints ceo $ do
568
+ govState :: ConwayGovState era <- getGovState epochStateView ceo
569
+ pure . LedgerProtocolParameters $ govState ^. L. cgsCurPParamsL
570
+
561
571
562
572
-- | Obtains the @govActionLifetime@ from the protocol parameters.
563
573
-- The @govActionLifetime@ or governance action maximum lifetime in epochs is
0 commit comments