-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat 30: Pagination checked by querying UTxOs at multiple addresses
- Loading branch information
1 parent
9972c3d
commit 8a668d6
Showing
12 changed files
with
150 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Maestro.Run.AddressV1 where | ||
|
||
import Maestro.Client.V1 | ||
|
||
runV1AddressAPI :: MaestroEnv -> IO () | ||
runV1AddressAPI mEnv = do | ||
utxos <- allPages $ (flip $ utxosAtMultiAddresses mEnv Nothing Nothing) ["insert","your", "big", "address", "list", "here"] | ||
putStrLn $ "Received: ⮯\n" ++ show utxos | ||
-- writeFile "allUtxos.txt" $ show utxos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,32 @@ | ||
module Main (main) where | ||
|
||
import qualified Data.Text as T | ||
import Maestro.Client.V0 | ||
import Maestro.Client.Env | ||
import Maestro.Run.Datum | ||
import Maestro.Run.Epochs | ||
import Maestro.Run.General | ||
import Maestro.Run.Pools | ||
import Maestro.Run.Scripts | ||
import Maestro.Run.Tx | ||
import Maestro.Run.AddressV1 | ||
import System.Environment (getEnv) | ||
|
||
|
||
main :: IO () | ||
|
||
main = do | ||
apiKey <- maestroKey | ||
apiKeyMain <- maestroMainKey | ||
env <- mkMaestroEnv (T.pack apiKey) Preprod V0 | ||
runPoolsAPI env | ||
runTxApi env | ||
runEpochsAPI env | ||
runDatumAPI env | ||
runScriptsAPI env | ||
runGeneralAPI env | ||
env' <- mkMaestroEnv (T.pack apiKeyMain) Mainnet V1 | ||
runV1AddressAPI env' | ||
|
||
where | ||
maestroKey = getEnv "MAESTRO_API_KEY" | ||
maestroMainKey = getEnv "MAESTRO_MAIN_KEY" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module Maestro.API.V1.Address where | ||
|
||
import Data.Text (Text) | ||
import Maestro.Client.V1.Core.Pagination | ||
import Maestro.Types.V1 | ||
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] Utxos | ||
|
||
} deriving (Generic) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
module Maestro.Client.V0 | ||
module Maestro.Client.V1 | ||
( module Maestro.Client.Env | ||
, module Maestro.Client.Error | ||
, module Maestro.Client.V0.Core | ||
, module Maestro.Client.V1.Core | ||
, module Maestro.Client.V1.Address | ||
) where | ||
|
||
|
||
import Maestro.Client.Env | ||
import Maestro.Client.Error | ||
import Maestro.Client.V0.Core | ||
import Maestro.Client.V1.Address | ||
import Maestro.Client.V1.Core |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module Maestro.Client.V1.Address where | ||
|
||
import Data.Text (Text) | ||
import Maestro.API.V1 | ||
import Maestro.API.V1.Address | ||
import Maestro.Client.Env | ||
import Maestro.Client.V1.Core | ||
import Maestro.Types.V1 | ||
import Servant.API.Generic | ||
import Servant.Client | ||
|
||
addressClient :: MaestroEnv -> AddressAPI (AsClientT IO) | ||
addressClient = fromServant . _address . apiV1Client | ||
|
||
-- | Returns list of utxos for multiple addresses | ||
utxosAtMultiAddresses :: | ||
-- | The Maestro Environment | ||
MaestroEnv -> | ||
-- | 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 | ||
Cursor -> | ||
-- | List of Address in bech32 format to fetch utxo from | ||
[Text] -> | ||
IO Utxos | ||
utxosAtMultiAddresses = _addressesUtxos . addressClient |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
-- | Maestro types | ||
|
||
module Maestro.Types.V1 | ||
( module Maestro.Types.V0.Common | ||
, module Maestro.Types.V1.Common | ||
( module Maestro.Types.V1.Common | ||
, module Maestro.Types.V1.General | ||
) where | ||
|
||
import Maestro.Types.V0.Common | ||
import Maestro.Types.V1.Common | ||
import Maestro.Types.V1.General |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters