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

Incorporate remaining ledger certificates #119

Merged
merged 10 commits into from
Jul 17, 2023
6 changes: 6 additions & 0 deletions cardano-api/cardano-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ library internal
Cardano.Api.ProtocolParameters
Cardano.Api.Query
Cardano.Api.Query.Expr
Cardano.Api.ReexposeLedger
Cardano.Api.Script
Cardano.Api.ScriptData
Cardano.Api.SerialiseBech32
Expand Down Expand Up @@ -193,6 +194,11 @@ library
Cardano.Api.ChainSync.ClientPipelined
Cardano.Api.Crypto.Ed25519Bip32
Cardano.Api.Shelley
-- TODO: Eliminate Cardano.Api.Ledger when
-- cardano-api only depends on modules
-- exposed by cardano-api-ledger
Cardano.Api.Ledger


build-depends: bytestring
, cardano-api:internal
Expand Down
43 changes: 32 additions & 11 deletions cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -590,22 +590,43 @@ genTxCertificates :: CardanoEra era -> Gen (TxCertificates BuildTx era)
genTxCertificates era =
case certificatesSupportedInEra era of
Nothing -> pure TxCertificatesNone
Just supported -> do
certs <- Gen.list (Range.constant 0 3) genCertificate
Gen.choice
[ pure TxCertificatesNone
, pure (TxCertificates supported certs $ BuildTxWith mempty)
-- TODO: Generate certificates
]
Just supported ->
case cardanoEraStyle era of
LegacyByronEra -> pure TxCertificatesNone
ShelleyBasedEra sbe -> do
certs <- Gen.list (Range.constant 0 3) $ genCertificate sbe
Gen.choice
[ pure TxCertificatesNone
, pure (TxCertificates supported certs $ BuildTxWith mempty)
-- TODO: Generate certificates
]

-- TODO: Add remaining certificates
genCertificate :: Gen (Certificate era)
genCertificate =
-- TODO: This should be parameterised on ShelleyBasedEra
genCertificate :: ShelleyBasedEra era -> Gen (Certificate era)
genCertificate sbe =
Gen.choice
[ StakeAddressRegistrationCertificate <$> genStakeCredential
, StakeAddressDeregistrationCertificate <$> genStakeCredential
[ makeStakeAddressRegistrationCertificate <$> genStakeAddressRequirements sbe
, makeStakeAddressUnregistrationCertificate <$> genStakeAddressRequirements sbe
]

genStakeAddressRequirements :: ShelleyBasedEra era -> Gen (StakeAddressRequirements era)
genStakeAddressRequirements sbe =
case sbe of
ShelleyBasedEraShelley ->
StakeAddrRegistrationPreConway AtMostBabbageEraShelley <$> genStakeCredential
ShelleyBasedEraAllegra ->
StakeAddrRegistrationPreConway AtMostBabbageEraAllegra <$> genStakeCredential
ShelleyBasedEraMary ->
StakeAddrRegistrationPreConway AtMostBabbageEraMary <$> genStakeCredential
ShelleyBasedEraAlonzo ->
StakeAddrRegistrationPreConway AtMostBabbageEraAlonzo <$> genStakeCredential
ShelleyBasedEraBabbage ->
StakeAddrRegistrationPreConway AtMostBabbageEraBabbage <$> genStakeCredential
ShelleyBasedEraConway ->
StakeAddrRegistrationConway ConwayEraOnwardsConway <$> genLovelace <*> genStakeCredential


genTxUpdateProposal :: CardanoEra era -> Gen (TxUpdateProposal era)
genTxUpdateProposal era =
case updateProposalSupportedInEra era of
Expand Down
Loading
Loading