{-# LANGUAGE DataKinds            #-}
{-# LANGUAGE DeriveAnyClass       #-}
{-# LANGUAGE DeriveGeneric        #-}
{-# LANGUAGE DerivingVia          #-}
{-# LANGUAGE FlexibleContexts     #-}
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE NamedFieldPuns       #-}
{-# LANGUAGE OverloadedStrings    #-}
{-# LANGUAGE StrictData           #-}
{-# LANGUAGE UndecidableInstances #-}

{-# OPTIONS_GHC -Wno-orphans #-}

module Plutus.PAB.Webserver.Types where

import Cardano.Api qualified as C
import Cardano.Crypto.Hash qualified as Hash
import Cardano.Ledger.Hashes qualified as Hashes
import Cardano.Wallet.LocalClient.ExportTx (ExportTx, ExportTxInput, ExportTxRedeemer)
import Cardano.Wallet.Primitive.Types qualified as Cardano.Wallet
import Control.Lens ((&), (.~), (?~))
import Crypto.Hash qualified as Crypto
import Data.Aeson (FromJSON, ToJSON)
import Data.Aeson qualified as JSON
import Data.Data (Proxy (Proxy))
import Data.HashMap.Strict.InsOrd qualified as InsOrdMap
import Data.Map (Map)
import Data.OpenApi (NamedSchema (NamedSchema), OpenApiType (OpenApiObject), byteSchema, declareSchemaRef, properties,
                     required, type_)
import Data.OpenApi.Schema qualified as OpenApi
import GHC.Generics (Generic)
import Ledger (Certificate, Datum, POSIXTime (POSIXTime), PaymentPubKeyHash (PaymentPubKeyHash), PubKeyHash, TxId,
               TxOut, Value, Withdrawal)
import Ledger.Crypto (PubKey (PubKey), Signature (Signature))
import Ledger.Index (UtxoIndex)
import Ledger.Slot (Slot)
import Ledger.Tx (CardanoTx)
import Ledger.Tx.CardanoAPI (CardanoBuildTx)
import Ledger.Tx.Constraints.OffChain (UnbalancedTx)
import Plutus.Contract.Effects (ActiveEndpoint, ChainIndexQuery, PABReq)
import Plutus.PAB.Events.ContractInstanceState (PartiallyDecodedResponse)
import Plutus.V1.Ledger.Api (DCert, LedgerBytes (LedgerBytes))
import Prettyprinter (Pretty, pretty, (<+>))
import Wallet.Emulator.Wallet (Wallet, WalletId (WalletId))
import Wallet.Rollup.Types (AnnotatedTx, BeneficialOwner, DereferencedInput, SequenceId)
import Wallet.Types (ContractActivityStatus, ContractInstanceId, EndpointDescription)

instance OpenApi.ToSchema TxOut where
    declareNamedSchema :: Proxy TxOut -> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy TxOut
_ = do
      Referenced Schema
addressSchema <- Proxy (AddressInEra BabbageEra)
-> Declare (Definitions Schema) (Referenced Schema)
forall a.
ToSchema a =>
Proxy a -> Declare (Definitions Schema) (Referenced Schema)
declareSchemaRef (Proxy (AddressInEra BabbageEra)
forall k (t :: k). Proxy t
Proxy :: Proxy (C.AddressInEra C.BabbageEra))
      Referenced Schema
valueSchema <- Proxy Value -> Declare (Definitions Schema) (Referenced Schema)
forall a.
ToSchema a =>
Proxy a -> Declare (Definitions Schema) (Referenced Schema)
declareSchemaRef (Proxy Value
forall k (t :: k). Proxy t
Proxy :: Proxy Value)
      Referenced Schema
bsSchema <- Proxy Datum -> Declare (Definitions Schema) (Referenced Schema)
forall a.
ToSchema a =>
Proxy a -> Declare (Definitions Schema) (Referenced Schema)
declareSchemaRef (Proxy Datum
forall k (t :: k). Proxy t
Proxy :: Proxy Datum)
      NamedSchema -> Declare (Definitions Schema) NamedSchema
forall (f :: * -> *) a. Applicative f => a -> f a
pure (NamedSchema -> Declare (Definitions Schema) NamedSchema)
-> NamedSchema -> Declare (Definitions Schema) NamedSchema
forall a b. (a -> b) -> a -> b
$ Maybe Text -> Schema -> NamedSchema
NamedSchema (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"TxOut") (Schema -> NamedSchema) -> Schema -> NamedSchema
forall a b. (a -> b) -> a -> b
$ Schema
forall a. Monoid a => a
mempty
        Schema -> (Schema -> Schema) -> Schema
forall a b. a -> (a -> b) -> b
& (Maybe OpenApiType -> Identity (Maybe OpenApiType))
-> Schema -> Identity Schema
forall s a. HasType s a => Lens' s a
type_ ((Maybe OpenApiType -> Identity (Maybe OpenApiType))
 -> Schema -> Identity Schema)
-> OpenApiType -> Schema -> Schema
forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ OpenApiType
OpenApiObject
        Schema -> (Schema -> Schema) -> Schema
forall a b. a -> (a -> b) -> b
& (InsOrdHashMap Text (Referenced Schema)
 -> Identity (InsOrdHashMap Text (Referenced Schema)))
-> Schema -> Identity Schema
forall s a. HasProperties s a => Lens' s a
properties ((InsOrdHashMap Text (Referenced Schema)
  -> Identity (InsOrdHashMap Text (Referenced Schema)))
 -> Schema -> Identity Schema)
-> InsOrdHashMap Text (Referenced Schema) -> Schema -> Schema
forall s t a b. ASetter s t a b -> b -> s -> t
.~
          [(Text, Referenced Schema)]
-> InsOrdHashMap Text (Referenced Schema)
forall k v. (Eq k, Hashable k) => [(k, v)] -> InsOrdHashMap k v
InsOrdMap.fromList [ (Text
"address", Referenced Schema
addressSchema)
          , (Text
"value", Referenced Schema
valueSchema)
          , (Text
"datum", Referenced Schema
bsSchema)
          , (Text
"referenceScript", Referenced Schema
bsSchema)
          ]
        Schema -> (Schema -> Schema) -> Schema
forall a b. a -> (a -> b) -> b
& ([Text] -> Identity [Text]) -> Schema -> Identity Schema
forall s a. HasRequired s a => Lens' s a
required (([Text] -> Identity [Text]) -> Schema -> Identity Schema)
-> [Text] -> Schema -> Schema
forall s t a b. ASetter s t a b -> b -> s -> t
.~ [Text
"address",Text
"value"]

deriving newtype instance OpenApi.ToSchema Cardano.Wallet.WalletId
deriving newtype instance OpenApi.ToSchema WalletId
deriving newtype instance OpenApi.ToSchema POSIXTime
deriving newtype instance OpenApi.ToSchema PaymentPubKeyHash
deriving anyclass instance OpenApi.ToSchema DCert
deriving anyclass instance OpenApi.ToSchema EndpointDescription
deriving anyclass instance OpenApi.ToSchema ActiveEndpoint
deriving anyclass instance OpenApi.ToSchema Wallet
deriving anyclass instance OpenApi.ToSchema ContractActivityStatus
deriving anyclass instance OpenApi.ToSchema ExportTx

instance OpenApi.ToSchema (C.Hash C.ScriptData) where
    declareNamedSchema :: Proxy (Hash ScriptData) -> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy (Hash ScriptData)
_ = NamedSchema -> Declare (Definitions Schema) NamedSchema
forall (f :: * -> *) a. Applicative f => a -> f a
pure (NamedSchema -> Declare (Definitions Schema) NamedSchema)
-> NamedSchema -> Declare (Definitions Schema) NamedSchema
forall a b. (a -> b) -> a -> b
$ Maybe Text -> Schema -> NamedSchema
NamedSchema (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"HashScriptData") Schema
byteSchema
instance OpenApi.ToSchema C.AssetName where
    declareNamedSchema :: Proxy AssetName -> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy AssetName
_ = NamedSchema -> Declare (Definitions Schema) NamedSchema
forall (f :: * -> *) a. Applicative f => a -> f a
pure (NamedSchema -> Declare (Definitions Schema) NamedSchema)
-> NamedSchema -> Declare (Definitions Schema) NamedSchema
forall a b. (a -> b) -> a -> b
$ Maybe Text -> Schema -> NamedSchema
NamedSchema (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"AssetName") Schema
byteSchema
instance OpenApi.ToSchema C.ScriptHash where
    declareNamedSchema :: Proxy ScriptHash -> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy ScriptHash
_ = NamedSchema -> Declare (Definitions Schema) NamedSchema
forall (f :: * -> *) a. Applicative f => a -> f a
pure (NamedSchema -> Declare (Definitions Schema) NamedSchema)
-> NamedSchema -> Declare (Definitions Schema) NamedSchema
forall a b. (a -> b) -> a -> b
$ Maybe Text -> Schema -> NamedSchema
NamedSchema (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"ScriptHash") Schema
forall a. Monoid a => a
mempty
instance OpenApi.ToSchema (Crypto.Digest Crypto.Blake2b_160) where
    declareNamedSchema :: Proxy (Digest Blake2b_160)
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy (Digest Blake2b_160)
_ = NamedSchema -> Declare (Definitions Schema) NamedSchema
forall (f :: * -> *) a. Applicative f => a -> f a
pure (NamedSchema -> Declare (Definitions Schema) NamedSchema)
-> NamedSchema -> Declare (Definitions Schema) NamedSchema
forall a b. (a -> b) -> a -> b
$ Maybe Text -> Schema -> NamedSchema
NamedSchema (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"Digest") Schema
forall a. Monoid a => a
mempty
instance OpenApi.ToSchema (Hash.Hash Hash.Blake2b_256 Hashes.EraIndependentTxBody) where
    declareNamedSchema :: Proxy (Hash Blake2b_256 EraIndependentTxBody)
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy (Hash Blake2b_256 EraIndependentTxBody)
_ = NamedSchema -> Declare (Definitions Schema) NamedSchema
forall (f :: * -> *) a. Applicative f => a -> f a
pure (NamedSchema -> Declare (Definitions Schema) NamedSchema)
-> NamedSchema -> Declare (Definitions Schema) NamedSchema
forall a b. (a -> b) -> a -> b
$ Maybe Text -> Schema -> NamedSchema
NamedSchema (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"Hash") Schema
forall a. Monoid a => a
mempty

deriving anyclass instance OpenApi.ToSchema C.Quantity
deriving anyclass instance OpenApi.ToSchema C.PolicyId
deriving anyclass instance OpenApi.ToSchema C.Lovelace
deriving anyclass instance OpenApi.ToSchema C.TxIx
deriving anyclass instance OpenApi.ToSchema C.TxId
deriving anyclass instance OpenApi.ToSchema ExportTxInput
deriving anyclass instance OpenApi.ToSchema ExportTxRedeemer
deriving anyclass instance OpenApi.ToSchema ChainIndexQuery
deriving anyclass instance OpenApi.ToSchema UnbalancedTx
deriving anyclass instance OpenApi.ToSchema SequenceId
deriving anyclass instance OpenApi.ToSchema PABReq
deriving anyclass instance OpenApi.ToSchema ContractInstanceId

instance OpenApi.ToSchema CardanoBuildTx where
  -- TODO: implement the schema
  declareNamedSchema :: Proxy CardanoBuildTx -> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy CardanoBuildTx
_ = NamedSchema -> Declare (Definitions Schema) NamedSchema
forall (m :: * -> *) a. Monad m => a -> m a
return (NamedSchema -> Declare (Definitions Schema) NamedSchema)
-> NamedSchema -> Declare (Definitions Schema) NamedSchema
forall a b. (a -> b) -> a -> b
$ Maybe Text -> Schema -> NamedSchema
NamedSchema (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"CardanoBuildTx") Schema
forall a. Monoid a => a
mempty

instance OpenApi.ToSchema UtxoIndex where
  -- TODO: implement the schema
  declareNamedSchema :: Proxy UtxoIndex -> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy UtxoIndex
_ = NamedSchema -> Declare (Definitions Schema) NamedSchema
forall (m :: * -> *) a. Monad m => a -> m a
return (NamedSchema -> Declare (Definitions Schema) NamedSchema)
-> NamedSchema -> Declare (Definitions Schema) NamedSchema
forall a b. (a -> b) -> a -> b
$ Maybe Text -> Schema -> NamedSchema
NamedSchema (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"UtxoIndex") Schema
forall a. Monoid a => a
mempty

data ContractReport t =
    ContractReport
        { ContractReport t -> [ContractSignatureResponse t]
crAvailableContracts   :: [ContractSignatureResponse t]
        , ContractReport t
-> [(ContractInstanceId, PartiallyDecodedResponse PABReq)]
crActiveContractStates :: [(ContractInstanceId, PartiallyDecodedResponse PABReq)]
        }
    deriving stock ((forall x. ContractReport t -> Rep (ContractReport t) x)
-> (forall x. Rep (ContractReport t) x -> ContractReport t)
-> Generic (ContractReport t)
forall x. Rep (ContractReport t) x -> ContractReport t
forall x. ContractReport t -> Rep (ContractReport t) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall t x. Rep (ContractReport t) x -> ContractReport t
forall t x. ContractReport t -> Rep (ContractReport t) x
$cto :: forall t x. Rep (ContractReport t) x -> ContractReport t
$cfrom :: forall t x. ContractReport t -> Rep (ContractReport t) x
Generic, ContractReport t -> ContractReport t -> Bool
(ContractReport t -> ContractReport t -> Bool)
-> (ContractReport t -> ContractReport t -> Bool)
-> Eq (ContractReport t)
forall t. Eq t => ContractReport t -> ContractReport t -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContractReport t -> ContractReport t -> Bool
$c/= :: forall t. Eq t => ContractReport t -> ContractReport t -> Bool
== :: ContractReport t -> ContractReport t -> Bool
$c== :: forall t. Eq t => ContractReport t -> ContractReport t -> Bool
Eq, Int -> ContractReport t -> ShowS
[ContractReport t] -> ShowS
ContractReport t -> String
(Int -> ContractReport t -> ShowS)
-> (ContractReport t -> String)
-> ([ContractReport t] -> ShowS)
-> Show (ContractReport t)
forall t. Show t => Int -> ContractReport t -> ShowS
forall t. Show t => [ContractReport t] -> ShowS
forall t. Show t => ContractReport t -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ContractReport t] -> ShowS
$cshowList :: forall t. Show t => [ContractReport t] -> ShowS
show :: ContractReport t -> String
$cshow :: forall t. Show t => ContractReport t -> String
showsPrec :: Int -> ContractReport t -> ShowS
$cshowsPrec :: forall t. Show t => Int -> ContractReport t -> ShowS
Show)
    deriving anyclass ([ContractReport t] -> Value
[ContractReport t] -> Encoding
ContractReport t -> Value
ContractReport t -> Encoding
(ContractReport t -> Value)
-> (ContractReport t -> Encoding)
-> ([ContractReport t] -> Value)
-> ([ContractReport t] -> Encoding)
-> ToJSON (ContractReport t)
forall t. ToJSON t => [ContractReport t] -> Value
forall t. ToJSON t => [ContractReport t] -> Encoding
forall t. ToJSON t => ContractReport t -> Value
forall t. ToJSON t => ContractReport t -> Encoding
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [ContractReport t] -> Encoding
$ctoEncodingList :: forall t. ToJSON t => [ContractReport t] -> Encoding
toJSONList :: [ContractReport t] -> Value
$ctoJSONList :: forall t. ToJSON t => [ContractReport t] -> Value
toEncoding :: ContractReport t -> Encoding
$ctoEncoding :: forall t. ToJSON t => ContractReport t -> Encoding
toJSON :: ContractReport t -> Value
$ctoJSON :: forall t. ToJSON t => ContractReport t -> Value
ToJSON, Value -> Parser [ContractReport t]
Value -> Parser (ContractReport t)
(Value -> Parser (ContractReport t))
-> (Value -> Parser [ContractReport t])
-> FromJSON (ContractReport t)
forall t. FromJSON t => Value -> Parser [ContractReport t]
forall t. FromJSON t => Value -> Parser (ContractReport t)
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [ContractReport t]
$cparseJSONList :: forall t. FromJSON t => Value -> Parser [ContractReport t]
parseJSON :: Value -> Parser (ContractReport t)
$cparseJSON :: forall t. FromJSON t => Value -> Parser (ContractReport t)
FromJSON, Typeable (ContractReport t)
Typeable (ContractReport t)
-> (Proxy (ContractReport t)
    -> Declare (Definitions Schema) NamedSchema)
-> ToSchema (ContractReport t)
Proxy (ContractReport t)
-> Declare (Definitions Schema) NamedSchema
forall a.
Typeable a
-> (Proxy a -> Declare (Definitions Schema) NamedSchema)
-> ToSchema a
forall t. ToSchema t => Typeable (ContractReport t)
forall t.
ToSchema t =>
Proxy (ContractReport t)
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema :: Proxy (ContractReport t)
-> Declare (Definitions Schema) NamedSchema
$cdeclareNamedSchema :: forall t.
ToSchema t =>
Proxy (ContractReport t)
-> Declare (Definitions Schema) NamedSchema
$cp1ToSchema :: forall t. ToSchema t => Typeable (ContractReport t)
OpenApi.ToSchema)

deriving newtype instance OpenApi.ToSchema LedgerBytes
deriving newtype instance OpenApi.ToSchema Signature
deriving newtype instance OpenApi.ToSchema PubKey
deriving instance OpenApi.ToSchema Withdrawal
deriving instance OpenApi.ToSchema Certificate
deriving anyclass instance OpenApi.ToSchema DereferencedInput
deriving anyclass instance OpenApi.ToSchema BeneficialOwner
deriving anyclass instance OpenApi.ToSchema C.TxIn
deriving anyclass instance OpenApi.ToSchema AnnotatedTx

data ChainReport =
    ChainReport
        { ChainReport -> Map TxId CardanoTx
transactionMap      :: Map TxId CardanoTx
        , ChainReport -> UtxoIndex
utxoIndex           :: UtxoIndex
        , ChainReport -> [[AnnotatedTx]]
annotatedBlockchain :: [[AnnotatedTx]]
        }
    deriving (Int -> ChainReport -> ShowS
[ChainReport] -> ShowS
ChainReport -> String
(Int -> ChainReport -> ShowS)
-> (ChainReport -> String)
-> ([ChainReport] -> ShowS)
-> Show ChainReport
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChainReport] -> ShowS
$cshowList :: [ChainReport] -> ShowS
show :: ChainReport -> String
$cshow :: ChainReport -> String
showsPrec :: Int -> ChainReport -> ShowS
$cshowsPrec :: Int -> ChainReport -> ShowS
Show, ChainReport -> ChainReport -> Bool
(ChainReport -> ChainReport -> Bool)
-> (ChainReport -> ChainReport -> Bool) -> Eq ChainReport
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChainReport -> ChainReport -> Bool
$c/= :: ChainReport -> ChainReport -> Bool
== :: ChainReport -> ChainReport -> Bool
$c== :: ChainReport -> ChainReport -> Bool
Eq, (forall x. ChainReport -> Rep ChainReport x)
-> (forall x. Rep ChainReport x -> ChainReport)
-> Generic ChainReport
forall x. Rep ChainReport x -> ChainReport
forall x. ChainReport -> Rep ChainReport x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ChainReport x -> ChainReport
$cfrom :: forall x. ChainReport -> Rep ChainReport x
Generic)
    deriving anyclass (Value -> Parser [ChainReport]
Value -> Parser ChainReport
(Value -> Parser ChainReport)
-> (Value -> Parser [ChainReport]) -> FromJSON ChainReport
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [ChainReport]
$cparseJSONList :: Value -> Parser [ChainReport]
parseJSON :: Value -> Parser ChainReport
$cparseJSON :: Value -> Parser ChainReport
FromJSON, [ChainReport] -> Value
[ChainReport] -> Encoding
ChainReport -> Value
ChainReport -> Encoding
(ChainReport -> Value)
-> (ChainReport -> Encoding)
-> ([ChainReport] -> Value)
-> ([ChainReport] -> Encoding)
-> ToJSON ChainReport
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [ChainReport] -> Encoding
$ctoEncodingList :: [ChainReport] -> Encoding
toJSONList :: [ChainReport] -> Value
$ctoJSONList :: [ChainReport] -> Value
toEncoding :: ChainReport -> Encoding
$ctoEncoding :: ChainReport -> Encoding
toJSON :: ChainReport -> Value
$ctoJSON :: ChainReport -> Value
ToJSON, Typeable ChainReport
Typeable ChainReport
-> (Proxy ChainReport -> Declare (Definitions Schema) NamedSchema)
-> ToSchema ChainReport
Proxy ChainReport -> Declare (Definitions Schema) NamedSchema
forall a.
Typeable a
-> (Proxy a -> Declare (Definitions Schema) NamedSchema)
-> ToSchema a
declareNamedSchema :: Proxy ChainReport -> Declare (Definitions Schema) NamedSchema
$cdeclareNamedSchema :: Proxy ChainReport -> Declare (Definitions Schema) NamedSchema
$cp1ToSchema :: Typeable ChainReport
OpenApi.ToSchema)

emptyChainReport :: ChainReport
emptyChainReport :: ChainReport
emptyChainReport = Map TxId CardanoTx -> UtxoIndex -> [[AnnotatedTx]] -> ChainReport
ChainReport Map TxId CardanoTx
forall a. Monoid a => a
mempty UtxoIndex
forall a. Monoid a => a
mempty [[AnnotatedTx]]
forall a. Monoid a => a
mempty

data FullReport t =
    FullReport
        { FullReport t -> ContractReport t
contractReport :: ContractReport t
        , FullReport t -> ChainReport
chainReport    :: ChainReport
        }
    deriving stock ((forall x. FullReport t -> Rep (FullReport t) x)
-> (forall x. Rep (FullReport t) x -> FullReport t)
-> Generic (FullReport t)
forall x. Rep (FullReport t) x -> FullReport t
forall x. FullReport t -> Rep (FullReport t) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall t x. Rep (FullReport t) x -> FullReport t
forall t x. FullReport t -> Rep (FullReport t) x
$cto :: forall t x. Rep (FullReport t) x -> FullReport t
$cfrom :: forall t x. FullReport t -> Rep (FullReport t) x
Generic, FullReport t -> FullReport t -> Bool
(FullReport t -> FullReport t -> Bool)
-> (FullReport t -> FullReport t -> Bool) -> Eq (FullReport t)
forall t. Eq t => FullReport t -> FullReport t -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FullReport t -> FullReport t -> Bool
$c/= :: forall t. Eq t => FullReport t -> FullReport t -> Bool
== :: FullReport t -> FullReport t -> Bool
$c== :: forall t. Eq t => FullReport t -> FullReport t -> Bool
Eq, Int -> FullReport t -> ShowS
[FullReport t] -> ShowS
FullReport t -> String
(Int -> FullReport t -> ShowS)
-> (FullReport t -> String)
-> ([FullReport t] -> ShowS)
-> Show (FullReport t)
forall t. Show t => Int -> FullReport t -> ShowS
forall t. Show t => [FullReport t] -> ShowS
forall t. Show t => FullReport t -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FullReport t] -> ShowS
$cshowList :: forall t. Show t => [FullReport t] -> ShowS
show :: FullReport t -> String
$cshow :: forall t. Show t => FullReport t -> String
showsPrec :: Int -> FullReport t -> ShowS
$cshowsPrec :: forall t. Show t => Int -> FullReport t -> ShowS
Show)
    deriving anyclass ([FullReport t] -> Value
[FullReport t] -> Encoding
FullReport t -> Value
FullReport t -> Encoding
(FullReport t -> Value)
-> (FullReport t -> Encoding)
-> ([FullReport t] -> Value)
-> ([FullReport t] -> Encoding)
-> ToJSON (FullReport t)
forall t. ToJSON t => [FullReport t] -> Value
forall t. ToJSON t => [FullReport t] -> Encoding
forall t. ToJSON t => FullReport t -> Value
forall t. ToJSON t => FullReport t -> Encoding
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [FullReport t] -> Encoding
$ctoEncodingList :: forall t. ToJSON t => [FullReport t] -> Encoding
toJSONList :: [FullReport t] -> Value
$ctoJSONList :: forall t. ToJSON t => [FullReport t] -> Value
toEncoding :: FullReport t -> Encoding
$ctoEncoding :: forall t. ToJSON t => FullReport t -> Encoding
toJSON :: FullReport t -> Value
$ctoJSON :: forall t. ToJSON t => FullReport t -> Value
ToJSON, Value -> Parser [FullReport t]
Value -> Parser (FullReport t)
(Value -> Parser (FullReport t))
-> (Value -> Parser [FullReport t]) -> FromJSON (FullReport t)
forall t. FromJSON t => Value -> Parser [FullReport t]
forall t. FromJSON t => Value -> Parser (FullReport t)
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [FullReport t]
$cparseJSONList :: forall t. FromJSON t => Value -> Parser [FullReport t]
parseJSON :: Value -> Parser (FullReport t)
$cparseJSON :: forall t. FromJSON t => Value -> Parser (FullReport t)
FromJSON, Typeable (FullReport t)
Typeable (FullReport t)
-> (Proxy (FullReport t)
    -> Declare (Definitions Schema) NamedSchema)
-> ToSchema (FullReport t)
Proxy (FullReport t) -> Declare (Definitions Schema) NamedSchema
forall a.
Typeable a
-> (Proxy a -> Declare (Definitions Schema) NamedSchema)
-> ToSchema a
forall t. ToSchema t => Typeable (FullReport t)
forall t.
ToSchema t =>
Proxy (FullReport t) -> Declare (Definitions Schema) NamedSchema
declareNamedSchema :: Proxy (FullReport t) -> Declare (Definitions Schema) NamedSchema
$cdeclareNamedSchema :: forall t.
ToSchema t =>
Proxy (FullReport t) -> Declare (Definitions Schema) NamedSchema
$cp1ToSchema :: forall t. ToSchema t => Typeable (FullReport t)
OpenApi.ToSchema)

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

deriving anyclass instance OpenApi.ToSchema t => OpenApi.ToSchema (ContractSignatureResponse t)

-- | Data needed to start a new instance of a contract.
data ContractActivationArgs t =
    ContractActivationArgs
        { ContractActivationArgs t -> t
caID     :: t -- ^ ID of the contract
        , ContractActivationArgs t -> Maybe Wallet
caWallet :: Maybe Wallet -- ^ Wallet that should be used for this instance, `knownWallet 1` is used in the Nothing case.
        }
    deriving stock (ContractActivationArgs t -> ContractActivationArgs t -> Bool
(ContractActivationArgs t -> ContractActivationArgs t -> Bool)
-> (ContractActivationArgs t -> ContractActivationArgs t -> Bool)
-> Eq (ContractActivationArgs t)
forall t.
Eq t =>
ContractActivationArgs t -> ContractActivationArgs t -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContractActivationArgs t -> ContractActivationArgs t -> Bool
$c/= :: forall t.
Eq t =>
ContractActivationArgs t -> ContractActivationArgs t -> Bool
== :: ContractActivationArgs t -> ContractActivationArgs t -> Bool
$c== :: forall t.
Eq t =>
ContractActivationArgs t -> ContractActivationArgs t -> Bool
Eq, Int -> ContractActivationArgs t -> ShowS
[ContractActivationArgs t] -> ShowS
ContractActivationArgs t -> String
(Int -> ContractActivationArgs t -> ShowS)
-> (ContractActivationArgs t -> String)
-> ([ContractActivationArgs t] -> ShowS)
-> Show (ContractActivationArgs t)
forall t. Show t => Int -> ContractActivationArgs t -> ShowS
forall t. Show t => [ContractActivationArgs t] -> ShowS
forall t. Show t => ContractActivationArgs t -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ContractActivationArgs t] -> ShowS
$cshowList :: forall t. Show t => [ContractActivationArgs t] -> ShowS
show :: ContractActivationArgs t -> String
$cshow :: forall t. Show t => ContractActivationArgs t -> String
showsPrec :: Int -> ContractActivationArgs t -> ShowS
$cshowsPrec :: forall t. Show t => Int -> ContractActivationArgs t -> ShowS
Show, (forall x.
 ContractActivationArgs t -> Rep (ContractActivationArgs t) x)
-> (forall x.
    Rep (ContractActivationArgs t) x -> ContractActivationArgs t)
-> Generic (ContractActivationArgs t)
forall x.
Rep (ContractActivationArgs t) x -> ContractActivationArgs t
forall x.
ContractActivationArgs t -> Rep (ContractActivationArgs t) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall t x.
Rep (ContractActivationArgs t) x -> ContractActivationArgs t
forall t x.
ContractActivationArgs t -> Rep (ContractActivationArgs t) x
$cto :: forall t x.
Rep (ContractActivationArgs t) x -> ContractActivationArgs t
$cfrom :: forall t x.
ContractActivationArgs t -> Rep (ContractActivationArgs t) x
Generic)
    deriving anyclass ([ContractActivationArgs t] -> Value
[ContractActivationArgs t] -> Encoding
ContractActivationArgs t -> Value
ContractActivationArgs t -> Encoding
(ContractActivationArgs t -> Value)
-> (ContractActivationArgs t -> Encoding)
-> ([ContractActivationArgs t] -> Value)
-> ([ContractActivationArgs t] -> Encoding)
-> ToJSON (ContractActivationArgs t)
forall t. ToJSON t => [ContractActivationArgs t] -> Value
forall t. ToJSON t => [ContractActivationArgs t] -> Encoding
forall t. ToJSON t => ContractActivationArgs t -> Value
forall t. ToJSON t => ContractActivationArgs t -> Encoding
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [ContractActivationArgs t] -> Encoding
$ctoEncodingList :: forall t. ToJSON t => [ContractActivationArgs t] -> Encoding
toJSONList :: [ContractActivationArgs t] -> Value
$ctoJSONList :: forall t. ToJSON t => [ContractActivationArgs t] -> Value
toEncoding :: ContractActivationArgs t -> Encoding
$ctoEncoding :: forall t. ToJSON t => ContractActivationArgs t -> Encoding
toJSON :: ContractActivationArgs t -> Value
$ctoJSON :: forall t. ToJSON t => ContractActivationArgs t -> Value
ToJSON, Value -> Parser [ContractActivationArgs t]
Value -> Parser (ContractActivationArgs t)
(Value -> Parser (ContractActivationArgs t))
-> (Value -> Parser [ContractActivationArgs t])
-> FromJSON (ContractActivationArgs t)
forall t. FromJSON t => Value -> Parser [ContractActivationArgs t]
forall t. FromJSON t => Value -> Parser (ContractActivationArgs t)
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [ContractActivationArgs t]
$cparseJSONList :: forall t. FromJSON t => Value -> Parser [ContractActivationArgs t]
parseJSON :: Value -> Parser (ContractActivationArgs t)
$cparseJSON :: forall t. FromJSON t => Value -> Parser (ContractActivationArgs t)
FromJSON)

deriving instance OpenApi.ToSchema t => OpenApi.ToSchema (ContractActivationArgs t)

instance Pretty t => Pretty (ContractActivationArgs t) where
    pretty :: ContractActivationArgs t -> Doc ann
pretty ContractActivationArgs{t
caID :: t
caID :: forall t. ContractActivationArgs t -> t
caID, Maybe Wallet
caWallet :: Maybe Wallet
caWallet :: forall t. ContractActivationArgs t -> Maybe Wallet
caWallet} =
        t -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty t
caID Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ann
"on" Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Maybe Wallet -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Maybe Wallet
caWallet

-- | Current state of a contract instance
--   (to be sent to external clients)
data ContractInstanceClientState t =
    ContractInstanceClientState
        { ContractInstanceClientState t -> ContractInstanceId
cicContract         :: ContractInstanceId
        , ContractInstanceClientState t
-> PartiallyDecodedResponse ActiveEndpoint
cicCurrentState     :: PartiallyDecodedResponse ActiveEndpoint
        , ContractInstanceClientState t -> Wallet
cicWallet           :: Wallet
        , ContractInstanceClientState t -> t
cicDefinition       :: t
        , ContractInstanceClientState t -> ContractActivityStatus
cicStatus           :: ContractActivityStatus
        , ContractInstanceClientState t -> [ExportTx]
cicYieldedExportTxs :: [ExportTx]
        }
        deriving stock (ContractInstanceClientState t
-> ContractInstanceClientState t -> Bool
(ContractInstanceClientState t
 -> ContractInstanceClientState t -> Bool)
-> (ContractInstanceClientState t
    -> ContractInstanceClientState t -> Bool)
-> Eq (ContractInstanceClientState t)
forall t.
Eq t =>
ContractInstanceClientState t
-> ContractInstanceClientState t -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContractInstanceClientState t
-> ContractInstanceClientState t -> Bool
$c/= :: forall t.
Eq t =>
ContractInstanceClientState t
-> ContractInstanceClientState t -> Bool
== :: ContractInstanceClientState t
-> ContractInstanceClientState t -> Bool
$c== :: forall t.
Eq t =>
ContractInstanceClientState t
-> ContractInstanceClientState t -> Bool
Eq, Int -> ContractInstanceClientState t -> ShowS
[ContractInstanceClientState t] -> ShowS
ContractInstanceClientState t -> String
(Int -> ContractInstanceClientState t -> ShowS)
-> (ContractInstanceClientState t -> String)
-> ([ContractInstanceClientState t] -> ShowS)
-> Show (ContractInstanceClientState t)
forall t. Show t => Int -> ContractInstanceClientState t -> ShowS
forall t. Show t => [ContractInstanceClientState t] -> ShowS
forall t. Show t => ContractInstanceClientState t -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ContractInstanceClientState t] -> ShowS
$cshowList :: forall t. Show t => [ContractInstanceClientState t] -> ShowS
show :: ContractInstanceClientState t -> String
$cshow :: forall t. Show t => ContractInstanceClientState t -> String
showsPrec :: Int -> ContractInstanceClientState t -> ShowS
$cshowsPrec :: forall t. Show t => Int -> ContractInstanceClientState t -> ShowS
Show, (forall x.
 ContractInstanceClientState t
 -> Rep (ContractInstanceClientState t) x)
-> (forall x.
    Rep (ContractInstanceClientState t) x
    -> ContractInstanceClientState t)
-> Generic (ContractInstanceClientState t)
forall x.
Rep (ContractInstanceClientState t) x
-> ContractInstanceClientState t
forall x.
ContractInstanceClientState t
-> Rep (ContractInstanceClientState t) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall t x.
Rep (ContractInstanceClientState t) x
-> ContractInstanceClientState t
forall t x.
ContractInstanceClientState t
-> Rep (ContractInstanceClientState t) x
$cto :: forall t x.
Rep (ContractInstanceClientState t) x
-> ContractInstanceClientState t
$cfrom :: forall t x.
ContractInstanceClientState t
-> Rep (ContractInstanceClientState t) x
Generic)
        deriving anyclass ([ContractInstanceClientState t] -> Value
[ContractInstanceClientState t] -> Encoding
ContractInstanceClientState t -> Value
ContractInstanceClientState t -> Encoding
(ContractInstanceClientState t -> Value)
-> (ContractInstanceClientState t -> Encoding)
-> ([ContractInstanceClientState t] -> Value)
-> ([ContractInstanceClientState t] -> Encoding)
-> ToJSON (ContractInstanceClientState t)
forall t. ToJSON t => [ContractInstanceClientState t] -> Value
forall t. ToJSON t => [ContractInstanceClientState t] -> Encoding
forall t. ToJSON t => ContractInstanceClientState t -> Value
forall t. ToJSON t => ContractInstanceClientState t -> Encoding
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [ContractInstanceClientState t] -> Encoding
$ctoEncodingList :: forall t. ToJSON t => [ContractInstanceClientState t] -> Encoding
toJSONList :: [ContractInstanceClientState t] -> Value
$ctoJSONList :: forall t. ToJSON t => [ContractInstanceClientState t] -> Value
toEncoding :: ContractInstanceClientState t -> Encoding
$ctoEncoding :: forall t. ToJSON t => ContractInstanceClientState t -> Encoding
toJSON :: ContractInstanceClientState t -> Value
$ctoJSON :: forall t. ToJSON t => ContractInstanceClientState t -> Value
ToJSON, Value -> Parser [ContractInstanceClientState t]
Value -> Parser (ContractInstanceClientState t)
(Value -> Parser (ContractInstanceClientState t))
-> (Value -> Parser [ContractInstanceClientState t])
-> FromJSON (ContractInstanceClientState t)
forall t.
FromJSON t =>
Value -> Parser [ContractInstanceClientState t]
forall t.
FromJSON t =>
Value -> Parser (ContractInstanceClientState t)
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [ContractInstanceClientState t]
$cparseJSONList :: forall t.
FromJSON t =>
Value -> Parser [ContractInstanceClientState t]
parseJSON :: Value -> Parser (ContractInstanceClientState t)
$cparseJSON :: forall t.
FromJSON t =>
Value -> Parser (ContractInstanceClientState t)
FromJSON)

deriving instance OpenApi.ToSchema t => OpenApi.ToSchema (ContractInstanceClientState t)

-- | Status updates for contract instances streamed to client
data InstanceStatusToClient
    = NewObservableState JSON.Value -- ^ The observable state of the contract has changed.
    | NewActiveEndpoints [ActiveEndpoint] -- ^ The set of active endpoints has changed.
    | NewYieldedExportTxs [ExportTx] -- ^ Partial txs that need to be balanced, signed and submitted by an external client.
    | ContractFinished (Maybe JSON.Value) -- ^ Contract instance is done with an optional error message.
    deriving stock ((forall x. InstanceStatusToClient -> Rep InstanceStatusToClient x)
-> (forall x.
    Rep InstanceStatusToClient x -> InstanceStatusToClient)
-> Generic InstanceStatusToClient
forall x. Rep InstanceStatusToClient x -> InstanceStatusToClient
forall x. InstanceStatusToClient -> Rep InstanceStatusToClient x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InstanceStatusToClient x -> InstanceStatusToClient
$cfrom :: forall x. InstanceStatusToClient -> Rep InstanceStatusToClient x
Generic, InstanceStatusToClient -> InstanceStatusToClient -> Bool
(InstanceStatusToClient -> InstanceStatusToClient -> Bool)
-> (InstanceStatusToClient -> InstanceStatusToClient -> Bool)
-> Eq InstanceStatusToClient
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstanceStatusToClient -> InstanceStatusToClient -> Bool
$c/= :: InstanceStatusToClient -> InstanceStatusToClient -> Bool
== :: InstanceStatusToClient -> InstanceStatusToClient -> Bool
$c== :: InstanceStatusToClient -> InstanceStatusToClient -> Bool
Eq, Int -> InstanceStatusToClient -> ShowS
[InstanceStatusToClient] -> ShowS
InstanceStatusToClient -> String
(Int -> InstanceStatusToClient -> ShowS)
-> (InstanceStatusToClient -> String)
-> ([InstanceStatusToClient] -> ShowS)
-> Show InstanceStatusToClient
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstanceStatusToClient] -> ShowS
$cshowList :: [InstanceStatusToClient] -> ShowS
show :: InstanceStatusToClient -> String
$cshow :: InstanceStatusToClient -> String
showsPrec :: Int -> InstanceStatusToClient -> ShowS
$cshowsPrec :: Int -> InstanceStatusToClient -> ShowS
Show)
    deriving anyclass ([InstanceStatusToClient] -> Value
[InstanceStatusToClient] -> Encoding
InstanceStatusToClient -> Value
InstanceStatusToClient -> Encoding
(InstanceStatusToClient -> Value)
-> (InstanceStatusToClient -> Encoding)
-> ([InstanceStatusToClient] -> Value)
-> ([InstanceStatusToClient] -> Encoding)
-> ToJSON InstanceStatusToClient
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [InstanceStatusToClient] -> Encoding
$ctoEncodingList :: [InstanceStatusToClient] -> Encoding
toJSONList :: [InstanceStatusToClient] -> Value
$ctoJSONList :: [InstanceStatusToClient] -> Value
toEncoding :: InstanceStatusToClient -> Encoding
$ctoEncoding :: InstanceStatusToClient -> Encoding
toJSON :: InstanceStatusToClient -> Value
$ctoJSON :: InstanceStatusToClient -> Value
ToJSON, Value -> Parser [InstanceStatusToClient]
Value -> Parser InstanceStatusToClient
(Value -> Parser InstanceStatusToClient)
-> (Value -> Parser [InstanceStatusToClient])
-> FromJSON InstanceStatusToClient
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [InstanceStatusToClient]
$cparseJSONList :: Value -> Parser [InstanceStatusToClient]
parseJSON :: Value -> Parser InstanceStatusToClient
$cparseJSON :: Value -> Parser InstanceStatusToClient
FromJSON)

-- | Data sent to the client through the combined websocket API
data CombinedWSStreamToClient
    = InstanceUpdate ContractInstanceId InstanceStatusToClient
    | SlotChange Slot -- ^ New slot number
    deriving stock ((forall x.
 CombinedWSStreamToClient -> Rep CombinedWSStreamToClient x)
-> (forall x.
    Rep CombinedWSStreamToClient x -> CombinedWSStreamToClient)
-> Generic CombinedWSStreamToClient
forall x.
Rep CombinedWSStreamToClient x -> CombinedWSStreamToClient
forall x.
CombinedWSStreamToClient -> Rep CombinedWSStreamToClient x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CombinedWSStreamToClient x -> CombinedWSStreamToClient
$cfrom :: forall x.
CombinedWSStreamToClient -> Rep CombinedWSStreamToClient x
Generic, CombinedWSStreamToClient -> CombinedWSStreamToClient -> Bool
(CombinedWSStreamToClient -> CombinedWSStreamToClient -> Bool)
-> (CombinedWSStreamToClient -> CombinedWSStreamToClient -> Bool)
-> Eq CombinedWSStreamToClient
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CombinedWSStreamToClient -> CombinedWSStreamToClient -> Bool
$c/= :: CombinedWSStreamToClient -> CombinedWSStreamToClient -> Bool
== :: CombinedWSStreamToClient -> CombinedWSStreamToClient -> Bool
$c== :: CombinedWSStreamToClient -> CombinedWSStreamToClient -> Bool
Eq, Int -> CombinedWSStreamToClient -> ShowS
[CombinedWSStreamToClient] -> ShowS
CombinedWSStreamToClient -> String
(Int -> CombinedWSStreamToClient -> ShowS)
-> (CombinedWSStreamToClient -> String)
-> ([CombinedWSStreamToClient] -> ShowS)
-> Show CombinedWSStreamToClient
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CombinedWSStreamToClient] -> ShowS
$cshowList :: [CombinedWSStreamToClient] -> ShowS
show :: CombinedWSStreamToClient -> String
$cshow :: CombinedWSStreamToClient -> String
showsPrec :: Int -> CombinedWSStreamToClient -> ShowS
$cshowsPrec :: Int -> CombinedWSStreamToClient -> ShowS
Show)
    deriving anyclass ([CombinedWSStreamToClient] -> Value
[CombinedWSStreamToClient] -> Encoding
CombinedWSStreamToClient -> Value
CombinedWSStreamToClient -> Encoding
(CombinedWSStreamToClient -> Value)
-> (CombinedWSStreamToClient -> Encoding)
-> ([CombinedWSStreamToClient] -> Value)
-> ([CombinedWSStreamToClient] -> Encoding)
-> ToJSON CombinedWSStreamToClient
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [CombinedWSStreamToClient] -> Encoding
$ctoEncodingList :: [CombinedWSStreamToClient] -> Encoding
toJSONList :: [CombinedWSStreamToClient] -> Value
$ctoJSONList :: [CombinedWSStreamToClient] -> Value
toEncoding :: CombinedWSStreamToClient -> Encoding
$ctoEncoding :: CombinedWSStreamToClient -> Encoding
toJSON :: CombinedWSStreamToClient -> Value
$ctoJSON :: CombinedWSStreamToClient -> Value
ToJSON, Value -> Parser [CombinedWSStreamToClient]
Value -> Parser CombinedWSStreamToClient
(Value -> Parser CombinedWSStreamToClient)
-> (Value -> Parser [CombinedWSStreamToClient])
-> FromJSON CombinedWSStreamToClient
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [CombinedWSStreamToClient]
$cparseJSONList :: Value -> Parser [CombinedWSStreamToClient]
parseJSON :: Value -> Parser CombinedWSStreamToClient
$cparseJSON :: Value -> Parser CombinedWSStreamToClient
FromJSON)

-- | Instructions sent to the server through the combined websocket API
data CombinedWSStreamToServer
    = Subscribe (Either ContractInstanceId PubKeyHash)
    | Unsubscribe (Either ContractInstanceId PubKeyHash)
    deriving stock ((forall x.
 CombinedWSStreamToServer -> Rep CombinedWSStreamToServer x)
-> (forall x.
    Rep CombinedWSStreamToServer x -> CombinedWSStreamToServer)
-> Generic CombinedWSStreamToServer
forall x.
Rep CombinedWSStreamToServer x -> CombinedWSStreamToServer
forall x.
CombinedWSStreamToServer -> Rep CombinedWSStreamToServer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CombinedWSStreamToServer x -> CombinedWSStreamToServer
$cfrom :: forall x.
CombinedWSStreamToServer -> Rep CombinedWSStreamToServer x
Generic, CombinedWSStreamToServer -> CombinedWSStreamToServer -> Bool
(CombinedWSStreamToServer -> CombinedWSStreamToServer -> Bool)
-> (CombinedWSStreamToServer -> CombinedWSStreamToServer -> Bool)
-> Eq CombinedWSStreamToServer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CombinedWSStreamToServer -> CombinedWSStreamToServer -> Bool
$c/= :: CombinedWSStreamToServer -> CombinedWSStreamToServer -> Bool
== :: CombinedWSStreamToServer -> CombinedWSStreamToServer -> Bool
$c== :: CombinedWSStreamToServer -> CombinedWSStreamToServer -> Bool
Eq, Int -> CombinedWSStreamToServer -> ShowS
[CombinedWSStreamToServer] -> ShowS
CombinedWSStreamToServer -> String
(Int -> CombinedWSStreamToServer -> ShowS)
-> (CombinedWSStreamToServer -> String)
-> ([CombinedWSStreamToServer] -> ShowS)
-> Show CombinedWSStreamToServer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CombinedWSStreamToServer] -> ShowS
$cshowList :: [CombinedWSStreamToServer] -> ShowS
show :: CombinedWSStreamToServer -> String
$cshow :: CombinedWSStreamToServer -> String
showsPrec :: Int -> CombinedWSStreamToServer -> ShowS
$cshowsPrec :: Int -> CombinedWSStreamToServer -> ShowS
Show)
    deriving anyclass ([CombinedWSStreamToServer] -> Value
[CombinedWSStreamToServer] -> Encoding
CombinedWSStreamToServer -> Value
CombinedWSStreamToServer -> Encoding
(CombinedWSStreamToServer -> Value)
-> (CombinedWSStreamToServer -> Encoding)
-> ([CombinedWSStreamToServer] -> Value)
-> ([CombinedWSStreamToServer] -> Encoding)
-> ToJSON CombinedWSStreamToServer
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [CombinedWSStreamToServer] -> Encoding
$ctoEncodingList :: [CombinedWSStreamToServer] -> Encoding
toJSONList :: [CombinedWSStreamToServer] -> Value
$ctoJSONList :: [CombinedWSStreamToServer] -> Value
toEncoding :: CombinedWSStreamToServer -> Encoding
$ctoEncoding :: CombinedWSStreamToServer -> Encoding
toJSON :: CombinedWSStreamToServer -> Value
$ctoJSON :: CombinedWSStreamToServer -> Value
ToJSON, Value -> Parser [CombinedWSStreamToServer]
Value -> Parser CombinedWSStreamToServer
(Value -> Parser CombinedWSStreamToServer)
-> (Value -> Parser [CombinedWSStreamToServer])
-> FromJSON CombinedWSStreamToServer
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [CombinedWSStreamToServer]
$cparseJSONList :: Value -> Parser [CombinedWSStreamToServer]
parseJSON :: Value -> Parser CombinedWSStreamToServer
$cparseJSON :: Value -> Parser CombinedWSStreamToServer
FromJSON)