Skip to content

Commit ddd9821

Browse files
committed
Propagate Dijkstra era
1 parent 85fd5c6 commit ddd9821

File tree

7 files changed

+75
-2
lines changed

7 files changed

+75
-2
lines changed

cardano-api/src/Cardano/Api/Certificate/Internal.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ certificateToTxCert c =
234234
ConwayCertificate eon cert ->
235235
case eon of
236236
ConwayEraOnwardsConway -> cert
237+
ConwayEraOnwardsDijkstra -> cert
237238

238239
-- ----------------------------------------------------------------------------
239240
-- Stake pool parameters
@@ -576,6 +577,7 @@ filterUnRegCreds =
576577
Ledger.RetirePoolTxCert _ _ -> Nothing
577578
Ledger.MirTxCert _ -> Nothing
578579
Ledger.GenesisDelegTxCert{} -> Nothing
580+
_ -> error "dijkstra"
579581
ConwayCertificate cEra conwayCert -> conwayEraOnwardsConstraints cEra $
580582
case conwayCert of
581583
Ledger.RegPoolTxCert _ -> Nothing
@@ -593,6 +595,7 @@ filterUnRegCreds =
593595
Ledger.RegTxCert _ -> Nothing
594596
-- stake cred deregistration w/o deposit
595597
Ledger.UnRegTxCert cred -> Just cred
598+
_ -> error "dijkstra"
596599

597600
filterUnRegDRepCreds
598601
:: Certificate era -> Maybe (Ledger.Credential Ledger.DRepRole)
@@ -615,6 +618,7 @@ filterUnRegDRepCreds = \case
615618
Ledger.RegTxCert _ -> Nothing
616619
-- stake cred deregistration w/o deposit
617620
Ledger.UnRegTxCert _ -> Nothing
621+
_ -> error "dijkstra"
618622

619623
-- ----------------------------------------------------------------------------
620624
-- Internal conversion functions
@@ -803,6 +807,7 @@ getAnchorDataFromCertificate c =
803807
Ledger.RetirePoolTxCert _ _ -> return Nothing
804808
Ledger.GenesisDelegTxCert{} -> return Nothing
805809
Ledger.MirTxCert _ -> return Nothing
810+
_ -> error "dijkstra"
806811
ConwayCertificate ceo ccert ->
807812
conwayEraOnwardsConstraints ceo $
808813
case ccert of
@@ -819,6 +824,7 @@ getAnchorDataFromCertificate c =
819824
Ledger.UpdateDRepTxCert _ mAnchor -> return $ Ledger.strictMaybeToMaybe mAnchor
820825
Ledger.AuthCommitteeHotKeyTxCert _ _ -> return Nothing
821826
Ledger.ResignCommitteeColdTxCert _ mAnchor -> return $ Ledger.strictMaybeToMaybe mAnchor
827+
_ -> error "dijkstra"
822828
where
823829
anchorDataFromPoolMetadata
824830
:: MonadError AnchorDataFromCertificateError m

cardano-api/src/Cardano/Api/Experimental/Era.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ type EraCommonConstraints era =
295295
, L.AlonzoEraTx (LedgerEra era)
296296
, L.BabbageEraPParams (LedgerEra era)
297297
, L.BabbageEraTxBody (LedgerEra era)
298+
, L.ConwayEraTxBody (LedgerEra era)
298299
, L.ConwayEraTxCert (LedgerEra era)
299300
, L.TxCert (LedgerEra era) ~ L.ConwayTxCert (LedgerEra era)
300301
, L.Era (LedgerEra era)

cardano-api/src/Cardano/Api/Experimental/Plutus/Internal/IndexedPlutusScriptWitness.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,4 @@ obtainAlonzoScriptPurposeConstraints v =
211211
AlonzoEraOnwardsAlonzo -> id
212212
AlonzoEraOnwardsBabbage -> id
213213
AlonzoEraOnwardsConway -> id
214+
AlonzoEraOnwardsDijkstra -> id

