Skip to main content

handleOf

Contract: JBProjectHandles​‌

Interface: IJBProjectHandles

Returns the handle for a project.

Requires a TXT record for the TEXT_KEY that matches the _projectId.

Definition

function handleOf(uint256 _projectId) external view override returns (string memory) { ... }
  • Arguments:
    • _projectId is the ID of the project to get the handle of.
  • The view function can be accessed externally by anyone.
  • The view function does not alter state on the blockchain.
  • The function overrides a function definition from the IJBProjectHandles interface.
  • The function returns the project's handle.

Body

  1. Get the project's ENS name parts.

    // Get a reference to the project's ENS name parts.
    string[] memory _ensNameParts = _ensNamePartsOf[_projectId];

    Internal references:

  2. If there are no name parts, there's no handle.

    // Return empty string if ENS isn't set.
    if (_ensNameParts.length == 0) return '';
  3. Get the projectId stored in the TEXT record of the ENS node of the stored ENS name.

    // Find the projectId that the text record of the ENS name is mapped to.
    string memory textRecordProjectId = textResolver.text(_namehash(_ensNameParts), TEXT_KEY);

    Internal references:

    External references:

  4. If the project's ID doesn't match the text record, the project has no handle.

    // Return empty string if text record from ENS name doesn't match projectId.
    if (keccak256(bytes(textRecordProjectId)) != keccak256(bytes(Strings.toString(_projectId))))
    return '';

    Library references:

  5. Return a handle formatted from the stored ENS name parts.

    // Format the handle from the name parts.
    return _formatHandle(_ensNameParts);

    Internal references: