Closed EGreg closed 1 year ago
Actually, lines 1500-1509 seem to be totally useless
This happens because we need to return an array. However, dynamic arrays are only available in storage, not in memory. So, we need to calculate "how many items we will return," then declare an array with the appropriate length, and finally, fill it. That's it.
returns (uint8[] memory, string[] memory, string[] memory, uint8[], uint8[])
Should be like this
returns (uint8[] memory, string[] memory, string[] memory, uint8[][] memory, uint8[][] memory)
Because canGrantRoles
- it's already an array and belong to the single role
Actually, lines 1500-1509 seem to be totally useless
This happens because we need to return an array. However, dynamic arrays are only available in storage, not in memory. So, we need to calculate "how many items we will return," then declare an array with the appropriate length, and finally, fill it. That's it.
alright, sure
returns (uint8[] memory, string[] memory, string[] memory, uint8[], uint8[])
Should be like this
returns (uint8[] memory, string[] memory, string[] memory, uint8[][] memory, uint8[][] memory)
BecausecanGrantRoles
- it's already an array and belong to the single role
makes sense, ok update ABI also
Please add a method with the following signature, that just calls
manageRole
in a loop:Rename
getRoles()
to beallRoles
and returncanGrantRoles
andcanRevokeRoles
arrays in it:Let's make
_rolesByIndex
public and rename it toroleByIndex
.By the way, why do we need
allRoles
if we can just make _rolesByIndex public? Is it because some libraries can read arrays of arrays easier than array of struct which containsEnumerableSetUpgradeable.UintSet
? How is a UintSet even stored, where is it defined? Please update this issue with that info.Also, what is this method
getRolesWhichAccountCanGrant
and why isn't theregetRolesWhichAccountCanRevoke
? It takes takes string roles, but do any of our contracts actually use it? If not, please remove this function!Make common variables instead of retyping code, such as line 1022 and 1018
Remove
== true
on on lines 1505, 1515, 1020 -- it is unnecessaryActually, lines 1500-1509 seem to be totally useless
Improve documentation on all functions, including
grantRolesExternal
andrevokeRolesExternal