Git Source

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

mapping(address => bytes32[]) public tagRecords;

tagToIndex

mapping(address => mapping(bytes32 => uint256)) tagToIndex;

isTagRegistered

mapping(address => mapping(bytes32 => bool)) isTagRegistered;

MAX_TAGS

uint8 constant MAX_TAGS = 10;

Functions

constructor

Constructor that sets the app manager address used for permissions. This is required for upgrades.

constructor(address _dataModuleAppManagerAddress) DataModule(_dataModuleAppManagerAddress);

Parameters

NameTypeDescription
_dataModuleAppManagerAddressaddressaddress 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.

function addTag(address _address, bytes32 _tag) public virtual onlyOwner;

Parameters

NameTypeDescription
_addressaddressuser address
_tagbytes32metadata 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.*

function addTagToMultipleAccounts(address[] memory _accounts, bytes32 _tag) external virtual onlyOwner;

Parameters

NameTypeDescription
_accountsaddress[]Address array to be tagged
_tagbytes32Tag for the account. Can be any allowed string variant

removeTag

Remove the tag. Restricted to owner.

function removeTag(address _address, bytes32 _tag) external virtual onlyOwner;

Parameters

NameTypeDescription
_addressaddressuser address
_tagbytes32metadata 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.

function addMultipleTagToMultipleAccounts(address[] memory _accounts, bytes32[] memory _tags) external onlyOwner;

Parameters

NameTypeDescription
_accountsaddress[]Address array to be tagged
_tagsbytes32[]Tag array for the account at index. Can be any allowed string variant

hasTag

Check is a user has a certain tag

function hasTag(address _address, bytes32 _tag) public view virtual returns (bool);

Parameters

NameTypeDescription
_addressaddressuser address
_tagbytes32metadata tag

Returns

NameTypeDescription
<none>boolhasTag true if it has the tag, false if it doesn’t

getAllTags

function getAllTags(address _address) public view virtual returns (bytes32[] memory);