Skip to content

Commit

Permalink
Make multi-package-example, based heavily on upgrades-example (#20489) (
Browse files Browse the repository at this point in the history
  • Loading branch information
dylant-da authored Dec 17, 2024
1 parent 22e0ced commit 33fcd02
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 0 deletions.
11 changes: 11 additions & 0 deletions sdk/templates/multi-package-example/interfaces/daml.yaml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# for config file options, refer to
# https://docs.daml.com/tools/assistant.html#project-config-file-daml-yaml

sdk-version: __VERSION__
name: __PROJECT_NAME__-interfaces
source: daml
version: 1.0.0
dependencies:
- daml-prim
- daml-stdlib
- daml-script-lts
16 changes: 16 additions & 0 deletions sdk/templates/multi-package-example/interfaces/daml/Asset.daml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module Asset where

data View = View
{ assetOwner : Party
, description : Text
}
deriving (Show, Eq)

interface Asset where
viewtype View
getOwner : Party

nonconsuming choice GetView : View
controller (getOwner this)
do
pure (view this)
13 changes: 13 additions & 0 deletions sdk/templates/multi-package-example/main/daml.yaml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# for config file options, refer to
# https://docs.daml.com/tools/assistant.html#project-config-file-daml-yaml

sdk-version: __VERSION__
name: __PROJECT_NAME__-main
source: daml
version: 1.0.0
dependencies:
- daml-prim
- daml-stdlib
- daml-script-lts
data-dependencies:
- ../interfaces/.daml/dist/__PROJECT_NAME__-interfaces-1.0.0.dar
16 changes: 16 additions & 0 deletions sdk/templates/multi-package-example/main/daml/Main.daml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module Main where -- V1

import Asset (Asset)
import qualified Asset

template IOU with
issuer: Party
owner: Party
value: Int
name: Text
where
signatory issuer, owner

interface instance Asset for IOU where
view = Asset.View owner ("IOU (" <> name <> ")")
getOwner = owner
4 changes: 4 additions & 0 deletions sdk/templates/multi-package-example/multi-package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
packages:
- ./interfaces
- ./main
- ./test
14 changes: 14 additions & 0 deletions sdk/templates/multi-package-example/test/daml.yaml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# for config file options, refer to
# https://docs.daml.com/tools/assistant.html#project-config-file-daml-yaml

sdk-version: __VERSION__
name: __PROJECT_NAME__-test
source: daml
version: 1.0.0
dependencies:
- daml-prim
- daml-stdlib
- daml-script-lts
data-dependencies:
- ../interfaces/.daml/dist/__PROJECT_NAME__-interfaces-1.0.0.dar
- ../main/.daml/dist/__PROJECT_NAME__-main-1.0.0.dar
16 changes: 16 additions & 0 deletions sdk/templates/multi-package-example/test/daml/Test.daml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module Test where

import Daml.Script
import Asset (Asset)
import qualified Asset
import qualified Main
import DA.Assert

main : Script ()
main = do
a <- allocateParty "Alice"
mainCid <- a `submit` createCmd Main.IOU with owner = a, issuer = a, value = 5, name = "C1"
let assetCid = toInterfaceContractId @Asset mainCid
view <- a `submit` exerciseCmd assetCid Asset.GetView
"IOU (C1)" === view.description
pure ()

0 comments on commit 33fcd02

Please sign in to comment.