-- | Cardano Scripts responses

module Blockfrost.Types.Cardano.Scripts
  ( Script (..)
  , ScriptType (..)
  , ScriptRedeemer (..)
  , ScriptDatum (..)
  , ScriptDatumCBOR (..)
  , InlineDatum (..)
  , ScriptJSON (..)
  , ScriptCBOR (..)
  ) where

import Data.Aeson (Value, object, (.=), FromJSON (..), ToJSON (..))
import Data.Text (Text)
import Deriving.Aeson
import Servant.Docs (ToSample (..), samples, singleSample)

import Blockfrost.Types.Shared

-- | Script type
data ScriptType = PlutusV1 | PlutusV2 | Timelock
  deriving stock (Int -> ScriptType -> ShowS
[ScriptType] -> ShowS
ScriptType -> String
(Int -> ScriptType -> ShowS)
-> (ScriptType -> String)
-> ([ScriptType] -> ShowS)
-> Show ScriptType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ScriptType -> ShowS
showsPrec :: Int -> ScriptType -> ShowS
$cshow :: ScriptType -> String
show :: ScriptType -> String
$cshowList :: [ScriptType] -> ShowS
showList :: [ScriptType] -> ShowS
Show, ScriptType -> ScriptType -> Bool
(ScriptType -> ScriptType -> Bool)
-> (ScriptType -> ScriptType -> Bool) -> Eq ScriptType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ScriptType -> ScriptType -> Bool
== :: ScriptType -> ScriptType -> Bool
$c/= :: ScriptType -> ScriptType -> Bool
/= :: ScriptType -> ScriptType -> Bool
Eq, Eq ScriptType
Eq ScriptType =>
(ScriptType -> ScriptType -> Ordering)
-> (ScriptType -> ScriptType -> Bool)
-> (ScriptType -> ScriptType -> Bool)
-> (ScriptType -> ScriptType -> Bool)
-> (ScriptType -> ScriptType -> Bool)
-> (ScriptType -> ScriptType -> ScriptType)
-> (ScriptType -> ScriptType -> ScriptType)
-> Ord ScriptType
ScriptType -> ScriptType -> Bool
ScriptType -> ScriptType -> Ordering
ScriptType -> ScriptType -> ScriptType
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ScriptType -> ScriptType -> Ordering
compare :: ScriptType -> ScriptType -> Ordering
$c< :: ScriptType -> ScriptType -> Bool
< :: ScriptType -> ScriptType -> Bool
$c<= :: ScriptType -> ScriptType -> Bool
<= :: ScriptType -> ScriptType -> Bool
$c> :: ScriptType -> ScriptType -> Bool
> :: ScriptType -> ScriptType -> Bool
$c>= :: ScriptType -> ScriptType -> Bool
>= :: ScriptType -> ScriptType -> Bool
$cmax :: ScriptType -> ScriptType -> ScriptType
max :: ScriptType -> ScriptType -> ScriptType
$cmin :: ScriptType -> ScriptType -> ScriptType
min :: ScriptType -> ScriptType -> ScriptType
Ord, (forall x. ScriptType -> Rep ScriptType x)
-> (forall x. Rep ScriptType x -> ScriptType) -> Generic ScriptType
forall x. Rep ScriptType x -> ScriptType
forall x. ScriptType -> Rep ScriptType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ScriptType -> Rep ScriptType x
from :: forall x. ScriptType -> Rep ScriptType x
$cto :: forall x. Rep ScriptType x -> ScriptType
to :: forall x. Rep ScriptType x -> ScriptType
Generic)
  deriving (Maybe ScriptType
Value -> Parser [ScriptType]
Value -> Parser ScriptType
(Value -> Parser ScriptType)
-> (Value -> Parser [ScriptType])
-> Maybe ScriptType
-> FromJSON ScriptType
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser ScriptType
parseJSON :: Value -> Parser ScriptType
$cparseJSONList :: Value -> Parser [ScriptType]
parseJSONList :: Value -> Parser [ScriptType]
$comittedField :: Maybe ScriptType
omittedField :: Maybe ScriptType
FromJSON, [ScriptType] -> Value
[ScriptType] -> Encoding
ScriptType -> Bool
ScriptType -> Value
ScriptType -> Encoding
(ScriptType -> Value)
-> (ScriptType -> Encoding)
-> ([ScriptType] -> Value)
-> ([ScriptType] -> Encoding)
-> (ScriptType -> Bool)
-> ToJSON ScriptType
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: ScriptType -> Value
toJSON :: ScriptType -> Value
$ctoEncoding :: ScriptType -> Encoding
toEncoding :: ScriptType -> Encoding
$ctoJSONList :: [ScriptType] -> Value
toJSONList :: [ScriptType] -> Value
$ctoEncodingList :: [ScriptType] -> Encoding
toEncodingList :: [ScriptType] -> Encoding
$comitField :: ScriptType -> Bool
omitField :: ScriptType -> Bool
ToJSON)
  via CustomJSON '[ConstructorTagModifier '[ToLower]] ScriptType

instance ToSample ScriptType where
  toSamples :: Proxy ScriptType -> [(Text, ScriptType)]
