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 23, 2023
1 parent 35eac04 commit 1b21c7e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 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 @@ -849,14 +850,20 @@ 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 -- this will pring "keyHash-..." or "scriptHash-...", depending on the type of credential

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 1b21c7e

Please sign in to comment.