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

Remove Shelley prefix on from errors #262

Merged
merged 1 commit into from
Sep 12, 2023
Merged
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
22 changes: 11 additions & 11 deletions cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -154,33 +154,33 @@ library
Cardano.CLI.Run.Ping
Cardano.CLI.TopHandler
Cardano.CLI.Types.Common
Cardano.CLI.Types.Errors.AddressCmdError
Cardano.CLI.Types.Errors.AddressInfoError
Cardano.CLI.Types.Errors.BootstrapWitnessError
Cardano.CLI.Types.Errors.CardanoAddressSigningKeyConversionError
Cardano.CLI.Types.Errors.CmdError
Cardano.CLI.Types.Errors.DelegationError
Cardano.CLI.Types.Errors.GenesisCmdError
Cardano.CLI.Types.Errors.GovernanceActionsError
Cardano.CLI.Types.Errors.GovernanceCmdError
Cardano.CLI.Types.Errors.GovernanceCommitteeError
Cardano.CLI.Types.Errors.GovernanceQueryError
Cardano.CLI.Types.Errors.GovernanceVoteCmdError
Cardano.CLI.Types.Errors.ItnKeyConversionError
Cardano.CLI.Types.Errors.KeyCmdError
Cardano.CLI.Types.Errors.NodeCmdError
Cardano.CLI.Types.Errors.ProtocolParamsError
Cardano.CLI.Types.Errors.QueryCmdError
Cardano.CLI.Types.Errors.QueryCmdLocalStateQueryError
Cardano.CLI.Types.Errors.RegistrationError
Cardano.CLI.Types.Errors.ScriptDecodeError
Cardano.CLI.Types.Errors.ShelleyAddressCmdError
Cardano.CLI.Types.Errors.ShelleyAddressInfoError
Cardano.CLI.Types.Errors.ShelleyBootstrapWitnessError
Cardano.CLI.Types.Errors.ShelleyGenesisCmdError
Cardano.CLI.Types.Errors.ShelleyKeyCmdError
Cardano.CLI.Types.Errors.ShelleyNodeCmdError
Cardano.CLI.Types.Errors.ShelleyQueryCmdError
Cardano.CLI.Types.Errors.ShelleyQueryCmdLocalStateQueryError
Cardano.CLI.Types.Errors.ShelleyStakeAddressCmdError
Cardano.CLI.Types.Errors.ShelleyTextViewFileError
Cardano.CLI.Types.Errors.ShelleyTxCmdError
Cardano.CLI.Types.Errors.StakeAddressCmdError
Cardano.CLI.Types.Errors.StakeAddressDelegationError
Cardano.CLI.Types.Errors.StakeAddressRegistrationError
Cardano.CLI.Types.Errors.StakeCredentialError
Cardano.CLI.Types.Errors.StakePoolCmdError
Cardano.CLI.Types.Errors.TextViewFileError
Cardano.CLI.Types.Errors.TxCmdError
Cardano.CLI.Types.Errors.TxValidationError
Cardano.CLI.Types.Governance
Cardano.CLI.Types.Key
Expand Down
40 changes: 20 additions & 20 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Address.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Cardano.CLI.EraBased.Commands.Address
import Cardano.CLI.EraBased.Run.Address.Info
import Cardano.CLI.Read
import Cardano.CLI.Types.Common
import Cardano.CLI.Types.Errors.ShelleyAddressCmdError
import Cardano.CLI.Types.Errors.AddressCmdError
import Cardano.CLI.Types.Key (PaymentVerifier (..), StakeIdentifier (..),
StakeVerifier (..), VerificationKeyTextOrFile, generateKeyPair,
readVerificationKeyOrFile, readVerificationKeyTextOrFileAnyOf)
Expand All @@ -34,7 +34,7 @@ import qualified Data.Text.IO as Text

runAddressCmds :: ()
=> AddressCmds era
-> ExceptT ShelleyAddressCmdError IO ()
-> ExceptT AddressCmdError IO ()
runAddressCmds = \case
AddressKeyGen fmt kt vkf skf ->
runAddressKeyGenCmd fmt kt vkf skf
Expand All @@ -43,14 +43,14 @@ runAddressCmds = \case
AddressBuild paymentVerifier mbStakeVerifier nw mOutFp ->
runAddressBuildCmd paymentVerifier mbStakeVerifier nw mOutFp
AddressInfo txt mOFp ->
runAddressInfoCmd txt mOFp & firstExceptT ShelleyAddressCmdAddressInfoError
runAddressInfoCmd txt mOFp & firstExceptT AddressCmdAddressInfoError

