Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Support for multiple (Shelley-based) eras in the ledger.
Synopsis
- class (Crypto (EraCrypto era), Typeable era, KnownNat (ProtVerLow era), KnownNat (ProtVerHigh era), ProtVerLow era <= ProtVerHigh era, MinVersion <= ProtVerLow era, MinVersion <= ProtVerHigh era, CmpNat (ProtVerLow era) MaxVersion ~ 'LT, CmpNat (ProtVerHigh era) MaxVersion ~ 'LT, ProtVerLow era <= MaxVersion, ProtVerHigh era <= MaxVersion) ⇒ Era era where
- type EraCrypto era ∷ Type
- type PreviousEra era = (r ∷ Type) | r → era
- type ProtVerLow era ∷ Nat
- type ProtVerHigh era ∷ Nat
- eraName ∷ String
- getTxOutAddr ∷ EraTxOut era ⇒ TxOut era → Addr (EraCrypto era)
- getTxOutCompactAddr ∷ EraTxOut era ⇒ TxOut era → CompactAddr (EraCrypto era)
- getTxOutEitherAddr ∷ EraTxOut era ⇒ TxOut era → Either (Addr (EraCrypto era)) (CompactAddr (EraCrypto era))
- getTxOutBootstrapAddress ∷ EraTxOut era ⇒ TxOut era → Maybe (BootstrapAddress (EraCrypto era))
- getAllTxInputs ∷ EraTxBody era ⇒ TxBody era → Set (TxIn (EraCrypto era))
- type family TranslationContext era ∷ Type
- class (Era era, Era (PreviousEra era)) ⇒ TranslateEra era f where
- type TranslationError era f ∷ Type
- translateEra ∷ TranslationContext era → f (PreviousEra era) → Except (TranslationError era f) (f era)
- translateEra' ∷ (TranslateEra era f, TranslationError era f ~ Void) ⇒ TranslationContext era → f (PreviousEra era) → f era
- translateEraMaybe ∷ (TranslateEra era f, TranslationError era f ~ ()) ⇒ TranslationContext era → f (PreviousEra era) → Maybe (f era)
- class (EraTx era, Eq (TxSeq era), Show (TxSeq era), EncCBORGroup (TxSeq era), DecCBOR (Annotator (TxSeq era))) ⇒ EraSegWits era where
Documentation
class (Crypto (EraCrypto era), Typeable era, KnownNat (ProtVerLow era), KnownNat (ProtVerHigh era), ProtVerLow era <= ProtVerHigh era, MinVersion <= ProtVerLow era, MinVersion <= ProtVerHigh era, CmpNat (ProtVerLow era) MaxVersion ~ 'LT, CmpNat (ProtVerHigh era) MaxVersion ~ 'LT, ProtVerLow era <= MaxVersion, ProtVerHigh era <= MaxVersion) ⇒ Era era where Source #
type EraCrypto era ∷ Type Source #
type PreviousEra era = (r ∷ Type) | r → era Source #
Map an era to its predecessor.
For example:
type instance PreviousEra (AllegraEra c) = ShelleyEra c
type ProtVerLow era ∷ Nat Source #
Lowest major protocol version for this era
type ProtVerHigh era ∷ Nat Source #
Highest major protocol version for this era. By default se to ProtVerLow
type ProtVerHigh era = ProtVerLow era
Textual name of the current era.
Designed to be used with TypeApplications
:
>>>
eraName @(ByronEra StandardCrypto)
Byron
getTxOutAddr ∷ EraTxOut era ⇒ TxOut era → Addr (EraCrypto era) Source #
Deprecated: In favor of addrTxOutL
getTxOutCompactAddr ∷ EraTxOut era ⇒ TxOut era → CompactAddr (EraCrypto era) Source #
Deprecated: In favor of compactAddrTxOutL
getTxOutEitherAddr ∷ EraTxOut era ⇒ TxOut era → Either (Addr (EraCrypto era)) (CompactAddr (EraCrypto era)) Source #
Deprecated: In favor of addrEitherTxOutL
getTxOutBootstrapAddress ∷ EraTxOut era ⇒ TxOut era → Maybe (BootstrapAddress (EraCrypto era)) Source #
Deprecated: In favor of bootAddrTxOutF
Get the Bootsrap address from the TxOut. Returns Nothing
if it is a
Shelley address or newer
getAllTxInputs ∷ EraTxBody era ⇒ TxBody era → Set (TxIn (EraCrypto era)) Source #
The validity of any individual block depends only on a subset of the UTxO stored in the ledger state. The consensus layer makes use of this fact, and uses the function below to to retrieve the needed UTxO from disk and present only those to the ledger. It is therefore neccessary that this function account for all the different types of inputs inside a transaction.
type family TranslationContext era ∷ Type Source #
Per-era context used for TranslateEra
.
This context will be passed to the translation instances of all types of that particular era. In practice, most instances won't need the context, but this approach makes the translation composable (as opposed to having a separate context per type).
class (Era era, Era (PreviousEra era)) ⇒ TranslateEra era f where Source #
Translation of types between eras, e.g., from Shelley to Allegra.
When era
is just a phantom type parameter, an empty standalone deriving can be used:
newtype Foo era = Foo Int instance TranslateEra (Allegra c) Foo
Note that one could use DerivingAnyClass
(deriving (TranslateEra (Allegra
c))
), but this would introduce an undesired coupling between the
era-parametric type and (a) particular era(s). The intention is to have a
module with orphan instances per era.
In most cases, the era
parameter won't be phantom, and a manual instance
will have to be written:
newtype Bar era = Bar (TxBody era) instance CC.Crypto c => TranslateEra (Allegra c) Bar where translateEra ctxt = Bar <$> translateEra ctxt -- With the following instance being in scope: instance CC.Crypto c => TranslatEra (Allegra c) TxBody
Note: we use PreviousEra
instead of NextEra
as an era definitely knows
its predecessor, but not necessarily its successor. Moreover, one could argue
that it makes more sense to define the translation from era A to era B where
era B is defined, than where era A is defined.
Nothing
type TranslationError era f ∷ Type Source #
Most translations should be infallible (default instance), but we leave the door open for partial translations.
For a partial translation, override the default type to be ()
or a
concrete error type.
type TranslationError era f = Void
translateEra ∷ TranslationContext era → f (PreviousEra era) → Except (TranslationError era f) (f era) Source #
Translate a type f
parameterised by the era from an era to the era
after it.
The translation is a given the translation context of era
.
A default instance is provided for when the two types are Coercible
.
default translateEra ∷ (Coercible (f (PreviousEra era)) (f era), TranslationContext era ~ NoGenesis era) ⇒ TranslationContext era → f (PreviousEra era) → Except (TranslationError era f) (f era) Source #
translateEra' ∷ (TranslateEra era f, TranslationError era f ~ Void) ⇒ TranslationContext era → f (PreviousEra era) → f era Source #
Variant of translateEra
for when TranslationError
is Void
and the
translation thus cannot fail.
translateEraMaybe ∷ (TranslateEra era f, TranslationError era f ~ ()) ⇒ TranslationContext era → f (PreviousEra era) → Maybe (f era) Source #
Variant of translateEra
for when TranslationError
is ()
, converting
the result to a Maybe
.
class (EraTx era, Eq (TxSeq era), Show (TxSeq era), EncCBORGroup (TxSeq era), DecCBOR (Annotator (TxSeq era))) ⇒ EraSegWits era where Source #
Indicates that an era supports segregated witnessing.
This class embodies an isomorphism between 'TxSeq era' and 'StrictSeq
(Tx era)', witnessed by fromTxSeq
and toTxSeq
.
fromTxSeq ∷ TxSeq era → StrictSeq (Tx era) Source #
toTxSeq ∷ StrictSeq (Tx era) → TxSeq era Source #
hashTxSeq ∷ TxSeq era → Hash (HASH (EraCrypto era)) EraIndependentBlockBody Source #
Get the block body hash from the TxSeq. Note that this is not a regular "hash the stored bytes" function since the block body hash forms a small Merkle tree.
numSegComponents ∷ Word64 Source #
The number of segregated components