IAUT_TokenGated_Roles_v1.sol

Git Source

Inherits: IAuthorizer_v1

Functions

hasTokenRole

Checks if an account qualifies for a token-gated role.

function hasTokenRole(bytes32 role, address who) external view returns (bool);

Parameters

Name
Type
Description

role

bytes32

The role to be checked.

who

address

The account to be checked.

Returns

Name
Type
Description

<none>

bool

True if the account qualifies for the role.

getThresholdValue

Returns the threshold balance for a given token necessary to qualify for a specific role. If the value is 0, the supplied token is not part of the. role's token gating.

In case the queried role is not token gated, all calls will return 0.

function getThresholdValue(bytes32 roleId, address token)
    external
    returns (uint);

Parameters

Name
Type
Description

roleId

bytes32

The role to be checked on.

token

address

The token to check the threshold for.

Returns

Name
Type
Description

<none>

uint256

The threshold amount necessary to qualify for a given token role.

makeRoleTokenGatedFromModule

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()'.

function makeRoleTokenGatedFromModule(bytes32 role) external;

Parameters

Name
Type
Description

role

bytes32

The role to be made token-gated.

grantTokenRoleFromModule

One-step setup for Modules to create a token-gated role and set its threshold. Please be aware that using tokens that are transferable and have active markets could make the token-gated authorization vulnerable to flash loans, potentially bypassing. the authorization mechanism.

function grantTokenRoleFromModule(bytes32 role, address token, uint threshold)
    external;

Parameters

Name
Type
Description

role

bytes32

The role to be made token-gated.

token

address

The token for which the threshold will be set.

threshold

uint256

The minimum balance of the token required to qualify for the role.

setThresholdFromModule

Allows a Module to set the threshold of one of it's roles.

function setThresholdFromModule(bytes32 role, address token, uint threshold)
    external;

Parameters

Name
Type
Description

role

bytes32

The token-gated role.

token

address

The token for which the threshold will be set.

threshold

uint256

The new minimum balance of the token required to qualify for the role.

setTokenGated

Sets if a role is token-gated or not.

Admin access for rescue purposes. If the role has active members, they need to be reovked first.

function setTokenGated(bytes32 role, bool to) external;

Parameters

Name
Type
Description

role

bytes32

The ID of the role to be modified.

to

bool

The new value to be set.

setThreshold

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.

function setThreshold(bytes32 roleId, address token, uint threshold) external;

Parameters

Name
Type
Description

roleId

bytes32

The ID of the role to be modified.

token

address

The token for which to the threshold.

threshold

uint256

The user will need to have at least this number to qualify for the role.

Events

ChangedTokenGating

Event emitted when the token-gating of a role changes.

event ChangedTokenGating(bytes32 role, bool newValue);

Parameters

Name
Type
Description

role

bytes32

The role that was modified.

newValue

bool

The new value of the role.

ChangedTokenThreshold

Event emitted when the threshold of a token-gated role changes.

event ChangedTokenThreshold(bytes32 role, address token, uint newValue);

Parameters

Name
Type
Description

role

bytes32

The role that was modified.

token

address

The token for which the threshold was modified.

newValue

uint256

The new value of the threshold.

Errors

Module__AUT_TokenGated_Roles__RoleNotTokenGated

The function is only callable by an active Module.

error Module__AUT_TokenGated_Roles__RoleNotTokenGated();

Module__AUT_TokenGated_Roles__RoleNotEmpty

The function is only callable if the Module is self-managing its roles.

error Module__AUT_TokenGated_Roles__RoleNotEmpty();

Module__AUT_TokenGated_Roles__InvalidToken

The token doesn't support balance query.

error Module__AUT_TokenGated_Roles__InvalidToken(address token);

Parameters

Name
Type
Description

token

address

The token address that is not supported.

Module__AUT_TokenGated_Roles__InvalidThreshold

The given threshold is invalid.

error Module__AUT_TokenGated_Roles__InvalidThreshold(uint threshold);

Parameters

Name
Type
Description

threshold

uint256

The threshold that is not valid.

Module__AUT_TokenGated_Roles__TokenRoleMustHaveThreshold

The role is token-gated but no threshold is set.

error Module__AUT_TokenGated_Roles__TokenRoleMustHaveThreshold(
    bytes32 role, address token
);

Parameters

Name
Type
Description

role

bytes32

The role that doesnt have threshold.

token

address

The token for which the threshold was not set.

Last updated