runAddressKeyGenCmd
:: KeyOutputFormat
-> AddressKeyType
-> VerificationKeyFile Out
-> SigningKeyFile Out
-> ExceptT ShelleyAddressCmdError IO ()
-> ExceptT AddressCmdError IO ()
runAddressKeyGenCmd fmt kt vkf skf = case kt of
AddressKeyShelley -> generateAndWriteKeyFiles fmt AsPaymentKey vkf skf
AddressKeyShelleyExtended -> generateAndWriteKeyFiles fmt AsPaymentExtendedKey vkf skf
Expand All @@ -62,7 +62,7 @@ generateAndWriteByronKeyFiles :: ()
=> AsType keyrole
-> VerificationKeyFile Out
-> SigningKeyFile Out
-> ExceptT ShelleyAddressCmdError IO ()
-> ExceptT AddressCmdError IO ()
generateAndWriteByronKeyFiles asType vkf skf = do
uncurry (writeByronPaymentKeyFiles vkf skf) =<< liftIO (generateKeyPair asType)

Expand All @@ -75,7 +75,7 @@ generateAndWriteKeyFiles :: ()
-> AsType keyrole
-> VerificationKeyFile Out
-> SigningKeyFile Out
-> ExceptT ShelleyAddressCmdError IO ()
-> ExceptT AddressCmdError IO ()
generateAndWriteKeyFiles fmt asType vkf skf = do
uncurry (writePaymentKeyFiles fmt vkf skf) =<< liftIO (generateKeyPair asType)

Expand All @@ -88,9 +88,9 @@ writePaymentKeyFiles
-> SigningKeyFile Out
-> VerificationKey keyrole
-> SigningKey keyrole
-> ExceptT ShelleyAddressCmdError IO ()
-> ExceptT AddressCmdError IO ()
writePaymentKeyFiles fmt vkeyPath skeyPath vkey skey = do
firstExceptT ShelleyAddressCmdWriteFileError $ do
firstExceptT AddressCmdWriteFileError $ do
case fmt of
KeyOutputFormatTextEnvelope ->
newExceptT
Expand Down Expand Up @@ -122,9 +122,9 @@ writeByronPaymentKeyFiles
-> SigningKeyFile Out
-> VerificationKey keyrole
-> SigningKey keyrole
-> ExceptT ShelleyAddressCmdError IO ()
-> ExceptT AddressCmdError IO ()
writeByronPaymentKeyFiles vkeyPath skeyPath vkey skey = do
firstExceptT ShelleyAddressCmdWriteFileError $ do
firstExceptT AddressCmdWriteFileError $ do
-- No bech32 encoding for Byron keys
newExceptT $ writeLazyByteStringFile skeyPath $ textEnvelopeToJSON (Just skeyDesc) skey
newExceptT $ writeLazyByteStringFile vkeyPath $ textEnvelopeToJSON (Just vkeyDesc) vkey
Expand All @@ -135,9 +135,9 @@ writeByronPaymentKeyFiles vkeyPath skeyPath vkey skey = do

runAddressKeyHashCmd :: VerificationKeyTextOrFile
-> Maybe (File () Out)
-> ExceptT ShelleyAddressCmdError IO ()
-> ExceptT AddressCmdError IO ()
runAddressKeyHashCmd vkeyTextOrFile mOutputFp = do
vkey <- firstExceptT ShelleyAddressCmdVerificationKeyTextOrFileError $
vkey <- firstExceptT AddressCmdVerificationKeyTextOrFileError $
newExceptT $ readVerificationKeyTextOrFileAnyOf vkeyTextOrFile

