{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE LambdaCase         #-}
{-# LANGUAGE OverloadedStrings  #-}

module PlutusTx.Blueprint.PlutusVersion where

import Prelude

import Data.Aeson (ToJSON (..))

{- | A "Plutus Version", as defined by the CIP-0057
|
| This version corresponds to the "Plutus Ledger Language Version"
| defined by the plutus-tx-plugin.
-}
data PlutusVersion = PlutusV1 | PlutusV2 | PlutusV3
  deriving stock (Int -> PlutusVersion -> ShowS
[PlutusVersion] -> ShowS
PlutusVersion -> String
(Int -> PlutusVersion -> ShowS)
-> (PlutusVersion -> String)
-> ([PlutusVersion] -> ShowS)
-> Show PlutusVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PlutusVersion -> ShowS
showsPrec :: Int -> PlutusVersion -> ShowS
$cshow :: PlutusVersion -> String
show :: PlutusVersion -> String
$cshowList :: [PlutusVersion] -> ShowS
showList :: [PlutusVersion] -> ShowS
Show)

instance ToJSON PlutusVersion where
  toJSON :: PlutusVersion -> Value
toJSON = \case
    PlutusVersion
PlutusV1 -> Value
"v1"
    PlutusVersion
PlutusV2 -> Value
"v2"
    PlutusVersion
PlutusV3 -> Value
"v3"