Skip to content

Commit

Permalink
Update Query.hs
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosLopezDeLara committed Dec 20, 2024
1 parent 71af6f2 commit 38f5132
Showing 1 changed file with 22 additions and 25 deletions.
47 changes: 22 additions & 25 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -918,39 +918,36 @@ callQueryStakeAddressInfoCmd
, Cmd.target
}
, Cmd.addr = StakeAddress _ addr
} = do
let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath
} =
do
let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath

join $
lift
( executeLocalStateQueryExpr localNodeConnInfo target $ runExceptT $ do
AnyCardanoEra era <- easyRunQueryCurrentEra
lift $ executeLocalStateQueryExpr localNodeConnInfo target $ runExceptT $ do
AnyCardanoEra era <- easyRunQueryCurrentEra

sbe <-
requireShelleyBasedEra era
& onNothing (left QueryCmdByronEra)
sbe <-
requireShelleyBasedEra era
& onNothing (left QueryCmdByronEra)

let stakeAddr = Set.singleton $ fromShelleyStakeCredential addr
let stakeAddr = Set.singleton $ fromShelleyStakeCredential addr

(stakeRewardAccountBalances, stakePools) <-
easyRunQuery (queryStakeAddresses sbe stakeAddr networkId)
(stakeRewardAccountBalances, stakePools) <-
easyRunQuery (queryStakeAddresses sbe stakeAddr networkId)

beo <- requireEon BabbageEra era
beo <- requireEon BabbageEra era

stakeDelegDeposits <- easyRunQuery (queryStakeDelegDeposits beo stakeAddr)
stakeDelegDeposits <- easyRunQuery (queryStakeDelegDeposits beo stakeAddr)

stakeVoteDelegatees <- monoidForEraInEonA era $ \ceo ->
easyRunQuery (queryStakeVoteDelegatees ceo stakeAddr)
stakeVoteDelegatees <- monoidForEraInEonA era $ \ceo ->
easyRunQuery (queryStakeVoteDelegatees ceo stakeAddr)

return $
return $
StakeAddressInfoData
(DelegationsAndRewards (stakeRewardAccountBalances, stakePools))
(Map.mapKeys (makeStakeAddress networkId) stakeDelegDeposits)
(Map.mapKeys (makeStakeAddress networkId) stakeVoteDelegatees)
)
& onLeft (left . QueryCmdAcquireFailure)
& onLeft left
pure $
StakeAddressInfoData
(DelegationsAndRewards (stakeRewardAccountBalances, stakePools))
(Map.mapKeys (makeStakeAddress networkId) stakeDelegDeposits)
(Map.mapKeys (makeStakeAddress networkId) stakeVoteDelegatees)
& onLeft (left . QueryCmdAcquireFailure)
& onLeft left

-- -------------------------------------------------------------------------------------------------

Expand Down

0 comments on commit 38f5132

Please sign in to comment.