Separating Main Daml Templates to Individual Dar Files
Whats the best practice (for structuring the repo) when it comes to separating Daml models into individual dar files?
Also just to be sure, I should NOT be creating a daml project inside a daml project right?
I could manually do this, and create a daml.yaml file, and a daml directory, but because if I run daml init inside a directory which I had init’ed earlier with daml init I will get the message:
Target directory is inside existing DAML project "/Users/maxhsu/Desktop/projects/wallet-refapp/wallet" Please specify a new directory outside an existing project.
The end goal is to upload 4 Dar files onto Daml hub and have everything interact together, in the name of composability.
-
Account.dar, -
Asset.dar, -
User.dar, and finally a Triggers.dar
Currently, I have a separated triggers Daml project, and the main daml project under /wallet
/triggers (daml project)
/daml
triggerA.daml
triggerB.daml
daml.yaml ( with dep pointing to ../wallet/wallet-refapp.dar)
/wallet (daml project)
/daml
Account.daml
Asset.daml
User.daml
daml.yaml
daml.yaml (parent daml.yaml file specifying SDK)
And I’m only uploading 2 dar files to hub. Now, how should I structure the directory if I want to bring Account.daml, Asset.daml, and User.daml out as separate .dar files
would the end structure look like this?
parent
/triggers (daml project)
/daml
triggerA.daml
triggerB.daml
daml.yaml (at root of triggers project pointing to the new .dar file deps)
/Account (daml project)
/daml
Account.daml
daml.yaml (specifiy any deps from other dar files)
/Asset (daml project)
/daml
Asset.daml
daml.yaml
daml.yaml (this one in the root specifying the sdk)
and a final question, when I’m doing the JS codegen, would I only need to build the .dar file with all the dependencies?
Currently,
When I am in the /wallet directory and run daml build , I get the output
.daml/dist/wallet-refapp-0.1.0.dar, this is then used to create the javsscript bindings when I run
daml codegen js .daml/dist/wallet-refapp-0.1.0.dar -o ui/daml.js
Now I’ll have multiple dar files.
Your structure seems sensible. I’d generally recommend one directory per project and then the top-level daml.yaml fixing just the SDK version. Note that there are some caveats if you open the root directory in daml studio. Take a look at the documentation for more details.
Thanks, just wanted to confirm.