Source Code
Overview
POL Balance
Token Holdings
More Info
ContractCreator
Multichain Info
N/A
Latest 6 from a total of 6 transactions
| Transaction Hash |
Method
|
Block
|
From
|
To
|
Amount
|
||||
|---|---|---|---|---|---|---|---|---|---|
| Transfer | 11781918 | 588 days ago | IN | 3 POL | 0.00065292 | ||||
| Set Remote Zora ... | 11781706 | 588 days ago | IN | 0 POL | 0.00080242 | ||||
| Transfer | 11768323 | 588 days ago | IN | 3 POL | 0.0006129 | ||||
| Set Lz Sponsored | 11768224 | 588 days ago | IN | 0 POL | 0.00084787 | ||||
| Transfer | 11763584 | 589 days ago | IN | 0.1 POL | 0 | ||||
| Set Module Metad... | 11762795 | 589 days ago | IN | 0 POL | 0.00407886 |
Loading...
Loading
Contract Name:
ZoraLzMintActionV2
Compiler Version
v0.8.21+commit.d9974bed
Optimization Enabled:
Yes with 2000 runs
Other Settings:
london EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
/*
░▒▓███████▓▒░ ░▒▓██████▓▒░░▒▓███████▓▒░ ░▒▓███████▓▒░░▒▓██████▓▒░░▒▓█▓▒░
░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░
░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░
░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░░▒▓████████▓▒░▒▓█▓▒░
░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░
░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░
░▒▓███████▓▒░ ░▒▓██████▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░
*/
pragma solidity ^0.8.21;
import {Types} from "lens/interfaces/ILensProtocol.sol";
import {IPublicationActionModule} from "lens/interfaces/IPublicationActionModule.sol";
import {LensModuleMetadataInitializable} from "lens/modules/LensModuleMetadataInitializable.sol";
import {IERC721} from "lens/interfaces/ILensERC721.sol";
import {HubRestricted} from "lens/base/HubRestricted.sol";
import {ILensHub} from "lens/interfaces/ILensHub.sol";
import {
MessagingFee,
MessagingReceipt
} from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol";
import {OptionsBuilder} from "@layerzerolabs/oapp-evm/contracts/oapp/libs/OptionsBuilder.sol";
import {IOFT, SendParam} from "@layerzerolabs/oft-evm/contracts/interfaces/IOFT.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IZoraLzMintActionV2} from "./interfaces/IZoraLzMintActionV2.sol";
interface IWMATIC {
function withdraw(uint wad) external;
}
/**
* @title ZoraLzMintActionV2
* @notice This is a Lens Publication Action that allows creators to promote their Zora NFTs & enable in-feed mints
* using Base Bonsai.
*/
contract ZoraLzMintActionV2 is
HubRestricted,
LensModuleMetadataInitializable,
IZoraLzMintActionV2,
IPublicationActionModule
{
using SafeERC20 for IERC20;
using OptionsBuilder for bytes;
IERC20 public immutable bonsai;
IWMATIC public immutable WMATIC;
ILensHub public immutable hub;
IOFT public immutable bonsaiAdapter;
uint16 public protocolFeeBps;
bytes32 internal remoteZoraCreator;
uint32 internal remoteEid;
bool internal lzSponsored;
uint16 internal constant BPS_MAX = 10000;
uint128 internal constant DEST_GAS_LIMIT = 500_000;
uint256 internal constant ZORA_MINT_FEE_PER_MINT = 0.000777 ether;
mapping (uint256 profileId => mapping (uint256 pubId => RemoteMint)) public remoteMints;
/**
* @dev contract constructor
* @param _hub LensHub
* @param _lzEndpoint LZ endpoint contract on this chain
* @param _bonsai Bonsai token address
* @param _bonsaiAdapter BonsaiOFTAdapter
* @param _WMATIC _WMATIC
* @param _remoteZoraCreator ZoraLzCreatorV2 contract on the remote chain, in lz bytes32 format
* @param _remoteEid Default LayerZero eid on the target chain
*/
constructor(
address _hub,
address _lzEndpoint,
address _bonsai,
address _bonsaiAdapter,
address _WMATIC,
bytes32 _remoteZoraCreator,
uint32 _remoteEid
) HubRestricted(_hub) LensModuleMetadataInitializable(msg.sender) {
if (_hub == address(0) || _bonsaiAdapter == address(0) || _WMATIC == address(0)) revert NoZeroAddress();
remoteEid = _remoteEid;
bonsai = IERC20(_bonsai);
hub = ILensHub(_hub);
bonsaiAdapter = IOFT(_bonsaiAdapter);
WMATIC = IWMATIC(_WMATIC);
remoteZoraCreator = _remoteZoraCreator;
protocolFeeBps = 500; // 5%
}
/**
* @notice Allows the contract owner to set whether this contract is sponsoring lz messages
* @param _lzSponsored Whether this contract will pay the lz message fee
*/
function setLzSponsored(bool _lzSponsored) external onlyOwner {
lzSponsored = _lzSponsored;
}
/**
* @notice Allows the contract owner to set the remote ZoraLzCreator contract
* @param _remoteZoraCreator ZoraLzCreatorV2 contract on the remote chain, in lz bytes32 format
*/
function setRemoteZoraCreator(bytes32 _remoteZoraCreator) external onlyOwner {
remoteZoraCreator = _remoteZoraCreator;
}
function withdrawNative() external onlyOwner {
uint256 balance = address(this).balance;
payable(msg.sender).transfer(balance);
}
function withdrawTokens(address _token) external onlyOwner {
IERC20 token = IERC20(_token);
uint256 balance = token.balanceOf(address(this));
if (balance > 0) token.transfer(owner(), balance);
}
/**
* @notice Allows the contract owner to set the client fee for every mint
* @param _protocolFeeBps The client fee (bps)
*/
function setprotocolFeeBps(uint16 _protocolFeeBps) external onlyOwner {
protocolFeeBps = _protocolFeeBps;
}
/**
* @notice Required by Lens Protocol
*/
function supportsInterface(bytes4 interfaceID) public pure override returns (bool) {
return interfaceID == type(IPublicationActionModule).interfaceId || super.supportsInterface(interfaceID);
}
/**
* @notice Initializes the action module for the given publication being published with this Action module.
* @custom:permissions LensHub.
*
* @param profileId The profile ID of the author publishing the content with this Publication Action.
* @param pubId The publication ID being published.
* @param data Arbitrary data passed from the user to be decoded by the Action Module during initialization.
*
* @return bytes Any custom ABI-encoded data. This will be a LensHub event params that can be used by
* indexers or UIs.
*/
function initializePublicationAction(
uint256 profileId,
uint256 pubId,
address, // transactionExecutor
bytes calldata data
) external override onlyHub returns (bytes memory) {
(
address token,
uint256 tokenId,
uint96 salePrice
) = abi.decode(data, (address, uint256, uint96));
if (token == address(0) || tokenId == 0) revert InitParamsInvalid();
remoteMints[profileId][pubId] = RemoteMint({
token: token,
tokenId: tokenId,
salePrice: salePrice
});
emit InitAction(profileId, pubId, token, tokenId);
return data;
}
/**
* @notice Processes the action for a given publication. This includes the action's logic and any monetary/token
* operations.
* @custom:permissions LensHub.
*
* @param processActionParams The parameters needed to execute the publication action.
*
* @return bytes Any custom ABI-encoded data. This will be a LensHub event params that can be used by
* indexers or UIs.
*/
function processPublicationAction(
Types.ProcessActionParams calldata processActionParams
) external override onlyHub returns (bytes memory) {
RemoteMint memory data = remoteMints[processActionParams.publicationActedProfileId][
processActionParams.publicationActedId
];
(
uint256 quantity,
address clientAddress
) = abi.decode(processActionParams.actionModuleData, (uint256, address));
if (quantity == 0 ||
clientAddress == processActionParams.transactionExecutor ||
clientAddress == processActionParams.actorProfileOwner
) revert InvalidInput();
// prep all the data needed
address referrer = processActionParams.referrerProfileIds.length > 0
? _owner(processActionParams.referrerProfileIds[0])
: address(0);
bytes memory payload = _encodePayload(
data.token,
data.tokenId,
processActionParams.actorProfileOwner,
referrer,
quantity
);
uint256 zoraFee = _handlePayment(
processActionParams.transactionExecutor,
clientAddress,
data.salePrice,
quantity,
getTotalSalePrice(data.salePrice, quantity)
);
bonsai.approve(address(bonsaiAdapter), zoraFee);
// send tokens to the zora creator on the destination chain, including the mint payload
SendParam memory sendParam = SendParam(
remoteEid,
remoteZoraCreator,
zoraFee,
zoraFee,
OptionsBuilder.newOptions().addExecutorLzReceiveOption(DEST_GAS_LIMIT, 0).addExecutorLzComposeOption(0, DEST_GAS_LIMIT, 0),
payload,
""
);
// quote for native fee to send tokens including payload
MessagingFee memory fee = bonsaiAdapter.quoteSend(sendParam, false);
MessagingReceipt memory msgReceipt;
if (lzSponsored) {
(msgReceipt,) = bonsaiAdapter.send{ value: fee.nativeFee }(sendParam, fee, address(this));
} else {
// tx executor must have approved the wmatic transfer to cover the relay fee
IERC20(address(WMATIC))
.safeTransferFrom(processActionParams.transactionExecutor, address(this), fee.nativeFee);
WMATIC.withdraw(fee.nativeFee);
(msgReceipt,) = bonsaiAdapter
.send{ value: fee.nativeFee }(sendParam, fee, payable(processActionParams.transactionExecutor));
}
emit MintIntentRelayed(
processActionParams.publicationActedProfileId,
processActionParams.publicationActedId,
processActionParams.actorProfileId
);
return abi.encode(quantity, payload, msgReceipt.guid, msgReceipt.nonce, zoraFee);
}
/**
* @notice Estimate the relay fees for `#processPublicationAction`
* @return fee The calculated MessagingFee
*/
function quote(LzQuoteInput memory input) external view returns (MessagingFee memory fee) {
RemoteMint memory data = remoteMints[input.profileId][input.pubId];
bytes memory payload =
_encodePayload(data.token, data.tokenId, input.profileOwner, input.profileOwner, input.quantity);
uint256 salePrice = data.salePrice * input.quantity; // estimate for total tokens
SendParam memory sendParam = SendParam(
remoteEid,
remoteZoraCreator,
salePrice,
salePrice,
OptionsBuilder.newOptions().addExecutorLzReceiveOption(DEST_GAS_LIMIT, 0).addExecutorLzComposeOption(0, DEST_GAS_LIMIT, 0),
payload,
""
);
return bonsaiAdapter.quoteSend(sendParam, false);
}
/**
* @notice Get the total sale price for a Zora NFT promoted on a publication
* @param publicationActedProfileId the publication profile id to act on
* @param publicationActedId the publication id to act on
* @param quantity the amount of NFTs to mint
* @return uint256 total sale price
*/
function getTotalSalePrice(
uint256 publicationActedProfileId,
uint256 publicationActedId,
uint256 quantity
) public view returns (uint256) {
return getTotalSalePrice(remoteMints[publicationActedProfileId][publicationActedId].salePrice, quantity);
}
/**
* @notice Get the total sale price for a Zora NFT, including client + protocol fees
* @param salePrice The sale price of the NFT
* @param quantity the amount of NFTs to mint
* @return uint256 total sale price
*/
function getTotalSalePrice(uint96 salePrice, uint256 quantity) public view returns (uint256) {
uint256 cost = salePrice * quantity;
uint256 mintFee = (salePrice + ZORA_MINT_FEE_PER_MINT) * quantity;
uint256 protocolFee = (cost * protocolFeeBps) / BPS_MAX;
uint256 lensFee = (cost * hub.getTreasuryFee()) / BPS_MAX;
return mintFee + protocolFee + lensFee;
}
/**
* @dev Encodes the payload to mint on the destination chain
*/
function _encodePayload(
address token,
uint256 tokenId,
address profileOwner,
address referrerProfileOwner,
uint256 quantity
) internal pure returns (bytes memory) {
return abi.encode(
token,
tokenId,
quantity,
profileOwner,
referrerProfileOwner
);
}
/**
* @dev Transfer in the mint fee, including treasury, protocol fees
*/
function _handlePayment(
address transactionExecutor,
address clientAddress,
uint256 salePrice,
uint256 quantity,
uint256 totalSalePrice
) internal returns (uint256 mintFee) {
bonsai.safeTransferFrom(transactionExecutor, address(this), totalSalePrice);
uint256 cost = salePrice * quantity;
bonsai.safeTransfer(hub.getTreasury(), (cost * hub.getTreasuryFee()) / BPS_MAX);
// if a client address is passed in, share half the protocol fee
if (clientAddress != address(0)) {
bonsai.safeTransfer(clientAddress, ((cost * protocolFeeBps) / BPS_MAX) / 2);
}
mintFee = (salePrice + ZORA_MINT_FEE_PER_MINT) * quantity;
}
/**
* @dev Gets the profile owner
*/
function _owner(uint256 profileId) internal view returns (address) {
return IERC721(HUB).ownerOf(profileId);
}
// Function to allow receiving MATIC native currency (from WMATIC#withdraw)
receive() external payable {}
fallback() external payable {}
}// SPDX-License-Identifier: LZBL-1.2
pragma solidity ^0.8.20;
import { BytesLib } from "solidity-bytes-utils/contracts/BytesLib.sol";
import { BitMap256 } from "@layerzerolabs/lz-evm-protocol-v2/contracts/messagelib/libs/BitMaps.sol";
import { CalldataBytesLib } from "@layerzerolabs/lz-evm-protocol-v2/contracts/libs/CalldataBytesLib.sol";
library DVNOptions {
using CalldataBytesLib for bytes;
using BytesLib for bytes;
uint8 internal constant WORKER_ID = 2;
uint8 internal constant OPTION_TYPE_PRECRIME = 1;
error DVN_InvalidDVNIdx();
error DVN_InvalidDVNOptions(uint256 cursor);
/// @dev group dvn options by its idx
/// @param _options [dvn_id][dvn_option][dvn_id][dvn_option]...
/// dvn_option = [option_size][dvn_idx][option_type][option]
/// option_size = len(dvn_idx) + len(option_type) + len(option)
/// dvn_id: uint8, dvn_idx: uint8, option_size: uint16, option_type: uint8, option: bytes
/// @return dvnOptions the grouped options, still share the same format of _options
/// @return dvnIndices the dvn indices
function groupDVNOptionsByIdx(
bytes memory _options
) internal pure returns (bytes[] memory dvnOptions, uint8[] memory dvnIndices) {
if (_options.length == 0) return (dvnOptions, dvnIndices);
uint8 numDVNs = getNumDVNs(_options);
// if there is only 1 dvn, we can just return the whole options
if (numDVNs == 1) {
dvnOptions = new bytes[](1);
dvnOptions[0] = _options;
dvnIndices = new uint8[](1);
dvnIndices[0] = _options.toUint8(3); // dvn idx
return (dvnOptions, dvnIndices);
}
// otherwise, we need to group the options by dvn_idx
dvnIndices = new uint8[](numDVNs);
dvnOptions = new bytes[](numDVNs);
unchecked {
uint256 cursor = 0;
uint256 start = 0;
uint8 lastDVNIdx = 255; // 255 is an invalid dvn_idx
while (cursor < _options.length) {
++cursor; // skip worker_id
// optionLength asserted in getNumDVNs (skip check)
uint16 optionLength = _options.toUint16(cursor);
cursor += 2;
// dvnIdx asserted in getNumDVNs (skip check)
uint8 dvnIdx = _options.toUint8(cursor);
// dvnIdx must equal to the lastDVNIdx for the first option
// so it is always skipped in the first option
// this operation slices out options whenever the scan finds a different lastDVNIdx
if (lastDVNIdx == 255) {
lastDVNIdx = dvnIdx;
} else if (dvnIdx != lastDVNIdx) {
uint256 len = cursor - start - 3; // 3 is for worker_id and option_length
bytes memory opt = _options.slice(start, len);
_insertDVNOptions(dvnOptions, dvnIndices, lastDVNIdx, opt);
// reset the start and lastDVNIdx
start += len;
lastDVNIdx = dvnIdx;
}
cursor += optionLength;
}
// skip check the cursor here because the cursor is asserted in getNumDVNs
// if we have reached the end of the options, we need to process the last dvn
uint256 size = cursor - start;
bytes memory op = _options.slice(start, size);
_insertDVNOptions(dvnOptions, dvnIndices, lastDVNIdx, op);
// revert dvnIndices to start from 0
for (uint8 i = 0; i < numDVNs; ++i) {
--dvnIndices[i];
}
}
}
function _insertDVNOptions(
bytes[] memory _dvnOptions,
uint8[] memory _dvnIndices,
uint8 _dvnIdx,
bytes memory _newOptions
) internal pure {
// dvnIdx starts from 0 but default value of dvnIndices is 0,
// so we tell if the slot is empty by adding 1 to dvnIdx
if (_dvnIdx == 255) revert DVN_InvalidDVNIdx();
uint8 dvnIdxAdj = _dvnIdx + 1;
for (uint256 j = 0; j < _dvnIndices.length; ++j) {
uint8 index = _dvnIndices[j];
if (dvnIdxAdj == index) {
_dvnOptions[j] = abi.encodePacked(_dvnOptions[j], _newOptions);
break;
} else if (index == 0) {
// empty slot, that means it is the first time we see this dvn
_dvnIndices[j] = dvnIdxAdj;
_dvnOptions[j] = _newOptions;
break;
}
}
}
/// @dev get the number of unique dvns
/// @param _options the format is the same as groupDVNOptionsByIdx
function getNumDVNs(bytes memory _options) internal pure returns (uint8 numDVNs) {
uint256 cursor = 0;
BitMap256 bitmap;
// find number of unique dvn_idx
unchecked {
while (cursor < _options.length) {
++cursor; // skip worker_id
uint16 optionLength = _options.toUint16(cursor);
cursor += 2;
if (optionLength < 2) revert DVN_InvalidDVNOptions(cursor); // at least 1 byte for dvn_idx and 1 byte for option_type
uint8 dvnIdx = _options.toUint8(cursor);
// if dvnIdx is not set, increment numDVNs
// max num of dvns is 255, 255 is an invalid dvn_idx
// The order of the dvnIdx is not required to be sequential, as enforcing the order may weaken
// the composability of the options. e.g. if we refrain from enforcing the order, an OApp that has
// already enforced certain options can append additional options to the end of the enforced
// ones without restrictions.
if (dvnIdx == 255) revert DVN_InvalidDVNIdx();
if (!bitmap.get(dvnIdx)) {
++numDVNs;
bitmap = bitmap.set(dvnIdx);
}
cursor += optionLength;
}
}
if (cursor != _options.length) revert DVN_InvalidDVNOptions(cursor);
}
/// @dev decode the next dvn option from _options starting from the specified cursor
/// @param _options the format is the same as groupDVNOptionsByIdx
/// @param _cursor the cursor to start decoding
/// @return optionType the type of the option
/// @return option the option
/// @return cursor the cursor to start decoding the next option
function nextDVNOption(
bytes calldata _options,
uint256 _cursor
) internal pure returns (uint8 optionType, bytes calldata option, uint256 cursor) {
unchecked {
// skip worker id
cursor = _cursor + 1;
// read option size
uint16 size = _options.toU16(cursor);
cursor += 2;
// read option type
optionType = _options.toU8(cursor + 1); // skip dvn_idx
// startCursor and endCursor are used to slice the option from _options
uint256 startCursor = cursor + 2; // skip option type and dvn_idx
uint256 endCursor = cursor + size;
option = _options[startCursor:endCursor];
cursor += size;
}
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
import { IMessageLibManager } from "./IMessageLibManager.sol";
import { IMessagingComposer } from "./IMessagingComposer.sol";
import { IMessagingChannel } from "./IMessagingChannel.sol";
import { IMessagingContext } from "./IMessagingContext.sol";
struct MessagingParams {
uint32 dstEid;
bytes32 receiver;
bytes message;
bytes options;
bool payInLzToken;
}
struct MessagingReceipt {
bytes32 guid;
uint64 nonce;
MessagingFee fee;
}
struct MessagingFee {
uint256 nativeFee;
uint256 lzTokenFee;
}
struct Origin {
uint32 srcEid;
bytes32 sender;
uint64 nonce;
}
interface ILayerZeroEndpointV2 is IMessageLibManager, IMessagingComposer, IMessagingChannel, IMessagingContext {
event PacketSent(bytes encodedPayload, bytes options, address sendLibrary);
event PacketVerified(Origin origin, address receiver, bytes32 payloadHash);
event PacketDelivered(Origin origin, address receiver);
event LzReceiveAlert(
address indexed receiver,
address indexed executor,
Origin origin,
bytes32 guid,
uint256 gas,
uint256 value,
bytes message,
bytes extraData,
bytes reason
);
event LzTokenSet(address token);
event DelegateSet(address sender, address delegate);
function quote(MessagingParams calldata _params, address _sender) external view returns (MessagingFee memory);
function send(
MessagingParams calldata _params,
address _refundAddress
) external payable returns (MessagingReceipt memory);
function verify(Origin calldata _origin, address _receiver, bytes32 _payloadHash) external;
function verifiable(Origin calldata _origin, address _receiver) external view returns (bool);
function initializable(Origin calldata _origin, address _receiver) external view returns (bool);
function lzReceive(
Origin calldata _origin,
address _receiver,
bytes32 _guid,
bytes calldata _message,
bytes calldata _extraData
) external payable;
// oapp can burn messages partially by calling this function with its own business logic if messages are verified in order
function clear(address _oapp, Origin calldata _origin, bytes32 _guid, bytes calldata _message) external;
function setLzToken(address _lzToken) external;
function lzToken() external view returns (address);
function nativeToken() external view returns (address);
function setDelegate(address _delegate) external;
}// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
struct SetConfigParam {
uint32 eid;
uint32 configType;
bytes config;
}
interface IMessageLibManager {
struct Timeout {
address lib;
uint256 expiry;
}
event LibraryRegistered(address newLib);
event DefaultSendLibrarySet(uint32 eid, address newLib);
event DefaultReceiveLibrarySet(uint32 eid, address newLib);
event DefaultReceiveLibraryTimeoutSet(uint32 eid, address oldLib, uint256 expiry);
event SendLibrarySet(address sender, uint32 eid, address newLib);
event ReceiveLibrarySet(address receiver, uint32 eid, address newLib);
event ReceiveLibraryTimeoutSet(address receiver, uint32 eid, address oldLib, uint256 timeout);
function registerLibrary(address _lib) external;
function isRegisteredLibrary(address _lib) external view returns (bool);
function getRegisteredLibraries() external view returns (address[] memory);
function setDefaultSendLibrary(uint32 _eid, address _newLib) external;
function defaultSendLibrary(uint32 _eid) external view returns (address);
function setDefaultReceiveLibrary(uint32 _eid, address _newLib, uint256 _gracePeriod) external;
function defaultReceiveLibrary(uint32 _eid) external view returns (address);
function setDefaultReceiveLibraryTimeout(uint32 _eid, address _lib, uint256 _expiry) external;
function defaultReceiveLibraryTimeout(uint32 _eid) external view returns (address lib, uint256 expiry);
function isSupportedEid(uint32 _eid) external view returns (bool);
function isValidReceiveLibrary(address _receiver, uint32 _eid, address _lib) external view returns (bool);
/// ------------------- OApp interfaces -------------------
function setSendLibrary(address _oapp, uint32 _eid, address _newLib) external;
function getSendLibrary(address _sender, uint32 _eid) external view returns (address lib);
function isDefaultSendLibrary(address _sender, uint32 _eid) external view returns (bool);
function setReceiveLibrary(address _oapp, uint32 _eid, address _newLib, uint256 _gracePeriod) external;
function getReceiveLibrary(address _receiver, uint32 _eid) external view returns (address lib, bool isDefault);
function setReceiveLibraryTimeout(address _oapp, uint32 _eid, address _lib, uint256 _expiry) external;
function receiveLibraryTimeout(address _receiver, uint32 _eid) external view returns (address lib, uint256 expiry);
function setConfig(address _oapp, address _lib, SetConfigParam[] calldata _params) external;
function getConfig(
address _oapp,
address _lib,
uint32 _eid,
uint32 _configType
) external view returns (bytes memory config);
}// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
interface IMessagingChannel {
event InboundNonceSkipped(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce);
event PacketNilified(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce, bytes32 payloadHash);
event PacketBurnt(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce, bytes32 payloadHash);
function eid() external view returns (uint32);
// this is an emergency function if a message cannot be verified for some reasons
// required to provide _nextNonce to avoid race condition
function skip(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce) external;
function nilify(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) external;
function burn(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) external;
function nextGuid(address _sender, uint32 _dstEid, bytes32 _receiver) external view returns (bytes32);
function inboundNonce(address _receiver, uint32 _srcEid, bytes32 _sender) external view returns (uint64);
function outboundNonce(address _sender, uint32 _dstEid, bytes32 _receiver) external view returns (uint64);
function inboundPayloadHash(
address _receiver,
uint32 _srcEid,
bytes32 _sender,
uint64 _nonce
) external view returns (bytes32);
function lazyInboundNonce(address _receiver, uint32 _srcEid, bytes32 _sender) external view returns (uint64);
}// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
interface IMessagingComposer {
event ComposeSent(address from, address to, bytes32 guid, uint16 index, bytes message);
event ComposeDelivered(address from, address to, bytes32 guid, uint16 index);
event LzComposeAlert(
address indexed from,
address indexed to,
address indexed executor,
bytes32 guid,
uint16 index,
uint256 gas,
uint256 value,
bytes message,
bytes extraData,
bytes reason
);
function composeQueue(
address _from,
address _to,
bytes32 _guid,
uint16 _index
) external view returns (bytes32 messageHash);
function sendCompose(address _to, bytes32 _guid, uint16 _index, bytes calldata _message) external;
function lzCompose(
address _from,
address _to,
bytes32 _guid,
uint16 _index,
bytes calldata _message,
bytes calldata _extraData
) external payable;
}// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
interface IMessagingContext {
function isSendingMessage() external view returns (bool);
function getSendContext() external view returns (uint32 dstEid, address sender);
}// SPDX-License-Identifier: LZBL-1.2
pragma solidity ^0.8.20;
library CalldataBytesLib {
function toU8(bytes calldata _bytes, uint256 _start) internal pure returns (uint8) {
return uint8(_bytes[_start]);
}
function toU16(bytes calldata _bytes, uint256 _start) internal pure returns (uint16) {
unchecked {
uint256 end = _start + 2;
return uint16(bytes2(_bytes[_start:end]));
}
}
function toU32(bytes calldata _bytes, uint256 _start) internal pure returns (uint32) {
unchecked {
uint256 end = _start + 4;
return uint32(bytes4(_bytes[_start:end]));
}
}
function toU64(bytes calldata _bytes, uint256 _start) internal pure returns (uint64) {
unchecked {
uint256 end = _start + 8;
return uint64(bytes8(_bytes[_start:end]));
}
}
function toU128(bytes calldata _bytes, uint256 _start) internal pure returns (uint128) {
unchecked {
uint256 end = _start + 16;
return uint128(bytes16(_bytes[_start:end]));
}
}
function toU256(bytes calldata _bytes, uint256 _start) internal pure returns (uint256) {
unchecked {
uint256 end = _start + 32;
return uint256(bytes32(_bytes[_start:end]));
}
}
function toAddr(bytes calldata _bytes, uint256 _start) internal pure returns (address) {
unchecked {
uint256 end = _start + 20;
return address(bytes20(_bytes[_start:end]));
}
}
function toB32(bytes calldata _bytes, uint256 _start) internal pure returns (bytes32) {
unchecked {
uint256 end = _start + 32;
return bytes32(_bytes[_start:end]);
}
}
}// SPDX-License-Identifier: MIT
// modified from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/structs/BitMaps.sol
pragma solidity ^0.8.20;
type BitMap256 is uint256;
using BitMaps for BitMap256 global;
library BitMaps {
/**
* @dev Returns whether the bit at `index` is set.
*/
function get(BitMap256 bitmap, uint8 index) internal pure returns (bool) {
uint256 mask = 1 << index;
return BitMap256.unwrap(bitmap) & mask != 0;
}
/**
* @dev Sets the bit at `index`.
*/
function set(BitMap256 bitmap, uint8 index) internal pure returns (BitMap256) {
uint256 mask = 1 << index;
return BitMap256.wrap(BitMap256.unwrap(bitmap) | mask);
}
}// SPDX-License-Identifier: LZBL-1.2
pragma solidity ^0.8.20;
import { CalldataBytesLib } from "../../libs/CalldataBytesLib.sol";
library ExecutorOptions {
using CalldataBytesLib for bytes;
uint8 internal constant WORKER_ID = 1;
uint8 internal constant OPTION_TYPE_LZRECEIVE = 1;
uint8 internal constant OPTION_TYPE_NATIVE_DROP = 2;
uint8 internal constant OPTION_TYPE_LZCOMPOSE = 3;
uint8 internal constant OPTION_TYPE_ORDERED_EXECUTION = 4;
error Executor_InvalidLzReceiveOption();
error Executor_InvalidNativeDropOption();
error Executor_InvalidLzComposeOption();
/// @dev decode the next executor option from the options starting from the specified cursor
/// @param _options [executor_id][executor_option][executor_id][executor_option]...
/// executor_option = [option_size][option_type][option]
/// option_size = len(option_type) + len(option)
/// executor_id: uint8, option_size: uint16, option_type: uint8, option: bytes
/// @param _cursor the cursor to start decoding from
/// @return optionType the type of the option
/// @return option the option of the executor
/// @return cursor the cursor to start decoding the next executor option
function nextExecutorOption(
bytes calldata _options,
uint256 _cursor
) internal pure returns (uint8 optionType, bytes calldata option, uint256 cursor) {
unchecked {
// skip worker id
cursor = _cursor + 1;
// read option size
uint16 size = _options.toU16(cursor);
cursor += 2;
// read option type
optionType = _options.toU8(cursor);
// startCursor and endCursor are used to slice the option from _options
uint256 startCursor = cursor + 1; // skip option type
uint256 endCursor = cursor + size;
option = _options[startCursor:endCursor];
cursor += size;
}
}
function decodeLzReceiveOption(bytes calldata _option) internal pure returns (uint128 gas, uint128 value) {
if (_option.length != 16 && _option.length != 32) revert Executor_InvalidLzReceiveOption();
gas = _option.toU128(0);
value = _option.length == 32 ? _option.toU128(16) : 0;
}
function decodeNativeDropOption(bytes calldata _option) internal pure returns (uint128 amount, bytes32 receiver) {
if (_option.length != 48) revert Executor_InvalidNativeDropOption();
amount = _option.toU128(0);
receiver = _option.toB32(16);
}
function decodeLzComposeOption(
bytes calldata _option
) internal pure returns (uint16 index, uint128 gas, uint128 value) {
if (_option.length != 18 && _option.length != 34) revert Executor_InvalidLzComposeOption();
index = _option.toU16(0);
gas = _option.toU128(2);
value = _option.length == 34 ? _option.toU128(18) : 0;
}
function encodeLzReceiveOption(uint128 _gas, uint128 _value) internal pure returns (bytes memory) {
return _value == 0 ? abi.encodePacked(_gas) : abi.encodePacked(_gas, _value);
}
function encodeNativeDropOption(uint128 _amount, bytes32 _receiver) internal pure returns (bytes memory) {
return abi.encodePacked(_amount, _receiver);
}
function encodeLzComposeOption(uint16 _index, uint128 _gas, uint128 _value) internal pure returns (bytes memory) {
return _value == 0 ? abi.encodePacked(_index, _gas) : abi.encodePacked(_index, _gas, _value);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import { ILayerZeroEndpointV2 } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol";
/**
* @title IOAppCore
*/
interface IOAppCore {
// Custom error messages
error OnlyPeer(uint32 eid, bytes32 sender);
error NoPeer(uint32 eid);
error InvalidEndpointCall();
error InvalidDelegate();
// Event emitted when a peer (OApp) is set for a corresponding endpoint
event PeerSet(uint32 eid, bytes32 peer);
/**
* @notice Retrieves the OApp version information.
* @return senderVersion The version of the OAppSender.sol contract.
* @return receiverVersion The version of the OAppReceiver.sol contract.
*/
function oAppVersion() external view returns (uint64 senderVersion, uint64 receiverVersion);
/**
* @notice Retrieves the LayerZero endpoint associated with the OApp.
* @return iEndpoint The LayerZero endpoint as an interface.
*/
function endpoint() external view returns (ILayerZeroEndpointV2 iEndpoint);
/**
* @notice Retrieves the peer (OApp) associated with a corresponding endpoint.
* @param _eid The endpoint ID.
* @return peer The peer address (OApp instance) associated with the corresponding endpoint.
*/
function peers(uint32 _eid) external view returns (bytes32 peer);
/**
* @notice Sets the peer address (OApp instance) for a corresponding endpoint.
* @param _eid The endpoint ID.
* @param _peer The address of the peer to be associated with the corresponding endpoint.
*/
function setPeer(uint32 _eid, bytes32 _peer) external;
/**
* @notice Sets the delegate address for the OApp Core.
* @param _delegate The address of the delegate to be set.
*/
function setDelegate(address _delegate) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import { BytesLib } from "solidity-bytes-utils/contracts/BytesLib.sol";
import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol";
import { ExecutorOptions } from "@layerzerolabs/lz-evm-protocol-v2/contracts/messagelib/libs/ExecutorOptions.sol";
import { DVNOptions } from "@layerzerolabs/lz-evm-messagelib-v2/contracts/uln/libs/DVNOptions.sol";
/**
* @title OptionsBuilder
* @dev Library for building and encoding various message options.
*/
library OptionsBuilder {
using SafeCast for uint256;
using BytesLib for bytes;
// Constants for options types
uint16 internal constant TYPE_1 = 1; // legacy options type 1
uint16 internal constant TYPE_2 = 2; // legacy options type 2
uint16 internal constant TYPE_3 = 3;
// Custom error message
error InvalidSize(uint256 max, uint256 actual);
error InvalidOptionType(uint16 optionType);
// Modifier to ensure only options of type 3 are used
modifier onlyType3(bytes memory _options) {
if (_options.toUint16(0) != TYPE_3) revert InvalidOptionType(_options.toUint16(0));
_;
}
/**
* @dev Creates a new options container with type 3.
* @return options The newly created options container.
*/
function newOptions() internal pure returns (bytes memory) {
return abi.encodePacked(TYPE_3);
}
/**
* @dev Adds an executor LZ receive option to the existing options.
* @param _options The existing options container.
* @param _gas The gasLimit used on the lzReceive() function in the OApp.
* @param _value The msg.value passed to the lzReceive() function in the OApp.
* @return options The updated options container.
*
* @dev When multiples of this option are added, they are summed by the executor
* eg. if (_gas: 200k, and _value: 1 ether) AND (_gas: 100k, _value: 0.5 ether) are sent in an option to the LayerZeroEndpoint,
* that becomes (300k, 1.5 ether) when the message is executed on the remote lzReceive() function.
*/
function addExecutorLzReceiveOption(
bytes memory _options,
uint128 _gas,
uint128 _value
) internal pure onlyType3(_options) returns (bytes memory) {
bytes memory option = ExecutorOptions.encodeLzReceiveOption(_gas, _value);
return addExecutorOption(_options, ExecutorOptions.OPTION_TYPE_LZRECEIVE, option);
}
/**
* @dev Adds an executor native drop option to the existing options.
* @param _options The existing options container.
* @param _amount The amount for the native value that is airdropped to the 'receiver'.
* @param _receiver The receiver address for the native drop option.
* @return options The updated options container.
*
* @dev When multiples of this option are added, they are summed by the executor on the remote chain.
*/
function addExecutorNativeDropOption(
bytes memory _options,
uint128 _amount,
bytes32 _receiver
) internal pure onlyType3(_options) returns (bytes memory) {
bytes memory option = ExecutorOptions.encodeNativeDropOption(_amount, _receiver);
return addExecutorOption(_options, ExecutorOptions.OPTION_TYPE_NATIVE_DROP, option);
}
/**
* @dev Adds an executor LZ compose option to the existing options.
* @param _options The existing options container.
* @param _index The index for the lzCompose() function call.
* @param _gas The gasLimit for the lzCompose() function call.
* @param _value The msg.value for the lzCompose() function call.
* @return options The updated options container.
*
* @dev When multiples of this option are added, they are summed PER index by the executor on the remote chain.
* @dev If the OApp sends N lzCompose calls on the remote, you must provide N incremented indexes starting with 0.
* ie. When your remote OApp composes (N = 3) messages, you must set this option for index 0,1,2
*/
function addExecutorLzComposeOption(
bytes memory _options,
uint16 _index,
uint128 _gas,
uint128 _value
) internal pure onlyType3(_options) returns (bytes memory) {
bytes memory option = ExecutorOptions.encodeLzComposeOption(_index, _gas, _value);
return addExecutorOption(_options, ExecutorOptions.OPTION_TYPE_LZCOMPOSE, option);
}
/**
* @dev Adds an executor ordered execution option to the existing options.
* @param _options The existing options container.
* @return options The updated options container.
*/
function addExecutorOrderedExecutionOption(
bytes memory _options
) internal pure onlyType3(_options) returns (bytes memory) {
return addExecutorOption(_options, ExecutorOptions.OPTION_TYPE_ORDERED_EXECUTION, bytes(""));
}
/**
* @dev Adds a DVN pre-crime option to the existing options.
* @param _options The existing options container.
* @param _dvnIdx The DVN index for the pre-crime option.
* @return options The updated options container.
*/
function addDVNPreCrimeOption(
bytes memory _options,
uint8 _dvnIdx
) internal pure onlyType3(_options) returns (bytes memory) {
return addDVNOption(_options, _dvnIdx, DVNOptions.OPTION_TYPE_PRECRIME, bytes(""));
}
/**
* @dev Adds an executor option to the existing options.
* @param _options The existing options container.
* @param _optionType The type of the executor option.
* @param _option The encoded data for the executor option.
* @return options The updated options container.
*/
function addExecutorOption(
bytes memory _options,
uint8 _optionType,
bytes memory _option
) internal pure onlyType3(_options) returns (bytes memory) {
return
abi.encodePacked(
_options,
ExecutorOptions.WORKER_ID,
_option.length.toUint16() + 1, // +1 for optionType
_optionType,
_option
);
}
/**
* @dev Adds a DVN option to the existing options.
* @param _options The existing options container.
* @param _dvnIdx The DVN index for the DVN option.
* @param _optionType The type of the DVN option.
* @param _option The encoded data for the DVN option.
* @return options The updated options container.
*/
function addDVNOption(
bytes memory _options,
uint8 _dvnIdx,
uint8 _optionType,
bytes memory _option
) internal pure onlyType3(_options) returns (bytes memory) {
return
abi.encodePacked(
_options,
DVNOptions.WORKER_ID,
_option.length.toUint16() + 2, // +2 for optionType and dvnIdx
_dvnIdx,
_optionType,
_option
);
}
/**
* @dev Encodes legacy options of type 1.
* @param _executionGas The gasLimit value passed to lzReceive().
* @return legacyOptions The encoded legacy options.
*/
function encodeLegacyOptionsType1(uint256 _executionGas) internal pure returns (bytes memory) {
if (_executionGas > type(uint128).max) revert InvalidSize(type(uint128).max, _executionGas);
return abi.encodePacked(TYPE_1, _executionGas);
}
/**
* @dev Encodes legacy options of type 2.
* @param _executionGas The gasLimit value passed to lzReceive().
* @param _nativeForDst The amount of native air dropped to the receiver.
* @param _receiver The _nativeForDst receiver address.
* @return legacyOptions The encoded legacy options of type 2.
*/
function encodeLegacyOptionsType2(
uint256 _executionGas,
uint256 _nativeForDst,
bytes memory _receiver // @dev Use bytes instead of bytes32 in legacy type 2 for _receiver.
) internal pure returns (bytes memory) {
if (_executionGas > type(uint128).max) revert InvalidSize(type(uint128).max, _executionGas);
if (_nativeForDst > type(uint128).max) revert InvalidSize(type(uint128).max, _nativeForDst);
if (_receiver.length > 32) revert InvalidSize(32, _receiver.length);
return abi.encodePacked(TYPE_2, _executionGas, _nativeForDst, _receiver);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { IOAppCore, ILayerZeroEndpointV2 } from "./interfaces/IOAppCore.sol";
/**
* @title OAppCore
* @dev Abstract contract implementing the IOAppCore interface with basic OApp configurations.
*/
abstract contract OAppCore is IOAppCore, Ownable {
// The LayerZero endpoint associated with the given OApp
ILayerZeroEndpointV2 public immutable endpoint;
// Mapping to store peers associated with corresponding endpoints
mapping(uint32 eid => bytes32 peer) public peers;
/**
* @dev Constructor to initialize the OAppCore with the provided endpoint and delegate.
* @param _endpoint The address of the LOCAL Layer Zero endpoint.
* @param _delegate The delegate capable of making OApp configurations inside of the endpoint.
*
* @dev The delegate typically should be set as the owner of the contract.
*/
constructor(address _endpoint, address _delegate) {
endpoint = ILayerZeroEndpointV2(_endpoint);
if (_delegate == address(0)) revert InvalidDelegate();
endpoint.setDelegate(_delegate);
}
/**
* @notice Sets the peer address (OApp instance) for a corresponding endpoint.
* @param _eid The endpoint ID.
* @param _peer The address of the peer to be associated with the corresponding endpoint.
*
* @dev Only the owner/admin of the OApp can call this function.
* @dev Indicates that the peer is trusted to send LayerZero messages to this OApp.
* @dev Set this to bytes32(0) to remove the peer address.
* @dev Peer is a bytes32 to accommodate non-evm chains.
*/
function setPeer(uint32 _eid, bytes32 _peer) public virtual onlyOwner {
_setPeer(_eid, _peer);
}
/**
* @notice Sets the peer address (OApp instance) for a corresponding endpoint.
* @param _eid The endpoint ID.
* @param _peer The address of the peer to be associated with the corresponding endpoint.
*
* @dev Indicates that the peer is trusted to send LayerZero messages to this OApp.
* @dev Set this to bytes32(0) to remove the peer address.
* @dev Peer is a bytes32 to accommodate non-evm chains.
*/
function _setPeer(uint32 _eid, bytes32 _peer) internal virtual {
peers[_eid] = _peer;
emit PeerSet(_eid, _peer);
}
/**
* @notice Internal function to get the peer address associated with a specific endpoint; reverts if NOT set.
* ie. the peer is set to bytes32(0).
* @param _eid The endpoint ID.
* @return peer The address of the peer associated with the specified endpoint.
*/
function _getPeerOrRevert(uint32 _eid) internal view virtual returns (bytes32) {
bytes32 peer = peers[_eid];
if (peer == bytes32(0)) revert NoPeer(_eid);
return peer;
}
/**
* @notice Sets the delegate address for the OApp.
* @param _delegate The address of the delegate to be set.
*
* @dev Only the owner/admin of the OApp can call this function.
* @dev Provides the ability for a delegate to set configs, on behalf of the OApp, directly on the Endpoint contract.
*/
function setDelegate(address _delegate) public onlyOwner {
endpoint.setDelegate(_delegate);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import { SafeERC20, IERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { MessagingParams, MessagingFee, MessagingReceipt } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol";
import { OAppCore } from "./OAppCore.sol";
/**
* @title OAppSender
* @dev Abstract contract implementing the OAppSender functionality for sending messages to a LayerZero endpoint.
*/
abstract contract OAppSender is OAppCore {
using SafeERC20 for IERC20;
// Custom error messages
error NotEnoughNative(uint256 msgValue);
error LzTokenUnavailable();
// @dev The version of the OAppSender implementation.
// @dev Version is bumped when changes are made to this contract.
uint64 internal constant SENDER_VERSION = 1;
/**
* @notice Retrieves the OApp version information.
* @return senderVersion The version of the OAppSender.sol contract.
* @return receiverVersion The version of the OAppReceiver.sol contract.
*
* @dev Providing 0 as the default for OAppReceiver version. Indicates that the OAppReceiver is not implemented.
* ie. this is a SEND only OApp.
* @dev If the OApp uses both OAppSender and OAppReceiver, then this needs to be override returning the correct versions
*/
function oAppVersion() public view virtual returns (uint64 senderVersion, uint64 receiverVersion) {
return (SENDER_VERSION, 0);
}
/**
* @dev Internal function to interact with the LayerZero EndpointV2.quote() for fee calculation.
* @param _dstEid The destination endpoint ID.
* @param _message The message payload.
* @param _options Additional options for the message.
* @param _payInLzToken Flag indicating whether to pay the fee in LZ tokens.
* @return fee The calculated MessagingFee for the message.
* - nativeFee: The native fee for the message.
* - lzTokenFee: The LZ token fee for the message.
*/
function _quote(
uint32 _dstEid,
bytes memory _message,
bytes memory _options,
bool _payInLzToken
) internal view virtual returns (MessagingFee memory fee) {
return
endpoint.quote(
MessagingParams(_dstEid, _getPeerOrRevert(_dstEid), _message, _options, _payInLzToken),
address(this)
);
}
/**
* @dev Internal function to interact with the LayerZero EndpointV2.send() for sending a message.
* @param _dstEid The destination endpoint ID.
* @param _message The message payload.
* @param _options Additional options for the message.
* @param _fee The calculated LayerZero fee for the message.
* - nativeFee: The native fee.
* - lzTokenFee: The lzToken fee.
* @param _refundAddress The address to receive any excess fee values sent to the endpoint.
* @return receipt The receipt for the sent message.
* - guid: The unique identifier for the sent message.
* - nonce: The nonce of the sent message.
* - fee: The LayerZero fee incurred for the message.
*/
function _lzSend(
uint32 _dstEid,
bytes memory _message,
bytes memory _options,
MessagingFee memory _fee,
address _refundAddress
) internal virtual returns (MessagingReceipt memory receipt) {
// @dev Push corresponding fees to the endpoint, any excess is sent back to the _refundAddress from the endpoint.
uint256 messageValue = _payNative(_fee.nativeFee);
if (_fee.lzTokenFee > 0) _payLzToken(_fee.lzTokenFee);
return
// solhint-disable-next-line check-send-result
endpoint.send{ value: messageValue }(
MessagingParams(_dstEid, _getPeerOrRevert(_dstEid), _message, _options, _fee.lzTokenFee > 0),
_refundAddress
);
}
/**
* @dev Internal function to pay the native fee associated with the message.
* @param _nativeFee The native fee to be paid.
* @return nativeFee The amount of native currency paid.
*
* @dev If the OApp needs to initiate MULTIPLE LayerZero messages in a single transaction,
* this will need to be overridden because msg.value would contain multiple lzFees.
* @dev Should be overridden in the event the LayerZero endpoint requires a different native currency.
* @dev Some EVMs use an ERC20 as a method for paying transactions/gasFees.
* @dev The endpoint is EITHER/OR, ie. it will NOT support both types of native payment at a time.
*/
function _payNative(uint256 _nativeFee) internal virtual returns (uint256 nativeFee) {
if (msg.value != _nativeFee) revert NotEnoughNative(msg.value);
return _nativeFee;
}
/**
* @dev Internal function to pay the LZ token fee associated with the message.
* @param _lzTokenFee The LZ token fee to be paid.
*
* @dev If the caller is trying to pay in the specified lzToken, then the lzTokenFee is passed to the endpoint.
* @dev Any excess sent, is passed back to the specified _refundAddress in the _lzSend().
*/
function _payLzToken(uint256 _lzTokenFee) internal virtual {
// @dev Cannot cache the token because it is not immutable in the endpoint.
address lzToken = endpoint.lzToken();
if (lzToken == address(0)) revert LzTokenUnavailable();
// Pay LZ token fee by sending tokens to the endpoint.
IERC20(lzToken).safeTransferFrom(msg.sender, address(endpoint), _lzTokenFee);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import { MessagingReceipt, MessagingFee } from "@layerzerolabs/oapp-evm/contracts/oapp/OAppSender.sol";
/**
* @dev Struct representing token parameters for the OFT send() operation.
*/
struct SendParam {
uint32 dstEid; // Destination endpoint ID.
bytes32 to; // Recipient address.
uint256 amountLD; // Amount to send in local decimals.
uint256 minAmountLD; // Minimum amount to send in local decimals.
bytes extraOptions; // Additional options supplied by the caller to be used in the LayerZero message.
bytes composeMsg; // The composed message for the send() operation.
bytes oftCmd; // The OFT command to be executed, unused in default OFT implementations.
}
/**
* @dev Struct representing OFT limit information.
* @dev These amounts can change dynamically and are up the specific oft implementation.
*/
struct OFTLimit {
uint256 minAmountLD; // Minimum amount in local decimals that can be sent to the recipient.
uint256 maxAmountLD; // Maximum amount in local decimals that can be sent to the recipient.
}
/**
* @dev Struct representing OFT receipt information.
*/
struct OFTReceipt {
uint256 amountSentLD; // Amount of tokens ACTUALLY debited from the sender in local decimals.
// @dev In non-default implementations, the amountReceivedLD COULD differ from this value.
uint256 amountReceivedLD; // Amount of tokens to be received on the remote side.
}
/**
* @dev Struct representing OFT fee details.
* @dev Future proof mechanism to provide a standardized way to communicate fees to things like a UI.
*/
struct OFTFeeDetail {
int256 feeAmountLD; // Amount of the fee in local decimals.
string description; // Description of the fee.
}
/**
* @title IOFT
* @dev Interface for the OftChain (OFT) token.
* @dev Does not inherit ERC20 to accommodate usage by OFTAdapter as well.
* @dev This specific interface ID is '0x02e49c2c'.
*/
interface IOFT {
// Custom error messages
error InvalidLocalDecimals();
error SlippageExceeded(uint256 amountLD, uint256 minAmountLD);
// Events
event OFTSent(
bytes32 indexed guid, // GUID of the OFT message.
uint32 dstEid, // Destination Endpoint ID.
address indexed fromAddress, // Address of the sender on the src chain.
uint256 amountSentLD, // Amount of tokens sent in local decimals.
uint256 amountReceivedLD // Amount of tokens received in local decimals.
);
event OFTReceived(
bytes32 indexed guid, // GUID of the OFT message.
uint32 srcEid, // Source Endpoint ID.
address indexed toAddress, // Address of the recipient on the dst chain.
uint256 amountReceivedLD // Amount of tokens received in local decimals.
);
/**
* @notice Retrieves interfaceID and the version of the OFT.
* @return interfaceId The interface ID.
* @return version The version.
*
* @dev interfaceId: This specific interface ID is '0x02e49c2c'.
* @dev version: Indicates a cross-chain compatible msg encoding with other OFTs.
* @dev If a new feature is added to the OFT cross-chain msg encoding, the version will be incremented.
* ie. localOFT version(x,1) CAN send messages to remoteOFT version(x,1)
*/
function oftVersion() external view returns (bytes4 interfaceId, uint64 version);
/**
* @notice Retrieves the address of the token associated with the OFT.
* @return token The address of the ERC20 token implementation.
*/
function token() external view returns (address);
/**
* @notice Indicates whether the OFT contract requires approval of the 'token()' to send.
* @return requiresApproval Needs approval of the underlying token implementation.
*
* @dev Allows things like wallet implementers to determine integration requirements,
* without understanding the underlying token implementation.
*/
function approvalRequired() external view returns (bool);
/**
* @notice Retrieves the shared decimals of the OFT.
* @return sharedDecimals The shared decimals of the OFT.
*/
function sharedDecimals() external view returns (uint8);
/**
* @notice Provides a quote for OFT-related operations.
* @param _sendParam The parameters for the send operation.
* @return limit The OFT limit information.
* @return oftFeeDetails The details of OFT fees.
* @return receipt The OFT receipt information.
*/
function quoteOFT(
SendParam calldata _sendParam
) external view returns (OFTLimit memory, OFTFeeDetail[] memory oftFeeDetails, OFTReceipt memory);
/**
* @notice Provides a quote for the send() operation.
* @param _sendParam The parameters for the send() operation.
* @param _payInLzToken Flag indicating whether the caller is paying in the LZ token.
* @return fee The calculated LayerZero messaging fee from the send() operation.
*
* @dev MessagingFee: LayerZero msg fee
* - nativeFee: The native fee.
* - lzTokenFee: The lzToken fee.
*/
function quoteSend(SendParam calldata _sendParam, bool _payInLzToken) external view returns (MessagingFee memory);
/**
* @notice Executes the send() operation.
* @param _sendParam The parameters for the send operation.
* @param _fee The fee information supplied by the caller.
* - nativeFee: The native fee.
* - lzTokenFee: The lzToken fee.
* @param _refundAddress The address to receive any excess funds from fees etc. on the src.
* @return receipt The LayerZero messaging receipt from the send() operation.
* @return oftReceipt The OFT receipt information.
*
* @dev MessagingReceipt: LayerZero msg receipt
* - guid: The unique identifier for the sent message.
* - nonce: The nonce of the sent message.
* - fee: The LayerZero fee incurred for the message.
*/
function send(
SendParam calldata _sendParam,
MessagingFee calldata _fee,
address _refundAddress
) external payable returns (MessagingReceipt memory, OFTReceipt memory);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.0;
/**
* @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*
* Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
* all math on `uint256` and `int256` and then downcasting.
*/
library SafeCast {
/**
* @dev Returns the downcasted uint248 from uint256, reverting on
* overflow (when the input is greater than largest uint248).
*
* Counterpart to Solidity's `uint248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*
* _Available since v4.7._
*/
function toUint248(uint256 value) internal pure returns (uint248) {
require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits");
return uint248(value);
}
/**
* @dev Returns the downcasted uint240 from uint256, reverting on
* overflow (when the input is greater than largest uint240).
*
* Counterpart to Solidity's `uint240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*
* _Available since v4.7._
*/
function toUint240(uint256 value) internal pure returns (uint240) {
require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits");
return uint240(value);
}
/**
* @dev Returns the downcasted uint232 from uint256, reverting on
* overflow (when the input is greater than largest uint232).
*
* Counterpart to Solidity's `uint232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*
* _Available since v4.7._
*/
function toUint232(uint256 value) internal pure returns (uint232) {
require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits");
return uint232(value);
}
/**
* @dev Returns the downcasted uint224 from uint256, reverting on
* overflow (when the input is greater than largest uint224).
*
* Counterpart to Solidity's `uint224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*
* _Available since v4.2._
*/
function toUint224(uint256 value) internal pure returns (uint224) {
require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
return uint224(value);
}
/**
* @dev Returns the downcasted uint216 from uint256, reverting on
* overflow (when the input is greater than largest uint216).
*
* Counterpart to Solidity's `uint216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*
* _Available since v4.7._
*/
function toUint216(uint256 value) internal pure returns (uint216) {
require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits");
return uint216(value);
}
/**
* @dev Returns the downcasted uint208 from uint256, reverting on
* overflow (when the input is greater than largest uint208).
*
* Counterpart to Solidity's `uint208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*
* _Available since v4.7._
*/
function toUint208(uint256 value) internal pure returns (uint208) {
require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits");
return uint208(value);
}
/**
* @dev Returns the downcasted uint200 from uint256, reverting on
* overflow (when the input is greater than largest uint200).
*
* Counterpart to Solidity's `uint200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*
* _Available since v4.7._
*/
function toUint200(uint256 value) internal pure returns (uint200) {
require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits");
return uint200(value);
}
/**
* @dev Returns the downcasted uint192 from uint256, reverting on
* overflow (when the input is greater than largest uint192).
*
* Counterpart to Solidity's `uint192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*
* _Available since v4.7._
*/
function toUint192(uint256 value) internal pure returns (uint192) {
require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits");
return uint192(value);
}
/**
* @dev Returns the downcasted uint184 from uint256, reverting on
* overflow (when the input is greater than largest uint184).
*
* Counterpart to Solidity's `uint184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*
* _Available since v4.7._
*/
function toUint184(uint256 value) internal pure returns (uint184) {
require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits");
return uint184(value);
}
/**
* @dev Returns the downcasted uint176 from uint256, reverting on
* overflow (when the input is greater than largest uint176).
*
* Counterpart to Solidity's `uint176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*
* _Available since v4.7._
*/
function toUint176(uint256 value) internal pure returns (uint176) {
require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits");
return uint176(value);
}
/**
* @dev Returns the downcasted uint168 from uint256, reverting on
* overflow (when the input is greater than largest uint168).
*
* Counterpart to Solidity's `uint168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*
* _Available since v4.7._
*/
function toUint168(uint256 value) internal pure returns (uint168) {
require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits");
return uint168(value);
}
/**
* @dev Returns the downcasted uint160 from uint256, reverting on
* overflow (when the input is greater than largest uint160).
*
* Counterpart to Solidity's `uint160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*
* _Available since v4.7._
*/
function toUint160(uint256 value) internal pure returns (uint160) {
require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits");
return uint160(value);
}
/**
* @dev Returns the downcasted uint152 from uint256, reverting on
* overflow (when the input is greater than largest uint152).
*
* Counterpart to Solidity's `uint152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*
* _Available since v4.7._
*/
function toUint152(uint256 value) internal pure returns (uint152) {
require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits");
return uint152(value);
}
/**
* @dev Returns the downcasted uint144 from uint256, reverting on
* overflow (when the input is greater than largest uint144).
*
* Counterpart to Solidity's `uint144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*
* _Available since v4.7._
*/
function toUint144(uint256 value) internal pure returns (uint144) {
require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits");
return uint144(value);
}
/**
* @dev Returns the downcasted uint136 from uint256, reverting on
* overflow (when the input is greater than largest uint136).
*
* Counterpart to Solidity's `uint136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*
* _Available since v4.7._
*/
function toUint136(uint256 value) internal pure returns (uint136) {
require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits");
return uint136(value);
}
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*
* _Available since v2.5._
*/
function toUint128(uint256 value) internal pure returns (uint128) {
require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits");
return uint128(value);
}
/**
* @dev Returns the downcasted uint120 from uint256, reverting on
* overflow (when the input is greater than largest uint120).
*
* Counterpart to Solidity's `uint120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*
* _Available since v4.7._
*/
function toUint120(uint256 value) internal pure returns (uint120) {
require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits");
return uint120(value);
}
/**
* @dev Returns the downcasted uint112 from uint256, reverting on
* overflow (when the input is greater than largest uint112).
*
* Counterpart to Solidity's `uint112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*
* _Available since v4.7._
*/
function toUint112(uint256 value) internal pure returns (uint112) {
require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits");
return uint112(value);
}
/**
* @dev Returns the downcasted uint104 from uint256, reverting on
* overflow (when the input is greater than largest uint104).
*
* Counterpart to Solidity's `uint104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*
* _Available since v4.7._
*/
function toUint104(uint256 value) internal pure returns (uint104) {
require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits");
return uint104(value);
}
/**
* @dev Returns the downcasted uint96 from uint256, reverting on
* overflow (when the input is greater than largest uint96).
*
* Counterpart to Solidity's `uint96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*
* _Available since v4.2._
*/
function toUint96(uint256 value) internal pure returns (uint96) {
require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits");
return uint96(value);
}
/**
* @dev Returns the downcasted uint88 from uint256, reverting on
* overflow (when the input is greater than largest uint88).
*
* Counterpart to Solidity's `uint88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*
* _Available since v4.7._
*/
function toUint88(uint256 value) internal pure returns (uint88) {
require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits");
return uint88(value);
}
/**
* @dev Returns the downcasted uint80 from uint256, reverting on
* overflow (when the input is greater than largest uint80).
*
* Counterpart to Solidity's `uint80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*
* _Available since v4.7._
*/
function toUint80(uint256 value) internal pure returns (uint80) {
require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits");
return uint80(value);
}
/**
* @dev Returns the downcasted uint72 from uint256, reverting on
* overflow (when the input is greater than largest uint72).
*
* Counterpart to Solidity's `uint72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*
* _Available since v4.7._
*/
function toUint72(uint256 value) internal pure returns (uint72) {
require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits");
return uint72(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*
* _Available since v2.5._
*/
function toUint64(uint256 value) internal pure returns (uint64) {
require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits");
return uint64(value);
}
/**
* @dev Returns the downcasted uint56 from uint256, reverting on
* overflow (when the input is greater than largest uint56).
*
* Counterpart to Solidity's `uint56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*
* _Available since v4.7._
*/
function toUint56(uint256 value) internal pure returns (uint56) {
require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits");
return uint56(value);
}
/**
* @dev Returns the downcasted uint48 from uint256, reverting on
* overflow (when the input is greater than largest uint48).
*
* Counterpart to Solidity's `uint48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*
* _Available since v4.7._
*/
function toUint48(uint256 value) internal pure returns (uint48) {
require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits");
return uint48(value);
}
/**
* @dev Returns the downcasted uint40 from uint256, reverting on
* overflow (when the input is greater than largest uint40).
*
* Counterpart to Solidity's `uint40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*
* _Available since v4.7._
*/
function toUint40(uint256 value) internal pure returns (uint40) {
require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits");
return uint40(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*
* _Available since v2.5._
*/
function toUint32(uint256 value) internal pure returns (uint32) {
require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits");
return uint32(value);
}
/**
* @dev Returns the downcasted uint24 from uint256, reverting on
* overflow (when the input is greater than largest uint24).
*
* Counterpart to Solidity's `uint24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*
* _Available since v4.7._
*/
function toUint24(uint256 value) internal pure returns (uint24) {
require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits");
return uint24(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*
* _Available since v2.5._
*/
function toUint16(uint256 value) internal pure returns (uint16) {
require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits");
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*
* _Available since v2.5._
*/
function toUint8(uint256 value) internal pure returns (uint8) {
require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits");
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*
* _Available since v3.0._
*/
function toUint256(int256 value) internal pure returns (uint256) {
require(value >= 0, "SafeCast: value must be positive");
return uint256(value);
}
/**
* @dev Returns the downcasted int248 from int256, reverting on
* overflow (when the input is less than smallest int248 or
* greater than largest int248).
*
* Counterpart to Solidity's `int248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*
* _Available since v4.7._
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
require(downcasted == value, "SafeCast: value doesn't fit in 248 bits");
}
/**
* @dev Returns the downcasted int240 from int256, reverting on
* overflow (when the input is less than smallest int240 or
* greater than largest int240).
*
* Counterpart to Solidity's `int240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*
* _Available since v4.7._
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
require(downcasted == value, "SafeCast: value doesn't fit in 240 bits");
}
/**
* @dev Returns the downcasted int232 from int256, reverting on
* overflow (when the input is less than smallest int232 or
* greater than largest int232).
*
* Counterpart to Solidity's `int232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*
* _Available since v4.7._
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
require(downcasted == value, "SafeCast: value doesn't fit in 232 bits");
}
/**
* @dev Returns the downcasted int224 from int256, reverting on
* overflow (when the input is less than smallest int224 or
* greater than largest int224).
*
* Counterpart to Solidity's `int224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*
* _Available since v4.7._
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
require(downcasted == value, "SafeCast: value doesn't fit in 224 bits");
}
/**
* @dev Returns the downcasted int216 from int256, reverting on
* overflow (when the input is less than smallest int216 or
* greater than largest int216).
*
* Counterpart to Solidity's `int216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*
* _Available since v4.7._
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
require(downcasted == value, "SafeCast: value doesn't fit in 216 bits");
}
/**
* @dev Returns the downcasted int208 from int256, reverting on
* overflow (when the input is less than smallest int208 or
* greater than largest int208).
*
* Counterpart to Solidity's `int208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*
* _Available since v4.7._
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
require(downcasted == value, "SafeCast: value doesn't fit in 208 bits");
}
/**
* @dev Returns the downcasted int200 from int256, reverting on
* overflow (when the input is less than smallest int200 or
* greater than largest int200).
*
* Counterpart to Solidity's `int200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*
* _Available since v4.7._
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
require(downcasted == value, "SafeCast: value doesn't fit in 200 bits");
}
/**
* @dev Returns the downcasted int192 from int256, reverting on
* overflow (when the input is less than smallest int192 or
* greater than largest int192).
*
* Counterpart to Solidity's `int192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*
* _Available since v4.7._
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
require(downcasted == value, "SafeCast: value doesn't fit in 192 bits");
}
/**
* @dev Returns the downcasted int184 from int256, reverting on
* overflow (when the input is less than smallest int184 or
* greater than largest int184).
*
* Counterpart to Solidity's `int184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*
* _Available since v4.7._
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
require(downcasted == value, "SafeCast: value doesn't fit in 184 bits");
}
/**
* @dev Returns the downcasted int176 from int256, reverting on
* overflow (when the input is less than smallest int176 or
* greater than largest int176).
*
* Counterpart to Solidity's `int176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*
* _Available since v4.7._
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
require(downcasted == value, "SafeCast: value doesn't fit in 176 bits");
}
/**
* @dev Returns the downcasted int168 from int256, reverting on
* overflow (when the input is less than smallest int168 or
* greater than largest int168).
*
* Counterpart to Solidity's `int168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*
* _Available since v4.7._
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
require(downcasted == value, "SafeCast: value doesn't fit in 168 bits");
}
/**
* @dev Returns the downcasted int160 from int256, reverting on
* overflow (when the input is less than smallest int160 or
* greater than largest int160).
*
* Counterpart to Solidity's `int160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*
* _Available since v4.7._
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
require(downcasted == value, "SafeCast: value doesn't fit in 160 bits");
}
/**
* @dev Returns the downcasted int152 from int256, reverting on
* overflow (when the input is less than smallest int152 or
* greater than largest int152).
*
* Counterpart to Solidity's `int152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*
* _Available since v4.7._
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
require(downcasted == value, "SafeCast: value doesn't fit in 152 bits");
}
/**
* @dev Returns the downcasted int144 from int256, reverting on
* overflow (when the input is less than smallest int144 or
* greater than largest int144).
*
* Counterpart to Solidity's `int144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*
* _Available since v4.7._
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
require(downcasted == value, "SafeCast: value doesn't fit in 144 bits");
}
/**
* @dev Returns the downcasted int136 from int256, reverting on
* overflow (when the input is less than smallest int136 or
* greater than largest int136).
*
* Counterpart to Solidity's `int136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*
* _Available since v4.7._
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
require(downcasted == value, "SafeCast: value doesn't fit in 136 bits");
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*
* _Available since v3.1._
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
require(downcasted == value, "SafeCast: value doesn't fit in 128 bits");
}
/**
* @dev Returns the downcasted int120 from int256, reverting on
* overflow (when the input is less than smallest int120 or
* greater than largest int120).
*
* Counterpart to Solidity's `int120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*
* _Available since v4.7._
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
require(downcasted == value, "SafeCast: value doesn't fit in 120 bits");
}
/**
* @dev Returns the downcasted int112 from int256, reverting on
* overflow (when the input is less than smallest int112 or
* greater than largest int112).
*
* Counterpart to Solidity's `int112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*
* _Available since v4.7._
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
require(downcasted == value, "SafeCast: value doesn't fit in 112 bits");
}
/**
* @dev Returns the downcasted int104 from int256, reverting on
* overflow (when the input is less than smallest int104 or
* greater than largest int104).
*
* Counterpart to Solidity's `int104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*
* _Available since v4.7._
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
require(downcasted == value, "SafeCast: value doesn't fit in 104 bits");
}
/**
* @dev Returns the downcasted int96 from int256, reverting on
* overflow (when the input is less than smallest int96 or
* greater than largest int96).
*
* Counterpart to Solidity's `int96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*
* _Available since v4.7._
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
require(downcasted == value, "SafeCast: value doesn't fit in 96 bits");
}
/**
* @dev Returns the downcasted int88 from int256, reverting on
* overflow (when the input is less than smallest int88 or
* greater than largest int88).
*
* Counterpart to Solidity's `int88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*
* _Available since v4.7._
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
require(downcasted == value, "SafeCast: value doesn't fit in 88 bits");
}
/**
* @dev Returns the downcasted int80 from int256, reverting on
* overflow (when the input is less than smallest int80 or
* greater than largest int80).
*
* Counterpart to Solidity's `int80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*
* _Available since v4.7._
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
require(downcasted == value, "SafeCast: value doesn't fit in 80 bits");
}
/**
* @dev Returns the downcasted int72 from int256, reverting on
* overflow (when the input is less than smallest int72 or
* greater than largest int72).
*
* Counterpart to Solidity's `int72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*
* _Available since v4.7._
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
require(downcasted == value, "SafeCast: value doesn't fit in 72 bits");
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*
* _Available since v3.1._
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
require(downcasted == value, "SafeCast: value doesn't fit in 64 bits");
}
/**
* @dev Returns the downcasted int56 from int256, reverting on
* overflow (when the input is less than smallest int56 or
* greater than largest int56).
*
* Counterpart to Solidity's `int56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*
* _Available since v4.7._
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
require(downcasted == value, "SafeCast: value doesn't fit in 56 bits");
}
/**
* @dev Returns the downcasted int48 from int256, reverting on
* overflow (when the input is less than smallest int48 or
* greater than largest int48).
*
* Counterpart to Solidity's `int48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*
* _Available since v4.7._
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
require(downcasted == value, "SafeCast: value doesn't fit in 48 bits");
}
/**
* @dev Returns the downcasted int40 from int256, reverting on
* overflow (when the input is less than smallest int40 or
* greater than largest int40).
*
* Counterpart to Solidity's `int40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*
* _Available since v4.7._
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
require(downcasted == value, "SafeCast: value doesn't fit in 40 bits");
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*
* _Available since v3.1._
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
require(downcasted == value, "SafeCast: value doesn't fit in 32 bits");
}
/**
* @dev Returns the downcasted int24 from int256, reverting on
* overflow (when the input is less than smallest int24 or
* greater than largest int24).
*
* Counterpart to Solidity's `int24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*
* _Available since v4.7._
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
require(downcasted == value, "SafeCast: value doesn't fit in 24 bits");
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*
* _Available since v3.1._
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
require(downcasted == value, "SafeCast: value doesn't fit in 16 bits");
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*
* _Available since v3.1._
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
require(downcasted == value, "SafeCast: value doesn't fit in 8 bits");
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*
* _Available since v3.0._
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256");
return int256(value);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;
import {Errors} from 'lens/libraries/constants/Errors.sol';
/**
* @title HubRestricted
* @author Lens Protocol
*
* @notice This abstract contract adds a public `HUB` immutable field, as well as an `onlyHub` modifier,
* to inherit from contracts that have functions restricted to be only called by the Lens hub.
*/
abstract contract HubRestricted {
address public immutable HUB;
modifier onlyHub() {
if (msg.sender != HUB) {
revert Errors.NotHub();
}
_;
}
constructor(address hub) {
HUB = hub;
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
/**
* @title IERC721Burnable
* @author Lens Protocol
*
* @notice Extension of ERC-721 including a function that allows the token to be burned.
*/
interface IERC721Burnable {
/**
* @notice Burns an NFT, removing it from circulation and essentially destroying it.
* @custom:permission Owner of the NFT.
*
* @param tokenId The token ID of the token to burn.
*/
function burn(uint256 tokenId) external;
}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
/**
* @title IERC721MetaTx
* @author Lens Protocol
*
* @notice Extension of ERC-721 including meta-tx signatures related functions.
*/
interface IERC721MetaTx {
/**
* @notice Returns the current signature nonce of the given signer.
*
* @param signer The address for which to query the nonce.
*
* @return uint256 The current nonce of the given signer.
*/
function nonces(address signer) external view returns (uint256);
/**
* @notice Returns the EIP-712 domain separator for this contract.
*
* @return bytes32 The domain separator.
*/
function getDomainSeparator() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
import {Types} from 'lens/libraries/constants/Types.sol';
/**
* @title IERC721Timestamped
* @author Lens Protocol
*
* @notice Extension of ERC-721 including a struct for token data, which contains the owner and the mint timestamp, as
* well as their associated getters.
*/
interface IERC721Timestamped {
/**
* @notice Returns the mint timestamp associated with a given NFT.
*
* @param tokenId The token ID of the NFT to query the mint timestamp for.
*
* @return uint256 Mint timestamp, this is stored as a uint96 but returned as a uint256 to reduce unnecessary
* padding.
*/
function mintTimestampOf(uint256 tokenId) external view returns (uint256);
/**
* @notice Returns the token data associated with a given NFT. This allows fetching the token owner and
* mint timestamp in a single call.
*
* @param tokenId The token ID of the NFT to query the token data for.
*
* @return TokenData A struct containing both the owner address and the mint timestamp.
*/
function tokenDataOf(uint256 tokenId) external view returns (Types.TokenData memory);
/**
* @notice Returns whether a token with the given token ID exists.
*
* @param tokenId The token ID of the NFT to check existence for.
*
* @return bool True if the token exists.
*/
function exists(uint256 tokenId) external view returns (bool);
/**
* @notice Returns the amount of tokens in circulation.
*
* @return uint256 The current total supply of tokens.
*/
function totalSupply() external view returns (uint256);
}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
import {IERC721} from '@openzeppelin/contracts/token/ERC721/IERC721.sol';
import {IERC721Timestamped} from 'lens/interfaces/IERC721Timestamped.sol';
import {IERC721Burnable} from 'lens/interfaces/IERC721Burnable.sol';
import {IERC721MetaTx} from 'lens/interfaces/IERC721MetaTx.sol';
import {IERC721Metadata} from '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol';
interface ILensERC721 is IERC721, IERC721Timestamped, IERC721Burnable, IERC721MetaTx, IERC721Metadata {}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
import {Types} from 'lens/libraries/constants/Types.sol';
/**
* @title ILensGovernable
* @author Lens Protocol
*
* @notice This is the interface for the Lens Protocol main governance functions.
*/
interface ILensGovernable {
/**
* @notice Sets the privileged governance role.
* @custom:permissions Governance.
*
* @param newGovernance The new governance address to set.
*/
function setGovernance(address newGovernance) external;
/**
* @notice Sets the emergency admin, which is a permissioned role able to set the protocol state.
* @custom:permissions Governance.
*
* @param newEmergencyAdmin The new emergency admin address to set.
*/
function setEmergencyAdmin(address newEmergencyAdmin) external;
/**
* @notice Sets the protocol state to either a global pause, a publishing pause or an unpaused state.
* @custom:permissions Governance or Emergency Admin. Emergency Admin can only restrict more.
*
* @param newState The state to set. It can be one of the following:
* - Unpaused: The protocol is fully operational.
* - PublishingPaused: The protocol is paused for publishing, but it is still operational for others operations.
* - Paused: The protocol is paused for all operations.
*/
function setState(Types.ProtocolState newState) external;
/**
* @notice Adds or removes a profile creator from the whitelist.
* @custom:permissions Governance.
*
* @param profileCreator The profile creator address to add or remove from the whitelist.
* @param whitelist Whether or not the profile creator should be whitelisted.
*/
function whitelistProfileCreator(address profileCreator, bool whitelist) external;
/**
* @notice Sets the profile token URI contract.
* @custom:permissions Governance.
*
* @param profileTokenURIContract The profile token URI contract to set.
*/
function setProfileTokenURIContract(address profileTokenURIContract) external;
/**
* @notice Sets the follow token URI contract.
* @custom:permissions Governance.
*
* @param followTokenURIContract The follow token URI contract to set.
*/
function setFollowTokenURIContract(address followTokenURIContract) external;
/**
* @notice Sets the treasury address.
* @custom:permissions Governance
*
* @param newTreasury The new treasury address to set.
*/
function setTreasury(address newTreasury) external;
/**
* @notice Sets the treasury fee.
* @custom:permissions Governance
*
* @param newTreasuryFee The new treasury fee to set.
*/
function setTreasuryFee(uint16 newTreasuryFee) external;
/**
* @notice Returns the currently configured governance address.
*
* @return address The address of the currently configured governance.
*/
function getGovernance() external view returns (address);
/**
* @notice Gets the state currently set in the protocol. It could be a global pause, a publishing pause or an
* unpaused state.
* @custom:permissions Anyone.
*
* @return Types.ProtocolState The state currently set in the protocol.
*/
function getState() external view returns (Types.ProtocolState);
/**
* @notice Returns whether or not a profile creator is whitelisted.
*
* @param profileCreator The address of the profile creator to check.
*
* @return bool True if the profile creator is whitelisted, false otherwise.
*/
function isProfileCreatorWhitelisted(address profileCreator) external view returns (bool);
/**
* @notice Returns the treasury address.
*
* @return address The treasury address.
*/
function getTreasury() external view returns (address);
/**
* @notice Returns the treasury fee.
*
* @return uint16 The treasury fee.
*/
function getTreasuryFee() external view returns (uint16);
/**
* @notice Returns the treasury address and treasury fee in a single call.
*
* @return tuple First, the treasury address, second, the treasury fee.
*/
function getTreasuryData() external view returns (address, uint16);
/**
* @notice Gets the profile token URI contract.
*
* @return address The profile token URI contract.
*/
function getProfileTokenURIContract() external view returns (address);
/**
* @notice Gets the follow token URI contract.
*
* @return address The follow token URI contract.
*/
function getFollowTokenURIContract() external view returns (address);
}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
import {ILensProtocol} from 'lens/interfaces/ILensProtocol.sol';
import {ILensGovernable} from 'lens/interfaces/ILensGovernable.sol';
import {ILensHubEventHooks} from 'lens/interfaces/ILensHubEventHooks.sol';
import {ILensImplGetters} from 'lens/interfaces/ILensImplGetters.sol';
import {ILensProfiles} from 'lens/interfaces/ILensProfiles.sol';
import {ILensVersion} from 'lens/interfaces/ILensVersion.sol';
interface ILensHub is
ILensProfiles,
ILensProtocol,
ILensGovernable,
ILensHubEventHooks,
ILensImplGetters,
ILensVersion
{}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
/**
* @title ILensHubEventHooks
* @author Lens Protocol
*
* @notice This is the interface for the LensHub contract's event hooks. As we want most of the core events to be
* emitted by the LensHub contract, event hooks are needed for core events generated by pheripheral contracts.
*/
interface ILensHubEventHooks {
/**
* @dev Helper function to emit an `Unfollowed` event from the hub, to be consumed by indexers to track unfollows.
* @custom:permissions FollowNFT of the Profile unfollowed.
*
* @param unfollowerProfileId The ID of the profile that executed the unfollow.
* @param idOfProfileUnfollowed The ID of the profile that was unfollowed.
* @param transactionExecutor The address of the account executing the unfollow operation.
*/
function emitUnfollowedEvent(
uint256 unfollowerProfileId,
uint256 idOfProfileUnfollowed,
address transactionExecutor
) external;
}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
/**
* @title ILensImplGetters
* @author Lens Protocol
*
* @notice This is the interface for the LensHub contract's implementation getters. These implementations will be used
* for deploying each respective contract for each profile.
*/
interface ILensImplGetters {
/**
* @notice Returns the Follow NFT implementation address that is used for all deployed Follow NFTs.
*
* @return address The Follow NFT implementation address.
*/
function getFollowNFTImpl() external view returns (address);
/**
* @notice Returns the Collect NFT implementation address that is used for each new deployed Collect NFT.
* @custom:pending-deprecation
*
* @return address The Collect NFT implementation address.
*/
function getLegacyCollectNFTImpl() external view returns (address);
/**
* @notice Returns the address of the registry that stores all modules that are used by the Lens Protocol.
*
* @return address The address of the Module Registry contract.
*/
function getModuleRegistry() external view returns (address);
}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
import {ILensERC721} from 'lens/interfaces/ILensERC721.sol';
interface ILensProfiles is ILensERC721 {
/**
* @notice DANGER: Triggers disabling the profile protection mechanism for the msg.sender, which will allow
* transfers or approvals over profiles held by it.
* Disabling the mechanism will have a timelock before it becomes effective, allowing the owner to re-enable
* the protection back in case of being under attack.
* The protection layer only applies to EOA wallets.
*/
function DANGER__disableTokenGuardian() external;
/**
* @notice Enables back the profile protection mechanism for the msg.sender, preventing profile transfers or
* approvals (except when revoking them).
* The protection layer only applies to EOA wallets.
*/
function enableTokenGuardian() external;
/**
* @notice Returns the timestamp at which the Token Guardian will become effectively disabled.
*
* @param wallet The address to check the timestamp for.
*
* @return uint256 The timestamp at which the Token Guardian will become effectively disabled. Zero if enabled.
*/
function getTokenGuardianDisablingTimestamp(address wallet) external view returns (uint256);
}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
import {Types} from 'lens/libraries/constants/Types.sol';
/**
* @title ILensProtocol
* @author Lens Protocol
*
* @notice This is the interface for Lens Protocol's core functions. It contains all the entry points for performing
* social operations.
*/
interface ILensProtocol {
/**
* @notice Creates a profile with the specified parameters, minting a Profile NFT to the given recipient.
* @custom:permissions Any whitelisted profile creator.
*
* @param createProfileParams A CreateProfileParams struct containing the needed params.
*/
function createProfile(Types.CreateProfileParams calldata createProfileParams) external returns (uint256);
/**
* @notice Sets the metadata URI for the given profile.
* @custom:permissions Profile Owner or Delegated Executor.
*
* @param profileId The token ID of the profile to set the metadata URI for.
* @param metadataURI The metadata URI to set for the given profile.
*/
function setProfileMetadataURI(uint256 profileId, string calldata metadataURI) external;
/**
* @custom:meta-tx setProfileMetadataURI.
*/
function setProfileMetadataURIWithSig(
uint256 profileId,
string calldata metadataURI,
Types.EIP712Signature calldata signature
) external;
/**
* @notice Sets the follow module for the given profile.
* @custom:permissions Profile Owner or Delegated Executor.
*
* @param profileId The token ID of the profile to set the follow module for.
* @param followModule The follow module to set for the given profile, must be whitelisted.
* @param followModuleInitData The data to be passed to the follow module for initialization.
*/
function setFollowModule(uint256 profileId, address followModule, bytes calldata followModuleInitData) external;
/**
* @custom:meta-tx setFollowModule.
*/
function setFollowModuleWithSig(
uint256 profileId,
address followModule,
bytes calldata followModuleInitData,
Types.EIP712Signature calldata signature
) external;
/**
* @notice Changes the delegated executors configuration for the given profile. It allows setting the approvals for
* delegated executors in the specified configuration, as well as switching to it.
* @custom:permissions Profile Owner.
*
* @param delegatorProfileId The ID of the profile to which the delegated executor is being changed for.
* @param delegatedExecutors The array of delegated executors to set the approval for.
* @param approvals The array of booleans indicating the corresponding executor's new approval status.
* @param configNumber The number of the configuration where the executor approval state is being set.
* @param switchToGivenConfig A boolean indicating if the configuration must be switched to the one with the given
* number.
*/
function changeDelegatedExecutorsConfig(
uint256 delegatorProfileId,
address[] calldata delegatedExecutors,
bool[] calldata approvals,
uint64 configNumber,
bool switchToGivenConfig
) external;
/**
* @notice Changes the delegated executors configuration for the given profile under the current configuration.
* @custom:permissions Profile Owner.
*
* @param delegatorProfileId The ID of the profile to which the delegated executor is being changed for.
* @param delegatedExecutors The array of delegated executors to set the approval for.
* @param approvals The array of booleans indicating the corresponding executor's new approval status.
*/
function changeDelegatedExecutorsConfig(
uint256 delegatorProfileId,
address[] calldata delegatedExecutors,
bool[] calldata approvals
) external;
/**
* @custom:meta-tx changeDelegatedExecutorsConfig.
*/
function changeDelegatedExecutorsConfigWithSig(
uint256 delegatorProfileId,
address[] calldata delegatedExecutors,
bool[] calldata approvals,
uint64 configNumber,
bool switchToGivenConfig,
Types.EIP712Signature calldata signature
) external;
/**
* @notice Publishes a post.
* Post is the most basic publication type, and can be used to publish any kind of content.
* Posts can have these types of modules initialized:
* - Action modules: any number of publication actions (e.g. collect, tip, etc.)
* - Reference module: a module handling the rules when referencing this post (e.g. token-gated comments)
* @custom:permissions Profile Owner or Delegated Executor.
*
* @param postParams A PostParams struct containing the needed parameters.
*
* @return uint256 An integer representing the post's publication ID.
*/
function post(Types.PostParams calldata postParams) external returns (uint256);
/**
* @custom:meta-tx post.
*/
function postWithSig(
Types.PostParams calldata postParams,
Types.EIP712Signature calldata signature
) external returns (uint256);
/**
* @notice Publishes a comment on the given publication.
* Comment is a type of reference publication that points to another publication.
* Comments can have these types of modules initialized:
* - Action modules: any number of publication actions (e.g. collect, tip, etc.)
* - Reference module: a module handling the rules when referencing this comment (e.g. token-gated mirrors)
* Comments can have referrers (e.g. publications or profiles that helped to discover the pointed publication).
* @custom:permissions Profile Owner or Delegated Executor.
*
* @param commentParams A CommentParams struct containing the needed parameters.
*
* @return uint256 An integer representing the comment's publication ID.
*/
function comment(Types.CommentParams calldata commentParams) external returns (uint256);
/**
* @custom:meta-tx comment.
*/
function commentWithSig(
Types.CommentParams calldata commentParams,
Types.EIP712Signature calldata signature
) external returns (uint256);
/**
* @notice Publishes a mirror of the given publication.
* Mirror is a type of reference publication that points to another publication but doesn't have content.
* Mirrors don't have any modules initialized.
* Mirrors can have referrers (e.g. publications or profiles that allowed to discover the pointed publication).
* You cannot mirror a mirror, comment on a mirror, or quote a mirror.
* @custom:permissions Profile Owner or Delegated Executor.
*
* @param mirrorParams A MirrorParams struct containing the necessary parameters.
*
* @return uint256 An integer representing the mirror's publication ID.
*/
function mirror(Types.MirrorParams calldata mirrorParams) external returns (uint256);
/**
* @custom:meta-tx mirror.
*/
function mirrorWithSig(
Types.MirrorParams calldata mirrorParams,
Types.EIP712Signature calldata signature
) external returns (uint256);
/**
* @notice Publishes a quote of the given publication.
* Quote is a type of reference publication similar to mirror, but it has content and modules.
* Quotes can have these types of modules initialized:
* - Action modules: any number of publication actions (e.g. collect, tip, etc.)
* - Reference module: a module handling the rules when referencing this quote (e.g. token-gated comments on quote)
* Quotes can have referrers (e.g. publications or profiles that allowed to discover the pointed publication).
* Unlike mirrors, you can mirror a quote, comment on a quote, or quote a quote.
* @custom:permissions Profile Owner or Delegated Executor.
*
* @param quoteParams A QuoteParams struct containing the needed parameters.
*
* @return uint256 An integer representing the quote's publication ID.
*/
function quote(Types.QuoteParams calldata quoteParams) external returns (uint256);
/**
* @custom:meta-tx quote.
*/
function quoteWithSig(
Types.QuoteParams calldata quoteParams,
Types.EIP712Signature calldata signature
) external returns (uint256);
/**
* @notice Follows given profiles, executing each profile's follow module logic (if any).
* @custom:permissions Profile Owner or Delegated Executor.
*
* @dev Both the `idsOfProfilesToFollow`, `followTokenIds`, and `datas` arrays must be of the same length,
* regardless if the profiles do not have a follow module set.
*
* @param followerProfileId The ID of the profile the follows are being executed for.
* @param idsOfProfilesToFollow The array of IDs of profiles to follow.
* @param followTokenIds The array of follow token IDs to use for each follow (0 if you don't own a follow token).
* @param datas The arbitrary data array to pass to the follow module for each profile if needed.
*
* @return uint256[] An array of follow token IDs representing the follow tokens created for each follow.
*/
function follow(
uint256 followerProfileId,
uint256[] calldata idsOfProfilesToFollow,
uint256[] calldata followTokenIds,
bytes[] calldata datas
) external returns (uint256[] memory);
/**
* @custom:meta-tx follow.
*/
function followWithSig(
uint256 followerProfileId,
uint256[] calldata idsOfProfilesToFollow,
uint256[] calldata followTokenIds,
bytes[] calldata datas,
Types.EIP712Signature calldata signature
) external returns (uint256[] memory);
/**
* @notice Unfollows given profiles.
* @custom:permissions Profile Owner or Delegated Executor.
*
* @param unfollowerProfileId The ID of the profile the unfollows are being executed for.
* @param idsOfProfilesToUnfollow The array of IDs of profiles to unfollow.
*/
function unfollow(uint256 unfollowerProfileId, uint256[] calldata idsOfProfilesToUnfollow) external;
/**
* @custom:meta-tx unfollow.
*/
function unfollowWithSig(
uint256 unfollowerProfileId,
uint256[] calldata idsOfProfilesToUnfollow,
Types.EIP712Signature calldata signature
) external;
/**
* @notice Sets the block status for the given profiles. Changing a profile's block status to `true` (i.e. blocked),
* when will also force them to unfollow.
* Blocked profiles cannot perform any actions with the profile that blocked them: they cannot comment or mirror
* their publications, they cannot follow them, they cannot collect, tip them, etc.
* @custom:permissions Profile Owner or Delegated Executor.
*
* @dev Both the `idsOfProfilesToSetBlockStatus` and `blockStatus` arrays must be of the same length.
*
* @param byProfileId The ID of the profile that is blocking/unblocking somebody.
* @param idsOfProfilesToSetBlockStatus The array of IDs of profiles to set block status.
* @param blockStatus The array of block statuses to use for each (true is blocked).
*/
function setBlockStatus(
uint256 byProfileId,
uint256[] calldata idsOfProfilesToSetBlockStatus,
bool[] calldata blockStatus
) external;
/**
* @custom:meta-tx setBlockStatus.
*/
function setBlockStatusWithSig(
uint256 byProfileId,
uint256[] calldata idsOfProfilesToSetBlockStatus,
bool[] calldata blockStatus,
Types.EIP712Signature calldata signature
) external;
/**
* @notice Collects a given publication via signature with the specified parameters.
* Collect can have referrers (e.g. publications or profiles that allowed to discover the pointed publication).
* @custom:permissions Collector Profile Owner or its Delegated Executor.
* @custom:pending-deprecation Collect modules were replaced by PublicationAction Collect modules in V2. This method
* is left here for backwards compatibility with posts made in V1 that had Collect modules.
*
* @param collectParams A CollectParams struct containing the parameters.
*
* @return uint256 An integer representing the minted token ID.
*/
function collectLegacy(Types.LegacyCollectParams calldata collectParams) external returns (uint256);
/**
* @custom:meta-tx collect.
* @custom:pending-deprecation
*/
function collectLegacyWithSig(
Types.LegacyCollectParams calldata collectParams,
Types.EIP712Signature calldata signature
) external returns (uint256);
/**
* @notice Acts on a given publication with the specified parameters.
* You can act on a publication except a mirror (if it has at least one action module initialized).
* Actions can have referrers (e.g. publications or profiles that allowed to discover the pointed publication).
* @custom:permissions Actor Profile Owner or its Delegated Executor.
*
* @param publicationActionParams A PublicationActionParams struct containing the parameters.
*
* @return bytes Arbitrary data the action module returns.
*/
function act(Types.PublicationActionParams calldata publicationActionParams) external returns (bytes memory);
/**
* @custom:meta-tx act.
*/
function actWithSig(
Types.PublicationActionParams calldata publicationActionParams,
Types.EIP712Signature calldata signature
) external returns (bytes memory);
/**
* @dev This function is used to invalidate signatures by incrementing the nonce of the signer.
* @param increment The amount to increment the nonce by (max 255).
*/
function incrementNonce(uint8 increment) external;
/////////////////////////////////
/// VIEW FUNCTIONS ///
/////////////////////////////////
/**
* @notice Returns whether or not `followerProfileId` is following `followedProfileId`.
*
* @param followerProfileId The ID of the profile whose following state should be queried.
* @param followedProfileId The ID of the profile whose followed state should be queried.
*
* @return bool True if `followerProfileId` is following `followedProfileId`, false otherwise.
*/
function isFollowing(uint256 followerProfileId, uint256 followedProfileId) external view returns (bool);
/**
* @notice Returns whether the given address is approved as delegated executor, in the configuration with the given
* number, to act on behalf of the given profile.
*
* @param delegatorProfileId The ID of the profile to check the delegated executor approval for.
* @param delegatedExecutor The address to query the delegated executor approval for.
* @param configNumber The number of the configuration where the executor approval state is being queried.
*
* @return bool True if the address is approved as a delegated executor to act on behalf of the profile in the
* given configuration, false otherwise.
*/
function isDelegatedExecutorApproved(
uint256 delegatorProfileId,
address delegatedExecutor,
uint64 configNumber
) external view returns (bool);
/**
* @notice Returns whether the given address is approved as delegated executor, in the current configuration, to act
* on behalf of the given profile.
*
* @param delegatorProfileId The ID of the profile to check the delegated executor approval for.
* @param delegatedExecutor The address to query the delegated executor approval for.
*
* @return bool True if the address is approved as a delegated executor to act on behalf of the profile in the
* current configuration, false otherwise.
*/
function isDelegatedExecutorApproved(
uint256 delegatorProfileId,
address delegatedExecutor
) external view returns (bool);
/**
* @notice Returns the current delegated executor config number for the given profile.
*
* @param delegatorProfileId The ID of the profile from which the delegated executors config number is being queried
*
* @return uint256 The current delegated executor configuration number.
*/
function getDelegatedExecutorsConfigNumber(uint256 delegatorProfileId) external view returns (uint64);
/**
* @notice Returns the previous used delegated executor config number for the given profile.
*
* @param delegatorProfileId The ID of the profile from which the delegated executors' previous configuration number
* set is being queried.
*
* @return uint256 The delegated executor configuration number previously set. It will coincide with the current
* configuration set if it was never switched from the default one.
*/
function getDelegatedExecutorsPrevConfigNumber(uint256 delegatorProfileId) external view returns (uint64);
/**
* @notice Returns the maximum delegated executor config number for the given profile.
* This is the maximum config number that was ever used by this profile.
* When creating a new clean configuration, you can only use a number that is maxConfigNumber + 1.
*
* @param delegatorProfileId The ID of the profile from which the delegated executors' maximum configuration number
* set is being queried.
*
* @return uint256 The delegated executor maximum configuration number set.
*/
function getDelegatedExecutorsMaxConfigNumberSet(uint256 delegatorProfileId) external view returns (uint64);
/**
* @notice Returns whether `profileId` is blocked by `byProfileId`.
* See setBlockStatus() for more information on how blocking works on the platform.
*
* @param profileId The ID of the profile whose blocked status should be queried.
* @param byProfileId The ID of the profile whose blocker status should be queried.
*
* @return bool True if `profileId` is blocked by `byProfileId`, false otherwise.
*/
function isBlocked(uint256 profileId, uint256 byProfileId) external view returns (bool);
/**
* @notice Returns the URI associated with a given publication.
* This is used to store the publication's metadata, e.g.: content, images, etc.
*
* @param profileId The token ID of the profile that published the publication to query.
* @param pubId The publication ID of the publication to query.
*
* @return string The URI associated with a given publication.
*/
function getContentURI(uint256 profileId, uint256 pubId) external view returns (string memory);
/**
* @notice Returns the full profile struct associated with a given profile token ID.
*
* @param profileId The token ID of the profile to query.
*
* @return Profile The profile struct of the given profile.
*/
function getProfile(uint256 profileId) external view returns (Types.Profile memory);
/**
* @notice Returns the full publication struct for a given publication.
*
* @param profileId The token ID of the profile that published the publication to query.
* @param pubId The publication ID of the publication to query.
*
* @return Publication The publication struct associated with the queried publication.
*/
function getPublication(uint256 profileId, uint256 pubId) external view returns (Types.PublicationMemory memory);
/**
* @notice Returns the type of a given publication.
* The type can be one of the following (see PublicationType enum):
* - Nonexistent
* - Post
* - Comment
* - Mirror
* - Quote
*
* @param profileId The token ID of the profile that published the publication to query.
* @param pubId The publication ID of the publication to query.
*
* @return PublicationType The publication type of the queried publication.
*/
function getPublicationType(uint256 profileId, uint256 pubId) external view returns (Types.PublicationType);
/**
* @notice Returns wether a given Action Module is enabled for a given publication.
*
* @param profileId The token ID of the profile that published the publication to query.
* @param pubId The publication ID of the publication to query.
* @param module The address of the Action Module to query.
*
* @return bool True if the Action Module is enabled for the queried publication, false if not.
*/
function isActionModuleEnabledInPublication(
uint256 profileId,
uint256 pubId,
address module
) external view returns (bool);
}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
/**
* @title ILensVersion
* @author Lens Protocol
*
* @notice This is the interface for the LensHub Version getters and emitter.
* It allows to emit a LensHub version during an upgrade, and also to get the current version.
*/
interface ILensVersion {
/**
* @notice Returns the LensHub current Version.
*
* @return version The LensHub current Version.
*/
function getVersion() external view returns (string memory);
/**
* @notice Returns the LensHub current Git Commit.
*
* @return gitCommit The LensHub current Git Commit.
*/
function getGitCommit() external view returns (bytes20);
/**
* @notice Emits the LensHub current Version. Used in upgradeAndCall().
*/
function emitVersion() external;
}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
import {Types} from 'lens/libraries/constants/Types.sol';
/**
* @title IPublicationAction
* @author Lens Protocol
*
* @notice This is the standard interface for all Lens-compatible Publication Actions.
* Publication action modules allow users to execute actions directly from a publication, like:
* - Minting NFTs.
* - Collecting a publication.
* - Sending funds to the publication author (e.g. tipping).
* - Etc.
* Referrers are supported, so any publication or profile that references the publication can receive a share from the
* publication's action if the action module supports it.
*/
interface IPublicationActionModule {
/**
* @notice Initializes the action module for the given publication being published with this Action module.
* @custom:permissions LensHub.
*
* @param profileId The profile ID of the author publishing the content with this Publication Action.
* @param pubId The publication ID being published.
* @param transactionExecutor The address of the transaction executor (e.g. for any funds to transferFrom).
* @param data Arbitrary data passed from the user to be decoded by the Action Module during initialization.
*
* @return bytes Any custom ABI-encoded data. This will be a LensHub event params that can be used by
* indexers or UIs.
*/
function initializePublicationAction(
uint256 profileId,
uint256 pubId,
address transactionExecutor,
bytes calldata data
) external returns (bytes memory);
/**
* @notice Processes the action for a given publication. This includes the action's logic and any monetary/token
* operations.
* @custom:permissions LensHub.
*
* @param processActionParams The parameters needed to execute the publication action.
*
* @return bytes Any custom ABI-encoded data. This will be a LensHub event params that can be used by
* indexers or UIs.
*/
function processPublicationAction(Types.ProcessActionParams calldata processActionParams)
external
returns (bytes memory);
}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
library Errors {
error CannotInitImplementation();
error Initialized();
error SignatureExpired();
error SignatureInvalid();
error InvalidOwner();
error NotOwnerOrApproved();
error NotHub();
error TokenDoesNotExist();
error NotGovernance();
error NotGovernanceOrEmergencyAdmin();
error EmergencyAdminCanOnlyPauseFurther();
error NotProfileOwner();
error PublicationDoesNotExist();
error CallerNotFollowNFT();
error CallerNotCollectNFT(); // Legacy
error ArrayMismatch();
error NotWhitelisted();
error NotRegistered();
error InvalidParameter();
error ExecutorInvalid();
error Blocked();
error SelfBlock();
error NotFollowing();
error SelfFollow();
error InvalidReferrer();
error InvalidPointedPub();
error NonERC721ReceiverImplementer();
error AlreadyEnabled();
// Module Errors
error InitParamsInvalid();
error ActionNotAllowed();
error CollectNotAllowed(); // Used in LegacyCollectLib (pending deprecation)
// MultiState Errors
error Paused();
error PublishingPaused();
// Profile Guardian Errors
error GuardianEnabled();
error NotEOA();
error DisablingAlreadyTriggered();
// Migration Errors
error NotMigrationAdmin();
}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
/**
* @title Types
* @author Lens Protocol
*
* @notice A standard library of data types used throughout the Lens Protocol.
*/
library Types {
/**
* @notice ERC721Timestamped storage. Contains the owner address and the mint timestamp for every NFT.
*
* Note: Instead of the owner address in the _tokenOwners private mapping, we now store it in the
* _tokenData mapping, alongside the mint timestamp.
*
* @param owner The token owner.
* @param mintTimestamp The mint timestamp.
*/
struct TokenData {
address owner;
uint96 mintTimestamp;
}
/**
* @notice A struct containing token follow-related data.
*
* @param followerProfileId The ID of the profile using the token to follow.
* @param originalFollowTimestamp The timestamp of the first follow performed with the token.
* @param followTimestamp The timestamp of the current follow, if a profile is using the token to follow.
* @param profileIdAllowedToRecover The ID of the profile allowed to recover the follow ID, if any.
*/
struct FollowData {
uint160 followerProfileId;
uint48 originalFollowTimestamp;
uint48 followTimestamp;
uint256 profileIdAllowedToRecover;
}
/**
* @notice An enum containing the different states the protocol can be in, limiting certain actions.
*
* @param Unpaused The fully unpaused state.
* @param PublishingPaused The state where only publication creation functions are paused.
* @param Paused The fully paused state.
*/
enum ProtocolState {
Unpaused,
PublishingPaused,
Paused
}
/**
* @notice An enum specifically used in a helper function to easily retrieve the publication type for integrations.
*
* @param Nonexistent An indicator showing the queried publication does not exist.
* @param Post A standard post, having an URI, action modules and no pointer to another publication.
* @param Comment A comment, having an URI, action modules and a pointer to another publication.
* @param Mirror A mirror, having a pointer to another publication, but no URI or action modules.
* @param Quote A quote, having an URI, action modules, and a pointer to another publication.
*/
enum PublicationType {
Nonexistent,
Post,
Comment,
Mirror,
Quote
}
/**
* @notice A struct containing the necessary information to reconstruct an EIP-712 typed data signature.
*
* @param signer The address of the signer. Specially needed as a parameter to support EIP-1271.
* @param v The signature's recovery parameter.
* @param r The signature's r parameter.
* @param s The signature's s parameter.
* @param deadline The signature's deadline.
*/
struct EIP712Signature {
address signer;
uint8 v;
bytes32 r;
bytes32 s;
uint256 deadline;
}
/**
* @notice A struct containing profile data.
*
* @param pubCount The number of publications made to this profile.
* @param followModule The address of the current follow module in use by this profile, can be address(0) in none.
* @param followNFT The address of the followNFT associated with this profile. It can be address(0) if the
* profile has not been followed yet, as the collection is lazy-deployed upon the first follow.
* @param __DEPRECATED__handle DEPRECATED in V2: handle slot, was replaced with LensHandles.
* @param __DEPRECATED__imageURI DEPRECATED in V2: The URI to be used for the profile image.
* @param __DEPRECATED__followNFTURI DEPRECATED in V2: The URI used for the follow NFT image.
* @param metadataURI MetadataURI is used to store the profile's metadata, for example: displayed name, description,
* interests, etc.
*/
struct Profile {
uint256 pubCount; // offset 0
address followModule; // offset 1
address followNFT; // offset 2
string __DEPRECATED__handle; // offset 3
string __DEPRECATED__imageURI; // offset 4
string __DEPRECATED__followNFTURI; // Deprecated in V2 as we have a common tokenURI for all Follows, offset 5
string metadataURI; // offset 6
}
/**
* @notice A struct containing publication data.
*
* @param pointedProfileId The profile token ID to point the publication to.
* @param pointedPubId The publication ID to point the publication to.
* These are used to implement the "reference" feature of the platform and is used in:
* - Mirrors
* - Comments
* - Quotes
* There are (0,0) if the publication is not pointing to any other publication (i.e. the publication is a Post).
* @param contentURI The URI to set for the content of publication (can be ipfs, arweave, http, etc).
* @param referenceModule Reference module associated with this profile, if any.
* @param __DEPRECATED__collectModule Collect module associated with this publication, if any. Deprecated in V2.
* @param __DEPRECATED__collectNFT Collect NFT associated with this publication, if any. Deprecated in V2.
* @param pubType The type of publication, can be Nonexistent, Post, Comment, Mirror or Quote.
* @param rootProfileId The profile ID of the root post (to determine if comments/quotes and mirrors come from it).
* Posts, V1 publications and publications rooted in V1 publications don't have it set.
* @param rootPubId The publication ID of the root post (to determine if comments/quotes and mirrors come from it).
* Posts, V1 publications and publications rooted in V1 publications don't have it set.
* @param actionModuleEnabled The action modules enabled in a given publication.
*/
struct Publication {
uint256 pointedProfileId;
uint256 pointedPubId;
string contentURI;
address referenceModule;
address __DEPRECATED__collectModule; // Deprecated in V2
address __DEPRECATED__collectNFT; // Deprecated in V2
// Added in Lens V2, so these will be zero for old publications:
PublicationType pubType;
uint256 rootProfileId;
uint256 rootPubId;
mapping(address => bool) actionModuleEnabled;
}
struct PublicationMemory {
uint256 pointedProfileId;
uint256 pointedPubId;
string contentURI;
address referenceModule;
address __DEPRECATED__collectModule; // Deprecated in V2
address __DEPRECATED__collectNFT; // Deprecated in V2
// Added in Lens V2, so these will be zero for old publications:
PublicationType pubType;
uint256 rootProfileId;
uint256 rootPubId;
// bytes32 __ACTION_MODULE_ENABLED_MAPPING; // Mappings are not supported in memory.
}
/**
* @notice A struct containing the parameters required for the `createProfile()` function.
*
* @param to The address receiving the profile.
* @param followModule The follow module to use, can be the zero address.
* @param followModuleInitData The follow module initialization data, if any.
*/
struct CreateProfileParams {
address to;
address followModule;
bytes followModuleInitData;
}
/**
* @notice A struct containing the parameters required for the `post()` function.
*
* @param profileId The token ID of the profile to publish to.
* @param contentURI The URI to set for this new publication.
* @param actionModules The action modules to set for this new publication.
* @param actionModulesInitDatas The data to pass to the action modules' initialization.
* @param referenceModule The reference module to set for the given publication, must be whitelisted.
* @param referenceModuleInitData The data to be passed to the reference module for initialization.
*/
struct PostParams {
uint256 profileId;
string contentURI;
address[] actionModules;
bytes[] actionModulesInitDatas;
address referenceModule;
bytes referenceModuleInitData;
}
/**
* @notice A struct containing the parameters required for the `comment()` function.
*
* @param profileId The token ID of the profile to publish to.
* @param contentURI The URI to set for this new publication.
* @param pointedProfileId The profile token ID to point the comment to.
* @param pointedPubId The publication ID to point the comment to.
* @param referrerProfileId The profile token ID of the publication that referred to the publication being commented on/quoted.
* @param referrerPubId The ID of the publication that referred to the publication being commented on/quoted.
* @param referenceModuleData The data passed to the reference module.
* @param actionModules The action modules to set for this new publication.
* @param actionModulesInitDatas The data to pass to the action modules' initialization.
* @param referenceModule The reference module to set for the given publication, must be whitelisted.
* @param referenceModuleInitData The data to be passed to the reference module for initialization.
*/
struct CommentParams {
uint256 profileId;
string contentURI;
uint256 pointedProfileId;
uint256 pointedPubId;
uint256[] referrerProfileIds;
uint256[] referrerPubIds;
bytes referenceModuleData;
address[] actionModules;
bytes[] actionModulesInitDatas;
address referenceModule;
bytes referenceModuleInitData;
}
/**
* @notice A struct containing the parameters required for the `quote()` function.
*
* @param profileId The token ID of the profile to publish to.
* @param contentURI The URI to set for this new publication.
* @param pointedProfileId The profile token ID of the publication author that is quoted.
* @param pointedPubId The publication ID that is quoted.
* @param referrerProfileId The profile token ID of the publication that referred to the publication being commented on/quoted.
* @param referrerPubId The ID of the publication that referred to the publication being commented on/quoted.
* @param referenceModuleData The data passed to the reference module.
* @param actionModules The action modules to set for this new publication.
* @param actionModulesInitDatas The data to pass to the action modules' initialization.
* @param referenceModule The reference module to set for the given publication, must be whitelisted.
* @param referenceModuleInitData The data to be passed to the reference module for initialization.
*/
struct QuoteParams {
uint256 profileId;
string contentURI;
uint256 pointedProfileId;
uint256 pointedPubId;
uint256[] referrerProfileIds;
uint256[] referrerPubIds;
bytes referenceModuleData;
address[] actionModules;
bytes[] actionModulesInitDatas;
address referenceModule;
bytes referenceModuleInitData;
}
/**
* @notice A struct containing the parameters required for the `comment()` or `quote()` internal functions.
*
* @param profileId The token ID of the profile to publish to.
* @param contentURI The URI to set for this new publication.
* @param pointedProfileId The profile token ID of the publication author that is commented on/quoted.
* @param pointedPubId The publication ID that is commented on/quoted.
* @param referrerProfileId The profile token ID of the publication that referred to the publication being commented on/quoted.
* @param referrerPubId The ID of the publication that referred to the publication being commented on/quoted.
* @param referenceModuleData The data passed to the reference module.
* @param actionModules The action modules to set for this new publication.
* @param actionModulesInitDatas The data to pass to the action modules' initialization.
* @param referenceModule The reference module to set for the given publication, must be whitelisted.
* @param referenceModuleInitData The data to be passed to the reference module for initialization.
*/
struct ReferencePubParams {
uint256 profileId;
string contentURI;
uint256 pointedProfileId;
uint256 pointedPubId;
uint256[] referrerProfileIds;
uint256[] referrerPubIds;
bytes referenceModuleData;
address[] actionModules;
bytes[] actionModulesInitDatas;
address referenceModule;
bytes referenceModuleInitData;
}
/**
* @notice A struct containing the parameters required for the `mirror()` function.
*
* @param profileId The token ID of the profile to publish to.
* @param metadataURI the URI containing metadata attributes to attach to this mirror publication.
* @param pointedProfileId The profile token ID to point the mirror to.
* @param pointedPubId The publication ID to point the mirror to.
* @param referenceModuleData The data passed to the reference module.
*/
struct MirrorParams {
uint256 profileId;
string metadataURI;
uint256 pointedProfileId;
uint256 pointedPubId;
uint256[] referrerProfileIds;
uint256[] referrerPubIds;
bytes referenceModuleData;
}
/**
* Deprecated in V2: Will be removed after some time after upgrading to V2.
* @notice A struct containing the parameters required for the legacy `collect()` function.
* @dev The referrer can only be a mirror of the publication being collected.
*
* @param publicationCollectedProfileId The token ID of the profile that published the publication to collect.
* @param publicationCollectedId The publication to collect's publication ID.
* @param collectorProfileId The collector profile.
* @param referrerProfileId The ID of a profile that authored a mirror that helped discovering the collected pub.
* @param referrerPubId The ID of the mirror that helped discovering the collected pub.
* @param collectModuleData The arbitrary data to pass to the collectModule if needed.
*/
struct LegacyCollectParams {
uint256 publicationCollectedProfileId;
uint256 publicationCollectedId;
uint256 collectorProfileId;
uint256 referrerProfileId;
uint256 referrerPubId;
bytes collectModuleData;
}
/**
* @notice A struct containing the parameters required for the `action()` function.
*
* @param publicationActedProfileId The token ID of the profile that published the publication to action.
* @param publicationActedId The publication to action's publication ID.
* @param actorProfileId The actor profile.
* @param referrerProfileId
* @param referrerPubId
* @param actionModuleAddress
* @param actionModuleData The arbitrary data to pass to the actionModule if needed.
*/
struct PublicationActionParams {
uint256 publicationActedProfileId;
uint256 publicationActedId;
uint256 actorProfileId;
uint256[] referrerProfileIds;
uint256[] referrerPubIds;
address actionModuleAddress;
bytes actionModuleData;
}
struct ProcessActionParams {
uint256 publicationActedProfileId;
uint256 publicationActedId;
uint256 actorProfileId;
address actorProfileOwner;
address transactionExecutor;
uint256[] referrerProfileIds;
uint256[] referrerPubIds;
Types.PublicationType[] referrerPubTypes;
bytes actionModuleData;
}
struct ProcessCommentParams {
uint256 profileId;
uint256 pubId;
address transactionExecutor;
uint256 pointedProfileId;
uint256 pointedPubId;
uint256[] referrerProfileIds;
uint256[] referrerPubIds;
Types.PublicationType[] referrerPubTypes;
bytes data;
}
struct ProcessQuoteParams {
uint256 profileId;
uint256 pubId;
address transactionExecutor;
uint256 pointedProfileId;
uint256 pointedPubId;
uint256[] referrerProfileIds;
uint256[] referrerPubIds;
Types.PublicationType[] referrerPubTypes;
bytes data;
}
struct ProcessMirrorParams {
uint256 profileId;
uint256 pubId;
address transactionExecutor;
uint256 pointedProfileId;
uint256 pointedPubId;
uint256[] referrerProfileIds;
uint256[] referrerPubIds;
Types.PublicationType[] referrerPubTypes;
bytes data;
}
/**
* @notice A struct containing a profile's delegated executors configuration.
*
* @param isApproved Tells when an address is approved as delegated executor in the given configuration number.
* @param configNumber Current configuration number in use.
* @param prevConfigNumber Previous configuration number set, before switching to the current one.
* @param maxConfigNumberSet Maximum configuration number ever used.
*/
struct DelegatedExecutorsConfig {
mapping(uint256 => mapping(address => bool)) isApproved; // isApproved[configNumber][delegatedExecutor]
uint64 configNumber;
uint64 prevConfigNumber;
uint64 maxConfigNumberSet;
}
struct TreasuryData {
address treasury;
uint16 treasuryFeeBPS;
}
struct MigrationParams {
address lensHandlesAddress;
address tokenHandleRegistryAddress;
address legacyFeeFollowModule;
address legacyProfileFollowModule;
address newFeeFollowModule;
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
import {IERC165} from '@openzeppelin/contracts/utils/introspection/IERC165.sol';
interface ILensModule is IERC165 {
/// @dev for now we check for keccak('LENS_MODULE');
/// Override this and add the type(IModuleInterface).interfaceId for corresponding module type
function supportsInterface(bytes4 interfaceID) external view returns (bool);
/// @notice Human-readable description of the module
// Can be JSON
// Can be contract source code
// Can be github link
// Can be ipfs with documentation
// etc
function getModuleMetadataURI() external view returns (string memory);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
import {ILensModule} from 'lens/modules/interfaces/ILensModule.sol';
abstract contract LensModule is ILensModule {
/// @inheritdoc ILensModule
function supportsInterface(bytes4 interfaceID) public pure virtual override returns (bool) {
return interfaceID == bytes4(keccak256(abi.encodePacked('LENS_MODULE')));
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
import {Ownable} from '@openzeppelin/contracts/access/Ownable.sol';
import {LensModule} from 'lens/modules/LensModule.sol';
contract LensModuleMetadata is LensModule, Ownable {
string public metadataURI;
constructor(address owner_) Ownable() {
_transferOwnership(owner_);
}
function setModuleMetadataURI(string memory _metadataURI) external onlyOwner {
metadataURI = _metadataURI;
}
function getModuleMetadataURI() external view returns (string memory) {
return metadataURI;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
import {LensModuleMetadata} from 'lens/modules/LensModuleMetadata.sol';
contract LensModuleMetadataInitializable is LensModuleMetadata {
constructor(address owner_) LensModuleMetadata(owner_) {}
function initialize(address moduleOwner) external virtual {
if (owner() != address(0) || moduleOwner == address(0)) {
revert();
}
_transferOwnership(moduleOwner);
}
}// SPDX-License-Identifier: Unlicense /* * @title Solidity Bytes Arrays Utils * @author Gonçalo Sá <[email protected]> * * @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity. * The library lets you concatenate, slice and type cast bytes arrays both in memory and storage. */ pragma solidity >=0.8.0 <0.9.0; library BytesLib { function concat( bytes memory _preBytes, bytes memory _postBytes ) internal pure returns (bytes memory) { bytes memory tempBytes; assembly { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // Store the length of the first bytes array at the beginning of // the memory for tempBytes. let length := mload(_preBytes) mstore(tempBytes, length) // Maintain a memory counter for the current write location in the // temp bytes array by adding the 32 bytes for the array length to // the starting location. let mc := add(tempBytes, 0x20) // Stop copying when the memory counter reaches the length of the // first bytes array. let end := add(mc, length) for { // Initialize a copy counter to the start of the _preBytes data, // 32 bytes into its memory. let cc := add(_preBytes, 0x20) } lt(mc, end) { // Increase both counters by 32 bytes each iteration. mc := add(mc, 0x20) cc := add(cc, 0x20) } { // Write the _preBytes data into the tempBytes memory 32 bytes // at a time. mstore(mc, mload(cc)) } // Add the length of _postBytes to the current length of tempBytes // and store it as the new length in the first 32 bytes of the // tempBytes memory. length := mload(_postBytes) mstore(tempBytes, add(length, mload(tempBytes))) // Move the memory counter back from a multiple of 0x20 to the // actual end of the _preBytes data. mc := end // Stop copying when the memory counter reaches the new combined // length of the arrays. end := add(mc, length) for { let cc := add(_postBytes, 0x20) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } // Update the free-memory pointer by padding our last write location // to 32 bytes: add 31 bytes to the end of tempBytes to move to the // next 32 byte block, then round down to the nearest multiple of // 32. If the sum of the length of the two arrays is zero then add // one before rounding down to leave a blank 32 bytes (the length block with 0). mstore(0x40, and( add(add(end, iszero(add(length, mload(_preBytes)))), 31), not(31) // Round down to the nearest 32 bytes. )) } return tempBytes; } function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal { assembly { // Read the first 32 bytes of _preBytes storage, which is the length // of the array. (We don't need to use the offset into the slot // because arrays use the entire slot.) let fslot := sload(_preBytes.slot) // Arrays of 31 bytes or less have an even value in their slot, // while longer arrays have an odd value. The actual length is // the slot divided by two for odd values, and the lowest order // byte divided by two for even values. // If the slot is even, bitwise and the slot with 255 and divide by // two to get the length. If the slot is odd, bitwise and the slot // with -1 and divide by two. let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) let newlength := add(slength, mlength) // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage switch add(lt(slength, 32), lt(newlength, 32)) case 2 { // Since the new array still fits in the slot, we just need to // update the contents of the slot. // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length sstore( _preBytes.slot, // all the modifications to the slot are inside this // next block add( // we can just add to the slot contents because the // bytes we want to change are the LSBs fslot, add( mul( div( // load the bytes from memory mload(add(_postBytes, 0x20)), // zero all bytes to the right exp(0x100, sub(32, mlength)) ), // and now shift left the number of bytes to // leave space for the length in the slot exp(0x100, sub(32, newlength)) ), // increase length by the double of the memory // bytes length mul(mlength, 2) ) ) ) } case 1 { // The stored value fits in the slot, but the combined value // will exceed it. // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes.slot, add(mul(newlength, 2), 1)) // The contents of the _postBytes array start 32 bytes into // the structure. Our first read should obtain the `submod` // bytes that can fit into the unused space in the last word // of the stored array. To get this, we read 32 bytes starting // from `submod`, so the data we read overlaps with the array // contents by `submod` bytes. Masking the lowest-order // `submod` bytes allows us to add that value directly to the // stored value. let submod := sub(32, slength) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore( sc, add( and( fslot, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00 ), and(mload(mc), mask) ) ) for { mc := add(mc, 0x20) sc := add(sc, 1) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } default { // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) // Start copying to the last used word of the stored array. let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes.slot, add(mul(newlength, 2), 1)) // Copy over the first `submod` bytes of the new data as in // case 1 above. let slengthmod := mod(slength, 32) let mlengthmod := mod(mlength, 32) let submod := sub(32, slengthmod) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore(sc, add(sload(sc), and(mload(mc), mask))) for { sc := add(sc, 1) mc := add(mc, 0x20) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } } } function slice( bytes memory _bytes, uint256 _start, uint256 _length ) internal pure returns (bytes memory) { require(_length + 31 >= _length, "slice_overflow"); require(_bytes.length >= _start + _length, "slice_outOfBounds"); bytes memory tempBytes; assembly { switch iszero(_length) case 0 { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // The first word of the slice result is potentially a partial // word read from the original array. To read it, we calculate // the length of that partial word and start copying that many // bytes into the array. The first word we copy will start with // data we don't care about, but the last `lengthmod` bytes will // land at the beginning of the contents of the new array. When // we're done copying, we overwrite the full first word with // the actual length of the slice. let lengthmod := and(_length, 31) // The multiplication in the next line is necessary // because when slicing multiples of 32 bytes (lengthmod == 0) // the following copy loop was copying the origin's length // and then ending prematurely not copying everything it should. let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod))) let end := add(mc, _length) for { // The multiplication in the next line has the same exact purpose // as the one above. let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } mstore(tempBytes, _length) //update free-memory pointer //allocating the array padded to 32 bytes like the compiler does now mstore(0x40, and(add(mc, 31), not(31))) } //if we want a zero-length slice let's just return a zero-length array default { tempBytes := mload(0x40) //zero out the 32 bytes slice we are about to return //we need to do it because Solidity does not garbage collect mstore(tempBytes, 0) mstore(0x40, add(tempBytes, 0x20)) } } return tempBytes; } function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address) { require(_bytes.length >= _start + 20, "toAddress_outOfBounds"); address tempAddress; assembly { tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000) } return tempAddress; } function toUint8(bytes memory _bytes, uint256 _start) internal pure returns (uint8) { require(_bytes.length >= _start + 1 , "toUint8_outOfBounds"); uint8 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x1), _start)) } return tempUint; } function toUint16(bytes memory _bytes, uint256 _start) internal pure returns (uint16) { require(_bytes.length >= _start + 2, "toUint16_outOfBounds"); uint16 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x2), _start)) } return tempUint; } function toUint32(bytes memory _bytes, uint256 _start) internal pure returns (uint32) { require(_bytes.length >= _start + 4, "toUint32_outOfBounds"); uint32 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x4), _start)) } return tempUint; } function toUint64(bytes memory _bytes, uint256 _start) internal pure returns (uint64) { require(_bytes.length >= _start + 8, "toUint64_outOfBounds"); uint64 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x8), _start)) } return tempUint; } function toUint96(bytes memory _bytes, uint256 _start) internal pure returns (uint96) { require(_bytes.length >= _start + 12, "toUint96_outOfBounds"); uint96 tempUint; assembly { tempUint := mload(add(add(_bytes, 0xc), _start)) } return tempUint; } function toUint128(bytes memory _bytes, uint256 _start) internal pure returns (uint128) { require(_bytes.length >= _start + 16, "toUint128_outOfBounds"); uint128 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x10), _start)) } return tempUint; } function toUint256(bytes memory _bytes, uint256 _start) internal pure returns (uint256) { require(_bytes.length >= _start + 32, "toUint256_outOfBounds"); uint256 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x20), _start)) } return tempUint; } function toBytes32(bytes memory _bytes, uint256 _start) internal pure returns (bytes32) { require(_bytes.length >= _start + 32, "toBytes32_outOfBounds"); bytes32 tempBytes32; assembly { tempBytes32 := mload(add(add(_bytes, 0x20), _start)) } return tempBytes32; } function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) { bool success = true; assembly { let length := mload(_preBytes) // if lengths don't match the arrays are not equal switch eq(length, mload(_postBytes)) case 1 { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 let mc := add(_preBytes, 0x20) let end := add(mc, length) for { let cc := add(_postBytes, 0x20) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) } eq(add(lt(mc, end), cb), 2) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { // if any of these checks fails then arrays are not equal if iszero(eq(mload(mc), mload(cc))) { // unsuccess: success := 0 cb := 0 } } } default { // unsuccess: success := 0 } } return success; } function equal_nonAligned(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) { bool success = true; assembly { let length := mload(_preBytes) // if lengths don't match the arrays are not equal switch eq(length, mload(_postBytes)) case 1 { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 let endMinusWord := add(_preBytes, length) let mc := add(_preBytes, 0x20) let cc := add(_postBytes, 0x20) for { // the next line is the loop condition: // while(uint256(mc < endWord) + cb == 2) } eq(add(lt(mc, endMinusWord), cb), 2) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { // if any of these checks fails then arrays are not equal if iszero(eq(mload(mc), mload(cc))) { // unsuccess: success := 0 cb := 0 } } // Only if still successful // For <1 word tail bytes if gt(success, 0) { // Get the remainder of length/32 // length % 32 = AND(length, 32 - 1) let numTailBytes := and(length, 0x1f) let mcRem := mload(mc) let ccRem := mload(cc) for { let i := 0 // the next line is the loop condition: // while(uint256(i < numTailBytes) + cb == 2) } eq(add(lt(i, numTailBytes), cb), 2) { i := add(i, 1) } { if iszero(eq(byte(i, mcRem), byte(i, ccRem))) { // unsuccess: success := 0 cb := 0 } } } } default { // unsuccess: success := 0 } } return success; } function equalStorage( bytes storage _preBytes, bytes memory _postBytes ) internal view returns (bool) { bool success = true; assembly { // we know _preBytes_offset is 0 let fslot := sload(_preBytes.slot) // Decode the length of the stored array like in concatStorage(). let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) // if lengths don't match the arrays are not equal switch eq(slength, mlength) case 1 { // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage if iszero(iszero(slength)) { switch lt(slength, 32) case 1 { // blank the last byte which is the length fslot := mul(div(fslot, 0x100), 0x100) if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) { // unsuccess: success := 0 } } default { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := keccak256(0x0, 0x20) let mc := add(_postBytes, 0x20) let end := add(mc, mlength) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) for {} eq(add(lt(mc, end), cb), 2) { sc := add(sc, 1) mc := add(mc, 0x20) } { if iszero(eq(sload(sc), mload(mc))) { // unsuccess: success := 0 cb := 0 } } } } } default { // unsuccess: success := 0 } } return success; } }
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;
interface IZoraLzMintActionV2 {
struct RemoteMint {
address token;
uint256 tokenId;
uint96 salePrice;
}
struct LzQuoteInput {
address profileOwner;
address remoteContract;
uint256 profileId;
uint256 pubId;
uint256 quantity;
uint256 remoteTokenId;
}
error InitParamsInvalid();
error NoZeroAddress();
error InvalidQuoteForSalePrice();
error InvalidInput();
error InsufficientNativeFee();
event InitAction(uint256 profileId, uint256 pubId, address token, uint256 tokenId);
event MintIntentRelayed(
uint256 publicationActedProfileId,
uint256 publicationActedId,
uint256 actorProfileId
);
}{
"viaIR": true,
"optimizer": {
"enabled": true,
"runs": 2000
},
"evmVersion": "london",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"metadata": {
"useLiteralContent": true
},
"libraries": {}
}Contract ABI
API[{"inputs":[{"internalType":"address","name":"_hub","type":"address"},{"internalType":"address","name":"_lzEndpoint","type":"address"},{"internalType":"address","name":"_bonsai","type":"address"},{"internalType":"address","name":"_bonsaiAdapter","type":"address"},{"internalType":"address","name":"_WMATIC","type":"address"},{"internalType":"bytes32","name":"_remoteZoraCreator","type":"bytes32"},{"internalType":"uint32","name":"_remoteEid","type":"uint32"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"InitParamsInvalid","type":"error"},{"inputs":[],"name":"InsufficientNativeFee","type":"error"},{"inputs":[],"name":"InvalidInput","type":"error"},{"inputs":[{"internalType":"uint16","name":"optionType","type":"uint16"}],"name":"InvalidOptionType","type":"error"},{"inputs":[],"name":"InvalidQuoteForSalePrice","type":"error"},{"inputs":[],"name":"NoZeroAddress","type":"error"},{"inputs":[],"name":"NotHub","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"pubId","type":"uint256"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"InitAction","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"publicationActedProfileId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"publicationActedId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"actorProfileId","type":"uint256"}],"name":"MintIntentRelayed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"HUB","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WMATIC","outputs":[{"internalType":"contract IWMATIC","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bonsai","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bonsaiAdapter","outputs":[{"internalType":"contract IOFT","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getModuleMetadataURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"publicationActedProfileId","type":"uint256"},{"internalType":"uint256","name":"publicationActedId","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"name":"getTotalSalePrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint96","name":"salePrice","type":"uint96"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"name":"getTotalSalePrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hub","outputs":[{"internalType":"contract ILensHub","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"moduleOwner","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"pubId","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"initializePublicationAction","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"metadataURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"publicationActedProfileId","type":"uint256"},{"internalType":"uint256","name":"publicationActedId","type":"uint256"},{"internalType":"uint256","name":"actorProfileId","type":"uint256"},{"internalType":"address","name":"actorProfileOwner","type":"address"},{"internalType":"address","name":"transactionExecutor","type":"address"},{"internalType":"uint256[]","name":"referrerProfileIds","type":"uint256[]"},{"internalType":"uint256[]","name":"referrerPubIds","type":"uint256[]"},{"internalType":"enum Types.PublicationType[]","name":"referrerPubTypes","type":"uint8[]"},{"internalType":"bytes","name":"actionModuleData","type":"bytes"}],"internalType":"struct Types.ProcessActionParams","name":"processActionParams","type":"tuple"}],"name":"processPublicationAction","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"protocolFeeBps","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"profileOwner","type":"address"},{"internalType":"address","name":"remoteContract","type":"address"},{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"pubId","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"},{"internalType":"uint256","name":"remoteTokenId","type":"uint256"}],"internalType":"struct IZoraLzMintActionV2.LzQuoteInput","name":"input","type":"tuple"}],"name":"quote","outputs":[{"components":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"lzTokenFee","type":"uint256"}],"internalType":"struct MessagingFee","name":"fee","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"pubId","type":"uint256"}],"name":"remoteMints","outputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint96","name":"salePrice","type":"uint96"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_lzSponsored","type":"bool"}],"name":"setLzSponsored","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_metadataURI","type":"string"}],"name":"setModuleMetadataURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_remoteZoraCreator","type":"bytes32"}],"name":"setRemoteZoraCreator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_protocolFeeBps","type":"uint16"}],"name":"setprotocolFeeBps","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceID","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawNative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"withdrawTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
61012034620001bf57601f6200282e38819003918201601f19168301916001600160401b03831184841017620001c45780849260e094604052833981010312620001bf576200004e81620001da565b906200005d60208201620001da565b506200006c60408201620001da565b916200007b60608301620001da565b926200008a60808401620001da565b9060c060a085015194015163ffffffff8116809103620001bf5783608052620000b333620001ef565b620000be33620001ef565b6001600160a01b039384169182158015620001b4575b8015620001a9575b6200019757849163ffffffff1960045416176004551660a05260e05281610100941684521660c0526003556101f461ffff1960025416176002556040516125f79182620002378339608051828181610beb015281816111ff015281816115820152612575015260a05182818161085801528181610d9d0152612336015260c0518281816107d90152610fa5015260e05182818161064b0152818161225d0152612374015251818181610ab501528181610d2a01526121830152f35b60405163ddbadd5f60e01b8152600490fd5b5084841615620000dc565b5084871615620000d4565b600080fd5b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b0382168203620001bf57565b600080546001600160a01b039283166001600160a01b03198216811783559216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09080a356fe60806040526004361015610018575b361561001657005b005b60003560e01c806301ffc9a7146101a3578063023a979f1461019e57806303ee438c1461013a5780630b9602201461019957806328c8b8811461019457806335659fb81461018f578063365a86fc1461018a57806349df728c146101855780634d95cad91461018057806350431ce41461017b57806355c9ceac14610176578063681591c114610171578063715018a61461016c57806376c2c59a146101675780638baf57e7146101625780638da5cb5b1461015d5780638e156d021461015857806390ce6e0814610153578063a4c52b861461014e578063b71882b414610149578063b9b726ec14610144578063c4d66de81461013f578063ce90d52e1461013a578063dfe9c5fd146101355763f2fde38b0361000e5761137e565b6112f9565b610411565b6112ac565b61128b565b611223565b6111df565b610ba7565b610b6f565b610b2f565b610ad9565b610a95565b610a2e565b6108fe565b610838565b6107fd565b6107b9565b61066f565b61062b565b610609565b6105a8565b61052a565b610273565b34610262576020600319360112610262576004357fffffffff0000000000000000000000000000000000000000000000000000000080821680920361026257817f9b586c28000000000000000000000000000000000000000000000000000000006020931491821561021c575b50506040519015158152f35b909150604051838101907f4c454e535f4d4f44554c450000000000000000000000000000000000000000008252600b815261025681610376565b51902016143880610210565b600080fd5b61ffff81160361026257565b346102625760206003193601126102625761ffff60043561029381610267565b61029b611425565b167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00006002541617600255600080f35b600091031261026257565b90600182811c92168015610305575b60208310146102ef57565b634e487b7160e01b600052602260045260246000fd5b91607f16916102e4565b634e487b7160e01b600052604160045260246000fd5b67ffffffffffffffff811161033957604052565b61030f565b60c0810190811067ffffffffffffffff82111761033957604052565b6060810190811067ffffffffffffffff82111761033957604052565b6040810190811067ffffffffffffffff82111761033957604052565b90601f601f19910116810190811067ffffffffffffffff82111761033957604052565b60005b8381106103c85750506000910152565b81810151838201526020016103b8565b90601f19601f6020936103f6815180928187528780880191016103b5565b0116010190565b90602061040e9281815201906103d8565b90565b346102625760008060031936011261051657604051908082600192835493610438856102d5565b938484526020958683821691826000146104d557505060011461047c575b505061046492500383610392565b6104786040519282849384528301906103d8565b0390f35b908592508082527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf65b8583106104bd57505061046493508201013880610456565b805483890185015287945086939092019181016104a5565b915093506104649592507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0091501682840152151560051b8201013880610456565b80fd5b6001600160a01b0381160361026257565b3461026257608060031936011261026257610546604435610519565b67ffffffffffffffff6064358181116102625736602382011215610262578060040135918211610262573660248383010111610262576104789160246105929201602435600435611576565b604051918291826103fd565b8015150361026257565b34610262576020600319360112610262576004356105c58161059e565b6105cd611425565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffffffff64ff0000000060045492151560201b16911617600455600080f35b3461026257600060031936011261026257602061ffff60025416604051908152f35b346102625760006003193601126102625760206040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b3461026257602080600319360112610262576001600160a01b0360043561069581610519565b61069d611425565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015291168282602481845afa9182156107855760009261078a575b50816106ea57005b61074f9183916107026000546001600160a01b031690565b60006040518096819582947fa9059cbb00000000000000000000000000000000000000000000000000000000845260048401602090939291936001600160a01b0360408201951681520152565b03925af180156107855761075f57005b8161001692903d1061077e575b6107768183610392565b810190611561565b503d61076c565b611546565b6107ab919250833d85116107b2575b6107a38183610392565b810190611552565b90386106e2565b503d610799565b346102625760006003193601126102625760206040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b346102625760008060031936011261051657610817611425565b808080804781811561082f575b3390f1156107855780f35b506108fc610824565b346102625760006003193601126102625760206040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b6040519060e0820182811067ffffffffffffffff82111761033957604052565b604051906108a98261035a565b565b67ffffffffffffffff811161033957601f01601f191660200190565b9291926108d3826108ab565b916108e16040519384610392565b829481845281830111610262578281602093846000960137010152565b34610262576020806003193601126102625767ffffffffffffffff906004358281116102625736602382011215610262576109439036906024816004013591016108c7565b9161094c611425565b82519081116103395760019161096b8261096685546102d5565b6114d2565b80601f83116001146109aa5750819061099b939460009261099f575b50506000198260011b9260031b1c19161790565b9055005b015190503880610987565b90601f198316946109dd60016000527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf690565b926000905b878210610a17575050838596106109fe575b505050811b019055005b015160001960f88460031b161c191690553880806109f4565b8087859682949686015181550195019301906109e2565b346102625760008060031936011261051657610a48611425565b806001600160a01b03815473ffffffffffffffffffffffffffffffffffffffff1981168355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b346102625760006003193601126102625760206040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b3461026257606060031936011261026257600435600052600560205260406000206024356000526020526020610b276044356bffffffffffffffffffffffff600260406000200154166121e3565b604051908152f35b346102625760006003193601126102625760206001600160a01b0360005416604051908152f35b35906bffffffffffffffffffffffff8216820361026257565b34610262576040600319360112610262576004356bffffffffffffffffffffffff8116810361026257610b27602091602435906121e3565b3461026257602060031990808236011261026257600480359267ffffffffffffffff841161026257610120848301918536030112610262576001600160a01b0392837f00000000000000000000000000000000000000000000000000000000000000001633036111b657813584610c28826000526005602052604060002090565b94610c4a610c4560248a0135809890600052602052604060002090565b61176f565b95610c64610c5c6101048b01886117ae565b8101906117e1565b909816958815801561119f575b8015611188575b61115f5788610cdf9160a48c0190610c908282611807565b60009150156111575750610caa610cb692610cb092611807565b9061183d565b35612539565b898c610cd960648b610ccf85516001600160a01b031690565b94015192016117fd565b916122db565b91610d2660848b01978a610cf28a6117fd565b60409b8c01516bffffffffffffffffffffffff16926bffffffffffffffffffffffff610d1e84866121e3565b94169161232c565b93807f0000000000000000000000000000000000000000000000000000000000000000169089517f095ea7b3000000000000000000000000000000000000000000000000000000008152888180610d968a87898401602090939291936001600160a01b0360408201951681520152565b03816000867f0000000000000000000000000000000000000000000000000000000000000000165af180156107855761113a575b50825460035490610de9610de4610ddf611a5d565b611a92565b611bcc565b610df161087c565b63ffffffff83168152928b840152888d84015288606084015260808301528660a0830152610e1d61185c565b9a60c09b8c8401528c51937f3b6f743b0000000000000000000000000000000000000000000000000000000085528d8580610e5a878b8301611929565b0381895afa948515610785578e60009661110b575b505060ff600093610e7e61195f565b508d1c1615610f985750505091818a93610eca959351908d51968795869485937fc7c7f5b3000000000000000000000000000000000000000000000000000000008552309285016119e7565b03925af1908115610785576104789a610f32610f52977f68ae82f3369be05da0ae3b1c076eacccf981d7e837d84c6412e59f3ea88ef45b94604494610f609c600092610f6a575b5050955b8c5191825260208201529290910135604083015281906060820190565b0390a180519085015167ffffffffffffffff169187519889968701611a25565b03601f198101845283610392565b51918291826103fd565b610f899250803d10610f91575b610f818183610392565b810190611987565b503880610f11565b503d610f77565b90829f9a9c9592969493917f000000000000000000000000000000000000000000000000000000000000000016610fdc610fd1836117fd565b865190309084611da1565b8451813b15611107578f517f2e1a7d4d0000000000000000000000000000000000000000000000000000000081528781019182529891899182908490829060200103925af1948515610785578e9787966110ee575b5061108261104f6110438751946117fd565b6001600160a01b031690565b9851988996879586947fc7c7f5b300000000000000000000000000000000000000000000000000000000865285016119e7565b03925af195861561078557610f32610f6099610f52987f68ae82f3369be05da0ae3b1c076eacccf981d7e837d84c6412e59f3ea88ef45b956104789f95604496926110d0575b505095610f15565b6110e69250803d10610f9157610f818183610392565b5038806110c8565b806110fb61110192610325565b806102ca565b38611031565b8880fd5b61112b929650803d10611133575b6111238183610392565b8101906118a8565b93388e610e6f565b503d611119565b61115090893d8b1161077e576107768183610392565b5038610dca565b915050610cb6565b826040517fb4fa3fb3000000000000000000000000000000000000000000000000000000008152fd5b5061119861104360648c016117fd565b8714610c78565b506111af61104360848c016117fd565b8714610c71565b826040517f9de97418000000000000000000000000000000000000000000000000000000008152fd5b346102625760006003193601126102625760206040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b346102625760406003193601126102625760043560005260056020526040600020602435600052602052606060406000206001600160a01b03815416906bffffffffffffffffffffffff60026001830154920154169060405192835260208301526040820152f35b34610262576020600319360112610262576112a4611425565b600435600355005b34610262576020600319360112610262576004356112c981610519565b6001600160a01b03806000541615908115916112ee575b50610262576100169061147d565b9050811615386112e0565b346102625760c06003193601126102625761047861136060405161131c8161033e565b60043561132881610519565b815260243561133681610519565b602082015260443560408201526064356060820152608435608082015260a43560a0820152612038565b60405191829182815181526020918201519181019190915260400190565b346102625760206003193601126102625760043561139b81610519565b6113a3611425565b6001600160a01b038116156113bb576100169061147d565b608460405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152fd5b6001600160a01b0360005416330361143957565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b600054906001600160a01b03809116918273ffffffffffffffffffffffffffffffffffffffff19821617600055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b90601f82116114df575050565b6001916000908382527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6906020601f850160051c8301941061153c575b601f0160051c01915b8281106115325750505050565b8181558301611525565b909250829061151c565b6040513d6000823e3d90fd5b90816020910312610262575190565b90816020910312610262575161040e8161059e565b6001600160a01b0393917f000000000000000000000000000000000000000000000000000000000000000085163303611745576060848481010312610262578335916115c183610519565b6020850135956115d360408701610b56565b9316928315801561173d575b6117135761040e967fb02fc9d11ea117984ce645da380ae3dc69cfb90ba320e03d28428a987515776e946116dc6117099361164461161b61089c565b6001600160a01b038516815291602083018690526bffffffffffffffffffffffff166040830152565b61166b8761165c886000526005602052604060002090565b90600052602052604060002090565b604060026bffffffffffffffffffffffff926001600160a01b0385511673ffffffffffffffffffffffffffffffffffffffff198254161781556020850151600182015501920151167fffffffffffffffffffffffffffffffffffffffff000000000000000000000000825416179055565b60405194859485909493926001600160a01b03906060936080840197845260208401521660408201520152565b0390a136916108c7565b60046040517f48be0eb3000000000000000000000000000000000000000000000000000000008152fd5b5086156115df565b60046040517f9de97418000000000000000000000000000000000000000000000000000000008152fd5b9060405161177c8161035a565b60406bffffffffffffffffffffffff600283956001600160a01b03815416855260018101546020860152015416910152565b903590601e1981360301821215610262570180359067ffffffffffffffff82116102625760200191813603831361026257565b9190826040910312610262576020823592013561040e81610519565b3561040e81610519565b903590601e1981360301821215610262570180359067ffffffffffffffff821161026257602001918160051b3603831361026257565b90156118465790565b634e487b7160e01b600052603260045260246000fd5b604051906020820182811067ffffffffffffffff8211176103395760405260008252565b91908260409103126102625760405161189881610376565b6020808294805184520151910152565b906040828203126102625761040e91611880565b61040e9163ffffffff825116815260208201516020820152604082015160408201526060820151606082015260c0611918611906608085015160e0608086015260e08501906103d8565b60a085015184820360a08601526103d8565b9201519060c08184039101526103d8565b919060206119416000926040865260408601906118bc565b930152565b6040519061195382610376565b60006020838281520152565b6040519061196c8261035a565b8160008152600060208201526040611982611946565b910152565b919082810360c081126102625760801361026257604051906119a88261035a565b83518252602084015167ffffffffffffffff811681036102625782608091602061040e9501526119db8360408801611880565b60408201529401611880565b9193926001600160a01b0390611a1f611a0a6060946080875260808701906118bc565b96602086019060208091805184520151910152565b16910152565b9193611a4d60809497969567ffffffffffffffff93855260a0602086015260a08501906103d8565b9660408401521660608201520152565b6040517e0300000000000000000000000000000000000000000000000000000000000060208201526002815261040e81610376565b61ffff600381611aa184611fd1565b1603611bc157604051917207a12000000000000000000000000000000000602084015260108352611ad183610376565b600382611add83611fd1565b1603611b8657825191808311611b1c57611afe611b0e9161040e9416611c65565b9360405194859360208501611c7d565b03601f198101835282610392565b608460405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203160448201527f36206269747300000000000000000000000000000000000000000000000000006064820152fd5b90611b92602492611fd1565b6040517f3a51740d00000000000000000000000000000000000000000000000000000000815291166004820152fd5b611b92602492611fd1565b61ffff600381611bdb84611fd1565b1603611bc15760405191600060208401527207a12000000000000000000000000000000000602284015260128352611c1283610376565b600382611c1e83611fd1565b1603611b8657825191808311611b1c57611c3f611b0e9161040e9416611c65565b9360405194859360208501611d02565b634e487b7160e01b600052601160045260246000fd5b90600161ffff80931601918211611c7857565b611c4f565b602090611c946004959493828151948592016103b5565b01907fffff0000000000000000000000000000000000000000000000000000000000007f01000000000000000000000000000000000000000000000000000000000000009182845260f01b1660018301526003820152611cfd82518093602086850191016103b5565b010190565b60207fffff00000000000000000000000000000000000000000000000000000000000091611d3a6004969594828151948592016103b5565b01917f0100000000000000000000000000000000000000000000000000000000000000835260f01b1660018201527f03000000000000000000000000000000000000000000000000000000000000006003820152611cfd82518093602086850191016103b5565b9290604051927f23b872dd0000000000000000000000000000000000000000000000000000000060208501526001600160a01b03809216602485015216604483015260648201526064815260a081019181831067ffffffffffffffff841117610339576108a9926040525b604051611e89916001600160a01b0316611e2582610376565b6000806020958685527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656487860152868151910182855af13d15611f18573d91611e6d836108ab565b92611e7b6040519485610392565b83523d60008785013e611f1c565b80519081611e9657505050565b8280611ea6938301019101611561565b15611eae5750565b6084906040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152fd5b6060915b91929015611f7d5750815115611f30575090565b3b15611f395790565b606460405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152fd5b825190915015611f905750805190602001fd5b611fac9060405191829162461bcd60e51b8352600483016103fd565b0390fd5b906602c2ad68fd90008201809211611c7857565b91908201809211611c7857565b6002815110611fe1576002015190565b606460405162461bcd60e51b815260206004820152601460248201527f746f55696e7431365f6f75744f66426f756e64730000000000000000000000006044820152fd5b81810292918115918404141715611c7857565b612040611946565b506121776040826120e461207b610c4561206885809801516000526005602052604060002090565b6060850151600052602052604060002090565b916bffffffffffffffffffffffff6120db856120c76120a187516001600160a01b031690565b60806020890151966120ba81516001600160a01b031690565b91829101978851936122db565b9501516bffffffffffffffffffffffff1690565b91519116612025565b906120f460045463ffffffff1690565b9160035490612107610de4610ddf611a5d565b9161211f61211361087c565b63ffffffff9096168652565b602085015280858501526060840152608083015260a082015261214061185c565b60c08201528151809381927f3b6f743b00000000000000000000000000000000000000000000000000000000835260048301611929565b03816001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000165afa918215610785576000926121b857505090565b61040e9250803d10611133576111238183610392565b90816020910312610262575161040e81610267565b6bffffffffffffffffffffffff61220e9116916122096122038285612025565b93611fb0565b612025565b9061271061ffff81612224826002541685612025565b0492604051917f29070c6d0000000000000000000000000000000000000000000000000000000083526020836004816001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000165afa801561078557612299936000916122ad575b501690612025565b04908201809211611c785761040e91611fc4565b6122ce915060203d81116122d4575b6122c68183610392565b8101906121ce565b38612291565b503d6122bc565b909291604051946001600160a01b0394858094166020880152604087015260608601521660808401521660a082015260a0815261040e8161033e565b90816020910312610262575161040e81610519565b9291909361235e907f000000000000000000000000000000000000000000000000000000000000000094309086611da1565b6123688282612025565b6001600160a01b0393847f00000000000000000000000000000000000000000000000000000000000000001695604051957f3b19e84a000000000000000000000000000000000000000000000000000000008752602080886004818c5afa978815610785576000986124ae575b50806004979899604051988980927f29070c6d0000000000000000000000000000000000000000000000000000000082525afa9889156107855761243d61243561ffff61040e9c6122099b61244496600092612491575b50501688612025565b612710900490565b90856124e2565b8116612453575b505050611fb0565b61248361247d6124356124899561247761247060025461ffff1690565b61ffff1690565b90612025565b60011c90565b916124e2565b38808061244b565b6124a79250803d106122d4576122c68183610392565b388061242c565b60049798506124d38291823d84116124db575b6124cb8183610392565b810190612317565b9897506123d5565b503d6124c1565b6040517fa9059cbb0000000000000000000000000000000000000000000000000000000060208201526001600160a01b03909216602483015260448201929092526108a9916125348260648101610f52565b611e0c565b604051907f6352211e00000000000000000000000000000000000000000000000000000000825260048201526020816024816001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000165afa908115610785576000916125a9575090565b61040e915060203d81116124db576124cb818361039256fea2646970667358221220e02381a544fbdc6a9d771a833735093bfd29072819773da22681d815573b7d8764736f6c63430008150033000000000000000000000000a2574d9ddb6a325ad2be838bd854228b802151480000000000000000000000006edce65403992e310a62460808c4b910d972f10f0000000000000000000000003d2bd0e15829aa5c362a4144fdf4a1112fa29b5c0000000000000000000000009918889e93e8c4357a2d4bce0965dcc493fffda8000000000000000000000000360ad4f9a9a8efe9a8dcb5f461c4cc1047e1dcf9000000000000000000000000482107b5966178b595758069e80d7dd7f16526220000000000000000000000000000000000000000000000000000000000009d35
Deployed Bytecode
0x60806040526004361015610018575b361561001657005b005b60003560e01c806301ffc9a7146101a3578063023a979f1461019e57806303ee438c1461013a5780630b9602201461019957806328c8b8811461019457806335659fb81461018f578063365a86fc1461018a57806349df728c146101855780634d95cad91461018057806350431ce41461017b57806355c9ceac14610176578063681591c114610171578063715018a61461016c57806376c2c59a146101675780638baf57e7146101625780638da5cb5b1461015d5780638e156d021461015857806390ce6e0814610153578063a4c52b861461014e578063b71882b414610149578063b9b726ec14610144578063c4d66de81461013f578063ce90d52e1461013a578063dfe9c5fd146101355763f2fde38b0361000e5761137e565b6112f9565b610411565b6112ac565b61128b565b611223565b6111df565b610ba7565b610b6f565b610b2f565b610ad9565b610a95565b610a2e565b6108fe565b610838565b6107fd565b6107b9565b61066f565b61062b565b610609565b6105a8565b61052a565b610273565b34610262576020600319360112610262576004357fffffffff0000000000000000000000000000000000000000000000000000000080821680920361026257817f9b586c28000000000000000000000000000000000000000000000000000000006020931491821561021c575b50506040519015158152f35b909150604051838101907f4c454e535f4d4f44554c450000000000000000000000000000000000000000008252600b815261025681610376565b51902016143880610210565b600080fd5b61ffff81160361026257565b346102625760206003193601126102625761ffff60043561029381610267565b61029b611425565b167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00006002541617600255600080f35b600091031261026257565b90600182811c92168015610305575b60208310146102ef57565b634e487b7160e01b600052602260045260246000fd5b91607f16916102e4565b634e487b7160e01b600052604160045260246000fd5b67ffffffffffffffff811161033957604052565b61030f565b60c0810190811067ffffffffffffffff82111761033957604052565b6060810190811067ffffffffffffffff82111761033957604052565b6040810190811067ffffffffffffffff82111761033957604052565b90601f601f19910116810190811067ffffffffffffffff82111761033957604052565b60005b8381106103c85750506000910152565b81810151838201526020016103b8565b90601f19601f6020936103f6815180928187528780880191016103b5565b0116010190565b90602061040e9281815201906103d8565b90565b346102625760008060031936011261051657604051908082600192835493610438856102d5565b938484526020958683821691826000146104d557505060011461047c575b505061046492500383610392565b6104786040519282849384528301906103d8565b0390f35b908592508082527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf65b8583106104bd57505061046493508201013880610456565b805483890185015287945086939092019181016104a5565b915093506104649592507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0091501682840152151560051b8201013880610456565b80fd5b6001600160a01b0381160361026257565b3461026257608060031936011261026257610546604435610519565b67ffffffffffffffff6064358181116102625736602382011215610262578060040135918211610262573660248383010111610262576104789160246105929201602435600435611576565b604051918291826103fd565b8015150361026257565b34610262576020600319360112610262576004356105c58161059e565b6105cd611425565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffffffff64ff0000000060045492151560201b16911617600455600080f35b3461026257600060031936011261026257602061ffff60025416604051908152f35b346102625760006003193601126102625760206040516001600160a01b037f000000000000000000000000a2574d9ddb6a325ad2be838bd854228b80215148168152f35b3461026257602080600319360112610262576001600160a01b0360043561069581610519565b61069d611425565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015291168282602481845afa9182156107855760009261078a575b50816106ea57005b61074f9183916107026000546001600160a01b031690565b60006040518096819582947fa9059cbb00000000000000000000000000000000000000000000000000000000845260048401602090939291936001600160a01b0360408201951681520152565b03925af180156107855761075f57005b8161001692903d1061077e575b6107768183610392565b810190611561565b503d61076c565b611546565b6107ab919250833d85116107b2575b6107a38183610392565b810190611552565b90386106e2565b503d610799565b346102625760006003193601126102625760206040516001600160a01b037f000000000000000000000000360ad4f9a9a8efe9a8dcb5f461c4cc1047e1dcf9168152f35b346102625760008060031936011261051657610817611425565b808080804781811561082f575b3390f1156107855780f35b506108fc610824565b346102625760006003193601126102625760206040516001600160a01b037f0000000000000000000000003d2bd0e15829aa5c362a4144fdf4a1112fa29b5c168152f35b6040519060e0820182811067ffffffffffffffff82111761033957604052565b604051906108a98261035a565b565b67ffffffffffffffff811161033957601f01601f191660200190565b9291926108d3826108ab565b916108e16040519384610392565b829481845281830111610262578281602093846000960137010152565b34610262576020806003193601126102625767ffffffffffffffff906004358281116102625736602382011215610262576109439036906024816004013591016108c7565b9161094c611425565b82519081116103395760019161096b8261096685546102d5565b6114d2565b80601f83116001146109aa5750819061099b939460009261099f575b50506000198260011b9260031b1c19161790565b9055005b015190503880610987565b90601f198316946109dd60016000527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf690565b926000905b878210610a17575050838596106109fe575b505050811b019055005b015160001960f88460031b161c191690553880806109f4565b8087859682949686015181550195019301906109e2565b346102625760008060031936011261051657610a48611425565b806001600160a01b03815473ffffffffffffffffffffffffffffffffffffffff1981168355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b346102625760006003193601126102625760206040516001600160a01b037f0000000000000000000000009918889e93e8c4357a2d4bce0965dcc493fffda8168152f35b3461026257606060031936011261026257600435600052600560205260406000206024356000526020526020610b276044356bffffffffffffffffffffffff600260406000200154166121e3565b604051908152f35b346102625760006003193601126102625760206001600160a01b0360005416604051908152f35b35906bffffffffffffffffffffffff8216820361026257565b34610262576040600319360112610262576004356bffffffffffffffffffffffff8116810361026257610b27602091602435906121e3565b3461026257602060031990808236011261026257600480359267ffffffffffffffff841161026257610120848301918536030112610262576001600160a01b0392837f000000000000000000000000a2574d9ddb6a325ad2be838bd854228b802151481633036111b657813584610c28826000526005602052604060002090565b94610c4a610c4560248a0135809890600052602052604060002090565b61176f565b95610c64610c5c6101048b01886117ae565b8101906117e1565b909816958815801561119f575b8015611188575b61115f5788610cdf9160a48c0190610c908282611807565b60009150156111575750610caa610cb692610cb092611807565b9061183d565b35612539565b898c610cd960648b610ccf85516001600160a01b031690565b94015192016117fd565b916122db565b91610d2660848b01978a610cf28a6117fd565b60409b8c01516bffffffffffffffffffffffff16926bffffffffffffffffffffffff610d1e84866121e3565b94169161232c565b93807f0000000000000000000000009918889e93e8c4357a2d4bce0965dcc493fffda8169089517f095ea7b3000000000000000000000000000000000000000000000000000000008152888180610d968a87898401602090939291936001600160a01b0360408201951681520152565b03816000867f0000000000000000000000003d2bd0e15829aa5c362a4144fdf4a1112fa29b5c165af180156107855761113a575b50825460035490610de9610de4610ddf611a5d565b611a92565b611bcc565b610df161087c565b63ffffffff83168152928b840152888d84015288606084015260808301528660a0830152610e1d61185c565b9a60c09b8c8401528c51937f3b6f743b0000000000000000000000000000000000000000000000000000000085528d8580610e5a878b8301611929565b0381895afa948515610785578e60009661110b575b505060ff600093610e7e61195f565b508d1c1615610f985750505091818a93610eca959351908d51968795869485937fc7c7f5b3000000000000000000000000000000000000000000000000000000008552309285016119e7565b03925af1908115610785576104789a610f32610f52977f68ae82f3369be05da0ae3b1c076eacccf981d7e837d84c6412e59f3ea88ef45b94604494610f609c600092610f6a575b5050955b8c5191825260208201529290910135604083015281906060820190565b0390a180519085015167ffffffffffffffff169187519889968701611a25565b03601f198101845283610392565b51918291826103fd565b610f899250803d10610f91575b610f818183610392565b810190611987565b503880610f11565b503d610f77565b90829f9a9c9592969493917f000000000000000000000000360ad4f9a9a8efe9a8dcb5f461c4cc1047e1dcf916610fdc610fd1836117fd565b865190309084611da1565b8451813b15611107578f517f2e1a7d4d0000000000000000000000000000000000000000000000000000000081528781019182529891899182908490829060200103925af1948515610785578e9787966110ee575b5061108261104f6110438751946117fd565b6001600160a01b031690565b9851988996879586947fc7c7f5b300000000000000000000000000000000000000000000000000000000865285016119e7565b03925af195861561078557610f32610f6099610f52987f68ae82f3369be05da0ae3b1c076eacccf981d7e837d84c6412e59f3ea88ef45b956104789f95604496926110d0575b505095610f15565b6110e69250803d10610f9157610f818183610392565b5038806110c8565b806110fb61110192610325565b806102ca565b38611031565b8880fd5b61112b929650803d10611133575b6111238183610392565b8101906118a8565b93388e610e6f565b503d611119565b61115090893d8b1161077e576107768183610392565b5038610dca565b915050610cb6565b826040517fb4fa3fb3000000000000000000000000000000000000000000000000000000008152fd5b5061119861104360648c016117fd565b8714610c78565b506111af61104360848c016117fd565b8714610c71565b826040517f9de97418000000000000000000000000000000000000000000000000000000008152fd5b346102625760006003193601126102625760206040516001600160a01b037f000000000000000000000000a2574d9ddb6a325ad2be838bd854228b80215148168152f35b346102625760406003193601126102625760043560005260056020526040600020602435600052602052606060406000206001600160a01b03815416906bffffffffffffffffffffffff60026001830154920154169060405192835260208301526040820152f35b34610262576020600319360112610262576112a4611425565b600435600355005b34610262576020600319360112610262576004356112c981610519565b6001600160a01b03806000541615908115916112ee575b50610262576100169061147d565b9050811615386112e0565b346102625760c06003193601126102625761047861136060405161131c8161033e565b60043561132881610519565b815260243561133681610519565b602082015260443560408201526064356060820152608435608082015260a43560a0820152612038565b60405191829182815181526020918201519181019190915260400190565b346102625760206003193601126102625760043561139b81610519565b6113a3611425565b6001600160a01b038116156113bb576100169061147d565b608460405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152fd5b6001600160a01b0360005416330361143957565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b600054906001600160a01b03809116918273ffffffffffffffffffffffffffffffffffffffff19821617600055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b90601f82116114df575050565b6001916000908382527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6906020601f850160051c8301941061153c575b601f0160051c01915b8281106115325750505050565b8181558301611525565b909250829061151c565b6040513d6000823e3d90fd5b90816020910312610262575190565b90816020910312610262575161040e8161059e565b6001600160a01b0393917f000000000000000000000000a2574d9ddb6a325ad2be838bd854228b8021514885163303611745576060848481010312610262578335916115c183610519565b6020850135956115d360408701610b56565b9316928315801561173d575b6117135761040e967fb02fc9d11ea117984ce645da380ae3dc69cfb90ba320e03d28428a987515776e946116dc6117099361164461161b61089c565b6001600160a01b038516815291602083018690526bffffffffffffffffffffffff166040830152565b61166b8761165c886000526005602052604060002090565b90600052602052604060002090565b604060026bffffffffffffffffffffffff926001600160a01b0385511673ffffffffffffffffffffffffffffffffffffffff198254161781556020850151600182015501920151167fffffffffffffffffffffffffffffffffffffffff000000000000000000000000825416179055565b60405194859485909493926001600160a01b03906060936080840197845260208401521660408201520152565b0390a136916108c7565b60046040517f48be0eb3000000000000000000000000000000000000000000000000000000008152fd5b5086156115df565b60046040517f9de97418000000000000000000000000000000000000000000000000000000008152fd5b9060405161177c8161035a565b60406bffffffffffffffffffffffff600283956001600160a01b03815416855260018101546020860152015416910152565b903590601e1981360301821215610262570180359067ffffffffffffffff82116102625760200191813603831361026257565b9190826040910312610262576020823592013561040e81610519565b3561040e81610519565b903590601e1981360301821215610262570180359067ffffffffffffffff821161026257602001918160051b3603831361026257565b90156118465790565b634e487b7160e01b600052603260045260246000fd5b604051906020820182811067ffffffffffffffff8211176103395760405260008252565b91908260409103126102625760405161189881610376565b6020808294805184520151910152565b906040828203126102625761040e91611880565b61040e9163ffffffff825116815260208201516020820152604082015160408201526060820151606082015260c0611918611906608085015160e0608086015260e08501906103d8565b60a085015184820360a08601526103d8565b9201519060c08184039101526103d8565b919060206119416000926040865260408601906118bc565b930152565b6040519061195382610376565b60006020838281520152565b6040519061196c8261035a565b8160008152600060208201526040611982611946565b910152565b919082810360c081126102625760801361026257604051906119a88261035a565b83518252602084015167ffffffffffffffff811681036102625782608091602061040e9501526119db8360408801611880565b60408201529401611880565b9193926001600160a01b0390611a1f611a0a6060946080875260808701906118bc565b96602086019060208091805184520151910152565b16910152565b9193611a4d60809497969567ffffffffffffffff93855260a0602086015260a08501906103d8565b9660408401521660608201520152565b6040517e0300000000000000000000000000000000000000000000000000000000000060208201526002815261040e81610376565b61ffff600381611aa184611fd1565b1603611bc157604051917207a12000000000000000000000000000000000602084015260108352611ad183610376565b600382611add83611fd1565b1603611b8657825191808311611b1c57611afe611b0e9161040e9416611c65565b9360405194859360208501611c7d565b03601f198101835282610392565b608460405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203160448201527f36206269747300000000000000000000000000000000000000000000000000006064820152fd5b90611b92602492611fd1565b6040517f3a51740d00000000000000000000000000000000000000000000000000000000815291166004820152fd5b611b92602492611fd1565b61ffff600381611bdb84611fd1565b1603611bc15760405191600060208401527207a12000000000000000000000000000000000602284015260128352611c1283610376565b600382611c1e83611fd1565b1603611b8657825191808311611b1c57611c3f611b0e9161040e9416611c65565b9360405194859360208501611d02565b634e487b7160e01b600052601160045260246000fd5b90600161ffff80931601918211611c7857565b611c4f565b602090611c946004959493828151948592016103b5565b01907fffff0000000000000000000000000000000000000000000000000000000000007f01000000000000000000000000000000000000000000000000000000000000009182845260f01b1660018301526003820152611cfd82518093602086850191016103b5565b010190565b60207fffff00000000000000000000000000000000000000000000000000000000000091611d3a6004969594828151948592016103b5565b01917f0100000000000000000000000000000000000000000000000000000000000000835260f01b1660018201527f03000000000000000000000000000000000000000000000000000000000000006003820152611cfd82518093602086850191016103b5565b9290604051927f23b872dd0000000000000000000000000000000000000000000000000000000060208501526001600160a01b03809216602485015216604483015260648201526064815260a081019181831067ffffffffffffffff841117610339576108a9926040525b604051611e89916001600160a01b0316611e2582610376565b6000806020958685527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656487860152868151910182855af13d15611f18573d91611e6d836108ab565b92611e7b6040519485610392565b83523d60008785013e611f1c565b80519081611e9657505050565b8280611ea6938301019101611561565b15611eae5750565b6084906040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152fd5b6060915b91929015611f7d5750815115611f30575090565b3b15611f395790565b606460405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152fd5b825190915015611f905750805190602001fd5b611fac9060405191829162461bcd60e51b8352600483016103fd565b0390fd5b906602c2ad68fd90008201809211611c7857565b91908201809211611c7857565b6002815110611fe1576002015190565b606460405162461bcd60e51b815260206004820152601460248201527f746f55696e7431365f6f75744f66426f756e64730000000000000000000000006044820152fd5b81810292918115918404141715611c7857565b612040611946565b506121776040826120e461207b610c4561206885809801516000526005602052604060002090565b6060850151600052602052604060002090565b916bffffffffffffffffffffffff6120db856120c76120a187516001600160a01b031690565b60806020890151966120ba81516001600160a01b031690565b91829101978851936122db565b9501516bffffffffffffffffffffffff1690565b91519116612025565b906120f460045463ffffffff1690565b9160035490612107610de4610ddf611a5d565b9161211f61211361087c565b63ffffffff9096168652565b602085015280858501526060840152608083015260a082015261214061185c565b60c08201528151809381927f3b6f743b00000000000000000000000000000000000000000000000000000000835260048301611929565b03816001600160a01b037f0000000000000000000000009918889e93e8c4357a2d4bce0965dcc493fffda8165afa918215610785576000926121b857505090565b61040e9250803d10611133576111238183610392565b90816020910312610262575161040e81610267565b6bffffffffffffffffffffffff61220e9116916122096122038285612025565b93611fb0565b612025565b9061271061ffff81612224826002541685612025565b0492604051917f29070c6d0000000000000000000000000000000000000000000000000000000083526020836004816001600160a01b037f000000000000000000000000a2574d9ddb6a325ad2be838bd854228b80215148165afa801561078557612299936000916122ad575b501690612025565b04908201809211611c785761040e91611fc4565b6122ce915060203d81116122d4575b6122c68183610392565b8101906121ce565b38612291565b503d6122bc565b909291604051946001600160a01b0394858094166020880152604087015260608601521660808401521660a082015260a0815261040e8161033e565b90816020910312610262575161040e81610519565b9291909361235e907f0000000000000000000000003d2bd0e15829aa5c362a4144fdf4a1112fa29b5c94309086611da1565b6123688282612025565b6001600160a01b0393847f000000000000000000000000a2574d9ddb6a325ad2be838bd854228b802151481695604051957f3b19e84a000000000000000000000000000000000000000000000000000000008752602080886004818c5afa978815610785576000986124ae575b50806004979899604051988980927f29070c6d0000000000000000000000000000000000000000000000000000000082525afa9889156107855761243d61243561ffff61040e9c6122099b61244496600092612491575b50501688612025565b612710900490565b90856124e2565b8116612453575b505050611fb0565b61248361247d6124356124899561247761247060025461ffff1690565b61ffff1690565b90612025565b60011c90565b916124e2565b38808061244b565b6124a79250803d106122d4576122c68183610392565b388061242c565b60049798506124d38291823d84116124db575b6124cb8183610392565b810190612317565b9897506123d5565b503d6124c1565b6040517fa9059cbb0000000000000000000000000000000000000000000000000000000060208201526001600160a01b03909216602483015260448201929092526108a9916125348260648101610f52565b611e0c565b604051907f6352211e00000000000000000000000000000000000000000000000000000000825260048201526020816024816001600160a01b037f000000000000000000000000a2574d9ddb6a325ad2be838bd854228b80215148165afa908115610785576000916125a9575090565b61040e915060203d81116124db576124cb818361039256fea2646970667358221220e02381a544fbdc6a9d771a833735093bfd29072819773da22681d815573b7d8764736f6c63430008150033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000a2574d9ddb6a325ad2be838bd854228b802151480000000000000000000000006edce65403992e310a62460808c4b910d972f10f0000000000000000000000003d2bd0e15829aa5c362a4144fdf4a1112fa29b5c0000000000000000000000009918889e93e8c4357a2d4bce0965dcc493fffda8000000000000000000000000360ad4f9a9a8efe9a8dcb5f461c4cc1047e1dcf9000000000000000000000000482107b5966178b595758069e80d7dd7f16526220000000000000000000000000000000000000000000000000000000000009d35
-----Decoded View---------------
Arg [0] : _hub (address): 0xA2574D9DdB6A325Ad2Be838Bd854228B80215148
Arg [1] : _lzEndpoint (address): 0x6EDCE65403992e310A62460808c4b910D972f10f
Arg [2] : _bonsai (address): 0x3d2bD0e15829AA5C362a4144FdF4A1112fa29B5c
Arg [3] : _bonsaiAdapter (address): 0x9918889E93e8c4357a2D4bCE0965dcC493FFFDA8
Arg [4] : _WMATIC (address): 0x360ad4f9a9A8EFe9A8DCB5f461c4Cc1047E1Dcf9
Arg [5] : _remoteZoraCreator (bytes32): 0x000000000000000000000000482107b5966178b595758069e80d7dd7f1652622
Arg [6] : _remoteEid (uint32): 40245
-----Encoded View---------------
7 Constructor Arguments found :
Arg [0] : 000000000000000000000000a2574d9ddb6a325ad2be838bd854228b80215148
Arg [1] : 0000000000000000000000006edce65403992e310a62460808c4b910d972f10f
Arg [2] : 0000000000000000000000003d2bd0e15829aa5c362a4144fdf4a1112fa29b5c
Arg [3] : 0000000000000000000000009918889e93e8c4357a2d4bce0965dcc493fffda8
Arg [4] : 000000000000000000000000360ad4f9a9a8efe9a8dcb5f461c4cc1047e1dcf9
Arg [5] : 000000000000000000000000482107b5966178b595758069e80d7dd7f1652622
Arg [6] : 0000000000000000000000000000000000000000000000000000000000009d35
Loading...
Loading
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.