Hello!
The team here is having some trouble understanding how to use the Java bindings when Daml interfaces are involved.
There is previous experience with the Java bindings before Daml interfaces were introduced.
Are there any example projects we can take a look at showcasing typical use?
Additional docs would also be welcome if available.
Thanks,
Daniel
Please first see the documentation for Java codegen with interfaces. For contract ID conversion, note in that example that toInterface
and unsafeFromInterface
methods are defined, which serve a similar purpose to Daml toInterfaceContractId
and fromInterfaceContractId
.
Just as every template is codegenned with a singleton COMPANION: ContractCompanion
that may be used for abstract operations, interfaces get an INTERFACE: InterfaceCompanion
that can be used similarly.
Both companions can be used in similar ways in high-level utilities. For example, you can use getActiveContracts like so,
acc.getActiveContracts(ContractFilter.of(MyInterface.INTERFACE), parties, true, token)
to retrieve an ACS of interface-contract-IDs and interface views for MyInterface
, just as for templates.