Skip to content

Commit

Permalink
cardano-api: Add getStakeAddressCredential to get creadential from …
Browse files Browse the repository at this point in the history
…a stake address
  • Loading branch information
cblp committed Mar 17, 2022
1 parent 6ad9048 commit aa49e91
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions cardano-api/src/Cardano/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ module Cardano.Api (
StakeAddress,
StakeCredential,
makeStakeAddress,
stakeAddressCredential,
StakeKey,
StakeExtendedKey,

Expand Down
4 changes: 4 additions & 0 deletions cardano-api/src/Cardano/Api/Address.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module Cardano.Api.Address (
StakeAddress(..),
StakeCredential(..),
makeStakeAddress,
stakeAddressCredential,
StakeKey,
StakeExtendedKey,

Expand Down Expand Up @@ -649,3 +650,6 @@ fromShelleyStakeReference (Shelley.StakeRefPtr ptr) =
fromShelleyStakeReference Shelley.StakeRefNull =
NoStakeAddress

-- | Get credential from a stake address. This drops the network information.
stakeAddressCredential :: StakeAddress -> StakeCredential
stakeAddressCredential (StakeAddress _ scred) = fromShelleyStakeCredential scred
7 changes: 1 addition & 6 deletions cardano-cli/src/Cardano/CLI/Shelley/Run/Governance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ runGovernanceMIRCertificatePayStakeAddrs mirPot sAddrs rwdAmts (OutputFile oFp)
left $ ShelleyGovernanceCmdMIRCertificateKeyRewardMistmach
oFp (length sAddrs) (length rwdAmts)

let sCreds = map stakeAddrToStakeCredential sAddrs
let sCreds = map stakeAddressCredential sAddrs
mirCert = makeMIRCertificate mirPot (StakeAddressesMIR $ zip sCreds rwdAmts)

firstExceptT ShelleyGovernanceCmdTextEnvWriteError
Expand All @@ -84,11 +84,6 @@ runGovernanceMIRCertificatePayStakeAddrs mirPot sAddrs rwdAmts (OutputFile oFp)
mirCertDesc :: TextEnvelopeDescr
mirCertDesc = "Move Instantaneous Rewards Certificate"

--TODO: expose a pattern for StakeAddress that give us the StakeCredential
stakeAddrToStakeCredential :: StakeAddress -> StakeCredential
stakeAddrToStakeCredential (StakeAddress _ scred) =
fromShelleyStakeCredential scred

runGovernanceMIRCertificateTransfer
:: Lovelace
-> OutputFile
Expand Down

0 comments on commit aa49e91

Please sign in to comment.