Open lucianojoublanc-da opened 1 year ago
A suggestion is to add a constraint to the HasSyntheticKey
class HasField "id" Id t
, i.e. that the type has a field called id
of type Id
(which is itself a newtype Text
). This would make things much easier off-ledger, and keys would be more meaningful. On the other hand, this would make key clashes more likely (e.g. two users with a Savings
account).
At present, the version of Daml Finance in the
snapshot-vnext
branch relies on the following code to generate keys:https://github.com/digital-asset/daml-finance/blob/484dcab2b66a5366636353bae351deae23b0b6f8/src/main/daml/Daml/Finance/Interface/Util/KeyTable.daml#L67C33-L67C33
The use of
show
particularly is problematic; it relies on the internal representation ofShow
, which is often derived i.e.deriving (Eq, Show)
, and to provide akeyTable
off-ledger, we need to generate this manually.We haven't run into this problem yet as our tests are run using Daml script, which provides access to the
show
instance.One workaround would be to provide a manual instance of show e.g.
But this is also quite clunky (what happens if a customer uses
|
in their account keys?)A less problematic issue is also the use of a hash here. What happens if we have a clash? (e.g. two keys that have the same string such as "1" (numbered accounts and clients)).
cc @johan-da