handleOf
Contract: JBProjectHandles
Interface: IJBProjectHandles
- Step by step
- Code
- Bug bounty
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
-
Get the project's ENS name parts.
// Get a reference to the project's ENS name parts.
string[] memory _ensNameParts = _ensNamePartsOf[_projectId];Internal references:
-
If there are no name parts, there's no handle.
// Return empty string if ENS isn't set.
if (_ensNameParts.length == 0) return ''; -
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:
-
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:
Strings
.toString(...)
-
Return a handle formatted from the stored ENS name parts.
// Format the handle from the name parts.
return _formatHandle(_ensNameParts);Internal references:
/**
@notice
Returns the handle for a project.
@dev
Requires a TXT record for the `TEXT_KEY` that matches the `_projectId`.
@param _projectId The ID of the project to get the handle of.
@return The project's handle.
*/
function handleOf(uint256 _projectId) external view override returns (string memory) {
// Get a reference to the project's ENS name parts.
string[] memory _ensNameParts = _ensNamePartsOf[_projectId];
// Return empty string if ENS isn't set.
if (_ensNameParts.length == 0) return '';
// Find the projectId that the text record of the ENS name is mapped to.
string memory textRecordProjectId = textResolver.text(_namehash(_ensNameParts), TEXT_KEY);
// Return empty string if text record from ENS name doesn't match projectId.
if (keccak256(bytes(textRecordProjectId)) != keccak256(bytes(Strings.toString(_projectId))))
return '';
// Format the handle from the name parts.
return _formatHandle(_ensNameParts);
}
Category | Description | Reward |
---|---|---|
Optimization | Help make this operation more efficient. | 0.5ETH |
Low severity | Identify a vulnerability in this operation that could lead to an inconvenience for a user of the protocol or for a protocol developer. | 1ETH |
High severity | Identify a vulnerability in this operation that could lead to data corruption or loss of funds. | 5+ETH |