Skip to content

Commit

Permalink
Merge pull request #1032 from IntersectMBO/cl/sai
Browse files Browse the repository at this point in the history
Add governance action deposits to the output of `query stake-address-info
  • Loading branch information
CarlosLopezDeLara authored Feb 6, 2025
2 parents 1bc8d05 + b8e2793 commit 8e3cb63
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
1 change: 0 additions & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,3 @@ write-ghc-environment-files: always
-- IMPORTANT
-- Do NOT add more source-repository-package stanzas here unless they are strictly
-- temporary! Please read the section in CONTRIBUTING about updating dependencies.

40 changes: 34 additions & 6 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -886,11 +886,16 @@ runQueryStakeAddressInfoCmd

writeStakeAddressInfo sbe said mOutFile

-- | Container for data returned by 'callQueryStakeAddressInfoCmd'
-- | Container for data returned by 'callQueryStakeAddressInfoCmd' where:
data StakeAddressInfoData = StakeAddressInfoData
-- \| rewards: map of stake addresses to poolid and rewards balance
{ rewards :: DelegationsAndRewards
, deposits :: Map StakeAddress Lovelace
, delegatees :: Map StakeAddress (L.DRep L.StandardCrypto)
, -- \| deposits: the stake address registration deposit
deposits :: Map StakeAddress Lovelace
, -- \| gaDeposits: map of governance actions and their deposits associated to the reward account. Empty if not used in GA.
gaDeposits :: Map (L.GovActionId L.StandardCrypto) Lovelace
, -- \| delegatees: map of stake addresses and their delegation preference
delegatees :: Map StakeAddress (L.DRep L.StandardCrypto)
}

callQueryStakeAddressInfoCmd
Expand Down Expand Up @@ -923,13 +928,34 @@ callQueryStakeAddressInfoCmd

stakeDelegDeposits <- easyRunQuery (queryStakeDelegDeposits beo stakeAddr)

stakeVoteDelegatees <- monoidForEraInEonA era $ \ceo ->
easyRunQuery (queryStakeVoteDelegatees ceo stakeAddr)
(stakeVoteDelegatees, gaDeposits) <-
monoidForEraInEonA
(toCardanoEra beo)
( \ceo -> do
stakeVoteDelegatees <- easyRunQuery (queryStakeVoteDelegatees ceo stakeAddr)

govActionStates :: (Seq.Seq (L.GovActionState (ShelleyLedgerEra era))) <-
easyRunQuery $ queryProposals ceo Set.empty

let gaDeposits =
conwayEraOnwardsConstraints ceo $
Map.fromList
[ (L.gasId gas, L.pProcDeposit proc)
| gas <- toList govActionStates
, let proc = L.gasProposalProcedure gas
, let rewardAccount = L.pProcReturnAddr proc
stakeCredential :: Api.StakeCredential = fromShelleyStakeCredential $ L.raCredential rewardAccount
, stakeCredential == fromShelleyStakeCredential addr
]

return (stakeVoteDelegatees, gaDeposits)
)

pure $
StakeAddressInfoData
(DelegationsAndRewards (stakeRewardAccountBalances, stakePools))
(Map.mapKeys (makeStakeAddress networkId) stakeDelegDeposits)
gaDeposits
(Map.mapKeys (makeStakeAddress networkId) stakeVoteDelegatees)
& onLeft (left . QueryCmdAcquireFailure)
& onLeft left
Expand All @@ -946,6 +972,7 @@ writeStakeAddressInfo
( StakeAddressInfoData
{ rewards = DelegationsAndRewards (stakeAccountBalances, stakePools)
, deposits = stakeDelegDeposits
, gaDeposits = gaDeposits
, delegatees = voteDelegatees
}
)
Expand Down Expand Up @@ -976,7 +1003,8 @@ writeStakeAddressInfo
, "stakeDelegation" .= mPoolId
, "voteDelegation" .= fmap friendlyDRep mDRep
, "rewardAccountBalance" .= mBalance
, "delegationDeposit" .= mDeposit
, "stakeRegistrationDeposit" .= mDeposit
, "govActionDeposits" .= gaDeposits
]
)
merged
Expand Down

0 comments on commit 8e3cb63

Please sign in to comment.