Skip to content

Commit c95100b

Browse files
committed
Move AccountState to Cardano.Ledger.State from cardano-ledger-shelley
1 parent fd9af72 commit c95100b

File tree

15 files changed

+68
-71
lines changed

15 files changed

+68
-71
lines changed

eras/shelley/impl/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## 1.16.0.0
44

5+
* Move `AccountState` to `Cardano.Ledger.State`
56
* Deprecated `RewardAccounts`
67
* Deprecated `utxosUtxoL`
78
* Added `CanGetUTxO` and `CanSetUTxO` instances for `EpochState`, `UTxOState`, `NewEpochState`, `LedgerState`

eras/shelley/impl/src/Cardano/Ledger/Shelley/AdaPots.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,14 @@ import Cardano.Ledger.Compactible (fromCompact)
3333
import Cardano.Ledger.Core
3434
import Cardano.Ledger.Shelley.Governance (EraGov (..))
3535
import Cardano.Ledger.Shelley.LedgerState.Types (
36-
AccountState (..),
3736
EpochState (..),
3837
LedgerState (..),
3938
UTxOState (..),
4039
lsUTxOStateL,
4140
utxosGovStateL,
4241
)
4342
import Cardano.Ledger.Shelley.TxBody (unWithdrawals)
44-
import Cardano.Ledger.State (UTxO (..), coinBalance, txInsFilter, txouts)
43+
import Cardano.Ledger.State
4544
import Cardano.Ledger.UMap (sumRewardsUView)
4645
import Control.DeepSeq (NFData)
4746
import Data.Foldable (fold)

eras/shelley/impl/src/Cardano/Ledger/Shelley/LedgerState.hs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -154,17 +154,4 @@ import Cardano.Ledger.Shelley.PParams (pvCanFollow)
154154
import Cardano.Ledger.Shelley.RewardUpdate
155155
import Cardano.Ledger.Shelley.Rules.Ppup (ShelleyGovState (..))
156156
import Cardano.Ledger.Shelley.UTxO (consumed, produced)
157-
import Cardano.Ledger.State (
158-
CanGetUTxO (..),
159-
CanSetUTxO (..),
160-
UTxO (..),
161-
ssDelegationsL,
162-
ssFeeL,
163-
ssPoolParamsL,
164-
ssStakeDistrL,
165-
ssStakeGoL,
166-
ssStakeL,
167-
ssStakeMarkL,
168-
ssStakeMarkPoolDistrL,
169-
ssStakeSetL,
170-
)
157+
import Cardano.Ledger.State

