This is a relatively new feature of the TS bindings, available from Nov 30, 2020:
This PR adds TS bindings coverage for the party management methods of
the JSON API.
- [JavaScript Client Libraries] The Ledger object (returned by
useLedger
through the React bindings) has three new methods covering
the Party management API: getParties
allows users to, based on a
party id (or party ids, as the name suggests) fetch more information
about the party or check for its existence; listKnownParties
will
return a list of all known parties, and allocateParty
will allocate
a new party.
I could use this feature with the Create Daml App UI.
Also tried to use it with the Daml UI Template (GitHub - digital-asset/daml-ui-template), which uses
"@daml/ledger": "1.7.0",
"@daml/react": "1.7.0",
"@daml/types": "1.7.0",
It seems to me that the React UI Template doesn’t support yet the new TS bindings.
Am I right, or am I doing something wrong?
If I sinply include the useKnownParties
custom hook which works with Crete Daml App, I get error messages which indicate compatibility problems.
If I change manually the React bindings’ version, the useKnownParties
hook seems to work, but cannot see the contracts which are created by the init script.
1 Like
Hi @gyorgybalazsi,
That bullet point you reproduce comes from the Daml Connect 1.8 release notes, so it is expected that the feature was not available in 1.7 yet.
If I change manually the React bindings’ version, the useKnownParties
hook seems to work, but cannot see the contracts which are created by the init script.
As a rule of thumb it’s generally better to use the same version of Daml Connect throughout. So, rather than changing the React bindings’ version only, try bumping your Daml Connect version in daml.yaml
, rebuild your DAR file (daml build
), then regenerate the JS bindings (daml codegen js -o ...
).
If that doesn’t work for you, I’ll be happy to look into a minimal(-ish) reproduction case if you can provide one, ideally in the form of a GitHub repo and instructions on how to reproduce. Or just instructions on how to reproduce if you can do it fairly easily from the create-daml-app template.
1 Like
If I change the Daml Connect version number in the daml.yaml
file, and the @daml/ledger/
and @daml/package
version number in the package.json
file, delete the yarn.lock
file, and the --frozen-lockfile
option in the Makefile, it seems to work properly.
Previously it seemed not to work because I was experimenting with different party ids, and the window.localstorage
preserved the previous login name. After clearing the window.localstorage
it handles the users correctly.