Skip to content

Commit

Permalink
Generalize error name
Browse files Browse the repository at this point in the history
  • Loading branch information
palas committed Nov 14, 2024
1 parent e1789f8 commit 2161328
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions cardano-api/internal/Cardano/Api/Keys/Mnemonics.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
module Cardano.Api.Keys.Mnemonics
( MnemonicSize (..)
, generateMnemonic
, MnemonicToSigningStakeKeyError (..)
, MnemonicToSigningKeyError (..)
, signingKeyFromMnemonic
)
where
Expand Down Expand Up @@ -57,14 +57,14 @@ generateMnemonic MS24 = liftIO (mnemonicToText @24 . entropyToMnemonic <$> genEn

-- | Errors that can occur when converting a mnemonic sentence to a signing key
-- using the 'signingStakeKeyFromMnemonic' function.
data MnemonicToSigningStakeKeyError
data MnemonicToSigningKeyError
= InvalidMnemonicError String
| InvalidAccountNumberError Word32
| InvalidPaymentKeyNoError Word32
deriving (Eq, Show)

instance Error MnemonicToSigningStakeKeyError where
prettyError :: MnemonicToSigningStakeKeyError -> Doc ann
instance Error MnemonicToSigningKeyError where
prettyError :: MnemonicToSigningKeyError -> Doc ann
prettyError (InvalidMnemonicError str) = "Invalid mnemonic sentence: " <> pretty str
prettyError (InvalidAccountNumberError accNo) = "Invalid account number: " <> pretty accNo
prettyError (InvalidPaymentKeyNoError keyNo) = "Invalid payment key number: " <> pretty keyNo
Expand Down Expand Up @@ -147,7 +147,7 @@ signingKeyFromMnemonic
-> indexType
-- ^ The payment key number in the derivation path (as 'Word32') if applicable for
-- the given key role, otherwise '()'. First key is 0.
-> Either MnemonicToSigningStakeKeyError (SigningKey keyrole)
-> Either MnemonicToSigningKeyError (SigningKey keyrole)
signingKeyFromMnemonic role mnemonicWords accNo payKeyNo = do
-- Convert raw types to the ones used in the cardano-addresses library
someMnemonic <- mapLeft InvalidMnemonicError $ wordsToSomeMnemonic mnemonicWords
Expand Down
2 changes: 1 addition & 1 deletion cardano-api/src/Cardano/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ module Cardano.Api
, generateMnemonic

-- ** Key derivation from mnemonics
, MnemonicToSigningStakeKeyError (..)
, MnemonicToSigningKeyError (..)
, signingKeyFromMnemonic

-- * Payment addresses
Expand Down

0 comments on commit 2161328

Please sign in to comment.