toSamples = [(Text, ScriptType)] -> Proxy ScriptType -> [(Text, ScriptType)]
forall a. a -> Proxy ScriptType -> a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(Text, ScriptType)] -> Proxy ScriptType -> [(Text, ScriptType)])
-> [(Text, ScriptType)] -> Proxy ScriptType -> [(Text, ScriptType)]
forall a b. (a -> b) -> a -> b
$ [ScriptType] -> [(Text, ScriptType)]
forall a. [a] -> [(Text, a)]
samples [ ScriptType
PlutusV1, ScriptType
PlutusV2, ScriptType
Timelock ]

-- | Script info
data Script = Script
  { Script -> ScriptHash
_scriptScriptHash     :: ScriptHash -- ^ Hash of the script
  , Script -> ScriptType
_scriptType           :: ScriptType -- ^ Type of the script language
  , Script -> Maybe Integer
_scriptSerialisedSize :: Maybe Integer -- ^ The size of the CBOR serialised script, if a Plutus script
  }
  deriving stock (Int -> Script -> ShowS
[Script] -> ShowS
Script -> String
(Int -> Script -> ShowS)
-> (Script -> String) -> ([Script] -> ShowS) -> Show Script
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Script -> ShowS
showsPrec :: Int -> Script -> ShowS
$cshow :: Script -> String
show :: Script -> String
$cshowList :: [Script] -> ShowS
showList :: [Script] -> ShowS
Show, Script -> Script -> Bool
(Script -> Script -> Bool)
-> (Script -> Script -> Bool) -> Eq Script
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Script -> Script -> Bool
== :: Script -> Script -> Bool
$c/= :: Script -> Script -> Bool
/= :: Script -> Script -> Bool
Eq, (forall x. Script -> Rep Script x)
-> (forall x. Rep Script x -> Script) -> Generic Script
forall x. Rep Script x -> Script
forall x. Script -> Rep Script x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Script -> Rep Script x
from :: forall x. Script -> Rep Script x
$cto :: forall x. Rep Script x -> Script
to :: forall x. Rep Script x -> Script
Generic)
  deriving (Maybe Script
Value -> Parser [Script]
Value -> Parser Script
(Value -> Parser Script)
-> (Value -> Parser [Script]) -> Maybe Script -> FromJSON Script
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser Script
parseJSON :: Value -> Parser Script
$cparseJSONList :: Value -> Parser [Script]
parseJSONList :: Value -> Parser [Script]
$comittedField :: Maybe Script
omittedField :: Maybe Script
FromJSON, [Script] -> Value
[Script] -> Encoding
Script -> Bool
Script -> Value
Script -> Encoding
(Script -> Value)
-> (Script -> Encoding)
-> ([Script] -> Value)
-> ([Script] -> Encoding)
-> (Script -> Bool)
-> ToJSON Script
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: Script -> Value
toJSON :: Script -> Value
$ctoEncoding :: Script -> Encoding
toEncoding :: Script -> Encoding
$ctoJSONList :: [Script] -> Value
toJSONList :: [Script] -> Value
$ctoEncodingList :: [Script] -> Encoding
toEncodingList :: [Script] -> Encoding
$comitField :: Script -> Bool
omitField :: Script -> Bool
ToJSON)
  via CustomJSON '[FieldLabelModifier '[StripPrefix "_script", CamelToSnake]] Script

instance ToSample Script where
  toSamples :: Proxy Script -> [(Text, Script)]
toSamples = [(Text, Script)] -> Proxy Script -> [(Text, Script)]
forall a. a -> Proxy Script -> a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(Text, Script)] -> Proxy Script -> [(Text, Script)])
-> [(Text, Script)] -> Proxy Script -> [(Text, Script)]
forall a b. (a -> b) -> a -> b
$ Script -> [(Text, Script)]
forall a. a -> [(Text, a)]
singleSample
    Script
      { _scriptScriptHash :: ScriptHash
_scriptScriptHash = ScriptHash
"67f33146617a5e61936081db3b2117cbf59bd2123748f58ac9678656"
      , _scriptType :: ScriptType
_scriptType = ScriptType
PlutusV1
      , _scriptSerialisedSize :: Maybe Integer
_scriptSerialisedSize = Integer -> Maybe Integer
forall a. a -> Maybe a
Just Integer
3119
      }

