Tags
Inherits: DataModule, ITags, INoAddressToRemove, IAppLevelEvents
Author: @ShaneDuncan602, @oscarsernarosero, @TJ-Everett
Stores tag data for accounts
Tags are stored as an internal mapping
State Variables
tagRecords
tagToIndex
isTagRegistered
MAX_TAGS
Functions
constructor
Constructor that sets the app manager address used for permissions. This is required for upgrades.
Parameters
Name | Type | Description |
---|---|---|
_dataModuleAppManagerAddress | address | address of the owning app manager |
addTag
There is a hard limit of MAX_TAGS tags per address. This limit is also enforced by the protocol, so keeping this limit here prevents transfers to unexpectedly revert.
Add the tag. Restricted to owner.
Parameters
Name | Type | Description |
---|---|---|
_address | address | user address |
_tag | bytes32 | metadata tag to be added |
addTagToMultipleAccounts
There is a hard limit of MAX_TAGS tags per address. This limit is also enforced by the protocol, so keeping this limit here prevents transfers to unexpectedly revert.
_Add a general tag to an account. Restricted to Application Administrators. Loops through existing tags on accounts and will emit an event if tag is _ already applied.*
Parameters
Name | Type | Description |
---|---|---|
_accounts | address[] | Address array to be tagged |
_tag | bytes32 | Tag for the account. Can be any allowed string variant |
removeTag
Remove the tag. Restricted to owner.
Parameters
Name | Type | Description |
---|---|---|
_address | address | user address |
_tag | bytes32 | metadata tag to be removed |
addMultipleTagToMultipleAccounts
we only remove the tag if this exists in the account’s tag list we store the last tag on a local variable to avoid unnecessary costly memory reads we check if we are trying to remove the last tag since this would mean we can skip some steps if it is not the last tag, then we store the index of the address to remove we remove the tag by replacing it in the array with the last tag (now duplicated) we update the last tag index to its new position (the removed-tag index) we remove the last element of the tag array since it is now duplicated we set to false the membership mapping for this tag in this account we set the index to zero for this tag in this account only one event should be emitted and only if a tag was actually removed
there is a hard limit of 10 tags per address.
Add a general tag to an account at index in array. Restricted to Application Administrators. Loops through existing tags on accounts and will emit an event if tag is already applied.
Parameters
Name | Type | Description |
---|---|---|
_accounts | address[] | Address array to be tagged |
_tags | bytes32[] | Tag array for the account at index. Can be any allowed string variant |
hasTag
Check is a user has a certain tag
Parameters
Name | Type | Description |
---|---|---|
_address | address | user address |
_tag | bytes32 | metadata tag |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | hasTag true if it has the tag, false if it doesn’t |