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

Enable deposit return scripts and constitutional scripts #609

Merged
merged 7 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repository cardano-haskell-packages
-- you need to run if you change them
index-state:
, hackage.haskell.org 2024-02-23T02:09:28Z
, cardano-haskell-packages 2024-02-22T17:04:08Z
, cardano-haskell-packages 2024-02-23T11:16:54Z

packages:
cardano-cli
Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ library
, binary
, bytestring
, canonical-json
, cardano-api ^>= 8.39.0.0
, cardano-api ^>= 8.39.1.0
, cardano-binary
, cardano-crypto
, cardano-crypto-class ^>= 2.1.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ data GoveranceActionUpdateCommitteeCmdArgs era
{ eon :: !(ConwayEraOnwards era)
, networkId :: !L.Network
, deposit :: !Lovelace
, returnAddress :: !(VerificationKeyOrHashOrFile StakeKey)
, returnAddress :: !StakeIdentifier
, proposalUrl :: !ProposalUrl
, proposalHash :: !(L.SafeHash L.StandardCrypto L.AnchorData)
, oldCommitteeVkeySource :: ![VerificationKeyOrHashOrFile CommitteeColdKey]
Expand All @@ -61,12 +61,13 @@ data GovernanceActionCreateConstitutionCmdArgs era
{ eon :: !(ConwayEraOnwards era)
, networkId :: !L.Network
, deposit :: !Lovelace
, stakeCredential :: !(VerificationKeyOrHashOrFile StakeKey)
, stakeCredential :: !StakeIdentifier
, mPrevGovernanceActionId :: !(Maybe (TxId, Word32))
, proposalUrl :: !ProposalUrl
, proposalHash :: !(L.SafeHash L.StandardCrypto L.AnchorData)
, constitutionUrl :: !ConstitutionUrl
, constitutionHash :: !(L.SafeHash L.StandardCrypto L.AnchorData)
, constitutionScript :: !(Maybe ScriptHash)
, outFile :: !(File () Out)
} deriving Show

Expand All @@ -76,7 +77,7 @@ data GovernanceActionInfoCmdArgs era
{ eon :: !(ConwayEraOnwards era)
, networkId :: !L.Network
, deposit :: !Lovelace
, returnStakeAddress :: !(VerificationKeyOrHashOrFile StakeKey)
, returnStakeAddress :: !StakeIdentifier
, proposalUrl :: !ProposalUrl
, proposalHash :: !(L.SafeHash L.StandardCrypto L.AnchorData)
, outFile :: !(File () Out)
Expand All @@ -87,7 +88,7 @@ data GovernanceActionCreateNoConfidenceCmdArgs era
{ eon :: !(ConwayEraOnwards era)
, networkId :: !L.Network
, deposit :: !Lovelace
, returnStakeAddress :: !(VerificationKeyOrHashOrFile StakeKey)
, returnStakeAddress :: !StakeIdentifier
, proposalUrl :: !ProposalUrl
, proposalHash :: !(L.SafeHash L.StandardCrypto L.AnchorData)
, governanceActionId :: !TxId
Expand Down Expand Up @@ -117,7 +118,7 @@ data GovernanceActionTreasuryWithdrawalCmdArgs era
{ eon :: !(ConwayEraOnwards era)
, networkId :: !L.Network
, deposit :: !Lovelace
, returnAddr :: !(VerificationKeyOrHashOrFile StakeKey)
, returnAddr :: !StakeIdentifier
, proposalUrl :: !ProposalUrl
, proposalHash :: !(L.SafeHash L.StandardCrypto L.AnchorData)
, treasuryWithdrawal :: ![(VerificationKeyOrHashOrFile StakeKey, Lovelace)]
Expand All @@ -138,7 +139,7 @@ data UpdateProtocolParametersConwayOnwards era
{ eon :: !(ConwayEraOnwards era)
, networkId :: !L.Network
, deposit :: !Lovelace
, returnAddr :: !(VerificationKeyOrHashOrFile StakeKey)
, returnAddr :: !StakeIdentifier
, proposalUrl :: !ProposalUrl
, proposalHash :: !(L.SafeHash L.StandardCrypto L.AnchorData)
, governanceActionId :: !(Maybe (TxId, Word32))
Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/EraBased/Options/Address.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pAddressBuild :: EnvCli -> Parser (AddressCmds era)
pAddressBuild envCli =
AddressBuild
<$> pPaymentVerifier
<*> Opt.optional pStakeIdentifier
<*> Opt.optional (pStakeIdentifier Nothing)
<*> pNetworkId envCli
<*> pMaybeOutputFile

Expand Down
24 changes: 12 additions & 12 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -206,22 +206,22 @@ decimal :: Parsec.Parser Integer
Parsec.TokenParser { Parsec.decimal = decimal } = Parsec.haskell


pStakeIdentifier :: Parser StakeIdentifier
pStakeIdentifier = asum
[ StakeIdentifierVerifier <$> pStakeVerifier
, StakeIdentifierAddress <$> pStakeAddress
pStakeIdentifier :: Maybe String -> Parser StakeIdentifier
pStakeIdentifier prefix = asum
[ StakeIdentifierVerifier <$> pStakeVerifier prefix
, StakeIdentifierAddress <$> pStakeAddress prefix
]

pStakeVerifier :: Parser StakeVerifier
pStakeVerifier = asum
[ StakeVerifierKey <$> pStakeVerificationKeyOrFile Nothing
, StakeVerifierScriptFile <$> pScriptFor "stake-script-file" Nothing "Filepath of the staking script."
pStakeVerifier :: Maybe String -> Parser StakeVerifier
pStakeVerifier prefix = asum
[ StakeVerifierKey <$> pStakeVerificationKeyOrHashOrFile prefix
, StakeVerifierScriptFile <$> pScriptFor (prefixFlag prefix "stake-script-file") Nothing "Filepath of the staking script."
]

pStakeAddress :: Parser StakeAddress
pStakeAddress =
pStakeAddress :: Maybe String -> Parser StakeAddress
pStakeAddress prefix =
Opt.option (readerFromParsecParser parseStakeAddress) $ mconcat
[ Opt.long "stake-address"
[ Opt.long $ prefixFlag prefix "stake-address"
, Opt.metavar "ADDRESS"
, Opt.help "Target stake address (bech32 format)."
]
Expand Down Expand Up @@ -1295,7 +1295,7 @@ pCertificateFile balanceExecUnits =
<$> ( fmap CertificateFile $ asum
[ Opt.strOption $ mconcat
[ Opt.long "certificate-file"
, Opt.metavar "CERTIFICATEFILE"
, Opt.metavar "FILE"
, Opt.help helpText
, Opt.completer (Opt.bashCompleter "file")
]
Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/EraBased/Options/Governance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pMIRPayStakeAddresses :: ()
pMIRPayStakeAddresses w =
GovernanceCreateMirCertificateStakeAddressesCmd w
<$> pMIRPot
<*> some pStakeAddress
<*> some (pStakeAddress Nothing)
<*> some pRewardAmt
<*> pOutputFile

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pGovernanceActionNewInfoCmd era = do
Cmd.GovernanceActionInfoCmdArgs eon
<$> pNetwork
<*> pGovActionDeposit
<*> pStakeVerificationKeyOrHashOrFile (Just "deposit-return")
<*> pStakeIdentifier (Just "deposit-return")
<*> pAnchorUrl
<*> pAnchorDataHash
<*> pFileOutDirection "out-file" "Path to action file to be used later on with build or build-raw "
Expand All @@ -86,12 +86,13 @@ pGovernanceActionNewConstitutionCmd era = do
Cmd.GovernanceActionCreateConstitutionCmdArgs eon
<$> pNetwork
<*> pGovActionDeposit
<*> pStakeVerificationKeyOrHashOrFile (Just "deposit-return")
<*> pStakeIdentifier (Just "deposit-return")
<*> pPreviousGovernanceAction
<*> pAnchorUrl
<*> pAnchorDataHash
<*> pConstitutionUrl
<*> pConstitutionHash
<*> optional pConstitutionScriptHash
<*> pFileOutDirection "out-file" "Output filepath of the constitution."
)
$ Opt.progDesc "Create a constitution."
Expand All @@ -116,7 +117,7 @@ pUpdateCommitteeCmd eon =
Cmd.GoveranceActionUpdateCommitteeCmdArgs eon
<$> pNetwork
<*> pGovActionDeposit
<*> pStakeVerificationKeyOrHashOrFile (Just "deposit-return")
<*> pStakeIdentifier (Just "deposit-return")
<*> pAnchorUrl
<*> pAnchorDataHash
<*> many pRemoveCommitteeColdVerificationKeyOrHashOrFile
Expand All @@ -141,7 +142,7 @@ pGovernanceActionNoConfidenceCmd era = do
Cmd.GovernanceActionCreateNoConfidenceCmdArgs eon
<$> pNetwork
<*> pGovActionDeposit
<*> pStakeVerificationKeyOrHashOrFile (Just "deposit-return")
<*> pStakeIdentifier (Just "deposit-return")
<*> pAnchorUrl
<*> pAnchorDataHash
<*> pTxId "prev-governance-action-tx-id" "Txid of the previous governance action."
Expand All @@ -161,7 +162,7 @@ pUpdateProtocolParametersPostConway conwayOnwards =
Cmd.UpdateProtocolParametersConwayOnwards conwayOnwards
<$> pNetwork
<*> pGovActionDeposit
<*> pStakeVerificationKeyOrHashOrFile (Just "deposit-return")
<*> pStakeIdentifier (Just "deposit-return")
<*> pAnchorUrl
<*> pAnchorDataHash
<*> pPreviousGovernanceAction
Expand Down Expand Up @@ -353,7 +354,7 @@ pGovernanceActionTreasuryWithdrawalCmd era = do
Cmd.GovernanceActionTreasuryWithdrawalCmdArgs eon
<$> pNetwork
<*> pGovActionDeposit
<*> pStakeVerificationKeyOrHashOrFile (Just "deposit-return")
<*> pStakeIdentifier (Just "deposit-return")
<*> pAnchorUrl
<*> pAnchorDataHash
<*> many ((,) <$> pStakeVerificationKeyOrHashOrFile (Just "funds-receiving") <*> pTransferAmt)
Expand Down
16 changes: 8 additions & 8 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/StakeAddress.hs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pStakeAddressBuildCmd era envCli = do
$ subParser "build"
$ Opt.info
( StakeAddressBuildCmd w
<$> pStakeVerifier
<$> pStakeVerifier Nothing
<*> pNetworkId envCli
<*> pMaybeOutputFile
)
Expand All @@ -90,7 +90,7 @@ pStakeAddressRegistrationCertificateCmd era = do
(const $ subParser "registration-certificate"
$ Opt.info
( StakeAddressRegistrationCertificateCmd sbe
<$> pStakeIdentifier
<$> pStakeIdentifier Nothing
<*> pure Nothing
<*> pOutputFile
)
Expand All @@ -99,7 +99,7 @@ pStakeAddressRegistrationCertificateCmd era = do
(const $ subParser "registration-certificate"
$ Opt.info
( StakeAddressRegistrationCertificateCmd sbe
<$> pStakeIdentifier
<$> pStakeIdentifier Nothing
<*> fmap Just pKeyRegistDeposit
<*> pOutputFile
)
Expand All @@ -118,7 +118,7 @@ pStakeAddressDeregistrationCertificateCmd era = do
(\shelleyToBabbage -> subParser "deregistration-certificate"
$ Opt.info
( StakeAddressDeregistrationCertificateCmd (shelleyToBabbageEraToShelleyBasedEra shelleyToBabbage)
<$> pStakeIdentifier
<$> pStakeIdentifier Nothing
<*> pure Nothing
<*> pOutputFile
)
Expand All @@ -127,7 +127,7 @@ pStakeAddressDeregistrationCertificateCmd era = do
(\conwayOnwards -> subParser "deregistration-certificate"
$ Opt.info
( StakeAddressDeregistrationCertificateCmd (conwayEraOnwardsToShelleyBasedEra conwayOnwards)
<$> pStakeIdentifier
<$> pStakeIdentifier Nothing
<*> fmap Just pKeyRegistDeposit
<*> pOutputFile
)
Expand All @@ -144,7 +144,7 @@ pStakeAddressStakeDelegationCertificateCmd era = do
$ subParser "stake-delegation-certificate"
$ Opt.info
( StakeAddressStakeDelegationCertificateCmd w
<$> pStakeIdentifier
<$> pStakeIdentifier Nothing
<*> pStakePoolVerificationKeyOrHashOrFile Nothing
<*> pOutputFile
)
Expand All @@ -163,7 +163,7 @@ pStakeAddressStakeAndVoteDelegationCertificateCmd era = do
$ subParser "stake-and-vote-delegation-certificate"
$ Opt.info
( StakeAddressStakeAndVoteDelegationCertificateCmd w
<$> pStakeIdentifier
<$> pStakeIdentifier Nothing
<*> pStakePoolVerificationKeyOrHashOrFile Nothing
<*> pVoteDelegationTarget
<*> pOutputFile
Expand All @@ -183,7 +183,7 @@ pStakeAddressVoteDelegationCertificateCmd era = do
$ subParser "vote-delegation-certificate"
$ Opt.info
( StakeAddressVoteDelegationCertificateCmd w
<$> pStakeIdentifier
<$> pStakeIdentifier Nothing
<*> pVoteDelegationTarget
<*> pOutputFile
)
Expand Down
8 changes: 4 additions & 4 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Address.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import Cardano.CLI.Types.Common
import Cardano.CLI.Types.Errors.AddressCmdError
import Cardano.CLI.Types.Key (PaymentVerifier (..), StakeIdentifier (..),
StakeVerifier (..), VerificationKeyTextOrFile, generateKeyPair,
readVerificationKeyOrFile, readVerificationKeyTextOrFileAnyOf)
readVerificationKeyOrHashOrFile, readVerificationKeyTextOrFileAnyOf)

import qualified Data.ByteString.Char8 as BS
import Data.Function
Expand Down Expand Up @@ -194,10 +194,10 @@ makeStakeAddressRef stakeIdentifier =
StakeIdentifierVerifier stakeVerifier ->
case stakeVerifier of
StakeVerifierKey stkVkeyOrFile -> do
stakeVKey <- firstExceptT AddressCmdReadKeyFileError $
newExceptT $ readVerificationKeyOrFile AsStakeKey stkVkeyOrFile
stakeVKeyHash <- firstExceptT AddressCmdReadKeyFileError $
newExceptT $ readVerificationKeyOrHashOrFile AsStakeKey stkVkeyOrFile

return . StakeAddressByValue . StakeCredentialByKey . verificationKeyHash $ stakeVKey
return . StakeAddressByValue $ StakeCredentialByKey stakeVKeyHash

StakeVerifierScriptFile (ScriptFile fp) -> do
ScriptInAnyLang _lang script <-
Expand Down
Loading
Loading