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

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

data InitialError
  = STNotBurned
  | MissingOrInvalidCommitAuthor
  | LockedValueDoesNotMatch
  | MismatchCommittedTxOutInDatum
  | CouldNotFindTheCorrectCurrencySymbolInTokens
  | MultipleHeadTokensOrMoreThan1PTsFound
  | MissingCommittedTxOutInOutputDatum
  | CommittedTxOutMissingInOutputDatum
  | MissingDatum
  | UnexpectedNonInlineDatum
  | ExpectedCommitDatumTypeGotSomethingElse
  | ExpectedSingleCommitOutput
  | WrongHeadIdInCommitDatum
  | MintingOrBurningIsForbidden
  | OutRefNotFound
  deriving stock (Int -> InitialError -> ShowS
[InitialError] -> ShowS
InitialError -> String
(Int -> InitialError -> ShowS)
-> (InitialError -> String)
-> ([InitialError] -> ShowS)
-> Show InitialError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> InitialError -> ShowS
showsPrec :: Int -> InitialError -> ShowS
$cshow :: InitialError -> String
show :: InitialError -> String
$cshowList :: [InitialError] -> ShowS
showList :: [InitialError] -> ShowS
Show)

instance ToErrorCode InitialError where
  toErrorCode :: InitialError -> Text
toErrorCode = \case
    InitialError
STNotBurned -> Text
"I01"
    InitialError
MissingOrInvalidCommitAuthor -> Text
"I02"
    InitialError
LockedValueDoesNotMatch -> Text
"I03"
    InitialError
MismatchCommittedTxOutInDatum -> Text
"I04"
    InitialError
CouldNotFindTheCorrectCurrencySymbolInTokens -> Text
"I05"
    InitialError
MultipleHeadTokensOrMoreThan1PTsFound -> Text
"I06"
    InitialError
MissingCommittedTxOutInOutputDatum -> Text
"I07"
    InitialError
CommittedTxOutMissingInOutputDatum -> Text
"I08"
    InitialError
MissingDatum -> Text
"I09"
    InitialError
UnexpectedNonInlineDatum -> Text
"I10"
    InitialError
ExpectedCommitDatumTypeGotSomethingElse -> Text
"I11"
    InitialError
ExpectedSingleCommitOutput -> Text
"I12"
    InitialError
WrongHeadIdInCommitDatum -> Text
"I13"
    InitialError
MintingOrBurningIsForbidden -> Text
"I14"
    InitialError
OutRefNotFound -> Text
"I15"