Create a new skeleton project
daml new foo
And then change the module definition in Main.daml
to only explicitly export the following:
module Main (Asset, AssetId) where
So far, so good. You should be able to do daml start
or daml test
and everything should be peachy.
Note that by the above change, we’re no longer exporting Asset(..)
constructor, or Give
choice.
Now, if we move the included test script from Main.daml
, into say a new module Test.daml
, you’ll find that the code no longer compiles:
Test.daml|13 col 15| typecheck:Error:/tmp/foo/daml/Test.daml:13:15: error: Not in scope: data constructor ‘Asset’
Test.daml|19 col 25| typecheck:Error:/tmp/foo/daml/Test.daml:19:25: error: Not in scope: data constructor ‘Give’
Test.daml|22 col 23| typecheck:Error:/tmp/foo/daml/Test.daml:22:23: error: Not in scope: data constructor ‘Give’
I would say this is expected.
However, if I run daml start
, I can open the navigator, and I can still create Asset
s and Give
them!
Isn’t this a bug? I would further argue that, if the API/runtime respected the module scoping, it would give us a very useful feature: the ability to restrict the creation of assets/tokens in this example; you could still provide an initial mint via a script within the module, but it would prevent e.g. Bob from minting his own tokens.
The Daml language seems to respect the scoping, so why doesn’t the API?