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 authored and newhoggy committed Mar 7, 2023
1 parent 2120fac commit f2c5e63
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 @@ -97,6 +97,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 @@ -47,6 +47,7 @@ module Cardano.Api.Address (
StakeAddress(..),
StakeCredential(..),
makeStakeAddress,
stakeAddressCredential,
StakeKey,
StakeExtendedKey,

Expand Down Expand Up @@ -718,3 +719,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 @@ -87,7 +87,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 @@ -97,11 +97,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 f2c5e63

Please sign in to comment.