Skip to content

Commit

Permalink
Merge pull request #262 from input-output-hk/newhoggy/remove-shelley-…
Browse files Browse the repository at this point in the history
…prefix-on-from-errors

Remove `Shelley` prefix on from errors
  • Loading branch information
newhoggy authored Sep 12, 2023
2 parents df5f0e7 + 33fa8a1 commit 7069593
Show file tree
Hide file tree
Showing 40 changed files with 1,234 additions and 1,235 deletions.
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

0 comments on commit 7069593

Please sign in to comment.