AgentRegistry
Registry of agents (known now as Detection Bots). Agents are abstract objects identified by a unique uint256 value. Agents are owned, transferable, and come with attributes:
- "metadata": string (in practice the ipfs hash of a descriptor)
- "chainIds": (sorted) array of integers
Both the metadata and the chainIds are mutable through the updateAgent
function that is restricted to the agent's owner.
At every point in time, a metadata entry can belong to at most one agent (no two agents can share the same metadata entry).
Agents can be enabled / disabled either by their owner or by an admin (AGENT_ADMIN_ROLE
). Each actor has independent "disable" flags:
- If an admin disables an agent, it takes an admin action to re-enable it (the owner cannot re-enable).
- Similarly, if an owner disables an agent, an admin cannot re-enable it.
If the agent Id is staked under the minimum stake, it can’t be enabled()
will return false, regardless of the flags.
As metadata are unique, it is possible for someone to front-run the creation/update of an agent by creating a new agent, or updating an existing one, to take over the metadata entry. This should be avoided by adding a commit-reveal scheme with a delay to both functions (createAgent
and updateAgent
). This has been disabled for now, but should probably be re-activated in the future.
version
string version
constructor
constructor(address forwarder) public
initialize
function initialize(address __manager, address __router, string __name, string __symbol) public
Initializer method, access point to initialize inheritance tree.
Name | Type | Description |
---|---|---|
__manager | address | address of AccessManager. |
__router | address | address of Router. |
__name | string | ERC1155 token name. |
__symbol | string | ERC1155 token symbol. |
getAgentState
function getAgentState(uint256 agentId) public view returns (bool created, address owner, uint256 agentVersion, string metadata, uint256[] chainIds, bool enabled)
Gets all Agent state.
Name | Type | Description |
---|---|---|
agentId | uint256 | ERC1155 token id of the agent. |
Name | Type | Description |
---|---|---|
created | bool | if agent exists. |
owner | address | address. |
agentVersion | uint256 | of the agent. |
metadata | string | IPFS pointer. |
chainIds | uint256[] | the agent wants to run in. |
enabled | bool |
_beforeAgentUpdate
function _beforeAgentUpdate(uint256 agentId, string newMetadata, uint256[] newChainIds) internal virtual
Inheritance disambiguation for hook fired befire agent update (and creation).
Name | Type | Description |
---|---|---|
agentId | uint256 | id of the agent. |
newMetadata | string | IPFS pointer to agent's metadata |
newChainIds | uint256[] | chain ids that the agent wants to scan |
_agentUpdate
function _agentUpdate(uint256 agentId, string newMetadata, uint256[] newChainIds) internal virtual
Obligatory inheritance disambiguation for hook fired for agent update (and creation).
Name | Type | Description |
---|---|---|
agentId | uint256 | id of the agent. |
newMetadata | string | IPFS pointer to agent's metadata |
newChainIds | uint256[] | chain ids that the agent wants to scan |
_msgSender
function _msgSender() internal view virtual returns (address sender)
Helper to get either msg msg.sender if not a meta transaction, signer of forwarder metatx if it is.
_msgData
function _msgData() internal view virtual returns (bytes)
Helper to get msg.data if not a meta transaction, forwarder data in metatx if it is.
__gap
uint256[50] __gap