I am trying to overcome the necessity to hardcode in DAML.
I have some global data that all contracts need to have access to and that I have to make evolve over time. Think of some global config data.
This can be hardcoded in into summation types (enums) but it is very restrictive and instead of having an enum, I would need to have a list of strings for example that can be accessed by all contracts and can be changed over time.
Is this possible?
2 Likes
@Jean_Safar Remember that access to contracts depends on the Party
that is performing the lookup, not other contracts. You could “hardcode” the name of a global party, and then have that global Party
serve the data to other users. That global party would be responsible for updating that data and also accepting (ex. via triggers) requests to access that data. Ideally, you would manage access to that global contract via a simple key so that the observers could look up that data.
template GlobalData
with
global : Party
config_data : Text -- TODO
observers : [Party]
where
signatory global
observer observers
key global : Party
maintainer key
controller global can
AddObserver : ContractId GlobalData
with
who : Party
do
create this with observers = who :: observers
3 Likes
Thanks @Leonid_Rozenberg, that’s indeed how I have it modeled, remembering indeed at all time that access control depends on the party,…
2 Likes