-- | Script redeemer
data ScriptRedeemer = ScriptRedeemer
  { ScriptRedeemer -> TxHash
_scriptRedeemerTxHash    :: TxHash -- ^ Hash of the transaction
  , ScriptRedeemer -> Integer
_scriptRedeemerTxIndex   :: Integer -- ^ Index of the redeemer within a transaction
  , ScriptRedeemer -> ValidationPurpose
_scriptRedeemerPurpose   :: ValidationPurpose -- ^ Validation purpose
  , ScriptRedeemer -> DatumHash
_scriptRedeemerRedeemerDataHash :: DatumHash -- ^ Datum hash of the redeemer
  , ScriptRedeemer -> DatumHash
_scriptRedeemerDatumHash :: DatumHash -- ^ Datum hash (DEPRECATED)
  , ScriptRedeemer -> Quantity
_scriptRedeemerUnitMem   :: Quantity -- ^ The budget in Memory to run a script
  , ScriptRedeemer -> Quantity
_scriptRedeemerUnitSteps :: Quantity -- ^ The budget in Steps to run a script
  , ScriptRedeemer -> Lovelaces
_scriptRedeemerFee       :: Lovelaces -- ^ The fee consumed to run the script
  }
  deriving stock (Int -> ScriptRedeemer -> ShowS
[ScriptRedeemer] -> ShowS
ScriptRedeemer -> String
(Int -> ScriptRedeemer -> ShowS)
-> (ScriptRedeemer -> String)
-> ([ScriptRedeemer] -> ShowS)
-> Show ScriptRedeemer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ScriptRedeemer -> ShowS
showsPrec :: Int -> ScriptRedeemer -> ShowS
$cshow :: ScriptRedeemer -> String
show :: ScriptRedeemer -> String
$cshowList :: [ScriptRedeemer] -> ShowS
showList :: [ScriptRedeemer] -> ShowS
Show, ScriptRedeemer -> ScriptRedeemer -> Bool
(ScriptRedeemer -> ScriptRedeemer -> Bool)
-> (ScriptRedeemer -> ScriptRedeemer -> Bool) -> Eq ScriptRedeemer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ScriptRedeemer -> ScriptRedeemer -> Bool
== :: ScriptRedeemer -> ScriptRedeemer -> Bool
$c/= :: ScriptRedeemer -> ScriptRedeemer -> Bool
/= :: ScriptRedeemer -> ScriptRedeemer -> Bool
Eq, (forall x. ScriptRedeemer -> Rep ScriptRedeemer x)
-> (forall x. Rep ScriptRedeemer x -> ScriptRedeemer)
-> Generic ScriptRedeemer
forall x. Rep ScriptRedeemer x -> ScriptRedeemer
forall x. ScriptRedeemer -> Rep ScriptRedeemer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ScriptRedeemer -> Rep ScriptRedeemer x
from :: forall x. ScriptRedeemer -> Rep ScriptRedeemer x
$cto :: forall x. Rep ScriptRedeemer x -> ScriptRedeemer
to :: forall x. Rep ScriptRedeemer x -> ScriptRedeemer
Generic)
  deriving (Maybe ScriptRedeemer
Value -> Parser [ScriptRedeemer]
Value -> Parser ScriptRedeemer
(Value -> Parser ScriptRedeemer)
-> (Value -> Parser [ScriptRedeemer])
-> Maybe ScriptRedeemer
-> FromJSON ScriptRedeemer
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser ScriptRedeemer
parseJSON :: Value -> Parser ScriptRedeemer
$cparseJSONList :: Value -> Parser [ScriptRedeemer]
parseJSONList :: Value -> Parser [ScriptRedeemer]
$comittedField :: Maybe ScriptRedeemer
omittedField :: Maybe ScriptRedeemer
FromJSON, [ScriptRedeemer] -> Value
[ScriptRedeemer] -> Encoding
ScriptRedeemer -> Bool
ScriptRedeemer -> Value
ScriptRedeemer -> Encoding
(ScriptRedeemer -> Value)
-> (ScriptRedeemer -> Encoding)
-> ([ScriptRedeemer] -> Value)
-> ([ScriptRedeemer] -> Encoding)
-> (ScriptRedeemer -> Bool)
-> ToJSON ScriptRedeemer
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: ScriptRedeemer -> Value
toJSON :: ScriptRedeemer -> Value
$ctoEncoding :: ScriptRedeemer -> Encoding
toEncoding :: ScriptRedeemer -> Encoding
$ctoJSONList :: [ScriptRedeemer] -> Value
toJSONList :: [ScriptRedeemer] -> Value
$ctoEncodingList :: [ScriptRedeemer] -> Encoding
toEncodingList :: [ScriptRedeemer] -> Encoding
$comitField :: ScriptRedeemer -> Bool
omitField :: ScriptRedeemer -> Bool
ToJSON)
  via CustomJSON '[FieldLabelModifier '[StripPrefix "_scriptRedeemer", CamelToSnake]] ScriptRedeemer

instance ToSample ScriptRedeemer where
  toSamples :: Proxy ScriptRedeemer -> [(Text, ScriptRedeemer)]
toSamples = [(Text, ScriptRedeemer)]
-> Proxy ScriptRedeemer -> [(Text, ScriptRedeemer)]
forall a. a -> Proxy ScriptRedeemer -> a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(Text, ScriptRedeemer)]
 -> Proxy ScriptRedeemer -> [(Text, ScriptRedeemer)])
