diff --git a/maestro-exe/Maestro/Run/Address.hs b/maestro-exe/Maestro/Run/Address.hs deleted file mode 100644 index 7ba2703..0000000 --- a/maestro-exe/Maestro/Run/Address.hs +++ /dev/null @@ -1,20 +0,0 @@ -module Maestro.Run.Address where - -import Control.Monad (unless) -import Data.List (sort) -import qualified Data.Text as T (pack) -import Maestro.Client.Env -import qualified Maestro.Client.V0 as V0 -import qualified Maestro.Client.V1 as V1 -import Maestro.Types.V1.Common (v1UtxoWithSlotToV0) - -runAddressAPI :: String -> IO () -runAddressAPI apiKey = do - mEnvV0 <- mkMaestroEnv @'V0 (T.pack apiKey) Preprod - mEnvV1 <- mkMaestroEnv @'V1 (T.pack apiKey) Preprod - let addrs = undefined -- Mention list of addresses. - utxos <- V0.allPages $ flip (V0.utxosAtMultiAddresses mEnvV0 Nothing Nothing) addrs - let utxosSorted = sort utxos - utxos' <- fmap (fmap v1UtxoWithSlotToV0) $ V1.allPages $ flip (V1.utxosAtMultiAddresses mEnvV1 Nothing Nothing) addrs - let utxos'Sorted = sort utxos' - unless (utxosSorted == utxos'Sorted) $ error "Not same" diff --git a/maestro-exe/Maestro/Run/Datum.hs b/maestro-exe/Maestro/Run/Datum.hs deleted file mode 100644 index acdb9c7..0000000 --- a/maestro-exe/Maestro/Run/Datum.hs +++ /dev/null @@ -1,11 +0,0 @@ -module Maestro.Run.Datum where - -import Maestro.Client.V0 -import Text.Printf (printf) - -runDatumAPI :: MaestroEnv 'V0 -> IO () -runDatumAPI mEnv = do - let datumHash = "938dc15a5faa3da8e7f1e3ed8ca50b49248f8fffdfc04ff3cf7dffa0d06343eb" -- Quiet an involved datum. - printf "Fetching datum from hash %s...\n" datumHash - datum <- getDatumByHash mEnv datumHash - putStrLn $ "Received: ⮯\n" ++ show datum diff --git a/maestro-exe/Maestro/Run/Epochs.hs b/maestro-exe/Maestro/Run/Epochs.hs deleted file mode 100644 index 535a0b2..0000000 --- a/maestro-exe/Maestro/Run/Epochs.hs +++ /dev/null @@ -1,12 +0,0 @@ -module Maestro.Run.Epochs where - -import Maestro.Client.V0 - -runEpochsAPI :: MaestroEnv 'V0 -> IO () -runEpochsAPI mEnv = do - putStrLn "Fetching Current Epoch's Info ..." - currentEpochInfo <- getCurrentEpoch mEnv - putStrLn $ "Received: ⮯\n" ++ show currentEpochInfo - putStrLn "Fetching 70th Epoch's Info ..." - epochInfo <- getEpochInfo mEnv 70 - putStrLn $ "Received: ⮯\n" ++ show epochInfo diff --git a/maestro-exe/Maestro/Run/General.hs b/maestro-exe/Maestro/Run/General.hs deleted file mode 100644 index 774eb31..0000000 --- a/maestro-exe/Maestro/Run/General.hs +++ /dev/null @@ -1,9 +0,0 @@ -module Maestro.Run.General where - -import Maestro.Client.V0 -import Text.Printf (printf) - -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 deleted file mode 100644 index b97564d..0000000 --- a/maestro-exe/Maestro/Run/Pools.hs +++ /dev/null @@ -1,65 +0,0 @@ -module Maestro.Run.Pools where - -import Maestro.Client.V0 -import Maestro.Types.V0 - -poolId :: Bech32StringOf PoolId -poolId = "pool1rkfs9glmfva3jd0q9vnlqvuhnrflpzj4l07u6sayfx5k7d788us" - -runPoolsAPI :: MaestroEnv 'V0 -> IO () -runPoolsAPI mEnv = do - putStrLn "Fetching List Pools ..." - lstPools <- runListPools mEnv - putStrLn $ "fetched List Pools: \n " ++ show lstPools - - putStrLn "Fetching Pool Blocks ..." - blocks <- runPoolBlocks mEnv - putStrLn $ "fetched Pool Blocks: \n " ++ show blocks - - putStrLn "Fetching Pool Delegators ..." - delegators <- runPoolBlocks mEnv - putStrLn $ "fetched pool Delegators: \n " ++ show delegators - - putStrLn "Fetching Pool History ..." - hist <- runPoolBlocks mEnv - putStrLn $ "fetched pool History: \n " ++ show hist - - putStrLn "Fetching Pool Info ..." - info <- runPoolInfo mEnv - putStrLn $ "fetched pool Info: \n " ++ show info - - putStrLn "Fetching Pool Metadata ..." - metadata <- runPoolInfo mEnv - putStrLn $ "fetched pool Metadata: \n " ++ show metadata - - putStrLn "Fetching Pool Relays ..." - relays <- runPoolInfo mEnv - putStrLn $ "fetched pool Relays: \n " ++ show relays - - putStrLn "Fetching Pool Updates ..." - updates <- runPoolInfo mEnv - putStrLn $ "fetched pool Updates: \n " ++ show updates - -runPoolUpdates :: MaestroEnv 'V0 -> IO [PoolUpdate] -runPoolUpdates mEnv = poolUpdates mEnv poolId - -runListPools :: MaestroEnv 'V0 -> IO [PoolListInfo] -runListPools mEnv = listPools mEnv (Page 1 1) - -runPoolBlocks :: MaestroEnv 'V0 -> IO [PoolBlock] -runPoolBlocks mEnv = poolBlocks mEnv poolId (Page 1 1) Nothing (Just Ascending) - -runPoolDelegators :: MaestroEnv 'V0 -> IO [DelegatorInfo] -runPoolDelegators mEnv = poolDelegators mEnv poolId (Page 1 1) - -runPoolHistory :: MaestroEnv 'V0 -> IO [PoolHistory] -runPoolHistory mEnv = poolHistory mEnv poolId (Page 1 1) Nothing (Just Ascending) - -runPoolInfo :: MaestroEnv 'V0 -> IO PoolInfo -runPoolInfo mEnv = poolInfo mEnv poolId - -runPoolMetadata :: MaestroEnv 'V0 -> IO PoolMetadata -runPoolMetadata mEnv = poolMetadata mEnv poolId - -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 deleted file mode 100644 index afdd6d2..0000000 --- a/maestro-exe/Maestro/Run/Scripts.hs +++ /dev/null @@ -1,11 +0,0 @@ -module Maestro.Run.Scripts where - -import Maestro.Client.V0 -import Text.Printf (printf) - -runScriptsAPI :: MaestroEnv 'V0 -> IO () -runScriptsAPI mEnv = do - let scriptHash = "3a888d65f16790950a72daee1f63aa05add6d268434107cfa5b67712" - printf "Fetching script from hash %s...\n" scriptHash - script <- getScriptByHash mEnv scriptHash - putStrLn $ "Received: ⮯\n" ++ show script diff --git a/maestro-exe/Maestro/Run/Tx.hs b/maestro-exe/Maestro/Run/Tx.hs deleted file mode 100644 index 0e3899d..0000000 --- a/maestro-exe/Maestro/Run/Tx.hs +++ /dev/null @@ -1,30 +0,0 @@ -module Maestro.Run.Tx where - -import Maestro.Client.V0 -import Maestro.Types.V0 - -txHash :: HashStringOf Tx -txHash = "7fdf7a20ba50d841344ab0cb368da6a047ce1e2a29b707586f61f0b8fea6bcf2" - -runTxApi :: MaestroEnv 'V0 -> IO () -runTxApi mEnv = do - putStrLn "Fetching Tx Address ..." - txAddr <- runTxAddress mEnv - putStrLn $ "fetched Tx Addr: \n " ++ show txAddr - - putStrLn "Fetching Tx Cbor ..." - cbor <- runTxCbor mEnv - putStrLn $ "fetched Tx Cbor: \n " ++ show cbor - - putStrLn "Fetching Tx Utxo" - utxo <- runTxUtxo mEnv - putStrLn $ "fetched Tx Utxos: \n " ++ show utxo - -runTxAddress :: MaestroEnv 'V0 -> IO UtxoAddress -runTxAddress mEnv = txAddress mEnv txHash $ TxIndex 0 - -runTxCbor :: MaestroEnv 'V0 -> IO TxCbor -runTxCbor mEnv = txCbor mEnv txHash - -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 deleted file mode 100644 index 64f50f8..0000000 --- a/maestro-exe/Main.hs +++ /dev/null @@ -1,29 +0,0 @@ -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 System.Environment (getEnv) - - -main :: IO () - -main = do - apiKey <- maestroKey - env <- mkMaestroEnv @'V0 (T.pack apiKey) Preprod - runPoolsAPI env - runTxApi env - runEpochsAPI env - runDatumAPI env - runScriptsAPI env - runGeneralAPI env - -- runAddressAPI apiKey - - where - maestroKey = getEnv "MAESTRO_API_KEY" diff --git a/maestro-sdk.cabal b/maestro-sdk.cabal index bfac535..a686f11 100644 --- a/maestro-sdk.cabal +++ b/maestro-sdk.cabal @@ -44,18 +44,6 @@ common common library import: common exposed-modules: - Maestro.API.V0 - Maestro.API.V0.Accounts - Maestro.API.V0.Address - Maestro.API.V0.Assets - Maestro.API.V0.Datum - Maestro.API.V0.Epochs - Maestro.API.V0.General - Maestro.API.V0.Pool - Maestro.API.V0.Scripts - Maestro.API.V0.Transaction - Maestro.API.V0.TxManager - Maestro.API.V1 Maestro.API.V1.Addresses Maestro.API.V1.Datum @@ -66,19 +54,6 @@ library Maestro.Client.Env Maestro.Client.Error - Maestro.Client.V0 - Maestro.Client.V0.Core - Maestro.Client.V0.Core.Pagination - Maestro.Client.V0.Datum - Maestro.Client.V0.Epochs - Maestro.Client.V0.Accounts - Maestro.Client.V0.Address - Maestro.Client.V0.Assets - Maestro.Client.V0.General - Maestro.Client.V0.Pools - Maestro.Client.V0.Scripts - Maestro.Client.V0.Transaction - Maestro.Client.V0.TxManager Maestro.Client.V1 Maestro.Client.V1.Core @@ -91,16 +66,6 @@ library Maestro.Client.V1.TxManager Maestro.Types.Common - Maestro.Types.V0 - Maestro.Types.V0.Accounts - Maestro.Types.V0.Address - Maestro.Types.V0.Assets - Maestro.Types.V0.Common - Maestro.Types.V0.Datum - Maestro.Types.V0.Epochs - Maestro.Types.V0.General - Maestro.Types.V0.Pool - Maestro.Types.V0.Transactions Maestro.Types.V1 Maestro.Types.V1.Addresses @@ -133,49 +98,3 @@ library hs-source-dirs: src default-language: Haskell2010 - -test-suite maestro-sdk-tests - import: common - default-language: Haskell2010 - type: exitcode-stdio-1.0 - hs-source-dirs: test - main-is: Driver.hs - other-modules: - Maestro.Test.Datum - Maestro.Test.Epochs - Maestro.Test.General - Maestro.Test.Pool - Maestro.Test.Transaction - - build-depends: - base - , maestro-sdk - , aeson - , bytestring - , containers - , raw-strings-qq - , hspec - , tasty - , tasty-hspec - , time - build-tool-depends: - tasty-discover:tasty-discover - -executable maestro-exe - import: common - default-language: Haskell2010 - other-modules: - Maestro.Run.Datum - Maestro.Run.General - Maestro.Run.Pools - Maestro.Run.Scripts - Maestro.Run.Tx - Maestro.Run.Epochs - Maestro.Run.Address - -- other-extensions: - hs-source-dirs: maestro-exe - main-is: Main.hs - build-depends: - base, - maestro-sdk, - text diff --git a/src/Maestro/API/V0.hs b/src/Maestro/API/V0.hs deleted file mode 100644 index 414549f..0000000 --- a/src/Maestro/API/V0.hs +++ /dev/null @@ -1,32 +0,0 @@ -module Maestro.API.V0 where - -import Data.Text (Text) -import Maestro.API.V0.Accounts -import Maestro.API.V0.Address -import Maestro.API.V0.Assets -import Maestro.API.V0.Datum -import Maestro.API.V0.Epochs -import Maestro.API.V0.General -import Maestro.API.V0.Pool -import Maestro.API.V0.Scripts -import Maestro.API.V0.Transaction -import Maestro.API.V0.TxManager -import Servant.API -import Servant.API.Generic - -data MaestroApiV0 route = MaestroApiV0 - { _accounts :: route :- "accounts" :> ToServantApi AccountsAPI - , _address :: route :- "addresses" :> ToServantApi AddressAPI - , _assets :: route :- "assets" :> ToServantApi AssetsAPI - , _general :: route :- ToServantApi GeneralAPI - , _pools :: route :- "pools" :> ToServantApi PoolAPI - , _tx :: route :- ToServantApi TxAPI - , _epochs :: route :- "epochs" :> ToServantApi EpochsAPI - , _datum :: route :- "datum" :> ToServantApi DatumAPI - , _scripts :: route :- "scripts" :> ToServantApi ScriptsAPI - , _txManager :: route :- "txmanager" :> ToServantApi TxManagerAPI - } deriving Generic - -newtype MaestroApiV0Auth route = MaestroApiV0Auth - { _apiV0 :: route :- Header' '[Required] "api-key" Text :> ToServantApi MaestroApiV0 } - deriving Generic diff --git a/src/Maestro/API/V0/Accounts.hs b/src/Maestro/API/V0/Accounts.hs deleted file mode 100644 index fca412d..0000000 --- a/src/Maestro/API/V0/Accounts.hs +++ /dev/null @@ -1,52 +0,0 @@ -module Maestro.API.V0.Accounts where - -import Data.Text (Text) -import Maestro.Client.V0.Core.Pagination -import Maestro.Types.V0 -import Servant.API -import Servant.API.Generic - -data AccountsAPI route = AccountsAPI - { - _account - :: route - :- Capture "stake_addr" Text - :> Get '[JSON] AccountInfo - - , _accountAddresses - :: route - :- Capture "stake_addr" Text - :> "addresses" - :> Pagination - :> Get '[JSON] [Text] - - , _accountAssets - :: route - :- Capture "stake_addr" Text - :> "assets" - :> Pagination - :> Get '[JSON] [Asset] - - , _accountsHistory - :: route - :- Capture "stake_addr" Text - :> "history" - :> QueryParam "epoch_no" EpochNo - :> Pagination - :> Get '[JSON] [AccountHistory] - - , _accountsReward - :: route - :- Capture "stake_addr" Text - :> "rewards" - :> Pagination - :> Get '[JSON] [AccountReward] - - , _accountsUpdates - :: route - :- Capture "stake_addr" Text - :> "updates" - :> Pagination - :> Get '[JSON] [AccountUpdate] - - } deriving (Generic) diff --git a/src/Maestro/API/V0/Address.hs b/src/Maestro/API/V0/Address.hs deleted file mode 100644 index f690007..0000000 --- a/src/Maestro/API/V0/Address.hs +++ /dev/null @@ -1,44 +0,0 @@ -module Maestro.API.V0.Address where - -import Data.Text (Text) -import Maestro.Client.V0.Core.Pagination -import Maestro.Types.V0 -import Servant.API -import Servant.API.Generic - -data AddressAPI route = AddressAPI - { - - _addressesUtxos - :: route - :- "utxos" - :> QueryParam "resolve_datums" Bool - :> QueryParam "with_cbor" Bool - :> Pagination - :> ReqBody '[JSON] [Text] - :> Post '[JSON] [Utxo] - - , _addressUtxo - :: route - :- Capture "address" Text - :> "utxos" - :> QueryParam "resolve_datums" Bool - :> QueryParam "with_cbor" Bool - :> Pagination - :> Get '[JSON] [Utxo] - - , _addressUtxoRefs - :: route - :- Capture "address" Text - :> "utxo_refs" - :> Pagination - :> Get '[JSON] [UtxoRef] - - , _addressTransactionCount - :: route - :- Capture "address" Text - :> "transactions" - :> "count" - :> Get '[JSON] [AddressTxCount] - - } deriving (Generic) diff --git a/src/Maestro/API/V0/Assets.hs b/src/Maestro/API/V0/Assets.hs deleted file mode 100644 index d5ec5d9..0000000 --- a/src/Maestro/API/V0/Assets.hs +++ /dev/null @@ -1,69 +0,0 @@ -module Maestro.API.V0.Assets where - -import Data.Text (Text) -import Maestro.Client.V0.Core.Pagination -import Maestro.Types.V0 -import Servant.API -import Servant.API.Generic - -data AssetsAPI route = AssetsAPI - { _assetPolicyInfo :: - route - :- "policy" - :> Capture "policy" PolicyId - :> Pagination - :> Get '[JSON] [AssetInfo], - _assetPolicyAddress :: - route - :- "policy" - :> Capture "policy" PolicyId - :> "addresses" - :> Pagination - :> Get '[JSON] [Text], - _assetPolicyTxs :: - route - :- "policy" - :> Capture "policy" PolicyId - :> "txs" - :> Pagination - :> Get '[JSON] [AssetTx], - _assetPolicyUtxos :: - route - :- "policy" - :> Capture "policy" PolicyId - :> "utxos" - :> Pagination - :> Get '[JSON] [PolicyUtxo], - _assetDetail :: - route - :- Capture "asset" AssetId - :> Get '[JSON] AssetInfo, - _assetAddresses :: - route - :- Capture "asset" AssetId - :> "addresses" - :> Pagination - :> Get '[JSON] [Text], - _assetTxs :: - route - :- Capture "asset" AssetId - :> "txs" - :> QueryParam "from_height" Integer - :> Pagination - :> QueryParam "order" Order - :> Get '[JSON] [AssetTx], - _assetUpdates :: - route - :- Capture "asset" AssetId - :> "updates" - :> Pagination - :> QueryParam "order" Order - :> Get '[JSON] [MintingTx], - _assetUtxos :: - route - :- Capture "asset" AssetId - :> "utxos" - :> Pagination - :> Get '[JSON] [AssetUtxo] - } - deriving (Generic) diff --git a/src/Maestro/API/V0/Datum.hs b/src/Maestro/API/V0/Datum.hs deleted file mode 100644 index 0a57746..0000000 --- a/src/Maestro/API/V0/Datum.hs +++ /dev/null @@ -1,15 +0,0 @@ -module Maestro.API.V0.Datum where - -import Data.Text (Text) -import Maestro.Types.V0 -import Servant.API -import Servant.API.Generic - -newtype DatumAPI route = - DatumAPI - { - _datumByHash - :: route - :- Capture "datum_hash" Text - :> Get '[JSON] Datum - } deriving Generic diff --git a/src/Maestro/API/V0/Epochs.hs b/src/Maestro/API/V0/Epochs.hs deleted file mode 100644 index 219fc9a..0000000 --- a/src/Maestro/API/V0/Epochs.hs +++ /dev/null @@ -1,19 +0,0 @@ -module Maestro.API.V0.Epochs where - -import Maestro.Types.V0 -import Servant.API -import Servant.API.Generic - -data EpochsAPI route = - EpochsAPI - { - _currentEpochInfo - :: route - :- "current" - :> Get '[JSON] CurrentEpochInfo - , _epochInfo - :: route - :- Capture "epoch_no" EpochNo - :> "info" - :> Get '[JSON] EpochInfo - } deriving (Generic) diff --git a/src/Maestro/API/V0/General.hs b/src/Maestro/API/V0/General.hs deleted file mode 100644 index ccb78c2..0000000 --- a/src/Maestro/API/V0/General.hs +++ /dev/null @@ -1,26 +0,0 @@ -module Maestro.API.V0.General where - -import Maestro.Types.V0 -import Servant.API -import Servant.API.Generic - -data GeneralAPI route = - GeneralAPI - { - _systemStart - :: route - :- "system-start" - :> Get '[JSON] SystemStart - , _eraHistory - :: route - :- "era-history" - :> Get '[JSON] [EraSummary] - , _protocolParams - :: route - :- "protocol-params" - :> Get '[JSON] ProtocolParameters - , _chainTip - :: route - :- "chain-tip" - :> Get '[JSON] ChainTip - } deriving Generic diff --git a/src/Maestro/API/V0/Pool.hs b/src/Maestro/API/V0/Pool.hs deleted file mode 100644 index bee49f1..0000000 --- a/src/Maestro/API/V0/Pool.hs +++ /dev/null @@ -1,56 +0,0 @@ -module Maestro.API.V0.Pool where - -import Maestro.Client.V0.Core.Pagination -import Maestro.Types.V0 -import Servant.API -import Servant.API.Generic - -data PoolAPI route = PoolAPI - { _listPools :: - route - :- Pagination - :> Get '[JSON] [PoolListInfo], - _poolBlocks :: - route - :- Capture "pool_id" (Bech32StringOf PoolId) - :> "blocks" - :> Pagination - :> QueryParam "epoch_no" EpochNo - :> QueryParam "order" Order - :> Get '[JSON] [PoolBlock], - _poolDelegators :: - route - :- Capture "pool_id" (Bech32StringOf PoolId) - :> "delegators" - :> Pagination - :> Get '[JSON] [DelegatorInfo], - _poolHistory :: - route - :- Capture "pool_id" (Bech32StringOf PoolId) - :> "history" - :> Pagination - :> QueryParam "epoch_no" EpochNo - :> QueryParam "order" Order - :> Get '[JSON] [PoolHistory], - _poolInfo :: - route - :- Capture "pool_id" (Bech32StringOf PoolId) - :> "info" - :> Get '[JSON] PoolInfo, - _poolMetadata :: - route - :- Capture "pool_id" (Bech32StringOf PoolId) - :> "metadata" - :> Get '[JSON] PoolMetadata, - _poolRelays :: - route - :- Capture "pool_id" (Bech32StringOf PoolId) - :> "relays" - :> Get '[JSON] [PoolRelay], - _poolUpdates :: - route - :- Capture "pool_id" (Bech32StringOf PoolId) - :> "updates" - :> Get '[JSON] [PoolUpdate] - } - deriving (Generic) diff --git a/src/Maestro/API/V0/Scripts.hs b/src/Maestro/API/V0/Scripts.hs deleted file mode 100644 index 46d1536..0000000 --- a/src/Maestro/API/V0/Scripts.hs +++ /dev/null @@ -1,15 +0,0 @@ -module Maestro.API.V0.Scripts where - -import Data.Text (Text) -import Maestro.Types.V0 -import Servant.API -import Servant.API.Generic - -newtype ScriptsAPI route = - ScriptsAPI - { - _scriptByHash - :: route - :- Capture "script_hash" Text - :> Get '[JSON] Script - } deriving Generic diff --git a/src/Maestro/API/V0/Transaction.hs b/src/Maestro/API/V0/Transaction.hs deleted file mode 100644 index 399f4ae..0000000 --- a/src/Maestro/API/V0/Transaction.hs +++ /dev/null @@ -1,41 +0,0 @@ -module Maestro.API.V0.Transaction where - -import qualified Data.ByteString as BS -import qualified Data.Text as T -import Maestro.Types.V0 -import Servant.API -import Servant.API.Generic - -data TxAPI route = TxAPI - { _submitTx :: - route - :- "submit" - :> "tx" - :> ReqBody' '[Required] '[CBORStream] BS.ByteString - :> PostAccepted '[JSON] T.Text, - _txCborApi :: - route - :- "transactions" - :> Capture "tx_hash" (HashStringOf Tx) - :> "cbor" - :> Get '[JSON] TxCbor, - _txAddressApi :: - route - :- "transactions" - :> Capture "tx_hash" (HashStringOf Tx) - :> "outputs" - :> Capture "index" TxIndex - :> "address" - :> Get '[JSON] UtxoAddress, - _txUtxo :: - route - :- "transactions" - :> Capture "tx_hash" (HashStringOf Tx) - :> "outputs" - :> Capture "index" TxIndex - :> "utxo" - :> QueryParam "resolve_datums" Bool - :> QueryParam "with_cbor" Bool - :> Get '[JSON] Utxo - } - deriving (Generic) diff --git a/src/Maestro/API/V0/TxManager.hs b/src/Maestro/API/V0/TxManager.hs deleted file mode 100644 index 6ca5945..0000000 --- a/src/Maestro/API/V0/TxManager.hs +++ /dev/null @@ -1,15 +0,0 @@ -module Maestro.API.V0.TxManager where - -import qualified Data.ByteString as BS -import qualified Data.Text as T -import Maestro.Types.V0 -import Servant.API -import Servant.API.Generic - -newtype TxManagerAPI route = TxManagerAPI - { _monitorTxSubmit :: - route - :- ReqBody' '[Required] '[CBORStream] BS.ByteString - :> PostAccepted '[JSON] T.Text - } - deriving (Generic) diff --git a/src/Maestro/Client/V0.hs b/src/Maestro/Client/V0.hs deleted file mode 100644 index a5239ca..0000000 --- a/src/Maestro/Client/V0.hs +++ /dev/null @@ -1,30 +0,0 @@ -module Maestro.Client.V0 - ( module Maestro.Client.Env - , module Maestro.Client.Error - , module Maestro.Client.V0.Accounts - , module Maestro.Client.V0.Address - , module Maestro.Client.V0.Assets - , module Maestro.Client.V0.Core - , module Maestro.Client.V0.Datum - , module Maestro.Client.V0.Epochs - , module Maestro.Client.V0.General - , module Maestro.Client.V0.Pools - , module Maestro.Client.V0.Scripts - , module Maestro.Client.V0.Transaction - , module Maestro.Client.V0.TxManager - ) where - - -import Maestro.Client.Env -import Maestro.Client.Error -import Maestro.Client.V0.Accounts -import Maestro.Client.V0.Address -import Maestro.Client.V0.Assets -import Maestro.Client.V0.Core -import Maestro.Client.V0.Datum -import Maestro.Client.V0.Epochs -import Maestro.Client.V0.General -import Maestro.Client.V0.Pools -import Maestro.Client.V0.Scripts -import Maestro.Client.V0.Transaction -import Maestro.Client.V0.TxManager diff --git a/src/Maestro/Client/V0/Accounts.hs b/src/Maestro/Client/V0/Accounts.hs deleted file mode 100644 index bf40793..0000000 --- a/src/Maestro/Client/V0/Accounts.hs +++ /dev/null @@ -1,31 +0,0 @@ -module Maestro.Client.V0.Accounts where - -import Data.Text (Text) -import Maestro.API.V0 -import Maestro.API.V0.Accounts -import Maestro.Client.Env -import Maestro.Client.V0.Core -import Maestro.Types.V0 -import Servant.API.Generic -import Servant.Client - -accountsClient :: MaestroEnv 'V0 -> AccountsAPI (AsClientT IO) -accountsClient = fromServant . _accounts . apiV0Client - -getAccount :: MaestroEnv 'V0 -> Text -> IO AccountInfo -getAccount = _account . accountsClient - -listAccountAddresses :: MaestroEnv 'V0 -> Text -> Page -> IO [Text] -listAccountAddresses = _accountAddresses . accountsClient - -listAccountAssets :: MaestroEnv 'V0 -> Text -> Page -> IO [Asset] -listAccountAssets = _accountAssets . accountsClient - -listAccountHistory :: MaestroEnv 'V0 -> Text -> Maybe EpochNo -> Page -> IO [AccountHistory] -listAccountHistory = _accountsHistory . accountsClient - -listAccountRewards :: MaestroEnv 'V0 -> Text -> Page -> IO [AccountReward] -listAccountRewards = _accountsReward . accountsClient - -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 deleted file mode 100644 index 926d29e..0000000 --- a/src/Maestro/Client/V0/Address.hs +++ /dev/null @@ -1,64 +0,0 @@ -module Maestro.Client.V0.Address where - -import Data.Text (Text) -import Maestro.API.V0 -import Maestro.API.V0.Address -import Maestro.Client.Env -import Maestro.Client.V0.Core -import Maestro.Types.V0 -import Servant.API.Generic -import Servant.Client - -addressClient :: MaestroEnv 'V0 -> AddressAPI (AsClientT IO) -addressClient = fromServant . _address . apiV0Client - --- | --- Returns list of utxos for multiple addresses -utxosAtMultiAddresses :: - -- | The Maestro Environment - 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 - Maybe Bool -> - -- | The pagination attributes - Page -> - -- | List of Address in bech32 format to fetch utxo from - [Text] -> - IO [Utxo] -utxosAtMultiAddresses = _addressesUtxos . addressClient - --- | --- Returns list of utxo for specific address -utxosAtAddress :: - MaestroEnv 'V0 -> - -- | The Address in bech32 format - Text -> - -- | 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 - Maybe Bool -> - -- | The pagination attributes - Page -> - IO [Utxo] -utxosAtAddress = _addressUtxo . addressClient - --- | --- Returns list of utxo ref for address -getRefsAtAddress :: - MaestroEnv 'V0 -> - -- | The Address in bech32 format - Text -> - -- | The pagination attributes - Page -> - IO [UtxoRef] -getRefsAtAddress = _addressUtxoRefs . addressClient - --- | --- Get the transaction count for an address -getTxCountForAddress :: - MaestroEnv 'V0 -> - -- | The Address in bech32 format - Text -> - IO [AddressTxCount] -getTxCountForAddress = _addressTransactionCount . addressClient diff --git a/src/Maestro/Client/V0/Assets.hs b/src/Maestro/Client/V0/Assets.hs deleted file mode 100644 index 44af505..0000000 --- a/src/Maestro/Client/V0/Assets.hs +++ /dev/null @@ -1,123 +0,0 @@ -module Maestro.Client.V0.Assets where - -import Data.Text (Text) -import Maestro.API.V0 (_assets) -import Maestro.API.V0.Assets -import Maestro.Client.Env -import Maestro.Client.V0.Core -import Maestro.Types.V0 -import Servant.API.Generic -import Servant.Client - -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 'V0 -> - -- | The Hex encoded policy ID - PolicyId -> - -- | Pagination - Page -> - IO [AssetInfo] -listAssetInfoByPolicyId = _assetPolicyInfo . assetClient - --- | --- Returns a list of addresses which holding some of an asset of the given policy ID -listAssetAddressByPolicyId :: - -- | The Maestro Environment - MaestroEnv 'V0 -> - -- | The Hex encoded policy ID - PolicyId -> - -- | Pagination - Page -> - IO [Text] -listAssetAddressByPolicyId = _assetPolicyAddress . assetClient - --- | --- Returns list of transactions in which an address receives an asset of the specified policy -listTxByPolicyId :: - -- | The Maestro Environment - MaestroEnv 'V0 -> - -- | The Hex encoded policy ID - PolicyId -> - -- | Pagination - Page -> - IO [AssetTx] -listTxByPolicyId = _assetPolicyTxs . assetClient - --- | --- Returns UTxOs which contain assets of the given policy ID, with the asset names and amounts -listUtxosByPolicyId :: - -- | The Maestro Environment - MaestroEnv 'V0 -> - -- | The Hex encoded policy ID - PolicyId -> - -- | Pagination - Page -> - IO [PolicyUtxo] -listUtxosByPolicyId = _assetPolicyUtxos . assetClient - --- | --- Returns UTxOs which contain assets of the given policy ID, with the asset names and amounts -getAssetDetail :: - -- | The Maestro Environment - MaestroEnv 'V0 -> - -- | Asset, encoded as concatenation of hex of policy ID and asset name - AssetId -> - IO AssetInfo -getAssetDetail = _assetDetail . assetClient - --- | --- Returns a list of addresses which hold some amount of the specified asset -listAssetAddresses :: - -- | The Maestro Environment - MaestroEnv 'V0 -> - -- | Asset, encoded as concatenation of hex of policy ID and asset name - AssetId -> - Page -> - IO [Text] -listAssetAddresses = _assetAddresses . assetClient - --- | --- Returns list of transactions in which an address receives an asset of the specified policy -listAssetTx :: - -- | The Maestro Environment - MaestroEnv 'V0 -> - -- | Asset, encoded as concatenation of hex of policy ID and asset name - AssetId -> - -- | Return only transactions after supplied block height - Maybe Integer -> - -- | The Pagination - Page -> - Maybe Order -> - IO [AssetTx] -listAssetTx = _assetTxs . assetClient - --- | --- Returns list of transactions which minted or burned the specified asset -listAssetUpdates :: - -- | The Maestro Environment - MaestroEnv 'V0 -> - -- | Asset, encoded as concatenation of hex of policy ID and asset name - AssetId -> - -- | The Pagination - Page -> - -- | The order in which the results are sorted (by block height) - Maybe Order -> - IO [MintingTx] -listAssetUpdates = _assetUpdates . assetClient - --- | --- Returns UTxOs containing the specified asset, each paired with the amount of the asset -listAssetUtxos :: - -- | The Maestro Environment - MaestroEnv 'V0 -> - -- | Asset, encoded as concatenation of hex of policy ID and asset name - AssetId -> - -- | The Pagination - Page -> - IO [AssetUtxo] -listAssetUtxos = _assetUtxos . assetClient diff --git a/src/Maestro/Client/V0/Core.hs b/src/Maestro/Client/V0/Core.hs deleted file mode 100644 index 621ca52..0000000 --- a/src/Maestro/Client/V0/Core.hs +++ /dev/null @@ -1,20 +0,0 @@ -module Maestro.Client.V0.Core - ( apiV0Client - , module Maestro.Client.V0.Core.Pagination - ) where - -import Control.Exception (throwIO) -import Maestro.API.V0 -import Maestro.Client.Env -import Maestro.Client.Error (fromServantClientError) -import Maestro.Client.V0.Core.Pagination -import Servant.API.Generic (fromServant) -import Servant.Client -import Servant.Client.Generic - - -apiV0ClientAuth :: MaestroEnv 'V0 -> MaestroApiV0Auth (AsClientT IO) -apiV0ClientAuth MaestroEnv {..} = genericClientHoist $ \x -> runClientM x _maeClientEnv >>= either (throwIO . fromServantClientError) pure - -apiV0Client :: MaestroEnv 'V0 -> MaestroApiV0 (AsClientT IO) -apiV0Client mEnv@MaestroEnv {..} = fromServant $ _apiV0 (apiV0ClientAuth mEnv) _maeToken diff --git a/src/Maestro/Client/V0/Core/Pagination.hs b/src/Maestro/Client/V0/Core/Pagination.hs deleted file mode 100644 index d9a2100..0000000 --- a/src/Maestro/Client/V0/Core/Pagination.hs +++ /dev/null @@ -1,64 +0,0 @@ -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeApplications #-} -{-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeOperators #-} - -module Maestro.Client.V0.Core.Pagination where - -import Data.Default.Class -import Data.Proxy (Proxy (..)) -import Servant.API (QueryParam, (:>)) -import Servant.Client.Core (Client, HasClient, clientWithRoute, - hoistClientMonad) - --- | Pagination parameters -data Page = Page - { resultPerPage :: !Int -- ^ Total result per page - , pageNumber :: !Int -- ^ Page Number - } - --- | maximum number of result -maxPageResult :: Int -maxPageResult = 100 - -instance Default Page where - def = Page maxPageResult 1 - -page :: Int -> Page -page n - | n >= 1 = Page maxPageResult n - | otherwise = error "Page number not in range [1..]" - --- Utility for querying all results from a paged endpoint. -allPages :: (Monad m, Foldable t, Monoid (t a)) => (Page -> m (t a)) -> m (t a) -allPages act = fetch 1 - where - fetch pageNo = do - xs <- act $ Page maxPageResult pageNo - if length xs < maxPageResult then - pure xs - else do - next <- fetch $ pageNo + 1 - pure $ xs <> next -- Note: In case of list, concatenation takes linear time in the number of elements of the first list, thus, `xs` should come before. - -data Pagination - -type PaginationApi api = - QueryParam "count" Int - :> QueryParam "page" Int - :> api - -instance HasClient m api => HasClient m (Pagination :> api) where - type Client m (Pagination :> api) = Page -> Client m api - - clientWithRoute pm _ req Page{..} = - clientWithRoute - pm - (Proxy @(PaginationApi api)) - req - (Just resultPerPage) - (Just pageNumber) - - hoistClientMonad pm _pa hst subClient = hoistClientMonad pm (Proxy @api) hst . subClient diff --git a/src/Maestro/Client/V0/Datum.hs b/src/Maestro/Client/V0/Datum.hs deleted file mode 100644 index 90c002d..0000000 --- a/src/Maestro/Client/V0/Datum.hs +++ /dev/null @@ -1,19 +0,0 @@ -module Maestro.Client.V0.Datum - ( getDatumByHash - ) where - -import Data.Text (Text) -import Maestro.API.V0 (_datum) -import Maestro.API.V0.Datum -import Maestro.Client.Env -import Maestro.Client.V0.Core -import Maestro.Types.V0 -import Servant.API.Generic -import Servant.Client - -datumClient :: MaestroEnv 'V0 -> DatumAPI (AsClientT IO) -datumClient = fromServant . _datum . apiV0Client - --- | Get information about the datum from it's hash. -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 deleted file mode 100644 index 347aaf1..0000000 --- a/src/Maestro/Client/V0/Epochs.hs +++ /dev/null @@ -1,23 +0,0 @@ -module Maestro.Client.V0.Epochs - ( getCurrentEpoch - , getEpochInfo - ) where - -import Maestro.API.V0 (_epochs) -import Maestro.API.V0.Epochs -import Maestro.Client.Env -import Maestro.Client.V0.Core -import Maestro.Types.V0 -import Servant.API.Generic -import Servant.Client - -epochsClient :: MaestroEnv 'V0 -> EpochsAPI (AsClientT IO) -epochsClient = fromServant . _epochs . apiV0Client - --- | Get information about the current epoch. -getCurrentEpoch :: MaestroEnv 'V0 -> IO CurrentEpochInfo -getCurrentEpoch = _currentEpochInfo . epochsClient - --- | Get information about a specific epoch. -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 deleted file mode 100644 index dfb280c..0000000 --- a/src/Maestro/Client/V0/General.hs +++ /dev/null @@ -1,33 +0,0 @@ -module Maestro.Client.V0.General - ( getChainTip - , getSystemStart - , getEraHistory - , getProtocolParameters - ) where - -import Maestro.API.V0 (_general) -import Maestro.API.V0.General -import Maestro.Client.Env -import Maestro.Client.V0.Core -import Maestro.Types.V0 -import Servant.API.Generic -import Servant.Client - -generalClient :: MaestroEnv 'V0 -> GeneralAPI (AsClientT IO) -generalClient = fromServant . _general . apiV0Client - --- | Get details about the latest block of the network. -getChainTip :: MaestroEnv 'V0 -> IO ChainTip -getChainTip = _chainTip . generalClient - --- | Get network start time since genesis. -getSystemStart :: MaestroEnv 'V0 -> IO SystemStart -getSystemStart = _systemStart . generalClient - --- | Get network era history. -getEraHistory :: MaestroEnv 'V0 -> IO [EraSummary] -getEraHistory = _eraHistory . generalClient - --- | Get protocol parameters for the latest epoch. -getProtocolParameters :: MaestroEnv 'V0 -> IO ProtocolParameters -getProtocolParameters = _protocolParams . generalClient diff --git a/src/Maestro/Client/V0/Pagination.hs b/src/Maestro/Client/V0/Pagination.hs deleted file mode 100644 index 2a572a1..0000000 --- a/src/Maestro/Client/V0/Pagination.hs +++ /dev/null @@ -1,64 +0,0 @@ -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeApplications #-} -{-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeOperators #-} - -module Maestro.Client.V0.Pagination where - -import Data.Default.Class -import Data.Proxy (Proxy (..)) -import Servant.API (QueryParam, (:>)) -import Servant.Client.Core (Client, HasClient, clientWithRoute, - hoistClientMonad) - --- | Pagination parameters -data Page = Page - { resultPerPage :: !Int -- ^ Total result per page - , pageNumber :: !Int -- ^ Page Number - } - --- | maximum number of result -maxPageResult :: Int -maxPageResult = 100 - -instance Default Page where - def = Page maxPageResult 1 - -page :: Int -> Page -page n - | n >= 1 = Page maxPageResult n - | otherwise = error "Page number not in range [1..]" - --- Utility for querying all results from a paged endpoint. -allPages :: (Monad m, Foldable t, Monoid (t a)) => (Page -> m (t a)) -> m (t a) -allPages act = fetch 1 - where - fetch pageNo = do - xs <- act $ Page maxPageResult pageNo - if length xs < maxPageResult then - pure xs - else do - next <- fetch $ pageNo + 1 - pure $ xs <> next -- Note: In case of list, concatenation takes linear time in the number of elements of the first list, thus, `xs` should come before. - -data Pagination - -type PaginationApi api = - QueryParam "count" Int - :> QueryParam "page" Int - :> api - -instance HasClient m api => HasClient m (Pagination :> api) where - type Client m (Pagination :> api) = Page -> Client m api - - clientWithRoute pm _ req Page{..} = - clientWithRoute - pm - (Proxy @(PaginationApi api)) - req - (Just resultPerPage) - (Just pageNumber) - - hoistClientMonad pm _pa hst subClient = hoistClientMonad pm (Proxy @api) hst . subClient diff --git a/src/Maestro/Client/V0/Pools.hs b/src/Maestro/Client/V0/Pools.hs deleted file mode 100644 index 355a139..0000000 --- a/src/Maestro/Client/V0/Pools.hs +++ /dev/null @@ -1,55 +0,0 @@ -module Maestro.Client.V0.Pools - ( listPools, - poolBlocks, - poolDelegators, - poolHistory, - poolMetadata, - poolRelays, - poolInfo, - poolUpdates, - ) -where - -import Maestro.API.V0 -import Maestro.API.V0.Pool -import Maestro.Client.Env -import Maestro.Client.V0.Core -import Maestro.Types.V0 -import Servant.API.Generic -import Servant.Client - -poolsClient :: MaestroEnv 'V0 -> PoolAPI (AsClientT IO) -poolsClient = fromServant . _pools . apiV0Client - --- | Returns a list of currently registered stake pools -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 'V0 -> Bech32StringOf PoolId -> Page -> Maybe EpochNo -> Maybe Order -> IO [PoolBlock] -poolBlocks = _poolBlocks . poolsClient - -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 'V0 -> Bech32StringOf PoolId -> Page -> Maybe EpochNo -> Maybe Order -> IO [PoolHistory] -poolHistory = _poolHistory . poolsClient - --- | Returns current information about the specified pool -poolInfo :: MaestroEnv 'V0 -> Bech32StringOf PoolId -> IO PoolInfo -poolInfo = _poolInfo . poolsClient - --- | Returns the metadata declared by a specific pool -poolMetadata :: MaestroEnv 'V0 -> Bech32StringOf PoolId -> IO PoolMetadata -poolMetadata = _poolMetadata . poolsClient - --- | Returns a list of relays declared by the specified pool -poolRelays :: MaestroEnv 'V0 -> Bech32StringOf PoolId -> IO [PoolRelay] -poolRelays = _poolRelays . poolsClient - --- | Returns a list of updates relating to the specified pool -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 deleted file mode 100644 index c7455a4..0000000 --- a/src/Maestro/Client/V0/Scripts.hs +++ /dev/null @@ -1,19 +0,0 @@ -module Maestro.Client.V0.Scripts - ( getScriptByHash - ) where - -import Data.Text (Text) -import Maestro.API.V0 (_scripts) -import Maestro.API.V0.Scripts -import Maestro.Client.Env -import Maestro.Client.V0.Core -import Maestro.Types.V0 -import Servant.API.Generic -import Servant.Client - -scriptsClient :: MaestroEnv 'V0 -> ScriptsAPI (AsClientT IO) -scriptsClient = fromServant . _scripts . apiV0Client - --- | Get information about the script from it's hash. -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 deleted file mode 100644 index 02b5329..0000000 --- a/src/Maestro/Client/V0/Transaction.hs +++ /dev/null @@ -1,70 +0,0 @@ -module Maestro.Client.V0.Transaction - ( submitTx, - txCbor, - txAddress, - txUtxo, - ) -where - -import qualified Data.ByteString as BS -import Data.Text (Text) -import Maestro.API.V0 (_tx) -import Maestro.API.V0.Transaction -import Maestro.Client.Env -import Maestro.Client.V0.Core -import Maestro.Types.V0 -import Servant.API.Generic -import Servant.Client - -txClient :: MaestroEnv 'V0 -> TxAPI (AsClientT IO) -txClient = fromServant . _tx . apiV0Client - --- | --- Submit a signed and serialized transaction to the network. --- Interaction with this endpoint is identical to IOG's Cardano Submit API and will not be monitored by Maestro. -submitTx :: - -- | The Maestro Environment - MaestroEnv 'V0 -> - -- | CBOR encoded Transaction - BS.ByteString -> - IO Text -submitTx = _submitTx . txClient - --- | --- Returns hex-encoded CBOR bytes of a transaction -txCbor :: - -- | The Maestro Environment - MaestroEnv 'V0 -> - -- | Hex Encoded Transaction Hash - HashStringOf Tx -> - -- | hex-encoded CBOR bytes of a transaction - IO TxCbor -txCbor = _txCborApi . txClient - --- | --- Returns the address specified in the given transaction output -txAddress :: - -- | The Maestro Environment - MaestroEnv 'V0 -> - -- | Hex Encoded Transaction Hash - HashStringOf Tx -> - -- | The Transaction Output Index - TxIndex -> - IO UtxoAddress -txAddress = _txAddressApi . txClient - --- | --- Returns the specified transaction output of a transaction output reference -txUtxo :: - -- | The Maestro Environment. - MaestroEnv 'V0 -> - -- | Hex encoded transaction hash - HashStringOf Tx -> - -- | The Transaction Output Index - TxIndex -> - -- | Try find and include the corresponding datums for datum hashes - Maybe Bool -> - -- | Include the CBOR encodings of the transaction outputs in the response - Maybe Bool -> - IO Utxo -txUtxo = _txUtxo . txClient diff --git a/src/Maestro/Client/V0/TxManager.hs b/src/Maestro/Client/V0/TxManager.hs deleted file mode 100644 index 171ab5b..0000000 --- a/src/Maestro/Client/V0/TxManager.hs +++ /dev/null @@ -1,27 +0,0 @@ -module Maestro.Client.V0.TxManager - ( submitAndMonitorTx - ) -where - -import qualified Data.ByteString as BS -import Data.Text (Text) -import Maestro.API.V0 (_txManager) -import Maestro.API.V0.TxManager -import Maestro.Client.Env -import Maestro.Client.V0.Core -import Servant.API.Generic -import Servant.Client - -txClient :: MaestroEnv 'V0 -> TxManagerAPI (AsClientT IO) -txClient = fromServant . _txManager . apiV0Client - --- | --- Submit a signed and serialized transaction to the network. --- A transaction submited with this endpoint will be monitored by Maestro. -submitAndMonitorTx :: - -- | The Maestro Environment - MaestroEnv 'V0 -> - -- | CBOR encoded Transaction - BS.ByteString -> - IO Text -submitAndMonitorTx = _monitorTxSubmit . txClient diff --git a/src/Maestro/Types/V0.hs b/src/Maestro/Types/V0.hs deleted file mode 100644 index 26a45a5..0000000 --- a/src/Maestro/Types/V0.hs +++ /dev/null @@ -1,23 +0,0 @@ --- | Maestro types - -module Maestro.Types.V0 - ( module Maestro.Types.V0.Accounts - , module Maestro.Types.V0.Address - , module Maestro.Types.V0.Assets - , module Maestro.Types.V0.Datum - , module Maestro.Types.V0.Epochs - , module Maestro.Types.V0.Common - , module Maestro.Types.V0.General - , module Maestro.Types.V0.Pool - , module Maestro.Types.V0.Transactions - ) where - -import Maestro.Types.V0.Accounts -import Maestro.Types.V0.Address -import Maestro.Types.V0.Assets -import Maestro.Types.V0.Common -import Maestro.Types.V0.Datum -import Maestro.Types.V0.Epochs -import Maestro.Types.V0.General -import Maestro.Types.V0.Pool -import Maestro.Types.V0.Transactions diff --git a/src/Maestro/Types/V0/Accounts.hs b/src/Maestro/Types/V0/Accounts.hs deleted file mode 100644 index 757955d..0000000 --- a/src/Maestro/Types/V0/Accounts.hs +++ /dev/null @@ -1,63 +0,0 @@ -module Maestro.Types.V0.Accounts - ( AccountInfo (..) - , AccountHistory (..) - , AccountReward (..) - , AccountUpdate (..) - ) where - -import Data.Text (Text) -import Deriving.Aeson -import Maestro.Types.V0.Common (EpochNo, LowerFirst, SlotNo) - --- | Information about an account -data AccountInfo = AccountInfo - { _accountInfoDelegatedPool :: !(Maybe Text) - , _accountInfoRegistered :: !Bool - , _accountInfoRewardsAvailable :: !Integer - , _accountInfoStakeAddress :: !Text - , _accountInfoTotalBalance :: !Integer - , _accountInfoTotalRewarded :: !Integer - , _accountInfoTotalWithdrawn :: !Integer - , _accountInfoUtxoBalance :: !Integer - } - deriving stock (Show, Eq, Generic) - deriving (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_accountInfo", CamelToSnake]] AccountInfo - - --- | Information about an Account Assets -data AccountHistory = AccountHistory - { _accountHistoryActiveStake :: !Integer - , _accountHistoryEpochNo :: !EpochNo - , _accountHistoryPoolId :: !(Maybe Text) - } - deriving stock (Show, Eq, Generic) - deriving (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_accountHistory", CamelToSnake]] AccountHistory - --- | Information about an Account Assets -data AccountReward = AccountReward - { _accountRewardAmount :: !Integer - , _accountRewardEarnedEpoch :: !EpochNo - , _accountRewardPoolId :: !Text - , _accountRewardSpendableEpoch :: !EpochNo - , _accountRewardType :: !Text - } - deriving stock (Show, Eq, Generic) - deriving (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_accountReward", CamelToSnake]] AccountReward - -data AccountAction = Registration | Deregistration | Delegation | Withdrawal - deriving stock (Show, Eq, Generic) - deriving (FromJSON, ToJSON) via CustomJSON '[ConstructorTagModifier '[LowerFirst]] AccountAction - --- | Information about an Account Assets -data AccountUpdate = AccountUpdate - { _accountUpdateAbsSlot :: !SlotNo - , _accountUpdateAction :: !AccountAction - , _accountUpdateEpoch :: !EpochNo - , _accountUpdateTxHash :: !Text - } - deriving stock (Show, Eq, Generic) - deriving (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_accountUpdate", CamelToSnake]] AccountUpdate diff --git a/src/Maestro/Types/V0/Address.hs b/src/Maestro/Types/V0/Address.hs deleted file mode 100644 index 7958dc5..0000000 --- a/src/Maestro/Types/V0/Address.hs +++ /dev/null @@ -1,20 +0,0 @@ -module Maestro.Types.V0.Address where - -import Data.Text (Text) -import Deriving.Aeson -import GHC.Natural (Natural) - -newtype AddressTxCount = AddressTxCount - { _addressTxCount :: Int - } - deriving stock (Show, Eq, Generic) - deriving (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_addressTx", CamelToSnake]] AddressTxCount - -data UtxoRef = UtxoRef - { _utxoRefIndex :: !Natural - , _utxoRefTxHash :: !Text - } - deriving stock (Show, Eq, Generic) - deriving (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_utxoRef", CamelToSnake]] UtxoRef diff --git a/src/Maestro/Types/V0/Assets.hs b/src/Maestro/Types/V0/Assets.hs deleted file mode 100644 index 0dd2871..0000000 --- a/src/Maestro/Types/V0/Assets.hs +++ /dev/null @@ -1,95 +0,0 @@ -module Maestro.Types.V0.Assets where - -import qualified Data.Aeson as Aeson -import Data.Text (Text) -import Data.Time.Clock.POSIX (POSIXTime) -import Deriving.Aeson -import GHC.Natural (Natural) -import Maestro.Types.V0.Common (BlockHeight, EpochNo, LowerFirst) - -data TokenRegistryMetadata = TokenRegistryMetadata - { _tokenRegMetDecimals :: !Integer - , _tokenRegMetDescription :: !Text - , _tokenRegMetLogo :: !Text - , _tokenRegMetName :: !Text - , _tokenRegMetTicker :: !Text - , _tokenRegMetUrl :: !Text - } - deriving stock (Show, Eq, Generic) - deriving (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_tokenRegMet", CamelToSnake]] TokenRegistryMetadata - - -data AssetStandards = AssetStandards - { _assetStandardsCip25Metadata :: !(Maybe Aeson.Value) - , _assetStandardsCip68Metadata :: !(Maybe Aeson.Value) - } - deriving stock (Show, Eq, Generic) - deriving (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_assetStandards", CamelToSnake]] AssetStandards - - -data AssetInfo = AssetInfo - { _assetInfoAssetName :: !Text - , _assetInfoAssetNameAscii :: !(Maybe Text) - , _assetInfoAssetStandards :: !AssetStandards - , _assetInfoBurnTxCount :: !Integer - , _assetInfoFingerprint :: !Text - , _assetInfoFirstMintTime :: !POSIXTime - , _assetInfoFirstMintTx :: !Text - , _assetInfoLatestMintTxMetadata :: !(Maybe Aeson.Value) - , _assetInfoMintTxCount :: !Natural - , _assetInfoTokenRegistryMetadata :: !(Maybe TokenRegistryMetadata) - , _assetInfoTotalSupply :: !Integer - } - deriving stock (Show, Eq, Generic) - deriving (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_assetInfo", CamelToSnake]] AssetInfo - -data AssetTx = AssetTx - { _assetTxBlockHeight :: !BlockHeight - , _assetTxEpochNo :: !EpochNo - , _assetTxTxHash :: !Text - } - deriving stock (Show, Eq, Generic) - deriving (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_assetTx", CamelToSnake]] AssetTx - -data AssetUtxo = AssetUtxo - { _assetUtxoAddress :: !Text - , _assetUtxoAmount :: !Integer - , _assetUtxoIndex :: !Natural - , _assetUtxoTxHash :: !Text - } - deriving stock (Show, Eq, Generic) - deriving (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_assetUtxo", CamelToSnake]] AssetUtxo - -data AssetInPolicy = AssetInPolicy - { _assetInPolicyName :: !Text - , _assetInPolicyQuantity :: !Integer - } - deriving stock (Show, Eq, Generic) - deriving - (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_assetInPolicy", LowerFirst]] AssetInPolicy - -data PolicyUtxo = PolicyUtxo - { _policyUtxoAddress :: !Text - , _policyUtxoAssets :: ![AssetInPolicy] - , _policyUtxoIndex :: !Natural - , _policyUtxoTxHash :: !Text - } - deriving stock (Show, Eq, Generic) - deriving (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_policyUtxo", CamelToSnake]] PolicyUtxo - -data MintingTx = MintingTx - { _mintingTxBlockTimestamp :: !POSIXTime - , _mintingTxMetadata :: !(Maybe Aeson.Value) - , _mintingTxMintAmount :: !Integer - , _mintingTxTxHash :: !Text - } - deriving stock (Show, Eq, Generic) - deriving (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_mintingTx", CamelToSnake]] MintingTx diff --git a/src/Maestro/Types/V0/Common.hs b/src/Maestro/Types/V0/Common.hs deleted file mode 100644 index 950b965..0000000 --- a/src/Maestro/Types/V0/Common.hs +++ /dev/null @@ -1,43 +0,0 @@ -module Maestro.Types.V0.Common - ( AssetId (..), - Asset (..), - Utxo (..), - module Maestro.Types.Common - ) -where - -import Data.Text (Text) -import Deriving.Aeson -import GHC.Natural (Natural) -import Maestro.Types.Common -import Servant.API (FromHttpApiData, ToHttpApiData) - --- | Concatenation of hex encoded policy ID and hex encoded asset name. -newtype AssetId = AssetId Text - deriving stock (Eq, Ord, Show, Generic) - deriving newtype (FromHttpApiData, ToHttpApiData, FromJSON, ToJSON) - --- | Representation of asset in an UTxO. -data Asset = Asset - { _assetQuantity :: !Integer - , _assetUnit :: !Text - } - deriving stock (Show, Eq, Ord, Generic) - deriving - (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_asset", CamelToSnake]] Asset - --- | Transaction output. -data Utxo = Utxo - { _utxoAddress :: !(Bech32StringOf Address), - _utxoAssets :: ![Asset], - _utxoDatum :: !(Maybe DatumOption), - _utxoIndex :: !Natural, - _utxoReferenceScript :: !(Maybe Script), - _utxoTxHash :: !Text, - _utxoTxoutCbor :: !(Maybe (HexStringOf TxOutCbor)) - } - deriving stock (Show, Eq, Ord, Generic) - deriving - (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_utxo", CamelToSnake]] Utxo diff --git a/src/Maestro/Types/V0/Datum.hs b/src/Maestro/Types/V0/Datum.hs deleted file mode 100644 index 79dbc8c..0000000 --- a/src/Maestro/Types/V0/Datum.hs +++ /dev/null @@ -1,20 +0,0 @@ --- | Module to define types for /\"Datum\"/ endpoints defined at [reference.gomaestro.org](https://reference.gomaestro.org/). - -module Maestro.Types.V0.Datum - ( Datum (..) - ) where - -import Data.Aeson (Value) -import Data.Text (Text) -import Deriving.Aeson -import Maestro.Types.V0.Common (LowerFirst) - --- | Details of datum when queried by it's hash. -data Datum = Datum - { _datumBytes :: !Text - -- ^ Hex encoded datum CBOR bytes. - , _datumJson :: !Value - -- ^ JSON representation of the datum. - } - deriving stock (Eq, Show, Generic) - deriving (FromJSON, ToJSON) via CustomJSON '[FieldLabelModifier '[StripPrefix "_datum", LowerFirst]] Datum diff --git a/src/Maestro/Types/V0/Epochs.hs b/src/Maestro/Types/V0/Epochs.hs deleted file mode 100644 index 35b79f2..0000000 --- a/src/Maestro/Types/V0/Epochs.hs +++ /dev/null @@ -1,61 +0,0 @@ -module Maestro.Types.V0.Epochs ( EpochInfoFees (..), CurrentEpochInfo (..), EpochInfo (..) ) where - -import Data.Aeson (FromJSON (parseJSON), toEncoding, - toJSON, withText) -import Data.Text (unpack) -import Data.Time.Clock.POSIX (POSIXTime) -import Data.Word (Word64) -import Deriving.Aeson -import Maestro.Types.V0.Common -import Numeric.Natural (Natural) -import Text.Read (readMaybe) - --- | Sum of all the fees within the epoch in lovelaces. -newtype EpochInfoFees = EpochInfoFees Natural - deriving newtype (Eq, Ord, Show, Num, Enum, Real, Integral) - -instance ToJSON EpochInfoFees where - toEncoding = toEncoding . show - toJSON = toJSON . show - -instance FromJSON EpochInfoFees where - parseJSON = withText "EpochInfoFees" $ \txt -> either fail pure $ textToNatural $ unpack txt - where - textToNatural :: String -> Either String EpochInfoFees - textToNatural txt = case readMaybe txt :: Maybe Natural of - Just n -> Right $ EpochInfoFees n - Nothing -> Left "Given epoch fees is not a natural number" - --- | Current epoch information. -data CurrentEpochInfo = CurrentEpochInfo - { -- | Current epoch number. - _currentEpochInfoEpochNo :: !EpochNo - , -- | Sum of all the fees within the epoch in lovelaces. - _currentEpochInfoFees :: !EpochInfoFees - , -- | Number of transactions within the epoch. - _currentEpochInfoTxCount :: !Word64 - , -- | Number of blocks within the epoch. - _currentEpochInfoBlkCount :: !Word64 - , -- | Start time of the epoch in UNIX time. - _currentEpochInfoStartTime :: !POSIXTime - } - deriving stock (Show, Eq, Generic) - deriving (FromJSON, ToJSON) via CustomJSON '[FieldLabelModifier '[StripPrefix "_currentEpochInfo", CamelToSnake]] CurrentEpochInfo - --- | Epoch information. -data EpochInfo = EpochInfo - { -- | Epoch number. - _epochInfoEpochNo :: !EpochNo - , -- | Sum of all the fees within the epoch in lovelaces. - _epochInfoFees :: !EpochInfoFees - , -- | Number of transactions within the epoch. - _epochInfoTxCount :: !Word64 - , -- | Number of blocks within the epoch. - _epochInfoBlkCount :: !Word64 - , -- | Start time of the epoch in UNIX time. - _epochInfoStartTime :: !POSIXTime - , -- | End time of the epoch in UNIX time. - _epochInfoEndTime :: !POSIXTime - } - deriving stock (Show, Eq, Generic) - deriving (FromJSON, ToJSON) via CustomJSON '[FieldLabelModifier '[StripPrefix "_epochInfo", CamelToSnake]] EpochInfo diff --git a/src/Maestro/Types/V0/General.hs b/src/Maestro/Types/V0/General.hs deleted file mode 100644 index bb8f33d..0000000 --- a/src/Maestro/Types/V0/General.hs +++ /dev/null @@ -1,224 +0,0 @@ --- | Module to define types for /\"General\"/ endpoints defined at [reference.gomaestro.org](https://reference.gomaestro.org/). - -module Maestro.Types.V0.General - ( -- * Types for @/system-start@ endpoint - SystemStart (..) - -- * Types for @/era-history@ endpoint - , EraSummary (..) - , EraParameters (..) - , EraBound (..) - -- * Types for @/protocol-params@ endpoint - , ProtocolVersion (..) - , MemoryStepsWith (..) - , CostModel (..) - , CostModels (..) - , MaestroRational (..) - , textToMaestroRational - , textFromMaestroRational - , ProtocolParameters (..) - -- * Types for @/chain-tip@ endpoint - , ChainTip (..) - ) where - -import Control.Monad (unless, when) -import Data.Aeson (FromJSON (parseJSON), toEncoding, - toJSON, withText) -import Data.Map.Strict (Map) -import Data.Ratio (denominator, numerator, (%)) -import Data.Text (Text) -import qualified Data.Text as Txt -import qualified Data.Text.Read as TxtRead -import Data.Time (LocalTime, NominalDiffTime) -import Data.Word (Word64) -import Deriving.Aeson -import Maestro.Types.V0.Common (BlockHash, EpochNo, EpochSize, - LowerFirst, SlotNo) -import Numeric.Natural (Natural) - ------------------------------------------------------------------- --- Types for @/system-start@ endpoint. ------------------------------------------------------------------- - --- | Network start time since genesis. -newtype SystemStart = SystemStart { _systemStartTime :: LocalTime } - deriving stock (Eq, Ord, Show, Generic) - deriving (FromJSON, ToJSON) via CustomJSON '[FieldLabelModifier '[StripPrefix "_systemStart", CamelToSnake]] SystemStart - ------------------------------------------------------------------- --- Types for @/era-history@ endpoint ------------------------------------------------------------------- - --- | Network era summary. -data EraSummary = EraSummary - { _eraSummaryStart :: !EraBound - -- ^ Start of this era. - , _eraSummaryEnd :: !(Maybe EraBound) - -- ^ End of this era. - , _eraSummaryParameters :: !EraParameters - -- ^ Parameters of this era. - } - deriving stock (Eq, Show, Generic) - deriving (FromJSON, ToJSON) via CustomJSON '[FieldLabelModifier '[StripPrefix "_eraSummary", LowerFirst]] EraSummary - --- | Parameters for a network era which can vary between hardforks. -data EraParameters = EraParameters - { _eraParametersEpochLength :: !EpochSize - -- ^ Number of slots in an epoch. - , _eraParametersSlotLength :: !NominalDiffTime - -- ^ How long a slot lasts. - , _eraParametersSafeZone :: !Word64 - -- ^ Number of slots from the tip of the ledger in which a hardfork will not happen. - } - deriving stock (Eq, Show, Generic) - deriving (FromJSON, ToJSON) via CustomJSON '[FieldLabelModifier '[StripPrefix "_eraParameters", CamelToSnake]] EraParameters - --- | Bounds of an era. -data EraBound = EraBound - { _eraBoundEpoch :: !EpochNo - -- ^ Epoch number bounding this era. - , _eraBoundSlot :: !SlotNo - -- ^ Absolute slot number bounding this era. - , _eraBoundTime :: !NominalDiffTime - -- ^ Time relative to the start time of the network. - } - deriving stock (Eq, Show, Generic) - deriving (FromJSON, ToJSON) via CustomJSON '[FieldLabelModifier '[StripPrefix "_eraBound", LowerFirst]] EraBound - ------------------------------------------------------------------- --- Types for @/protocol-params@ endpoint. ------------------------------------------------------------------- - --- | Current accepted protocol version. An increase in the major version indicates a hard fork, and the minor version a soft fork (meaning old software can validate but not produce new blocks). -data ProtocolVersion = ProtocolVersion - { _protocolVersionMajor :: !Natural - -- ^ Accepted protocol major version. - , _protocolVersionMinor :: !Natural - -- ^ Accepted protocol minor version. - } - deriving stock (Eq, Show, Generic) - deriving (FromJSON, ToJSON) via CustomJSON '[FieldLabelModifier '[StripPrefix "_protocolVersion", LowerFirst]] ProtocolVersion - --- | Pair of memory & steps for the given type. -data MemoryStepsWith i = MemoryStepsWith - { _memoryStepsWithMemory :: !i - , _memoryStepsWithSteps :: !i - } - deriving stock (Eq, Show, Generic) - deriving (FromJSON, ToJSON) via CustomJSON '[FieldLabelModifier '[StripPrefix "_memoryStepsWith", LowerFirst]] (MemoryStepsWith i) - --- | A cost model is a vector of coefficients that are used to compute the execution units required to execute a script. Its specifics depend on specific versions of the Plutus interpreter it is used with. -newtype CostModel = CostModel (Map Text Integer) - deriving (Eq, Show) - deriving newtype (ToJSON, FromJSON) - --- | Cost models (see `CostModel`) for script languages that use them. -data CostModels = CostModels - { _costModelsPlutusV1 :: !CostModel - , _costModelsPlutusV2 :: !CostModel - } - deriving stock (Eq, Show, Generic) - deriving (FromJSON, ToJSON) via CustomJSON '[FieldLabelModifier '[StripPrefix "_costModels", Rename "PlutusV1" "plutus:v1", Rename "PlutusV2" "plutus:v2"]] CostModels - --- | Maestro's represents rational numbers as string with numerator and denominator demarcated by \'\/\', example: @"1/3"@. -newtype MaestroRational = MaestroRational { unMaestroRational :: Rational } - deriving stock Eq - -instance Show MaestroRational where - show (MaestroRational r) = show (numerator r) ++ '/' : show (denominator r) - --- | Get original `Text` from `MaestroRational`. -textFromMaestroRational :: MaestroRational -> Text -textFromMaestroRational = Txt.pack . show . unMaestroRational - --- | Parses given `Text` to `MaestroRational`. -textToMaestroRational :: Text -> Either String MaestroRational -textToMaestroRational ratTxt = - case TxtRead.signed rationalReader ratTxt of - Right (rat, remainingTxt) -> if Txt.null remainingTxt - then pure $ MaestroRational rat - else Left "Expected full string to be parsed" - Left e -> Left e - where - rationalReader :: TxtRead.Reader Rational - rationalReader ratTxt' = do - (numr, remaining) <- TxtRead.decimal ratTxt' - (nextChar, denmrTxt) <- maybe - (Left "Unexpected end of string after parsing numerator") - pure - $ Txt.uncons remaining - unless (nextChar == '/') - . Left - $ "Expected numerator to be immediately followed by '/', but it was followed by: " ++ show nextChar - (denmr, finalRemaining) <- TxtRead.decimal denmrTxt - when (denmr == 0) - $ Left "Expected non-zero denominator" - pure (numr % denmr, finalRemaining) - -instance ToJSON MaestroRational where - toEncoding = toEncoding . textFromMaestroRational - toJSON = toJSON . textFromMaestroRational - -instance FromJSON MaestroRational where - parseJSON = withText "MaestroRational" $ \ratTxt -> either fail pure $ textToMaestroRational ratTxt - --- | Protocol parameters for the latest epoch. -data ProtocolParameters = ProtocolParameters - { _protocolParametersProtocolVersion :: !ProtocolVersion - -- ^ See `ProtocolVersion`. - , _protocolParametersMinFeeConstant :: !Natural - -- ^ The linear factor for the minimum fee calculation for given epoch /AKA/ @min_fee_b@ and @tx_fee_fixed@. - , _protocolParametersMinFeeCoefficient :: !Natural - -- ^ The constant factor for the minimum fee calculation /AKA/ @min_fee_a@ and @tx_fee_per_byte@. - , _protocolParametersMaxBlockBodySize :: !Natural - -- ^ Maximum block body size. - , _protocolParametersMaxBlockHeaderSize :: !Natural - -- ^ Maximum block header size. - , _protocolParametersMaxTxSize :: !Natural - -- ^ Maximum transaction size. - , _protocolParametersStakeKeyDeposit :: !Natural - -- The deposit required to register a stake address. - , _protocolParametersPoolDeposit :: !Natural - -- ^ The amount of a pool registration deposit in lovelaces /AKA/ @stake_pool_deposit@. - , _protocolParametersPoolRetirementEpochBound :: !EpochNo - -- ^ The maximum number of epochs into the future that stake pools are permitted to schedule a retirement /AKA/ @pool_retire_max_epoch@, @e_max@. - , _protocolParametersDesiredNumberOfPools :: !Natural - -- The equilibrium target number of stake pools. This is the \"k\" incentives parameter from the design document, /AKA/ @n_opt@, @stake_pool_target@. - , _protocolParametersPoolInfluence :: !MaestroRational - -- The influence of the pledge in stake pool rewards. This is the \"a_0\" incentives parameter from the design document. - , _protocolParametersMonetaryExpansion :: !MaestroRational - -- ^ The monetary expansion rate. This determines the fraction of the reserves that are added to the fee pot each epoch. This is the \"rho\" incentives parameter from the design document. - , _protocolParametersTreasuryExpansion :: !MaestroRational - -- ^ The fraction of the fee pot each epoch that goes to the treasury. This is the \"tau\" incentives parameter from the design document, /AKA/ @treasury_cut@. - , _protocolParametersMinPoolCost :: !Natural - -- ^ The minimum value that stake pools are permitted to declare for their cost parameter. - , _protocolParametersPrices :: !(MemoryStepsWith MaestroRational) - -- ^ The price per unit memory & price per reduction step corresponding to abstract notions of the relative memory usage and script execution steps respectively. - , _protocolParametersMaxExecutionUnitsPerTransaction :: !(MemoryStepsWith Natural) - -- ^ The maximum number of execution memory & steps allowed to be used in a single transaction. - , _protocolParametersMaxExecutionUnitsPerBlock :: !(MemoryStepsWith Natural) - -- ^ The maximum number of execution memory & steps allowed to be used in a single block. - , _protocolParametersMaxValueSize :: !Natural - -- ^ Maximum size of the /value/ part of an output in a serialized transaction. - , _protocolParametersCollateralPercentage :: !Natural - -- ^ The percentage of the transactions fee which must be provided as collateral when including non-native scripts. - , _protocolParametersMaxCollateralInputs :: !Natural - -- ^ The maximum number of collateral inputs allowed in a transaction. - , _protocolParametersCoinsPerUtxoByte :: !Natural - -- ^ The cost per UTxO size. Cost per UTxO /word/ for Alozno. Cost per UTxO /byte/ for Babbage and later. - , _protocolParametersCostModels :: !CostModels - -- ^ See `CostModels`. - } - deriving stock (Eq, Show, Generic) - deriving (FromJSON, ToJSON) via CustomJSON '[FieldLabelModifier '[StripPrefix "_protocolParameters", CamelToSnake]] ProtocolParameters - --- | Details about the latest block of the network. -data ChainTip = ChainTip - { _chainTipBlockHash :: !BlockHash - -- ^ Hash of the latest block. - , _chainTipSlot :: !SlotNo - -- ^ Slot number for the tip. - , _chainTipHeight :: !Word64 - -- ^ Block number to denote height of the tip. - } - deriving stock (Eq, Show, Generic) - deriving (FromJSON, ToJSON) via CustomJSON '[FieldLabelModifier '[StripPrefix "_chainTip", CamelToSnake]] ChainTip diff --git a/src/Maestro/Types/V0/Pool.hs b/src/Maestro/Types/V0/Pool.hs deleted file mode 100644 index 87f9d08..0000000 --- a/src/Maestro/Types/V0/Pool.hs +++ /dev/null @@ -1,262 +0,0 @@ -module Maestro.Types.V0.Pool - ( ActiveStake (..), - DelegatorInfo (..), - PoolListInfo (..), - PoolBlock (..), - PoolHistory (..), - PoolInfo (..), - PoolMetadata (..), - PoolMetaJson (..), - PoolRelay (..), - Relay (..), - PoolUpdate (..), - PoolId, - ) -where - -import Data.Text (Text) -import Data.Time.Clock.POSIX (POSIXTime) -import Deriving.Aeson -import GHC.Natural (Natural) -import Maestro.Types.V0.Common - -data PoolId - -data Reward - -data Stake - -data VrfKey - -data PoolMeta - -data PoolUpdateTx - -data PoolListInfo = PoolListInfo - { _poolListInfoPoolIdBech32 :: !(Bech32StringOf PoolId), - _poolListInfoTicker :: !(Maybe Text) - } - deriving stock (Show, Eq, Generic) - deriving - (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_poolListInfo", CamelToSnake]] PoolListInfo - -data PoolBlock = PoolBlock - { -- | Absolute slot of the block - _poolBlkAbsSlot :: !(Maybe AbsoluteSlot), - -- | The Block Hash - _poolBlkBlockHash :: !BlockHash, - -- | The Block Height i.e Block Number - _poolBlkBlockHeight :: !BlockHeight, - -- | UNIX timestamp when the block was mined - _poolBlkBlockTime :: !POSIXTime, - -- | Epoch number - _poolBlkEpochNo :: !(Maybe EpochNo), - -- | Epoch Slot - _poolBlkEpochSlot :: !(Maybe EpochSize) - } - deriving stock (Show, Eq, Generic) - deriving - (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_poolBlk", CamelToSnake]] PoolBlock - --- | Information summary of a delegator -data DelegatorInfo = DelegatorInfo - { -- | Epoch at which the delegation becomes active - _delegatorActiveEpochNo :: !(Maybe EpochNo), - -- | Delegator live stake - _delegatorAmount :: !(Maybe Natural), - -- | Transaction hash relating to the most recent delegation - _delegatorLatestDelegationTxHash :: !(Maybe TxHash), - -- | Bech32 encoded stake address (reward address) - _delegatorStakeAddress :: !(Maybe (Bech32StringOf Stake)) - } - deriving stock (Show, Eq, Generic) - deriving - (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_delegator", CamelToSnake]] DelegatorInfo - -newtype ActiveStake = ActiveStake {unActiveStake :: Natural} - deriving stock (Show, Eq, Ord, Generic) - deriving newtype (Num, Enum, Real, Integral, FromJSON, ToJSON) - --- | Per-epoch history of a stake pool -data PoolHistory = PoolHistory - { -- | Active stake in the epoch - _poolHstActiveStake :: !(Maybe ActiveStake), - -- | Pool active stake as percentage of total active stake - _poolHstActiveStakePct :: !(Maybe Text), - -- | Blocks created in the epoch - _poolHstBlockCnt :: !(Maybe Natural), - -- | Total rewards earned by pool delegators for the epoch - _poolHstDelegRewards :: !Natural, - -- | Total Delegators in the epoch - _poolHstDelegatorCnt :: !(Maybe Natural), - -- | The Epoch number - _poolHstEpochNo :: !EpochNo, - -- | Annual return percentage for delegators for the epoch - _poolHstEpochRos :: !Text, - -- | Pool fixed cost - _poolHstFixedCost :: !Natural, - -- | Pool margin - _poolHstMargin :: !(Maybe Double), - -- | Fees collected for the epoch - _poolHstPoolFees :: !Natural, - -- | Pool saturation percent - _poolHstSaturationPct :: !(Maybe Text) - } - deriving stock (Show, Eq, Generic) - deriving - (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_poolHst", CamelToSnake]] PoolHistory - -data Relay = Relay - { _relayDns :: !(Maybe Text), - _relayIpv4 :: !(Maybe Text), - _relayIpv6 :: !(Maybe Text), - _relayPort :: !(Maybe Int), - _relaySrv :: !(Maybe Text) - } - deriving stock (Show, Eq, Generic) - deriving - (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_relay", CamelToSnake]] Relay - --- | JSON metadata associated with a stake pool -data PoolMetaJson = PoolMetaJson - { -- | Pool description - _poolMetaJsonDescription :: !(Maybe Text), - -- | Pool home page URL - _poolMetaJsonHomepage :: !(Maybe Text), - -- | Pool name - _poolMetaJsonName :: !Text, - -- | Pool ticker symbol - _poolMetaJsonTicker :: !(Maybe Text) - } - deriving stock (Show, Eq, Generic) - deriving - (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_poolMetaJson", CamelToSnake]] PoolMetaJson - --- | Metadata associated with a stake pool -data PoolMetadata = PoolMetadata - { -- | Hash of the pool metadata - _poolMetadataMetaHash :: !(Maybe Text), - -- | JSON metadata associated with a stake pool - _poolMetadataMetaJson :: !(Maybe PoolMetaJson), - -- | URL pointing to the pool metadata - _poolMetadataMetaUrl :: !(Maybe Text), - -- | Bech32 encoded pool ID - _poolMetadataPoolIdBech32 :: !(Bech32StringOf PoolId) - } - deriving stock (Show, Eq, Generic) - deriving - (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_poolMetadata", CamelToSnake]] PoolMetadata - -data PoolInfo = PoolInfo - { -- | Epoch when the update takes effect - _poolInfActiveEpochNo :: !EpochNo, - -- | Active stake - _poolInfActiveStake :: !(Maybe Natural), - -- | Number of blocks created - _poolInfBlockCount :: !(Maybe Natural), - -- | Pool fixed cost - _poolInfFixedCost :: !Natural, - -- | Number of current delegators - _poolInfLiveDelegators :: !Natural, - -- | Account balance of pool owners - _poolInfLivePledge :: !(Maybe Natural), - -- | Live saturation - _poolInfLiveSaturation :: !(Maybe Text), - -- | Live stake - _poolInfLiveStake :: !(Maybe Integer), - -- | Pool margin - _poolInfMargin :: !Double, - -- | Hash of the pool metadata - _poolInfMetaHash :: !(Maybe Text), - -- | JSON metadata associated with a stake pool - _poolInfMetaJson :: !(Maybe PoolMetaJson), - -- | URL pointing to the pool metadata - _poolInfMetaUrl :: !(Maybe Text), - -- | Pool operational certificate - _poolInfOpCert :: !(Maybe Text), - -- | Operational certificate counter - _poolInfOpCertCounter :: !(Maybe Integer), - -- | List of stake keys which control the pool - _poolInfOwners :: ![Text], - -- | Pool pledge - _poolInfPledge :: !Integer, - -- | Bech32 encoded pool ID - _poolInfPoolIdBech32 :: !(Bech32StringOf PoolId), - -- | Hex encoded pool ID - _poolInfPoolIdHex :: !(HexStringOf PoolId), - -- | Status of the pool - _poolInfPoolStatus :: !(Maybe Text), - -- | Stake pool relay - _poolInfRelays :: ![Relay], - -- | Epoch at which the pool will be retired - _poolInfRetiringEpoch :: !(Maybe EpochNo), - -- | Reward address associated with the pool - _poolInfRewardAddr :: !(Maybe (Bech32StringOf PoolId)), - -- | Pool stake share - _poolInfSigma :: !(Maybe Text), - -- | VRF key hash - _poolInfVrfKeyHash :: !(HashStringOf VrfKey) - } - deriving stock (Show, Eq, Generic) - deriving - (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_poolInf", CamelToSnake]] PoolInfo - --- | Relay declared by a stake pool -data PoolRelay = PoolRelay - { _poolRelPoolIdBech32 :: !(Bech32StringOf PoolId), - _poolRelRelays :: ![Relay] - } - deriving stock (Show, Eq, Generic) - deriving - (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_poolRel", CamelToSnake]] PoolRelay - --- | Update to a stake pool -data PoolUpdate = PoolUpdate - { -- | Epoch when the update takes effect - _poolUpdateActiveEpochNo :: !EpochNo, - -- | UNIX timestamp of the block containing the transaction - _poolUpdateBlockTime :: !(Maybe POSIXTime), - -- | Pool fixed cost - _poolUpdateFixedCost :: !Natural, - -- | Pool margin - _poolUpdateMargin :: !Double, - -- | Hash of the pool metadata - _poolUpdateMetaHash :: !(Maybe (HashStringOf PoolMeta)), - -- | JSON metadata associated with a stake pool - _poolUpdateMetaJson :: !(Maybe PoolMetaJson), - -- | URL pointing to the pool metadata - _poolUpdateMetaUrl :: !(Maybe Text), - -- | List of stake keys which control the pool - _poolUpdateOwners :: ![Text], - -- | Pool pledge - _poolUpdatePledge :: !Integer, - -- | Bech32 encoded pool ID - _poolUpdatePoolIdBech32 :: !(Bech32StringOf PoolId), - -- | Hex encoded pool ID - _poolUpdatePoolIdHex :: !(HexStringOf PoolId), - -- | Status of the pool - _poolUpdatePoolStatus :: !(Maybe Text), - -- | Stake pool relay - _poolUpdateRelays :: ![Relay], - -- | Epoch at which the pool will be retired - _poolUpdateRetiringEpoch :: !(Maybe Text), - -- | Reward address associated with the pool - _poolUpdateRewardAddr :: !(Maybe (Bech32StringOf Reward)), - -- | Transaction hash for the transaction which contained the update - _poolUpdateTxHash :: !(HashStringOf PoolUpdateTx), - -- | VRF key hash - _poolUpdateVrfKeyHash :: !(HashStringOf VrfKey) - } - deriving stock (Show, Eq, Generic) - deriving - (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_poolUpdate", CamelToSnake]] PoolUpdate diff --git a/src/Maestro/Types/V0/Transactions.hs b/src/Maestro/Types/V0/Transactions.hs deleted file mode 100644 index dd98e18..0000000 --- a/src/Maestro/Types/V0/Transactions.hs +++ /dev/null @@ -1,22 +0,0 @@ -module Maestro.Types.V0.Transactions - ( TxCbor (..), - UtxoAddress (..), - ) -where - -import Data.Text (Text) -import Deriving.Aeson -import Maestro.Types.Common (LowerFirst) - -newtype TxCbor = TxCbor { _txCbor :: Text } - deriving stock (Show, Eq, Generic) - deriving - (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_tx", LowerFirst]] TxCbor - -newtype UtxoAddress = UtxoAddress { _utxoAddressAddress :: Text } - deriving stock (Show, Eq, Generic) - deriving - (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_utxoAddress", LowerFirst]] UtxoAddress - diff --git a/test/Driver.hs b/test/Driver.hs deleted file mode 100644 index 70c55f5..0000000 --- a/test/Driver.hs +++ /dev/null @@ -1 +0,0 @@ -{-# OPTIONS_GHC -F -pgmF tasty-discover #-} diff --git a/test/Maestro/Test/Datum.hs b/test/Maestro/Test/Datum.hs deleted file mode 100644 index 3199480..0000000 --- a/test/Maestro/Test/Datum.hs +++ /dev/null @@ -1,33 +0,0 @@ -module Maestro.Test.Datum where - -import Data.Aeson (eitherDecode, object, (.=)) -import Test.Hspec -import Text.RawString.QQ - -import Data.ByteString.Lazy (ByteString) -import Maestro.Types.V0 - -spec_general :: Spec -spec_general = do - - it "parsing /datum/{datum_hash} sample" $ do - eitherDecode datumByHashSample - `shouldBe` - Right datumByHashExpected - - -datumByHashSample :: ByteString -datumByHashSample = [r| -{ - "bytes": "1a00278530", - "json": { - "int": 2590000 - } -} -|] - -datumByHashExpected :: Datum -datumByHashExpected = Datum - { _datumBytes = "1a00278530" - , _datumJson = object ["int" .= (2590000 :: Int)] - } diff --git a/test/Maestro/Test/Epochs.hs b/test/Maestro/Test/Epochs.hs deleted file mode 100644 index ba80cbb..0000000 --- a/test/Maestro/Test/Epochs.hs +++ /dev/null @@ -1,67 +0,0 @@ -module Maestro.Test.Epochs where - -import Data.Aeson (eitherDecode) -import Test.Hspec -import Text.RawString.QQ - -import Data.ByteString.Lazy (ByteString) -import Maestro.Types.V0 - -spec_general :: Spec -spec_general = do - - it "parsing /epochs/current sample" $ do - eitherDecode currentEpochSample - `shouldBe` - Right currentEpochExpected - - it "parsing /epochs/{epoch_no}/info sample" $ do - eitherDecode epochInfoSample - `shouldBe` - Right epochInfoExpected - - -currentEpochSample :: ByteString -currentEpochSample = [r| -{ - "epoch_no": 413, - "fees": "47553352844", - "tx_count": 127481, - "blk_count": 6488, - "start_time": 1684619256 -} -|] - -currentEpochExpected :: CurrentEpochInfo -currentEpochExpected = CurrentEpochInfo - { _currentEpochInfoBlkCount = 6488 - , _currentEpochInfoEpochNo = 413 - , _currentEpochInfoFees = EpochInfoFees 47553352844 - , _currentEpochInfoStartTime = 1684619256 - , _currentEpochInfoTxCount = 127481 - } - -epochInfoSample :: ByteString -epochInfoSample = [r| -{ - "epoch_no": 36, - "fees": "8308727733", - "tx_count": 18799, - "blk_count": 21052, - "start_time": 1669593614, - "end_time": 1670025570 -} -|] - -epochInfoExpected :: EpochInfo -epochInfoExpected = EpochInfo - { _epochInfoEpochNo = 36 - , _epochInfoFees = EpochInfoFees 8308727733 - , _epochInfoTxCount = 18799 - , _epochInfoBlkCount = 21052 - , _epochInfoStartTime = 1669593614 - , _epochInfoEndTime = 1670025570 - } - - - diff --git a/test/Maestro/Test/General.hs b/test/Maestro/Test/General.hs deleted file mode 100644 index ee17d07..0000000 --- a/test/Maestro/Test/General.hs +++ /dev/null @@ -1,187 +0,0 @@ -module Maestro.Test.General where - -import Data.Aeson (eitherDecode) -import qualified Data.Map.Strict as Map -import Data.Ratio ((%)) -import Data.Time (LocalTime (..), midnight) -import Test.Hspec -import Text.RawString.QQ - -import Data.ByteString.Lazy (ByteString) -import Data.Time.Calendar.OrdinalDate (fromOrdinalDate) -import Maestro.Types.V0 - -spec_general :: Spec -spec_general = do - it "parsing /chain-tip sample" $ do - eitherDecode chainTipSample - `shouldBe` - Right chainTipExpected - - it "parsing /system-start sample" $ do - eitherDecode systemStartSample - `shouldBe` - Right systemStartExpected - - it "parsing /era-history sample" $ do - eitherDecode eraHistorySample - `shouldBe` - Right eraHistoryExpected - - it "parsing /protocol-params sample" $ do - eitherDecode protocolParamsSample - `shouldBe` - Right protocolParamsExpected - -chainTipSample :: ByteString -chainTipSample = [r| -{ - "block_hash": "2de4cd25f0a18228ce6451950793c54f6c556a53a5625c7fe80721f77c8b5fa8", - "slot": 84899112, - "height": 8402752 -} -|] - -chainTipExpected :: ChainTip -chainTipExpected = ChainTip - { _chainTipBlockHash = BlockHash "2de4cd25f0a18228ce6451950793c54f6c556a53a5625c7fe80721f77c8b5fa8" - , _chainTipSlot = 84899112 - , _chainTipHeight = 8402752 - } - -systemStartSample :: ByteString -systemStartSample = [r| -{ - "time": "2022-06-01 00:00:00" -} -|] - -systemStartExpected :: SystemStart -systemStartExpected = SystemStart $ LocalTime (fromOrdinalDate 2022 152) midnight - -eraHistorySample :: ByteString -eraHistorySample = [r| -[ - { - "end": { - "epoch": 1, - "slot": 2, - "time": 3 - }, - "parameters": { - "epoch_length": 30, - "safe_zone": 40, - "slot_length": 50 - }, - "start": { - "epoch": 1, - "slot": 2, - "time": 3 - } - } -] -|] - -eraHistoryExpected :: [EraSummary] -eraHistoryExpected = - [ EraSummary - eraBoundSample - (Just eraBoundSample) - eraParametersSample - ] - where - eraBoundSample = - EraBound - { _eraBoundEpoch = 1 - , _eraBoundSlot = 2 - , _eraBoundTime = 3 - } - eraParametersSample = - EraParameters - { _eraParametersEpochLength = 30 - , _eraParametersSafeZone = 40 - , _eraParametersSlotLength = 50 - } - -protocolParamsSample :: ByteString -protocolParamsSample = [r| -{ - "coins_per_utxo_byte": 31, - "collateral_percentage": 29, - "cost_models": { - "plutus:v1": { - "A": 0, - "B": 1, - "C": 2 - }, - "plutus:v2": { - "D": 3, - "E": 4, - "F": 5 - } - }, - "desired_number_of_pools": 23, - "max_block_body_size": 11, - "max_block_header_size": 13, - "max_collateral_inputs": 3, - "max_execution_units_per_block": { - "memory": 3, - "steps": 4 - }, - "max_execution_units_per_transaction": { - "memory": 1, - "steps": 2 - }, - "max_tx_size": 15, - "max_value_size": 27, - "min_fee_coefficient": 9, - "min_fee_constant": 7, - "min_pool_cost": 25, - "monetary_expansion": "7/5", - "pool_deposit": 19, - "pool_influence": "5/3", - "pool_retirement_epoch_bound": 21, - "prices": { - "memory": "5/3", - "steps": "7/5" - }, - "protocol_version": { - "major": 1, - "minor": 2 - }, - "stake_key_deposit": 17, - "treasury_expansion": "9/7" -} -|] - -protocolParamsExpected :: ProtocolParameters -protocolParamsExpected = ProtocolParameters - { _protocolParametersProtocolVersion = ProtocolVersion 1 2 - , _protocolParametersMinFeeConstant = 7 - , _protocolParametersMinFeeCoefficient = 9 - , _protocolParametersMaxBlockBodySize = 11 - , _protocolParametersMaxBlockHeaderSize = 13 - , _protocolParametersMaxTxSize = 15 - , _protocolParametersStakeKeyDeposit = 17 - , _protocolParametersPoolDeposit = 19 - , _protocolParametersPoolRetirementEpochBound = 21 - , _protocolParametersDesiredNumberOfPools = 23 - , _protocolParametersPoolInfluence = maestroRationalSample - , _protocolParametersMonetaryExpansion = maestroRationalSample' - , _protocolParametersTreasuryExpansion = MaestroRational $ 9 % 7 - , _protocolParametersMinPoolCost = 25 - , _protocolParametersPrices = MemoryStepsWith maestroRationalSample maestroRationalSample' - , _protocolParametersMaxExecutionUnitsPerTransaction = MemoryStepsWith 1 2 - , _protocolParametersMaxExecutionUnitsPerBlock = MemoryStepsWith 3 4 - , _protocolParametersMaxValueSize = 27 - , _protocolParametersCollateralPercentage = 29 - , _protocolParametersMaxCollateralInputs = 3 - , _protocolParametersCoinsPerUtxoByte = 31 - , _protocolParametersCostModels = CostModels - { _costModelsPlutusV1 = CostModel $ Map.fromList [("A", 0), ("B", 1), ("C", 2)] - , _costModelsPlutusV2 = CostModel $ Map.fromList [("D", 3), ("E", 4), ("F", 5)] - } - } - where - maestroRationalSample = MaestroRational $ 5 % 3 - maestroRationalSample' = MaestroRational $ 7 % 5 diff --git a/test/Maestro/Test/Pool.hs b/test/Maestro/Test/Pool.hs deleted file mode 100644 index ba89dcc..0000000 --- a/test/Maestro/Test/Pool.hs +++ /dev/null @@ -1,451 +0,0 @@ -{-# LANGUAGE QuasiQuotes #-} -module Maestro.Test.Pool where - -import Data.Aeson (eitherDecode) -import Test.Hspec -import Text.RawString.QQ - -import Data.ByteString.Lazy (ByteString) -import Maestro.Types.V0 - -spec_pool :: Spec -spec_pool = do - it "parsing /pools sample" $ do - eitherDecode poolsSample - `shouldBe` - Right poolsExpected - - it "parsing /pools/pool_id/blocks sample" $ do - eitherDecode poolBlocksSample - `shouldBe` - Right poolBlockExpected - - it "parsing /pools/pool_id/delegators sample" $ do - eitherDecode poolDelegatorSample - `shouldBe` - Right poolDelegatorExpected - - it "parsing /pools/pool_id/history sample" $ do - eitherDecode poolHistorySample - `shouldBe` - Right poolHistoryExpected - - it "parsing /pools/pool_id/info sample" $ do - eitherDecode poolInfoSample - `shouldBe` - Right poolInfoExpected - - it "parsing /pools/pool_id/metadata sample" $ do - eitherDecode poolMetadataSample - `shouldBe` - Right poolMetadataExpected - - it "parsing /pools/pool_id/relays sample" $ do - eitherDecode poolRelaySample - `shouldBe` - Right poolRelayExpected - - it "parsing /pools/pool_id/updates sample" $ do - eitherDecode poolUpdatesSample - `shouldBe` - Right poolUpdatesExpected - -poolsSample :: ByteString -poolsSample = [r| - [ - { - "pool_id_bech32": "pool12584mjtgz3fhgpx823qht56gycnfnezg6aqqthazv4qdxkd5c46", - "ticker": "DOLCA" - }, - { - "pool_id_bech32": "pool125kh7e0y9lwya4sz5etmsk7hvga9jtfpuhw00vz9zvk6sh8xh5r", - "ticker": "CHOCO" - } - ] -|] - -poolsExpected :: [PoolListInfo] -poolsExpected = - [ - PoolListInfo { - _poolListInfoPoolIdBech32 = "pool12584mjtgz3fhgpx823qht56gycnfnezg6aqqthazv4qdxkd5c46", - _poolListInfoTicker = Just "DOLCA" - }, - - PoolListInfo { - _poolListInfoPoolIdBech32 = "pool125kh7e0y9lwya4sz5etmsk7hvga9jtfpuhw00vz9zvk6sh8xh5r", - _poolListInfoTicker = Just "CHOCO" - } - - ] - -poolBlocksSample :: ByteString -poolBlocksSample = [r| - [ - { - "epoch_no": 331, - "epoch_slot": 247198, - "abs_slot": 57875998, - "block_height": 7099157, - "block_hash": "25c48307d94b1d6b98c50482a0a36c6d104c66a5186ce73eac7e9fe4e34a1e4b", - "block_time": 1649442289 - }, - { - "epoch_no": 331, - "epoch_slot": 271486, - "abs_slot": 57900286, - "block_height": 7100338, - "block_hash": "b00aaff6fd95e9718748ef16a6f1787af95970bf8da072c1031f569783001997", - "block_time": 1649466577 - } - ] -|] - -poolBlockExpected :: [PoolBlock] -poolBlockExpected = - [ - PoolBlock - { _poolBlkEpochNo = Just $ EpochNo 331 - , _poolBlkEpochSlot = Just $ EpochSize 247198 - , _poolBlkAbsSlot = Just $ AbsoluteSlot 57875998 - , _poolBlkBlockHeight = BlockHeight 7099157 - , _poolBlkBlockHash = BlockHash "25c48307d94b1d6b98c50482a0a36c6d104c66a5186ce73eac7e9fe4e34a1e4b" - , _poolBlkBlockTime = 1649442289 - } - , PoolBlock - { _poolBlkEpochNo = Just $ EpochNo 331 - , _poolBlkEpochSlot = Just $ EpochSize 271486 - , _poolBlkAbsSlot = Just $ AbsoluteSlot 57900286 - , _poolBlkBlockHeight = BlockHeight 7100338 - , _poolBlkBlockHash = BlockHash "b00aaff6fd95e9718748ef16a6f1787af95970bf8da072c1031f569783001997" - , _poolBlkBlockTime = 1649466577 - } - ] - -poolDelegatorSample :: ByteString -poolDelegatorSample = [r| - [ - { - "stake_address": "stake1uyxylkzz6qcmu823tpfvq2kv4v0eejrh6w3qcfl2t3ax4acmdtchp", - "amount": 104694974790, - "active_epoch_no": 288, - "latest_delegation_tx_hash": "7feeb8988ac7ae488dacf189dd6cb2f52173692dfb45603942fbe8b7a6ccd40b" - }, - { - "stake_address": "stake1uyztgnymq9pktsjw7ae9csea4xueymap54gg252wyvsgv8cxscnaz", - "amount": 4128157247, - "active_epoch_no": 293, - "latest_delegation_tx_hash": "e8d1e0a2c9e1d9a33b79db3d4e997a2e797ade35d81ed993936bba409e7c9a1f" - } - ] -|] - -poolDelegatorExpected :: [DelegatorInfo] -poolDelegatorExpected = - [ - DelegatorInfo - { _delegatorStakeAddress = Just "stake1uyxylkzz6qcmu823tpfvq2kv4v0eejrh6w3qcfl2t3ax4acmdtchp" - , _delegatorAmount = Just 104694974790 - , _delegatorActiveEpochNo = Just $ EpochNo 288 - , _delegatorLatestDelegationTxHash = Just "7feeb8988ac7ae488dacf189dd6cb2f52173692dfb45603942fbe8b7a6ccd40b" - } - ,DelegatorInfo - { _delegatorStakeAddress = Just "stake1uyztgnymq9pktsjw7ae9csea4xueymap54gg252wyvsgv8cxscnaz" - , _delegatorAmount = Just 4128157247 - , _delegatorActiveEpochNo = Just $ EpochNo 293 - , _delegatorLatestDelegationTxHash = Just "e8d1e0a2c9e1d9a33b79db3d4e997a2e797ade35d81ed993936bba409e7c9a1f" - } - ] - -poolHistorySample :: ByteString -poolHistorySample = - [r| - [ - { - "epoch_no": 384, - "active_stake": 3850078783520, - "active_stake_pct": "0.01517945984844733700", - "saturation_pct": "5.4500", - "block_cnt": 0, - "delegator_cnt": 23, - "margin": 0, - "fixed_cost": 340000000, - "pool_fees": 0, - "deleg_rewards": 0, - "epoch_ros": "0" - }, - { - "epoch_no": 385, - "active_stake": 3851856595953, - "active_stake_pct": "0.01517156647812579800", - "saturation_pct": "5.4500", - "block_cnt": 3, - "delegator_cnt": 23, - "margin": 0, - "fixed_cost": 340000000, - "pool_fees": 340000000, - "deleg_rewards": 1447424779, - "epoch_ros": "2.78058595" - } - ] - |] - -poolHistoryExpected :: [PoolHistory] -poolHistoryExpected = - [ - PoolHistory - { _poolHstEpochNo = EpochNo 384 - , _poolHstActiveStake = Just $ ActiveStake 3850078783520 - , _poolHstActiveStakePct = Just "0.01517945984844733700" - , _poolHstSaturationPct = Just "5.4500" - , _poolHstBlockCnt = Just 0 - , _poolHstDelegatorCnt = Just 23 - , _poolHstMargin = Just 0 - , _poolHstFixedCost = 340000000 - , _poolHstPoolFees = 0 - , _poolHstDelegRewards = 0 - , _poolHstEpochRos = "0" - } - , PoolHistory - { _poolHstEpochNo = EpochNo 385 - , _poolHstActiveStake = Just $ ActiveStake 3851856595953 - , _poolHstActiveStakePct = Just "0.01517156647812579800" - , _poolHstSaturationPct = Just "5.4500" - , _poolHstBlockCnt = Just 3 - , _poolHstDelegatorCnt = Just 23 - , _poolHstMargin = Just 0 - , _poolHstFixedCost = 340000000 - , _poolHstPoolFees = 340000000 - , _poolHstDelegRewards = 1447424779 - , _poolHstEpochRos = "2.78058595" - } - ] - -poolInfoSample :: ByteString -poolInfoSample = [r| - { - "pool_id_bech32": "pool125kh7e0y9lwya4sz5etmsk7hvga9jtfpuhw00vz9zvk6sh8xh5r", - "pool_id_hex": "552d7f65e42fdc4ed602a657b85bd7623a592d21e5dcf7b045132da8", - "active_epoch_no": 290, - "vrf_key_hash": "076102096f5fc37a47ff14390f7320c76ea769183d06881d53dc4ea1be51acae", - "margin": 0, - "fixed_cost": 340000000, - "pledge": 10000000000, - "reward_addr": "stake1uxtdm5q9j89mmme0l6jt9rsap8cn3vjy3eflptx34s2645ge7r9gp", - "owners": [ - "stake1uxtdm5q9j89mmme0l6jt9rsap8cn3vjy3eflptx34s2645ge7r9gp" - ], - "relays": [ - { - "dns": null, - "srv": null, - "ipv4": "202.182.106.104", - "ipv6": null, - "port": 6000 - } - ], - "meta_url": "https://git.io/J0eoF", - "meta_hash": "63c1b74c5489659d8ec374fa9f22f3e185c5ac458ecc69fdc324ba3bbe2c5093", - "meta_json": { - "name": "CHOCO Stake Pool", - "ticker": "CHOCO", - "homepage": "https://twitter.com/choco_stake", - "description": "Choco pool description" - }, - "pool_status": "registered", - "retiring_epoch": null, - "op_cert": "cdac991e5a547c86fe869b37eb58c77cc3804d2e592200c835da0b3dbfe8e763", - "op_cert_counter": 7, - "active_stake": 3847126072870, - "sigma": "0.00015093541821247124", - "block_count": 307, - "live_pledge": 38784976226, - "live_stake": 3848841013319, - "live_delegators": 24, - "live_saturation": "5.4200" - } -|] - -poolInfoExpected :: PoolInfo -poolInfoExpected = - PoolInfo - { _poolInfPoolIdBech32 = "pool125kh7e0y9lwya4sz5etmsk7hvga9jtfpuhw00vz9zvk6sh8xh5r" - , _poolInfPoolIdHex = "552d7f65e42fdc4ed602a657b85bd7623a592d21e5dcf7b045132da8" - , _poolInfActiveEpochNo = EpochNo 290 - , _poolInfVrfKeyHash = "076102096f5fc37a47ff14390f7320c76ea769183d06881d53dc4ea1be51acae" - , _poolInfMargin = 0 - , _poolInfFixedCost = 340000000 - , _poolInfPledge = 10000000000 - , _poolInfRewardAddr = Just "stake1uxtdm5q9j89mmme0l6jt9rsap8cn3vjy3eflptx34s2645ge7r9gp" - , _poolInfOwners = - [ - "stake1uxtdm5q9j89mmme0l6jt9rsap8cn3vjy3eflptx34s2645ge7r9gp" - ] - , _poolInfRelays = - [ - Relay - { _relayDns = Nothing - , _relaySrv = Nothing - , _relayIpv4 = Just "202.182.106.104" - , _relayIpv6 = Nothing - , _relayPort = Just 6000 - } - ] - , _poolInfMetaUrl = Just "https://git.io/J0eoF" - , _poolInfMetaHash = Just "63c1b74c5489659d8ec374fa9f22f3e185c5ac458ecc69fdc324ba3bbe2c5093" - , _poolInfMetaJson = - Just $ PoolMetaJson - { _poolMetaJsonName = "CHOCO Stake Pool" - , _poolMetaJsonTicker = Just "CHOCO" - , _poolMetaJsonHomepage = Just "https://twitter.com/choco_stake" - , _poolMetaJsonDescription = Just "Choco pool description" - } - , _poolInfPoolStatus = Just "registered" - , _poolInfRetiringEpoch = Nothing - , _poolInfOpCert = Just "cdac991e5a547c86fe869b37eb58c77cc3804d2e592200c835da0b3dbfe8e763" - , _poolInfOpCertCounter = Just 7 - , _poolInfActiveStake = Just 3847126072870 - , _poolInfSigma = Just "0.00015093541821247124" - , _poolInfBlockCount = Just 307 - , _poolInfLivePledge = Just 38784976226 - , _poolInfLiveStake = Just 3848841013319 - , _poolInfLiveDelegators = 24 - , _poolInfLiveSaturation = Just "5.4200" - } - - -poolMetadataSample :: ByteString -poolMetadataSample = [r| - { - "pool_id_bech32": "pool125kh7e0y9lwya4sz5etmsk7hvga9jtfpuhw00vz9zvk6sh8xh5r", - "meta_url": "https://git.io/J0eoF", - "meta_hash": "63c1b74c5489659d8ec374fa9f22f3e185c5ac458ecc69fdc324ba3bbe2c5093", - "meta_json": { - "name": "CHOCO Stake Pool", - "ticker": "CHOCO", - "homepage": "https://twitter.com/choco_stake", - "description": "Choco pool description" - } - } -|] - -poolMetadataExpected :: PoolMetadata -poolMetadataExpected = - PoolMetadata - { _poolMetadataPoolIdBech32 = "pool125kh7e0y9lwya4sz5etmsk7hvga9jtfpuhw00vz9zvk6sh8xh5r" - , _poolMetadataMetaUrl = Just "https://git.io/J0eoF" - , _poolMetadataMetaHash = Just "63c1b74c5489659d8ec374fa9f22f3e185c5ac458ecc69fdc324ba3bbe2c5093" - , _poolMetadataMetaJson = - Just $ PoolMetaJson - { _poolMetaJsonName = "CHOCO Stake Pool" - , _poolMetaJsonTicker = Just "CHOCO" - , _poolMetaJsonHomepage = Just "https://twitter.com/choco_stake" - , _poolMetaJsonDescription = Just "Choco pool description" - } - } - - -poolRelaySample :: ByteString -poolRelaySample = [r| - [ - { - "pool_id_bech32": "pool125kh7e0y9lwya4sz5etmsk7hvga9jtfpuhw00vz9zvk6sh8xh5r", - "relays": [ - { - "dns": null, - "srv": null, - "ipv4": "202.182.106.104", - "ipv6": null, - "port": 6000 - } - ] - } - ] -|] - -poolRelayExpected :: [PoolRelay] -poolRelayExpected = - [ - PoolRelay - { _poolRelPoolIdBech32 = "pool125kh7e0y9lwya4sz5etmsk7hvga9jtfpuhw00vz9zvk6sh8xh5r" - , _poolRelRelays = - [ - Relay - { _relayDns = Nothing - , _relaySrv = Nothing - , _relayIpv4 = Just "202.182.106.104" - , _relayIpv6 = Nothing - , _relayPort = Just 6000 - } - ] - } - ] - - -poolUpdatesSample :: ByteString -poolUpdatesSample = [r| - [ - { - "tx_hash": "58011f2d795af54ab076320d5092a7989efd451eb39c5c64794c7b5eccd9da97", - "block_time": 1629034536, - "pool_id_bech32": "pool125kh7e0y9lwya4sz5etmsk7hvga9jtfpuhw00vz9zvk6sh8xh5r", - "pool_id_hex": "552d7f65e42fdc4ed602a657b85bd7623a592d21e5dcf7b045132da8", - "active_epoch_no": 286, - "vrf_key_hash": "076102096f5fc37a47ff14390f7320c76ea769183d06881d53dc4ea1be51acae", - "margin": 0, - "fixed_cost": 340000000, - "pledge": 10000000000, - "reward_addr": "stake1uxtdm5q9j89mmme0l6jt9rsap8cn3vjy3eflptx34s2645ge7r9gp", - "owners": [ - "stake1uxtdm5q9j89mmme0l6jt9rsap8cn3vjy3eflptx34s2645ge7r9gp" - ], - "relays": [ - { - "dns": null, - "srv": null, - "ipv4": "139.180.198.13", - "ipv6": null, - "port": 6000 - } - ], - "meta_url": "https://git.io/J0eoF", - "meta_hash": "563af2ed89859d9eb1976706f86285f7b5c8f51a3fa354b185b8f86797416b97", - "meta_json": null, - "pool_status": "registered", - "retiring_epoch": null - } - ] -|] - -poolUpdatesExpected :: [PoolUpdate] -poolUpdatesExpected = - [ - PoolUpdate - { _poolUpdateTxHash = "58011f2d795af54ab076320d5092a7989efd451eb39c5c64794c7b5eccd9da97" - , _poolUpdateBlockTime = Just 1629034536 - , _poolUpdatePoolIdBech32 = "pool125kh7e0y9lwya4sz5etmsk7hvga9jtfpuhw00vz9zvk6sh8xh5r" - , _poolUpdatePoolIdHex = "552d7f65e42fdc4ed602a657b85bd7623a592d21e5dcf7b045132da8" - , _poolUpdateActiveEpochNo = EpochNo 286 - , _poolUpdateVrfKeyHash = "076102096f5fc37a47ff14390f7320c76ea769183d06881d53dc4ea1be51acae" - , _poolUpdateMargin = 0 - , _poolUpdateFixedCost = 340000000 - , _poolUpdatePledge = 10000000000 - , _poolUpdateRewardAddr = Just "stake1uxtdm5q9j89mmme0l6jt9rsap8cn3vjy3eflptx34s2645ge7r9gp" - , _poolUpdateOwners = ["stake1uxtdm5q9j89mmme0l6jt9rsap8cn3vjy3eflptx34s2645ge7r9gp"] - , _poolUpdateRelays = - [ - Relay - { _relayDns = Nothing - , _relaySrv = Nothing - , _relayIpv4 = Just "139.180.198.13" - , _relayIpv6 = Nothing - , _relayPort = Just 6000 - } - ] - , _poolUpdateMetaUrl = Just "https://git.io/J0eoF" - , _poolUpdateMetaHash = Just "563af2ed89859d9eb1976706f86285f7b5c8f51a3fa354b185b8f86797416b97" - , _poolUpdateMetaJson = Nothing - , _poolUpdatePoolStatus = Just "registered" - , _poolUpdateRetiringEpoch = Nothing - } - ] diff --git a/test/Maestro/Test/Transaction.hs b/test/Maestro/Test/Transaction.hs deleted file mode 100644 index 56be7f6..0000000 --- a/test/Maestro/Test/Transaction.hs +++ /dev/null @@ -1,111 +0,0 @@ -{-# LANGUAGE QuasiQuotes #-} -module Maestro.Test.Transaction where - -import Data.Aeson (decode, eitherDecode) -import Test.Hspec -import Text.RawString.QQ - -import Data.ByteString.Lazy (ByteString) -import Maestro.Types.V0 - -spec_pool :: Spec -spec_pool = do - it "parsing /transaction/tx_hash/cbor sample" $ do - eitherDecode txCborSample - `shouldBe` - Right txCborExpected - - it "parsing /transaction/tx_hash/outputs/index/address sample" $ do - eitherDecode txAddressSample - `shouldBe` - Right txAddressExpected - -txCborSample :: ByteString -txCborSample = [r| - { - "cbor": "84a4008382582038dc2ac77bac948bdc623be..." - } -|] - -txCborExpected :: TxCbor -txCborExpected = TxCbor{ _txCbor = "84a4008382582038dc2ac77bac948bdc623be..."} - - -txAddressSample :: ByteString -txAddressSample = [r| - { - "address": "addr1wxgg25t3tk30jqzl2elqz94lzgmr8a9c9m5z902ds5sjh0g7uaj8z" - } -|] - -txAddressExpected :: UtxoAddress -txAddressExpected = UtxoAddress {_utxoAddressAddress = "addr1wxgg25t3tk30jqzl2elqz94lzgmr8a9c9m5z902ds5sjh0g7uaj8z"} - -txUtxoSample :: ByteString -txUtxoSample = [r| - { - "tx_hash": "9907c1bcab96889368d975ec1964e2fedfef22ce4a0e367bf9cb621b9f0dcb4a", - "index": 0, - "assets": [ - { - "unit": "lovelace", - "quantity": 7280082022 - }, - { - "unit": "34250edd1e9836f5378702fbf9416b709bc140e04f668cc355208518#4154414441636f696e", - "quantity": 10824 - } - ], - "address": "addr_test1vpfwv0ezc5g8a4mkku8hhy3y3vp92t7s3ul8g778g5yegsgalc6gc", - "datum": { - "type": "inline", - "hash": "432cb73420839fb517533c365d7ec125c457ea4ba5c0349be81be6796d52ef3b", - "bytes": "1a00278530", - "json": { - "int": 2590000 - } - }, - "reference_script": { - "type": "plutusv2", - "hash": "3a888d65f16790950a72daee1f63aa05add6d268434107cfa5b67712", - "bytes": "480100002221200101", - "json": null - } - } -|] - -txUtxoExpected :: Utxo -txUtxoExpected = - Utxo - {_utxoTxHash = "" - , _utxoIndex = 0 - , _utxoAssets = - [ - Asset - { _assetUnit = "lovelace" - , _assetQuantity = 7280082022 - } - , - Asset - { _assetUnit = "34250edd1e9836f5378702fbf9416b709bc140e04f668cc355208518#4154414441636f696e" - , _assetQuantity = 10824 - } - ] - , _utxoAddress = "addr_test1vpfwv0ezc5g8a4mkku8hhy3y3vp92t7s3ul8g778g5yegsgalc6gc" - , _utxoDatum = - Just DatumOption - { _datumOptionType = Inline - , _datumOptionHash = "432cb73420839fb517533c365d7ec125c457ea4ba5c0349be81be6796d52ef3b" - , _datumOptionBytes = Just "1a00278530" - , _datumOptionJson = decode "{\"int\":2590000}" - } - - , _utxoReferenceScript = - Just Script - { _scriptHash = "3a888d65f16790950a72daee1f63aa05add6d268434107cfa5b67712" - , _scriptBytes = Just "480100002221200101" - , _scriptType = PlutusV2 - , _scriptJson = Nothing - } - , _utxoTxoutCbor = Nothing - }