-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make multi-package-example, based heavily on upgrades-example (#20489) (
- Loading branch information
Showing
7 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
sdk/templates/multi-package-example/interfaces/daml.yaml.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
16
sdk/templates/multi-package-example/interfaces/daml/Asset.daml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
13
sdk/templates/multi-package-example/main/daml.yaml.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
packages: | ||
- ./interfaces | ||
- ./main | ||
- ./test |
14 changes: 14 additions & 0 deletions
14
sdk/templates/multi-package-example/test/daml.yaml.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 () |