The current code-gen supports encoding and decoding of contract **payload** data from and to JSON-LF format. However, it is currently missing facilities for encoding and decoding contract **keys**. This would be required by a user wishing to use codegen types to represent the content of the `contract_key` column returned by PQS.
This adds extra methods to the classes generated for templates with keys:
* static methods `keyJsonDecoder` and `keyFromJson`
* instance methods `keyJsonEncoder` and `keyToJson`
* Rename canton-3x to canton
* fix build
* fix BuildInfo for canton 3
* add reference drivers as a runtime dep to community_domain
* target 2.1 in interface-choices-valid
* run damlc integration tests with LF2
* fix the repl tests
* fix repl-functests
* fix package manager test
* disable V1 scala integration tests
* port the scala canton fixture to canton3
* fix JsonApiIt, using sleeps :/
* fix test-daml-packages and test-daml-ledger under //daml-assistant/daml-helper
* fix integration tests
* fix QuickstartTest.hs
* fix //daml-script/export/integration-tests/reproduces-transactions:test
* fix //daml-script/runner:tests
* fix Daml3ScriptDevIT
* fix Daml2ScriptTestRunner
* remove sleeps in functests now that a delay has been added to daml3-script's allocateParty
* fix //language-support/java/codegen:ledger-tests
* fix ScalaCodeGenIT
* remove useless sleep
* fix //language-support/ts/codegen/tests:build-and-lint-test
* remove redundant sleep and fix daml script
* fix //daml-assistant/daml-helper:test-tls
* fix CommandClientIT
* fix //daml-assistant/daml-helper:test-deployment
* Remove duplicate contract key test: not supported by canton 3.
run-all-tests: true
* fix //language-support/hs/bindings:test
run-all-tests: true
* small cleanups
run-all-tests: true
* clean up and fix compat tests
* fix build after rebase
run-full-compat: true
run-all-tests: true
Why?
This is a terrible introductory application. We have no expertise in web
development (it's terribly outdated and we don't have the knowledge to
update it), so steering newcomers in that direction is disputable at
best. This example (and the associated documentation) spends more time
discussing (a very old version of) TypeScript than Daml. The use-case
presented is not one that showcases the strength of either the Daml
language or the underlying Canton ledger. It's not even a distributed
application as it assumes a single ledger.
At best, this template presents Daml as a DDL for simple wep API
definitions, but one where the resulting generated code provides no
support for authentication, external API calls, or any common
server-side tasks like sending emails.
Why now?
As we start working in parallel on 2.9 and 3.0, we are faced with the
perspective of having to do two weekly snapshots and thus having to test
both of them. Removing create-daml-app from the 3.0 branch alleviates
the testing burden quite a bit.
Daml 3.0 will be a long-term effort, and we have plenty of time to figure
out what should replace create-daml-app for this new version. If this
template was bad at showcasing Daml 2 strength, it's an even worse fit
for Daml 3.
Note that this PR removes a lot of additional tests, notably
compatibility ones. They live on in the main-2.x branch, where
compatibility tests also run.
* update canton to 20240110.12220.0.ve226317e/2.9.0-snapshot.20240110.11694.0.vbbc5a08b/3.0.0-snapshot.20240110.12220.0.ve226317e
tell-slack: canton
* Fix hs-bindings from canton proto change
run-all-tests: true
---------
Co-authored-by: Azure Pipelines Daml Build <support@digitalasset.com>
Co-authored-by: Samuel Williams <samuel.williams@digitalasset.com>
* Resolve release version for sdk build checks
* lint
* lint
run-full-compat: true
* Simple test for using daml-script in release versions
* Fix build issues in tests using pSdkVersion
run-full-compat: true
* Fix build issues with DamlcIntegration
* fix bad sdk version being an invalid version
run-full-compat: true
* Fix the linux "mmap 4096 bytes at (nil): Cannot allocate memory" error
* Fix compat tests on Windows
run-full-compat: true
* test windows os correctly
run-full-compat: true
* temporarily disable canton_3x
run-full-compat: true
---------
Co-authored-by: Paul Brauner <paul.brauner@digitalasset.com>
Basically we remove the dependency of different components on "//language-support/scala/bindings" by:
- replacing com.daml.ledger.api.refinements.ApiTypes.Party by com.daml.lf.data.Ref.Party
- replacing com.daml.ledger.api.refinements.ApiTypes.ApplicationId by Option[com.daml.lf.data.Ref.ApplicationId] (here we use option as ApiTypes.ApplicationId allows empty string while Ref.ApplicationId does not).
- adding rounding logic for timestamp in com.daml.lf.data.Time.Timestamp and use it instead of the one from com.daml.api.util.TimestampConversion
Note we did not clean daml-sript export as it have never pass the alpha stage and will be dropped with the 3.x fork.
ContractMetadata is deprecated and has been replaced with an opaque byte array, in a field called `created_event_blob` in the api protos, and a column called `metadata` in Scribe. I don't think we need a wrapper type for this data. When reading out of scribe, we'd typically be using it to build a `DisclosedContract`, and we have a Java type for that, so I think that would be the anchor we'd use when reading.
* ensure we java-sanitise the names of type variables when building identifiers for JSON decoding and encoding these types
* avoid name clashes (obscuring) when the package-qualified name of a type begins with the same identifier as a field name
* initial implementation supporting version splitting in assistant
stubbed out implementations of resolveReleaseVersion/other resolution
* implement resolveReleaseVersionFromGithub
* continue work on fixing SDK/release version split
* First commit that successfully runs `daml-head install <split version>`
* fix tests
* Ignore snapshot/metadata for isHeadVersion
* remove log debugging
* Fix tests for getSdk
* refactor DA.Daml.Project.Types.defaultSdkPath
* enable incremental changes to version cache
* Allow resolveReleaseVersionFromGithub to fail via Either
* Split getSdkVersionFromSdkPath into get{Sdk,Release}VersionFromSdkPath
* Add resolveReleaseVersionFromDamlPath/Github to resolveReleaseVersion
* Add mock sdk config with version
* Remove getInstalledSdkVersions dependency on Cache
* add override for github version api endpoint, useful for mocking
* Add alternate-download to provide alternate tarball install resolution
* initial work on comprehensive autotester
* Copyright header
* fix build generation to have valid Main.daml
* improve error message for check_daml_install_nonzero
* Make killing miniserve processes more robust
* remove breakpoint
* Implement `daml build` tests
* Solve TODO in installExtracted to resolve sourceSdkVersion coherently
Supply useful error message with it.
* Return SdkVersion from sdkVersionFromReleaseVersion for typechecking
* Finish tests for tarball build, drop installed_already_behaviour
* Try to force-reload cache on tar failure, fix `Possible fix:` notes
* Add AllowInstallNonRelease as a flag
* Test allow_nonrelease, refactor, clean up setup_sandbox
* Move no_cache_override_github_endpoint API response into file
* Remove dead code, vestigial code
* Remove TODOs that no longer are relevant
* fix iAllowInstallNonRelease in InstallOptions for autoInstall
* Refactor alternateVersionLocation
* (Try to) lint language-support/ts/codegen/BUILD.bazel
* fix daml-assistant/test
* Enable allow_nonrelease post-build checks
* Remove writeFile debugging from DA.Daml.Assistant.Version
* Replace ../test-daml-yaml-install/test.sh with test-all-installs.sh
* lint
* more lint
run-full-compat: true
* Stop tracking API response in test-daml-yaml-install
* Move ReleaseResolution into Version
* remove extra deps, fixes daml-project-config-cabal-file-matches
* Move InstallLocation to minimize changes to DA.Daml.Project.Types
run-full-compat: true
* Create cachePath in daml-assistant tests that need it
* Bind to unused ports in test-all-installs.sh
run-full-compat: true
* Override via files instead of just URLs
run-full-compat: true
* Remove unused RELEASES_ENDPOINT
* Use dict keys instead of hardcoding in test-all-installs listing
* Refactor to remove check_daml_install_from_tarball_after_cache_reload
* Improve comment on update_cache
* Move shift before cases
* Add comment for unsafeParseReleaseVersion
* Rename unsafeParseReleaseVersion into unsafeParseOldReleaseVersion
* remove done todo
* Add some hungarian notation to resolveReleaseVersionFromDamlPath
* drop redundant let
* Define ordering over ReleaseVersion
run-full-compat: true
* use sdkVersion for codegen
* Use `urls` attribute in http_file, `url` is unsupported on Windows (!)
run-full-compat: true
* Remove unnecessary check for cache reload
run-full-compat: true
* Try use daml executable directly without daml-sdk-0.0.0
run-full-compat: true
* try force daml.exe to daml
run-full-compat: true
* Use daml.exe when windows is detected
* add windows tarballs for snapshots
* Fix most tests on windows, "line too long" breaks some tarball tests
run-full-compat: true
* Point to more recent snapshot post Moises's fixes
* Add os-specific tarball paths and alternate-download
run-full-compat: true
* Fix windows autoinstall with 0.0.0
run-full-compat: true
* Fix error message, remove daml_install_output catching
* Detect "The input line is too long" in other post_failed commands
* Fix missing releases endpoint, handle "cannot find the path specified"
run-full-compat: true
* Automated renames by bash script
This commit is exclusively contains changes by the bash script.
For the bash script is present at the pull request.
* Manual pekko migration changes
* adapt fully qualified name references
* adapt pekko package declarations
* adapt bazel files with dependency changes
* adapt canton pekko lib shade_rule
* adapt logger configuration declarations
* pin maven dependencies
* revert incorrect changes by script to compatibility module
Workarounds for further TODOs:
* disable http-json-perf and libs-scala/gatling-utils modules to maintain clean pekko dependencies (without akka)
* disable GraphQLSchemaSpec test (sangria library needs to be upgraded)
* Formatting
* Make `TransactionFilter.toProto` public
We are in the process of enabling the usage of the Java bindings from the
Canton Console. In order to do so in a backward-compatible fashion, we
often rely on existing Scala code and use the Protobuf representation as
a bridge between the two. Unfortunately the fact that the `toProto` method
on `TransactionFilter`s is package-private forced us to temporarily add
a conversion method located within the package that re-exported it publicly
for usage as part of the Canton Console. This change should enable us to
remove this workaround. I would be happy to hear other possible approaches
to consider.
* Update subclass
* pin dependencies to json and add missing dep
* fix cyclic dep
* remove unused dep
* add missing dep to //ledger-api/testing-utils:testing-utils
* remove unused dep in //ledger/ledger-api-auth:ledger-api-auth
* remove more unused deps
* more dep fixes
* yet more dep fixing
* more fixing..
* more of the same
* hopefully the last deps to fix
* Bump the version of protobuf and fix everything that depends on it. Took shortcuts that I need to fix in a next commit, but would like to run the CI on this now that it compiles
* don't error out in the grpc-haskell patch
* remove obsolete patch
* patch absl to compile on mingw
* Add a patch to recognize the compiler
* Define _DNS_SD_LIBDISPATCH for macOS gRPC
* bump netty_tcnative_version according to https://github.com/grpc/grpc-java/blob/master/SECURITY.md#netty
* pin maven deps
* Fix macos linking errors 'dyld[xxx]: missing symbol called'
* Skip Darwin frameworks in package-app.sh
* pin stackage packages
* pin stackage windows deps
* use the netty version agreed on
* bump the windows global cache to try and debug the upb issue
* restart the CI after timeout
* clean up
* disable failing tests for now
* comment out unused code
* reset the windows machine name to 'default'
---------
Co-authored-by: Moisés Ackerman <6054733+akrmn@users.noreply.github.com>
* Adapt JSON API write path to the new explicit disclosure Ledger API interface
* Address review comments
* Switch to vanilla Base64 for createdEventBlob instead of Base64Url
* update TypeScript bindings of DisclosedContract to use the createdEventBlob field instead of payload, payloadBlob and metadata, and short-circuit a test which depends on canton populating the createdEventBlob field
* get TypeScript integration tests to use transaction service to get created_event_blob data
---------
Co-authored-by: = <=>
Fixes https://github.com/digital-asset/daml/issues/17692
Fixes the error from the `jsonEncoder` method (which was about `javac` mis-interpreting a method reference), and the warnings in `toValue`, `valueDecoder` and the initialiser for `__enums$`, which did not need to qualify the static identifiers by class name.
* replace community canton snapshot with our bazel-built canton deploy jar
* add VERSION to the resources of the jar
* fix canton-test-runner-with-dependencies-script
* add resources to community_common
* Update test-common/canton/it-lib/src/main/com/daml/CantonFixture.scala
Co-authored-by: Remy <remy.haemmerle@daml.com>
---------
Co-authored-by: Remy <remy.haemmerle@daml.com>
To avoid excess duplicate code-gen, I put the implementation of `toJson` into the parent interface `DefinedDataType`, and leverage the `jsonEncoder()` in each generated subclasses. However custom datatypes with type parameters have a different signature of `toJson(...)` as they need to pass in arguments for encoders for each type arg, so we generate a custom `toJson(...)` for those classes. I also do a static import of the `JsonLfEncoder.apply` method, as a useful uniform syntax for calling either `Function` objects or method references (e.g. `JsonLfEncoder::bool`). That required propagating the static imports up from the various methods that need them, and adding them at the `JavaFile.Builder` level.
I changed all the integration tests that did `fromJson` from a hard-coded string, into round-trip tests a la `Foo.fromJson(foo.toJson())`, now that we have `toJson`.
Also add a benchmark, which can be run with
```
bazel run //language-support/java/codegen:to-json-bench
```
Locally I currently get these results.
```
# Run complete. Total time: 00:00:56
Benchmark Mode Cnt Score Error Units
ToJsonBench.enummodBox thrpt 10 8138043.644 ± 197223.048 ops/s
ToJsonBench.enummodColoredTree thrpt 10 3132500.885 ± 23677.832 ops/s
ToJsonBench.enummodOptionalColor thrpt 10 10762883.904 ± 116865.102 ops/s
ToJsonBench.genmapmodBox thrpt 10 1554965.578 ± 4956.210 ops/s
```
The `Score` is the number of times the sample values can be converted to json per second.