cardano-api/src/Cardano/Api/Experimental/Tx/Internal/TxScriptWitnessRequirements.hs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ instance Semigroup (TxScriptWitnessRequirements L.ConwayEra) where
6161
instance Monoid (TxScriptWitnessRequirements L.ConwayEra) where
6262
mempty = TxScriptWitnessRequirements mempty mempty mempty mempty
6363

64+
instance Semigroup (TxScriptWitnessRequirements L.DijkstraEra) where
65+
(<>) (TxScriptWitnessRequirements l1 s1 d1 r1) (TxScriptWitnessRequirements l2 s2 d2 r2) =
66+
TxScriptWitnessRequirements (l1 <> l2) (s1 <> s2) (d1 <> d2) (r1 <> r2)
67+
68+
instance Monoid (TxScriptWitnessRequirements L.DijkstraEra) where
69+
mempty = TxScriptWitnessRequirements mempty mempty mempty mempty
70+
6471
getTxScriptWitnessRequirements
6572
:: AlonzoEraOnwards era
6673
-> [(Witnessable witnessable (ShelleyLedgerEra era), AnyWitness (ShelleyLedgerEra era))]
@@ -93,6 +100,7 @@ obtainMonoidConstraint eon = case eon of
93100
AlonzoEraOnwardsAlonzo -> id
94101
AlonzoEraOnwardsBabbage -> id
95102
AlonzoEraOnwardsConway -> id
103+
AlonzoEraOnwardsDijkstra -> id
96104

97105
extractExecutionUnits :: TxScriptWitnessRequirements era -> [ExecutionUnits]
98106
extractExecutionUnits (TxScriptWitnessRequirements _ _ _ redeemers) =

cardano-api/src/Cardano/Api/LedgerState.hs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,11 @@ getNewEpochState era x = do
12901290
ConwayLedgerState conwayCurrent ->
12911291
pure $ Shelley.shelleyLedgerState $ unFlip $ currentState conwayCurrent
12921292
_ -> Left err
1293+
ShelleyBasedEraDijkstra ->
1294+
case tip of
1295+
DijkstraLedgerState dijkstraCurrent ->
1296+
pure $ Shelley.shelleyLedgerState $ unFlip $ currentState dijkstraCurrent
1297+
_ -> Left err
12931298

