From 0e1f3b9f20f8c828d2cab6f74a4b34abc776e587 Mon Sep 17 00:00:00 2001 From: sourabhxyz Date: Fri, 6 Sep 2024 15:11:17 +0530 Subject: [PATCH 1/5] feat: add conway related fields to protocol parameters endpoint --- CHANGELOG.md | 4 +++ maestro-sdk.cabal | 2 +- src/Maestro/Types/V1/General.hs | 63 +++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc48f4d..b4b7960 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Revision history for `maestro-sdk` +## [1.7.3](https://github.com/maestro-org/haskell-sdk/compare/v1.7.2..v1.7.3) -- 2024-09-06 + +* Add Conway related fields to protocol parameters endpoint. + ## [1.7.2](https://github.com/maestro-org/haskell-sdk/compare/v1.7.1..v1.7.2) -- 2024-08-28 * Add `PlutusV3` to `ScriptType`. diff --git a/maestro-sdk.cabal b/maestro-sdk.cabal index 20ba9d2..06254a3 100644 --- a/maestro-sdk.cabal +++ b/maestro-sdk.cabal @@ -1,6 +1,6 @@ cabal-version: 3.0 name: maestro-sdk -version: 1.7.2 +version: 1.7.3 synopsis: Maestro Blockchain Indexer SDK description: Maestro provides blockchain indexers, APIs and event management systems for the Cardano blockchain. diff --git a/src/Maestro/Types/V1/General.hs b/src/Maestro/Types/V1/General.hs index da10205..31251d7 100644 --- a/src/Maestro/Types/V1/General.hs +++ b/src/Maestro/Types/V1/General.hs @@ -185,6 +185,7 @@ newtype CostModel = CostModel [Int64] data CostModels = CostModels { costModelsPlutusV1 :: !CostModel , costModelsPlutusV2 :: !CostModel + , costModelsPlutusV3 :: !CostModel } deriving stock (Eq, Show, Generic) deriving (FromJSON, ToJSON) via CustomJSON '[FieldLabelModifier '[StripPrefix "costModels", CamelToSnake]] CostModels @@ -231,6 +232,58 @@ instance ToJSON MaestroRational where instance FromJSON MaestroRational where parseJSON = withText "MaestroRational" $ \ratTxt -> either fail pure $ textToMaestroRational ratTxt +data ConstitutionalCommittee = ConstitutionalCommittee + { constitutionalCommitteeDefault :: !MaestroRational + , constitutionalCommitteeStateOfNoConfidence :: !MaestroRational + } + deriving stock (Eq, Show, Generic) + deriving (FromJSON, ToJSON) via CustomJSON '[FieldLabelModifier '[StripPrefix "constitutionalCommittee", CamelToSnake]] ConstitutionalCommittee + +data ProtocolParametersUpdateDRep = ProtocolParametersUpdateDRep + { ppUpdateDrepEconomic :: !MaestroRational + , ppUpdateDrepGovernance :: !MaestroRational + , ppUpdateDrepNetwork :: !MaestroRational + , ppUpdateDrepTechnical :: !MaestroRational + } + deriving stock (Eq, Show, Generic) + deriving (FromJSON, ToJSON) via CustomJSON '[FieldLabelModifier '[StripPrefix "ppUpdateDrep", CamelToSnake]] ProtocolParametersUpdateDRep + +-- | DRep voting thresholds. +data DRepVotingThresholds = DRepVotingThresholds + { drepVotingThresholdsConstitution :: !MaestroRational + , drepVotingThresholdsConstitutionalCommittee :: !ConstitutionalCommittee + , drepVotingThresholdsHardForkInitiation :: !MaestroRational + , drepVotingThresholdsNoConfidence :: !MaestroRational + , drepVotingThresholdsProtocolParametersUpdate :: !ProtocolParametersUpdateDRep + , drepVotingThresholdsTreasuryWithdrawals :: !MaestroRational + } + deriving stock (Eq, Show, Generic) + deriving (FromJSON, ToJSON) via CustomJSON '[FieldLabelModifier '[StripPrefix "drepVotingThresholds", CamelToSnake]] DRepVotingThresholds + +newtype ProtocolParametersUpdateStakePool = ProtocolParametersUpdateStakePool + { ppUpdateStakePoolSecurity :: MaestroRational + } + deriving stock (Eq, Show, Generic) + deriving (FromJSON, ToJSON) via CustomJSON '[FieldLabelModifier '[StripPrefix "ppUpdateStakePool", CamelToSnake]] ProtocolParametersUpdateStakePool + +-- | Stake pool voting thresholds. +data StakePoolVotingThresholds = StakePoolVotingThresholds + { stakePoolVotingThresholdsConstitutionalCommittee :: !ConstitutionalCommittee + , stakePoolVotingThresholdsHardForkInitiation :: !MaestroRational + , stakePoolVotingThresholdsNoConfidence :: !MaestroRational + , stakePoolVotingThresholdsProtocolParametersUpdate :: !ProtocolParametersUpdateStakePool + } + deriving stock (Eq, Show, Generic) + deriving (FromJSON, ToJSON) via CustomJSON '[FieldLabelModifier '[StripPrefix "stakePoolVotingThresholds", CamelToSnake]] StakePoolVotingThresholds + +data MinFeeReferenceScripts = MinFeeReferenceScripts + { minFeeReferenceScriptsBase :: !Natural + , minFeeReferenceScriptsMultiplier :: !Rational + , minFeeReferenceScriptsRange :: !Natural + } + deriving stock (Eq, Show, Generic) + deriving (FromJSON, ToJSON) via CustomJSON '[FieldLabelModifier '[StripPrefix "minFeeReferenceScripts", CamelToSnake]] MinFeeReferenceScripts + -- | Timestamped `ProtocolParameters` response. data TimestampedProtocolParameters = TimestampedProtocolParameters { timestampedProtocolParametersData :: !ProtocolParameters @@ -251,8 +304,15 @@ data ProtocolParameters = ProtocolParameters { protocolParametersCollateralPercentage :: !Natural -- ^ The percentage of the transactions fee which must be provided as collateral when including non-native scripts. + , protocolParametersConstitutionalCommitteeMaxTermLength :: !(Maybe Natural) + , protocolParametersConstitutionalCommitteeMinSize :: !(Maybe Natural) + , protocolParametersDelegateRepresentativeDeposit :: !(Maybe AsAda) + , protocolParametersDelegateRepresentativeMaxIdleTime :: !(Maybe Natural) + , protocolParametersDelegateRepresentativeVotingThresholds :: !(Maybe DRepVotingThresholds) , protocolParametersDesiredNumberOfStakePools :: !Natural -- The equilibrium target number of stake pools. This is the \"k\" incentives parameter from the design document, /AKA/ @n_opt@, @stake_pool_target@. + , protocolParametersGovernanceActionDeposit :: !(Maybe AsAda) + , protocolParametersGovernanceActionLifetime :: !(Maybe Natural) , protocolParametersMaxBlockBodySize :: !AsBytes -- ^ Maximum block body size. , protocolParametersMaxBlockHeaderSize :: !AsBytes @@ -263,6 +323,7 @@ data ProtocolParameters = ProtocolParameters -- ^ The maximum number of execution memory & steps allowed to be used in a single block. , protocolParametersMaxExecutionUnitsPerTransaction :: !(MemoryCpuWith Natural) -- ^ The maximum number of execution memory & steps allowed to be used in a single transaction. + , protocolParametersMaxReferenceScriptsSize :: !(Maybe AsBytes) , protocolParametersMaxTransactionSize :: !AsBytes -- ^ Maximum transaction size. , protocolParametersMaxValueSize :: !AsBytes @@ -271,6 +332,7 @@ data ProtocolParameters = ProtocolParameters -- ^ The constant factor for the minimum fee calculation /AKA/ @min_fee_a@ and @tx_fee_per_byte@. , protocolParametersMinFeeConstant :: !AsAda -- ^ The linear factor for the minimum fee calculation for given epoch /AKA/ @min_fee_b@ and @tx_fee_fixed@. + , protocolParametersMinFeeReferenceScripts :: !(Maybe MinFeeReferenceScripts) , protocolParametersMinStakePoolCost :: !AsAda -- ^ The minimum value that stake pools are permitted to declare for their cost parameter. , protocolParametersMinUtxoDepositCoefficient :: !Natural @@ -289,6 +351,7 @@ data ProtocolParameters = ProtocolParameters -- The influence of the pledge in stake pool rewards. This is the \"a_0\" incentives parameter from the design document. , protocolParametersStakePoolRetirementEpochBound :: !EpochNo -- ^ The maximum number of epochs into the future that stake pools are permitted to schedule a retirement /AKA/ @pool_retire_max_epoch@, @e_max@. + , protocolParametersStakePoolVotingThresholds :: !(Maybe StakePoolVotingThresholds) , protocolParametersTreasuryExpansion :: !MaestroRational -- ^ The fraction of the fee pot each epoch that goes to the treasury. This is the \"tau\" incentives parameter from the design document, /AKA/ @treasury_cut@. , protocolParametersVersion :: !ProtocolVersion From b1fb7c4fea519bc3cac52c4ee2ee6f85bd050b2c Mon Sep 17 00:00:00 2001 From: sourabhxyz Date: Fri, 6 Sep 2024 15:23:12 +0530 Subject: [PATCH 2/5] feat: export newly added types relating to protocol params introduced in conway --- src/Maestro/Types/V1/General.hs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Maestro/Types/V1/General.hs b/src/Maestro/Types/V1/General.hs index 31251d7..dd6e6d1 100644 --- a/src/Maestro/Types/V1/General.hs +++ b/src/Maestro/Types/V1/General.hs @@ -21,6 +21,12 @@ module Maestro.Types.V1.General , MaestroRational (..) , textToMaestroRational , textFromMaestroRational + , ConstitutionalCommittee (..) + , ProtocolParametersUpdateDRep (..) + , DRepVotingThresholds (..) + , ProtocolParametersUpdateStakePool (..) + , StakePoolVotingThresholds (..) + , MinFeeReferenceScripts (..) , TimestampedProtocolParameters (..) , ProtocolParameters (..) -- * Types for @/chain-tip@ endpoint From 23f609f474a3e006c1b0d3fa3261d50a88203c19 Mon Sep 17 00:00:00 2001 From: sourabhxyz Date: Fri, 6 Sep 2024 15:29:26 +0530 Subject: [PATCH 3/5] feat: remove unnecessary `Maybe` wrap over some of the protocol params --- src/Maestro/Types/V1/General.hs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Maestro/Types/V1/General.hs b/src/Maestro/Types/V1/General.hs index dd6e6d1..3c7e487 100644 --- a/src/Maestro/Types/V1/General.hs +++ b/src/Maestro/Types/V1/General.hs @@ -310,15 +310,15 @@ data ProtocolParameters = ProtocolParameters { protocolParametersCollateralPercentage :: !Natural -- ^ The percentage of the transactions fee which must be provided as collateral when including non-native scripts. - , protocolParametersConstitutionalCommitteeMaxTermLength :: !(Maybe Natural) - , protocolParametersConstitutionalCommitteeMinSize :: !(Maybe Natural) - , protocolParametersDelegateRepresentativeDeposit :: !(Maybe AsAda) - , protocolParametersDelegateRepresentativeMaxIdleTime :: !(Maybe Natural) - , protocolParametersDelegateRepresentativeVotingThresholds :: !(Maybe DRepVotingThresholds) + , protocolParametersConstitutionalCommitteeMaxTermLength :: Natural + , protocolParametersConstitutionalCommitteeMinSize :: Natural + , protocolParametersDelegateRepresentativeDeposit :: AsAda + , protocolParametersDelegateRepresentativeMaxIdleTime :: Natural + , protocolParametersDelegateRepresentativeVotingThresholds :: DRepVotingThresholds , protocolParametersDesiredNumberOfStakePools :: !Natural -- The equilibrium target number of stake pools. This is the \"k\" incentives parameter from the design document, /AKA/ @n_opt@, @stake_pool_target@. - , protocolParametersGovernanceActionDeposit :: !(Maybe AsAda) - , protocolParametersGovernanceActionLifetime :: !(Maybe Natural) + , protocolParametersGovernanceActionDeposit :: AsAda + , protocolParametersGovernanceActionLifetime :: Natural , protocolParametersMaxBlockBodySize :: !AsBytes -- ^ Maximum block body size. , protocolParametersMaxBlockHeaderSize :: !AsBytes @@ -329,7 +329,7 @@ data ProtocolParameters = ProtocolParameters -- ^ The maximum number of execution memory & steps allowed to be used in a single block. , protocolParametersMaxExecutionUnitsPerTransaction :: !(MemoryCpuWith Natural) -- ^ The maximum number of execution memory & steps allowed to be used in a single transaction. - , protocolParametersMaxReferenceScriptsSize :: !(Maybe AsBytes) + , protocolParametersMaxReferenceScriptsSize :: AsBytes , protocolParametersMaxTransactionSize :: !AsBytes -- ^ Maximum transaction size. , protocolParametersMaxValueSize :: !AsBytes @@ -338,7 +338,7 @@ data ProtocolParameters = ProtocolParameters -- ^ The constant factor for the minimum fee calculation /AKA/ @min_fee_a@ and @tx_fee_per_byte@. , protocolParametersMinFeeConstant :: !AsAda -- ^ The linear factor for the minimum fee calculation for given epoch /AKA/ @min_fee_b@ and @tx_fee_fixed@. - , protocolParametersMinFeeReferenceScripts :: !(Maybe MinFeeReferenceScripts) + , protocolParametersMinFeeReferenceScripts :: MinFeeReferenceScripts , protocolParametersMinStakePoolCost :: !AsAda -- ^ The minimum value that stake pools are permitted to declare for their cost parameter. , protocolParametersMinUtxoDepositCoefficient :: !Natural @@ -357,7 +357,7 @@ data ProtocolParameters = ProtocolParameters -- The influence of the pledge in stake pool rewards. This is the \"a_0\" incentives parameter from the design document. , protocolParametersStakePoolRetirementEpochBound :: !EpochNo -- ^ The maximum number of epochs into the future that stake pools are permitted to schedule a retirement /AKA/ @pool_retire_max_epoch@, @e_max@. - , protocolParametersStakePoolVotingThresholds :: !(Maybe StakePoolVotingThresholds) + , protocolParametersStakePoolVotingThresholds :: !StakePoolVotingThresholds , protocolParametersTreasuryExpansion :: !MaestroRational -- ^ The fraction of the fee pot each epoch that goes to the treasury. This is the \"tau\" incentives parameter from the design document, /AKA/ @treasury_cut@. , protocolParametersVersion :: !ProtocolVersion From b20781fd75a05fe91c352150732093ba550105dc Mon Sep 17 00:00:00 2001 From: sourabhxyz Date: Fri, 6 Sep 2024 15:32:28 +0530 Subject: [PATCH 4/5] feat: add bangs where it is missed --- src/Maestro/Types/V1/General.hs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Maestro/Types/V1/General.hs b/src/Maestro/Types/V1/General.hs index 3c7e487..3222951 100644 --- a/src/Maestro/Types/V1/General.hs +++ b/src/Maestro/Types/V1/General.hs @@ -310,15 +310,15 @@ data ProtocolParameters = ProtocolParameters { protocolParametersCollateralPercentage :: !Natural -- ^ The percentage of the transactions fee which must be provided as collateral when including non-native scripts. - , protocolParametersConstitutionalCommitteeMaxTermLength :: Natural - , protocolParametersConstitutionalCommitteeMinSize :: Natural - , protocolParametersDelegateRepresentativeDeposit :: AsAda - , protocolParametersDelegateRepresentativeMaxIdleTime :: Natural - , protocolParametersDelegateRepresentativeVotingThresholds :: DRepVotingThresholds + , protocolParametersConstitutionalCommitteeMaxTermLength :: !Natural + , protocolParametersConstitutionalCommitteeMinSize :: !Natural + , protocolParametersDelegateRepresentativeDeposit :: !AsAda + , protocolParametersDelegateRepresentativeMaxIdleTime :: !Natural + , protocolParametersDelegateRepresentativeVotingThresholds :: !DRepVotingThresholds , protocolParametersDesiredNumberOfStakePools :: !Natural -- The equilibrium target number of stake pools. This is the \"k\" incentives parameter from the design document, /AKA/ @n_opt@, @stake_pool_target@. - , protocolParametersGovernanceActionDeposit :: AsAda - , protocolParametersGovernanceActionLifetime :: Natural + , protocolParametersGovernanceActionDeposit :: !AsAda + , protocolParametersGovernanceActionLifetime :: !Natural , protocolParametersMaxBlockBodySize :: !AsBytes -- ^ Maximum block body size. , protocolParametersMaxBlockHeaderSize :: !AsBytes @@ -329,7 +329,7 @@ data ProtocolParameters = ProtocolParameters -- ^ The maximum number of execution memory & steps allowed to be used in a single block. , protocolParametersMaxExecutionUnitsPerTransaction :: !(MemoryCpuWith Natural) -- ^ The maximum number of execution memory & steps allowed to be used in a single transaction. - , protocolParametersMaxReferenceScriptsSize :: AsBytes + , protocolParametersMaxReferenceScriptsSize :: !AsBytes , protocolParametersMaxTransactionSize :: !AsBytes -- ^ Maximum transaction size. , protocolParametersMaxValueSize :: !AsBytes @@ -338,7 +338,7 @@ data ProtocolParameters = ProtocolParameters -- ^ The constant factor for the minimum fee calculation /AKA/ @min_fee_a@ and @tx_fee_per_byte@. , protocolParametersMinFeeConstant :: !AsAda -- ^ The linear factor for the minimum fee calculation for given epoch /AKA/ @min_fee_b@ and @tx_fee_fixed@. - , protocolParametersMinFeeReferenceScripts :: MinFeeReferenceScripts + , protocolParametersMinFeeReferenceScripts :: !MinFeeReferenceScripts , protocolParametersMinStakePoolCost :: !AsAda -- ^ The minimum value that stake pools are permitted to declare for their cost parameter. , protocolParametersMinUtxoDepositCoefficient :: !Natural From 29a826c26b06505d4fbe81c731125740962a00ce Mon Sep 17 00:00:00 2001 From: sourabhxyz Date: Fri, 6 Sep 2024 15:51:42 +0530 Subject: [PATCH 5/5] feat: make `minFeeReferenceScriptsBase` a `Rational` --- src/Maestro/Types/V1/General.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Maestro/Types/V1/General.hs b/src/Maestro/Types/V1/General.hs index 3222951..a26b7b6 100644 --- a/src/Maestro/Types/V1/General.hs +++ b/src/Maestro/Types/V1/General.hs @@ -283,7 +283,7 @@ data StakePoolVotingThresholds = StakePoolVotingThresholds deriving (FromJSON, ToJSON) via CustomJSON '[FieldLabelModifier '[StripPrefix "stakePoolVotingThresholds", CamelToSnake]] StakePoolVotingThresholds data MinFeeReferenceScripts = MinFeeReferenceScripts - { minFeeReferenceScriptsBase :: !Natural + { minFeeReferenceScriptsBase :: !Rational , minFeeReferenceScriptsMultiplier :: !Rational , minFeeReferenceScriptsRange :: !Natural }