-> [(Text, ScriptRedeemer)]
-> Proxy ScriptRedeemer
-> [(Text, ScriptRedeemer)]
forall a b. (a -> b) -> a -> b
$ ScriptRedeemer -> [(Text, ScriptRedeemer)]
forall a. a -> [(Text, a)]
singleSample
    ScriptRedeemer
      { _scriptRedeemerTxHash :: TxHash
_scriptRedeemerTxHash = TxHash
"1a0570af966fb355a7160e4f82d5a80b8681b7955f5d44bec0dce628516157f0"
      , _scriptRedeemerTxIndex :: Integer
_scriptRedeemerTxIndex = Integer
0
      , _scriptRedeemerPurpose :: ValidationPurpose
_scriptRedeemerPurpose = ValidationPurpose
Spend
      , _scriptRedeemerRedeemerDataHash :: DatumHash
_scriptRedeemerRedeemerDataHash = DatumHash
"923918e403bf43c34b4ef6b48eb2ee04babed17320d8d1b9ff9ad086e86f44ec"
      , _scriptRedeemerDatumHash :: DatumHash
_scriptRedeemerDatumHash = DatumHash
"923918e403bf43c34b4ef6b48eb2ee04babed17320d8d1b9ff9ad086e86f44ec"
      , _scriptRedeemerUnitMem :: Quantity
_scriptRedeemerUnitMem = Quantity
1700
      , _scriptRedeemerUnitSteps :: Quantity
_scriptRedeemerUnitSteps = Quantity
476468
      , _scriptRedeemerFee :: Lovelaces
_scriptRedeemerFee = Discrete' "ADA" '(1000000, 1)
Lovelaces
172033
      }

newtype ScriptDatum = ScriptDatum { ScriptDatum -> Value
_scriptDatumJsonValue :: Value }
  deriving stock (Int -> ScriptDatum -> ShowS
[ScriptDatum] -> ShowS
ScriptDatum -> String
(Int -> ScriptDatum -> ShowS)
-> (ScriptDatum -> String)
-> ([ScriptDatum] -> ShowS)
-> Show ScriptDatum
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ScriptDatum -> ShowS
showsPrec :: Int -> ScriptDatum -> ShowS
$cshow :: ScriptDatum -> String
show :: ScriptDatum -> String
$cshowList :: [ScriptDatum] -> ShowS
showList :: [ScriptDatum] -> ShowS
Show, ScriptDatum -> ScriptDatum -> Bool
(ScriptDatum -> ScriptDatum -> Bool)
-> (ScriptDatum -> ScriptDatum -> Bool) -> Eq ScriptDatum
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ScriptDatum -> ScriptDatum -> Bool
== :: ScriptDatum -> ScriptDatum -> Bool
$c/= :: ScriptDatum -> ScriptDatum -> Bool
/= :: ScriptDatum -> ScriptDatum -> Bool
Eq, (forall x. ScriptDatum -> Rep ScriptDatum x)
-> (forall x. Rep ScriptDatum x -> ScriptDatum)
-> Generic ScriptDatum
forall x. Rep ScriptDatum x -> ScriptDatum
forall x. ScriptDatum -> Rep ScriptDatum x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ScriptDatum -> Rep ScriptDatum x
from :: forall x. ScriptDatum -> Rep ScriptDatum x
$cto :: forall x. Rep ScriptDatum x -> ScriptDatum
to :: forall x. Rep ScriptDatum x -> ScriptDatum
Generic)
  deriving (Maybe ScriptDatum
Value -> Parser [ScriptDatum]
Value -> Parser ScriptDatum
(Value -> Parser ScriptDatum)
-> (Value -> Parser [ScriptDatum])
-> Maybe ScriptDatum
-> FromJSON ScriptDatum
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser ScriptDatum
parseJSON :: Value -> Parser ScriptDatum
$cparseJSONList :: Value -> Parser [ScriptDatum]
parseJSONList :: Value -> Parser [ScriptDatum]
$comittedField :: Maybe ScriptDatum
omittedField :: Maybe ScriptDatum
FromJSON, [ScriptDatum] -> Value
[ScriptDatum] -> Encoding
ScriptDatum -> Bool
ScriptDatum -> Value
ScriptDatum -> Encoding
(ScriptDatum -> Value)
-> (ScriptDatum -> Encoding)
-> ([ScriptDatum] -> Value)
-> ([ScriptDatum] -> Encoding)
-> (ScriptDatum -> Bool)
-> ToJSON ScriptDatum
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: ScriptDatum -> Value
toJSON :: ScriptDatum -> Value
$ctoEncoding :: ScriptDatum -> Encoding
toEncoding :: ScriptDatum -> Encoding
$ctoJSONList :: [ScriptDatum] -> Value
toJSONList :: [ScriptDatum] -> Value
$ctoEncodingList :: [ScriptDatum] -> Encoding
toEncodingList :: [ScriptDatum] -> Encoding
$comitField :: ScriptDatum -> Bool
omitField :: ScriptDatum -> Bool
ToJSON)
  via CustomJSON '[FieldLabelModifier '[StripPrefix "_scriptDatum", CamelToSnake]] ScriptDatum

instance ToSample ScriptDatum where
  toSamples :: Proxy ScriptDatum -> [(Text, ScriptDatum)]
toSamples =
      [(Text, ScriptDatum)] -> Proxy ScriptDatum -> [(Text, ScriptDatum)]
forall a. a -> Proxy ScriptDatum -> a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
    ([(Text, ScriptDatum)]
 -> Proxy ScriptDatum -> [(Text, ScriptDatum)])
