ERC-721
Overview
Max Total Supply
1 GG
Holders
1
Total Transfers
-
Market
Volume (24H)
N/A
Min Price (24H)
N/A
Max Price (24H)
N/A
Other Info
Token Contract
Loading...
Loading
Loading...
Loading
Loading...
Loading
Minimal Proxy Contract for 0x75d2ea122cc20b6e661775ac18fff0b4547b9fe6
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0xb834BBe1...14458Eb47 The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
OpenEdition721Mint
Compiler Version
v0.8.22+commit.4fc1097e
Optimization Enabled:
Yes with 100 runs
Other Settings:
shanghai EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.22; import {ERC721} from "solmate/tokens/ERC721.sol"; import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import {Ownable2StepUpgradeable} from "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol"; import {CollectionCreationRequest} from "../interfaces/ISharedConstructs.sol"; import "../interfaces/IErrors.sol"; import {IMintFactory, IMint, Royalty, MintingFee} from "../interfaces/IMintFactory.sol"; import {MintUtil} from "../../utils/MintUtil.sol"; /* ████████╗ ██████╗ ██╗ ██╗███████╗███╗ ██╗███████╗ ██████╗ ██████╗ ██████╗ ███████╗ ╚══██╔══╝██╔═══██╗██║ ██╔╝██╔════╝████╗ ██║██╔════╝██╔═══██╗██╔══██╗██╔════╝ ██╔════╝ ██║ ██║ ██║█████╔╝ █████╗ ██╔██╗ ██║█████╗ ██║ ██║██████╔╝██║ ███╗█████╗ ██║ ██║ ██║██╔═██╗ ██╔══╝ ██║╚██╗██║██╔══╝ ██║ ██║██╔══██╗██║ ██║██╔══╝ ██║ ╚██████╔╝██║ ██╗███████╗██║ ╚████║██║ ╚██████╔╝██║ ██║╚██████╔╝███████╗ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ */ /// @title Open Edition 721 NFT Collection /// @dev NFT Collection which supports an Open Edition style with shared metadata between all tokens. /// @author Coinbase - @polak.eth contract OpenEdition721Mint is IMint, ERC721("", ""), Initializable, Ownable2StepUpgradeable, ReentrancyGuardUpgradeable { /// @dev Current Token Id matches the token id type of Solmate uint256 public currentTokenId; /// @dev Metadata for the minting contract CollectionCreationRequest public metadata; /// @dev Mint Factory reference for fees address public mintingContract; /// @dev MintConfigChanged is required for Reservoir Minting ingestion /// @notice See Reference: https://github.com/reservoirprotocol/indexer/tree/main/packages/mint-interface event MintConfigChanged(); /// @dev Withdrawn is emitted if an owner has withdrawn an accidental funds transfer to the contract. event Withdrawn(address indexed owner, uint256 amount); /// @dev CommentEvent is emitted when a creator or minter attaches a comment with their mint. event TokenForgeMintComment(address indexed to, uint256 quantity, string comment); /// @dev Event emitted when a token forge mint occurs event TokenForgeMint(address indexed to, uint256 quantity); /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); // disabled initializers so they cannot be called again. } /// @dev Initializer which creates a new NFT collection based on the request. /// @notice This is Initializable because we are using clones to create. function initialize(CollectionCreationRequest memory request, address mintingContract_) public initializer { if (mintingContract_ == address(0)) { revert IErrors.InvalidContractAddress(); } // Make sure the creator gets ownership of the contract __Ownable2Step_init(); _transferOwnership(request.creator); __ReentrancyGuard_init(); // Set super params name = request.name; symbol = request.symbol; // Contract Params _setMetadata(request); metadata.mintType = request.mintType; //Only allowed to set on init mintingContract = mintingContract_; currentTokenId = 1; // Set current to 1 so the first NFT is #1 and not #0 emit MintConfigChanged(); } /** * ------------ External ------------ */ // @dev standard mint function function mint(address to, uint256 quantity) external payable nonReentrant { if (quantity == 0) { revert IErrors.InvalidMintQuantity(); } // Check we don't exceed max supply, add one since we start at tokenId = 1. if (currentTokenId + quantity > metadata.maxSupply + 1) { revert IErrors.OutOfSupply(); } // Check the mint has started or ended. if (metadata.startTime > 0 && metadata.startTime > block.timestamp) { revert IErrors.MintingNotStarted(); } if (metadata.endTime > 0 && metadata.endTime < block.timestamp) { revert IErrors.MintingClosed(); } // Check if we are over wallet limits if (balanceOf(to) + quantity > metadata.maxPerWallet) { revert IErrors.OverClaimLimit(); } // Check the correct amount of ETH sent. uint256 creatorFee; uint256 platformFee; address platformFeeAddr; (creatorFee, platformFee, platformFeeAddr) = _getFees(quantity); // Verify the exact amount, don't want to deal with refunding ETH. if (msg.value != creatorFee + platformFee) { revert IErrors.IncorrectETHAmount(msg.value, creatorFee + platformFee); } // Increment OE for (uint64 i = 0; i < quantity; i++) { _safeMint(to, currentTokenId++); } uint256 paid = 0; paid += platformFee; // Pay Platform Fee (bool payPlatformFee,) = platformFeeAddr.call{value: platformFee}(""); if (!payPlatformFee) { revert IErrors.FailedToSendEth(); } // Pay Creator Royalties for (uint256 i = 0; i < metadata.royalties.length; i++) { Royalty memory royalty = metadata.royalties[i]; uint256 royaltyAmount = quantity * royalty.amt; paid += royaltyAmount; (bool payRoyaltyResult,) = royalty.to.call{value: royaltyAmount}(""); if (!payRoyaltyResult) { revert IErrors.FailedToSendEth(); } } if (paid != creatorFee + platformFee) { revert IErrors.IncorrectETHAmount(paid, creatorFee + platformFee); } emit TokenForgeMint(to, quantity); } function mintWithComment(address to, uint256 quantity, string calldata comment) external payable { this.mint{value: msg.value}(to, quantity); if (bytes(comment).length > 0) { emit TokenForgeMintComment(to, quantity, comment); } } /// @dev Allows an owner to extract a eth balance from the contract. function withdraw() external onlyOwner { uint256 balance = address(this).balance; (bool payOwnerResult,) = owner().call{value: balance}(""); if (!payOwnerResult) { revert IErrors.FailedToSendEth(); } emit Withdrawn(owner(), balance); } /// @dev Allows an owner to update the metadata of the collection. /// @notice This will allow and owner to change claim conditions owners should burn collections that should not change. function setMetadata(CollectionCreationRequest memory metadata_) external onlyOwner { _setMetadata(metadata_); emit MintConfigChanged(); } function contractURI() external view returns (string memory) { uint256 creatorFee; uint256 platformFee; (creatorFee, platformFee,) = _getFees(1); return MintUtil.contractURI(metadata, creatorFee + platformFee, true); } /// @dev get the total minted quantity. /// @notice have to offset because we are starting at #1 vs #0 function totalSupply() external view returns (uint256) { return currentTokenId - 1; } /** * ------------ Public ------------ */ function tokenURI(uint256 tokenId) public view override(ERC721) returns (string memory) { if (tokenId > currentTokenId || tokenId == 0) { revert IErrors.TokenDoesNotExist({tokenId: tokenId}); } return MintUtil.getOpenEditionUri(metadata, tokenId, true); } function getMetadata() public view returns (CollectionCreationRequest memory) { return metadata; } /// @dev Gets the total cost to mint this collection. /// @notice We call the mint factory to determine platform costs. function cost(uint256 quantity) public view returns (uint256) { uint256 creatorFee; uint256 platformFee; (creatorFee, platformFee,) = _getFees(quantity); return creatorFee + platformFee; } /** * ------------ Internal ------------ */ /// @dev Gets the fees for this collection. /// @notice We call the mint factory to determine platform costs. function _getFees(uint256 quantity) internal view returns (uint256, uint256, address) { IMintFactory mintFactory = IMintFactory(mintingContract); MintingFee memory mintingFee = mintFactory.getMintingFee(address(this)); uint256 creatorFee = (metadata.cost * quantity); uint256 platformFee = mintingFee.fee * quantity; return (creatorFee, platformFee, mintingFee.addr); } function _setMetadata(CollectionCreationRequest memory metadata_) internal { MintUtil.validateCollectionCreationRequest(metadata_); // Manually copy simple fields metadata.creator = metadata_.creator; metadata.name = metadata_.name; metadata.description = metadata_.description; metadata.symbol = metadata_.symbol; metadata.image = metadata_.image; metadata.animation_url = metadata_.animation_url; metadata.maxSupply = metadata_.maxSupply; metadata.maxPerWallet = metadata_.maxPerWallet; metadata.cost = metadata_.cost; metadata.startTime = metadata_.startTime; metadata.endTime = metadata_.endTime; // Make sure to remove old royalties delete metadata.royalties; // Manually copy array fields for (uint256 i = 0; i < metadata_.royalties.length; i++) { metadata.royalties.push(Royalty({to: metadata_.royalties[i].to, amt: metadata_.royalties[i].amt})); } } }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; /// @notice Modern, minimalist, and gas efficient ERC-721 implementation. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC721.sol) abstract contract ERC721 { /*////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event Transfer(address indexed from, address indexed to, uint256 indexed id); event Approval(address indexed owner, address indexed spender, uint256 indexed id); event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /*////////////////////////////////////////////////////////////// METADATA STORAGE/LOGIC //////////////////////////////////////////////////////////////*/ string public name; string public symbol; function tokenURI(uint256 id) public view virtual returns (string memory); /*////////////////////////////////////////////////////////////// ERC721 BALANCE/OWNER STORAGE //////////////////////////////////////////////////////////////*/ mapping(uint256 => address) internal _ownerOf; mapping(address => uint256) internal _balanceOf; function ownerOf(uint256 id) public view virtual returns (address owner) { require((owner = _ownerOf[id]) != address(0), "NOT_MINTED"); } function balanceOf(address owner) public view virtual returns (uint256) { require(owner != address(0), "ZERO_ADDRESS"); return _balanceOf[owner]; } /*////////////////////////////////////////////////////////////// ERC721 APPROVAL STORAGE //////////////////////////////////////////////////////////////*/ mapping(uint256 => address) public getApproved; mapping(address => mapping(address => bool)) public isApprovedForAll; /*////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ constructor(string memory _name, string memory _symbol) { name = _name; symbol = _symbol; } /*////////////////////////////////////////////////////////////// ERC721 LOGIC //////////////////////////////////////////////////////////////*/ function approve(address spender, uint256 id) public virtual { address owner = _ownerOf[id]; require(msg.sender == owner || isApprovedForAll[owner][msg.sender], "NOT_AUTHORIZED"); getApproved[id] = spender; emit Approval(owner, spender, id); } function setApprovalForAll(address operator, bool approved) public virtual { isApprovedForAll[msg.sender][operator] = approved; emit ApprovalForAll(msg.sender, operator, approved); } function transferFrom( address from, address to, uint256 id ) public virtual { require(from == _ownerOf[id], "WRONG_FROM"); require(to != address(0), "INVALID_RECIPIENT"); require( msg.sender == from || isApprovedForAll[from][msg.sender] || msg.sender == getApproved[id], "NOT_AUTHORIZED" ); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. unchecked { _balanceOf[from]--; _balanceOf[to]++; } _ownerOf[id] = to; delete getApproved[id]; emit Transfer(from, to, id); } function safeTransferFrom( address from, address to, uint256 id ) public virtual { transferFrom(from, to, id); require( to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT" ); } function safeTransferFrom( address from, address to, uint256 id, bytes calldata data ) public virtual { transferFrom(from, to, id); require( to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT" ); } /*////////////////////////////////////////////////////////////// ERC165 LOGIC //////////////////////////////////////////////////////////////*/ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165 interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721 interfaceId == 0x5b5e139f; // ERC165 Interface ID for ERC721Metadata } /*////////////////////////////////////////////////////////////// INTERNAL MINT/BURN LOGIC //////////////////////////////////////////////////////////////*/ function _mint(address to, uint256 id) internal virtual { require(to != address(0), "INVALID_RECIPIENT"); require(_ownerOf[id] == address(0), "ALREADY_MINTED"); // Counter overflow is incredibly unrealistic. unchecked { _balanceOf[to]++; } _ownerOf[id] = to; emit Transfer(address(0), to, id); } function _burn(uint256 id) internal virtual { address owner = _ownerOf[id]; require(owner != address(0), "NOT_MINTED"); // Ownership check above ensures no underflow. unchecked { _balanceOf[owner]--; } delete _ownerOf[id]; delete getApproved[id]; emit Transfer(owner, address(0), id); } /*////////////////////////////////////////////////////////////// INTERNAL SAFE MINT LOGIC //////////////////////////////////////////////////////////////*/ function _safeMint(address to, uint256 id) internal virtual { _mint(to, id); require( to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, address(0), id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT" ); } function _safeMint( address to, uint256 id, bytes memory data ) internal virtual { _mint(to, id); require( to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, address(0), id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT" ); } } /// @notice A generic interface for a contract which properly accepts ERC721 tokens. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC721.sol) abstract contract ERC721TokenReceiver { function onERC721Received( address, address, uint256, bytes calldata ) external virtual returns (bytes4) { return ERC721TokenReceiver.onERC721Received.selector; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.20; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Storage of the initializable contract. * * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions * when using with upgradeable contracts. * * @custom:storage-location erc7201:openzeppelin.storage.Initializable */ struct InitializableStorage { /** * @dev Indicates that the contract has been initialized. */ uint64 _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool _initializing; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00; /** * @dev The contract is already initialized. */ error InvalidInitialization(); /** * @dev The contract is not initializing. */ error NotInitializing(); /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint64 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in * production. * * Emits an {Initialized} event. */ modifier initializer() { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); // Cache values to avoid duplicated sloads bool isTopLevelCall = !$._initializing; uint64 initialized = $._initialized; // Allowed calls: // - initialSetup: the contract is not in the initializing state and no previous version was // initialized // - construction: the contract is initialized at version 1 (no reininitialization) and the // current contract is just being deployed bool initialSetup = initialized == 0 && isTopLevelCall; bool construction = initialized == 1 && address(this).code.length == 0; if (!initialSetup && !construction) { revert InvalidInitialization(); } $._initialized = 1; if (isTopLevelCall) { $._initializing = true; } _; if (isTopLevelCall) { $._initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint64 version) { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing || $._initialized >= version) { revert InvalidInitialization(); } $._initialized = version; $._initializing = true; _; $._initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { _checkInitializing(); _; } /** * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}. */ function _checkInitializing() internal view virtual { if (!_isInitializing()) { revert NotInitializing(); } } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing) { revert InvalidInitialization(); } if ($._initialized != type(uint64).max) { $._initialized = type(uint64).max; emit Initialized(type(uint64).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint64) { return _getInitializableStorage()._initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _getInitializableStorage()._initializing; } /** * @dev Returns a pointer to the storage namespace. */ // solhint-disable-next-line var-name-mixedcase function _getInitializableStorage() private pure returns (InitializableStorage storage $) { assembly { $.slot := INITIALIZABLE_STORAGE } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable2Step.sol) pragma solidity ^0.8.20; import {OwnableUpgradeable} from "./OwnableUpgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is specified at deployment time in the constructor for `Ownable`. This * can later be changed with {transferOwnership} and {acceptOwnership}. * * This module is used through inheritance. It will make available all functions * from parent (Ownable). */ abstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable { /// @custom:storage-location erc7201:openzeppelin.storage.Ownable2Step struct Ownable2StepStorage { address _pendingOwner; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable2Step")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant Ownable2StepStorageLocation = 0x237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c00; function _getOwnable2StepStorage() private pure returns (Ownable2StepStorage storage $) { assembly { $.slot := Ownable2StepStorageLocation } } event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner); function __Ownable2Step_init() internal onlyInitializing { } function __Ownable2Step_init_unchained() internal onlyInitializing { } /** * @dev Returns the address of the pending owner. */ function pendingOwner() public view virtual returns (address) { Ownable2StepStorage storage $ = _getOwnable2StepStorage(); return $._pendingOwner; } /** * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual override onlyOwner { Ownable2StepStorage storage $ = _getOwnable2StepStorage(); $._pendingOwner = newOwner; emit OwnershipTransferStarted(owner(), newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner. * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual override { Ownable2StepStorage storage $ = _getOwnable2StepStorage(); delete $._pendingOwner; super._transferOwnership(newOwner); } /** * @dev The new owner accepts the ownership transfer. */ function acceptOwnership() public virtual { address sender = _msgSender(); if (pendingOwner() != sender) { revert OwnableUnauthorizedAccount(sender); } _transferOwnership(sender); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol) pragma solidity ^0.8.20; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant NOT_ENTERED = 1; uint256 private constant ENTERED = 2; /// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard struct ReentrancyGuardStorage { uint256 _status; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00; function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) { assembly { $.slot := ReentrancyGuardStorageLocation } } /** * @dev Unauthorized reentrant call. */ error ReentrancyGuardReentrantCall(); function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); $._status = NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); // On the first call to nonReentrant, _status will be NOT_ENTERED if ($._status == ENTERED) { revert ReentrancyGuardReentrantCall(); } // Any calls to nonReentrant after this point will fail $._status = ENTERED; } function _nonReentrantAfter() private { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) $._status = NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); return $._status == ENTERED; } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.22; /// @dev Minting Fee for a given contract struct MintingFee { bool hasOverride; address addr; uint256 fee; } struct Royalty { address to; uint256 amt; // amt in ETH } /// @dev Collection request struct which defines a common set of fields needed to create a new NFT collection. struct CollectionCreationRequest { address creator; // Collection Information string name; string description; string symbol; string image; string animation_url; string mintType; //TODO: support collection attributes? // Claim Conditions uint128 maxSupply; uint128 maxPerWallet; uint256 cost; // Start + End Dates uint256 startTime; uint256 endTime; // royalties Royalty[] royalties; uint256 nonce; // Nonce added to support duplicate generations }
pragma solidity ^0.8.22; /// @dev library of common errors across our Mint + Factory contracts library IErrors { // Factory Errors error InvalidSignature(); error SignatureInvalidated(); error SignatureUsed(); error InvalidMintType(); error InvalidZeroAddress(); error InvalidContractAddress(); error NotCollectionCreator(); error CreationFailed(); error ContractExists(); // Minting Errors error IncorrectETHAmount(uint256 sent, uint256 expected); error TokenDoesNotExist(uint256 tokenId); error OutOfSupply(); error FailedToSendEth(); error MintingNotStarted(); error MintingClosed(); error OverClaimLimit(); error InvalidMintQuantity(); }
pragma solidity ^0.8.22; import "./ISharedConstructs.sol"; /// @dev Shared interface for the Mint factory. interface IMintFactory { function getMintingFee(address addr) external view returns (MintingFee memory); } /// @dev Shared interface for all Mints. interface IMint { function mint(address to, uint256 quantity) external payable; function mintWithComment(address to, uint256 quantity, string calldata comment) external payable; function initialize(CollectionCreationRequest memory request, address _mintingContract) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.22; import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts/utils/Base64.sol"; import "../tokenforge/interfaces/ISharedConstructs.sol"; import "./Json.sol"; import {Solarray} from "solarray/Solarray.sol"; /// @title Generic Mint utility for common uses across many different mint types. /// @author polak.eth library MintUtil { error InvalidCollectionRequest(string message); function contractURI(CollectionCreationRequest memory metadata, uint256 cost, bool encode) internal pure returns (string memory) { string memory jsonMetadata = Json.objectOf( Solarray.strings( Json.property("name", metadata.name), Json.property("description", metadata.description), Json.property("symbol", metadata.symbol), Json.property("image", metadata.image), Json.property("animation_url", metadata.animation_url), Json.rawProperty("mintConfig", _mintConfig(metadata, cost)) ) ); if (encode) { return encodeJsonToBase64(jsonMetadata); } else { return jsonMetadata; } } /// @dev MintConfig as defined by Reservoirs standard /// @notice See Reference: https://github.com/reservoirprotocol/indexer/tree/main/packages/mint-interface function _mintConfig(CollectionCreationRequest memory metadata, uint256 cost) internal pure returns (string memory) { // Construct the mintConfig JSON return Json.objectOf( Solarray.strings( Json.property("maxSupply", Strings.toString(metadata.maxSupply)), Json.rawProperty("phases", Json.array(_encodePhases(metadata, cost))) ) ); } /// @dev Formats for an OpenEdition which is an auto-incrementing name (e.g. NFT #1, NFT #2 ...). function getOpenEditionUri(CollectionCreationRequest memory metadata, uint256 tokenId, bool encode) internal pure returns (string memory) { // Generates a name with edition .. e.g. NFT => NFT #1029 string memory nameWithTokenId = string(abi.encodePacked(metadata.name, " #", Strings.toString(tokenId))); string memory jsonMetadata = Json.objectOf( Solarray.strings( Json.property("name", nameWithTokenId), Json.property("description", metadata.description), Json.property("symbol", metadata.symbol), Json.property("image", metadata.image), Json.property("animation_url", metadata.animation_url) ) ); if (encode) { return encodeJsonToBase64(jsonMetadata); } else { return jsonMetadata; } } /// @dev Phases are required for the Reservoir minting integration. Reservoir will read this configuration /// from the ContractURI() function. function _encodePhases(CollectionCreationRequest memory metadata, uint256 cost) internal pure returns (string memory) { string memory maxPerWalletStr = Strings.toString(metadata.maxPerWallet); string memory addrParam = '{"name": "recipient","abiType": "address","kind": "RECIPIENT"}'; string memory qtyParam = '{"name": "quantity", "abiType": "uint256", "kind": "QUANTITY"}'; // Params used to call the mint function string memory params = string(abi.encodePacked(addrParam, ",", qtyParam)); // Define the method that needs to be called string memory txnData = Json.objectOf( Solarray.strings(Json.property("method", "0x40c10f19"), Json.rawProperty("params", Json.array(params))) ); // Mint phases (we only support one phase right now) return Json.objectOf( Solarray.strings( Json.property("maxMintsPerWallet", maxPerWalletStr), Json.property("startTime", Strings.toString(metadata.startTime)), Json.property("endTime", Strings.toString(metadata.endTime)), Json.property("price", Strings.toString(cost)), Json.rawProperty("tx", txnData) ) ); } function encodeJsonToBase64(string memory str) internal pure returns (string memory) { return string.concat("data:application/json;base64,", Base64.encode(abi.encodePacked(str))); } /// @dev Validates the CollectionCreationRequest for common logical errors. /// @param metadata The collection creation request to validate. function validateCollectionCreationRequest(CollectionCreationRequest memory metadata) internal pure { // Check start and end times if (metadata.startTime > metadata.endTime && metadata.endTime != 0) { revert InvalidCollectionRequest("End time must be greater than or equal to start time."); } // Check that royalty amounts add up to mint cost. uint256 totalAmt = 0; for (uint256 i = 0; i < metadata.royalties.length; i++) { if (metadata.royalties[i].to == address(0)) { revert InvalidCollectionRequest("Invalid Address"); } totalAmt += metadata.royalties[i].amt; } if (totalAmt != metadata.cost) { revert InvalidCollectionRequest("Total royalties must equal cost"); } if (metadata.royalties.length > 5) { revert InvalidCollectionRequest("Cannot have more than 5 royalty addresses"); } // Check for valid max supply and per wallet limits if (metadata.maxSupply == 0) { revert InvalidCollectionRequest("Max supply must be greater than zero."); } if (metadata.maxPerWallet == 0) { revert InvalidCollectionRequest("Max per wallet must be greater than zero."); } // Check for non-empty essential strings if (isEmptyString(metadata.name) || isEmptyString(metadata.symbol)) { revert InvalidCollectionRequest("Name & symbol cannot be empty."); } if (isEmptyString(metadata.image) && isEmptyString(metadata.animation_url)) { revert InvalidCollectionRequest("Must have an image or animation_url."); } } /// @dev Helper function to check if a string is empty. /// @param value The string to check. /// @return bool Whether the string is empty. function isEmptyString(string memory value) internal pure returns (bool) { return bytes(value).length == 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.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. * * The initial owner is set to the address provided by the deployer. 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 OwnableUpgradeable is Initializable, ContextUpgradeable { /// @custom:storage-location erc7201:openzeppelin.storage.Ownable struct OwnableStorage { address _owner; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300; function _getOwnableStorage() private pure returns (OwnableStorage storage $) { assembly { $.slot := OwnableStorageLocation } } /** * @dev The caller account is not authorized to perform an operation. */ error OwnableUnauthorizedAccount(address account); /** * @dev The owner is not a valid owner account. (eg. `address(0)`) */ error OwnableInvalidOwner(address owner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the address provided by the deployer as the initial owner. */ function __Ownable_init(address initialOwner) internal onlyInitializing { __Ownable_init_unchained(initialOwner); } function __Ownable_init_unchained(address initialOwner) internal onlyInitializing { if (initialOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(initialOwner); } /** * @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) { OwnableStorage storage $ = _getOwnableStorage(); return $._owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { if (owner() != _msgSender()) { revert OwnableUnauthorizedAccount(_msgSender()); } } /** * @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. */ 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 { if (newOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { OwnableStorage storage $ = _getOwnableStorage(); address oldOwner = $._owner; $._owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol) pragma solidity ^0.8.20; import {Math} from "./math/Math.sol"; import {SignedMath} from "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant HEX_DIGITS = "0123456789abcdef"; uint8 private constant ADDRESS_LENGTH = 20; /** * @dev The `value` string doesn't fit in the specified `length`. */ error StringsInsufficientHexLength(uint256 value, uint256 length); /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), HEX_DIGITS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toStringSigned(int256 value) internal pure returns (string memory) { return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { uint256 localValue = value; bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = HEX_DIGITS[localValue & 0xf]; localValue >>= 4; } if (localValue != 0) { revert StringsInsufficientHexLength(value, length); } return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal * representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.2) (utils/Base64.sol) pragma solidity ^0.8.20; /** * @dev Provides a set of functions to operate with Base64 strings. */ library Base64 { /** * @dev Base64 Encoding/Decoding Table */ string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /** * @dev Converts a `bytes` to its Bytes64 `string` representation. */ function encode(bytes memory data) internal pure returns (string memory) { /** * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol */ if (data.length == 0) return ""; // Loads the table into memory string memory table = _TABLE; // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter // and split into 4 numbers of 6 bits. // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up // - `data.length + 2` -> Round up // - `/ 3` -> Number of 3-bytes chunks // - `4 *` -> 4 characters for each chunk string memory result = new string(4 * ((data.length + 2) / 3)); /// @solidity memory-safe-assembly assembly { // Prepare the lookup table (skip the first "length" byte) let tablePtr := add(table, 1) // Prepare result pointer, jump over length let resultPtr := add(result, 0x20) let dataPtr := data let endPtr := add(data, mload(data)) // In some cases, the last iteration will read bytes after the end of the data. We cache the value, and // set it to zero to make sure no dirty bytes are read in that section. let afterPtr := add(endPtr, 0x20) let afterCache := mload(afterPtr) mstore(afterPtr, 0x00) // Run over the input, 3 bytes at a time for { } lt(dataPtr, endPtr) { } { // Advance 3 bytes dataPtr := add(dataPtr, 3) let input := mload(dataPtr) // To write each character, shift the 3 byte (24 bits) chunk // 4 times in blocks of 6 bits for each character (18, 12, 6, 0) // and apply logical AND with 0x3F to bitmask the least significant 6 bits. // Use this as an index into the lookup table, mload an entire word // so the desired character is in the least significant byte, and // mstore8 this least significant byte into the result and continue. mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F)))) resultPtr := add(resultPtr, 1) // Advance mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F)))) resultPtr := add(resultPtr, 1) // Advance mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F)))) resultPtr := add(resultPtr, 1) // Advance mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F)))) resultPtr := add(resultPtr, 1) // Advance } // Reset the value that was cached mstore(afterPtr, afterCache) // When data `bytes` is not exactly 3 bytes long // it is padded with `=` characters at the end switch mod(mload(data), 3) case 1 { mstore8(sub(resultPtr, 1), 0x3d) mstore8(sub(resultPtr, 2), 0x3d) } case 2 { mstore8(sub(resultPtr, 1), 0x3d) } } return result; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.22; import {LibString} from "solmate/utils/LibString.sol"; /** * Credit goes to emo.eth / OpenSea, extracted portions of their JSON library for building the OpenEdition * JSON metadata. * ref: https://github.com/ProjectOpenSea/shipyard-core/blob/main/src/onchain/json.sol */ /** * @title JSON * @author emo.eth * @notice TODO: overrides for common types that automatically stringify */ library Json { string private constant NULL = ""; using LibString for string; /** * @notice enclose a string in {braces} * Note: does not escape quotes in value * @param value string to enclose in braces * @return string of {value} */ function object(string memory value) internal pure returns (string memory) { return string.concat("{", value, "}"); } /** * @notice enclose a string in [brackets] * Note: does not escape quotes in value * @param value string to enclose in brackets * @return string of [value] */ function array(string memory value) internal pure returns (string memory) { return string.concat("[", value, "]"); } /** * @notice enclose name and value with quotes, and place a colon "between":"them". * Note: escapes quotes in name and value * @param name name of property * @param value value of property * @return string of "name":"value" */ function property(string memory name, string memory value) internal pure returns (string memory) { return string.concat('"', escapeJSON(name, false), '":"', escapeJSON(value, false), '"'); } function intProperty(string memory name, string memory value) internal pure returns (string memory) { return string.concat('"', escapeJSON(name, false), '":', escapeJSON(value, false), ""); } /** * @notice enclose name with quotes, but not rawValue, and place a colon "between":them * Note: escapes quotes in name, but not value (which may itself be a JSON object, array, etc) * @param name name of property * @param rawValue raw value of property, which will not be enclosed in quotes * @return string of "name":value */ function rawProperty(string memory name, string memory rawValue) internal pure returns (string memory) { return string.concat('"', escapeJSON(name, false), '":', rawValue); } /** * @notice comma-join an array of properties and {"enclose":"them","in":"braces"} * Note: does not escape quotes in properties, as it assumes they are already escaped * @param properties array of '"name":"value"' properties to join * @return string of {"name":"value","name":"value",...} */ function objectOf(string[] memory properties) internal pure returns (string memory) { return object(_commaJoin(properties)); } /** * @notice comma-join an array of strings * @param values array of strings to join * @return string of value,value,... */ function _commaJoin(string[] memory values) internal pure returns (string memory) { return _join(values, ","); } /** * @notice join an array of strings with a specified separator * @param values array of strings to join * @param separator separator to join with * @return string of value<separator>value<separator>... */ function _join(string[] memory values, string memory separator) internal pure returns (string memory) { if (values.length == 0) { return NULL; } string memory result = values[0]; for (uint256 i = 1; i < values.length; ++i) { result = string.concat(result, separator, values[i]); } return result; } /** * @dev Extracted from solady/utils/LibString.sol */ function escapeJSON(string memory s, bool addDoubleQuotes) internal pure returns (string memory result) { /// @solidity memory-safe-assembly assembly { let end := add(s, mload(s)) result := add(mload(0x40), 0x20) if addDoubleQuotes { mstore8(result, 34) result := add(1, result) } // Store "\\u0000" in scratch space. // Store "0123456789abcdef" in scratch space. // Also, store `{0x08:"b", 0x09:"t", 0x0a:"n", 0x0c:"f", 0x0d:"r"}`. // into the scratch space. mstore(0x15, 0x5c75303030303031323334353637383961626364656662746e006672) // Bitmask for detecting `["\"","\\"]`. let e := or(shl(0x22, 1), shl(0x5c, 1)) for {} iszero(eq(s, end)) {} { s := add(s, 1) let c := and(mload(s), 0xff) if iszero(lt(c, 0x20)) { if iszero(and(shl(c, 1), e)) { // Not in `["\"","\\"]`. mstore8(result, c) result := add(result, 1) continue } mstore8(result, 0x5c) // "\\". mstore8(add(result, 1), c) result := add(result, 2) continue } if iszero(and(shl(c, 1), 0x3700)) { // Not in `["\b","\t","\n","\f","\d"]`. mstore8(0x1d, mload(shr(4, c))) // Hex value. mstore8(0x1e, mload(and(c, 15))) // Hex value. mstore(result, mload(0x19)) // "\\u00XX". result := add(result, 6) continue } mstore8(result, 0x5c) // "\\". mstore8(add(result, 1), mload(add(c, 8))) result := add(result, 2) } if addDoubleQuotes { mstore8(result, 34) result := add(1, result) } let last := result mstore(last, 0) // Zeroize the slot after the string. result := mload(0x40) mstore(result, sub(last, add(result, 0x20))) // Store the length. mstore(0x40, add(last, 0x20)) // Allocate the memory. } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.9.0; library Solarray { function uint8s(uint8 a) internal pure returns (uint8[] memory) { uint8[] memory arr = new uint8[](1); arr[0] = a; return arr; } function uint8s(uint8 a,uint8 b) internal pure returns (uint8[] memory) { uint8[] memory arr = new uint8[](2); arr[0] = a; arr[1] = b; return arr; } function uint8s(uint8 a,uint8 b,uint8 c) internal pure returns (uint8[] memory) { uint8[] memory arr = new uint8[](3); arr[0] = a; arr[1] = b; arr[2] = c; return arr; } function uint8s(uint8 a,uint8 b,uint8 c,uint8 d) internal pure returns (uint8[] memory) { uint8[] memory arr = new uint8[](4); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; return arr; } function uint8s(uint8 a,uint8 b,uint8 c,uint8 d,uint8 e) internal pure returns (uint8[] memory) { uint8[] memory arr = new uint8[](5); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; return arr; } function uint8s(uint8 a,uint8 b,uint8 c,uint8 d,uint8 e,uint8 f) internal pure returns (uint8[] memory) { uint8[] memory arr = new uint8[](6); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; return arr; } function uint8s(uint8 a,uint8 b,uint8 c,uint8 d,uint8 e,uint8 f,uint8 g) internal pure returns (uint8[] memory) { uint8[] memory arr = new uint8[](7); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; arr[6] = g; return arr; } function uint16s(uint16 a) internal pure returns (uint16[] memory) { uint16[] memory arr = new uint16[](1); arr[0] = a; return arr; } function uint16s(uint16 a,uint16 b) internal pure returns (uint16[] memory) { uint16[] memory arr = new uint16[](2); arr[0] = a; arr[1] = b; return arr; } function uint16s(uint16 a,uint16 b,uint16 c) internal pure returns (uint16[] memory) { uint16[] memory arr = new uint16[](3); arr[0] = a; arr[1] = b; arr[2] = c; return arr; } function uint16s(uint16 a,uint16 b,uint16 c,uint16 d) internal pure returns (uint16[] memory) { uint16[] memory arr = new uint16[](4); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; return arr; } function uint16s(uint16 a,uint16 b,uint16 c,uint16 d,uint16 e) internal pure returns (uint16[] memory) { uint16[] memory arr = new uint16[](5); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; return arr; } function uint16s(uint16 a,uint16 b,uint16 c,uint16 d,uint16 e,uint16 f) internal pure returns (uint16[] memory) { uint16[] memory arr = new uint16[](6); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; return arr; } function uint16s(uint16 a,uint16 b,uint16 c,uint16 d,uint16 e,uint16 f,uint16 g) internal pure returns (uint16[] memory) { uint16[] memory arr = new uint16[](7); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; arr[6] = g; return arr; } function uint32s(uint32 a) internal pure returns (uint32[] memory) { uint32[] memory arr = new uint32[](1); arr[0] = a; return arr; } function uint32s(uint32 a,uint32 b) internal pure returns (uint32[] memory) { uint32[] memory arr = new uint32[](2); arr[0] = a; arr[1] = b; return arr; } function uint32s(uint32 a,uint32 b,uint32 c) internal pure returns (uint32[] memory) { uint32[] memory arr = new uint32[](3); arr[0] = a; arr[1] = b; arr[2] = c; return arr; } function uint32s(uint32 a,uint32 b,uint32 c,uint32 d) internal pure returns (uint32[] memory) { uint32[] memory arr = new uint32[](4); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; return arr; } function uint32s(uint32 a,uint32 b,uint32 c,uint32 d,uint32 e) internal pure returns (uint32[] memory) { uint32[] memory arr = new uint32[](5); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; return arr; } function uint32s(uint32 a,uint32 b,uint32 c,uint32 d,uint32 e,uint32 f) internal pure returns (uint32[] memory) { uint32[] memory arr = new uint32[](6); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; return arr; } function uint32s(uint32 a,uint32 b,uint32 c,uint32 d,uint32 e,uint32 f,uint32 g) internal pure returns (uint32[] memory) { uint32[] memory arr = new uint32[](7); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; arr[6] = g; return arr; } function uint40s(uint40 a) internal pure returns (uint40[] memory) { uint40[] memory arr = new uint40[](1); arr[0] = a; return arr; } function uint40s(uint40 a,uint40 b) internal pure returns (uint40[] memory) { uint40[] memory arr = new uint40[](2); arr[0] = a; arr[1] = b; return arr; } function uint40s(uint40 a,uint40 b,uint40 c) internal pure returns (uint40[] memory) { uint40[] memory arr = new uint40[](3); arr[0] = a; arr[1] = b; arr[2] = c; return arr; } function uint40s(uint40 a,uint40 b,uint40 c,uint40 d) internal pure returns (uint40[] memory) { uint40[] memory arr = new uint40[](4); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; return arr; } function uint40s(uint40 a,uint40 b,uint40 c,uint40 d,uint40 e) internal pure returns (uint40[] memory) { uint40[] memory arr = new uint40[](5); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; return arr; } function uint40s(uint40 a,uint40 b,uint40 c,uint40 d,uint40 e,uint40 f) internal pure returns (uint40[] memory) { uint40[] memory arr = new uint40[](6); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; return arr; } function uint40s(uint40 a,uint40 b,uint40 c,uint40 d,uint40 e,uint40 f,uint40 g) internal pure returns (uint40[] memory) { uint40[] memory arr = new uint40[](7); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; arr[6] = g; return arr; } function uint64s(uint64 a) internal pure returns (uint64[] memory) { uint64[] memory arr = new uint64[](1); arr[0] = a; return arr; } function uint64s(uint64 a,uint64 b) internal pure returns (uint64[] memory) { uint64[] memory arr = new uint64[](2); arr[0] = a; arr[1] = b; return arr; } function uint64s(uint64 a,uint64 b,uint64 c) internal pure returns (uint64[] memory) { uint64[] memory arr = new uint64[](3); arr[0] = a; arr[1] = b; arr[2] = c; return arr; } function uint64s(uint64 a,uint64 b,uint64 c,uint64 d) internal pure returns (uint64[] memory) { uint64[] memory arr = new uint64[](4); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; return arr; } function uint64s(uint64 a,uint64 b,uint64 c,uint64 d,uint64 e) internal pure returns (uint64[] memory) { uint64[] memory arr = new uint64[](5); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; return arr; } function uint64s(uint64 a,uint64 b,uint64 c,uint64 d,uint64 e,uint64 f) internal pure returns (uint64[] memory) { uint64[] memory arr = new uint64[](6); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; return arr; } function uint64s(uint64 a,uint64 b,uint64 c,uint64 d,uint64 e,uint64 f,uint64 g) internal pure returns (uint64[] memory) { uint64[] memory arr = new uint64[](7); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; arr[6] = g; return arr; } function uint128s(uint128 a) internal pure returns (uint128[] memory) { uint128[] memory arr = new uint128[](1); arr[0] = a; return arr; } function uint128s(uint128 a,uint128 b) internal pure returns (uint128[] memory) { uint128[] memory arr = new uint128[](2); arr[0] = a; arr[1] = b; return arr; } function uint128s(uint128 a,uint128 b,uint128 c) internal pure returns (uint128[] memory) { uint128[] memory arr = new uint128[](3); arr[0] = a; arr[1] = b; arr[2] = c; return arr; } function uint128s(uint128 a,uint128 b,uint128 c,uint128 d) internal pure returns (uint128[] memory) { uint128[] memory arr = new uint128[](4); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; return arr; } function uint128s(uint128 a,uint128 b,uint128 c,uint128 d,uint128 e) internal pure returns (uint128[] memory) { uint128[] memory arr = new uint128[](5); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; return arr; } function uint128s(uint128 a,uint128 b,uint128 c,uint128 d,uint128 e,uint128 f) internal pure returns (uint128[] memory) { uint128[] memory arr = new uint128[](6); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; return arr; } function uint128s(uint128 a,uint128 b,uint128 c,uint128 d,uint128 e,uint128 f,uint128 g) internal pure returns (uint128[] memory) { uint128[] memory arr = new uint128[](7); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; arr[6] = g; return arr; } function uint256s(uint256 a) internal pure returns (uint256[] memory) { uint256[] memory arr = new uint256[](1); arr[0] = a; return arr; } function uint256s(uint256 a,uint256 b) internal pure returns (uint256[] memory) { uint256[] memory arr = new uint256[](2); arr[0] = a; arr[1] = b; return arr; } function uint256s(uint256 a,uint256 b,uint256 c) internal pure returns (uint256[] memory) { uint256[] memory arr = new uint256[](3); arr[0] = a; arr[1] = b; arr[2] = c; return arr; } function uint256s(uint256 a,uint256 b,uint256 c,uint256 d) internal pure returns (uint256[] memory) { uint256[] memory arr = new uint256[](4); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; return arr; } function uint256s(uint256 a,uint256 b,uint256 c,uint256 d,uint256 e) internal pure returns (uint256[] memory) { uint256[] memory arr = new uint256[](5); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; return arr; } function uint256s(uint256 a,uint256 b,uint256 c,uint256 d,uint256 e,uint256 f) internal pure returns (uint256[] memory) { uint256[] memory arr = new uint256[](6); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; return arr; } function uint256s(uint256 a,uint256 b,uint256 c,uint256 d,uint256 e,uint256 f,uint256 g) internal pure returns (uint256[] memory) { uint256[] memory arr = new uint256[](7); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; arr[6] = g; return arr; } function int8s(int8 a) internal pure returns (int8[] memory) { int8[] memory arr = new int8[](1); arr[0] = a; return arr; } function int8s(int8 a,int8 b) internal pure returns (int8[] memory) { int8[] memory arr = new int8[](2); arr[0] = a; arr[1] = b; return arr; } function int8s(int8 a,int8 b,int8 c) internal pure returns (int8[] memory) { int8[] memory arr = new int8[](3); arr[0] = a; arr[1] = b; arr[2] = c; return arr; } function int8s(int8 a,int8 b,int8 c,int8 d) internal pure returns (int8[] memory) { int8[] memory arr = new int8[](4); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; return arr; } function int8s(int8 a,int8 b,int8 c,int8 d,int8 e) internal pure returns (int8[] memory) { int8[] memory arr = new int8[](5); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; return arr; } function int8s(int8 a,int8 b,int8 c,int8 d,int8 e,int8 f) internal pure returns (int8[] memory) { int8[] memory arr = new int8[](6); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; return arr; } function int8s(int8 a,int8 b,int8 c,int8 d,int8 e,int8 f,int8 g) internal pure returns (int8[] memory) { int8[] memory arr = new int8[](7); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; arr[6] = g; return arr; } function int16s(int16 a) internal pure returns (int16[] memory) { int16[] memory arr = new int16[](1); arr[0] = a; return arr; } function int16s(int16 a,int16 b) internal pure returns (int16[] memory) { int16[] memory arr = new int16[](2); arr[0] = a; arr[1] = b; return arr; } function int16s(int16 a,int16 b,int16 c) internal pure returns (int16[] memory) { int16[] memory arr = new int16[](3); arr[0] = a; arr[1] = b; arr[2] = c; return arr; } function int16s(int16 a,int16 b,int16 c,int16 d) internal pure returns (int16[] memory) { int16[] memory arr = new int16[](4); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; return arr; } function int16s(int16 a,int16 b,int16 c,int16 d,int16 e) internal pure returns (int16[] memory) { int16[] memory arr = new int16[](5); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; return arr; } function int16s(int16 a,int16 b,int16 c,int16 d,int16 e,int16 f) internal pure returns (int16[] memory) { int16[] memory arr = new int16[](6); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; return arr; } function int16s(int16 a,int16 b,int16 c,int16 d,int16 e,int16 f,int16 g) internal pure returns (int16[] memory) { int16[] memory arr = new int16[](7); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; arr[6] = g; return arr; } function int32s(int32 a) internal pure returns (int32[] memory) { int32[] memory arr = new int32[](1); arr[0] = a; return arr; } function int32s(int32 a,int32 b) internal pure returns (int32[] memory) { int32[] memory arr = new int32[](2); arr[0] = a; arr[1] = b; return arr; } function int32s(int32 a,int32 b,int32 c) internal pure returns (int32[] memory) { int32[] memory arr = new int32[](3); arr[0] = a; arr[1] = b; arr[2] = c; return arr; } function int32s(int32 a,int32 b,int32 c,int32 d) internal pure returns (int32[] memory) { int32[] memory arr = new int32[](4); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; return arr; } function int32s(int32 a,int32 b,int32 c,int32 d,int32 e) internal pure returns (int32[] memory) { int32[] memory arr = new int32[](5); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; return arr; } function int32s(int32 a,int32 b,int32 c,int32 d,int32 e,int32 f) internal pure returns (int32[] memory) { int32[] memory arr = new int32[](6); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; return arr; } function int32s(int32 a,int32 b,int32 c,int32 d,int32 e,int32 f,int32 g) internal pure returns (int32[] memory) { int32[] memory arr = new int32[](7); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; arr[6] = g; return arr; } function int64s(int64 a) internal pure returns (int64[] memory) { int64[] memory arr = new int64[](1); arr[0] = a; return arr; } function int64s(int64 a,int64 b) internal pure returns (int64[] memory) { int64[] memory arr = new int64[](2); arr[0] = a; arr[1] = b; return arr; } function int64s(int64 a,int64 b,int64 c) internal pure returns (int64[] memory) { int64[] memory arr = new int64[](3); arr[0] = a; arr[1] = b; arr[2] = c; return arr; } function int64s(int64 a,int64 b,int64 c,int64 d) internal pure returns (int64[] memory) { int64[] memory arr = new int64[](4); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; return arr; } function int64s(int64 a,int64 b,int64 c,int64 d,int64 e) internal pure returns (int64[] memory) { int64[] memory arr = new int64[](5); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; return arr; } function int64s(int64 a,int64 b,int64 c,int64 d,int64 e,int64 f) internal pure returns (int64[] memory) { int64[] memory arr = new int64[](6); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; return arr; } function int64s(int64 a,int64 b,int64 c,int64 d,int64 e,int64 f,int64 g) internal pure returns (int64[] memory) { int64[] memory arr = new int64[](7); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; arr[6] = g; return arr; } function int128s(int128 a) internal pure returns (int128[] memory) { int128[] memory arr = new int128[](1); arr[0] = a; return arr; } function int128s(int128 a,int128 b) internal pure returns (int128[] memory) { int128[] memory arr = new int128[](2); arr[0] = a; arr[1] = b; return arr; } function int128s(int128 a,int128 b,int128 c) internal pure returns (int128[] memory) { int128[] memory arr = new int128[](3); arr[0] = a; arr[1] = b; arr[2] = c; return arr; } function int128s(int128 a,int128 b,int128 c,int128 d) internal pure returns (int128[] memory) { int128[] memory arr = new int128[](4); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; return arr; } function int128s(int128 a,int128 b,int128 c,int128 d,int128 e) internal pure returns (int128[] memory) { int128[] memory arr = new int128[](5); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; return arr; } function int128s(int128 a,int128 b,int128 c,int128 d,int128 e,int128 f) internal pure returns (int128[] memory) { int128[] memory arr = new int128[](6); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; return arr; } function int128s(int128 a,int128 b,int128 c,int128 d,int128 e,int128 f,int128 g) internal pure returns (int128[] memory) { int128[] memory arr = new int128[](7); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; arr[6] = g; return arr; } function int256s(int256 a) internal pure returns (int256[] memory) { int256[] memory arr = new int256[](1); arr[0] = a; return arr; } function int256s(int256 a,int256 b) internal pure returns (int256[] memory) { int256[] memory arr = new int256[](2); arr[0] = a; arr[1] = b; return arr; } function int256s(int256 a,int256 b,int256 c) internal pure returns (int256[] memory) { int256[] memory arr = new int256[](3); arr[0] = a; arr[1] = b; arr[2] = c; return arr; } function int256s(int256 a,int256 b,int256 c,int256 d) internal pure returns (int256[] memory) { int256[] memory arr = new int256[](4); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; return arr; } function int256s(int256 a,int256 b,int256 c,int256 d,int256 e) internal pure returns (int256[] memory) { int256[] memory arr = new int256[](5); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; return arr; } function int256s(int256 a,int256 b,int256 c,int256 d,int256 e,int256 f) internal pure returns (int256[] memory) { int256[] memory arr = new int256[](6); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; return arr; } function int256s(int256 a,int256 b,int256 c,int256 d,int256 e,int256 f,int256 g) internal pure returns (int256[] memory) { int256[] memory arr = new int256[](7); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; arr[6] = g; return arr; } function bytes1s(bytes1 a) internal pure returns (bytes1[] memory) { bytes1[] memory arr = new bytes1[](1); arr[0] = a; return arr; } function bytes1s(bytes1 a,bytes1 b) internal pure returns (bytes1[] memory) { bytes1[] memory arr = new bytes1[](2); arr[0] = a; arr[1] = b; return arr; } function bytes1s(bytes1 a,bytes1 b,bytes1 c) internal pure returns (bytes1[] memory) { bytes1[] memory arr = new bytes1[](3); arr[0] = a; arr[1] = b; arr[2] = c; return arr; } function bytes1s(bytes1 a,bytes1 b,bytes1 c,bytes1 d) internal pure returns (bytes1[] memory) { bytes1[] memory arr = new bytes1[](4); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; return arr; } function bytes1s(bytes1 a,bytes1 b,bytes1 c,bytes1 d,bytes1 e) internal pure returns (bytes1[] memory) { bytes1[] memory arr = new bytes1[](5); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; return arr; } function bytes1s(bytes1 a,bytes1 b,bytes1 c,bytes1 d,bytes1 e,bytes1 f) internal pure returns (bytes1[] memory) { bytes1[] memory arr = new bytes1[](6); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; return arr; } function bytes1s(bytes1 a,bytes1 b,bytes1 c,bytes1 d,bytes1 e,bytes1 f,bytes1 g) internal pure returns (bytes1[] memory) { bytes1[] memory arr = new bytes1[](7); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; arr[6] = g; return arr; } function bytes8s(bytes8 a) internal pure returns (bytes8[] memory) { bytes8[] memory arr = new bytes8[](1); arr[0] = a; return arr; } function bytes8s(bytes8 a,bytes8 b) internal pure returns (bytes8[] memory) { bytes8[] memory arr = new bytes8[](2); arr[0] = a; arr[1] = b; return arr; } function bytes8s(bytes8 a,bytes8 b,bytes8 c) internal pure returns (bytes8[] memory) { bytes8[] memory arr = new bytes8[](3); arr[0] = a; arr[1] = b; arr[2] = c; return arr; } function bytes8s(bytes8 a,bytes8 b,bytes8 c,bytes8 d) internal pure returns (bytes8[] memory) { bytes8[] memory arr = new bytes8[](4); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; return arr; } function bytes8s(bytes8 a,bytes8 b,bytes8 c,bytes8 d,bytes8 e) internal pure returns (bytes8[] memory) { bytes8[] memory arr = new bytes8[](5); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; return arr; } function bytes8s(bytes8 a,bytes8 b,bytes8 c,bytes8 d,bytes8 e,bytes8 f) internal pure returns (bytes8[] memory) { bytes8[] memory arr = new bytes8[](6); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; return arr; } function bytes8s(bytes8 a,bytes8 b,bytes8 c,bytes8 d,bytes8 e,bytes8 f,bytes8 g) internal pure returns (bytes8[] memory) { bytes8[] memory arr = new bytes8[](7); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; arr[6] = g; return arr; } function bytes16s(bytes16 a) internal pure returns (bytes16[] memory) { bytes16[] memory arr = new bytes16[](1); arr[0] = a; return arr; } function bytes16s(bytes16 a,bytes16 b) internal pure returns (bytes16[] memory) { bytes16[] memory arr = new bytes16[](2); arr[0] = a; arr[1] = b; return arr; } function bytes16s(bytes16 a,bytes16 b,bytes16 c) internal pure returns (bytes16[] memory) { bytes16[] memory arr = new bytes16[](3); arr[0] = a; arr[1] = b; arr[2] = c; return arr; } function bytes16s(bytes16 a,bytes16 b,bytes16 c,bytes16 d) internal pure returns (bytes16[] memory) { bytes16[] memory arr = new bytes16[](4); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; return arr; } function bytes16s(bytes16 a,bytes16 b,bytes16 c,bytes16 d,bytes16 e) internal pure returns (bytes16[] memory) { bytes16[] memory arr = new bytes16[](5); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; return arr; } function bytes16s(bytes16 a,bytes16 b,bytes16 c,bytes16 d,bytes16 e,bytes16 f) internal pure returns (bytes16[] memory) { bytes16[] memory arr = new bytes16[](6); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; return arr; } function bytes16s(bytes16 a,bytes16 b,bytes16 c,bytes16 d,bytes16 e,bytes16 f,bytes16 g) internal pure returns (bytes16[] memory) { bytes16[] memory arr = new bytes16[](7); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; arr[6] = g; return arr; } function bytes20s(bytes20 a) internal pure returns (bytes20[] memory) { bytes20[] memory arr = new bytes20[](1); arr[0] = a; return arr; } function bytes20s(bytes20 a,bytes20 b) internal pure returns (bytes20[] memory) { bytes20[] memory arr = new bytes20[](2); arr[0] = a; arr[1] = b; return arr; } function bytes20s(bytes20 a,bytes20 b,bytes20 c) internal pure returns (bytes20[] memory) { bytes20[] memory arr = new bytes20[](3); arr[0] = a; arr[1] = b; arr[2] = c; return arr; } function bytes20s(bytes20 a,bytes20 b,bytes20 c,bytes20 d) internal pure returns (bytes20[] memory) { bytes20[] memory arr = new bytes20[](4); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; return arr; } function bytes20s(bytes20 a,bytes20 b,bytes20 c,bytes20 d,bytes20 e) internal pure returns (bytes20[] memory) { bytes20[] memory arr = new bytes20[](5); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; return arr; } function bytes20s(bytes20 a,bytes20 b,bytes20 c,bytes20 d,bytes20 e,bytes20 f) internal pure returns (bytes20[] memory) { bytes20[] memory arr = new bytes20[](6); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; return arr; } function bytes20s(bytes20 a,bytes20 b,bytes20 c,bytes20 d,bytes20 e,bytes20 f,bytes20 g) internal pure returns (bytes20[] memory) { bytes20[] memory arr = new bytes20[](7); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; arr[6] = g; return arr; } function bytes32s(bytes32 a) internal pure returns (bytes32[] memory) { bytes32[] memory arr = new bytes32[](1); arr[0] = a; return arr; } function bytes32s(bytes32 a,bytes32 b) internal pure returns (bytes32[] memory) { bytes32[] memory arr = new bytes32[](2); arr[0] = a; arr[1] = b; return arr; } function bytes32s(bytes32 a,bytes32 b,bytes32 c) internal pure returns (bytes32[] memory) { bytes32[] memory arr = new bytes32[](3); arr[0] = a; arr[1] = b; arr[2] = c; return arr; } function bytes32s(bytes32 a,bytes32 b,bytes32 c,bytes32 d) internal pure returns (bytes32[] memory) { bytes32[] memory arr = new bytes32[](4); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; return arr; } function bytes32s(bytes32 a,bytes32 b,bytes32 c,bytes32 d,bytes32 e) internal pure returns (bytes32[] memory) { bytes32[] memory arr = new bytes32[](5); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; return arr; } function bytes32s(bytes32 a,bytes32 b,bytes32 c,bytes32 d,bytes32 e,bytes32 f) internal pure returns (bytes32[] memory) { bytes32[] memory arr = new bytes32[](6); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; return arr; } function bytes32s(bytes32 a,bytes32 b,bytes32 c,bytes32 d,bytes32 e,bytes32 f,bytes32 g) internal pure returns (bytes32[] memory) { bytes32[] memory arr = new bytes32[](7); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; arr[6] = g; return arr; } function bytess(bytes memory a) internal pure returns (bytes[] memory) { bytes[] memory arr = new bytes[](1); arr[0] = a; return arr; } function bytess(bytes memory a,bytes memory b) internal pure returns (bytes[] memory) { bytes[] memory arr = new bytes[](2); arr[0] = a; arr[1] = b; return arr; } function bytess(bytes memory a,bytes memory b,bytes memory c) internal pure returns (bytes[] memory) { bytes[] memory arr = new bytes[](3); arr[0] = a; arr[1] = b; arr[2] = c; return arr; } function bytess(bytes memory a,bytes memory b,bytes memory c,bytes memory d) internal pure returns (bytes[] memory) { bytes[] memory arr = new bytes[](4); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; return arr; } function bytess(bytes memory a,bytes memory b,bytes memory c,bytes memory d,bytes memory e) internal pure returns (bytes[] memory) { bytes[] memory arr = new bytes[](5); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; return arr; } function bytess(bytes memory a,bytes memory b,bytes memory c,bytes memory d,bytes memory e,bytes memory f) internal pure returns (bytes[] memory) { bytes[] memory arr = new bytes[](6); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; return arr; } function bytess(bytes memory a,bytes memory b,bytes memory c,bytes memory d,bytes memory e,bytes memory f,bytes memory g) internal pure returns (bytes[] memory) { bytes[] memory arr = new bytes[](7); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; arr[6] = g; return arr; } function addresses(address a) internal pure returns (address[] memory) { address[] memory arr = new address[](1); arr[0] = a; return arr; } function addresses(address a,address b) internal pure returns (address[] memory) { address[] memory arr = new address[](2); arr[0] = a; arr[1] = b; return arr; } function addresses(address a,address b,address c) internal pure returns (address[] memory) { address[] memory arr = new address[](3); arr[0] = a; arr[1] = b; arr[2] = c; return arr; } function addresses(address a,address b,address c,address d) internal pure returns (address[] memory) { address[] memory arr = new address[](4); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; return arr; } function addresses(address a,address b,address c,address d,address e) internal pure returns (address[] memory) { address[] memory arr = new address[](5); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; return arr; } function addresses(address a,address b,address c,address d,address e,address f) internal pure returns (address[] memory) { address[] memory arr = new address[](6); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; return arr; } function addresses(address a,address b,address c,address d,address e,address f,address g) internal pure returns (address[] memory) { address[] memory arr = new address[](7); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; arr[6] = g; return arr; } function bools(bool a) internal pure returns (bool[] memory) { bool[] memory arr = new bool[](1); arr[0] = a; return arr; } function bools(bool a,bool b) internal pure returns (bool[] memory) { bool[] memory arr = new bool[](2); arr[0] = a; arr[1] = b; return arr; } function bools(bool a,bool b,bool c) internal pure returns (bool[] memory) { bool[] memory arr = new bool[](3); arr[0] = a; arr[1] = b; arr[2] = c; return arr; } function bools(bool a,bool b,bool c,bool d) internal pure returns (bool[] memory) { bool[] memory arr = new bool[](4); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; return arr; } function bools(bool a,bool b,bool c,bool d,bool e) internal pure returns (bool[] memory) { bool[] memory arr = new bool[](5); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; return arr; } function bools(bool a,bool b,bool c,bool d,bool e,bool f) internal pure returns (bool[] memory) { bool[] memory arr = new bool[](6); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; return arr; } function bools(bool a,bool b,bool c,bool d,bool e,bool f,bool g) internal pure returns (bool[] memory) { bool[] memory arr = new bool[](7); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; arr[6] = g; return arr; } function strings(string memory a) internal pure returns (string[] memory) { string[] memory arr = new string[](1); arr[0] = a; return arr; } function strings(string memory a,string memory b) internal pure returns (string[] memory) { string[] memory arr = new string[](2); arr[0] = a; arr[1] = b; return arr; } function strings(string memory a,string memory b,string memory c) internal pure returns (string[] memory) { string[] memory arr = new string[](3); arr[0] = a; arr[1] = b; arr[2] = c; return arr; } function strings(string memory a,string memory b,string memory c,string memory d) internal pure returns (string[] memory) { string[] memory arr = new string[](4); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; return arr; } function strings(string memory a,string memory b,string memory c,string memory d,string memory e) internal pure returns (string[] memory) { string[] memory arr = new string[](5); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; return arr; } function strings(string memory a,string memory b,string memory c,string memory d,string memory e,string memory f) internal pure returns (string[] memory) { string[] memory arr = new string[](6); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; return arr; } function strings(string memory a,string memory b,string memory c,string memory d,string memory e,string memory f,string memory g) internal pure returns (string[] memory) { string[] memory arr = new string[](7); arr[0] = a; arr[1] = b; arr[2] = c; arr[3] = d; arr[4] = e; arr[5] = f; arr[6] = g; return arr; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @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 ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol) pragma solidity ^0.8.20; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Muldiv operation overflow. */ error MathOverflowedMulDiv(); enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an overflow flag. */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. return a / b; } // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by * Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. if (denominator <= prod1) { revert MathOverflowedMulDiv(); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. // Always >= 1. See https://cs.stackexchange.com/q/138556/92363. uint256 twos = denominator & (0 - denominator); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also // works in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.20; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; /// @notice Efficient library for creating string representations of integers. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/LibString.sol) /// @author Modified from Solady (https://github.com/Vectorized/solady/blob/main/src/utils/LibString.sol) library LibString { function toString(int256 value) internal pure returns (string memory str) { if (value >= 0) return toString(uint256(value)); unchecked { str = toString(uint256(-value)); /// @solidity memory-safe-assembly assembly { // Note: This is only safe because we over-allocate memory // and write the string from right to left in toString(uint256), // and thus can be sure that sub(str, 1) is an unused memory location. let length := mload(str) // Load the string length. // Put the - character at the start of the string contents. mstore(str, 45) // 45 is the ASCII code for the - character. str := sub(str, 1) // Move back the string pointer by a byte. mstore(str, add(length, 1)) // Update the string length. } } } function toString(uint256 value) internal pure returns (string memory str) { /// @solidity memory-safe-assembly assembly { // The maximum value of a uint256 contains 78 digits (1 byte per digit), but we allocate 160 bytes // to keep the free memory pointer word aligned. We'll need 1 word for the length, 1 word for the // trailing zeros padding, and 3 other words for a max of 78 digits. In total: 5 * 32 = 160 bytes. let newFreeMemoryPointer := add(mload(0x40), 160) // Update the free memory pointer to avoid overriding our string. mstore(0x40, newFreeMemoryPointer) // Assign str to the end of the zone of newly allocated memory. str := sub(newFreeMemoryPointer, 32) // Clean the last word of memory it may not be overwritten. mstore(str, 0) // Cache the end of the memory to calculate the length later. let end := str // We write the string from rightmost digit to leftmost digit. // The following is essentially a do-while loop that also handles the zero case. // prettier-ignore for { let temp := value } 1 {} { // Move the pointer 1 byte to the left. str := sub(str, 1) // Write the character to the pointer. // The ASCII index of the '0' character is 48. mstore8(str, add(48, mod(temp, 10))) // Keep dividing temp until zero. temp := div(temp, 10) // prettier-ignore if iszero(temp) { break } } // Compute and cache the final total length of the string. let length := sub(end, str) // Move the pointer 32 bytes leftwards to make room for the length. str := sub(str, 32) // Store the string's length at the start of memory allocated for our string. mstore(str, length) } } }
{ "remappings": [ "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", "ds-test/=lib/solmate/lib/ds-test/src/", "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/", "forge-std/=lib/forge-std/src/", "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/", "openzeppelin-contracts/=lib/openzeppelin-contracts/", "solarray/=lib/solarray/src/", "solmate/=lib/solmate/src/" ], "optimizer": { "enabled": true, "runs": 100 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "shanghai", "viaIR": false, "libraries": {} }
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"FailedToSendEth","type":"error"},{"inputs":[{"internalType":"uint256","name":"sent","type":"uint256"},{"internalType":"uint256","name":"expected","type":"uint256"}],"name":"IncorrectETHAmount","type":"error"},{"inputs":[{"internalType":"string","name":"message","type":"string"}],"name":"InvalidCollectionRequest","type":"error"},{"inputs":[],"name":"InvalidContractAddress","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"InvalidMintQuantity","type":"error"},{"inputs":[],"name":"MintingClosed","type":"error"},{"inputs":[],"name":"MintingNotStarted","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"OutOfSupply","type":"error"},{"inputs":[],"name":"OverClaimLimit","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"TokenDoesNotExist","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[],"name":"MintConfigChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","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"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"quantity","type":"uint256"}],"name":"TokenForgeMint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"quantity","type":"uint256"},{"indexed":false,"internalType":"string","name":"comment","type":"string"}],"name":"TokenForgeMintComment","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"contractURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"quantity","type":"uint256"}],"name":"cost","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMetadata","outputs":[{"components":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"description","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"string","name":"image","type":"string"},{"internalType":"string","name":"animation_url","type":"string"},{"internalType":"string","name":"mintType","type":"string"},{"internalType":"uint128","name":"maxSupply","type":"uint128"},{"internalType":"uint128","name":"maxPerWallet","type":"uint128"},{"internalType":"uint256","name":"cost","type":"uint256"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"components":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amt","type":"uint256"}],"internalType":"struct Royalty[]","name":"royalties","type":"tuple[]"},{"internalType":"uint256","name":"nonce","type":"uint256"}],"internalType":"struct CollectionCreationRequest","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"description","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"string","name":"image","type":"string"},{"internalType":"string","name":"animation_url","type":"string"},{"internalType":"string","name":"mintType","type":"string"},{"internalType":"uint128","name":"maxSupply","type":"uint128"},{"internalType":"uint128","name":"maxPerWallet","type":"uint128"},{"internalType":"uint256","name":"cost","type":"uint256"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"components":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amt","type":"uint256"}],"internalType":"struct Royalty[]","name":"royalties","type":"tuple[]"},{"internalType":"uint256","name":"nonce","type":"uint256"}],"internalType":"struct CollectionCreationRequest","name":"request","type":"tuple"},{"internalType":"address","name":"mintingContract_","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"metadata","outputs":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"description","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"string","name":"image","type":"string"},{"internalType":"string","name":"animation_url","type":"string"},{"internalType":"string","name":"mintType","type":"string"},{"internalType":"uint128","name":"maxSupply","type":"uint128"},{"internalType":"uint128","name":"maxPerWallet","type":"uint128"},{"internalType":"uint256","name":"cost","type":"uint256"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"quantity","type":"uint256"},{"internalType":"string","name":"comment","type":"string"}],"name":"mintWithComment","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"mintingContract","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"owner","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"description","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"string","name":"image","type":"string"},{"internalType":"string","name":"animation_url","type":"string"},{"internalType":"string","name":"mintType","type":"string"},{"internalType":"uint128","name":"maxSupply","type":"uint128"},{"internalType":"uint128","name":"maxPerWallet","type":"uint128"},{"internalType":"uint256","name":"cost","type":"uint256"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"components":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amt","type":"uint256"}],"internalType":"struct Royalty[]","name":"royalties","type":"tuple[]"},{"internalType":"uint256","name":"nonce","type":"uint256"}],"internalType":"struct CollectionCreationRequest","name":"metadata_","type":"tuple"}],"name":"setMetadata","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]
[ Download: CSV Export ]
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.