-
Notifications
You must be signed in to change notification settings - Fork 23
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
Replace CertificatesSupportedInEra
with ShelleyBasedEra
#259
Merged
newhoggy
merged 1 commit into
main
from
newhoggy/replace-CertificatesSupportedInEra-with-ShelleyBasedEra
Sep 26, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,7 +125,6 @@ module Cardano.Api.TxBody ( | |
TxExtraKeyWitnessesSupportedInEra(..), | ||
ScriptDataSupportedInEra(..), | ||
WithdrawalsSupportedInEra(..), | ||
CertificatesSupportedInEra(..), | ||
UpdateProposalSupportedInEra(..), | ||
TxTotalAndReturnCollateralSupportedInEra(..), | ||
|
||
|
@@ -140,7 +139,6 @@ module Cardano.Api.TxBody ( | |
extraKeyWitnessesSupportedInEra, | ||
scriptDataSupportedInEra, | ||
withdrawalsSupportedInEra, | ||
certificatesSupportedInEra, | ||
updateProposalSupportedInEra, | ||
txScriptValiditySupportedInShelleyBasedEra, | ||
txScriptValiditySupportedInCardanoEra, | ||
|
@@ -1252,35 +1250,6 @@ withdrawalsSupportedInEra AlonzoEra = Just WithdrawalsInAlonzoEra | |
withdrawalsSupportedInEra BabbageEra = Just WithdrawalsInBabbageEra | ||
withdrawalsSupportedInEra ConwayEra = Just WithdrawalsInConwayEra | ||
|
||
|
||
-- | A representation of whether the era supports 'Certificate's embedded in | ||
-- transactions. | ||
-- | ||
-- The Shelley and subsequent eras support such certificates. | ||
-- | ||
data CertificatesSupportedInEra era where | ||
|
||
CertificatesInShelleyEra :: CertificatesSupportedInEra ShelleyEra | ||
CertificatesInAllegraEra :: CertificatesSupportedInEra AllegraEra | ||
CertificatesInMaryEra :: CertificatesSupportedInEra MaryEra | ||
CertificatesInAlonzoEra :: CertificatesSupportedInEra AlonzoEra | ||
CertificatesInBabbageEra :: CertificatesSupportedInEra BabbageEra | ||
CertificatesInConwayEra :: CertificatesSupportedInEra ConwayEra | ||
|
||
deriving instance Eq (CertificatesSupportedInEra era) | ||
deriving instance Show (CertificatesSupportedInEra era) | ||
|
||
certificatesSupportedInEra :: CardanoEra era | ||
-> Maybe (CertificatesSupportedInEra era) | ||
certificatesSupportedInEra ByronEra = Nothing | ||
certificatesSupportedInEra ShelleyEra = Just CertificatesInShelleyEra | ||
certificatesSupportedInEra AllegraEra = Just CertificatesInAllegraEra | ||
certificatesSupportedInEra MaryEra = Just CertificatesInMaryEra | ||
certificatesSupportedInEra AlonzoEra = Just CertificatesInAlonzoEra | ||
certificatesSupportedInEra BabbageEra = Just CertificatesInBabbageEra | ||
certificatesSupportedInEra ConwayEra = Just CertificatesInConwayEra | ||
|
||
|
||
-- | A representation of whether the era supports 'UpdateProposal's embedded in | ||
-- transactions. | ||
-- | ||
|
@@ -1687,13 +1656,14 @@ deriving instance Show (TxWithdrawals build era) | |
|
||
data TxCertificates build era where | ||
|
||
TxCertificatesNone :: TxCertificates build era | ||
TxCertificatesNone | ||
:: TxCertificates build era | ||
|
||
TxCertificates :: CertificatesSupportedInEra era | ||
-> [Certificate era] | ||
-> BuildTxWith build | ||
(Map StakeCredential (Witness WitCtxStake era)) | ||
-> TxCertificates build era | ||
TxCertificates | ||
:: ShelleyBasedEra era | ||
-> [Certificate era] | ||
-> BuildTxWith build (Map StakeCredential (Witness WitCtxStake era)) | ||
-> TxCertificates build era | ||
|
||
deriving instance Eq (TxCertificates build era) | ||
deriving instance Show (TxCertificates build era) | ||
|
@@ -3210,59 +3180,11 @@ fromLedgerTxCertificates | |
-> Ledger.TxBody (ShelleyLedgerEra era) | ||
-> TxCertificates ViewTx era | ||
fromLedgerTxCertificates sbe body = | ||
case sbe of | ||
ShelleyBasedEraShelley | ||
| null certificates -> TxCertificatesNone | ||
| otherwise -> | ||
TxCertificates | ||
CertificatesInShelleyEra | ||
(map (fromShelleyCertificate sbe) $ toList certificates) | ||
ViewTx | ||
where | ||
certificates = body ^. L.certsTxBodyL | ||
|
||
ShelleyBasedEraAllegra | ||
| null certificates -> TxCertificatesNone | ||
| otherwise -> | ||
TxCertificates | ||
CertificatesInAllegraEra | ||
(map (fromShelleyCertificate sbe) $ toList certificates) | ||
ViewTx | ||
where | ||
certificates = body ^. L.certsTxBodyL | ||
|
||
ShelleyBasedEraMary | ||
| null certificates -> TxCertificatesNone | ||
| otherwise -> | ||
TxCertificates | ||
CertificatesInMaryEra | ||
(map (fromShelleyCertificate sbe) $ toList certificates) | ||
ViewTx | ||
where | ||
certificates = body ^. L.certsTxBodyL | ||
|
||
ShelleyBasedEraAlonzo | ||
| null certificates -> TxCertificatesNone | ||
| otherwise -> | ||
TxCertificates | ||
CertificatesInAlonzoEra | ||
(map (fromShelleyCertificate sbe) $ toList certificates) | ||
ViewTx | ||
where | ||
certificates = body ^. L.certsTxBodyL | ||
|
||
ShelleyBasedEraBabbage | ||
| null certificates -> TxCertificatesNone | ||
| otherwise -> | ||
TxCertificates | ||
CertificatesInBabbageEra | ||
(map (fromShelleyCertificate sbe) $ toList certificates) | ||
ViewTx | ||
where | ||
certificates = body ^. L.certsTxBodyL | ||
|
||
-- TODO: Implement once certificates are done in Conway. | ||
ShelleyBasedEraConway -> TxCertificatesNone | ||
shelleyBasedEraConstraints sbe $ | ||
let certificates = body ^. L.certsTxBodyL in | ||
if null certificates | ||
then TxCertificatesNone | ||
else TxCertificates sbe (map (fromShelleyCertificate sbe) $ toList certificates) ViewTx | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is simplified via the use of |
||
|
||
fromLedgerTxUpdateProposal | ||
:: ShelleyBasedEra era | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we replace this with
?
Feels like it would simplify era-witness checking down the line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. Can do that in a future commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't. Having this as a data definition makes it clearer what it is when using it.