Skip to content

Commit

Permalink
Add support for --drep-script-hash --always-abstain --always-no-confi…
Browse files Browse the repository at this point in the history
…dence to vote-delegation-certificate command.
  • Loading branch information
newhoggy committed Sep 12, 2023
1 parent 7e6af26 commit 8bbf602
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ data StakeAddressCmds era
| StakeAddressVoteDelegationCertificateCmd
(ConwayEraOnwards era)
StakeIdentifier
(VerificationKeyOrHashOrFile DRepKey)
VoteDelegationTarget
(File () Out)
| StakeAddressDeregistrationCertificateCmd
(ShelleyBasedEra era)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ pStakeAddressVoteDelegationCertificateCmd era = do
$ Opt.info
( StakeAddressVoteDelegationCertificateCmd w
<$> pStakeIdentifier
<*> pDRepVerificationKeyOrHashOrFile
<*> pVoteDelegationTarget
<*> pOutputFile
)
$ Opt.progDesc
Expand Down
24 changes: 11 additions & 13 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/StakeAddress.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import Cardano.Api.Shelley
import Cardano.CLI.EraBased.Commands.StakeAddress
import Cardano.CLI.Read
import Cardano.CLI.Types.Common
import Cardano.CLI.Types.Errors.DelegationError
import Cardano.CLI.Types.Errors.StakeAddressCmdError
import Cardano.CLI.Types.Errors.StakeAddressRegistrationError
import Cardano.CLI.Types.Governance
Expand Down Expand Up @@ -54,10 +53,10 @@ runStakeAddressCmds = \case
runStakeAddressRegistrationCertificateCmd sbe stakeIdentifier mDeposit outputFp
StakeAddressStakeDelegationCertificateCmd sbe stakeIdentifier stkPoolVerKeyHashOrFp outputFp ->
runStakeAddressStakeDelegationCertificateCmd sbe stakeIdentifier stkPoolVerKeyHashOrFp outputFp
StakeAddressStakeAndVoteDelegationCertificateCmd w stakeIdentifier stakePoolVerificationKeyHashSource drepVerificationKeyHashSource outputFp ->
runStakeAddressStakeAndVoteDelegationCertificateCmd w stakeIdentifier stakePoolVerificationKeyHashSource drepVerificationKeyHashSource outputFp
StakeAddressVoteDelegationCertificateCmd w stakeIdentifier drepVerificationKeyHashSource outputFp ->
runStakeAddressVoteDelegationCertificateCmd w stakeIdentifier drepVerificationKeyHashSource outputFp
StakeAddressStakeAndVoteDelegationCertificateCmd w stakeIdentifier stakePoolVerificationKeyHashSource voteDelegationTarget outputFp ->
runStakeAddressStakeAndVoteDelegationCertificateCmd w stakeIdentifier stakePoolVerificationKeyHashSource voteDelegationTarget outputFp
StakeAddressVoteDelegationCertificateCmd w stakeIdentifier voteDelegationTarget outputFp ->
runStakeAddressVoteDelegationCertificateCmd w stakeIdentifier voteDelegationTarget outputFp
StakeAddressDeregistrationCertificateCmd sbe stakeIdentifier mDeposit outputFp ->
runStakeAddressDeregistrationCertificateCmd sbe stakeIdentifier mDeposit outputFp

Expand Down Expand Up @@ -245,23 +244,22 @@ runStakeAddressStakeAndVoteDelegationCertificateCmd w stakeVerifier poolVKeyOrHa
runStakeAddressVoteDelegationCertificateCmd :: ()
=> ConwayEraOnwards era
-> StakeIdentifier
-- ^ Delegator stake verification key, verification key file or script file.
-> VerificationKeyOrHashOrFile DRepKey
-- ^ Delegatee stake pool verification key or verification key file or
-> VoteDelegationTarget
-- ^ Delegatee stake pool verification key or verification key file or verification key hash.
-> File () Out
-> ExceptT StakeAddressCmdError IO ()
runStakeAddressVoteDelegationCertificateCmd w stakeVerifier drepVKeyOrHashOrFile outFp =
runStakeAddressVoteDelegationCertificateCmd w stakeVerifier voteDelegationTarget outFp =
conwayEraOnwardsConstraints w $ do
stakeCredential <-
getStakeCredentialFromIdentifier stakeVerifier
& firstExceptT StakeAddressCmdStakeCredentialError

DRepKeyHash drepKeyHash <-
lift (readVerificationKeyOrHashOrTextEnvFile AsDRepKey drepVKeyOrHashOrFile)
& onLeft (left . StakeAddressCmdDelegationError . DelegationDRepReadError)
drep <-
readVoteDelegationTarget voteDelegationTarget
& firstExceptT StakeAddressCmdDelegationError

let drepCred = Ledger.DRepCredential $ Ledger.KeyHashObj drepKeyHash
let delegatee = Ledger.DelegVote (conwayEraOnwardsConstraints w drepCred)
let delegatee = Ledger.DelegVote drep

let certificate =
ConwayCertificate w
Expand Down
5 changes: 4 additions & 1 deletion cardano-cli/test/cardano-cli-golden/files/golden/help.cli
Original file line number Diff line number Diff line change
Expand Up @@ -6847,9 +6847,12 @@ Usage: cardano-cli conway stake-address vote-delegation-certificate
| --stake-script-file FILE
| --stake-address ADDRESS
)
( --drep-verification-key STRING
( --drep-script-hash HASH
| --drep-verification-key STRING
| --drep-verification-key-file FILE
| --drep-key-hash HASH
| --always-abstain
| --always-no-confidence
)
--out-file FILE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ Usage: cardano-cli conway stake-address vote-delegation-certificate
| --stake-script-file FILE
| --stake-address ADDRESS
)
( --drep-verification-key STRING
( --drep-script-hash HASH
| --drep-verification-key STRING
| --drep-verification-key-file FILE
| --drep-key-hash HASH
| --always-abstain
| --always-no-confidence
)
--out-file FILE

Expand All @@ -20,12 +23,15 @@ Available options:
Filepath of the staking verification key.
--stake-script-file FILE Filepath of the staking script.
--stake-address ADDRESS Target stake address (bech32 format).
--drep-script-hash HASH DRep script hash (hex-encoded).
--drep-verification-key STRING
DRep verification key (Bech32 or hex-encoded).
--drep-verification-key-file FILE
Filepath of the DRep verification key.
--drep-key-hash HASH DRep verification key hash (either Bech32-encoded or
hex-encoded). Zero or more occurences of this option
is allowed.
--always-abstain Abstain from voting on all proposals.
--always-no-confidence Always vote no confidence
--out-file FILE The output file.
-h,--help Show this help text

0 comments on commit 8bbf602

Please sign in to comment.