Skip to content

Commit

Permalink
Merge pull request #914 from IntersectMBO/cl/createtw
Browse files Browse the repository at this point in the history
Update create-treasury-withdrawal
  • Loading branch information
CarlosLopezDeLara authored Sep 25, 2024
2 parents 4a5096b + a58a54e commit fef657b
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 12 deletions.
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

0 comments on commit fef657b

Please sign in to comment.