Hi @code_monkey,
Thanks for your question. Let me try to clarify why we use the Reference
workaround. I assume here that you are familiar with contract keys (which apply to templates and are documented here).
In Daml Finance we work with interfaces and, as Stephen mentions, Account
is in this case an interface type, for which in principle multiple template implementations can exist.
We wanted a way to reference an Account
by key, but interface keys are not currently supported: for interfaces we can only use ContractId
s.
Hence the following workaround:
- define a concrete template called
Reference
which is keyed (with a contract key) - have
Reference
store theContractId
of anAccount
We then define some helper functions called exerciseInterfaceByKey
which effectively
- fetch the
Reference
contract by key - exercise a choice on the corresponding
Account
contract using theContractId
that is stored in theReference
Hopefully we will be able to remove this workaround once interface keys are supported.
Matteo