12941299
{-# COMPLETE
12951300
ShelleyLedgerState
@@ -1360,6 +1365,16 @@ pattern ConwayLedgerState
13601365
-> NS (Current (Flip Consensus.LedgerState mk)) (Consensus.CardanoEras Consensus.StandardCrypto)
13611366
pattern ConwayLedgerState x = S (S (S (S (S (S (Z x))))))
13621367

1368+
pattern DijkstraLedgerState
1369+
:: Current
1370+
(Flip Consensus.LedgerState mk)
1371+
( Shelley.ShelleyBlock
1372+
(Praos.Praos Ledger.StandardCrypto)
1373+
Consensus.DijkstraEra
1374+
)
1375+
-> NS (Current (Flip Consensus.LedgerState mk)) (Consensus.CardanoEras Consensus.StandardCrypto)
1376+
pattern DijkstraLedgerState x = S (S (S (S (S (S (S (Z x)))))))
1377+
13631378
encodeLedgerState :: LedgerState -> CBOR.Encoding
13641379
encodeLedgerState (LedgerState hst@(HFC.HardForkLedgerState st) tbs) =
13651380
mconcat
@@ -2267,6 +2282,7 @@ getLedgerTablesUTxOValues sbe tbs =
22672282
ShelleyBasedEraAlonzo -> ejectTables (IS (IS (IS (IS IZ))))
22682283
ShelleyBasedEraBabbage -> ejectTables (IS (IS (IS (IS (IS IZ)))))
22692284
ShelleyBasedEraConway -> ejectTables (IS (IS (IS (IS (IS (IS IZ))))))
2285+
ShelleyBasedEraDijkstra -> ejectTables (IS (IS (IS (IS (IS (IS (IS IZ)))))))
22702286

22712287
-- | Reconstructs the ledger's new epoch state and applies a supplied condition to it for every block. This
22722288
-- function only terminates if the condition is met or we have reached the termination epoch. We need to

cardano-api/src/Cardano/Api/Tx/Internal/Sign.hs

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ instance Show (Tx era) where
179179
showParen (p >= 11) $
180180
showString "ShelleyTx ShelleyBasedEraConway "
181181
. showsPrec 11 tx
182+
showsPrec p (ShelleyTx ShelleyBasedEraDijkstra tx) =
183+
showParen (p >= 11) $
184+
showString "ShelleyTx ShelleyBasedEraDijkstra "
185+
. showsPrec 11 tx
182186

183187
instance HasTypeProxy era => HasTypeProxy (Tx era) where
184188
data AsType (Tx era) = AsTx (AsType era)
@@ -277,6 +281,7 @@ instance IsShelleyBasedEra era => HasTextEnvelope (Tx era) where
277281
ShelleyBasedEraAlonzo -> "Tx AlonzoEra"
278282
ShelleyBasedEraBabbage -> "Tx BabbageEra"
279283
ShelleyBasedEraConway -> "Tx ConwayEra"
284+
ShelleyBasedEraDijkstra -> "Tx DijkstraEra"
280285

281286
-- ----------------------------------------------------------------------------
282287
-- Transaction bodies
@@ -472,6 +477,29 @@ instance Show (TxBody era) where
472477
. showChar ' '
473478
. showsPrec 11 scriptValidity
474479
)
480+
showsPrec
481+
p
482+
( ShelleyTxBody
483+
ShelleyBasedEraDijkstra
484+
txbody
485+
txscripts
486+
redeemers
487+
txmetadata
488+
scriptValidity
489+
) =
490+
showParen
491+
(p >= 11)
492+
( showString "ShelleyTxBody ShelleyBasedEraDijkstra "
493+
. showsPrec 11 txbody
494+
. showChar ' '
495+
. showsPrec 11 txscripts
496+
. showChar ' '
497+
. showsPrec 11 redeemers
498+
. showChar ' '
499+
. showsPrec 11 txmetadata
500+
. showChar ' '
501+
. showsPrec 11 scriptValidity
502+
)
475503

476504
instance HasTypeProxy era => HasTypeProxy (TxBody era) where
477505
data AsType (TxBody era) = AsTxBody (AsType era)
@@ -513,6 +541,7 @@ instance IsShelleyBasedEra era => HasTextEnvelope (TxBody era) where
513541
ShelleyBasedEraAlonzo -> "TxBodyAlonzo"
514542
ShelleyBasedEraBabbage -> "TxBodyBabbage"
515543
ShelleyBasedEraConway -> "TxBodyConway"
544+
ShelleyBasedEraDijkstra -> "TxBodyDijkstra"
516545

