Thanks. useParty() worked
my question was very similar to
My Daml
template Network
with
operator : Party
where
signatory operator
controller operator can
nonconsuming InviteHealthClinic : ContractId HealthClinicInvitation
with
healthclinic : Party
do
create HealthClinicInvitation with healthclinic, operator
nonconsuming InviteCitizen : ContractId CitizenInvitation
with
citizen : Party
do
create CitizenInvitation with citizen, operatortemplate HealthClinicInvitation
with
operator : Party
healthclinic : Party
where
signatory operator
controller healthclinic can
AcceptInvitation : ContractId HealthClinicRole
do
create HealthClinicRole with healthclinic, operator
My react code: Report.js
export default function Report() {
const ledger = useLedger();
const assets = useStreamQuery (Main.Network);
const exerciseInviteHealthClinic = function(cid, operator, healthclinic ) {
ledger.exercise(Main.Network.InviteHealthClinic, cid, {operator: operator, healthclinic: healthclinic })};
const exerciseInviteCitizen = function(cid , citizen ) {
ledger.exercise(Main.Network.InviteCitizen, cid, citizen)};
const ops = useParty();
return (<> <Contracts contracts={assets.contracts} columns={[ ["ContractId", "contractId"], ["TemplateId", "templateId"], ["Operator", "payload.operator"] ]} actions={[
[“InviteHealthClinic”, (c, healthclinic ) => { exerciseInviteHealthClinic(c.contractId, {operator: ops, healthclinic: healthclinic}); }, “Healthclinic”],
]}
/>
</>
);
}
Is currently causing the following error
VM967:1 POST http://localhost:3000/v1/exercise 400 (Bad Request)
(anonymous) @ VM967:1
(anonymous) @ browser-ponyfill.js:516
fetch @ browser-ponyfill.js:453
(anonymous) @ index.js:178
step @ index.js:33
(anonymous) @ index.js:14
(anonymous) @ index.js:8
push…/node_modules/@daml/react/node_modules/@daml/ledger/index.js.__awaiter @ index.js:4
Ledger.submit @ index.js:174
(anonymous) @ index.js:350
step @ index.js:33
(anonymous) @ index.js:14
(anonymous) @ index.js:8
push…/node_modules/@daml/react/node_modules/@daml/ledger/index.js.__awaiter @ index.js:4
Ledger.exercise @ index.js:339
exerciseInviteHealthClinic @ Report.js:14
…
{errors: Array(1), status: 400}
errors: Array(1)
1. 0: ""JsonError: spray.json.DeserializationException: Can't read {
“operator”: {
“operator”: “Operator”,
“healthclinic”: “AtriumHealth”
}
} as DamlLfRecord c94a6ca42d2899213eb9634a997a173f12698d32c69781559e077163792aeddf:Main:InviteHealthClinic, missing field ‘healthclinic’"
2. length: 1 3. __proto__: Array(0)
- status: 400
- proto: Object