Skip to main content

_formatHandle

Contract: JBProjectHandles​‌

Formats ENS name parts into a handle.

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

Definition

function _formatHandle(string[] memory _ensNameParts)
internal
pure
returns (string memory _handle) { ... }
  • Arguments:
    • _ensNameParts is the ENS name parts to format into a handle.
  • The view function can be accessed externally by anyone.
  • The view function does not alter state on the blockchain.
  • The function returns the formatted ENS handle.

Body

  1. Get the number of parts there are to iterate over.

    // Get a reference to the number of parts are in the ENS name.
    uint256 _partsLength = _ensNameParts.length;
  2. Loop through each part, adding the the part first so subdomains show up in order. Add a dot to seperate each subdomain.

    // Concatenate each name part.
    for (uint256 _i = 1; _i <= _partsLength; ) {
    _handle = string(abi.encodePacked(_handle, _ensNameParts[_partsLength - _i]));

    // Add a dot if this part isn't the last.
    if (_i < _partsLength) _handle = string(abi.encodePacked(_handle, '.'));

    unchecked {
    ++_i;
    }
    }