daml icon indicating copy to clipboard operation
daml copied to clipboard

Identifier property is missing from ChoiceArgument classes (java-bindings)

Open StephenOTT opened this issue 3 years ago • 3 comments

When working with ExercisedEvent.class you receive the choiceArgument property which is an Identifier.class

The identifier provides the package, module and entitiyName (where entityName is the choice)

When working with a Template the Identifier of the template is provided as a static field in the Template's generated class.

But the Identifier property is missing from generated Choice classes. There is only the "_packageId` field.

The identifier is used so provide a lookup / match between conversion of a DamlRecord to a typed Choice argument.

each Choice class provides a fromValue() method. But you need to know which specific choice class to use. When ExercisedEvent provides the choiceArgument.recordId value, it is the full Choice Identifier.

Without the identifier, the dev has to create additional mappings against the templateId identifier in the Exercise choice further complicating the mapping process.

StephenOTT avatar Jul 14 '22 17:07 StephenOTT

Related to https://github.com/digital-asset/daml/issues/14313 (and would likely be subsumed by it)

ray-roestenburg-da avatar Sep 12 '22 09:09 ray-roestenburg-da

Specifically, this would be subsumed by the ChoiceMetadata proposal and #12897. The pair (ChoiceMetadata<?, Arg, ...>, Arg) represents the metadata related to Arg being a choice argument type, and the first element itself is more than sufficient to decode Arg. The mapping from choice names to metadata values would be in the companion, as mentioned there.

S11001001 avatar Sep 12 '22 15:09 S11001001

@ray-roestenburg-da To clarify, our planned approach to #12897 will also close this.

S11001001 avatar Sep 13 '22 18:09 S11001001