The first parameter is darHash (which is not the same as the packageId). The following, for example,…
val dar = participant.dars.list().filter(_.name == "AdminWorkflowsWithVacuuming").head
participant.dars.download(dar.hash, ".")
…will save the AdminWorkflowsWithVacuuming.dar file. You can append the extension .zip to the file name to extract the files to view the contents. You will notice that one DAR file has lots of packages.
In my example above, participant.dars.list() doesn’t list the mentioned package, unfortunately. I can fetch it with daml ledger fetch-dar, but not with canton script:
Interesting! Thanks, Richard, for bringing this up.
In my example above, participant.dars.list() doesn’t list the mentioned package, unfortunately.
You are right. It does not “list the mentioned package.” That call returns a list of DAR files, not packages. The package you are interested in, with package id 65921..., is in fact within the DAR file AdminWorkflowsWithVacuuming.dar.
What I learned today is that the example you gave in your original post…
… creates a new DAR file named x.dar. It will contain the 65921... package and its 22 dependencies. That’s in contrast to the AdminWorkflowsWithVacuuming.dar, which is what is included by default in a 2.9.4 Canton node. The AdminWorkflowsWithVacuuming.dar contains 30+ packages, including the 23 that were exported into your new x.dar.
It feels like daml ledger fetch-dar is more like an “export a package and its dependencies” function, than it is a “download dar” function.
val src = participant.packages.find("PingPong").head
val dar = participant.dars.list().find(_.name == src.sourceDescription).head
participant.dars.download(dar.hash, ".")