daostack / daostack/access_control
Formalize a language and interpreter for defining the lock criterion
- Dominant language
- JavaScript
- Stars
- 1
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
I believe there is a need to include in the interface function to get the locks of a function, so that a user/ contract would be able to know what conditions he needs to satisfy in order to trigger a function.
My original thought was to make a function return an array of "lock sets" which would look like this:
`[["Admin"], ["User", "Editor"]]`, each "lockset array is ORed while the lock sets themselves are ANDed, the example would look like so `"Admin" && ("User" || "Editor")`.
As @dev-matan-tsuberi mentioned on the PR, there are 2 problems with this approach:
1. Locks might be tied with the function parameters, like `keccak256("foo", p)`, then how will we add p in this function.
2. Functions can use any complex boolean expression for access limiting, so a function may use this condition for example: `unlock("Admin") && p == "PARAMETER")` or `unlockable("Admin") && !unlockable("Junior")`.
I have a few ideas for possible solutions:
1. The simplest, is just return the actual condition as a string. This won't be really helpful for contracts or simple users but it can be useful for developers.
2. To solve 1, we can basically use names as `arg0`, `arg1` and so. For 2 we can also use some "keywords". A few examples might look like so:
- `unlockable("Admin") && !unlockable("Junior") => [["Admin"], [not "Junior"]]`
- `(unlock("Admin") && p == "PARAMETER") || unlock("SuperUser") => [["SuperUser", ["Admin", bool(arg0 == "PARAMETER")]]]`
Notice the `bool()` on the second option. This is to identify between a `Key` and some boolean expression.
If you have any idea for a better solution please share it here as well.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.