Skip to content

Commit

Permalink
Merge pull request #48 from maestro-org/txAtAddressOrCredential
Browse files Browse the repository at this point in the history
Feat: Client functions to get transactions at an address / payment credential...
  • Loading branch information
Vardominator authored Apr 9, 2024
2 parents bafa41f + d70479c commit 609515b
Show file tree
Hide file tree
Showing 16 changed files with 498 additions and 159 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Revision history for `maestro-sdk`

## [1.6.0](https://github.com/maestro-org/haskell-sdk/compare/v1.5.0..v1.6.0) -- 2024-04-09

Added:

* GET `/addresses/:address/transactions`
* `asset` query parameter to GET `/addresses/cred/:credential/utxos`
* POST `/addresses/cred/utxos`
* GET `/addresses/cred/:credential/transactions`
* GET `/assets/:asset`
* `from`, `to`, `limit` query parameters to GET `/markets/dexs/ohlc/:dex/:pair`
* provision to prevent api-key from being leaked in error messages
* provision to handle Maestro error bodies which are not enclosed in double quotes. Earlier behaviour was to expect message such as `"Failed to deserialise"` and not `Failed to deserialise`.
* `FromHttpApiData`, `ToHttpApiData` instance for `SlotNo`
* `Eq`, `Ord`, `Enum`, `Bounded`, `ToJSON`, `FromHttpApiData` instance for `Order`
* `Enum`, `Bounded`, `FromHttpApiData` instance for `Dex`
* `Data`, `Typeable`, `Enum`, `Bounded`, `FromHttpApiData` instance for `Resolution` and also refactored it's `Show` instance.

## [1.5.0](https://github.com/maestro-org/haskell-sdk/compare/v1.4.0..v1.5.0) -- 2024-01-02

