module Hydra.Contract.HeadTokensError (
  errorCode,
  module Hydra.Contract.HeadTokensError,
) where

import Hydra.Contract.Error (ToErrorCode (..), errorCode)
import Text.Show (Show)

data HeadTokensError
  = SeedNotSpent
  | WrongNumberOfTokensMinted
  | MissingST
  | WrongNumberOfInitialOutputs
  | WrongDatum
  | MintingNotAllowed
  | NoPT
  | WrongQuantity
  | ExpectedHeadDatumType
  | ExpectedInlineDatum
  | MultipleHeadOutput
  | WrongInitialDatum
  deriving stock (Int -> HeadTokensError -> ShowS
[HeadTokensError] -> ShowS
HeadTokensError -> String
(Int -> HeadTokensError -> ShowS)
-> (HeadTokensError -> String)
-> ([HeadTokensError] -> ShowS)
-> Show HeadTokensError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HeadTokensError -> ShowS
showsPrec :: Int -> HeadTokensError -> ShowS
$cshow :: HeadTokensError -> String
show :: HeadTokensError -> String
$cshowList :: [HeadTokensError] -> ShowS
showList :: [HeadTokensError] -> ShowS
Show)

instance ToErrorCode HeadTokensError where
  toErrorCode :: HeadTokensError -> Text
toErrorCode = \case
    HeadTokensError
SeedNotSpent -> Text
"M01"
    HeadTokensError
WrongNumberOfTokensMinted -> Text
"M02"
    HeadTokensError
MissingST -> Text
"M03"
    HeadTokensError
WrongNumberOfInitialOutputs -> Text
"M04"
    HeadTokensError
WrongDatum -> Text
"M05"
    HeadTokensError
MintingNotAllowed -> Text
"M06"
    HeadTokensError
NoPT -> Text
"M07"
    HeadTokensError
WrongQuantity -> Text
"M08"
    HeadTokensError
ExpectedHeadDatumType -> Text
"M09"
    HeadTokensError
ExpectedInlineDatum -> Text
"M10"
    HeadTokensError
MultipleHeadOutput -> Text
"M11"
    HeadTokensError
WrongInitialDatum -> Text
"M12"