iroha
iroha copied to clipboard
Refactor permission tokens API
Right now we have to identify PermissionTokens
using some constant string. It makes sense for external API, but inside Iroha it could be strong typed.
If someone has something to add, feel free to leave a comment
After some consideration and failed experiments I can't come up with a satisfactory design that would allow us to both create permission tokens dynamically and have them as completely independent types, as opposed to specialized wrappers around stringly-typed PermissionToken
.
If we don't have/expect to have any cases where one would like to create and use new permission tokens via e.g. smartcontracts, we could make them strongly-typed and predefined per iroha build.
In the other case, I would propose bringing permission tokens more in line with other dynamically created entities: make them Identifiable and Registrable and require registering a token before granting it, like is the case with Roles. That would allow to easily query for all existing permission tokens and make them more consistent with everything else.
I'm more in favor of the second approach, but I think it depends mostly on whether we have any use-cases for defining new permission tokens at run-time, if there are none, it would make sense to go with the first one.