AgentRegistryEnable
AgentRegistryEnable
AgentRegistry methods and state handling disabling and enabling agents, and recognizing stake changes that might disable an agent. NOTE: This contract was deployed before StakeAwareUpgradeable was created, so __StakeAwareUpgradeable_init is not called.
Permission
_disabled
AgentEnabled
event AgentEnabled(uint256 agentId, bool enabled, enum AgentRegistryEnable.Permission permission, bool value)
isEnabled
Check if agent is enabled
Name | Type | Description |
---|---|---|
agentId | uint256 | ERC721 token id of the agent. |
Name | Type | Description |
---|---|---|
[0] | bool | true if the agent exist, has not been disabled, and is staked over minimum Returns false if otherwise |
enableAgent
function enableAgent(uint256 agentId, enum AgentRegistryEnable.Permission permission) public virtual
Enable an agent if sender has correct permission and the agent is staked over minimum stake.
agents can be disabled by ADMIN or OWNER.
Name | Type | Description |
---|---|---|
agentId | uint256 | ERC721 token id of the agent. |
permission | enum AgentRegistryEnable.Permission | the sender claims to have to enable the agent. |
disableAgent
function disableAgent(uint256 agentId, enum AgentRegistryEnable.Permission permission) public virtual
Disable an agent if sender has correct permission.
agents can be disabled by ADMIN or OWNER.
Name | Type | Description |
---|---|---|
agentId | uint256 | ERC721 token id of the agent. |
permission | enum AgentRegistryEnable.Permission | the sender claims to have to enable the agent. |
getDisableFlags
Get the disabled flags for an agentId.
Permission (uint8) is used for indexing, so we don't need to loop. If not disabled, all flags will be 0.
Name | Type | Description |
---|---|---|
agentId | uint256 | ERC721 token id of the agent. |
Name | Type | Description |
---|---|---|
[0] | uint256 | uint256 containing the byte flags. |
_hasPermission
function _hasPermission(uint256 agentId, enum AgentRegistryEnable.Permission permission) internal view returns (bool)
Permission check.
it does not uses AccessManager since it is agent specific
Name | Type | Description |
---|---|---|
agentId | uint256 | ERC721 token id of the agent. |
permission | enum AgentRegistryEnable.Permission | the sender claims to have to enable the agent. |
Name | Type | Description |
---|---|---|
[0] | bool | true if: permission.ADMIN and _msgSender is ADMIN_ROLE, Permission.OWNER and owner of agentId, false otherwise. |
_enable
function _enable(uint256 agentId, enum AgentRegistryEnable.Permission permission, bool enable) internal
Internal methods for enabling the agent.
fires hook _before and _after enable within the inheritance tree.
Name | Type | Description |
---|---|---|
agentId | uint256 | ERC721 token id of the agent. |
permission | enum AgentRegistryEnable.Permission | the sender claims to have to enable the agent. |
enable | bool | true if enabling, false if disabling. |
_beforeAgentEnable
function _beforeAgentEnable(uint256 agentId, enum AgentRegistryEnable.Permission permission, bool value) internal virtual
Hook _before agent enable
does nothing in this contract
Name | Type | Description |
---|---|---|
agentId | uint256 | ERC721 token id of the agent. |
permission | enum AgentRegistryEnable.Permission | the sender claims to have to enable the agent. |
value | bool | true if enabling, false if disabling. |
_agentEnable
function _agentEnable(uint256 agentId, enum AgentRegistryEnable.Permission permission, bool value) internal virtual
Logic for enabling agents, sets flag corresponding to permission.
does nothing in this contract
Name | Type | Description |
---|---|---|
agentId | uint256 | ERC721 token id of the agent. |
permission | enum AgentRegistryEnable.Permission | the sender claims to have to enable the agent. |
value | bool | true if enabling, false if disabling. |
_afterAgentEnable
function _afterAgentEnable(uint256 agentId, enum AgentRegistryEnable.Permission permission, bool value) internal virtual
Hook _after agent enable
emits Router hook
Name | Type | Description |
---|---|---|
agentId | uint256 | ERC721 token id of the agent. |
permission | enum AgentRegistryEnable.Permission | the sender claims to have to enable the agent. |
value | bool | true if enabling, false if disabling. |
_msgSender
Obligatory inheritance dismambiguation of ForwardedContext's _msgSender()
Name | Type | Description |
---|---|---|
sender | address | msg.sender if not a meta transaction, signer of forwarder metatx if it is. |
_msgData
Obligatory inheritance dismambiguation of ForwardedContext's _msgSender()
Name | Type | Description |
---|---|---|
[0] | bytes | sender msg.data if not a meta transaction, forwarder data in metatx if it is. |