-> [(Text, ScriptDatum)]
-> Proxy ScriptDatum
-> [(Text, ScriptDatum)]
forall a b. (a -> b) -> a -> b
$ ScriptDatum -> [(Text, ScriptDatum)]
forall a. a -> [(Text, a)]
singleSample
    (ScriptDatum -> [(Text, ScriptDatum)])
-> ScriptDatum -> [(Text, ScriptDatum)]
forall a b. (a -> b) -> a -> b
$ Value -> ScriptDatum
ScriptDatum
    (Value -> ScriptDatum) -> Value -> ScriptDatum
forall a b. (a -> b) -> a -> b
$ [Pair] -> Value
object [ Key
"int" Key -> Int -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (Int
42 :: Int) ]

newtype ScriptDatumCBOR = ScriptDatumCBOR { ScriptDatumCBOR -> Text
_scriptDatumCborCbor :: Text }
  deriving stock (Int -> ScriptDatumCBOR -> ShowS
[ScriptDatumCBOR] -> ShowS
ScriptDatumCBOR -> String
(Int -> ScriptDatumCBOR -> ShowS)
-> (ScriptDatumCBOR -> String)
-> ([ScriptDatumCBOR] -> ShowS)
-> Show ScriptDatumCBOR
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ScriptDatumCBOR -> ShowS
showsPrec :: Int -> ScriptDatumCBOR -> ShowS
$cshow :: ScriptDatumCBOR -> String
show :: ScriptDatumCBOR -> String
$cshowList :: [ScriptDatumCBOR] -> ShowS
showList :: [ScriptDatumCBOR] -> ShowS
Show, ScriptDatumCBOR -> ScriptDatumCBOR -> Bool
(ScriptDatumCBOR -> ScriptDatumCBOR -> Bool)
-> (ScriptDatumCBOR -> ScriptDatumCBOR -> Bool)
-> Eq ScriptDatumCBOR
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ScriptDatumCBOR -> ScriptDatumCBOR -> Bool
== :: ScriptDatumCBOR -> ScriptDatumCBOR -> Bool
$c/= :: ScriptDatumCBOR -> ScriptDatumCBOR -> Bool
/= :: ScriptDatumCBOR -> ScriptDatumCBOR -> Bool
Eq, (forall x. ScriptDatumCBOR -> Rep ScriptDatumCBOR x)
-> (forall x. Rep ScriptDatumCBOR x -> ScriptDatumCBOR)
-> Generic ScriptDatumCBOR
forall x. Rep ScriptDatumCBOR x -> ScriptDatumCBOR
forall x. ScriptDatumCBOR -> Rep ScriptDatumCBOR x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ScriptDatumCBOR -> Rep ScriptDatumCBOR x
from :: forall x. ScriptDatumCBOR -> Rep ScriptDatumCBOR x
$cto :: forall x. Rep ScriptDatumCBOR x -> ScriptDatumCBOR
to :: forall x. Rep ScriptDatumCBOR x -> ScriptDatumCBOR
Generic)
  deriving (Maybe ScriptDatumCBOR
Value -> Parser [ScriptDatumCBOR]
Value -> Parser ScriptDatumCBOR
(Value -> Parser ScriptDatumCBOR)
-> (Value -> Parser [ScriptDatumCBOR])
-> Maybe ScriptDatumCBOR
-> FromJSON ScriptDatumCBOR
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser ScriptDatumCBOR
parseJSON :: Value -> Parser ScriptDatumCBOR
$cparseJSONList :: Value -> Parser [ScriptDatumCBOR]
parseJSONList :: Value -> Parser [ScriptDatumCBOR]
$comittedField :: Maybe ScriptDatumCBOR
omittedField :: Maybe ScriptDatumCBOR
FromJSON, [ScriptDatumCBOR] -> Value
[ScriptDatumCBOR] -> Encoding
ScriptDatumCBOR -> Bool
ScriptDatumCBOR -> Value
ScriptDatumCBOR -> Encoding
(ScriptDatumCBOR -> Value)
-> (ScriptDatumCBOR -> Encoding)
-> ([ScriptDatumCBOR] -> Value)
-> ([ScriptDatumCBOR] -> Encoding)
-> (ScriptDatumCBOR -> Bool)
-> ToJSON ScriptDatumCBOR
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: ScriptDatumCBOR -> Value
toJSON :: ScriptDatumCBOR -> Value
$ctoEncoding :: ScriptDatumCBOR -> Encoding
toEncoding :: ScriptDatumCBOR -> Encoding
$ctoJSONList :: [ScriptDatumCBOR] -> Value
toJSONList :: [ScriptDatumCBOR] -> Value
$ctoEncodingList :: [ScriptDatumCBOR] -> Encoding
toEncodingList :: [ScriptDatumCBOR] -> Encoding
$comitField :: ScriptDatumCBOR -> Bool
omitField :: ScriptDatumCBOR -> Bool
ToJSON)
  via CustomJSON '[FieldLabelModifier '[StripPrefix "_scriptDatumCbor", CamelToSnake]] ScriptDatumCBOR

instance ToSample ScriptDatumCBOR where
  toSamples :: Proxy ScriptDatumCBOR -> [(Text, ScriptDatumCBOR)]