let hexKeyHash = foldSomeAddressVerificationKey
Expand All @@ -152,11 +152,11 @@ runAddressBuildCmd :: PaymentVerifier
-> Maybe StakeIdentifier
-> NetworkId
-> Maybe (File () Out)
-> ExceptT ShelleyAddressCmdError IO ()
-> ExceptT AddressCmdError IO ()
runAddressBuildCmd paymentVerifier mbStakeVerifier nw mOutFp = do
outText <- case paymentVerifier of
PaymentVerifierKey payVkeyTextOrFile -> do
payVKey <- firstExceptT ShelleyAddressCmdVerificationKeyTextOrFileError $
payVKey <- firstExceptT AddressCmdVerificationKeyTextOrFileError $
newExceptT $ readVerificationKeyTextOrFileAnyOf payVkeyTextOrFile

addr <- case payVKey of
Expand All @@ -172,12 +172,12 @@ runAddressBuildCmd paymentVerifier mbStakeVerifier nw mOutFp = do
AGenesisUTxOVerificationKey vk ->
AddressShelley <$> buildShelleyAddress (castVerificationKey vk) mbStakeVerifier nw
nonPaymentKey ->
left $ ShelleyAddressCmdExpectedPaymentVerificationKey nonPaymentKey
left $ AddressCmdExpectedPaymentVerificationKey nonPaymentKey
return $ serialiseAddress (addr :: AddressAny)

PaymentVerifierScriptFile (ScriptFile fp) -> do
ScriptInAnyLang _lang script <-
firstExceptT ShelleyAddressCmdReadScriptFileError $
firstExceptT AddressCmdReadScriptFileError $
readFileScriptInAnyLang fp

let payCred = PaymentCredentialByScript (hashScript script)
Expand All @@ -192,20 +192,20 @@ runAddressBuildCmd paymentVerifier mbStakeVerifier nw mOutFp = do

makeStakeAddressRef
:: StakeIdentifier
-> ExceptT ShelleyAddressCmdError IO StakeAddressReference
-> ExceptT AddressCmdError IO StakeAddressReference
makeStakeAddressRef stakeIdentifier =
case stakeIdentifier of
StakeIdentifierVerifier stakeVerifier ->
case stakeVerifier of
StakeVerifierKey stkVkeyOrFile -> do
stakeVKey <- firstExceptT ShelleyAddressCmdReadKeyFileError $
stakeVKey <- firstExceptT AddressCmdReadKeyFileError $
newExceptT $ readVerificationKeyOrFile AsStakeKey stkVkeyOrFile

return . StakeAddressByValue . StakeCredentialByKey . verificationKeyHash $ stakeVKey

StakeVerifierScriptFile (ScriptFile fp) -> do
ScriptInAnyLang _lang script <-
firstExceptT ShelleyAddressCmdReadScriptFileError $
firstExceptT AddressCmdReadScriptFileError $
readFileScriptInAnyLang fp

let stakeCred = StakeCredentialByScript (hashScript script)
Expand All @@ -217,7 +217,7 @@ buildShelleyAddress
:: VerificationKey PaymentKey
-> Maybe StakeIdentifier
-> NetworkId
-> ExceptT ShelleyAddressCmdError IO (Address ShelleyAddr)
-> ExceptT AddressCmdError IO (Address ShelleyAddr)
buildShelleyAddress vkey mbStakeVerifier nw =
makeShelleyAddress nw (PaymentCredentialByKey (verificationKeyHash vkey)) <$> maybe (return NoStakeAddress) makeStakeAddressRef mbStakeVerifier

Expand Down
4 changes: 2 additions & 2 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Address/Info.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Cardano.CLI.EraBased.Run.Address.Info

import Cardano.Api

import Cardano.CLI.Types.Errors.ShelleyAddressInfoError
import Cardano.CLI.Types.Errors.AddressInfoError

import Control.Monad.IO.Class (MonadIO (..))
import Control.Monad.Trans.Except (ExceptT)
Expand Down Expand Up @@ -36,7 +36,7 @@ instance ToJSON AddressInfo where
, "base16" .= aiBase16 addrInfo
]

runAddressInfoCmd :: Text -> Maybe (File () Out) -> ExceptT ShelleyAddressInfoError IO ()
runAddressInfoCmd :: Text -> Maybe (File () Out) -> ExceptT AddressInfoError IO ()
runAddressInfoCmd addrTxt mOutputFp = do
addrInfo <- case (Left <$> deserialiseAddress AsAddressAny addrTxt)
<|> (Right <$> deserialiseAddress AsStakeAddress addrTxt) of
Expand Down
Loading