Skip to content

Commit

Permalink
Friendlier printing of delegations
Browse files Browse the repository at this point in the history
  • Loading branch information
carlhammann committed Nov 21, 2023
1 parent 39be08a commit 33a8643
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import Cardano.Crypto.Hash (hashToBytesAsHex)
import qualified Cardano.Crypto.Hash.Blake2b as Blake2b
import qualified Cardano.Ledger.BaseTypes as L
import qualified Cardano.Ledger.Core as Core
import qualified Cardano.Ledger.Credential as L
import qualified Cardano.Ledger.Crypto as Crypto
import Cardano.Ledger.Keys (KeyHash (..), KeyRole (..))
import Cardano.Ledger.SafeHash (SafeHash)
Expand Down Expand Up @@ -848,14 +849,19 @@ writeStakeAddressInfo
(\(addr, mBalance, mPoolId, mDRep, mDeposit) ->
Aeson.object
[ "address" .= addr
, "delegation" .= mPoolId
, "voteDelegation" .= mDRep
, "stakeDelegation" .= mPoolId
, "voteDelegation" .= fmap friendlyDRep mDRep
, "rewardAccountBalance" .= mBalance
, "delegationDeposit" .= mDeposit
]
)
merged

friendlyDRep :: L.DRep L.StandardCrypto -> Text
friendlyDRep L.DRepAlwaysAbstain = "alwaysAbstain"
friendlyDRep L.DRepAlwaysNoConfidence = "alwaysNoConfidence"
friendlyDRep (L.DRepCredential cred) = L.credToText cred

merged :: [(StakeAddress, Maybe Lovelace, Maybe PoolId, Maybe (L.DRep L.StandardCrypto), Maybe Lovelace)]
merged =
[ (addr, mBalance, mPoolId, mDRep, mDeposit)
Expand Down

0 comments on commit 33a8643

Please sign in to comment.