eras/shelley/impl/src/Cardano/Ledger/Shelley/LedgerState/IncrementalStake.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import Cardano.Ledger.Shelley.Rewards (
5656
aggregateRewards,
5757
filterRewards,
5858
)
59-
import Cardano.Ledger.State (SnapShot (..), Stake (..), UTxO (..))
59+
import Cardano.Ledger.State
6060
import Cardano.Ledger.UMap (
6161
UMElem,
6262
UMap (..),

eras/shelley/impl/src/Cardano/Ledger/Shelley/LedgerState/NewEpochState.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import Cardano.Ledger.Coin (Coin (..), addDeltaCoin)
2424
import Cardano.Ledger.Keys (GenDelegPair (..), GenDelegs (..))
2525
import Cardano.Ledger.Shelley.Core
2626
import Cardano.Ledger.Shelley.LedgerState.Types
27-
import Cardano.Ledger.State (UTxO (..), coinBalance)
27+
import Cardano.Ledger.State
2828
import qualified Cardano.Ledger.UMap as UM
2929
import Cardano.Ledger.Val ((<+>), (<->))
3030
import Data.Default (def)

eras/shelley/impl/src/Cardano/Ledger/Shelley/LedgerState/PulsingReward.hs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,7 @@ import Cardano.Ledger.Shelley.Rewards (
7373
sumRewards,
7474
)
7575
import Cardano.Ledger.Slot (EpochSize (..))
76-
import Cardano.Ledger.State (
77-
SnapShot (..),
78-
SnapShots (..),
79-
Stake (..),
80-
sumAllStake,
81-
sumStakePerPool,
82-
)
76+
import Cardano.Ledger.State
8377
import qualified Cardano.Ledger.UMap as UM
8478
import Cardano.Ledger.Val ((<->))
8579
import Data.Group (invert)

eras/shelley/impl/src/Cardano/Ledger/Shelley/LedgerState/Types.hs

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,7 @@ import Cardano.Ledger.Shelley.Core
6565
import Cardano.Ledger.Shelley.Era (ShelleyEra)
6666
import Cardano.Ledger.Shelley.PoolRank (NonMyopic (..))
6767
import Cardano.Ledger.Shelley.RewardUpdate (PulsingRewUpdate (..))
68-
import Cardano.Ledger.State (
69-
CanGetUTxO (..),
70-
CanSetUTxO (..),
71-
PoolDistr (..),
72-
SnapShots (..),
73-
UTxO (..),
74-
ssStakeDistrL,
75-
ssStakeMarkL,
76-
)
68+
import Cardano.Ledger.State
7769
import Cardano.Ledger.UMap (UMap (..))
7870
import Control.DeepSeq (NFData)
7971
import Control.Monad.State.Strict (evalStateT)
@@ -96,35 +88,6 @@ type RewardAccounts =
9688
Map (Credential 'Staking) Coin
9789
{-# DEPRECATED RewardAccounts "In favor of `Map` (`Credential` `Staking`) `Coin`" #-}
9890

99-
data AccountState = AccountState
100-
{ asTreasury :: !Coin
101-
, asReserves :: !Coin
102-
}
103-
deriving (Show, Eq, Generic)
104-
105-
instance EncCBOR AccountState where
106-
encCBOR (AccountState t r) =
107-
encodeListLen 2 <> encCBOR t <> encCBOR r
108-
109-
instance DecCBOR AccountState where
110-
decCBOR =
111-
decodeRecordNamed "AccountState" (const 2) $ AccountState <$> decCBOR <*> decCBOR
112-
113-
instance ToJSON AccountState where
114-
toJSON = object . toAccountStatePairs
115-
toEncoding = pairs . mconcat . toAccountStatePairs
116-
117-
toAccountStatePairs :: KeyValue e a => AccountState -> [a]
118-
toAccountStatePairs as@(AccountState _ _) =
119-
let AccountState {asTreasury, asReserves} = as
120-
in [ "treasury" .= asTreasury
121-
, "reserves" .= asReserves
122-
]
123-
124-
instance NoThunks AccountState
125-
126-
instance NFData AccountState
127-
12891
data EpochState era = EpochState
12992
{ esAccountState :: !AccountState
13093
, esLState :: !(LedgerState era)
@@ -607,9 +570,6 @@ instance
607570
instance Default (UTxOState era) => Default (LedgerState era) where
608571
def = LedgerState def def
609572

610-
instance Default AccountState where
611-
def = AccountState (Coin 0) (Coin 0)
612-
613573
-- =============================================================
614574
-- Lenses for types found inside NewEpochState and its fields
615575

eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Arbitrary.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,6 @@ instance
203203
-- > instance OVERLAPPING_ GSubtermsIncl (K1 i a) b where
204204
shrink = recursivelyShrink
205205

206-
instance Arbitrary AccountState where
207-
arbitrary = AccountState <$> arbitrary <*> arbitrary
208-
shrink = genericShrink
209-
210206
instance Arbitrary IncrementalStake where
211207
arbitrary = IStake <$> arbitrary <*> pure mempty -- Once in Conway Ptrs Map will be removed
212208
shrink = genericShrink

eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/TreeDiff.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ instance ToExpr PulsingRewUpdate where
126126
instance ToExpr RewardUpdate
127127

128128
-- LedgerState/Types
129-
instance ToExpr AccountState
130129

131130
instance
132131
( ToExpr (TxOut era)

libs/cardano-ledger-core/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## 1.17.0.0
44

5+
* Move `AccountState` to `Cardano.Ledger.State` from `cardano-ledger-shelley`
56
* Move `Cardano.Ledger.PoolDistr` module contents into `Cardano.Ledger.State` and deprecated the former
67
* Move `Cardano.Ledger.SnapShots` module contents into `Cardano.Ledger.State` and deprecated the former
78
* Move `Cardano.Ledger.UTxO` module contents into `Cardano.Ledger.State` and deprecated the former

0 commit comments

Comments
 (0)