MetaTxLib

Git Source

Author: Lens Protocol NOTE: the functions in this contract operate under the assumption that the passed signer is already validated to either be the originator or one of their delegated executors.

User nonces are incremented from this library as well.

State Variables

EIP712_DOMAIN_VERSION

string constant EIP712_DOMAIN_VERSION = "2";

EIP712_DOMAIN_VERSION_HASH

bytes32 constant EIP712_DOMAIN_VERSION_HASH = keccak256(bytes(EIP712_DOMAIN_VERSION));

EIP1271_MAGIC_VALUE

bytes4 constant EIP1271_MAGIC_VALUE = 0x1626ba7e;

LENS_HUB_CACHED_POLYGON_DOMAIN_SEPARATOR

We store the domain separator and LensHub Proxy address as constants to save gas. keccak256( abi.encode( keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'), keccak256('Lens Protocol Profiles'), // Contract Name keccak256('2'), // Version Hash 137, // Polygon Chain ID address(0xDb46d1Dc155634FbC732f92E853b10B288AD5a1d) // Verifying Contract Address - LensHub Address ) );

bytes32 constant LENS_HUB_CACHED_POLYGON_DOMAIN_SEPARATOR =
    0xbf9544cf7d7a0338fc4f071be35409a61e51e9caef559305410ad74e16a05f2d;

LENS_HUB_ADDRESS

address constant LENS_HUB_ADDRESS = 0xDb46d1Dc155634FbC732f92E853b10B288AD5a1d;

POLYGON_CHAIN_ID

uint256 constant POLYGON_CHAIN_ID = 137;

Functions

validateSetProfileMetadataURISignature

function validateSetProfileMetadataURISignature(
    Types.EIP712Signature calldata signature,
    uint256 profileId,
    string calldata metadataURI
) external;

validateSetFollowModuleSignature

function validateSetFollowModuleSignature(
    Types.EIP712Signature calldata signature,
    uint256 profileId,
    address followModule,
    bytes calldata followModuleInitData
) external;

validateChangeDelegatedExecutorsConfigSignature

function validateChangeDelegatedExecutorsConfigSignature(
    Types.EIP712Signature calldata signature,
    uint256 delegatorProfileId,
    address[] calldata delegatedExecutors,
    bool[] calldata approvals,
    uint64 configNumber,
    bool switchToGivenConfig
) external;

validatePostSignature

function validatePostSignature(Types.EIP712Signature calldata signature, Types.PostParams calldata postParams)
    external;

validateCommentSignature

function validateCommentSignature(Types.EIP712Signature calldata signature, Types.CommentParams calldata commentParams)
    external;

validateQuoteSignature

function validateQuoteSignature(Types.EIP712Signature calldata signature, Types.QuoteParams calldata quoteParams)
    external;

validateMirrorSignature

function validateMirrorSignature(Types.EIP712Signature calldata signature, Types.MirrorParams calldata mirrorParams)
    external;

validateFollowSignature

function validateFollowSignature(
    Types.EIP712Signature calldata signature,
    uint256 followerProfileId,
    uint256[] calldata idsOfProfilesToFollow,
    uint256[] calldata followTokenIds,
    bytes[] calldata datas
) external;

validateUnfollowSignature

function validateUnfollowSignature(
    Types.EIP712Signature calldata signature,
    uint256 unfollowerProfileId,
    uint256[] calldata idsOfProfilesToUnfollow
) external;

validateSetBlockStatusSignature

function validateSetBlockStatusSignature(
    Types.EIP712Signature calldata signature,
    uint256 byProfileId,
    uint256[] calldata idsOfProfilesToSetBlockStatus,
    bool[] calldata blockStatus
) external;

validateLegacyCollectSignature

function validateLegacyCollectSignature(
    Types.EIP712Signature calldata signature,
    Types.LegacyCollectParams calldata collectParams
) external;

validateActSignature

function validateActSignature(
    Types.EIP712Signature calldata signature,
    Types.PublicationActionParams calldata publicationActionParams
) external;

calculateDomainSeparator

function calculateDomainSeparator() internal view returns (bytes32);

_validateRecoveredAddress

Wrapper for ecrecover to reduce code size, used in meta-tx specific functions.

function _validateRecoveredAddress(bytes32 digest, Types.EIP712Signature calldata signature) private view;

_calculateDigest

Calculates EIP712 digest based on the current DOMAIN_SEPARATOR.

function _calculateDigest(bytes32 hashedMessage) private view returns (bytes32);

Parameters

NameTypeDescription
hashedMessagebytes32The message hash from which the digest should be calculated.

Returns

NameTypeDescription
<none>bytes32bytes32 A 32-byte output representing the EIP712 digest.

_getNonceIncrementAndEmitEvent

This fetches a signer's current nonce and increments it so it's ready for the next meta-tx. Also emits the NonceUpdated event.

function _getNonceIncrementAndEmitEvent(address signer) private returns (uint256);

Parameters

NameTypeDescription
signeraddressThe address to get and increment the nonce for.

Returns

NameTypeDescription
<none>uint256uint256 The current nonce for the given signer prior to being incremented.

_encodeUsingEip712Rules

function _encodeUsingEip712Rules(bytes[] memory bytesArray) private pure returns (bytes32);

_encodeUsingEip712Rules

function _encodeUsingEip712Rules(bool[] memory boolArray) private pure returns (bytes32);

_encodeUsingEip712Rules

function _encodeUsingEip712Rules(address[] memory addressArray) private pure returns (bytes32);

_encodeUsingEip712Rules

function _encodeUsingEip712Rules(uint256[] memory uint256Array) private pure returns (bytes32);

_encodeUsingEip712Rules

function _encodeUsingEip712Rules(bytes32[] memory bytes32Array) private pure returns (bytes32);

_encodeUsingEip712Rules

function _encodeUsingEip712Rules(string memory stringValue) private pure returns (bytes32);

_encodeUsingEip712Rules

function _encodeUsingEip712Rules(bytes memory bytesValue) private pure returns (bytes32);