daml
daml copied to clipboard
Calling interface choices in Script fails via JSON API
See https://discuss.daml.com/t/exercise-interface-choice-on-daml-script-with-json-api/7134.
Repro:
Script:
module Main where
import Daml.Script
import DA.Foldable (mapA_)
data VFoo = VFoo with
deriving (Eq, Show)
interface IFoo where
viewtype VFoo
c : Party
choice Bar : ()
controller (c this)
do return ()
template Foo
with
p : Party
where
signatory p
interface instance IFoo for Foo where
view = VFoo
c = p
test_foo p = do
submit p do createCmd Foo with ..
(cidList, _) <- unzip <$> queryInterface @IFoo p
mapA_ (\ cid -> submit p do exerciseCmd cid Bar) cidList
Script call:
daml script --dar .daml/dist/repro-0.0.1.dar --ledger-host http://localhost --ledger-port 7575 --json-api --script-name Main:test_foo --access-token-file token --input-file input.json
Decoded token:
{
"https://daml.com/ledger-api": {
"ledgerId": "sandbox",
"participantId": "sandbox",
"applicationId": "script",
"admin": true,
"actAs": ["sandbox::122022077a14b5f6d5b324727c5aabc2123c88c75f0e455811992f4ad5f81735e887"],
"readAs": []
}
}
input.json:
"sandbox::122022077a14b5f6d5b324727c5aabc2123c88c75f0e455811992f4ad5f81735e887"
Replace the participant Id as appropriate.
Assess how much work this will be. If it's more than a day, I would say to push back as this will be removed for 3.x anyway.
I think this could be done in a day. Would this need backporting to 2.8?