toSamples =
      [(Text, ScriptDatumCBOR)]
-> Proxy ScriptDatumCBOR -> [(Text, ScriptDatumCBOR)]
forall a. a -> Proxy ScriptDatumCBOR -> a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
    ([(Text, ScriptDatumCBOR)]
 -> Proxy ScriptDatumCBOR -> [(Text, ScriptDatumCBOR)])
-> [(Text, ScriptDatumCBOR)]
-> Proxy ScriptDatumCBOR
-> [(Text, ScriptDatumCBOR)]
forall a b. (a -> b) -> a -> b
$ ScriptDatumCBOR -> [(Text, ScriptDatumCBOR)]
forall a. a -> [(Text, a)]
singleSample
    (ScriptDatumCBOR -> [(Text, ScriptDatumCBOR)])
-> ScriptDatumCBOR -> [(Text, ScriptDatumCBOR)]
forall a b. (a -> b) -> a -> b
$ Text -> ScriptDatumCBOR
ScriptDatumCBOR Text
"19a6aa"

newtype InlineDatum = InlineDatum { InlineDatum -> ScriptDatumCBOR
unInlineDatum :: ScriptDatumCBOR }
  deriving stock (Int -> InlineDatum -> ShowS
[InlineDatum] -> ShowS
InlineDatum -> String
(Int -> InlineDatum -> ShowS)
-> (InlineDatum -> String)
-> ([InlineDatum] -> ShowS)
-> Show InlineDatum
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> InlineDatum -> ShowS
showsPrec :: Int -> InlineDatum -> ShowS
$cshow :: InlineDatum -> String
show :: InlineDatum -> String
$cshowList :: [InlineDatum] -> ShowS
showList :: [InlineDatum] -> ShowS
Show, InlineDatum -> InlineDatum -> Bool
(InlineDatum -> InlineDatum -> Bool)
-> (InlineDatum -> InlineDatum -> Bool) -> Eq InlineDatum
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: InlineDatum -> InlineDatum -> Bool
== :: InlineDatum -> InlineDatum -> Bool
$c/= :: InlineDatum -> InlineDatum -> Bool
/= :: InlineDatum -> InlineDatum -> Bool
Eq, (forall x. InlineDatum -> Rep InlineDatum x)
-> (forall x. Rep InlineDatum x -> InlineDatum)
-> Generic InlineDatum
forall x. Rep InlineDatum x -> InlineDatum
forall x. InlineDatum -> Rep InlineDatum x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. InlineDatum -> Rep InlineDatum x
from :: forall x. InlineDatum -> Rep InlineDatum x
$cto :: forall x. Rep InlineDatum x -> InlineDatum
to :: forall x. Rep InlineDatum x -> InlineDatum
Generic)

instance ToJSON InlineDatum  where
  toJSON :: InlineDatum -> Value
toJSON = Text -> Value
forall a. ToJSON a => a -> Value
toJSON (Text -> Value) -> (InlineDatum -> Text) -> InlineDatum -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ScriptDatumCBOR -> Text
_scriptDatumCborCbor (ScriptDatumCBOR -> Text)
-> (InlineDatum -> ScriptDatumCBOR) -> InlineDatum -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InlineDatum -> ScriptDatumCBOR
unInlineDatum
  toEncoding :: InlineDatum -> Encoding
toEncoding = Text -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding (Text -> Encoding)
-> (InlineDatum -> Text) -> InlineDatum -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ScriptDatumCBOR -> Text
_scriptDatumCborCbor (ScriptDatumCBOR -> Text)
-> (InlineDatum -> ScriptDatumCBOR) -> InlineDatum -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InlineDatum -> ScriptDatumCBOR
unInlineDatum

instance FromJSON InlineDatum  where
  parseJSON :: Value -> Parser InlineDatum