517546
data TxBodyScriptData era where
518547
TxBodyNoScriptData :: TxBodyScriptData era
@@ -531,7 +560,7 @@ selectTxDatums
531560
:: TxBodyScriptData era
532561
-> Map L.DataHash (L.Data (ShelleyLedgerEra era))
533562
selectTxDatums TxBodyNoScriptData = Map.empty
534-
selectTxDatums (TxBodyScriptData _ (Alonzo.TxDats' datums) _) = datums
563+
selectTxDatums (TxBodyScriptData _ (Alonzo.TxDats datums) _) = datums
535564

536565
-- | Indicates whether a script is expected to fail or pass validation.
537566
data ScriptValidity
@@ -642,6 +671,10 @@ instance Show (KeyWitness era) where
642671
showParen (p >= 11) $
643672
showString "ShelleyBootstrapWitness ShelleyBasedEraConway "
644673
. showsPrec 11 tx
674+
showsPrec p (ShelleyBootstrapWitness ShelleyBasedEraDijkstra tx) =
675+
showParen (p >= 11) $
676+
showString "ShelleyBootstrapWitness ShelleyBasedEraDijkstra "
677+
. showsPrec 11 tx
645678
showsPrec p (ShelleyKeyWitness ShelleyBasedEraShelley tx) =
646679
showParen (p >= 11) $
647680
showString "ShelleyKeyWitness ShelleyBasedEraShelley "
@@ -666,6 +699,10 @@ instance Show (KeyWitness era) where
666699
showParen (p >= 11) $
667700
showString "ShelleyKeyWitness ShelleyBasedEraConway "
668701
. showsPrec 11 tx
702+
showsPrec p (ShelleyKeyWitness ShelleyBasedEraDijkstra tx) =
703+
showParen (p >= 11) $
704+
showString "ShelleyKeyWitness ShelleyBasedEraDijkstra "
705+
. showsPrec 11 tx
669706

670707
instance HasTypeProxy era => HasTypeProxy (KeyWitness era) where
671708
data AsType (KeyWitness era) = AsKeyWitness (AsType era)
@@ -707,6 +744,7 @@ instance IsCardanoEra era => SerialiseAsCBOR (KeyWitness era) where
707744
AlonzoEra -> decodeShelleyBasedWitness ShelleyBasedEraAlonzo bs
708745
BabbageEra -> decodeShelleyBasedWitness ShelleyBasedEraBabbage bs
709746
ConwayEra -> decodeShelleyBasedWitness ShelleyBasedEraConway bs
747+
DijkstraEra -> decodeShelleyBasedWitness ShelleyBasedEraDijkstra bs
710748

711749
encodeShelleyBasedKeyWitness :: CBOR.EncCBOR w => w -> CBOR.Encoding
712750
encodeShelleyBasedKeyWitness wit =
@@ -752,6 +790,7 @@ instance IsCardanoEra era => HasTextEnvelope (KeyWitness era) where
752790
AlonzoEra -> "TxWitness AlonzoEra"
753791
BabbageEra -> "TxWitness BabbageEra"
754792
ConwayEra -> "TxWitness ConwayEra"
793+
DijkstraEra -> "TxWitness DijkstraEra"
755794

756795
getTxBodyAndWitnesses :: Tx era -> (TxBody era, [KeyWitness era])
757796
getTxBodyAndWitnesses tx = (getTxBody tx, getTxWitnesses tx)
@@ -905,6 +944,7 @@ makeSignedTransaction
905944
ShelleyBasedEraAlonzo -> alonzoSignedTransaction
906945
ShelleyBasedEraBabbage -> alonzoSignedTransaction
907946
ShelleyBasedEraConway -> alonzoSignedTransaction
947+
ShelleyBasedEraDijkstra -> alonzoSignedTransaction
908948
where
909949
txCommon
910950
:: forall ledgerera
@@ -1025,7 +1065,7 @@ makeShelleyBasedBootstrapWitness sbe nwOrAddr txbody (ByronSigningKey sk) =
10251065
-- Byron era witnesses were weird. This reveals all that weirdness.
10261066
Shelley.BootstrapWitness
10271067
{ Shelley.bwKey = vk
1028-
, Shelley.bwSig = signature
1068+
, Shelley.bwSignature = signature
10291069
, Shelley.bwChainCode = chainCode
10301070
, Shelley.bwAttributes = attributes
10311071
}

cardano-api/test/cardano-api-test/Test/Cardano/Api/Transaction/Autobalance.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@ loadPlutusWitness ceo = do
651651
H.leftFail $ deserialiseFromTextEnvelopeAnyOf textEnvTypes envelope
652652
let scriptLangInEra = case ceo of
653653
ConwayEraOnwardsConway -> PlutusScriptV3InConway
654+
ConwayEraOnwardsDijkstra -> PlutusScriptV3InDijkstra
654655
pure
655656
( hashScript s
656657
, PlutusScriptWitness

0 commit comments

Comments
 (0)