Commit Graph

967 Commits

Author SHA1 Message Date
Stephen Compall
b84ce35982
@hidden does not take an argument (#15461) 2022-11-07 11:20:45 -05:00
Chun Lok Ling
d7d3bc28d6
Module collision check on generated item only (#15440)
* do the module collision check on generated item only

* Revert "do the module collision check on generated item only"

This reverts commit a6a38425ab.

* added test for detectModuleCollisions

* added test to reproduce issue #15341

* Revert "Revert "do the module collision check on generated item only""

This reverts commit cd4c5a24fd.

* fix test case

* use `daml.lf.language.Reference.Module` instead

* add change log

CHANGELOG_BEGIN
Bug fix: Module name collision check performed on modules which is not to be generated #15340 #15341
CHANGELOG_END

* remove debug log

* Minor renaming

* refine name test case name

* add comment

* format

Co-authored-by: Fayi Femi-Balogun <fayimora.femibalogun@digitalasset.com>
2022-11-04 17:04:20 +00:00
Chun Lok Ling
b77a4552d1
Use typed acstransaction streams in quickstart java examples (#15363)
* Added new method using contractUtil instead of filter so that creation of filter is not necessary in IouMain.

* public fields instead of private fields with getters

* delete getContracts

* var

* move ContractUtil to java binding

* to String

* update doc

* address comments

* address comment

* add change log

CHANGELOG_BEGIN
change quickstart java example to use typed acs stream and transaction.
CHANGELOG_END

* rename to response

* format

* update line number
2022-11-01 19:22:12 +00:00
Stephen Compall
7ab367b0e3
call library functions instead of generating code (#15401)
* factor variant case handling to utility function

* factor record case handling to utility function

* remove unused import; reformat

* full internal api notes

CHANGELOG_BEGIN
CHANGELOG_END
2022-11-01 11:01:56 -04:00
Stephen Compall
68e04a4e8b
getContractTypeId on Template and Contract (#15367)
* add getContractTypeId to Contract

* add getContractTypeId to Template

* generate getCompanion methods for every Template

* hide ContractId#getCompanion

* test getting from interface Contract

* test getting from template and template contract

* add changelog

CHANGELOG_BEGIN
- [Java codegen] Template payloads and contract instances (including for
  interface views) now support a ``getContractTypeId`` method that
  returns the template or interface ID.
CHANGELOG_END
2022-10-27 08:45:38 -04:00
Chun Lok Ling
fd9676754c
Add Update<R> to exercise and create method result types in Java codegen (#15193)
* pre

* address Stephen's comments

* get command from Update<R>

* to public

* generateDeprecatedFlattenedStaticExerciseByKeyMethod

* Ensure interface generation uses package prefixes

CHANGELOG_BEGIN
- [BUGFIX] Interface generation now respects package prefixes argument. This means generated interfaces will now be placed in the right subpackages.
CHANGELOG_END

* packagePrefixes

* fix what exercise* returning update breaks

* doc

* format

* WIP

* address comments

* compile

* added 2 utility methods in CommandClient for getting the result of submitted commands to demonstrate value of Update R

* address some comments

* update line number

* rename

* fold for create and exercise cases

* move transaction logic to fold

* revert config

* argTypeDecoder

* add internal api doc

* rename to Choice

* quickstart doc

* use update

* address comment

* address comment on compactability issue

* move abstract static class FoldUpdate<Z>  to Update<>

* change command clients to use List<? extends HasCommands> instead of List<Command>

* move fold to update

* compare commands

* Update docs/source/app-dev/bindings-java/quickstart.rst

Co-authored-by: Raymond Roestenburg <98821776+ray-roestenburg-da@users.noreply.github.com>

* address comments

* address comments

* add changelog

CHANGELOG_BEGIN
- [Java codegen] Replace return type to Update<R> of exercise and create methods in Java codegen
CHANGELOG_END

Co-authored-by: Fayi Femi-Balogun <fayimora.femibalogun@digitalasset.com>
Co-authored-by: Raymond Roestenburg <98821776+ray-roestenburg-da@users.noreply.github.com>
2022-10-26 14:53:06 +01:00
Chun Lok Ling
1730a96515
javapoet space instead of literally space (#15326)
* javapoet space instead of literally space

* javapoet space instead of literally space

* add change log

CHANGELOG_BEGIN
CHANGELOG_END
2022-10-24 20:21:45 +01:00
fayi-da
e3dcaf8aaf
Hide internal APIs (#15325)
* Hide internal APIs

CHANGELOG_BEGIN
CHANGELOG_END

* Formatting

CHANGELOG_BEGIN
CHANGELOG_END
2022-10-24 16:49:53 +01:00
tudor-da
1a4ef5b238
Revert "Upgrade dependencies to their latest stable release (#15216)" (#15309)
This reverts commit 1454497f

changelog_begin
changelog_end
2022-10-24 08:33:37 +02:00
Stephen Compall
5ed5658724
rename ChoiceMetadata to Choice (#15295)
* rename ChoiceMetadata to Choice

CHANGELOG_BEGIN
- [Java codegen] The (new since 2.4) ``ChoiceMetadata`` class has been
  renamed to ``Choice``.
CHANGELOG_END

* replace ChoiceMetadata with Choice in codegen docs
2022-10-19 19:01:26 +00:00
Moisés Ackerman
6ef040743f
Support interface choices in daml ledger export (#15189)
* Rename test //daml-script/export/integration-tests/golden:{export-=>}values

* Switch 'daml_ledger_export_test' to use 'run' instead of 'run-legacy-cli-config'

* Extract 'encodeImports' from 'encodeModuleHeader'

* Sort import list in 'daml ledger export'

* Add 'dev' argument to 'daml_ledger_export_test'

* Add interfaceId to ExercisedSelector

* Extract 'encodeExercisedEvent' from 'encodeCmd'

* Split 'encodeCid' into 'encodeCid{Expr,Pat}'

* 'CreatedContract' field 'tplId' now has type 'TemplateId'

* Specialize CreatedContract{=>WithPath}

* 'treeEventCreatedConsumedCids' returns Seq[SimpleCreatedContract] instead of Set[ContractId]

* Change type of 'SimpleCommand' field 'contractId' to 'SimpleCreatedContract'

* Coerce ContractIds to underlying template type

* Use interface ContractId in encodeExercisedEvent if present

* Add test //daml-script/export/integration-tests/golden:interface-choices

* Fix encoding of getAnyChoiceTemplateTypeRep in daml-script converter

* Set getAnyChoiceTemplateTypeRep to interfaceId if available

* fromExercised uses choice instead of templateId to find subtree

fromExercised uses exercised.argument.templateTypeRep instead of exercised.contractId.templateId

Previously it used exercised.contractId.templateId, but now it uses
exercised.argument.getAnyChoiceTemplateTypeRep, which corresponds
to the TemplateTypeRep of the {template,interface} that defined the choice.

* TestData.Exercised now takes a more flexible TestData.Choice argument

* Add unit tests for encoding of exercise of interface choice

* Apply code review suggestions

* sealed {trait=>abstract class} CreatedContract

* Use List instead of Seq

* Use ::= instead of :+= and ++=

changelog_begin
- [Daml export] Added support for interface choices (#15189)
- [Daml export] Export.daml imports are now sorted alphabetically
changelog_end

Co-authored-by: Stephen Compall <stephen.compall@daml.com>
2022-10-19 10:43:04 +02:00
Stephen Compall
7bfeada75c
replace x -> d.decode(x) with d in Java codegen output (#15267)
* remove accessor references from the decision branches of extractor

CHANGELOG_BEGIN
CHANGELOG_END

* eta-reduce all recursively-summoned ValueDecoders

* add more whitespace
2022-10-18 10:31:14 -04:00
Gerolf Seitz
1454497f3a
Upgrade dependencies to their latest stable release (#15216)
The outdated dependencies where determined by running
`bazel run @maven//:outdated`.

Not all dependencies are brought up to the latest version available on
Maven Central, for the following reasons:

Nobody dares to touch DB:
  com.oracle.database.jdbc:ojdbc8 [19.14.0.0 -> 21.7.0.0]
  com.oracle.database.jdbc.debug:ojdbc8_g [19.14.0.0 -> 21.7.0.0]
  com.h2database:h2 [2.1.210 -> 2.1.214]
  org.flywaydb:flyway-core [8.4.1 -> 9.4.0]

License issues beyond version 2.6.x:
  com.typesafe.akka:akka-actor_2.13 [2.6.18 -> 2.7.0-M3]
  com.typesafe.akka:akka-actor-testkit-typed_2.13 [2.6.18 -> 2.7.0-M3]
  com.typesafe.akka:akka-actor-typed_2.13 [2.6.18 -> 2.7.0-M3]
  com.typesafe.akka:akka-http_2.13 [10.2.8 -> 10.4.0-M1]
  com.typesafe.akka:akka-http-spray-json_2.13 [10.2.8 -> 10.4.0-M1]
  com.typesafe.akka:akka-http-testkit_2.13 [10.2.8 -> 10.4.0-M1]
  com.typesafe.akka:akka-slf4j_2.13 [2.6.18 -> 2.7.0-M3]
  com.typesafe.akka:akka-stream_2.13 [2.6.18 -> 2.7.0-M3]
  com.typesafe.akka:akka-stream-testkit_2.13 [2.6.18 -> 2.7.0-M3]
  com.typesafe.akka:akka-testkit_2.13 [2.6.18 -> 2.7.0-M3]

Not a stable release:
  com.chuusai:shapeless_2.13 [2.3.3 -> 2.4.0-M1]
  io.circe:circe-core_2.13 [0.14.3 -> 0.15.0-M1]
  io.circe:circe-generic_2.13 [0.14.3 -> 0.15.0-M1]
  io.circe:circe-parser_2.13 [0.14.3 -> 0.15.0-M1]
  org.scalameta:munit_2.13 [0.7.29 -> 1.0.0-M6]
  org.scalactic:scalactic_2.13 [3.2.14 -> 3.3.0-SNAP3]
  org.scalatest:scalatest_2.13 [3.2.14 -> 3.3.0-SNAP3]
  org.scalatestplus:scalacheck-1-15_2.13 [3.2.11.0 -> 3.3.0.0-SNAP3]
  org.scalatestplus:selenium-3-141_2.13 [3.2.10.0 -> 3.3.0.0-SNAP3]
  org.scalatestplus:testng-6-7_2.13 [3.2.10.0 -> 3.3.0.0-SNAP3]
  org.tpolecat:doobie-core_2.13 [0.13.4 -> 1.0.0-RC2]
  org.tpolecat:doobie-hikari_2.13 [0.13.4 -> 1.0.0-RC2]
  org.tpolecat:doobie-postgres_2.13 [0.13.4 -> 1.0.0-RC2]
  com.fasterxml.jackson.core:jackson-core [2.13.4 -> 2.14.0-rc2]
  com.fasterxml.jackson.core:jackson-databind [2.13.4 -> 2.14.0-rc2]

Netty + boringssl + grpc + protobuf need be kept in sync, and the latest
versions also aren't stable releases:
  io.netty:netty-buffer [4.1.79.Final -> 5.0.0.Alpha2]
  io.netty:netty-codec-http2 [4.1.79.Final -> 5.0.0.Alpha2]
  io.netty:netty-handler [4.1.79.Final -> 5.0.0.Alpha2]
  io.netty:netty-handler-proxy [4.1.79.Final -> 5.0.0.Alpha2]
  io.netty:netty-resolver [4.1.79.Final -> 5.0.0.Alpha2]
  com.google.protobuf:protobuf-java [3.21.7 -> 4.0.0-rc-2]

Scalaz changed a few annoying things in 7.3, so let's stick to 7.2:
  org.scalaz:scalaz-core_2.13 [7.2.34 -> 7.4.0-M12]
  org.scalaz:scalaz-scalacheck-binding_2.13 [7.2.34-scalacheck-1.15 -> 7.4.0-M12]
  org.scalacheck:scalacheck_2.13 [1.15.4 -> 1.17.0]

Determined by the rules_scala:
  org.scala-lang:scala-library [2.13.8 -> 2.13.10]

CHANGELOG_BEGIN
Upgraded to the latest stable version of the following JVM dependencies:

ch.qos.logback:logback-classic:1.4.4
ch.qos.logback:logback-core:1.4.4
com.auth0:java-jwt:4.1.0
com.auth0:jwks-rsa:0.21.2
com.fasterxml.jackson.core:jackson-core:2.13.4
com.fasterxml.jackson.core:jackson-databind:2.13.4
com.github.ben-manes.caffeine:caffeine:3.1.1
com.github.pathikrit:better-files_2.13:3.9.1
com.github.pureconfig:pureconfig-core_2.13:0.17.1
com.github.pureconfig:pureconfig-generic-base_2.13:0.17.1"
com.github.pureconfig:pureconfig-generic_2.13:0.17.1
com.github.pureconfig:pureconfig_2.13:0.17.1
com.github.scopt:scopt_2.13:4.1.0
com.google.code.gson:gson:2.9.1
com.lihaoyi:pprint_2._13:0.8.0"
com.lihaoyi:sourcecode_2.13:0.3.0
com.sparkjava:spark-core:2.9.4
com.squareup:javapoet:1.13.0
com.storm-enroute:scalameter-core_2.13:0.21
com.storm-enroute:scalameter_2.13:0.21
com.thesamet.scalapb:scalapb-json4s_2.13:0.12.0
com.typesafe.scala-logging:scala-logging_2.13:3.9.5
com.zaxxer:HikariCP:5.0.1
commons-io:commons-io:2.11.0
eu.rekawek.toxiproxy:toxiproxy-java:2.1.7
io.circe:circe-core_2.13:0.14.3
io.circe:circe-generic-extras_2.13:0.14.2
io.circe:circe-generic_2.13:0.14.3
io.circe:circe-parser_2.13:0.14.3
io.circe:circe-yaml_2.13:0.14.1
io.github.paoloboni:spray-json-derived-codecs_2.13:2.3.9
io.reactivex.rxjava2:rxjava:2.2.21
io.spray:spray-json_2.13:1.3.6
javax.annotation:javax.annotation-api:1.3.2
javax.ws.rs:javax.ws.rs-api:2.1.1
junit:junit-dep:4.11
junit:junit:4.13.2
net.logstash.logback:logstash-logback-encoder:7.2
org.apache.commons:commons-lang3:3.12.0
org.apache.commons:commons-text:1.10.0
org.awaitility:awaitility:4.2.0
org.checkerframework:checker-qual:3.26.0
org.checkerframework:checker:3.26.0
org.codehaus.janino:janino:3.1.8
org.freemarker:freemarker-gae:2.3.31
org.jline:jline-reader:3.21.0
org.jline:jline:3.21.0
org.junit.jupiter:junit-jupiter-api:5.9.1
org.junit.jupiter:junit-jupiter-engine:5.9.1
org.junit.platform:junit-platform-engine:1.9.1
org.junit.platform:junit-platform-runner:1.9.1
org.mockito:mockito-core:4.6.1
org.mockito:mockito-inline:4.6.1
org.mockito:mockito-scala_2.13:1.17.12
org.pcollections:pcollections:3.2.0
org.playframework.anorm:anorm-akka_2.13:2.7.0
org.playframework.anorm:anorm_2.13:2.7.0
org.postgresql:postgresql:42.5.0
org.reactivestreams:reactive-streams-tck:1.0.4
org.reactivestreams:reactive-streams:1.0.4
org.reflections:reflections:0.10.2
org.sangria-graphql:sangria-ast_2.13:3.4.0
org.sangria-graphql:sangria-core_2.13:3.4.0
org.sangria-graphql:sangria-derivation_2.13:3.4.0
org.sangria-graphql:sangria-parser_2.13:3.4.0
org.sangria-graphql:sangria-spray-json_2.13:1.0.3
org.scala-lang.modules:scala-parallel-collections_2.13:1.0.4
org.scalactic:scalactic_2.13:3.2.10
org.scalameta:munit_2.13:0.7.29
org.scalatest:scalatest_2.13:3.2.10
org.scalatestplus:scalacheck-1-15_2.13:3.2.10.0
org.scalatestplus:selenium-3-141_2.13:3.2.10.0
org.scalatestplus:testng-6-7_2.13:3.2.10.0
org.scalaz:scalaz-core_2.13:7.2.34
org.scalaz:scalaz-scalacheck-binding_2.13:7.2.34-scalacheck-1.15
org.seleniumhq.selenium:selenium-java:4.5.0
org.slf4j:slf4j-api:2.0.3
org.slf4j:slf4j-simple:2.0.3
org.testng:testng:6.7
org.typelevel:cats-core_2.13:2.8.0
org.typelevel:cats-kernel_2.13:2.8.0
org.typelevel:cats-laws_2.13:2.8.0
org.typelevel:paiges-core_2.13:0.4.2
org.wartremover:wartremover_2.13.8:3.0.6
org.xerial:sqlite-jdbc:3.39.3.0
CHANGELOG_END
2022-10-18 08:50:23 +02:00
Remy
3622518ed6
[HS bindings] disable flaky tests (#15233)
CHANGELOG_BEGIN
CHANGELOG_END
2022-10-13 16:07:03 +02:00
pbatko-da
e766b5d333
[DPP-1219] Organize packages in participant-local-store Bazel package (#15206)
changelog_begin
changelog_end
2022-10-13 09:58:09 +02:00
Chun Lok Ling
74dd242984
Typed ACS and transaction streams for Java codegen (#15159)
* added transactionFilter

* move transactionFilter to `TransactionFilter`

* fromCreatedEvent

* format

* added getTransaction with contract type companion

* ACS using contract type companion

* position

* add change log

CHANGELOG_BEGIN
CHANGELOG_END

* Ct

* Ct

* format

* better exception

* fixed test cases

* added java doc and rename method to GetContracts

* address Stephen's comments

* address Stephen's comments

* address Stephen's comments

* remove unused import

* format

* address Stephen's comments

* address Stephen's comments

* Make some codegen code to be java 8 compatible; Modify IouMain to use the new getActiveContracts. to address Stephen's comments

* use 1.11, no need to be java 8 compatible

* revert

* 11 not 1.11
2022-10-12 21:01:01 +01:00
fayi-da
ae70c97390
Ensure interface generation uses package prefixes (#15215)
* Ensure interface generation uses package prefixes

CHANGELOG_BEGIN
- [BUGFIX] Interface generation now respects package prefixes argument. This means generated interfaces will now be placed in the right subpackages.
CHANGELOG_END

* Prove that we get an error if interface is generated in the wrong directory

Command: bazel build //language-support/java/codegen:test-daml-java.jar

Error:
bazel-out/darwin_arm64-opt/bin/language-support/java/codegen/_javac/test-daml-java.jar/libtest-daml-java.jar_tmp/blah/ut/retro/InterfaceRetro.java:24: error: cannot find symbol
  public static final ChoiceMetadata<ut.retro.InterfaceRetro, Transfer, ut.retro.InterfaceRetro.ContractId> CHOICE_Transfer =
                                             ^
  symbol:   class InterfaceRetro
  location: package ut.retro
bazel-out/darwin_arm64-opt/bin/language-support/java/codegen/_javac/test-daml-java.jar/libtest-daml-java.jar_tmp/blah/ut/retro/InterfaceRetro.java:24: error: package ut.retro.InterfaceRetro does not exist
  public static final ChoiceMetadata<ut.retro.InterfaceRetro, Transfer, ut.retro.InterfaceRetro.ContractId> CHOICE_Transfer =

* Revert "Prove that we get an error if interface is generated in the wrong directory"

This reverts commit cc8612a8a3.
2022-10-12 16:13:06 +00:00
Stephen Compall
d03ed9c66b
add missing PrimitiveValueDecoders (#15195)
* add List, Optional, ContractId, TextMap primitive decoders

CHANGELOG_BEGIN
CHANGELOG_END

* add fromNumeric and fromGenMap

* generate less code for list, optional

* allow newline in assignment

* generate less code for contract ID

* generate less code for textmap

* generate less code for genmap

* use fromNumeric

* extra test for an indirect case

* javadoc fromTextMap, fromGenMap, impossible

* example of building value decoders with derived combinators
2022-10-12 09:46:25 -04:00
Stephen Compall
0d36c0ac17
javadocs for javaapi.data.codegen (#15209)
* link to #15207
* javadoc for ContractTypeCompanion and ChoiceMetadata
* link to #15208

CHANGELOG_BEGIN
CHANGELOG_END
2022-10-11 09:26:28 -04:00
fayi-da
d11704018a
Provide contract choice metadata (#15116)
* #13766 initial implementation of choice metadata for templates

* #13766 initial implementation of choice metadata for interfaces

* #13766 Add marker type to ContractTypeCompanion

* #13766 Minor type fix

* Cleanup after merge with main

* Temporary fix for package prefixes

* Format java files, rename Maker -> ContractType in ContractTypeCompanion

* Add documentation and tests

* Complete choice metadata implementation

CHANGELOG_BEGIN
- Add new representation of a choice, ChoiceMetadata.
- Generated templates and interfaces now include fields for each available choice. These fields will have a ChoiceMetadata type and will be called CHOICE_N, where N represents the choices' name.
CHANGELOG_END

* Update docs and cleanup tests
2022-10-07 20:54:43 +00:00
Stephen Compall
df2dd37735
mark parts of Java bindings final (#15173)
* mark several javaapi.data models final
* PrimitiveValueDecoders are final; utility classes should not be constructed
* replace Bool constructor with new #of static method

CHANGELOG_BEGIN
- [Java bindings] Many classes in the ``javaapi.data`` package that were
  *intended* to be ``final`` are now explicitly marked as such.
CHANGELOG_END
2022-10-07 18:04:03 +00:00
Stephen Compall
10b5654aab
more Javadocs for codegen base library (#15171)
* javadoc DefinedDataType tree
* javadoc ContractWithKey
* javadoc ValueDecoder

CHANGELOG_BEGIN
CHANGELOG_END
2022-10-06 14:33:34 +00:00
Stephen Compall
6df0c24d78
turn on -Xlint -Werror for Java bindings (#15155)
* turn on -Xlint -Werror for Java bindings
* remove unused locals
* remove raw casts for deprecated Record
* fix rawtypes
* don't check for serialVersionUID
* some javadoc for DefinedDataType
* add lint to bindings-rxjava; deprecate ledger identity client
* document DamlRecord
* fix rawtypes in Java codegen output
* fix unused cast in Java codegen output
* enable -Xlint for Java codegen output

CHANGELOG_BEGIN
- [Java codegen] Now outputs code that should pass ``-Xlint:rawtypes``
  as well as other ``-Xlint`` warnings.
CHANGELOG_END
2022-10-04 10:57:45 -04:00
Stephen Compall
f2f311a7da
mark internal Java bindings functions in Javadoc (#15151)
* note that makeExerciseCmd is not for application use
* notes on Contract, *Companion
* doc View type parameter
* fromContractId is also internal API

CHANGELOG_BEGIN
CHANGELOG_END
2022-10-04 07:59:29 -04:00
pbatko-da
a55ccc384e
[DPP-1219] Move local stores for participant users and parties to a separate bazel target (#15108)
changelog_begin
changelog_end
2022-10-03 17:26:28 +02:00
Chun Lok Ling
1adf3930cd
passed value decoder to interface Companion (#15143)
* passed value decoder to interface Companion

CHANGELOG_BEGIN
CHANGELOG_END

* throw IllegalArgumentException if view type not found for an interface

CHANGELOG_BEGIN
CHANGELOG_END

* address comments

* test

* test

Co-authored-by: Chun Lok Ling <lokling@gmail.com>
2022-10-03 10:03:07 +01:00
Stephen Compall
a55eabb132
handle incomplete event metadata for parsing exercise results (#15050)
* drop payload and key instead of passing through
* build a "hidden" dar with a new template for build-and-lint-test
* test the events that come back; passing
* test key and that template is definitely not registered
* confirm test fails without changes to @daml/ledger

  ✕ undecodable exercise result event data is discarded (334 ms)

● interfaces › undecodable exercise result event data is discarded

  Failed to look up template 24124e8b5ae6c7f06835529d5b7338ed32308cdcb6409ba72f88351da9145ff1:Hidden:NotVisibleInTs. Make sure your @daml/types version agrees with the used Daml SDK version.

    at lookupTemplate (../../../../language-support/ts/daml-types/index.ts:269:11)
    at ../../../../language-support/ts/daml-ledger/index.ts:196:59
    at ../node_modules/@mojotech/json-type-validation/src/decoder.ts:795:31
    at Result.andThen (../node_modules/@mojotech/json-type-validation/src/result.ts:130:19)
    at Decoder.decode (../node_modules/@mojotech/json-type-validation/src/decoder.ts:795:7)
    at Decoder.decode (../node_modules/@mojotech/json-type-validation/src/decoder.ts:312:37)
    at Decoder.decode (../node_modules/@mojotech/json-type-validation/src/decoder.ts:501:31)
    at decodeValue_1 (../node_modules/@mojotech/json-type-validation/src/decoder.ts:371:68)
    at ../node_modules/@mojotech/json-type-validation/src/decoder.ts:375:65
        at Array.reduce (<anonymous>)

CHANGELOG_BEGIN
- [JS codegen] Exercise no longer fails on unrecognized templates occurring in
  create/archive events resulting from an exercise, such as may happen when
  exercising interface choices; instead, any such "uninterpretable creates" have
  their payloads changed to ``{}`` and their keys removed.
CHANGELOG_END
2022-09-29 17:12:51 +00:00
Chun Lok Ling
28f37cb003
ValueDecoder Interface (#15017)
* FromValue Interface

* add deprecated and new fromvalue method

* debug log

* added apply

* no semicolon

* colon

* fix VariantConstructorClass

* fix VariantConstructorClass

* fix VariantConstructorClass

* fix VariantConstructorClass

* fix test cases

* add changelog

CHANGELOG_BEGIN
CHANGELOG_END

* For template, use the fromValue in contract companion

* Added private value decoder method for passing in to contract companion

* WIP

* move variant sub type decoder method to the base variant class

* remove debug log

* don't call deprecated value

* pass value decoder instead of lambda

* move PrimitiveValueDecoders to codegen package

* rename from FromValue to ValueDecoder

* rename from method fromValue to valueDecoder

* extract isVariantRecord

* remove unused import

* added java doc for valueDecoder method

* format

* address comments

* address comments
2022-09-29 09:16:00 +01:00
Chun Lok Ling
0a0b32e808
use Objects.equals instead (#15094)
* use Objects.equals instead

CHANGELOG_BEGIN
CHANGELOG_END

* add () back

* specfy type of object to avoid java.io.Serializable being inferred which wartremover doesn't like it

* remove warnings

* address Stephen's comment

* address Stephen's comment
2022-09-28 12:15:26 +01:00
Sergey Kisel
9ce2830cd4
Contract Argument Blob API change for the Explicit Disclosure [DPP-1162] (#15012)
* Contract argument blob [DPP-1161].

CHANGELOG_BEGIN

[Ledger API]: Introduce an ability to expose contract arguments as blob if matched by the interface filter using `include_create_arguments_blob` flag in the ``InterfaceFilter``.
Introduce an ability to provide `DisclosedContract.arguments` as a blob instead of a typed `Record`.

CHANGELOG_END

Breaks-protobuf: true


Co-authored-by: Simon Meier <meiersi-da@users.noreply.github.com>
Co-authored-by: atriantafyllos-da <andreas.triantafyllos@digitalasset.com>
2022-09-27 14:30:47 +02:00
Stephen Compall
5c66d53aa8
combine mostly-duplicate functions in TS codegen (#15096)
CHANGELOG_BEGIN
CHANGELOG_END
2022-09-26 19:56:08 +00:00
pbatko-da
ca81adeb3e
6 - Ledger API changes for UM/UP extensions for Hub [DPP-1211] (#14937)
changelog_begin

[Ledger API Specification]:
1. Add 'is_deactivated' attribute to participant users.
2. Introduce participant server's local metadata for parties and participant users consisting of:
 - a resource version for optional concurrent change control,
 - modifiable key-value based annotations.
3. Add experimental update RPCs for parties and participant users:
  - participant user's modifiable fields are: 'primary_party', 'is_deactivated', 'metadata.annotations',
  - party's modifiable fields are 'local_metadata.annotations'.
4. Discourage use of 'party_details.display_name' in favor of using party's metadata annotations.

changelog_end


Other notes:

- no-op updates are allowed,
- update paths are resource relative,
- as annotation deletion is by providing an key with the empty string value,
- as a corollary, only non-empty strings are valid annotation values.
2022-09-26 12:56:55 +00:00
Chun Lok Ling
63e8dc2c82
Contract decoder class which constructed with list of template companions (#15078)
* new ContractDecoder

* change DecoderClass to use template companion for contract decoders

* add change log

CHANGELOG_BEGIN
CHANGELOG_END

* format

* Revert "add change log"

This reverts commit 6d59829883.
2022-09-23 21:09:41 +01:00
mziolekda
41dc32a016
Remove reliance on implicit party allocation in CI tests [DPP-1234] (#15037)
* Remove reliance on implict party allocation in the authorization tests of the sandbox-on-x

CHANGELOG_BEGIN
CHANGELOG_END

* Remove the HOCON and cli config parameters

* Remove implicit party allocation from the Submission Service

* Remove support for implicit parties from the bridge

* Fix codegen reliance on implicit party allocation

* Fix daml script tests

* Fix trigger tests

* format security-evidence.md post rebase

* Fix json-api tests

* One more json-api test

* Fix haskell tests

* Corrections post-review

* Cosmetic improvements

* Fix race condition in party allocation handling
2022-09-22 10:20:53 +02:00
fayi-da
51af09646c
add abstract class parents to type-parameterless records, variants, enums (#15023)
* Add abstract class parents to generated ordinary records and variants

* Add common supertype for generated enums

* Add abstract class parents to generated ordinary records and variants

CHANGELOG_BEGIN
- Ordinary Records and Variants now have a super class defining toValue()
- Generated enums now have a common supertype, DamlEnum<T>
CHANGELOG_END
2022-09-15 15:26:31 +01:00
Stephen Compall
29313626e6
forbid interface choices for createAnd and byKey (#14971)
* ChoiceFrom intersection
* require ChoiceFrom in some functions
* codegen ChoiceFrom

CHANGELOG_BEGIN
- [TypeScript] Codegen output now uses the new ``ChoiceFrom`` interface;
  prior output that does not use this interface will not work with this
  version of ``@daml/types``.  If you use the type ``Choice`` in your
  own types and your code no longer type-checks, you must include
  ``ChoiceFrom`` in your declarations as well.
CHANGELOG_END
2022-09-08 12:29:20 -04:00
Chun Lok Ling
5f8c9db7b8
Added Packages deduplication before module name collision check. (#14970)
* addressed #11457

CHANGELOG_BEGIN
Fixed #11457 bug of module name collision found in the same packages
CHANGELOG_END

* rename test
2022-09-08 09:45:23 +01:00
Simon Maxen
b90d681118
Cleanup metering report proto now clients have switched to using JSON [DPP-1203] (#14967)
* Cleanup metering report proto now clients have switched to using JSON.

changelog_begin
changelog_end

Breaks-Protobuf: true
2022-09-08 09:31:18 +01:00
Stephen Compall
7657ba0342
remove choice inheritance from TypeScript codegen (#14953)
CHANGELOG_BEGIN
- [codegen js] Interface choices are no longer inherited by implementing
  templates.  Instead, refer to the choice directly on the interface.
CHANGELOG_END
2022-09-07 17:44:23 +00:00
Stephen Compall
277779dc36
widen @daml/react types to admit querying interfaces (#14968)
CHANGELOG_BEGIN
- [JS] ``@daml/react`` functions like ``useQuery`` allow interfaces to
  be queried, where JSON API supports this.
CHANGELOG_END
2022-09-07 17:12:42 +00:00
Stephen Compall
2c7cabcff7
interface subscriptions from TypeScript codegen (#14920)
* new types and companion derivation function for interfaces
* declare that interface companions are no longer Templates
* widen the type of Choice#template, experimentally
* widen some types to admit sync query
* declare that interfaces are allowed for fetch, WS query

CHANGELOG_BEGIN
- [codegen js] Support querying interface views and fetching by contract
  ID retrieving the interface view rather than the template payload.
CHANGELOG_END
2022-09-07 16:31:35 +00:00
Chun Lok Ling
a516be7328
Added ListUsersRequest (#14943)
* Added ListUsersRequest

CHANGELOG_BEGIN
CHANGELOG_END

* Add code change

CHANGELOG_BEGIN
Allow to list all users by providing page token and page size in the Java bindings
CHANGELOG_END

* added test cases to cover the new method
2022-09-07 16:57:17 +01:00
Simon Maxen
fe2d5b06ac
Switch to using json structure for metering report [DPP-1134] (#14891)
* Switch to using json structure

changelog_begin
changelog_end
2022-09-06 15:02:52 +01:00
Stephen Compall
3902380b14
declare retroactive interface implementations in TypeScript (#14892)
* include retro-implements in TS interface type decls

* split interface exercise test into two sub-tests

* test that contract ID conversion resolves

CHANGELOG_BEGIN
- [TypeScript codegen] Support for retroactive interface implementations
  included.  Choice inheritance is deprecated and `will be removed
  <https://github.com/digital-asset/daml/issues/14893>`__; to invoke an
  interface choice on a template-typed contract ID, convert it to an
  interface-typed ID with *TemplateName*``.toInterface``.
CHANGELOG_END
2022-09-02 10:10:58 -04:00
Stephen Compall
85f93f54a0
make exercise by interface contract ID safe (#14134)
* declare Interface, ToInterface, FromInterface in @daml/types library

* generate ToInterface and FromTemplate companion declarations

* add toInterface and unsafeFromInterface to template companion implementations

* declare marker types for every interface

* remove type parameter from interface companions' types

* add the union for forward implements

CHANGELOG_BEGIN
- [TypeScript codegen] To exercise an interface choice on a
  template-typed contract ID, you must now explicitly convert the
  contract ID to an interface-typed ID.  For example, where ``cid:
  ContractId<TemplateName>``, you can use
  ``TemplateName.toInterface(InterfaceName, cid)`` to produce a
  ``ContractId<InterfaceName>``.

  Interface contract IDs are also now typed as shown above; for example,
  the former type ``ContractId<InterfaceNameInterface<TemplateName>>``
  would now simply be ``ContractId<InterfaceName>``.
CHANGELOG_END
2022-08-31 09:25:53 -04:00
Chun Lok Ling
bb4a17e345
add test case (#14882)
CHANGELOG_BEGIN
CHANGELOG_END
2022-08-31 11:28:59 +01:00
Chun Lok Ling
a29b95d38b
Test retro implements in java codegen (#14875)
* fixes #14822, added test case to ensure retroactive implements works in java code gen

CHANGELOG_BEGIN
CHANGELOG_END

* fixes #14822, added test case to ensure retroactive implements works in java code gen
* format
* address Stephen's comment
* fmt
2022-08-31 09:19:08 +01:00
Stephen Compall
99a48557d3
deprecate interface library names; use new names downstream (#14856)
* new names in daml-script/runner

* new names in json-api

* new names in Scala bindings/codegen

* new names in Java bindings/codegen

* new names in daml-lf interpreter tests

* more new names in daml-script tests

* new names in navigator backend

* deprecate all iface symbols and old method names

CHANGELOG_BEGIN
- [Scala API] ``com.daml.lf.iface`` has been deprecated, as discussed
  further in
  `issue #14783 <https://github.com/digital-asset/daml/pull/14783>`__.
  Use the deprecation warnings as guidance to the new names.
CHANGELOG_END

* prefix cases in OrderingSpec

- suggested by @remyhaemmerle-da; thanks
2022-08-29 20:43:47 +00:00
Stephen Compall
f43bc5c8d1
use new api-type-signature names in some dependents (#14785)
* use new names in json-api

* use new names in java codegen

* use new names in Scala codegen

* use new names in TypedValueGenerators

CHANGELOG_BEGIN
CHANGELOG_END
2022-08-23 17:52:10 +00:00
Stephen Compall
f85f7816c7
rename interface library to api-type-signature; alias symbols (#14783)
* move interface directory to api-type-signature; change bazel target; move scala files

* rename iface package to typesig; rename EnvironmentInterface to EnvironmentSignature

* rename Interface to PackageSignature

* rename fromReaderInterfaces to fromPackageSignatures

* rename InterfaceReader to SignatureReader

* rename InterfaceReader to SignatureReader in deprecation note

* rename readInterface to readPackageSignature

* rename InterfaceReaderError to Error

* rename InterfaceReaderMain to SignatureReaderMain

* rename InterfaceType to PackageSignature.TypeDecl

* rename astInterfaces to interfaces

* rename astInterfaces to interfaces in PackageSignature

* rename findAstInterface to findInterface

* rename a couple arguments

CHANGELOG_BEGIN
- [Scala API] The "quasi-public" API in ``com.daml.lf.iface`` has moved
  to the new ``com.daml.lf.typesig`` package, with many accompanying
  name changes as documented in `issue #13669
  <https://github.com/digital-asset/daml/issues/13669>`__.

  Daml 2.5.0 or later will remove the old names, and also rename the
  Maven artifact from ``daml-lf-interface`` to
  ``daml-lf-api-type-signature``.  We recommend that users of this API
  use the deprecation guidance in 2.4.0 to port their applications
  before this happens.
CHANGELOG_END
2022-08-23 15:21:45 +00:00