mirror of
https://github.com/digital-asset/daml.git
synced 2024-11-10 00:35:25 +03:00
ebde049cc6
This follows up on #7066 and exposes the new underlying multi-key and multi-query stream functions through the React bindings. Following the same reasoning as in #7066, we therefore deprecate the existing functions (with no intention of removing them) as they become redundant. CHANGELOG_BEGIN * JavaScript Client Libraries: Updated React bindings to expose the recent addition of multi-key and multi-query streams in @daml/ledger. The singular versions are marked as deprecated as they have become redundant. The upgrade path for `useStreamQuery` is very straightforward: the query factory remains optional, but if specified it should return an array of queries instead of a single query. The array may be empty, which will return all contracts for that template (similar as not passing in a query factory). The return values of `useStreamQuery` and `useStreamQueries` are the same type. ``` useStreamQuery(T) --> useStreamQueries(T) useStreamQuery(T, () => query, ...) --> useStreamQueries(T, () => [query], ...) ``` The upgrade path for `useStreamFetchByKey` is only slightly more involved as the return type of `useStreamFetchByKeys` is a new type called `FetchByKeysResult` instead of the existing `FetchResult`. `FetchByKeysResult` differs from `FetchResult` in that it contains a `contracts` field with an array of contracts instead of a singular `contract` field. (It differs from `QueryResult` in that each element of the returned array can also be `null`, if there is no corresponding active contract.) Call sites can be updated as follows: ``` const {loading, contract} = useStreamFetchByKey(T, () => k, ...); --> const {loading, contracts} = useStreamFetchByKeys(T, () => [k], ...)); const contract = contracts[0]; ``` CHANGELOG_END |
||
---|---|---|
.. | ||
create-daml-app | ||
create-daml-app-test-resources | ||
empty-skeleton | ||
quickstart-java | ||
quickstart-scala | ||
skeleton | ||
BUILD.bazel | ||
default-dlint-yaml | ||
default-gitattributes | ||
default-gitignore | ||
README.txt |
These are template projects for `daml new`. Testing the create-daml-app template ==================================== While automated integration tests for the create-daml-app template are being built, we have the following manual testing procedure. Note that this is for testing against the head of the daml repo. For testing against a released SDK, you can skip past the package.json step and use `daml` instead of `daml-head` after installing the released version. First, build the SDK from head using the `daml-sdk-head` command. This gives an executable DAML assistant called `daml-head` in your path. Next, instantiate the `create-daml-app` template as follows: ``` daml-head new create-daml-app --template create-daml-app cd create-daml-app ``` Crucially, you'll need to add a package.json file at the root of the project for testing (this is not required when using the released SDK). It should look as follows, with the dummy paths here replaced by relative paths to locally built TypeScript libraries. (These need to be built from head using Bazel: ``` bazel build //language-support/ts/daml-types bazel build //language-support/ts/daml-ledger bazel build //language-support/ts/daml-react```) package.json: { "resolutions": { "@daml/types": "file:path/to/daml-types/npm_package", "@daml/ledger": "file:path/to/daml-ledger/npm_package", "@daml/react": "file:path/to/daml-react/npm_package" }, "private": true, "workspaces": [ "daml.js", "ui" ] } Now you can continue to build and run the project as described in create-daml-app/README.md, using `daml-head` instead of `daml`. Specifically, you should run the following in the root directory: ``` daml-head build daml-head codegen js .daml/dist/create-daml-app-0.1.0.dar -o daml.js daml-head start ``` Then in another terminal, navigate to `create-daml-app/ui/` and run: ``` yarn install yarn start ``` And check that the app works. Finally, terminate both the `daml start` and `yarn start` processes and run `yarn test` from the `ui` directory. All tests should pass.