There may be a few of these questions coming from me over the next few weeks as I figure out the architecture of my app and whether or not DAML is right for my project.
Let’s say you have a contract:
template Product with producer : Party productType : ProductType label : Text where signatory producer
template ProductType with admin : Party description : Text where signatory admin
ProductType contracts are created by site admins and are basically categories for different types of products.
Product contracts are created by producers. Is it possible for a producer to create a
Product given that they are not observers on
ProductType contract? I tried this test code:
productScenario = scenario do admin <- getParty "Admin" producer <- getParty "Producer" productTypeCid <- submit admin do create ProductType with description = "product" admin productCid <- submit producer do productType <- fetch productTypeCid create Product with producer productType label = "label return productCid
…it fails because the producer cannot fetch a
ProductType contract as he/she is not an observer on it. Maybe there is a hacky way to do this in the UI code, by:
ProductTypeobservable to a
publicparty (as discussed here Should everything be on the ledger?)
ProductTypewith the public token
- creating the
Productwith the producer token
Or maybe I should just have a
ContractId ProductType on the
Would either work? Do you foresee any problems?