Multiple Dars on Hub, and Single Dar to Run Locally, What to do with Frontend React?
This is a follow up from the thread
Follow up question, running locally, and having the frontend interact. Currently with 3 separate dars, I pass the dars into the codgen js script, this ultimately generates my daml.js in the ui directory, upon which when I do npm install, it installs the types. and in my package.json, I am importing the new js types. Now this is for deploying on daml hub. To do this locally, you mentioned I create a dummy project. In order to run daml start, I need to do daml build. So are you saying that cre…
Which can be it’s own question. My question is how do I get my app running locally now ? the answer is partially given in the thread above, but I’m running issues into the frontend.
Currently, I have 3 dar files, and I create the js typings by passing in the dar files into codegen js script.
This in turn creates a daml.js file in my ui directory. My package.json looks like
"@daml.js/account": "file:daml.js/Account-0.0.1",
"@daml.js/user": "file:daml.js/User-0.0.1",
"@daml.js/asset": "file:daml.js/Asset-0.0.1",
I can import the types in the react app like
import { Asset } from '@daml.js/asset/lib/Asset/';
and
import { AssetHoldingAccount, } from '@daml.js/account/lib/Account/';
With no issue.
This works fine on Daml hub. But in order for me to run this app locally, I need to create a dummy project that imports the dar files, and I create a singular dar file (back to square one with only 1 dar file again), and this is so I can run
daml start and run the sandbox ledger. However this requires me to do a codgen with the new singular dar file, which produces different package IDs for the dependencies.
The current error I see is below, when a user logs on, a new user contract should be created:
But the new package IDs (from the singular dar file) is not being used on the frontend. Because I am still referencing the old js typines.

Do I need to create both? and toggle the imported typings based on the dev env?
It feels like a hack, but I’m not sure at this point. I tried to manually run the sandbox and pass in the individual dars, but that wasn’t working.
To resolve this, I created a dummy project along side my other main daml projects (as @cocreature has mentioned). Repo looks like:
parent
/main
/Account
/Asset
/User
/LocalDev (dummy project)
/daml
LocalDev.daml (I don't actually use this template, but I need it for when I generate the JS bindings)
daml.yaml (listing Account, Asset, User as dependencies)
Then from the localDev directory, I can run daml start
In addition, I now pass the localDev.dar into the codegen js script. Which looks like
daml codegen js main/Asset/.daml/dist/asset-0.0.1.dar main/User/.daml/dist/user-0.0.1.dar main/Account/.daml/dist/account-0.0.1.dar main/LocalDev/.daml/dist/LocalDev-0.0.1.dar -o ui/daml.js
This dummy template is needed creating one centralized dar file to run locally without this template, after running daml build in the LocalDev directorya and running the script for codegen that generates the daml.js in the UI directory
/ui/daml.js/LocalDev-0.0.1/lib/LocalDev will not appear (the final directory), instead it will only show
/ui/daml.js/LocalDev-0.0.1/lib
Now, I can deploy everything on to damlhub, and also just run daml start from the localDev directory to start the sandbox.
… Is this how its supposed to be done?
I have rebuilt everything and codegen’ed everything, deleted node_modules, package.json lock and daml.js
When the error comes up, the terminal where my sandbox is running shows
5-04-2022 03:12:15.995 [http-json-ledger-api-akka.actor.default-dispatcher-6] INFO com.daml.http.PackageService - new package IDs loaded: 518032f41fd0175461b35ae0c9691e08b4aea55e62915f8360af2cc7a1f2ba6c, cc348d369011362a5190fe96dd1f0dfbc697fdfd10e382b9e9666f0da05961b7, 9de3ae0b7b4e753f7ce2a5dcaa8d49ab4b92c4d8a8fb9589b5f8c893fbea5bd1, 99a2705ed38c1c26cbb8fe7acf36bbf626668e167a33335de932599219e0a235, e22bce619ae24ca3b8e6519281cb5a33b64b3190cc763248b4c3f9ad5087a92c, d58cf9939847921b2aab78eaa7b427dc4c649d25e6bee3c749ace4c3f52f5c97, 6c2c0667393c5f92f1885163068cd31800d2264eb088eb6fc740e11241b2bf06, 8a7806365bbd98d88b4c13832ebfa305f6abaeaf32cfa2b7dd25c4fa489b79fb, 108aa371793a39379d09dd6f02b5613e8bf37ec9893a826747545df5318475f1, 86828b9843465f419db1ef8a8ee741d1eef645df02375ebf509cdc8c3ddd16cb, c1f1f00558799eec139fb4f4c76f95fb52fa1837a5dd29600baa1c8ed1bdccfd, 733e38d36a2759688a4b2c4cec69d48e7b55ecc8dedc8067b815926c917a182a, f20de1e4e37b92280264c08bf15eca0be0bc5babd7a7b5e574997f154c00cb78, 3f4deaf145a15cdcfa762c058005e2edb9baa75bb7f95a4f8f6f937378e86415, bfcd37bd6b84768e86e432f5f6c33e25d9e7724a9d42e33875ff74f6348e733f, 6839a6d3d430c569b2425e9391717b44ca324b88ba621d597778811b2d05031d, 36ca4e027e6f3c2c3445fcf20a373b754d01c793d712611c59b0513521160a48, cb0552debf219cc909f51cbb5c3b41e9981d39f8f645b1f35e2ef5be2e0b858a, 76bf0fd12bd945762a01f8fc5bbcdfa4d0ff20f8762af490f8f41d6237c6524f, d14e08374fc7197d6a0de468c968ae8ba3aadbf9315476fd39071831f5923662, 057eed1fd48c238491b8ea06b9b5bf85a5d4c9275dd3f6183e0e6b01730cc2ba, 38e6274601b21d7202bb995bc5ec147decda5a01b68d57dda422425038772af7, e491352788e56ca4603acc411ffe1a49fefd76ed8b163af86cf5ee5f4c38645b, 40f452260bef3f29dede136108fc08a88d5a5250310281067087da6f0baddff7, 97b883cd8a2b7f49f90d5d39c981cf6e110cf1f1c64427a28a6d58ec88c43657, context: {ledger_id: "wallet-refapp-sandbox", request_id: "7b6f9e19-caaa-481c-b3f8-2bc9a172b64d", instance_uuid: "fd8ea7cd-2233-42fd-aa08-1fd3e51786ac", application_id: "delete-later", read_as: "List()", act_as: "List(a)"}
and 5b1e901f47c81c7e8fbe1aece228b9ec76037bbe333b6b33286b35f9fb86dd01 is not in there. Is that a reason? Why are new package Ids being loaded?
See solution here:
The issue it seems stems from the empty daml project in my dummy project. Similar issue I posted here: Multiple Dars on Hub, and Single Dar to Run Locally, What to do with Frontend React? - #4 by rikotacards if the daml file is empty, no dars are uploaded if the daml file has a dummy template, yet the templates don’t import the Asset, Account, User module, no dars are uploaded So the solution if to use a dummy project is to create a dummy template as well, module LocalDev where import Asse…
Great to see you’ve found a solution and are making progress @rikotacards
Thanks for cross-posting the solution in this thread as well ![]()
