digital-asset / daml

The Daml smart contract language
https://www.digitalasset.com/developers
797 stars 199 forks source link

Ledger API support for providing package metadata #3883

Open jkk-vmw opened 4 years ago

jkk-vmw commented 4 years ago

Howdy, DA folks.

I've already gotten answer that JSON-API will not be providing package metadata for template data structures and generic function definitions of choices (generic, defined by the .daml, which can be very complicated nested structures, referring other defined generic structures and even non-daml-primitive Haskell data types)

It seems that by after uploading the DAR package, the ledger already have the metadata in hand; otherwise, it wouldn't even be able to create the database table/collection with indexes and columns. (I could be wrong on this)

In short, are there any plans to provide this metadata via for Ledger API? or any other endpoints?

Thanks in advance. You guys are doing awesome work!

Related to: https://github.com/digital-asset/daml/issues/3539 https://github.com/digital-asset/daml/issues/3508

jkk-vmw commented 4 years ago

Bump!

gerolf-da commented 4 years ago

Hi @jkk-vmw, the Ledger API already provides this information, albeit in the very low level form of DAML LF packages (see package service). There is currently no plan to add a higher level API in the next couple of months, but we will revisit the topic in the future for sure.

leo-da commented 4 years ago

LedgerReader takes com.digitalasset.ledger.client.services.pkg.PackageClient as a parameter and returns type PackageStore = Map[String, Interface] which contains all types and templates.

https://github.com/digital-asset/daml/blob/878429e3bf07b09e727224d5dc423444d071a95b/ledger-service/utils/src/main/scala/com/digitalasset/ledger/service/LedgerReader.scala#L19