-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5330848
commit 2e3e4d7
Showing
6 changed files
with
189 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
cardano-cli/src/Cardano/CLI/Compatible/StakeAddress/Commands.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE LambdaCase #-} | ||
|
||
module Cardano.CLI.Compatible.StakeAddress.Commands | ||
( CompatibleStakeAddressCmds (..) | ||
, renderCompatibleStakeAddressCmds | ||
) | ||
where | ||
|
||
import Cardano.Api.Ledger (Coin) | ||
import Cardano.Api.Shelley | ||
|
||
import Cardano.CLI.Types.Common | ||
import Cardano.CLI.Types.Governance | ||
import Cardano.CLI.Types.Key | ||
|
||
import Prelude | ||
|
||
import Data.Text (Text) | ||
|
||
data CompatibleStakeAddressCmds era | ||
= CompatibleStakeAddressRegistrationCertificateCmd | ||
(ShelleyBasedEra era) | ||
StakeIdentifier | ||
(Maybe Coin) | ||
(File () Out) | ||
| CompatibleStakeAddressStakeDelegationCertificateCmd | ||
(ShelleyBasedEra era) | ||
StakeIdentifier | ||
(VerificationKeyOrHashOrFile StakePoolKey) | ||
(File () Out) | ||
deriving Show | ||
|
||
renderStakeAddressCmds :: StakeAddressCmds era -> Text | ||
renderStakeAddressCmds = | ||
(<>) "stake-address " . \case | ||
CompatibleStakeAddressRegistrationCertificateCmd{} -> "registration-certificate" | ||
CompatibleStakeAddressStakeDelegationCertificateCmd{} -> "stake-delegation-certificate" |
82 changes: 82 additions & 0 deletions
82
cardano-cli/src/Cardano/CLI/Compatible/StakeAddress/Options.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE GADTs #-} | ||
|
||
module Cardano.CLI.Compatible.StakeAddress.Options | ||
( pStakeAddressCmds | ||
) | ||
where | ||
|
||
import Cardano.Api | ||
|
||
import Cardano.CLI.Environment | ||
import Cardano.CLI.EraBased.Commands.StakeAddress | ||
import Cardano.CLI.EraBased.Options.Common | ||
import Cardano.CLI.Parser | ||
|
||
import Options.Applicative | ||
import Options.Applicative qualified as Opt | ||
|
||
pStakeAddressCmds | ||
:: () | ||
=> ShelleyBasedEra era | ||
-> EnvCli | ||
-> Maybe (Parser (CompatibleStakeAddressCmds era)) | ||
pStakeAddressCmds era envCli = | ||
subInfoParser | ||
"stake-address" | ||
( Opt.progDesc $ | ||
mconcat | ||
[ "Stake address commands." | ||
] | ||
) | ||
[ Just (pStakeAddressRegistrationCertificateCmd era) | ||
, Just (pStakeAddressStakeDelegationCertificateCmd era) | ||
] | ||
|
||
pStakeAddressRegistrationCertificateCmd | ||
:: () | ||
=> ShelleyBasedEra era | ||
-> Parser (CompatibleStakeAddressCmds era) | ||
pStakeAddressRegistrationCertificateCmd sbe = do | ||
caseShelleyToBabbageOrConwayEraOnwards | ||
( const $ | ||
subParser "registration-certificate" $ | ||
Opt.info | ||
( CompatibleStakeAddressRegistrationCertificateCmd sbe | ||
<$> pStakeIdentifier Nothing | ||
<*> pure Nothing | ||
<*> pOutputFile | ||
) | ||
desc | ||
) | ||
( const $ | ||
subParser "registration-certificate" $ | ||
Opt.info | ||
( CompatibleStakeAddressRegistrationCertificateCmd sbe | ||
<$> pStakeIdentifier Nothing | ||
<*> fmap Just pKeyRegistDeposit | ||
<*> pOutputFile | ||
) | ||
desc | ||
) | ||
sbe | ||
where | ||
desc = Opt.progDesc "Create a stake address registration certificate" | ||
|
||
pStakeAddressStakeDelegationCertificateCmd | ||
:: () | ||
=> ShelleyBasedEra era | ||
-> Parser (CompatibleStakeAddressCmds era) | ||
pStakeAddressStakeDelegationCertificateCmd sbe = do | ||
subParser "stake-delegation-certificate" | ||
$ Opt.info | ||
( CompatibleStakeAddressStakeDelegationCertificateCmd sbe | ||
<$> pStakeIdentifier Nothing | ||
<*> pStakePoolVerificationKeyOrHashOrFile Nothing | ||
<*> pOutputFile | ||
) | ||
$ Opt.progDesc | ||
$ mconcat | ||
[ "Create a stake address stake delegation certificate, which when submitted in a transaction " | ||
, "delegates stake to a stake pool." | ||
] |
59 changes: 59 additions & 0 deletions
59
cardano-cli/src/Cardano/CLI/Compatible/StakePool/Commands.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE DuplicateRecordFields #-} | ||
{-# LANGUAGE LambdaCase #-} | ||
|
||
module Cardano.CLI.Compatible.StakePool.Commands | ||
( CompatibleStakePoolCmds (..) | ||
, renderCompatibleStakePoolCmds | ||
, CompatibleStakePoolRegistrationCertificateCmdArgs (..) | ||
) | ||
where | ||
|
||
import Cardano.Api.Ledger (Coin) | ||
import Cardano.Api.Ledger qualified as L | ||
import Cardano.Api.Shelley hiding (QueryInShelleyBasedEra (..)) | ||
|
||
import Cardano.CLI.Commands.Hash (HashGoal) | ||
import Cardano.CLI.Types.Common | ||
import Cardano.CLI.Types.Key | ||
|
||
import Prelude | ||
|
||
import Data.Text (Text) | ||
|
||
data CompatibleStakePoolCmds era | ||
= CompatibleStakePoolRegistrationCertificateCmd !(CompatibleStakePoolRegistrationCertificateCmdArgs era) | ||
deriving Show | ||
Check notice Code scanning / HLint Use newtype instead of data Note
cardano-cli/src/Cardano/CLI/Compatible/StakePool/Commands.hs:(22,1)-(25,15): Suggestion: Use newtype instead of data
Found: data CompatibleStakePoolCmds era = CompatibleStakePoolRegistrationCertificateCmd !(CompatibleStakePoolRegistrationCertificateCmdArgs era) deriving Show Perhaps: newtype CompatibleStakePoolCmds era = CompatibleStakePoolRegistrationCertificateCmd (CompatibleStakePoolRegistrationCertificateCmdArgs era) deriving Show |
||
|
||
data CompatibleStakePoolRegistrationCertificateCmdArgs era | ||
= CompatibleStakePoolRegistrationCertificateCmdArgs | ||
{ sbe :: !(ShelleyBasedEra era) | ||
-- ^ Era in which to register the stake pool. | ||
, poolVerificationKeyOrFile :: !(VerificationKeyOrFile StakePoolKey) | ||
-- ^ Stake pool verification key. | ||
, vrfVerificationKeyOrFile :: !(VerificationKeyOrFile VrfKey) | ||
-- ^ VRF Verification key. | ||
, poolPledge :: !Coin | ||
-- ^ Pool pledge. | ||
, poolCost :: !Coin | ||
-- ^ Pool cost. | ||
, poolMargin :: !Rational | ||
-- ^ Pool margin. | ||
, rewardStakeVerificationKeyOrFile :: !(VerificationKeyOrFile StakeKey) | ||
-- ^ Reward account verification staking key. | ||
, ownerStakeVerificationKeyOrFiles :: ![VerificationKeyOrFile StakeKey] | ||
-- ^ Pool owner verification staking key(s). | ||
, relays :: ![StakePoolRelay] | ||
-- ^ Stake pool relays. | ||
, mMetadata | ||
:: !(Maybe (PotentiallyCheckedAnchor StakePoolMetadataReference StakePoolMetadataReference)) | ||
-- ^ Stake pool metadata. | ||
, network :: !NetworkId | ||
, outFile :: !(File () Out) | ||
} | ||
deriving Show | ||
|
||
renderStakePoolCmds :: StakePoolCmds era -> Text | ||
renderStakePoolCmds = (<>) "stake-pool " . \case | ||
StakePoolRegistrationCertificateCmd{} -> | ||
"registration-certificate" |