How to use qualified template names in REPL queries?
- gyorgybalazsiOP 1
I’m running the paint agreement use case on Canton, and trying to query the
PaintHousecontract instances using DAML REPL, attached to a Canton participant node.The problem is that the package contains two
PaintHousetemplates, one in thePaintmodule and another in theSafePaintmodule.So I’m trying to use the qualified
Paint.PaintHousetemplate name in the REPL query, but keep running into a strange error message:balazsigyorgy@Orss-MacBook-Air ~ % daml repl --ledger-host=localhost --ledger-port=5021 /Users/balazsigyorgy/canton-0.18.2/dars/CantonExamples.dar --import CantonExamples daml> Some details <- find (\d -> d.displayName == Some "Alice") <$> listKnownParties daml> let alice = details.party daml> alice 'Alice::01e74ceb0405f555dc0b05e682bf1f57a75e499084d445176eea2354dad7291dbc' daml> ph <- query @Paint.PaintHouse alice daml> ph File: Line4.daml Hidden: no Range: 13:60-13:70 Source: typecheck Severity: DsError Message: Line4.daml:13:61: error: Ambiguous occurrence ‘PaintHouse’ It could refer to either ‘Paint.PaintHouse’, imported from ‘Paint’ at Line4.daml:10:1-12 or ‘SafePaint.PaintHouse’, imported from ‘SafePaint’ at Line4.daml:11:1-16 File: Line4.daml Hidden: no Range: 13:72-13:82 Source: typecheck Severity: DsError Message: Line4.daml:13:73: error: Ambiguous occurrence ‘PaintHouse’ It could refer to either ‘Paint.PaintHouse’, imported from ‘Paint’ at Line4.daml:10:1-12 or ‘SafePaint.PaintHouse’, imported from ‘SafePaint’ at Line4.daml:11:1-16 daml>I have already run the
PaintScenario.scScala script (see Getting Started — Canton 0.22.0 documentation), and the query using the Scala REPL returns the following result:@ participant1.ledger_api.acs.of_all().filter(_.templateId == "Paint.PaintHouse").map(_.arguments) res17: Seq[Map[String, Any]] = ListBuffer( Map("painter" -> "Bob::01d78c99e87c61d360930cf413c7d03dcbdd8882ad63d18dee2db1a20952c19b49", "houseOwner" -> "Alice::01e74ceb0405f555dc0b05e682bf1f57a75e499084d445176eea2354dad7291dbc") ) - cocreature 2
Hi @gyorgybalazsi, unfortunately I cannot reproduce this:
moritz@adjunction ~/D/c/d/CantonExamples> DAML_SDK_VERSION=1.5.0 daml repl .daml/dist/CantonExamples-0.18.2.dar --import CantonExamples --ledger-host localhost --ledger-port 6865 daml> p <- allocateParty "p" daml> query @PaintHouse p File: Line1.daml Hidden: no Range: 15:23-15:33 Source: typecheck Severity: DsError Message: Line1.daml:15:24: error: Ambiguous occurrence ‘PaintHouse’ It could refer to either ‘Paint.PaintHouse’, imported from ‘Paint’ at Line1.daml:10:1-12 or ‘SafePaint.PaintHouse’, imported from ‘SafePaint’ at Line1.daml:11:1-16 daml> query @Paint.PaintHouse p []Which SDK version are you using? I tried this with 1.5.0, the 1.5.0 snapshot used in the latest canton release as well as the latest 1.6.0 snapshot
1.6.0-snapshot.20200930.5312.0.b9a1905d. - gyorgybalazsi 1
cocreature:DAML_SDK_VERSION=1.5.0I didn’t modify the default SDK version of Canton
- gyorgybalazsi 1
cocreature:query @Paint.PaintHouse pCould you try running this and query-ing for a party which actually has a “Paint.Painthouse” contract? I think the problem occurs when you want to print out the non-empty result.
I have already run the
PaintScenario.scScala script (see Getting Started — Daml SDK 2.6.5 documentation). - cocreature 1
I’ve tried that as well but it seems to work just fine:
moritz@adjunction ~/D/c/d/CantonExamples> daml repl .daml/dist/CantonExamples-0.18.2.dar --import CantonExamples --ledger-host localhost --ledger-port 6865 DAML SDK 1.5.0 has been released! See https://github.com/digital-asset/daml/releases/tag/v1.5.0 for details. daml> p <- allocateParty "p" daml> query @Paint.PaintHouse p [] daml> submit p $ createCmd (Paint.PaintHouse p p) c<contract-id> daml> query @Paint.PaintHouse p [(<contract-id>,PaintHouse {painter = 'party-833d2323', houseOwner = 'party-833d2323'})] - gyorgybalazsi 1
If I create the contract your way, I get the same result as you. But if I run the Scala script according to the instructions in the docs, I get the error.
Anyways, now I know what is the correct way of using query in REPL.
- cocreature 2
Oh I see what the issue is:
daml> query @Paint.PaintHouse pworks fine and prints out the contratcs.
daml> cs <- query @Paint.PaintHouse p daml> csfails.
That’s definitely a bug, we’ll look into it and get back to you when it’s fixed.
- gyorgybalazsi 1
Yess, one more bug in my collection…
- cocreature 2
Hi @gyorgybalazsi, we’ve just merged the fix for this in https://github.com/digital-asset/daml/pull/7544 so it will land in next weeks snapshot (it’s probably not going to make it into 1.6 since it’s a bit too late for that).
- gyorgybalazsi 1
Thank you!
- cocreature 2
Hi @gyorgybalazsi,we’ve just released 1.7.0-snapshot.20201006.5358.0.0c1cadcf which should fix this issue.
- gyorgybalazsi 1
Thansks, will try!
- gyorgybalazsi 2
Perfect, thank you:
daml> alice <- allocatePartyWithHint "Alice" (PartyIdHint "alice") daml> painter <- allocatePartyWithHint "Painter" (PartyIdHint "painter") daml> bank <- allocatePartyWithHint "Bank" (PartyIdHint "bank") daml> iouCid <- submit bank $ createCmd $ Iou bank alice (Amount 100.0 "USD") [painter] daml> offerCid <- submit alice $ createCmd $ OfferToPaintHouseByOwner alice painter bank iouCid daml> submit painter $ exerciseCmd offerCid AcceptByPainter <contract-id> daml> [(cid,c)] <- query @Paint.PaintHouse alice daml> c PaintHouse {painter = 'painter', houseOwner = 'alice'} daml>