Intercoin / CommunityContract

Smart contract for managing community membership and roles
https://intercoin.org
GNU Affero General Public License v3.0
1 stars 2 forks source link

Implement Whitelist mixin #31

Closed EGreg closed 1 year ago

EGreg commented 1 year ago

Make a mixin class so people can do

class Foo is Bar, Whitelist

Put it in this repo and others Ideally you should start using subrepos in git to avoid maintaining multiple versions of libraries and shared classes. Google the github tutorials and learn to do that!!

It would be like this:

const METHOD_HASROLEPACKED = 0xabcdef; // takes uint8 roleCount, followed by uint256 up to 32 roles
struct Whitelist
{
  address contract, // 160
  uint16 method, // 16
  uint8 roleCount // 8
  bytes8 roles // up to 8 roles here
}
Whitelist public whitelist;
function whitelisted(address) public view returns (bool) {
    if (whitelist.roleCount == 0) {
        result = call(abi.encodeWithParams(whitelist.contract, whitelist.method), address)
    } else {
        result = call(abi.encodeWithParams(whitelist.contract, METHOD_HASROLEPACKED), address, whitelist.roleCount, whitelist.roles);
    }
    if error revert(exact error)
    else return result
}

also please implement the following in CommunityContract:

hasRole(address, role) returns (boolean) in CommunityContract {

} 

hasRolePacked(address, uint8 roleCount, bytes8 roles) {

}