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: add more fields to AssetInfo type #68

Merged
merged 9 commits into from
Aug 19, 2024
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Revision history for `maestro-sdk`

## [1.7.0](https://github.com/maestro-org/haskell-sdk/compare/v1.5.0..v1.6.0) -- 2024-08-17

* Updated to newer `era-summaries` and `protocol-parameters` endpoint from earlier `era-history` and `protocol-params` respectively.
* `AssetInfo` type which corresponds to `/assets/:asset` is updated with more response fields.

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

Added:
Expand Down
94 changes: 47 additions & 47 deletions maestro-sdk.cabal
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
cabal-version: 3.0
name: maestro-sdk
version: 1.6.0
synopsis: Maestro Blockchain Indexer SDK
cabal-version: 3.0
name: maestro-sdk
version: 1.7.0
synopsis: Maestro Blockchain Indexer SDK
description:
Maestro provides blockchain indexers, APIs and event management systems for the Cardano blockchain.

license: Apache-2.0
license-file: LICENSE
author: [email protected]
maintainer: [email protected]
copyright: (c) 2023 Maestro Blockchain Inc
build-type: Simple
category: Blockchain, Cardano, SDK, API, REST
extra-doc-files: CHANGELOG.md
license: Apache-2.0
license-file: LICENSE
author: [email protected]
maintainer: [email protected]
copyright: (c) 2023 Maestro Blockchain Inc
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
type: git
location: https://github.com/maestro-org/haskell-sdk

common common
ghc-options: -Wall
ghc-options: -Wall
default-extensions:
DataKinds
DeriveGeneric
Expand All @@ -44,7 +44,7 @@ common common
TypeOperators

library
import: common
import: common
exposed-modules:
Maestro.API.V1
Maestro.API.V1.Accounts
Expand Down Expand Up @@ -88,41 +88,41 @@ library
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 || ^>=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
aeson >=2.1 && <2.3,
base >=4.9 && <5,
bytestring >=0.10 && <0.12,
containers ^>=0.6,
data-default-class ^>=0.1,
deriving-aeson ^>=0.2,
http-api-data >=0.5 && <0.7,
http-client ^>=0.7,
http-client-tls ^>=0.3,
http-types ^>=0.12,
retry ^>=0.9,
servant >=0.19 && <0.21,
servant-client >=0.19 && <0.21,
servant-client-core >=0.19 && <0.21,
text >=1.2 && <3.0,
time >=1.9 && <1.13,

hs-source-dirs: src
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
base,
containers,
hspec >=2.11 && <2.12,
maestro-sdk,
tasty >=1.4 && <1.6,
tasty-hspec >=1.2 && <1.3,
text,
time,

build-tool-depends: tasty-discover:tasty-discover
4 changes: 2 additions & 2 deletions src/Maestro/API/V1/General.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ data GeneralAPI route =
:> Get '[JSON] TimestampedSystemStart
, eraHistory
:: route
:- "era-history"
:- "era-summaries"
:> Get '[JSON] TimestampedEraSummaries
, protocolParams
:: route
:- "protocol-params"
:- "protocol-parameters"
:> Get '[JSON] TimestampedProtocolParameters
, chainTip
:: route
Expand Down
35 changes: 34 additions & 1 deletion src/Maestro/Types/V1/Assets.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Maestro.Types.V1.Assets (
TimestampedAssetInfo (..),
) where

import Data.Aeson (Value)
import Data.Text (Text)
import Data.Word (Word64)
import Deriving.Aeson
Expand All @@ -28,9 +29,41 @@ data TokenRegistryMetadata = TokenRegistryMetadata
deriving stock (Eq, Show, Generic)
deriving (FromJSON, ToJSON) via CustomJSON '[FieldLabelModifier '[StripPrefix "tokenRegistryMetadata", CamelToSnake]] TokenRegistryMetadata

data Cip68AssetType = CIP68ATReferenceNft | CIP68ATUserNft | CIP68ATUserFt
deriving stock (Eq, Show, Generic, Enum, Bounded)
deriving (FromJSON, ToJSON) via CustomJSON '[ConstructorTagModifier '[StripPrefix "CIP68AT", CamelToSnake]] Cip68AssetType

data Cip68Metadata = Cip68Metadata
{ cip68MetadataExtra :: !(Maybe Text)
-- ^ Custom user defined Plutus data CBOR bytes.
, cip68MetadataMetadata :: !Value
-- ^ Asset CIP-68 metadata.
, cip68MetadataPurpose :: !Cip68AssetType
-- ^ Purpose.
, cip68MetadataVersion :: !Word64
-- ^ CIP-68 version.
}
deriving stock (Eq, Show, Generic)
deriving (FromJSON, ToJSON) via CustomJSON '[FieldLabelModifier '[StripPrefix "cip68Metadata", CamelToSnake]] Cip68Metadata

-- | Asset information corresponding to popular standards.
data AssetStandards = AssetStandards
{ assetStandardsCip25Metadata :: !(Maybe Value)
-- ^ CIP-25 metadata for a specific asset.
, assetStandardsCip68Metadata :: !(Maybe Cip68Metadata)
}
deriving stock (Eq, Show, Generic)
deriving (FromJSON, ToJSON) via CustomJSON '[FieldLabelModifier '[StripPrefix "assetStandards", CamelToSnake]] AssetStandards

-- | Information about a specific Cardano native-asset.
data AssetInfo = AssetInfo
{ assetInfoTokenRegistryMetadata :: !(Maybe TokenRegistryMetadata)
{ assetInfoAssetName :: !TokenName
-- ^ Hex encoding of the asset name.
, assetInfoAssetStandards :: !AssetStandards
-- ^ Asset information corresponding to popular standards.
, assetInfoLatestMintTxMetadata :: !(Maybe Value)
-- ^ Metadata of the most recent transaction which minted or burned the asset.
, assetInfoTokenRegistryMetadata :: !(Maybe TokenRegistryMetadata)
-- ^ See `TokenRegistryMetadata`.
}
deriving stock (Eq, Show, Generic)
Expand Down
Loading
Loading