Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'unflatten' keys in core models #1167

Open
lucianojoublanc-da opened this issue Nov 28, 2023 · 1 comment
Open

'unflatten' keys in core models #1167

lucianojoublanc-da opened this issue Nov 28, 2023 · 1 comment

Comments

@lucianojoublanc-da
Copy link
Contributor

Templates and Interfaces such as Account are currently 'flat', meaning they have no nested structures:

data View = View
  with
    custodian : Party
      -- ^ Party providing accounting services.
    owner : Party
      -- ^ Party owning this account.
    id : Id
      -- ^ Identifier for the account.
    description : Text
      -- ^ Human readable description of the account.
    controllers : Controllers
      -- ^ Parties controlling transfers.

Accessing the keys of these entities can be done with a convenience function, e.g. toKey in this case:

-- | Convert the account's 'View' to its key.
toKey : View -> AccountKey
toKey v = AccountKey with custodian = v.custodian; owner = v.owner; id = v.id

While this works fine within Daml, these functions can't be used from a client application. These need to be packed/unpacked manually, (both externally, but also in Daml) - which requires looking at the function definition to know what the key is.

I suggest that this be changed to:

data View = View
  with
    key: AccountKey
    description : Text
      -- ^ Human readable description of the account.
    controllers : Controllers
      -- ^ Parties controlling transfers.

I have a recollection that at some point we had this, and I think it's changed since.

@lucianojoublanc-da
Copy link
Contributor Author

Note that this is also inconsistent: for Holding for example, we have InstrumentKey and AccountKey on the contract.

@georg-da georg-da added this to the release-vnext milestone Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants