-
Notifications
You must be signed in to change notification settings - Fork 155
/
Allegra.hs
106 lines (88 loc) · 2.7 KB
/
Allegra.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Cardano.Ledger.Allegra
( AllegraEra,
Self,
TxOut,
TxBody,
Value,
Script,
AuxiliaryData,
PParams,
PParamsDelta,
Tx,
Witnesses,
)
where
import Cardano.Ledger.BaseTypes (BlocksMade (..))
import Cardano.Ledger.Crypto (Crypto)
import qualified Cardano.Ledger.Crypto as CC
import qualified Cardano.Ledger.Era as E (Era (Crypto))
import Cardano.Ledger.Shelley.API hiding (PParams, Tx, TxBody, TxOut, WitnessSet)
import Cardano.Ledger.Shelley.EpochBoundary (emptySnapShots)
import Cardano.Ledger.Shelley.LedgerState (minfee)
import qualified Cardano.Ledger.Shelley.PParams as Shelley (PParamsUpdate)
import Cardano.Ledger.Shelley.Tx (WitnessSet)
import Cardano.Ledger.ShelleyMA
import Cardano.Ledger.ShelleyMA.Rules.EraMapping ()
import Cardano.Ledger.ShelleyMA.Rules.Utxo (consumed)
import Cardano.Ledger.ShelleyMA.Timelocks (Timelock)
import Cardano.Ledger.ShelleyMA.TxBody ()
import Cardano.Ledger.Val (Val ((<->)))
import Data.Default.Class (def)
import qualified Data.Map.Strict as Map
type AllegraEra = ShelleyMAEra 'Allegra
instance PraosCrypto c => ApplyTx (AllegraEra c)
instance PraosCrypto c => ApplyBlock (AllegraEra c)
instance PraosCrypto c => GetLedgerView (AllegraEra c)
instance
( Crypto c
) =>
CanStartFromGenesis (AllegraEra c)
where
initialState sg () =
NewEpochState
initialEpochNo
(BlocksMade Map.empty)
(BlocksMade Map.empty)
( EpochState
(AccountState (Coin 0) reserves)
emptySnapShots
( LedgerState
( UTxOState
initialUtxo
(Coin 0)
(Coin 0)
def
)
(DPState (def {_genDelegs = GenDelegs genDelegs}) def)
)
pp
pp
def
)
SNothing
(PoolDistr Map.empty)
where
initialEpochNo = 0
initialUtxo = genesisUTxO sg
reserves =
word64ToCoin (sgMaxLovelaceSupply sg)
<-> balance initialUtxo
genDelegs = sgGenDelegs sg
pp = sgProtocolParams sg
instance PraosCrypto c => ShelleyBasedEra (AllegraEra c)
instance CC.Crypto c => CLI (AllegraEra c) where
evaluateMinFee = minfee
evaluateConsumed = consumed
addKeyWitnesses = addShelleyKeyWitnesses
evaluateMinLovelaceOutput pp _out = _minUTxOValue pp
-- Self-Describing type synomyms
type Self c = ShelleyMAEra 'Allegra c
type Script era = Timelock (E.Crypto era)
type Value era = Coin
type Witnesses era = WitnessSet (E.Crypto era)
type PParamsDelta era = Shelley.PParamsUpdate era