¡El código fuente de este contrato está verificado!
Metadatos del Contrato
Compilador
0.8.23+commit.f704f362
Idioma
Solidity
Código Fuente del Contrato
Archivo 1 de 6: Context.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)pragmasolidity ^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.
*/abstractcontractContext{
function_msgSender() internalviewvirtualreturns (address) {
returnmsg.sender;
}
function_msgData() internalviewvirtualreturns (bytescalldata) {
returnmsg.data;
}
}
Código Fuente del Contrato
Archivo 2 de 6: EFPListRecords.sol
// SPDX-License-Identifier: UNLICENSEDpragmasolidity ^0.8.23;import {Ownable} from'lib/openzeppelin-contracts/contracts/access/Ownable.sol';
import {Pausable} from'lib/openzeppelin-contracts/contracts/security/Pausable.sol';
import {IEFPListMetadata, IEFPListRecords} from'./interfaces/IEFPListRecords.sol';
import {ENSReverseClaimer} from'./lib/ENSReverseClaimer.sol';
/**
* @title ListMetadata
* @author Cory Gabrielsen (cory.eth)
* @custom:contributor throw; (0xthrpw.eth)
* @custom:benediction DEVS BENEDICAT ET PROTEGAT CONTRACTVS MEAM
*
* @notice Manages key-value pairs associated with EFP List NFTs.
* Provides functionalities for list managers to set and retrieve metadata for their lists.
*/abstractcontractListMetadataisIEFPListMetadata, Pausable, Ownable{
errorSlotAlreadyClaimed(uint256 slot, address manager);
// error NotListManager(address manager);///////////////////////////////////////////////////////////////////////////// Data Structures////////////////////////////////////////////////////////////////////////////// @dev The key-value set for each token IDmapping(uint256=>mapping(string=>bytes)) private values;
/////////////////////////////////////////////////////////////////////////////// Pausable//////////////////////////////////////////////////////////////////////////////**
* @dev Pauses the contract. Can only be called by the contract owner.
*/functionpause() publiconlyOwner{
_pause();
}
/**
* @dev Unpauses the contract. Can only be called by the contract owner.
*/functionunpause() publiconlyOwner{
_unpause();
}
/////////////////////////////////////////////////////////////////////////////// Helpers/////////////////////////////////////////////////////////////////////////////functionbytesToAddress(bytesmemory b) internalpurereturns (address) {
require(b.length==20, 'Invalid length');
address addr;
assembly {
addr :=mload(add(b, 20))
}
return addr;
}
/////////////////////////////////////////////////////////////////////////////// Getters//////////////////////////////////////////////////////////////////////////////**
* @dev Retrieves metadata value for token ID and key.
* @param tokenId The token Id to query.
* @param key The key to query.
* @return The associated value.
*/functiongetMetadataValue(uint256 tokenId, stringcalldata key) externalviewreturns (bytesmemory) {
return values[tokenId][key];
}
/**
* @dev Retrieves metadata values for token ID and keys.
* @param tokenId The token Id to query.
* @param keys The keys to query.
* @return The associated values.
*/functiongetMetadataValues(uint256 tokenId, string[] calldata keys) externalviewreturns (bytes[] memory) {
uint256 length = keys.length;
bytes[] memory result =newbytes[](length);
for (uint256 i =0; i < length;) {
stringcalldata key = keys[i];
result[i] = values[tokenId][key];
unchecked {
++i;
}
}
return result;
}
/////////////////////////////////////////////////////////////////////////////// Setters//////////////////////////////////////////////////////////////////////////////**
* @dev Sets metadata records for token ID with the unique key key to value,
* overwriting anything previously stored for token ID and key. To clear a
* field, set it to the empty string.
* @param slot The slot corresponding to the list to update.
* @param key The key to set.
* @param value The value to set.
*/function_setMetadataValue(uint256 slot, stringmemory key, bytesmemory value) internal{
values[slot][key] = value;
emit UpdateListMetadata(slot, key, value);
}
/**
* @dev Sets metadata records for token ID with the unique key key to value,
* overwriting anything previously stored for token ID and key. To clear a
* field, set it to the empty string. Only callable by the list manager.
* @param slot The slot corresponding to the list to update.
* @param key The key to set.
* @param value The value to set.
*/functionsetMetadataValue(uint256 slot, stringcalldata key, bytescalldata value)
externalwhenNotPausedonlyListManager(slot)
{
_setMetadataValue(slot, key, value);
}
/**
* @dev Sets an array of metadata records for a token ID. Each record is a
* key/value pair.
* @param slot The slot corresponding to the list to update.
* @param records The records to set.
*/function_setMetadataValues(uint256 slot, KeyValue[] calldata records) internal{
uint256 length = records.length;
for (uint256 i =0; i < length;) {
KeyValue calldata record = records[i];
_setMetadataValue(slot, record.key, record.value);
unchecked {
++i;
}
}
}
/**
* @dev Sets an array of metadata records for a token ID. Each record is a
* key/value pair. Only callable by the list manager.
* @param slot The slot corresponding to the list to update.
* @param records The records to set.
*/functionsetMetadataValues(uint256 slot, KeyValue[] calldata records) externalwhenNotPausedonlyListManager(slot) {
_setMetadataValues(slot, records);
}
///////////////////////////////////////////////////////////////////////////// Modifiers////////////////////////////////////////////////////////////////////////////**
* @notice Ensures that the caller is the manager of the specified list.
* @param slot The unique identifier of the list.
* @dev Used to restrict function access to the list's manager.
*/modifieronlyListManager(uint256 slot) {
bytesmemory existing = values[slot]['manager'];
// if not set, claim for msg.senderif (existing.length!=20) {
_claimListManager(slot, msg.sender);
} else {
address existingManager = bytesToAddress(existing);
if (existingManager ==address(0)) {
_claimListManager(slot, msg.sender);
} else {
require(existingManager ==msg.sender, 'Not list manager');
}
}
_;
}
///////////////////////////////////////////////////////////////////////////// List Manager - Claim////////////////////////////////////////////////////////////////////////////**
* @notice Allows an address to claim management of an unclaimed list slot.
* @param slot The slot that the sender wishes to claim.
* @param manager The address to be set as the manager.
* @dev This function establishes the first-come-first-serve basis for slot claiming.
*/function_claimListManager(uint256 slot, address manager) internal{
bytesmemory existing = values[slot]['manager'];
// require(existing.length != 20 || bytesToAddress(existing) == manager, "slot already claimed");if (existing.length==20) {
address existingManager = bytesToAddress(existing);
if (existingManager != manager) {
revert SlotAlreadyClaimed(slot, existingManager);
}
}
_setMetadataValue(slot, 'manager', abi.encodePacked(manager));
}
/**
* @notice Allows the sender to claim management of an unclaimed list slot.
* @param slot The slot that the sender wishes to claim.
*/functionclaimListManager(uint256 slot) externalwhenNotPaused{
_claimListManager(slot, msg.sender);
}
/**
* @notice Allows the sender to transfer management of a list to a new address.
* @param slot The list's unique identifier.
* @param manager The address to be set as the new manager.
*/functionclaimListManagerForAddress(uint256 slot, address manager) externalwhenNotPaused{
_claimListManager(slot, manager);
}
///////////////////////////////////////////////////////////////////////////// List Manager - Read////////////////////////////////////////////////////////////////////////////**
* @notice Retrieves the address of the manager for a specified list slot.
* @param slot The list's unique identifier.
* @return The address of the manager.
*/functiongetListManager(uint256 slot) externalviewreturns (address) {
bytesmemory existing = values[slot]['manager'];
return existing.length!=20 ? address(0) : bytesToAddress(existing);
}
///////////////////////////////////////////////////////////////////////////// List Manager - Write////////////////////////////////////////////////////////////////////////////**
* @notice Allows the current manager to transfer management of a list to a new address.
* @param slot The list's unique identifier.
* @param manager The address to be set as the new manager.
* @dev Only the current manager can transfer their management role.
*/functionsetListManager(uint256 slot, address manager) externalwhenNotPausedonlyListManager(slot) {
_setMetadataValue(slot, 'manager', abi.encodePacked(manager));
}
///////////////////////////////////////////////////////////////////////////// List User - Read////////////////////////////////////////////////////////////////////////////**
* @notice Retrieves the address of the list user for a specified list
* slot.
* @param slot The list's unique identifier.
* @return The address of the list user.
*/functiongetListUser(uint256 slot) externalviewreturns (address) {
bytesmemory existing = values[slot]['user'];
return existing.length!=20 ? address(0) : bytesToAddress(existing);
}
///////////////////////////////////////////////////////////////////////////// List Manager - Write////////////////////////////////////////////////////////////////////////////**
* @notice Allows the current manager to change the list user to a new
* address.
* @param slot The list's unique identifier.
* @param user The address to be set as the new list user.
* @dev Only the current manager can change the list user.
*/functionsetListUser(uint256 slot, address user) externalwhenNotPausedonlyListManager(slot) {
_setMetadataValue(slot, 'user', abi.encodePacked(user));
}
}
/**
* @title EFPListRecords
* @notice Manages a dynamic list of records associated with EFP List NFTs.
* Provides functionalities for list managers to apply operations to their lists.
*/abstractcontractListRecordsisIEFPListRecords, ListMetadata{
///////////////////////////////////////////////////////////////////////////// Data Structures////////////////////////////////////////////////////////////////////////////// @notice Stores a sequence of operations for each list identified by its slot./// @dev Each list can have multiple operations performed over time.mapping(uint256=>bytes[]) public listOps;
///////////////////////////////////////////////////////////////////////////// List Operation Functions - Read////////////////////////////////////////////////////////////////////////////**
* @notice Retrieves the number of operations performed on a list.
* @param slot The list's unique identifier.
* @return The number of operations performed on the list.
*/functiongetListOpCount(uint256 slot) externalviewreturns (uint256) {
return listOps[slot].length;
}
/**
* @notice Retrieves the operation at a specified index for a list.
* @param slot The list's unique identifier.
* @param index The index of the operation to be retrieved.
* @return The operation at the specified index.
*/functiongetListOp(uint256 slot, uint256 index) externalviewreturns (bytesmemory) {
return listOps[slot][index];
}
/**
* @notice Retrieves a range of operations for a list.
* @param slot The list's unique identifier.
* @param start The starting index of the range.
* @param end The ending index of the range.
* @return The operations in the specified range.
*/functiongetListOpsInRange(uint256 slot, uint256 start, uint256 end) externalviewreturns (bytes[] memory) {
if (start > end) {
revert('Invalid range');
}
bytes[] memory ops =newbytes[](end - start);
for (uint256 i = start; i < end;) {
ops[i - start] = listOps[slot][i];
unchecked {
++i;
}
}
return ops;
}
/**
* @notice Retrieves all operations for a list.
* @param slot The list's unique identifier.
* @return The operations performed on the list.
*/functiongetAllListOps(uint256 slot) externalviewreturns (bytes[] memory) {
return listOps[slot];
}
///////////////////////////////////////////////////////////////////////////// List Operation Functions - Write////////////////////////////////////////////////////////////////////////////**
* @notice Applies a single operation to the list.
* @param slot The list's unique identifier.
* @param op The operation to be applied.
*/function_applyListOp(uint256 slot, bytescalldata op) internal{
listOps[slot].push(op);
emit ListOp(slot, op);
}
/**
* @notice Public wrapper for `_applyOp`, enabling list managers to apply a single operation.
* @param slot The list's unique identifier.
* @param op The operation to be applied.
*/functionapplyListOp(uint256 slot, bytescalldata op) externalwhenNotPausedonlyListManager(slot) {
_applyListOp(slot, op);
}
/**
* @notice Allows list managers to apply multiple operations in a single transaction.
* @param slot The list's unique identifier.
* @param ops An array of operations to be applied.
*/function_applyListOps(uint256 slot, bytes[] calldata ops) internal{
uint256 len = ops.length;
for (uint256 i =0; i < len;) {
_applyListOp(slot, ops[i]);
unchecked {
++i;
}
}
}
/**
* @notice Allows list managers to apply multiple operations in a single transaction.
* @param slot The list's unique identifier.
* @param ops An array of operations to be applied.
*/functionapplyListOps(uint256 slot, bytes[] calldata ops) externalwhenNotPausedonlyListManager(slot) {
_applyListOps(slot, ops);
}
/**
* @notice Allows list managers to set metadata values and apply list ops
* in a single transaction.
* @param slot The list's unique identifier.
* @param records An array of key-value pairs to set.
* @param ops An array of operations to be applied.
*/functionsetMetadataValuesAndApplyListOps(uint256 slot, KeyValue[] calldata records, bytes[] calldata ops)
externalwhenNotPausedonlyListManager(slot)
{
_setMetadataValues(slot, records);
_applyListOps(slot, ops);
}
}
contractEFPListRecordsisIEFPListRecords, ListRecords, ENSReverseClaimer{}
Código Fuente del Contrato
Archivo 3 de 6: ENSReverseClaimer.sol
//SPDX-License-Identifier: MITpragmasolidity ^0.8.23;import {Ownable} from'lib/openzeppelin-contracts/contracts/access/Ownable.sol';
interfaceENS{
/**
* @dev Returns the address that owns the specified node.
* @param node The specified node.
* @return address of the owner.
*/functionowner(bytes32 node) externalviewreturns (address);
}
interfaceIReverseRegistrar{
/**
* @dev Transfers ownership of the reverse ENS record associated with the
* calling account.
* @param owner The address to set as the owner of the reverse record in ENS.
* @return The ENS node hash of the reverse record.
*/functionclaim(address owner) externalreturns (bytes32);
/**
* @dev Sets the `name()` record for the reverse ENS record associated with
* the calling account. First updates the resolver to the default reverse
* resolver if necessary.
* @param name The name to set for this address.
* @return The ENS node hash of the reverse record.
*/functionsetName(stringmemory name) externalreturns (bytes32);
}
/**
* @title ENSReverseClaimer
* @dev This contract is used to claim reverse ENS records.
*/abstractcontractENSReverseClaimerisOwnable{
/// @dev The namehash of 'addr.reverse', the domain at which reverse records/// are stored in ENS.bytes32constant ADDR_REVERSE_NODE =0x91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e2;
/**
* @dev Transfers ownership of the reverse ENS record associated with the
* contract.
* @param ens The ENS registry.
* @param claimant The address to set as the owner of the reverse record in
* ENS.
* @return The ENS node hash of the reverse record.
*/functionclaimReverseENS(ENS ens, address claimant) externalonlyOwnerreturns (bytes32) {
return IReverseRegistrar(ens.owner(ADDR_REVERSE_NODE)).claim(claimant);
}
/**
* @dev Sets the reverse ENS record associated with the contract.
* @param ens The ENS registry.
* @param name The name to set as the reverse record in ENS.
* @return The ENS node hash of the reverse record.
*/functionsetReverseENS(ENS ens, stringcalldata name) externalonlyOwnerreturns (bytes32) {
return IReverseRegistrar(ens.owner(ADDR_REVERSE_NODE)).setName(name);
}
}
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)pragmasolidity ^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.
*/abstractcontractOwnableisContext{
addressprivate _owner;
eventOwnershipTransferred(addressindexed previousOwner, addressindexed 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.
*/modifieronlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/functionowner() publicviewvirtualreturns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/function_checkOwner() internalviewvirtual{
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/functionrenounceOwnership() publicvirtualonlyOwner{
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/functiontransferOwnership(address newOwner) publicvirtualonlyOwner{
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) internalvirtual{
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
Código Fuente del Contrato
Archivo 6 de 6: Pausable.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)pragmasolidity ^0.8.0;import"../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/abstractcontractPausableisContext{
/**
* @dev Emitted when the pause is triggered by `account`.
*/eventPaused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/eventUnpaused(address account);
boolprivate _paused;
/**
* @dev Initializes the contract in unpaused state.
*/constructor() {
_paused =false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/modifierwhenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/modifierwhenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/functionpaused() publicviewvirtualreturns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/function_requireNotPaused() internalviewvirtual{
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/function_requirePaused() internalviewvirtual{
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/function_pause() internalvirtualwhenNotPaused{
_paused =true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/function_unpause() internalvirtualwhenPaused{
_paused =false;
emit Unpaused(_msgSender());
}
}