{-# LANGUAGE OverloadedStrings #-}
module Cometa.Provider (Provider (..), unavailable) where
import Cometa.Address (Address)
import Cometa.Address.Reward (RewardAddress)
import Cometa.AssetId (AssetId)
import Cometa.Error (Error (..))
import Cometa.Evaluation (Budgets)
import Cometa.PlutusData (EncodedPlutusData)
import Cometa.Protocol.Parameters (Parameters)
import Cometa.Transaction (Transaction)
import Cometa.Transaction.Datum (Hash32)
import Cometa.Transaction.Input (Input)
import Cometa.Transaction.Utxo (Utxo)
import Cometa.TransactionId (TransactionId)
import Data.Text (Text)
import Data.Word (Word32, Word64)
data Provider = Provider
{
Provider -> Text
name :: !Text,
Provider -> Word32
networkMagic :: !Word32,
Provider -> IO (Either Error Parameters)
protocolParameters :: IO (Either Error Parameters),
Provider -> Address -> IO (Either Error [Utxo])
utxosAt :: Address -> IO (Either Error [Utxo]),
Provider -> RewardAddress -> IO (Either Error Word64)
rewardBalance :: RewardAddress -> IO (Either Error Word64),
Provider -> Address -> AssetId -> IO (Either Error [Utxo])
utxosWithAsset :: Address -> AssetId -> IO (Either Error [Utxo]),
Provider -> AssetId -> IO (Either Error (Maybe Utxo))
utxoWithAsset :: AssetId -> IO (Either Error (Maybe Utxo)),
Provider -> [Input] -> IO (Either Error [Utxo])
resolveInputs :: [Input] -> IO (Either Error [Utxo]),
Provider -> Hash32 -> IO (Either Error (Maybe EncodedPlutusData))
resolveDatum :: Hash32 -> IO (Either Error (Maybe EncodedPlutusData)),
Provider -> TransactionId -> Word64 -> IO (Either Error Bool)
awaitTransaction :: TransactionId -> Word64 -> IO (Either Error Bool),
Provider -> Transaction -> IO (Either Error TransactionId)
submitTransaction :: Transaction -> IO (Either Error TransactionId),
Provider -> Transaction -> [Utxo] -> IO (Either Error Budgets)
evaluateTransaction :: Transaction -> [Utxo] -> IO (Either Error Budgets)
}
unavailable :: Text -> Word32 -> Provider
unavailable :: Text -> Word32 -> Provider
unavailable Text
backendName Word32
magic =
Text
-> Word32
-> IO (Either Error Parameters)
-> (Address -> IO (Either Error [Utxo]))
-> (RewardAddress -> IO (Either Error Word64))
-> (Address -> AssetId -> IO (Either Error [Utxo]))
-> (AssetId -> IO (Either Error (Maybe Utxo)))
-> ([Input] -> IO (Either Error [Utxo]))
-> (Hash32 -> IO (Either Error (Maybe EncodedPlutusData)))
-> (TransactionId -> Word64 -> IO (Either Error Bool))
-> (Transaction -> IO (Either Error TransactionId))
-> (Transaction -> [Utxo] -> IO (Either Error Budgets))
-> Provider
Provider
Text
backendName
Word32
magic
(Text -> IO (Either Error Parameters)
forall {f :: * -> *} {b}.
Applicative f =>
Text -> f (Either Error b)
unsupported Text
"provider.protocolParameters")
(\Address
_ -> Text -> IO (Either Error [Utxo])
forall {f :: * -> *} {b}.
Applicative f =>
Text -> f (Either Error b)
unsupported Text
"provider.utxosAt")
(\RewardAddress
_ -> Text -> IO (Either Error Word64)
forall {f :: * -> *} {b}.
Applicative f =>
Text -> f (Either Error b)
unsupported Text
"provider.rewardBalance")
(\Address
_ AssetId
_ -> Text -> IO (Either Error [Utxo])
forall {f :: * -> *} {b}.
Applicative f =>
Text -> f (Either Error b)
unsupported Text
"provider.utxosWithAsset")
(\AssetId
_ -> Text -> IO (Either Error (Maybe Utxo))
forall {f :: * -> *} {b}.
Applicative f =>
Text -> f (Either Error b)
unsupported Text
"provider.utxoWithAsset")
(\[Input]
_ -> Text -> IO (Either Error [Utxo])
forall {f :: * -> *} {b}.
Applicative f =>
Text -> f (Either Error b)
unsupported Text
"provider.resolveInputs")
(\Hash32
_ -> Text -> IO (Either Error (Maybe EncodedPlutusData))
forall {f :: * -> *} {b}.
Applicative f =>
Text -> f (Either Error b)
unsupported Text
"provider.resolveDatum")
(\TransactionId
_ Word64
_ -> Text -> IO (Either Error Bool)
forall {f :: * -> *} {b}.
Applicative f =>
Text -> f (Either Error b)
unsupported Text
"provider.awaitTransaction")
(\Transaction
_ -> Text -> IO (Either Error TransactionId)
forall {f :: * -> *} {b}.
Applicative f =>
Text -> f (Either Error b)
unsupported Text
"provider.submitTransaction")
(\Transaction
_ [Utxo]
_ -> Text -> IO (Either Error Budgets)
forall {f :: * -> *} {b}.
Applicative f =>
Text -> f (Either Error b)
unsupported Text
"provider.evaluateTransaction")
where
unsupported :: Text -> f (Either Error b)
unsupported Text
operation = Either Error b -> f (Either Error b)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Error -> Either Error b
forall a b. a -> Either a b
Left (Text -> Error
UnsupportedOperation Text
operation))