{-# LANGUAGE DeriveAnyClass     #-}
{-# LANGUAGE DerivingStrategies #-}

module Plutus.Blockfrost.Types where

import Data.Aeson (FromJSON, ToJSON)
import Data.Map (Map)
import Data.Text (Text)
import GHC.Generics (Generic)

import Cardano.Api (NetworkId)

import Blockfrost.Client

newtype BlockfrostConfig =
    BlockfrostConfig { BlockfrostConfig -> FilePath
bfTokenPath :: FilePath }
    deriving stock (Int -> BlockfrostConfig -> ShowS
[BlockfrostConfig] -> ShowS
BlockfrostConfig -> FilePath
(Int -> BlockfrostConfig -> ShowS)
-> (BlockfrostConfig -> FilePath)
-> ([BlockfrostConfig] -> ShowS)
-> Show BlockfrostConfig
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [BlockfrostConfig] -> ShowS
$cshowList :: [BlockfrostConfig] -> ShowS
show :: BlockfrostConfig -> FilePath
$cshow :: BlockfrostConfig -> FilePath
showsPrec :: Int -> BlockfrostConfig -> ShowS
$cshowsPrec :: Int -> BlockfrostConfig -> ShowS
Show, BlockfrostConfig -> BlockfrostConfig -> Bool
(BlockfrostConfig -> BlockfrostConfig -> Bool)
-> (BlockfrostConfig -> BlockfrostConfig -> Bool)
-> Eq BlockfrostConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BlockfrostConfig -> BlockfrostConfig -> Bool
$c/= :: BlockfrostConfig -> BlockfrostConfig -> Bool
== :: BlockfrostConfig -> BlockfrostConfig -> Bool
$c== :: BlockfrostConfig -> BlockfrostConfig -> Bool
Eq, (forall x. BlockfrostConfig -> Rep BlockfrostConfig x)
-> (forall x. Rep BlockfrostConfig x -> BlockfrostConfig)
-> Generic BlockfrostConfig
forall x. Rep BlockfrostConfig x -> BlockfrostConfig
forall x. BlockfrostConfig -> Rep BlockfrostConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BlockfrostConfig x -> BlockfrostConfig
$cfrom :: forall x. BlockfrostConfig -> Rep BlockfrostConfig x
Generic)
    deriving anyclass (Value -> Parser [BlockfrostConfig]
Value -> Parser BlockfrostConfig
(Value -> Parser BlockfrostConfig)
-> (Value -> Parser [BlockfrostConfig])
-> FromJSON BlockfrostConfig
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [BlockfrostConfig]
$cparseJSONList :: Value -> Parser [BlockfrostConfig]
parseJSON :: Value -> Parser BlockfrostConfig
$cparseJSON :: Value -> Parser BlockfrostConfig
FromJSON, [BlockfrostConfig] -> Encoding
[BlockfrostConfig] -> Value
BlockfrostConfig -> Encoding
BlockfrostConfig -> Value
(BlockfrostConfig -> Value)
-> (BlockfrostConfig -> Encoding)
-> ([BlockfrostConfig] -> Value)
-> ([BlockfrostConfig] -> Encoding)
-> ToJSON BlockfrostConfig
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [BlockfrostConfig] -> Encoding
$ctoEncodingList :: [BlockfrostConfig] -> Encoding
toJSONList :: [BlockfrostConfig] -> Value
$ctoJSONList :: [BlockfrostConfig] -> Value
toEncoding :: BlockfrostConfig -> Encoding
$ctoEncoding :: BlockfrostConfig -> Encoding
toJSON :: BlockfrostConfig -> Value
$ctoJSON :: BlockfrostConfig -> Value
ToJSON)

data BlockfrostEnv = BlockfrostEnv { BlockfrostEnv -> FilePath
envBfTokenPath :: FilePath
                                   , BlockfrostEnv -> NetworkId
envNetworkId   :: NetworkId
                                   }

data TxResponse = TxResponse { TxResponse -> TxHash
_txHash        :: TxHash
                             , TxResponse -> Maybe Text
_invalidBefore :: Maybe Text
                             , TxResponse -> Maybe Text
_invalidAfter  :: Maybe Text
                             , TxResponse -> [UtxoInput]
_utxosInputs   :: [UtxoInput]
                             , TxResponse -> [UtxoOutput]
_utxosOutpus   :: [UtxoOutput]
                             , TxResponse -> Map Text ScriptDatum
_datumsMap     :: Map Text ScriptDatum
                             , TxResponse -> Map Integer (ValidationPurpose, ScriptDatum)
_redeemersMap  :: Map Integer (ValidationPurpose, ScriptDatum)
                             , TxResponse -> Map Text ScriptCBOR
_scriptsMap    :: Map Text ScriptCBOR
                             }