New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add contract keys to created events in the Ledger API #1586
Conversation
4426faa
to
861f85c
Compare
NoteI would greatly benefit from some input from either @S11001001 or @leo-da on how to reflect this change in the Scala bindings (so that this information can also be added to the navigator). @gerolf-da suggested using a type dependent type on |
Nonetheless, I would consider merging this PR as-is (modulo the review) and add the Scala bindings and navigator support for contract keys as a separate contribution (just to keep things simple). |
d99c68b
to
33bb02e
Compare
daml-lf/transaction/src/main/scala/com/digitalasset/daml/lf/transaction/Node.scala
Outdated
Show resolved
Hide resolved
daml-lf/transaction/src/main/scala/com/digitalasset/daml/lf/transaction/Node.scala
Outdated
Show resolved
Hide resolved
...indings-rxjava/src/test/scala/com/daml/ledger/rxjava/grpc/helpers/TransactionGenerator.scala
Outdated
Show resolved
Hide resolved
...uite/scala/com/digitalasset/platform/tests/integration/ledger/api/TransactionServiceIT.scala
Outdated
Show resolved
Hide resolved
...ger-api-common/src/main/scala/com/digitalasset/platform/participant/util/LfEngineToApi.scala
Show resolved
Hide resolved
...uite/scala/com/digitalasset/platform/tests/integration/ledger/api/TransactionServiceIT.scala
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @stefanobaghino-da.
...uite/scala/com/digitalasset/platform/tests/integration/ledger/api/TransactionServiceIT.scala
Outdated
Show resolved
Hide resolved
...uite/scala/com/digitalasset/platform/tests/integration/ledger/api/TransactionServiceIT.scala
Outdated
Show resolved
Hide resolved
Addresses #1586 (comment) Addresses #1586 (comment)
Addresses #1586 (comment) Addresses #1586 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @stefanobaghino-da 👍
@S11001001 your explicit approval is required in order to merge this PR. |
As discussed off-band with @gerolf-da, it would be desirable to improve the codegen by exposing contract keys
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed offline, please only generate a contract key field in the java codegen of the right type if there is an key defined in the model.
dd21811
to
c65b649
Compare
Also adds support in daml-lf/interface for contract keys Addresses #1586 (review)
@gerolf-da The latest commit should fix it, thanks for the guidance. @S11001001 I added contract keys support to the interface reader, you may want to have a look at it. |
contractKeyFieldName) | ||
} else { | ||
spec.addStatement( | ||
"return new $T($L, $L, $L)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could build up the return statement with something like the following to avoid having to duplicate the statement itself:
val names = Vector(idFieldName, dataFieldName, agreementFieldName) ++ maybeContractKeyClassName.map(_ => contractKeyFieldName)
val params = names.map(n => CodeBlock.of("$L", n)).asJava
val allParams = CodeBlock.join(params, ", ")
spec.addStatement("return new $T($L)", className, params)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, both my Scala and my javapoet
became rusty after the last few months. 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed by 4249373
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, @stefanobaghino-da. Very smoothly integrated. 👏
Only had 1 comment that you could also apply to other places in this commit where you find you had to duplicate code depending on whether the key was defined or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
6240a38
to
bbb2a07
Compare
…/digitalasset/platform/tests/integration/ledger/api/TransactionServiceIT.scala Co-Authored-By: Stephen Compall <scompall@nocandysw.com>
…ledger/rxjava/grpc/helpers/TransactionGenerator.scala Co-Authored-By: Stephen Compall <scompall@nocandysw.com>
…/digitalasset/platform/tests/integration/ledger/api/TransactionServiceIT.scala Co-Authored-By: Stephen Compall <scompall@nocandysw.com>
Addresses #1586 (comment) Addresses #1586 (comment)
Addresses #1586 (comment) Addresses #1586 (comment)
…orm/participant/util/LfEngineToApi.scala Co-Authored-By: Stephen Compall <scompall@nocandysw.com>
Applies the suggestion introduced by 7cc5c3e
Also adds support in daml-lf/interface for contract keys Addresses #1586 (review)
bbb2a07
to
20b0f18
Compare
private val getArguments = CodeBlock.of("event.getArguments()") | ||
private val getAgreementText = CodeBlock.of("event.getAgreementText()") | ||
private def getContractKey(t: TypeName) = | ||
CodeBlock.of("event.getContractKey().map($T::fromValue)", t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately this seems to not work as expected when t
is a TupleN
for some N.
The fromValue
functions for tuples expect additional arguments to convert the components.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally right, fixed by #1743, thanks for the detailed report.
Fixes #1268
Pull Request Checklist
NOTE: CI is not automatically run on non-members pull-requests for security
reasons. The reviewer will have to comment with
/AzurePipelines run
totrigger the build.