DABL - viewing templates from packages

Hi, I noticed that in DABL, users can view the template source code once a package is uploaded. Just curious which part of the Daml SDK did that? Is that function available on Daml assistant?

2 Likes

By default, the Daml source code is packaged along the compiler output in the DAR file produced by daml build, as you can see in this example:

> daml new --template create-daml-app create-daml-app
> cd create-daml-app/
> daml build
Compiling create-daml-app to a DAR.
Created .daml/dist/create-daml-app-0.1.0.dar
> unzip -l .daml/dist/create-daml-app-0.1.0.dar | grep '\.daml'
Archive:  .daml/dist/create-daml-app-0.1.0.dar
      766  1980-01-01 00:00   create-daml-app-0.1.0-735923d27aa225fb82858e175e6690661f0be60f757b80e3bc1859525bc142de/User.daml
> unzip -p .daml/dist/create-daml-app-0.1.0.dar create-daml-app-0.1.0-735923d27aa225fb82858e175e6690661f0be60f757b80e3bc1859525bc142de/User.daml
-- Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0

module User where

-- MAIN_TEMPLATE_BEGIN
template User with
    username: Party
    following: [Party]
  where
    signatory username
    observer following
-- MAIN_TEMPLATE_END

    key username: Party
    maintainer key

    -- FOLLOW_BEGIN
    nonconsuming choice Follow: ContractId User with
        userToFollow: Party
      controller username
      do
        assertMsg "You cannot follow yourself" (userToFollow /= username)
        assertMsg "You cannot follow the same user twice" (notElem userToFollow following)
        archive self
        create this with following = userToFollow :: following
    -- FOLLOW_END
4 Likes