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 ContractIds.
Hence the following workaround:
- define a concrete template called
Referencewhich is keyed (with a contract key) - have
Referencestore theContractIdof anAccount
We then define some helper functions called exerciseInterfaceByKey which effectively
- fetch the
Referencecontract by key - exercise a choice on the corresponding
Accountcontract using theContractIdthat is stored in theReference
Hopefully we will be able to remove this workaround once interface keys are supported.
Matteo