* Added support GeniusYield DEX to market defi endpoints in [#45](https://github.com/maestro-org/haskell-sdk/pull/45).
Expand Down
207 changes: 103 additions & 104 deletions maestro-sdk.cabal
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
cabal-version: 3.0
name: maestro-sdk
version: 1.5.0
version: 1.6.0
synopsis: Maestro Blockchain Indexer SDK
description: Maestro provides blockchain indexers, APIs and event management systems for the Cardano blockchain.
description:
Maestro provides blockchain indexers, APIs and event management systems for the Cardano blockchain.

license: Apache-2.0
license-file: LICENSE
author: [email protected]
Expand All @@ -12,118 +14,115 @@ build-type: Simple
category: Blockchain, Cardano, SDK, API, REST
extra-doc-files: CHANGELOG.md
extra-source-files: README.md
tested-with: GHC == { 8.10.7, 9.2.8, 9.6.2 }
tested-with: GHC ==8.10.7 || ==9.2.8 || ==9.6.2

source-repository head
type: git
location: https://github.com/maestro-org/haskell-sdk

common common
ghc-options: -Wall
default-extensions:
GADTs
DataKinds
DeriveGeneric
DerivingStrategies
DerivingVia
GeneralisedNewtypeDeriving
FlexibleInstances
FlexibleContexts
MultiParamTypeClasses
NumericUnderscores
OverloadedStrings
RecordWildCards
RoleAnnotations
ScopedTypeVariables
TemplateHaskell
TypeApplications
TypeFamilies
TypeOperators
QuasiQuotes
ghc-options: -Wall
default-extensions:
DataKinds
DeriveGeneric
DerivingStrategies
DerivingVia
FlexibleContexts
FlexibleInstances
GADTs
GeneralisedNewtypeDeriving
MultiParamTypeClasses
NumericUnderscores
OverloadedStrings
QuasiQuotes
RecordWildCards
RoleAnnotations
ScopedTypeVariables
TemplateHaskell
TypeApplications
TypeFamilies
TypeOperators

library
import: common
exposed-modules:
Maestro.API.V1
Maestro.API.V1.Accounts
Maestro.API.V1.Addresses
Maestro.API.V1.Blocks
Maestro.API.V1.Datum
Maestro.API.V1.DefiMarkets
Maestro.API.V1.General
Maestro.API.V1.Pools
Maestro.API.V1.Transactions
Maestro.API.V1.TxManager

Maestro.Client.Env
Maestro.Client.Error

Maestro.Client.V1
Maestro.Client.V1.Core
Maestro.Client.V1.Core.Pagination
Maestro.Client.V1.Accounts
Maestro.Client.V1.Addresses
Maestro.Client.V1.Blocks
Maestro.Client.V1.Datum
Maestro.Client.V1.DefiMarkets
Maestro.Client.V1.General
Maestro.Client.V1.Pools
Maestro.Client.V1.Transactions
Maestro.Client.V1.TxManager

Maestro.Types.Common

Maestro.Types.V1
Maestro.Types.V1.Accounts
Maestro.Types.V1.Addresses
Maestro.Types.V1.Blocks
Maestro.Types.V1.Datum
Maestro.Types.V1.DefiMarkets
Maestro.Types.V1.Common
Maestro.Types.V1.Common.Pagination
Maestro.Types.V1.Common.Timestamped
Maestro.Types.V1.General
Maestro.Types.V1.Pools
Maestro.Types.V1.Transactions
import: common
exposed-modules:
Maestro.API.V1
Maestro.API.V1.Accounts
Maestro.API.V1.Addresses
Maestro.API.V1.Assets
Maestro.API.V1.Blocks
Maestro.API.V1.Datum
Maestro.API.V1.DefiMarkets
Maestro.API.V1.General
Maestro.API.V1.Pools
Maestro.API.V1.Transactions
Maestro.API.V1.TxManager
Maestro.Client.Env
Maestro.Client.Error
Maestro.Client.V1
Maestro.Client.V1.Accounts
Maestro.Client.V1.Addresses
Maestro.Client.V1.Assets
Maestro.Client.V1.Blocks
Maestro.Client.V1.Core
Maestro.Client.V1.Core.Pagination
Maestro.Client.V1.Datum
Maestro.Client.V1.DefiMarkets
Maestro.Client.V1.General
Maestro.Client.V1.Pools
Maestro.Client.V1.Transactions
Maestro.Client.V1.TxManager
Maestro.Types.Common
Maestro.Types.V1
Maestro.Types.V1.Accounts
Maestro.Types.V1.Addresses
Maestro.Types.V1.Assets
Maestro.Types.V1.Blocks
Maestro.Types.V1.Common
Maestro.Types.V1.Common.Pagination
Maestro.Types.V1.Common.Timestamped
Maestro.Types.V1.Datum
Maestro.Types.V1.DefiMarkets
Maestro.Types.V1.General
Maestro.Types.V1.Pools
Maestro.Types.V1.Transactions

build-depends:
aeson ^>=2.1,
base ^>=4.14.3.0 || ^>=4.16.4.0 || ^>=4.18.0.0,
bytestring ^>=0.10 || ^>=0.11,
containers ^>=0.6,
data-default-class ^>=0.1,
deriving-aeson ^>=0.2,
http-api-data ^>=0.5 || ^>=0.6,
http-client ^>=0.7,
http-client-tls ^>=0.3,
http-types ^>=0.12,
retry ^>=0.9,
servant ^>=0.19 || ^>=0.20,
servant-client ^>=0.19 || ^>=0.20,
servant-client-core ^>=0.19 || ^>=0.20,
text ^>=1.2 || ^>=2.0,
time ^>=1.9 || ^>=1.11 || ^>=1.12
build-depends:
, aeson ^>=2.1
, base ^>=4.14.3.0 || ^>=4.16.4.0 || ^>=4.18.0.0
, bytestring >=0.10 && <0.11 || ^>=0.11
, containers ^>=0.6
, data-default-class ^>=0.1
, deriving-aeson ^>=0.2
, http-api-data >=0.5 && <0.6 || ^>=0.6
, http-client ^>=0.7
, http-client-tls ^>=0.3
, http-types ^>=0.12
, retry ^>=0.9
, servant >=0.19 && <0.20 || ^>=0.20
, servant-client >=0.19 && <0.20 || ^>=0.20
, servant-client-core >=0.19 && <0.20 || ^>=0.20
, text ^>=1.2 || ^>=2.0
, time ^>=1.9 || >=1.11 && <1.12 || ^>=1.12

hs-source-dirs: src
default-language: Haskell2010
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.Backoff
import: common
default-language: Haskell2010
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: Driver.hs
other-modules: Maestro.Test.Backoff
build-depends:
, base ^>=4.14.3.0 || ^>=4.16.4.0 || ^>=4.18.0.0
, containers ^>=0.6.5.1
, hspec ^>=2.11.4
, maestro-sdk
, tasty ^>=1.4.3
, tasty-hspec ^>=1.2.0.4
, text ^>=1.2.4.1 || ^>=2.0.2
, time ^>=1.9.3 || ^>=1.11.1.1 || ^>=1.12.2

build-depends:
base ^>=4.14.3.0 || ^>=4.16.4.0 || ^>=4.18.0.0,
maestro-sdk,
containers ^>=0.6.5.1,
hspec ^>=2.11.4,
tasty ^>=1.4.3,
tasty-hspec ^>=1.2.0.4,
text ^>=1.2.4.1 || ^>=2.0.2,
time ^>=1.9.3 || ^>=1.11.1.1 || ^>=1.12.2
build-tool-depends:
tasty-discover:tasty-discover
build-tool-depends: tasty-discover:tasty-discover
2 changes: 2 additions & 0 deletions src/Maestro/API/V1.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Maestro.API.V1 where
import Data.Text (Text)
import Maestro.API.V1.Accounts
import Maestro.API.V1.Addresses
import Maestro.API.V1.Assets
import Maestro.API.V1.Blocks
import Maestro.API.V1.Datum
import Maestro.API.V1.DefiMarkets
Expand All @@ -23,6 +24,7 @@ data MaestroApiV1 route = MaestroApiV1
, pools :: route :- "pools" :> ToServantApi PoolsAPI
, txManager :: route :- "txmanager" :> ToServantApi TxManagerAPI
, transactions :: route :- "transactions" :> ToServantApi TransactionsAPI
, assets :: route :- "assets" :> ToServantApi AssetsAPI
} deriving Generic

