Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UTxOs at a single address function + Removed deprecated datum endpoint #42

Merged
merged 3 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Revision history for `maestro-sdk`

## [1.3.0](https://github.com/maestro-org/haskell-sdk/compare/v1.2.0..v1.3.0) -- 2023-11-27

* Removed deprecated `/datum` endpoint in favour of `/datums`, [#42](https://github.com/maestro-org/haskell-sdk/pull/42).
* Support for endpoint to query UTxOs at a single address, [#42](https://github.com/maestro-org/haskell-sdk/pull/42).

## [1.2.0](https://github.com/maestro-org/haskell-sdk/compare/v1.1.0..v1.2.0) -- 2023-10-18

* Incorporating updated response when submitting the transaction, [#41](https://github.com/maestro-org/haskell-sdk/pull/41).

## [1.1.0](https://github.com/maestro-org/haskell-sdk/compare/v1.0.0..v1.1.0) -- 2023-09-23

* Support of v0 family of endpoints have been dropped, [#33](https://github.com/maestro-org/haskell-sdk/pull/33).
Expand Down
2 changes: 1 addition & 1 deletion maestro-sdk.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: maestro-sdk
version: 1.1.0
version: 1.3.0
synopsis: Maestro Blockchain Indexer SDK
description: Maestro provides blockchain indexers, APIs and event management systems for the Cardano blockchain.
license: Apache-2.0
Expand Down
2 changes: 1 addition & 1 deletion src/Maestro/API/V1.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ data MaestroApiV1 route = MaestroApiV1
, accounts :: route :- "accounts" :> ToServantApi AccountsAPI
, addresses :: route :- "addresses" :> ToServantApi AddressesAPI
, blocks :: route :- "blocks" :> ToServantApi BlocksAPI
, datum :: route :- "datum" :> ToServantApi DatumAPI
, datums :: route :- "datums" :> ToServantApi DatumAPI
, pools :: route :- "pools" :> ToServantApi PoolsAPI
, txManager :: route :- "txmanager" :> ToServantApi TxManagerAPI
, transactions :: route :- "transactions" :> ToServantApi TransactionsAPI
Expand Down
10 changes: 10 additions & 0 deletions src/Maestro/API/V1/Addresses.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ data AddressesAPI route = AddressesAPI
:> "decode"
:> Get '[JSON] AddressInfo

, addressUtxos
:: route
:- Capture "address" (Bech32StringOf Address)
:> "utxos"
:> QueryParam "resolve_datums" Bool
:> QueryParam "with_cbor" Bool
:> QueryParam "asset" NonAdaNativeToken
:> Pagination
:> Get '[JSON] PaginatedUtxoWithSlot

, addressesUtxos
:: route
:- "utxos"
Expand Down
4 changes: 2 additions & 2 deletions src/Maestro/API/V1/Blocks.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import Servant.API
import Servant.API.Generic

data BlocksAPI route = BlocksAPI
{ -- | Get details of the specified block by hash
{ -- | Get details of the specified block by hash.
blockByHash
:: route
:- Capture "hash_or_height" BlockHash
:> Get '[JSON] TimestampedBlockDetails
-- | Get details of the specified block by height
-- | Get details of the specified block by height.
, blockByHeight
:: route
:- Capture "hash_or_height" BlockHeight
Expand Down
21 changes: 20 additions & 1 deletion src/Maestro/Client/V1/Addresses.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-- | Module to query for /"addresses"/ category of endpoints defined at [docs.gomaestro.org](https://docs.gomaestro.org/docs/category/addresses).

module Maestro.Client.V1.Addresses (
utxosAtAddress,
utxosAtMultiAddresses,
getRefsAtAddress,
utxosByPaymentCredential,
Expand All @@ -11,7 +12,8 @@ import Maestro.API.V1.Addresses
import Maestro.Client.Env
import Maestro.Client.V1.Core
import Maestro.Types.Common (Address, Bech32StringOf)
import Maestro.Types.V1 (PaginatedOutputReferenceObject,
import Maestro.Types.V1 (NonAdaNativeToken,
PaginatedOutputReferenceObject,
PaginatedUtxoWithSlot,
PaymentCredentialAddress)
import Servant.API.Generic
Expand All @@ -35,6 +37,23 @@ utxosAtMultiAddresses ::
IO PaginatedUtxoWithSlot
utxosAtMultiAddresses = addressesUtxos . addressClient

-- | Returns list of utxos for a given address.
utxosAtAddress ::
-- | The Maestro Environment.
MaestroEnv 'V1 ->
-- | Address in bech32 format to fetch utxo from.
Bech32StringOf Address ->
-- | 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 ->
-- | Query Param to return for only those UTxOs which contain this given asset.
Maybe NonAdaNativeToken ->
-- | The pagination attributes.
Cursor ->
IO PaginatedUtxoWithSlot
utxosAtAddress = addressUtxos . addressClient

-- | UTxO IDs for all the unspent transaction outputs at an address.
getRefsAtAddress ::
MaestroEnv 'V1 ->
Expand Down
4 changes: 2 additions & 2 deletions src/Maestro/Client/V1/Datum.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Maestro.Client.V1.Datum
( getDatumByHash
) where

import Maestro.API.V1 (datum)
import Maestro.API.V1 (datums)
import Maestro.API.V1.Datum
import Maestro.Client.Env
import Maestro.Client.V1.Core
Expand All @@ -13,7 +13,7 @@ import Servant.API.Generic
import Servant.Client

datumClient :: MaestroEnv 'V1 -> DatumAPI (AsClientT IO)
datumClient = fromServant . datum . apiV1Client
datumClient = fromServant . datums . apiV1Client

-- | Get information about the datum from it's hash.
getDatumByHash :: MaestroEnv 'V1 -> HexStringOf DatumHash -> IO TimestampedDatum
Expand Down