Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add governance action deposits to the output of `query stake-address-info #1032

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

registration*

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you clarify?

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
Loading