newtype MaestroApiV1Auth route = MaestroApiV1Auth
Expand Down
32 changes: 32 additions & 0 deletions src/Maestro/API/V1/Addresses.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,47 @@ data AddressesAPI route = AddressesAPI
:> Pagination
:> Get '[JSON] PaginatedOutputReferenceObject

, addressTxs
:: route
:- Capture "address" (Bech32StringOf Address)
:> "transactions"
:> QueryParam "order" Order
:> QueryParam "from" SlotNo
:> QueryParam "to" SlotNo
:> Pagination
:> Get '[JSON] PaginatedAddressTransaction

, paymentCredentialUtxos
:: route
:- "cred"
:> Capture "credential" (Bech32StringOf PaymentCredentialAddress)
:> "utxos"
:> QueryParam "resolve_datums" Bool
:> QueryParam "with_cbor" Bool
:> QueryParam "asset" NonAdaNativeToken
-- TODO: Support for more query parameters.
:> Pagination
:> Get '[JSON] PaginatedUtxoWithSlot

, paymentCredentialsUtxos
:: route
:- "cred"
:> "utxos"
:> QueryParam "resolve_datums" Bool
:> QueryParam "with_cbor" Bool
:> Pagination
:> ReqBody '[JSON] [Bech32StringOf PaymentCredentialAddress]
:> Post '[JSON] PaginatedUtxoWithSlot

, paymentCredentialTxs
:: route
:- "cred"
:> Capture "credential" (Bech32StringOf PaymentCredentialAddress)
:> "transactions"
:> QueryParam "order" Order
:> QueryParam "from" SlotNo
:> QueryParam "to" SlotNo
:> Pagination
:> Get '[JSON] PaginatedPaymentCredentialTransaction

} deriving (Generic)
14 changes: 14 additions & 0 deletions src/Maestro/API/V1/Assets.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Maestro.API.V1.Assets where

import Maestro.Types.V1
import Servant.API
import Servant.API.Generic

data AssetsAPI route = AssetsAPI
{ assetInfo ::
route
:- Capture "asset" NonAdaNativeToken
:> Get '[JSON] TimestampedAssetInfo
-- ^ Native asset information.
}
deriving (Generic)
41 changes: 22 additions & 19 deletions src/Maestro/API/V1/DefiMarkets.hs
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
module Maestro.API.V1.DefiMarkets where

import Maestro.Types.V1
import Servant.API
import Servant.API.Generic
import Data.Time (Day)
import Data.Word (Word64)
import Maestro.Types.V1
import Servant.API
import Servant.API.Generic

data DefiMarketsAPI route = DefiMarketsAPI
{
dexOHLC
:: route
:- "ohlc"
:> Capture "dex" Dex
:> Capture "pair" (TaggedText PairOfDexTokens)
:> QueryParam "resolution" Resolution
:> QueryParam "sort" Order
:> Get '[JSON] [OHLCCandleInfo]

, dexPairs
:: route
:- Capture "dex" Dex
:> Get '[JSON] DexPairResponse

} deriving (Generic)
{ dexOHLC ::
route
:- "ohlc"
:> Capture "dex" Dex
:> Capture "pair" (TaggedText PairOfDexTokens)
:> QueryParam "resolution" Resolution
:> QueryParam "from" Day
:> QueryParam "to" Day
:> QueryParam "limit" Word64
:> QueryParam "sort" Order
:> Get '[JSON] [OHLCCandleInfo]
, dexPairs ::
route
:- Capture "dex" Dex
:> Get '[JSON] DexPairResponse
}
deriving (Generic)
Loading

0 comments on commit 609515b

Please sign in to comment.