parseJSON = (Text -> InlineDatum) -> Parser Text -> Parser InlineDatum
forall a b. (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (ScriptDatumCBOR -> InlineDatum
InlineDatum (ScriptDatumCBOR -> InlineDatum)
-> (Text -> ScriptDatumCBOR) -> Text -> InlineDatum
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> ScriptDatumCBOR
ScriptDatumCBOR) (Parser Text -> Parser InlineDatum)
-> (Value -> Parser Text) -> Value -> Parser InlineDatum
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser Text
forall a. FromJSON a => Value -> Parser a
parseJSON

instance ToSample InlineDatum where
  toSamples :: Proxy InlineDatum -> [(Text, InlineDatum)]
toSamples =
      [(Text, InlineDatum)] -> Proxy InlineDatum -> [(Text, InlineDatum)]
forall a. a -> Proxy InlineDatum -> a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
    ([(Text, InlineDatum)]
 -> Proxy InlineDatum -> [(Text, InlineDatum)])
-> [(Text, InlineDatum)]
-> Proxy InlineDatum
-> [(Text, InlineDatum)]
forall a b. (a -> b) -> a -> b
$ InlineDatum -> [(Text, InlineDatum)]
forall a. a -> [(Text, a)]
singleSample
    (InlineDatum -> [(Text, InlineDatum)])
-> InlineDatum -> [(Text, InlineDatum)]
forall a b. (a -> b) -> a -> b
$ ScriptDatumCBOR -> InlineDatum
InlineDatum
    (ScriptDatumCBOR -> InlineDatum) -> ScriptDatumCBOR -> InlineDatum
forall a b. (a -> b) -> a -> b
$ Text -> ScriptDatumCBOR
ScriptDatumCBOR Text
"19a6aa"

newtype ScriptJSON = ScriptJSON { ScriptJSON -> Maybe Value
_scriptJsonJson :: Maybe Value }
  deriving stock (Int -> ScriptJSON -> ShowS
[ScriptJSON] -> ShowS
ScriptJSON -> String
(Int -> ScriptJSON -> ShowS)
-> (ScriptJSON -> String)
-> ([ScriptJSON] -> ShowS)
-> Show ScriptJSON
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ScriptJSON -> ShowS
showsPrec :: Int -> ScriptJSON -> ShowS
$cshow :: ScriptJSON -> String
show :: ScriptJSON -> String
$cshowList :: [ScriptJSON] -> ShowS
showList :: [ScriptJSON] -> ShowS
Show, ScriptJSON -> ScriptJSON -> Bool
(ScriptJSON -> ScriptJSON -> Bool)
-> (ScriptJSON -> ScriptJSON -> Bool) -> Eq ScriptJSON
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ScriptJSON -> ScriptJSON -> Bool
== :: ScriptJSON -> ScriptJSON -> Bool
$c/= :: ScriptJSON -> ScriptJSON -> Bool
/= :: ScriptJSON -> ScriptJSON -> Bool
Eq, (forall x. ScriptJSON -> Rep ScriptJSON x)
-> (forall x. Rep ScriptJSON x -> ScriptJSON) -> Generic ScriptJSON
forall x. Rep ScriptJSON x -> ScriptJSON
forall x. ScriptJSON -> Rep ScriptJSON x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ScriptJSON -> Rep ScriptJSON x
from :: forall x. ScriptJSON -> Rep ScriptJSON x
$cto :: forall x. Rep ScriptJSON x -> ScriptJSON
to :: forall x. Rep ScriptJSON x -> ScriptJSON
Generic)
  deriving (Maybe ScriptJSON
Value -> Parser [ScriptJSON]
Value -> Parser ScriptJSON
(Value -> Parser ScriptJSON)
-> (Value -> Parser [ScriptJSON])
-> Maybe ScriptJSON
-> FromJSON ScriptJSON
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser ScriptJSON
parseJSON :: Value -> Parser ScriptJSON
$cparseJSONList :: Value -> Parser [ScriptJSON]
parseJSONList :: Value -> Parser [ScriptJSON]
$comittedField :: Maybe ScriptJSON
omittedField :: Maybe ScriptJSON
FromJSON, [ScriptJSON] -> Value
[ScriptJSON] -> Encoding
ScriptJSON -> Bool
ScriptJSON -> Value
ScriptJSON -> Encoding
(ScriptJSON -> Value)
-> (ScriptJSON -> Encoding)
-> ([ScriptJSON] -> Value)
-> ([ScriptJSON] -> Encoding)
-> (ScriptJSON -> Bool)
-> ToJSON ScriptJSON
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: ScriptJSON -> Value
toJSON :: ScriptJSON -> Value
$ctoEncoding :: ScriptJSON -> Encoding
toEncoding :: ScriptJSON -> Encoding
$ctoJSONList :: [ScriptJSON] -> Value
toJSONList :: [ScriptJSON] -> Value
$ctoEncodingList :: [ScriptJSON] -> Encoding
toEncodingList :: [ScriptJSON] -> Encoding
$comitField :: ScriptJSON -> Bool
omitField :: ScriptJSON -> Bool
ToJSON)
  via CustomJSON '[FieldLabelModifier '[StripPrefix "_scriptJson", CamelToSnake]] ScriptJSON

instance ToSample ScriptJSON where
  toSamples :: Proxy ScriptJSON -> [(Text, ScriptJSON)]
toSamples =
      [(Text, ScriptJSON)] -> Proxy ScriptJSON -> [(Text, ScriptJSON)]
forall a. a -> Proxy ScriptJSON -> a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
    ([(Text, ScriptJSON)] -> Proxy ScriptJSON -> [(Text, ScriptJSON)])
-> [(Text, ScriptJSON)] -> Proxy ScriptJSON -> [(Text, ScriptJSON)]
forall a b. (a -> b) -> a -> b
$ ScriptJSON -> [(Text, ScriptJSON)]
forall a. a -> [(Text, a)]
singleSample
    (ScriptJSON -> [(Text, ScriptJSON)])
-> ScriptJSON -> [(Text, ScriptJSON)]
forall a b. (a -> b) -> a -> b
$ Maybe Value -> ScriptJSON
ScriptJSON
    (Maybe Value -> ScriptJSON) -> Maybe Value -> ScriptJSON
forall a b. (a -> b) -> a -> b
$ Value -> Maybe Value
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
    (Value -> Maybe Value) -> Value -> Maybe Value
