setEnsNamePartsFor
Contract: JBProjectHandles
Interface: IJBProjectHandles
- Step by step
- Code
- Errors
- Bug bounty
Associate an ENS name with a project.
["jbx", "dao", "foo"] represents foo.dao.jbx.eth.
Only a project's owner or a designated operator can set its ENS name parts.
Definition
function setEnsNamePartsFor(uint256 _projectId, string[] memory _parts)
external
override
requirePermission(projects.ownerOf(_projectId), _projectId, JBOperations2.SET_ENS_NAME_FOR) { ... }
- Arguments:
_projectId
is the ID of the project to set an ENS handle for._parts
is t
- The function can be accessed externally by anyone.
- Through the
requirePermission
modifier, the function is only accessible by the token holder, or from an operator that has been given theJBOperations2.SET_ENS_NAME_FOR
permission by the token holder. - The resulting function overrides a function definition from the
IJBProjectHandles
interface. - The function doesn't return anything.
Body
-
Get a reference to the number of parts there are in the name.
// Get a reference to the number of parts are in the ENS name.
uint256 _partsLength = _parts.length; -
Make sure there are at least some parts that make up the ENS name.
// Make sure there are ens name parts.
if (_parts.length == 0) revert NO_PARTS(); -
Make sure there aren't any empty name parts by looping through each and checking if any of them is an empty string.
// Make sure no provided parts are empty.
for (uint256 _i = 0; _i < _partsLength; ) {
if (bytes(_parts[_i]).length == 0) revert EMPTY_NAME_PART();
unchecked {
++_i;
}
} -
Store the name parts.
// Store the parts.
_ensNamePartsOf[_projectId] = _parts;Internal references:
-
Emit a
SetEnsNameParts
event with the relevant parameters.emit SetEnsNameParts(_projectId, _formatHandle(_parts), _parts, msg.sender);