-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
Automatically generate Role contracts #1290
Comments
Instead of a code generator to avoid human error I humbly request that we instead change the architecture to not require that everyone include the same duplicate code. At best, this will be expensive (with gas), error prone (with typos) and hard to upgrade and maintain. |
Wow, I didn't know about #1090. Yuck. Implementing a role with this scheme costs a substantial amount of coding (43 lines of Solidity contact and 11 lines of JavaScript test), not to mention the gas to deploy it. Implementing a new role with RBAC was a one-liner, and all of the access methods were orthogonal (making meta-coding and Web3 coding a lot easier). With C++ I'd use a template class to implement RBAC with whatever datatype is passed in, so if you wanted integer-based, cool, if you want strings, cool. But of course Solidity doesn't have generics yet. But there is In any case, experience tells me that whenever I see the words "code generator" or "code wizard" I think "architecture problem" and "maintenance nightmare". Windows. Rails scaffolds. Etc. |
The problem with enum Roles {
Minter,
Pauser,
Signer
} we'd have to hardcode the values in JavaScript, since they are not included in the artifact (the That said, I fully agree with your concerns regarding code generation, and would much prefer not using it, should we find a better alternative. |
I've finally read all the way through 1090 and understand why it is the way it is. Although it may be right within the scope of this project I'm afraid it won't be maintainable in my dependent project, plus it'll make the code super clumsy, so I'll just fork out RBAC and stay with that until something better comes along. Thanks! (and please don't write a code generator ;) |
If you don't mind, could you expand a bit on why the current |
I have n different related permissions to manage, Record101, Record102, Record103 in which one account may have Record rights for 101 and 102 but not 103, etc. With RBAC I can set up n permissions. I thought I was going to append the number to the string, but that turns out to be expensive (string support is still terrible). So instead I might just use integers and bitmasking. Those are fast, and the |
Please do! I'm very interested in looking at it :) |
I've come to the conclusion that I should just be using
if and when I need more permission types, I'll just map the mapping to a list of permission types: Thanks for the help! |
Awesome! Indeed, if that |
With the release of |
The 2.0 release will introduce
MinterRole
,SignerRole
, etc.: these are all manually generated, as are their tests, mocks, etc. We should have some sort of automatic code generation step in our build process to both make it easier to add new roles, and reduce the potential for human error.The text was updated successfully, but these errors were encountered: