diff --git a/README.md b/README.md index 7aaf524..841e1ba 100644 --- a/README.md +++ b/README.md @@ -36,8 +36,8 @@ ```haskell import Maestro.Client.Env -myEnvPreprod <- mkMaestroEnv "Your-API-Key" Preprod -myEnvMainnet <- mkMaestroEnv "Your-API-Key" Mainnet +myEnvPreprod <- mkMaestroEnv @'V0 "Your-API-Key" Preprod +myEnvMainnet <- mkMaestroEnv @'V0 "Your-API-Key" Mainnet ``` 4. Example: chain tip ```haskell diff --git a/maestro-exe/Maestro/Run/Address.hs b/maestro-exe/Maestro/Run/Address.hs new file mode 100644 index 0000000..5fa3234 --- /dev/null +++ b/maestro-exe/Maestro/Run/Address.hs @@ -0,0 +1,8 @@ +module Maestro.Run.Address where + +import Maestro.Client.Env +import qualified Maestro.Client.V0 as V0 +import qualified Maestro.Client.V1 as V1 + +runAddressAPI :: MaestroEnv 'V0 -> IO () +runAddressAPI mEnv = undefined diff --git a/maestro-exe/Maestro/Run/AddressV1.hs b/maestro-exe/Maestro/Run/AddressV1.hs deleted file mode 100644 index 8ae7b19..0000000 --- a/maestro-exe/Maestro/Run/AddressV1.hs +++ /dev/null @@ -1,9 +0,0 @@ -module Maestro.Run.AddressV1 where - -import Maestro.Client.V1 - -runV1AddressAPI :: MaestroEnv -> IO () -runV1AddressAPI mEnv = do - utxos <- allPages $ (flip $ utxosAtMultiAddresses mEnv Nothing Nothing) ["insert","your", "big", "address", "list", "here"] - putStrLn $ "Received: ⮯\n" ++ show utxos - -- writeFile "allUtxos.txt" $ show utxos diff --git a/maestro-exe/Maestro/Run/Datum.hs b/maestro-exe/Maestro/Run/Datum.hs index e07134e..acdb9c7 100644 --- a/maestro-exe/Maestro/Run/Datum.hs +++ b/maestro-exe/Maestro/Run/Datum.hs @@ -3,7 +3,7 @@ module Maestro.Run.Datum where import Maestro.Client.V0 import Text.Printf (printf) -runDatumAPI :: MaestroEnv -> IO () +runDatumAPI :: MaestroEnv 'V0 -> IO () runDatumAPI mEnv = do let datumHash = "938dc15a5faa3da8e7f1e3ed8ca50b49248f8fffdfc04ff3cf7dffa0d06343eb" -- Quiet an involved datum. printf "Fetching datum from hash %s...\n" datumHash diff --git a/maestro-exe/Maestro/Run/Epochs.hs b/maestro-exe/Maestro/Run/Epochs.hs index 67a7d5b..535a0b2 100644 --- a/maestro-exe/Maestro/Run/Epochs.hs +++ b/maestro-exe/Maestro/Run/Epochs.hs @@ -2,7 +2,7 @@ module Maestro.Run.Epochs where import Maestro.Client.V0 -runEpochsAPI :: MaestroEnv -> IO () +runEpochsAPI :: MaestroEnv 'V0 -> IO () runEpochsAPI mEnv = do putStrLn "Fetching Current Epoch's Info ..." currentEpochInfo <- getCurrentEpoch mEnv diff --git a/maestro-exe/Maestro/Run/General.hs b/maestro-exe/Maestro/Run/General.hs index 1d29e89..774eb31 100644 --- a/maestro-exe/Maestro/Run/General.hs +++ b/maestro-exe/Maestro/Run/General.hs @@ -3,7 +3,7 @@ module Maestro.Run.General where import Maestro.Client.V0 import Text.Printf (printf) -runGeneralAPI :: MaestroEnv -> IO () +runGeneralAPI :: MaestroEnv 'V0 -> IO () runGeneralAPI mEnv = do chainTip <- getChainTip mEnv printf "Querying chain-tip, received: ⮯\n%s\n" (show chainTip) diff --git a/maestro-exe/Maestro/Run/Pools.hs b/maestro-exe/Maestro/Run/Pools.hs index 0bb8ae7..b97564d 100644 --- a/maestro-exe/Maestro/Run/Pools.hs +++ b/maestro-exe/Maestro/Run/Pools.hs @@ -6,7 +6,7 @@ import Maestro.Types.V0 poolId :: Bech32StringOf PoolId poolId = "pool1rkfs9glmfva3jd0q9vnlqvuhnrflpzj4l07u6sayfx5k7d788us" -runPoolsAPI :: MaestroEnv -> IO () +runPoolsAPI :: MaestroEnv 'V0 -> IO () runPoolsAPI mEnv = do putStrLn "Fetching List Pools ..." lstPools <- runListPools mEnv @@ -40,26 +40,26 @@ runPoolsAPI mEnv = do updates <- runPoolInfo mEnv putStrLn $ "fetched pool Updates: \n " ++ show updates -runPoolUpdates :: MaestroEnv -> IO [PoolUpdate] +runPoolUpdates :: MaestroEnv 'V0 -> IO [PoolUpdate] runPoolUpdates mEnv = poolUpdates mEnv poolId -runListPools :: MaestroEnv -> IO [PoolListInfo] +runListPools :: MaestroEnv 'V0 -> IO [PoolListInfo] runListPools mEnv = listPools mEnv (Page 1 1) -runPoolBlocks :: MaestroEnv -> IO [PoolBlock] +runPoolBlocks :: MaestroEnv 'V0 -> IO [PoolBlock] runPoolBlocks mEnv = poolBlocks mEnv poolId (Page 1 1) Nothing (Just Ascending) -runPoolDelegators :: MaestroEnv -> IO [DelegatorInfo] +runPoolDelegators :: MaestroEnv 'V0 -> IO [DelegatorInfo] runPoolDelegators mEnv = poolDelegators mEnv poolId (Page 1 1) -runPoolHistory :: MaestroEnv -> IO [PoolHistory] +runPoolHistory :: MaestroEnv 'V0 -> IO [PoolHistory] runPoolHistory mEnv = poolHistory mEnv poolId (Page 1 1) Nothing (Just Ascending) -runPoolInfo :: MaestroEnv -> IO PoolInfo +runPoolInfo :: MaestroEnv 'V0 -> IO PoolInfo runPoolInfo mEnv = poolInfo mEnv poolId -runPoolMetadata :: MaestroEnv -> IO PoolMetadata +runPoolMetadata :: MaestroEnv 'V0 -> IO PoolMetadata runPoolMetadata mEnv = poolMetadata mEnv poolId -runPoolRelay :: MaestroEnv -> IO [PoolRelay] +runPoolRelay :: MaestroEnv 'V0 -> IO [PoolRelay] runPoolRelay mEnv = poolRelays mEnv poolId diff --git a/maestro-exe/Maestro/Run/Scripts.hs b/maestro-exe/Maestro/Run/Scripts.hs index f51e30d..afdd6d2 100644 --- a/maestro-exe/Maestro/Run/Scripts.hs +++ b/maestro-exe/Maestro/Run/Scripts.hs @@ -3,7 +3,7 @@ module Maestro.Run.Scripts where import Maestro.Client.V0 import Text.Printf (printf) -runScriptsAPI :: MaestroEnv -> IO () +runScriptsAPI :: MaestroEnv 'V0 -> IO () runScriptsAPI mEnv = do let scriptHash = "3a888d65f16790950a72daee1f63aa05add6d268434107cfa5b67712" printf "Fetching script from hash %s...\n" scriptHash diff --git a/maestro-exe/Maestro/Run/Tx.hs b/maestro-exe/Maestro/Run/Tx.hs index 963f1a7..0e3899d 100644 --- a/maestro-exe/Maestro/Run/Tx.hs +++ b/maestro-exe/Maestro/Run/Tx.hs @@ -6,7 +6,7 @@ import Maestro.Types.V0 txHash :: HashStringOf Tx txHash = "7fdf7a20ba50d841344ab0cb368da6a047ce1e2a29b707586f61f0b8fea6bcf2" -runTxApi :: MaestroEnv -> IO () +runTxApi :: MaestroEnv 'V0 -> IO () runTxApi mEnv = do putStrLn "Fetching Tx Address ..." txAddr <- runTxAddress mEnv @@ -20,11 +20,11 @@ runTxApi mEnv = do utxo <- runTxUtxo mEnv putStrLn $ "fetched Tx Utxos: \n " ++ show utxo -runTxAddress :: MaestroEnv -> IO UtxoAddress +runTxAddress :: MaestroEnv 'V0 -> IO UtxoAddress runTxAddress mEnv = txAddress mEnv txHash $ TxIndex 0 -runTxCbor :: MaestroEnv -> IO TxCbor +runTxCbor :: MaestroEnv 'V0 -> IO TxCbor runTxCbor mEnv = txCbor mEnv txHash -runTxUtxo :: MaestroEnv -> IO Utxo +runTxUtxo :: MaestroEnv 'V0 -> IO Utxo runTxUtxo mEnv = txUtxo mEnv txHash (TxIndex 0) (Just True) (Just True) diff --git a/maestro-exe/Main.hs b/maestro-exe/Main.hs index db2c952..11b8f3c 100644 --- a/maestro-exe/Main.hs +++ b/maestro-exe/Main.hs @@ -2,13 +2,13 @@ module Main (main) where import qualified Data.Text as T import Maestro.Client.Env +import Maestro.Run.Address import Maestro.Run.Datum import Maestro.Run.Epochs import Maestro.Run.General import Maestro.Run.Pools import Maestro.Run.Scripts import Maestro.Run.Tx -import Maestro.Run.AddressV1 import System.Environment (getEnv) @@ -17,15 +17,16 @@ main :: IO () main = do apiKey <- maestroKey apiKeyMain <- maestroMainKey - env <- mkMaestroEnv (T.pack apiKey) Preprod V0 + env <- mkMaestroEnv @'V0 (T.pack apiKey) Preprod runPoolsAPI env runTxApi env runEpochsAPI env runDatumAPI env runScriptsAPI env runGeneralAPI env - env' <- mkMaestroEnv (T.pack apiKeyMain) Mainnet V1 - runV1AddressAPI env' + -- env' <- mkMaestroEnv @'V1 (T.pack apiKeyMain) Mainnet + env' <- mkMaestroEnv @'V0 (T.pack apiKeyMain) Mainnet + runAddressAPI env' where maestroKey = getEnv "MAESTRO_API_KEY" diff --git a/maestro-sdk.cabal b/maestro-sdk.cabal index 67ef973..23d4ba6 100644 --- a/maestro-sdk.cabal +++ b/maestro-sdk.cabal @@ -21,6 +21,7 @@ source-repository head common common ghc-options: -Wall default-extensions: + GADTs DataKinds DeriveGeneric DerivingStrategies @@ -154,7 +155,7 @@ executable maestro-exe Maestro.Run.Scripts Maestro.Run.Tx Maestro.Run.Epochs - Maestro.Run.AddressV1 + Maestro.Run.Address -- other-extensions: hs-source-dirs: maestro-exe main-is: Main.hs diff --git a/src/Maestro/Client/Env.hs b/src/Maestro/Client/Env.hs index 601e48b..6b15c7f 100644 --- a/src/Maestro/Client/Env.hs +++ b/src/Maestro/Client/Env.hs @@ -14,25 +14,40 @@ import qualified Servant.Client as Servant type MaestroToken = Text -data MaestroEnv = MaestroEnv +data MaestroApiVersion = V0 | V1 + +instance Show MaestroApiVersion where + show V0 = "v0" + show V1 = "v1" + +data SingMaestroApiVersion (v :: MaestroApiVersion) where + SingV0 :: SingMaestroApiVersion 'V0 + SingV1 :: SingMaestroApiVersion 'V1 + +fromSingMaestroApiVersion :: SingMaestroApiVersion v -> MaestroApiVersion +fromSingMaestroApiVersion SingV0 = V0 +fromSingMaestroApiVersion SingV1 = V1 + +class SingMaestroApiVersionI (v :: MaestroApiVersion) + where singMaestroApiVersion :: SingMaestroApiVersion v + +instance SingMaestroApiVersionI 'V0 where singMaestroApiVersion = SingV0 +instance SingMaestroApiVersionI 'V1 where singMaestroApiVersion = SingV1 + +data MaestroEnv (v :: MaestroApiVersion) = MaestroEnv { _maeClientEnv :: !Servant.ClientEnv , _maeToken :: !MaestroToken } data MaestroNetwork = Mainnet | Preprod -data MaestroApiVersion = V0 | V1 - --- TODO : Move version check inside. maestroBaseUrl :: MaestroNetwork -> MaestroApiVersion -> String -maestroBaseUrl Preprod V0 = "https://preprod.gomaestro-api.org/v0" -maestroBaseUrl Preprod V1 = "https://preprod.gomaestro-api.org/v1" -maestroBaseUrl Mainnet V0 = "https://mainnet.gomaestro-api.org/v0" -maestroBaseUrl Mainnet V1 = "https://mainnet.gomaestro-api.org/v1" - -mkMaestroEnv :: MaestroToken -> MaestroNetwork -> MaestroApiVersion -> IO MaestroEnv -mkMaestroEnv token nid apiVersion = do - clientEnv <- servantClientEnv $ maestroBaseUrl nid apiVersion +maestroBaseUrl Preprod v = "https://preprod.gomaestro-api.org/" <> show v +maestroBaseUrl Mainnet v = "https://mainnet.gomaestro-api.org/" <> show v + +mkMaestroEnv :: forall (apiVersion :: MaestroApiVersion). SingMaestroApiVersionI apiVersion => MaestroToken -> MaestroNetwork -> IO (MaestroEnv apiVersion) +mkMaestroEnv token nid = do + clientEnv <- servantClientEnv $ maestroBaseUrl nid (fromSingMaestroApiVersion $ singMaestroApiVersion @apiVersion) pure $ MaestroEnv { _maeClientEnv = clientEnv, _maeToken = token } servantClientEnv :: String -> IO Servant.ClientEnv diff --git a/src/Maestro/Client/V0/Accounts.hs b/src/Maestro/Client/V0/Accounts.hs index 89f11e5..bf40793 100644 --- a/src/Maestro/Client/V0/Accounts.hs +++ b/src/Maestro/Client/V0/Accounts.hs @@ -9,23 +9,23 @@ import Maestro.Types.V0 import Servant.API.Generic import Servant.Client -accountsClient :: MaestroEnv -> AccountsAPI (AsClientT IO) +accountsClient :: MaestroEnv 'V0 -> AccountsAPI (AsClientT IO) accountsClient = fromServant . _accounts . apiV0Client -getAccount :: MaestroEnv -> Text -> IO AccountInfo +getAccount :: MaestroEnv 'V0 -> Text -> IO AccountInfo getAccount = _account . accountsClient -listAccountAddresses :: MaestroEnv -> Text -> Page -> IO [Text] +listAccountAddresses :: MaestroEnv 'V0 -> Text -> Page -> IO [Text] listAccountAddresses = _accountAddresses . accountsClient -listAccountAssets :: MaestroEnv -> Text -> Page -> IO [Asset] +listAccountAssets :: MaestroEnv 'V0 -> Text -> Page -> IO [Asset] listAccountAssets = _accountAssets . accountsClient -listAccountHistory :: MaestroEnv -> Text -> Maybe EpochNo -> Page -> IO [AccountHistory] +listAccountHistory :: MaestroEnv 'V0 -> Text -> Maybe EpochNo -> Page -> IO [AccountHistory] listAccountHistory = _accountsHistory . accountsClient -listAccountRewards :: MaestroEnv -> Text -> Page -> IO [AccountReward] +listAccountRewards :: MaestroEnv 'V0 -> Text -> Page -> IO [AccountReward] listAccountRewards = _accountsReward . accountsClient -listAccountUpdates :: MaestroEnv -> Text -> Page -> IO [AccountUpdate] +listAccountUpdates :: MaestroEnv 'V0 -> Text -> Page -> IO [AccountUpdate] listAccountUpdates = _accountsUpdates . accountsClient diff --git a/src/Maestro/Client/V0/Address.hs b/src/Maestro/Client/V0/Address.hs index 5ec9fef..926d29e 100644 --- a/src/Maestro/Client/V0/Address.hs +++ b/src/Maestro/Client/V0/Address.hs @@ -9,14 +9,14 @@ import Maestro.Types.V0 import Servant.API.Generic import Servant.Client -addressClient :: MaestroEnv -> AddressAPI (AsClientT IO) +addressClient :: MaestroEnv 'V0 -> AddressAPI (AsClientT IO) addressClient = fromServant . _address . apiV0Client -- | -- Returns list of utxos for multiple addresses utxosAtMultiAddresses :: -- | The Maestro Environment - MaestroEnv -> + MaestroEnv 'V0 -> -- | Query param to include the corresponding datums for datum hashes Maybe Bool -> -- | Query Param to include the CBOR encodings of the transaction outputs in the response @@ -31,7 +31,7 @@ utxosAtMultiAddresses = _addressesUtxos . addressClient -- | -- Returns list of utxo for specific address utxosAtAddress :: - MaestroEnv -> + MaestroEnv 'V0 -> -- | The Address in bech32 format Text -> -- | Query param to include the corresponding datums for datum hashes @@ -46,7 +46,7 @@ utxosAtAddress = _addressUtxo . addressClient -- | -- Returns list of utxo ref for address getRefsAtAddress :: - MaestroEnv -> + MaestroEnv 'V0 -> -- | The Address in bech32 format Text -> -- | The pagination attributes @@ -57,7 +57,7 @@ getRefsAtAddress = _addressUtxoRefs . addressClient -- | -- Get the transaction count for an address getTxCountForAddress :: - MaestroEnv -> + MaestroEnv 'V0 -> -- | The Address in bech32 format Text -> IO [AddressTxCount] diff --git a/src/Maestro/Client/V0/Assets.hs b/src/Maestro/Client/V0/Assets.hs index 85e4233..44af505 100644 --- a/src/Maestro/Client/V0/Assets.hs +++ b/src/Maestro/Client/V0/Assets.hs @@ -9,14 +9,14 @@ import Maestro.Types.V0 import Servant.API.Generic import Servant.Client -assetClient :: MaestroEnv -> AssetsAPI (AsClientT IO) +assetClient :: MaestroEnv 'V0 -> AssetsAPI (AsClientT IO) assetClient = fromServant . _assets . apiV0Client -- | -- Returns list of Information about the assets of the given policy ID listAssetInfoByPolicyId :: -- | The Maestro Environment - MaestroEnv -> + MaestroEnv 'V0 -> -- | The Hex encoded policy ID PolicyId -> -- | Pagination @@ -28,7 +28,7 @@ listAssetInfoByPolicyId = _assetPolicyInfo . assetClient -- Returns a list of addresses which holding some of an asset of the given policy ID listAssetAddressByPolicyId :: -- | The Maestro Environment - MaestroEnv -> + MaestroEnv 'V0 -> -- | The Hex encoded policy ID PolicyId -> -- | Pagination @@ -40,7 +40,7 @@ listAssetAddressByPolicyId = _assetPolicyAddress . assetClient -- Returns list of transactions in which an address receives an asset of the specified policy listTxByPolicyId :: -- | The Maestro Environment - MaestroEnv -> + MaestroEnv 'V0 -> -- | The Hex encoded policy ID PolicyId -> -- | Pagination @@ -52,7 +52,7 @@ listTxByPolicyId = _assetPolicyTxs . assetClient -- Returns UTxOs which contain assets of the given policy ID, with the asset names and amounts listUtxosByPolicyId :: -- | The Maestro Environment - MaestroEnv -> + MaestroEnv 'V0 -> -- | The Hex encoded policy ID PolicyId -> -- | Pagination @@ -64,7 +64,7 @@ listUtxosByPolicyId = _assetPolicyUtxos . assetClient -- Returns UTxOs which contain assets of the given policy ID, with the asset names and amounts getAssetDetail :: -- | The Maestro Environment - MaestroEnv -> + MaestroEnv 'V0 -> -- | Asset, encoded as concatenation of hex of policy ID and asset name AssetId -> IO AssetInfo @@ -74,7 +74,7 @@ getAssetDetail = _assetDetail . assetClient -- Returns a list of addresses which hold some amount of the specified asset listAssetAddresses :: -- | The Maestro Environment - MaestroEnv -> + MaestroEnv 'V0 -> -- | Asset, encoded as concatenation of hex of policy ID and asset name AssetId -> Page -> @@ -85,7 +85,7 @@ listAssetAddresses = _assetAddresses . assetClient -- Returns list of transactions in which an address receives an asset of the specified policy listAssetTx :: -- | The Maestro Environment - MaestroEnv -> + MaestroEnv 'V0 -> -- | Asset, encoded as concatenation of hex of policy ID and asset name AssetId -> -- | Return only transactions after supplied block height @@ -100,7 +100,7 @@ listAssetTx = _assetTxs . assetClient -- Returns list of transactions which minted or burned the specified asset listAssetUpdates :: -- | The Maestro Environment - MaestroEnv -> + MaestroEnv 'V0 -> -- | Asset, encoded as concatenation of hex of policy ID and asset name AssetId -> -- | The Pagination @@ -114,7 +114,7 @@ listAssetUpdates = _assetUpdates . assetClient -- Returns UTxOs containing the specified asset, each paired with the amount of the asset listAssetUtxos :: -- | The Maestro Environment - MaestroEnv -> + MaestroEnv 'V0 -> -- | Asset, encoded as concatenation of hex of policy ID and asset name AssetId -> -- | The Pagination diff --git a/src/Maestro/Client/V0/Core.hs b/src/Maestro/Client/V0/Core.hs index 1acd9ad..621ca52 100644 --- a/src/Maestro/Client/V0/Core.hs +++ b/src/Maestro/Client/V0/Core.hs @@ -13,8 +13,8 @@ import Servant.Client import Servant.Client.Generic -apiV0ClientAuth :: MaestroEnv -> MaestroApiV0Auth (AsClientT IO) -apiV0ClientAuth MaestroEnv{..} = genericClientHoist $ \x -> runClientM x _maeClientEnv >>= either (throwIO . fromServantClientError) pure +apiV0ClientAuth :: MaestroEnv 'V0 -> MaestroApiV0Auth (AsClientT IO) +apiV0ClientAuth MaestroEnv {..} = genericClientHoist $ \x -> runClientM x _maeClientEnv >>= either (throwIO . fromServantClientError) pure -apiV0Client :: MaestroEnv -> MaestroApiV0 (AsClientT IO) +apiV0Client :: MaestroEnv 'V0 -> MaestroApiV0 (AsClientT IO) apiV0Client mEnv@MaestroEnv {..} = fromServant $ _apiV0 (apiV0ClientAuth mEnv) _maeToken diff --git a/src/Maestro/Client/V0/Datum.hs b/src/Maestro/Client/V0/Datum.hs index 02336ae..90c002d 100644 --- a/src/Maestro/Client/V0/Datum.hs +++ b/src/Maestro/Client/V0/Datum.hs @@ -11,9 +11,9 @@ import Maestro.Types.V0 import Servant.API.Generic import Servant.Client -datumClient :: MaestroEnv -> DatumAPI (AsClientT IO) +datumClient :: MaestroEnv 'V0 -> DatumAPI (AsClientT IO) datumClient = fromServant . _datum . apiV0Client -- | Get information about the datum from it's hash. -getDatumByHash :: MaestroEnv -> Text -> IO Datum +getDatumByHash :: MaestroEnv 'V0 -> Text -> IO Datum getDatumByHash = _datumByHash . datumClient diff --git a/src/Maestro/Client/V0/Epochs.hs b/src/Maestro/Client/V0/Epochs.hs index 6ab5639..347aaf1 100644 --- a/src/Maestro/Client/V0/Epochs.hs +++ b/src/Maestro/Client/V0/Epochs.hs @@ -11,13 +11,13 @@ import Maestro.Types.V0 import Servant.API.Generic import Servant.Client -epochsClient :: MaestroEnv -> EpochsAPI (AsClientT IO) +epochsClient :: MaestroEnv 'V0 -> EpochsAPI (AsClientT IO) epochsClient = fromServant . _epochs . apiV0Client -- | Get information about the current epoch. -getCurrentEpoch :: MaestroEnv -> IO CurrentEpochInfo +getCurrentEpoch :: MaestroEnv 'V0 -> IO CurrentEpochInfo getCurrentEpoch = _currentEpochInfo . epochsClient -- | Get information about a specific epoch. -getEpochInfo :: MaestroEnv -> EpochNo -> IO EpochInfo +getEpochInfo :: MaestroEnv 'V0 -> EpochNo -> IO EpochInfo getEpochInfo = _epochInfo . epochsClient diff --git a/src/Maestro/Client/V0/General.hs b/src/Maestro/Client/V0/General.hs index 18bc915..dfb280c 100644 --- a/src/Maestro/Client/V0/General.hs +++ b/src/Maestro/Client/V0/General.hs @@ -13,21 +13,21 @@ import Maestro.Types.V0 import Servant.API.Generic import Servant.Client -generalClient :: MaestroEnv -> GeneralAPI (AsClientT IO) +generalClient :: MaestroEnv 'V0 -> GeneralAPI (AsClientT IO) generalClient = fromServant . _general . apiV0Client -- | Get details about the latest block of the network. -getChainTip :: MaestroEnv -> IO ChainTip +getChainTip :: MaestroEnv 'V0 -> IO ChainTip getChainTip = _chainTip . generalClient -- | Get network start time since genesis. -getSystemStart :: MaestroEnv -> IO SystemStart +getSystemStart :: MaestroEnv 'V0 -> IO SystemStart getSystemStart = _systemStart . generalClient -- | Get network era history. -getEraHistory :: MaestroEnv -> IO [EraSummary] +getEraHistory :: MaestroEnv 'V0 -> IO [EraSummary] getEraHistory = _eraHistory . generalClient -- | Get protocol parameters for the latest epoch. -getProtocolParameters :: MaestroEnv -> IO ProtocolParameters +getProtocolParameters :: MaestroEnv 'V0 -> IO ProtocolParameters getProtocolParameters = _protocolParams . generalClient diff --git a/src/Maestro/Client/V0/Pools.hs b/src/Maestro/Client/V0/Pools.hs index 841aafb..355a139 100644 --- a/src/Maestro/Client/V0/Pools.hs +++ b/src/Maestro/Client/V0/Pools.hs @@ -18,38 +18,38 @@ import Maestro.Types.V0 import Servant.API.Generic import Servant.Client -poolsClient :: MaestroEnv -> PoolAPI (AsClientT IO) +poolsClient :: MaestroEnv 'V0 -> PoolAPI (AsClientT IO) poolsClient = fromServant . _pools . apiV0Client -- | Returns a list of currently registered stake pools -listPools :: MaestroEnv -> Page -> IO [PoolListInfo] +listPools :: MaestroEnv 'V0 -> Page -> IO [PoolListInfo] listPools = _listPools . poolsClient -- | Return information about blocks minted by a given pool for all epochs -- (or just epoch `epoch_no` if provided) -poolBlocks :: MaestroEnv -> Bech32StringOf PoolId -> Page -> Maybe EpochNo -> Maybe Order -> IO [PoolBlock] +poolBlocks :: MaestroEnv 'V0 -> Bech32StringOf PoolId -> Page -> Maybe EpochNo -> Maybe Order -> IO [PoolBlock] poolBlocks = _poolBlocks . poolsClient -poolDelegators :: MaestroEnv -> Bech32StringOf PoolId -> Page -> IO [DelegatorInfo] +poolDelegators :: MaestroEnv 'V0 -> Bech32StringOf PoolId -> Page -> IO [DelegatorInfo] poolDelegators = _poolDelegators . poolsClient -- | Returns per-epoch information about the specified pool -- (or just epoch `epoch_no` if provided) -poolHistory :: MaestroEnv -> Bech32StringOf PoolId -> Page -> Maybe EpochNo -> Maybe Order -> IO [PoolHistory] +poolHistory :: MaestroEnv 'V0 -> Bech32StringOf PoolId -> Page -> Maybe EpochNo -> Maybe Order -> IO [PoolHistory] poolHistory = _poolHistory . poolsClient -- | Returns current information about the specified pool -poolInfo :: MaestroEnv -> Bech32StringOf PoolId -> IO PoolInfo +poolInfo :: MaestroEnv 'V0 -> Bech32StringOf PoolId -> IO PoolInfo poolInfo = _poolInfo . poolsClient -- | Returns the metadata declared by a specific pool -poolMetadata :: MaestroEnv -> Bech32StringOf PoolId -> IO PoolMetadata +poolMetadata :: MaestroEnv 'V0 -> Bech32StringOf PoolId -> IO PoolMetadata poolMetadata = _poolMetadata . poolsClient -- | Returns a list of relays declared by the specified pool -poolRelays :: MaestroEnv -> Bech32StringOf PoolId -> IO [PoolRelay] +poolRelays :: MaestroEnv 'V0 -> Bech32StringOf PoolId -> IO [PoolRelay] poolRelays = _poolRelays . poolsClient -- | Returns a list of updates relating to the specified pool -poolUpdates :: MaestroEnv -> Bech32StringOf PoolId -> IO [PoolUpdate] +poolUpdates :: MaestroEnv 'V0 -> Bech32StringOf PoolId -> IO [PoolUpdate] poolUpdates = _poolUpdates . poolsClient diff --git a/src/Maestro/Client/V0/Scripts.hs b/src/Maestro/Client/V0/Scripts.hs index c40641a..c7455a4 100644 --- a/src/Maestro/Client/V0/Scripts.hs +++ b/src/Maestro/Client/V0/Scripts.hs @@ -11,9 +11,9 @@ import Maestro.Types.V0 import Servant.API.Generic import Servant.Client -scriptsClient :: MaestroEnv -> ScriptsAPI (AsClientT IO) +scriptsClient :: MaestroEnv 'V0 -> ScriptsAPI (AsClientT IO) scriptsClient = fromServant . _scripts . apiV0Client -- | Get information about the script from it's hash. -getScriptByHash :: MaestroEnv -> Text -> IO Script +getScriptByHash :: MaestroEnv 'V0 -> Text -> IO Script getScriptByHash = _scriptByHash . scriptsClient diff --git a/src/Maestro/Client/V0/Transaction.hs b/src/Maestro/Client/V0/Transaction.hs index 641c561..02b5329 100644 --- a/src/Maestro/Client/V0/Transaction.hs +++ b/src/Maestro/Client/V0/Transaction.hs @@ -16,7 +16,7 @@ import Maestro.Types.V0 import Servant.API.Generic import Servant.Client -txClient :: MaestroEnv -> TxAPI (AsClientT IO) +txClient :: MaestroEnv 'V0 -> TxAPI (AsClientT IO) txClient = fromServant . _tx . apiV0Client -- | @@ -24,7 +24,7 @@ txClient = fromServant . _tx . apiV0Client -- Interaction with this endpoint is identical to IOG's Cardano Submit API and will not be monitored by Maestro. submitTx :: -- | The Maestro Environment - MaestroEnv -> + MaestroEnv 'V0 -> -- | CBOR encoded Transaction BS.ByteString -> IO Text @@ -34,7 +34,7 @@ submitTx = _submitTx . txClient -- Returns hex-encoded CBOR bytes of a transaction txCbor :: -- | The Maestro Environment - MaestroEnv -> + MaestroEnv 'V0 -> -- | Hex Encoded Transaction Hash HashStringOf Tx -> -- | hex-encoded CBOR bytes of a transaction @@ -45,7 +45,7 @@ txCbor = _txCborApi . txClient -- Returns the address specified in the given transaction output txAddress :: -- | The Maestro Environment - MaestroEnv -> + MaestroEnv 'V0 -> -- | Hex Encoded Transaction Hash HashStringOf Tx -> -- | The Transaction Output Index @@ -56,8 +56,8 @@ txAddress = _txAddressApi . txClient -- | -- Returns the specified transaction output of a transaction output reference txUtxo :: - -- | The MaestroEnv - MaestroEnv -> + -- | The Maestro Environment. + MaestroEnv 'V0 -> -- | Hex encoded transaction hash HashStringOf Tx -> -- | The Transaction Output Index diff --git a/src/Maestro/Client/V0/TxManager.hs b/src/Maestro/Client/V0/TxManager.hs index 6776ed6..171ab5b 100644 --- a/src/Maestro/Client/V0/TxManager.hs +++ b/src/Maestro/Client/V0/TxManager.hs @@ -12,7 +12,7 @@ import Maestro.Client.V0.Core import Servant.API.Generic import Servant.Client -txClient :: MaestroEnv -> TxManagerAPI (AsClientT IO) +txClient :: MaestroEnv 'V0 -> TxManagerAPI (AsClientT IO) txClient = fromServant . _txManager . apiV0Client -- | @@ -20,7 +20,7 @@ txClient = fromServant . _txManager . apiV0Client -- A transaction submited with this endpoint will be monitored by Maestro. submitAndMonitorTx :: -- | The Maestro Environment - MaestroEnv -> + MaestroEnv 'V0 -> -- | CBOR encoded Transaction BS.ByteString -> IO Text diff --git a/src/Maestro/Client/V1/Address.hs b/src/Maestro/Client/V1/Address.hs index cd9a0c8..c13f6b5 100644 --- a/src/Maestro/Client/V1/Address.hs +++ b/src/Maestro/Client/V1/Address.hs @@ -9,13 +9,13 @@ import Maestro.Types.V1 import Servant.API.Generic import Servant.Client -addressClient :: MaestroEnv -> AddressAPI (AsClientT IO) +addressClient :: MaestroEnv 'V1 -> AddressAPI (AsClientT IO) addressClient = fromServant . _address . apiV1Client -- | Returns list of utxos for multiple addresses utxosAtMultiAddresses :: -- | The Maestro Environment - MaestroEnv -> + MaestroEnv 'V1 -> -- | Query param to include the corresponding datums for datum hashes Maybe Bool -> -- | Query Param to include the CBOR encodings of the transaction outputs in the response diff --git a/src/Maestro/Client/V1/Core.hs b/src/Maestro/Client/V1/Core.hs index 638e983..266d1f6 100644 --- a/src/Maestro/Client/V1/Core.hs +++ b/src/Maestro/Client/V1/Core.hs @@ -12,8 +12,8 @@ import Servant.API.Generic (fromServant) import Servant.Client import Servant.Client.Generic -apiV1ClientAuth :: MaestroEnv -> MaestroApiV1Auth (AsClientT IO) +apiV1ClientAuth :: MaestroEnv 'V1 -> MaestroApiV1Auth (AsClientT IO) apiV1ClientAuth MaestroEnv{..} = genericClientHoist $ \x -> runClientM x _maeClientEnv >>= either (throwIO . fromServantClientError) pure -apiV1Client :: MaestroEnv -> MaestroApiV1 (AsClientT IO) +apiV1Client :: MaestroEnv 'V1 -> MaestroApiV1 (AsClientT IO) apiV1Client mEnv@MaestroEnv {..} = fromServant $ _apiV1 (apiV1ClientAuth mEnv) _maeToken