-
Notifications
You must be signed in to change notification settings - Fork 15
Token Gated Role Authorizer
File: TokenGatedRoleAuthorizer.sol
- This Module expands on the RoleAuthorizer by adding the possibility to set a role as "Token-Gated"
- Instead of whitelisting a user address, the whitelisted addresses will correspond to a token address, and on authorization the contract will check on ownership of one of the specified tokens.
modifier onlyEmptyRole(bytes32 roleId)
Checks that the role is empty or not.
modifier onlyTokenGated(bytes32 roleId)
Checks whether the given roleId
is token gated or not.
modifier validThreshold(uint threshold)
Checks that the threshold is non-zero. Since base ERC721 does not have a total/max supply, we can only enforce that the value should be non-zero.
function isAuthorized(address who) external view returns (bool);
Returns if an address is authorized to perform a specific action.
- address who: The adress to be checked.
function hasTokenRole(bytes32 role, address who) external returns (bool);
Checks if an account qualifies for a token-gated role.
- bytes32 role: The role to be checked
- address who: The account to be checked
function getThresholdValue(bytes32 roleId, address token)
external
returns (uint);
Returns the threshold amount necessary to qualify for a given token role.
- bytes32 roleId: The role to be checked on
- address token: The token to check the threshold for
function makeRoleTokenGatedFromModule(uint8 role) external;
Sets up a token-gated empty role. This function is only callable by an active Module for itself. Admin should use setTokenGated()
. Calling this function does not specify which token to use for gating. That has to be done with grantTokenFromModule()
.
- uint8 role: The role to be made token-gated
function grantTokenRoleFromModule(uint8 role, address token, uint threshold)
external;
One-step setup for Modules to create a token-gated role and set its threshold.
- uint8 role: The role to be made token-gated
- address token: The token for which the threshold will be set
- uint threshold: The minimum balance of the token required to qualify for the role
function setTokenGated(bytes32 role, bool to) external;
Sets if a role is token-gated or not. Admin access for rescue purposes. If the role has active members. they need to be revoked first.
- bytes32 role: The ID of the role to be modified
- bool to: The new value to be set
function setThreshold(bytes32 roleId, address token, uint threshold)
external;
Sets the minimum threshold for a token-gated role. This function does not validate the threshold. It is technically possible to set a threshold above the total supply of the token.
- bytes32 roleId: The ID of the role to be modified
- address token: The token for which to be threshold
- uint threshold: The user will need to have at least this number to qualify for the role