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

Feat: Client functions to get transactions at an address / payment credential... #48

Merged
merged 19 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
b381567
Feat: Client functions to get transactions at an address / payment cr…
sourabhxyz Feb 12, 2024
7783843
feat: Also parse error strings which are not enclosed in quotes
sourabhxyz Feb 20, 2024
f2d58ff
feat: :sparkles: add \`assets\` endpoint to get for native asset info…
sourabhxyz Feb 28, 2024
a20a033
feat: add `timestamp` field when fetching prices
sourabhxyz Mar 3, 2024
7877265
feat: add all the query parameters for the OHLC endpoint
sourabhxyz Mar 3, 2024
9d0d219
feat: adds newer `Show` instance and derives more classes for `Resolu…
sourabhxyz Mar 4, 2024
62af37a
feat: use `Natural` as type for `ohlcCandleInfoCount`
sourabhxyz Mar 4, 2024
cd42401
feat: hide api key in case of `ConnectionError`
sourabhxyz Mar 10, 2024
dc95858
feat: add `FromHttpApiData` instance of `Dex`
sourabhxyz Mar 10, 2024
0bd82fa
feat: add `Enum`, `Bounded` instance of `Dex`
sourabhxyz Mar 10, 2024
bd92193
feat: add `FromHttpApiData` instance for `Resolution`
sourabhxyz Mar 10, 2024
054711d
feat: add `FromHttpApiData` instance for `Order`
sourabhxyz Mar 10, 2024
83a37d8
feat: handle utf-8 encoding when decoding returned error message when…
sourabhxyz Mar 10, 2024
bdab74c
feat: add Eq, Ord, Enum, Bounded, ToJSON instances for Order
sourabhxyz Apr 2, 2024
eb2db38
feat: utxos by multiple payment credentials
sourabhxyz Apr 8, 2024
c108757
feat: add support of `asset` query parameter to utxos by payment cred…
sourabhxyz Apr 9, 2024
474a274
refactor: use `toStrict` from `Data.ByteString.Lazy` module to satisf…
sourabhxyz Apr 9, 2024
e1df1c3
feat: update cabal file to represent for latest release and add chang…
sourabhxyz Apr 9, 2024
d70479c
fix: use post verb instead of get for `paymentCredentialsUtxos` endpo…
sourabhxyz Apr 9, 2024
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
205 changes: 102 additions & 103 deletions maestro-sdk.cabal
Vardominator marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ cabal-version: 3.0
name: maestro-sdk
version: 1.5.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]
:> Get '[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
Loading