forall a b. (a -> b) -> a -> b
$ [Pair] -> Value
object [ Key
"type" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (String
"sig" :: String)
             , Key
"keyHash" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (String
"8ed9e675aaf99868736c372d5eac9f5b3deae4568f0cde6a7d9e1422" :: String)]

newtype ScriptCBOR = ScriptCBOR { ScriptCBOR -> Maybe Text
_scriptCborCbor :: Maybe Text }
  deriving stock (Int -> ScriptCBOR -> ShowS
[ScriptCBOR] -> ShowS
ScriptCBOR -> String
(Int -> ScriptCBOR -> ShowS)
-> (ScriptCBOR -> String)
-> ([ScriptCBOR] -> ShowS)
-> Show ScriptCBOR
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ScriptCBOR -> ShowS
showsPrec :: Int -> ScriptCBOR -> ShowS
$cshow :: ScriptCBOR -> String
show :: ScriptCBOR -> String
$cshowList :: [ScriptCBOR] -> ShowS
showList :: [ScriptCBOR] -> ShowS
Show, ScriptCBOR -> ScriptCBOR -> Bool
(ScriptCBOR -> ScriptCBOR -> Bool)
-> (ScriptCBOR -> ScriptCBOR -> Bool) -> Eq ScriptCBOR
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ScriptCBOR -> ScriptCBOR -> Bool
== :: ScriptCBOR -> ScriptCBOR -> Bool
$c/= :: ScriptCBOR -> ScriptCBOR -> Bool
/= :: ScriptCBOR -> ScriptCBOR -> Bool
Eq, (forall x. ScriptCBOR -> Rep ScriptCBOR x)
-> (forall x. Rep ScriptCBOR x -> ScriptCBOR) -> Generic ScriptCBOR
forall x. Rep ScriptCBOR x -> ScriptCBOR
forall x. ScriptCBOR -> Rep ScriptCBOR x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ScriptCBOR -> Rep ScriptCBOR x
from :: forall x. ScriptCBOR -> Rep ScriptCBOR x
$cto :: forall x. Rep ScriptCBOR x -> ScriptCBOR
to :: forall x. Rep ScriptCBOR x -> ScriptCBOR
Generic)
  deriving (Maybe ScriptCBOR
Value -> Parser [ScriptCBOR]
Value -> Parser ScriptCBOR
(Value -> Parser ScriptCBOR)
-> (Value -> Parser [ScriptCBOR])
-> Maybe ScriptCBOR
-> FromJSON ScriptCBOR
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser ScriptCBOR
parseJSON :: Value -> Parser ScriptCBOR
$cparseJSONList :: Value -> Parser [ScriptCBOR]
parseJSONList :: Value -> Parser [ScriptCBOR]
$comittedField :: Maybe ScriptCBOR
omittedField :: Maybe ScriptCBOR
FromJSON, [ScriptCBOR] -> Value
[ScriptCBOR] -> Encoding
ScriptCBOR -> Bool
ScriptCBOR -> Value
ScriptCBOR -> Encoding
(ScriptCBOR -> Value)
-> (ScriptCBOR -> Encoding)
-> ([ScriptCBOR] -> Value)
-> ([ScriptCBOR] -> Encoding)
-> (ScriptCBOR -> Bool)
-> ToJSON ScriptCBOR
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: ScriptCBOR -> Value
toJSON :: ScriptCBOR -> Value
$ctoEncoding :: ScriptCBOR -> Encoding
toEncoding :: ScriptCBOR -> Encoding
$ctoJSONList :: [ScriptCBOR] -> Value
toJSONList :: [ScriptCBOR] -> Value
$ctoEncodingList :: [ScriptCBOR] -> Encoding
toEncodingList :: [ScriptCBOR] -> Encoding
$comitField :: ScriptCBOR -> Bool
omitField :: ScriptCBOR -> Bool
ToJSON)
  via CustomJSON '[FieldLabelModifier '[StripPrefix "_scriptCbor", CamelToSnake]] ScriptCBOR

instance ToSample ScriptCBOR where
  toSamples :: Proxy ScriptCBOR -> [(Text, ScriptCBOR)]
toSamples =
      [(Text, ScriptCBOR)] -> Proxy ScriptCBOR -> [(Text, ScriptCBOR)]
forall a. a -> Proxy ScriptCBOR -> a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
    ([(Text, ScriptCBOR)] -> Proxy ScriptCBOR -> [(Text, ScriptCBOR)])
-> [(Text, ScriptCBOR)] -> Proxy ScriptCBOR -> [(Text, ScriptCBOR)]
forall a b. (a -> b) -> a -> b
$ ScriptCBOR -> [(Text, ScriptCBOR)]
forall a. a -> [(Text, a)]
singleSample
    (ScriptCBOR -> [(Text, ScriptCBOR)])
-> ScriptCBOR -> [(Text, ScriptCBOR)]
forall a b. (a -> b) -> a -> b
$ Maybe Text -> ScriptCBOR
ScriptCBOR
    (Maybe Text -> ScriptCBOR) -> Maybe Text -> ScriptCBOR
forall a b. (a -> b) -> a -> b
$ Text -> Maybe Text
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
"4e4d01000033222220051200120011"