Party visibility and Contract owner change on "to-do list" example
Hello!
I’m trying to make a “to-do list” app in DAML, and I have two main problems.
First:
Assumptions:
- Users have 3 roles (admin, support or user)
- Only admin can create new users
- Admin and support can change other user’s role (e.g. support can change user role from “user” to “support”)
- If possible: Support is able to see all Users, but User cannot see other User
What I have:
If admin create an user, and this user is not visible to anyone except admin
user template:
template UserModel
with
masterAdmin: Party
username: Party
role: Role
supporters: [Party]
where
signatory masterAdmin
observer login, supporters
What I want:
Support should be able to change role of every created user. Is delegation pattern only way to do it? Now I have empty Party list on every user, and if I want Support to change user role:
- Admin add support to supporter list
- Support have what he have to
- Admin remove support from supporters list
Second problem:
Is very similar to first. I have a “task” template:
template Task
with
name: Text
issuer: Party
possibleExecutors: [Party]
where
signatory issuer
observer possibleExecutors
What I want:
- My issuer should be able to add every user to “possibleExecutors”. (so we go back to first problem)
- Admin should have the same possibilities as Issuer (e.g. my issuer is not available and I as admin want to exercise every choice, e.g. mark task as done).
What I can achieve that? Is there any way to archive and recreate contract with other issuer?
At the end, I want to do these things on front-end side or API calls (but I don’t think that this make any differcence)
I’m sorry, if anything is not clear here
I figured out a solution.
First problem: stays uchanged. I think that a list, where I can add observer is the best solution for me so far.
Second problem (I wanted that admin could do anything): I used a dynamic signatory trick and this works just fine.
It’s Bernhard post in this topic:
Here’s my code and I don’t kown how to continue. template ContractWithMultiSignatories with signatories: [Party] where signatory signatories template ContracProposal with contract: ContractWithMultiSignatories submitter: Party signed: [Party] where signatory submitter observer contract.signatories controller contract.signatories can Accept : ContractId ContractWithMultiSignatories do assertMsg "Somebody hasn't signed" (contract.si…
Really awesome to hear you figure it out
(and were able to find a helpful post on the forum
)