Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding support for script stake credentials and stake address in create-treasury-withdrawal #913

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ data GovernanceActionTreasuryWithdrawalCmdArgs era
, returnAddr :: !StakeIdentifier
, proposalUrl :: !ProposalUrl
, proposalHash :: !(L.SafeHash L.StandardCrypto L.AnchorData)
, treasuryWithdrawal :: ![(VerificationKeyOrHashOrFile StakeKey, Lovelace)]
, treasuryWithdrawal :: ![(StakeIdentifier, Lovelace)]
, constitutionScriptHash :: !(Maybe ScriptHash)
, outFile :: !(File () Out)
}
Expand Down
14 changes: 14 additions & 0 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,20 @@ pTransferAmt =
, Opt.help "The amount to transfer."
]

pTreasuryWithdrawalAmt :: Parser Lovelace
pTreasuryWithdrawalAmt =
Opt.option (readerFromParsecParser parseLovelace) $
mconcat
[ Opt.long "transfer"
, Opt.metavar "LOVELACE"
, Opt.help $
mconcat
[ "The amount of lovelace the proposal intends to withdraw from the Treasury. "
, "Multiple withdrawals can be proposed in a single governance action "
, "by repeating the --funds-receiving-stake and --transfer options as many times as needed."
]
]

rHexHash
:: ()
=> SerialiseAsRawBytes (Hash a)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ pGovernanceActionTreasuryWithdrawalCmd era = do
<*> pStakeIdentifier (Just "deposit-return")
<*> pAnchorUrl
<*> pAnchorDataHash
<*> some ((,) <$> pStakeVerificationKeyOrHashOrFile (Just "funds-receiving") <*> pTransferAmt)
<*> some ((,) <$> pStakeIdentifier (Just "funds-receiving") <*> pTreasuryWithdrawalAmt)
<*> optional pConstitutionScriptHash
<*> pFileOutDirection "out-file" "Output filepath of the treasury withdrawal."
)
Expand Down
13 changes: 4 additions & 9 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,6 @@ runGovernanceActionCreateProtocolParametersUpdateCmd eraBasedPParams' = do
pure . addCostModelsToEraBasedProtocolParametersUpdate alonzoOnwards costModels $
uppNewPParams eraBasedPParams'

readStakeKeyHash
:: VerificationKeyOrHashOrFile StakeKey -> ExceptT GovernanceActionsError IO (Hash StakeKey)
readStakeKeyHash stake =
modifyError GovernanceActionsCmdReadFileError $
readVerificationKeyOrHashOrFile AsStakeKey stake

addCostModelsToEraBasedProtocolParametersUpdate
:: AlonzoEraOnwards era
-> L.CostModels
Expand Down Expand Up @@ -439,9 +433,10 @@ runGovernanceActionTreasuryWithdrawalCmd
firstExceptT GovernanceActionsReadStakeCredErrror $
getStakeCredentialFromIdentifier returnAddr

withdrawals <- forM treasuryWithdrawal $ \(verificationKeyOrHashOrFile, lovelace) -> do
stakeKeyHash <- readStakeKeyHash verificationKeyOrHashOrFile
pure (networkId, StakeCredentialByKey stakeKeyHash, lovelace)
withdrawals <- forM treasuryWithdrawal $ \(stakeIdentifier, lovelace) -> do
stakeCredential <-
firstExceptT GovernanceActionsReadStakeCredErrror $ getStakeCredentialFromIdentifier stakeIdentifier
pure (networkId, stakeCredential, lovelace)

let sbe = conwayEraOnwardsToShelleyBasedEra eon
treasuryWithdrawals =
Expand Down
2 changes: 2 additions & 0 deletions cardano-cli/test/cardano-cli-golden/files/golden/help.cli
Original file line number Diff line number Diff line change
Expand Up @@ -6082,6 +6082,8 @@ Usage: cardano-cli conway governance action create-treasury-withdrawal
( --funds-receiving-stake-verification-key STRING
| --funds-receiving-stake-verification-key-file FILEPATH
| --funds-receiving-stake-key-hash HASH
| --funds-receiving-stake-script-file FILEPATH
| --funds-receiving-stake-address ADDRESS
)
--transfer LOVELACE)
[--constitution-script-hash HASH]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Usage: cardano-cli conway governance action create-treasury-withdrawal
( --funds-receiving-stake-verification-key STRING
| --funds-receiving-stake-verification-key-file FILEPATH
| --funds-receiving-stake-key-hash HASH
| --funds-receiving-stake-script-file FILEPATH
| --funds-receiving-stake-address ADDRESS
)
--transfer LOVELACE)
[--constitution-script-hash HASH]
Expand Down Expand Up @@ -46,7 +48,15 @@ Available options:
Filepath of the staking verification key.
--funds-receiving-stake-key-hash HASH
Stake verification key hash (hex-encoded).
--transfer LOVELACE The amount to transfer.
--funds-receiving-stake-script-file FILEPATH
Filepath of the staking script.
--funds-receiving-stake-address ADDRESS
Target stake address (bech32 format).
--transfer LOVELACE The amount of lovelace the proposal intends to
withdraw from the Treasury. Multiple withdrawals can
be proposed in a single governance action by
repeating the --funds-receiving-stake and --transfer
options as many times as needed.
--constitution-script-hash HASH
Constitution script hash (hex-encoded). Obtain it
with "cardano-cli hash script ...".
Expand Down
Loading