Skip to content

Commit

Permalink
Improve RecentEra docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Anviking committed Dec 11, 2024
1 parent 3e617b9 commit 1a0fa53
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions lib/balance-tx/lib/internal/Internal/Cardano/Write/Eras.hs
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,37 @@ type LatestLedgerEra = Conway
-- RecentEra
--------------------------------------------------------------------------------

-- | 'RecentEra' respresents the eras we care about constructing transactions
-- for.
-- | We define the term "recent era" to mean one of the /two most recent eras/.
-- This represents eras we care constructing transactions for.
--
-- === Why /two/ eras?
--
-- To have the same software constructing transactions just before and just
-- after a hard-fork, we need to, at that time, support the two latest eras. We
-- could get away with just supporting one era at other times, but for
-- simplicity we stick with always supporting the two latest eras for now.
-- after a hard-fork, we need to, for a time, support two eras.
--
-- === 'RecentEra' the value vs 'IsRecentEra' the class
--
-- DO:
--
-- @@
-- myTx :: IsRecentEra era => Tx era
-- signByAlice :: IsRecentEra era => Tx era -> Tx era
-- renderCliTx :: IsRecentEra era -> Tx era -> Text
-- myCardanoApiTx :: IsRecentEra era -> RecentEra -> CardanoApi.Tx (CardanoApiEra era)
-- @@
--
-- DON'T:
--
-- @@
-- signByAlice :: RecentEra era -> Tx era -> Tx era
--
-- -- 'RecentEra era' adds boilerplate without improving type inference
-- signByAlice :: IsRecentEra era => RecentEra era -> Tx era -> Tx era
--
-- -- Will always require '@era' type application to disambiguate the type when
-- called:
-- myCardanoApiTx :: IsRecentEra era => CardanoApi.Tx (CardanoApiEra era)
-- @@
data RecentEra era where
RecentEraBabbage :: RecentEra Babbage
RecentEraConway :: RecentEra Conway
Expand All @@ -130,6 +154,7 @@ instance TestEquality RecentEra where
testEquality RecentEraBabbage RecentEraConway = Nothing
testEquality RecentEraConway RecentEraBabbage = Nothing

-- | C.f. 'RecentEra'
class
( CardanoApi.IsShelleyBasedEra (CardanoApiEra era)
, CardanoApi.ShelleyLedgerEra (CardanoApiEra era) ~ era
Expand Down

0 comments on commit 1a0fa53

Please sign in to comment.