Skip to content

Commit

Permalink
use readDelegations
Browse files Browse the repository at this point in the history
  • Loading branch information
paweljakubas committed Apr 30, 2024
1 parent 0a3c191 commit 7b9d9f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ import Cardano.Pool.Types
)
import Cardano.Wallet.Api.Types
( ApiCertificate (JoinPool, QuitPool, RegisterRewardAccount)
, ApiEra (..)
, ApiConstructTransaction
, ApiEra (..)
, ApiHealthCheck
, ApiPoolSpecifier (..)
, ApiSerialisedTransaction (..)
Expand Down
16 changes: 10 additions & 6 deletions lib/wallet/src/Cardano/Wallet/IO/Delegation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ handleDelegationVoteRequest
pure (Nothing, Nothing)
optionalDelegationAction <- forM delRequestM $
handleDelegationRequest ctx currentEpochSlotting getKnownPools
getPoolStatus withdrawal votingSameAgain
getPoolStatus withdrawal votingSameAgain

either (throwIO . ExceptionVoting) pure
(WD.guardVoting delRequestM $ toDrepEnriched votingSameAgain)
Expand Down Expand Up @@ -202,11 +202,12 @@ voteAction
-> DRep
-> IO (Tx.VotingAction, Bool)
voteAction ctx action = do
(_,(_, dlg),_) <- W.readWallet ctx
(_, stakeKeyIsRegistered) <- db & \DBLayer{atomically,walletState} ->
atomically $
currentEpochSlotting <- W.getCurrentEpochSlotting netLayer
(calculateWalletDelegations, stakeKeyIsRegistered) <-
db & \DBLayer{atomically,walletState} -> atomically $
(,) <$> readDelegation walletState
<*> W.isStakeKeyRegistered walletState
let dlg = calculateWalletDelegations currentEpochSlotting

traceWith tr $ W.MsgWallet $ MsgIsStakeKeyRegistered stakeKeyIsRegistered

Expand All @@ -217,6 +218,7 @@ voteAction ctx action = do
where
db = ctx ^. dbLayer
tr = ctx ^. logger
netLayer = ctx ^. networkLayer

isDRepSame (Voting drep) = drep == action
isDRepSame (DelegatingVoting _ drep) = drep == action
Expand Down Expand Up @@ -398,8 +400,10 @@ joinStakePool
joinStakePool ctx wid pools poolId poolStatus passphrase = do
pp <- currentProtocolParameters netLayer
currentEpochSlotting <- W.getCurrentEpochSlotting netLayer

(_,(_, dlg),_) <- W.readWallet ctx
calculateWalletDelegations <-
db & \DBLayer{atomically,walletState} -> atomically $
readDelegation walletState
let dlg = calculateWalletDelegations currentEpochSlotting

(delegation, votingM) <-
joinStakePoolDelegationAction
Expand Down

0 comments on commit 7b9d9f2

Please sign in to comment.