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

feat: add conway related fields to protocol parameters endpoint #73

Merged
merged 5 commits into from
Sep 6, 2024
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`.
Expand Down
2 changes: 1 addition & 1 deletion maestro-sdk.cabal
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
69 changes: 69 additions & 0 deletions src/Maestro/Types/V1/General.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -185,6 +191,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
Expand Down Expand Up @@ -231,6 +238,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 :: !Rational
, 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
Expand All @@ -251,8 +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
, 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
, protocolParametersMaxBlockBodySize :: !AsBytes
-- ^ Maximum block body size.
, protocolParametersMaxBlockHeaderSize :: !AsBytes
Expand All @@ -263,6 +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
, protocolParametersMaxTransactionSize :: !AsBytes
-- ^ Maximum transaction size.
, protocolParametersMaxValueSize :: !AsBytes
Expand All @@ -271,6 +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
, protocolParametersMinStakePoolCost :: !AsAda
-- ^ The minimum value that stake pools are permitted to declare for their cost parameter.
, protocolParametersMinUtxoDepositCoefficient :: !Natural
Expand All @@ -289,6 +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 :: !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
Expand Down
Loading