-
Notifications
You must be signed in to change notification settings - Fork 157
/
Mary.hs
100 lines (83 loc) · 2.69 KB
/
Mary.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
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Cardano.Ledger.Mary
( MaryEra,
Self,
TxOut,
Value,
TxBody,
Script,
AuxiliaryData,
PParams,
PParamsDelta,
Tx,
)
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 qualified Cardano.Ledger.Mary.Value as V (Value)
import Cardano.Ledger.Shelley.API hiding (TxBody)
import Cardano.Ledger.Shelley.EpochBoundary (emptySnapShots)
import Cardano.Ledger.Shelley.LedgerState (minfee)
import qualified Cardano.Ledger.Shelley.PParams as Shelley (PParamsUpdate)
import Cardano.Ledger.ShelleyMA
import Cardano.Ledger.ShelleyMA.Rules.EraMapping ()
import Cardano.Ledger.ShelleyMA.Rules.Utxo (consumed, scaledMinDeposit)
import Cardano.Ledger.ShelleyMA.Rules.Utxow ()
import Cardano.Ledger.ShelleyMA.Timelocks (Timelock)
import Cardano.Ledger.Val (Val ((<->)), coin, inject)
import Data.Default.Class (def)
import qualified Data.Map.Strict as Map
instance PraosCrypto c => ApplyTx (MaryEra c)
instance PraosCrypto c => ApplyBlock (MaryEra c)
instance PraosCrypto c => GetLedgerView (MaryEra c)
instance Crypto c => CanStartFromGenesis (MaryEra 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 =
coin $
inject (word64ToCoin (sgMaxLovelaceSupply sg))
<-> balance initialUtxo
genDelegs = sgGenDelegs sg
pp = sgProtocolParams sg
instance PraosCrypto c => ShelleyBasedEra (MaryEra c)
instance CC.Crypto c => CLI (MaryEra c) where
evaluateMinFee = minfee
evaluateConsumed = consumed
addKeyWitnesses = addShelleyKeyWitnesses
evaluateMinLovelaceOutput pp (TxOut _ v) = scaledMinDeposit v (_minUTxOValue pp)
-- Self-Describing type synomyms
type MaryEra c = ShelleyMAEra 'Mary c
type Self c = ShelleyMAEra 'Mary c
type Script era = Timelock (E.Crypto era)
type Value era = V.Value (E.Crypto era)
type PParamsDelta era = Shelley.PParamsUpdate era