Cannot Resolve template ID Locally

Issue I’m running into:
When trying to run daml start on a dummy project lists other Dars as dependencies, I run into the “Cannot Resolve Template ID” error locally. (I have uploaded the separate dars onto daml hub, and uploaded the ui zip, and there are no issues on daml hub)

I’m working on a project where the current structure looks like this:

parent
   main (where I have the daml models) 
      /Account
         /daml/Account.daml
         daml.yaml (User, Asset as dependencies)
      /Asset
         /daml/Asset.daml
      daml.yaml
      /User
         /daml/User.daml
      daml.yaml
     /LocalDev (this is the dummy project)
       /daml/LocalDev.daml
     daml.yaml (listing Account, User, Asset dar paths as dependencies) 

I first run daml build for the following:

  1. Asset
  2. User
  3. Account
    and finally LocalDev

I then run codegen for Asset, User, Account
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 -o ui/daml.js which produces a daml.js file in my UI directory. And I run npm install.

In one terminal, in the LocalDev directory, I’ll run daml start, in another terminal in the ui directory, I run npm start

I get error when I try to login:
Screenshot 2022-04-15 at 9.02.47 AM

Within the LocalDev .daml > dependencies file, I can see 5b1e9…

Within the daml.js file in the UI directory, I don’t see the package ID directly at the first layer where the package IDs are listed, is that the issue?

However, when I go into ‘User-0.0.1’
It seems that the module.js file references 5b1e9…

Where I’m uncertain about:
Am I creating the dummy project correctly? The LocalDev directory has a daml.yaml file with

sdk-version: 1.18.1
name: LocalDev
source: daml
version: 0.0.1
dependencies:
  - daml-prim
  - daml-stdlib
  - daml-script
  - ../Asset/asset.dar
  - ../User/user.dar
  - ../Account/account.dar

sandbox-options:
  - --wall-clock-time
  - --ledgerid=wallet-refapp-sandbox

Am I running the codegen correctly with only Asset, User, and Account
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

I’ve tried to include LocalDev dar as well, and same error.

The error message you receive suggests that the package for your User template is not know by your ledger. Please make sure that your packages are included in the dar file you start your sandbox with by running:
daml damlc inspect-dar <path-to-LocalDev.dar>

The User, Asset and Account packages should be listed under “DAR archive contains the following packages:”

1 Like

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

  1. if the daml file is empty, no dars are uploaded
  2. 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 Asset
import Account
import User

template LocalDev with
    owner: Party
    notUsedAsset: Asset
    notUsedAccount: Account.AssetHoldingAccount
    notUsedUser: User
  where
    signatory owner

Though this template is completely unused, it is necessary when running daml start and having the other dars to be uploaded to the sandbox.

An alternative solution from @Mate_Varga , is to simply use:

daml sandbox --ledgerid wallet-refapp-sandbox main/Asset/asset.dar main/User/user.dar main/Account/account.dar

This loads the dars into the sandbox, then the next step which I was missing when troubleshooting is running
daml json-api --ledger-host localhost --ledger-port 6865 --http-port 7575

and finally in another terminal run
npm start for the UI.

By doing that, we can avoid the use of a dummy project altogether.

2 Likes