Skip to content

Commit

Permalink
Add Delegations.Layer module.
Browse files Browse the repository at this point in the history
  • Loading branch information
paolino committed May 31, 2023
1 parent fe87ec7 commit 3a4758a
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/wallet/cardano-wallet.cabal
Expand Up @@ -267,6 +267,8 @@ library
Cardano.Wallet.DB.Sqlite.Stores
Cardano.Wallet.DB.Sqlite.Types
Cardano.Wallet.DB.Store.Checkpoints
Cardano.Wallet.DB.Store.Delegations.Layer
Cardano.Wallet.DB.Store.Delegations.Model
Cardano.Wallet.DB.Store.Delegations.Store
Cardano.Wallet.DB.Store.Info.Store
Cardano.Wallet.DB.Store.Meta.Layer
Expand Down
36 changes: 36 additions & 0 deletions lib/wallet/src/Cardano/Wallet/DB/Store/Delegations/Layer.hs
@@ -0,0 +1,36 @@
module Cardano.Wallet.DB.Store.Delegations.Layer
( isStakeKeyRegistered
, putDelegationCertificate
, readDelegation
)
where

import Prelude

import Cardano.Wallet.DB.Store.Delegations.Model
( Delegations, DeltaDelegations )
import Cardano.Wallet.Primitive.Types
( DelegationCertificate, SlotNo, WalletDelegation )


isStakeKeyRegistered :: Delegations -> Bool
isStakeKeyRegistered = error "TODO: isStakeKeyRegistered"

-- ^ Binds a stake pool id to a wallet. This will have an influence on
-- the wallet metadata: the last known certificate will indicate to
-- which pool a wallet is currently delegating.
--
-- This is done separately from 'putWalletMeta' because certificate
-- declarations are:
--
-- 1. Stored on-chain.
-- 2. Affected by rollbacks (or said differently, tied to a 'SlotNo').
putDelegationCertificate
:: DelegationCertificate
-> SlotNo
-> DeltaDelegations
putDelegationCertificate = error "TODO: putDelegationCertificate"


readDelegation :: SlotNo -> Delegations -> WalletDelegation
readDelegation = error "TODO: readDelegation"
18 changes: 18 additions & 0 deletions lib/wallet/src/Cardano/Wallet/DB/Store/Delegations/Model.hs
@@ -0,0 +1,18 @@
module Cardano.Wallet.DB.Store.Delegations.Model
( Delegations
, DeltaDelegations
) where


import Cardano.Pool.Types
( PoolId )
import Cardano.Wallet.Delegation.Model
( History, Operation )
import Cardano.Wallet.Primitive.Types
( SlotNo )

-- | Wallet delegation history
type Delegations = History SlotNo PoolId

-- | Delta of wallet delegation history
type DeltaDelegations = Operation SlotNo PoolId

0 comments on commit 3a4758a

Please sign in to comment.