LensHandles

Git Source

Inherits: ERC721, ImmutableOwnable, ILensHandles

A handle is defined as a local name inside a namespace context. A handle is represented as the local name with its namespace applied as a prefix, using the slash symbol as separator. handle = /${namespace}/${localName} Handle and local name can be used interchangeably once you are in a context of a namespace, as it became redundant. handle === ${localName} ; inside some namespace.

State Variables

MAX_LOCAL_NAME_LENGTH

uint256 internal constant MAX_LOCAL_NAME_LENGTH = 26;

NAMESPACE

string internal constant NAMESPACE = "lens";

NAMESPACE_LENGTH

uint256 internal immutable NAMESPACE_LENGTH = bytes(NAMESPACE).length;

SEPARATOR_LENGTH

uint256 internal constant SEPARATOR_LENGTH = 1;

NAMESPACE_HASH

bytes32 internal constant NAMESPACE_HASH = keccak256(bytes(NAMESPACE));

TOKEN_GUARDIAN_COOLDOWN

uint256 internal immutable TOKEN_GUARDIAN_COOLDOWN;

_tokenGuardianDisablingTimestamp

mapping(address => uint256) internal _tokenGuardianDisablingTimestamp;

_localNames

mapping(uint256 tokenId => string localName) internal _localNames;

Functions

onlyOwnerOrWhitelistedProfileCreator

modifier onlyOwnerOrWhitelistedProfileCreator();

onlyEOA

modifier onlyEOA();

onlyHub

modifier onlyHub();

constructor

constructor(address owner, address lensHub, uint256 tokenGuardianCooldown)
    ERC721("", "")
    ImmutableOwnable(owner, lensHub);

name

function name() public pure override returns (string memory);

symbol

function symbol() public pure override returns (string memory);

tokenURI

See {IERC721Metadata-tokenURI}.

function tokenURI(uint256 tokenId) public view override returns (string memory);

mintHandle

Mints a handle NFT in the given namespace.

function mintHandle(address to, string calldata localName)
    external
    onlyOwnerOrWhitelistedProfileCreator
    returns (uint256);

Parameters

NameTypeDescription
toaddressThe address to mint the handle to.
localNamestringThe local name of the handle (the part before ".lens").

Returns

NameTypeDescription
<none>uint256uint256 The ID of the handle NFT minted.

migrateHandle

function migrateHandle(address to, string calldata localName) external onlyHub returns (uint256);

burn

function burn(uint256 tokenId) external;

DANGER__disableTokenGuardian


**** TOKEN GUARDIAN FUNCTIONS ****


function DANGER__disableTokenGuardian() external onlyEOA;

enableTokenGuardian

function enableTokenGuardian() external onlyEOA;

approve

function approve(address to, uint256 tokenId) public override(IERC721, ERC721);

setApprovalForAll

function setApprovalForAll(address operator, bool approved) public override(IERC721, ERC721);

exists

function exists(uint256 tokenId) external view returns (bool);

getNamespace

function getNamespace() external pure returns (string memory);

getNamespaceHash

function getNamespaceHash() external pure returns (bytes32);

getLocalName

function getLocalName(uint256 tokenId) public view returns (string memory);

getHandle

function getHandle(uint256 tokenId) public view returns (string memory);

getTokenId

function getTokenId(string memory localName) public pure returns (uint256);

getTokenGuardianDisablingTimestamp

function getTokenGuardianDisablingTimestamp(address wallet) external view returns (uint256);

_mintHandle

INTERNAL FUNCTIONS ///

function _mintHandle(address to, string calldata localName) internal returns (uint256);

_validateLocalNameMigration

This function is used to validate the local name when migrating from V1 to V2. As in V1 we also allowed the Hyphen '-' character, we need to allow it here as well and use a separate validation function for migration VS newly created handles.

function _validateLocalNameMigration(string memory localName) internal pure;

_validateLocalName

In V2 we only accept the following characters: [a-z0-9_] to be used in newly created handles. We also disallow the first character to be an underscore '_'.

function _validateLocalName(string memory localName) internal pure;

_isAlphaNumeric

We only accept lowercase characters to avoid confusion.

function _isAlphaNumeric(bytes1 char) internal pure returns (bool);

Parameters

NameTypeDescription
charbytes1The character to check.

Returns

NameTypeDescription
<none>boolTrue if the character is alphanumeric, false otherwise.

_hasTokenGuardianEnabled

function _hasTokenGuardianEnabled(address wallet) internal view returns (bool);

_beforeTokenTransfer

function _beforeTokenTransfer(address from, address to, uint256, uint256 batchSize) internal override;