Skip to content

Commit

Permalink
Merge pull request #519 from IntersectMBO/ch/fix/dont-show-vote-deleg…
Browse files Browse the repository at this point in the history
…ation-before-conway

Suppress output of `voteDelegation` before Conway
  • Loading branch information
carlhammann authored Jan 4, 2024
2 parents a406a25 + 4f6202a commit aa70225
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ runQueryStakeAddressInfoCmd

return $ do
writeStakeAddressInfo
era
sbe
mOutFile
(DelegationsAndRewards (stakeRewardAccountBalances, stakePools))
(Map.mapKeys (makeStakeAddress networkId) stakeDelegDeposits)
Expand All @@ -843,34 +843,47 @@ runQueryStakeAddressInfoCmd
-- -------------------------------------------------------------------------------------------------

writeStakeAddressInfo
:: CardanoEra era
:: ShelleyBasedEra era
-> Maybe (File () Out)
-> DelegationsAndRewards
-> Map StakeAddress Lovelace -- ^ deposits
-> Map StakeAddress (L.DRep L.StandardCrypto) -- ^ vote delegatees
-> ExceptT QueryCmdError IO ()
writeStakeAddressInfo
era
sbe
mOutFile
(DelegationsAndRewards (stakeAccountBalances, stakePools))
stakeDelegDeposits
voteDelegatees =
firstExceptT QueryCmdWriteFileError . newExceptT
$ writeLazyByteStringOutput mOutFile (encodePretty jsonInfo)
$ writeLazyByteStringOutput mOutFile (encodePretty $ jsonInfo sbe)
where
jsonInfo :: [Aeson.Value]
jsonInfo :: ShelleyBasedEra era -> [Aeson.Value]
jsonInfo =
map
(\(addr, mBalance, mPoolId, mDRep, mDeposit) ->
Aeson.object
[ "address" .= addr
, forEraInEon @ConwayEraOnwards era "delegation" (const "stakeDelegation") .= mPoolId
, "voteDelegation" .= fmap friendlyDRep mDRep
, "rewardAccountBalance" .= mBalance
, "delegationDeposit" .= mDeposit
]
caseShelleyToBabbageOrConwayEraOnwards
( const $ map
(\(addr, mBalance, mPoolId, _mDRep, mDeposit) ->
Aeson.object
[ "address" .= addr
, "delegation" .= mPoolId
, "rewardAccountBalance" .= mBalance
, "delegationDeposit" .= mDeposit
]
)
merged
)
( const $ map
(\(addr, mBalance, mPoolId, mDRep, mDeposit) ->
Aeson.object
[ "address" .= addr
, "stakeDelegation" .= mPoolId
, "voteDelegation" .= fmap friendlyDRep mDRep
, "rewardAccountBalance" .= mBalance
, "delegationDeposit" .= mDeposit
]
)
merged
)
merged

friendlyDRep :: L.DRep L.StandardCrypto -> Text
friendlyDRep L.DRepAlwaysAbstain = "alwaysAbstain"
Expand Down

0 comments on commit aa70225

Please sign in to comment.