transmissions11/solmate

Best Practice for `RolesAuthority`

ryanli-me opened this issue · 4 comments

What is the best practice for using RolesAuthority?

I've tried inheriting it and using constructor RolesAuthority(_owner, this) to enable a contract with role based control. However, I also saw examples similar to the RolesAuthority.t.sol where we set up a RoleAuthority and pass it to a contract that inherits only Auth.

you don't inherit roles authority, u deploy it separately and set it as the authority for a contract that inherits from Auth

see https://github.com/dapphub/ds-roles for more background on this pattern

thanks for explaining! i thought so too. curious why is RoleAuthority inheriting Auth in addition to Authority. seems all it needs is a canCall. because it inherits Auth makes inheriting RoleAuthority actually workable?

you're correct it doesn't have to inherit Auth specifically but it needs some form of access control to determine who can set roles n such

https://github.com/Rari-Capital/solmate/blob/eaaccf88ac5290299884437e1aee098a96583d54/src/auth/authorities/RolesAuthority.sol#L99

could use Owned instead for example but Auth is more flexible

makes sense. thanks!