Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- OpenEditionERC721
- Optimization enabled
- true
- Compiler version
- v0.8.23+commit.f704f362
- Optimization runs
- 20
- EVM Version
- london
- Verified at
- 2024-08-03T16:36:19.081182Z
contracts/prebuilts/open-edition/OpenEditionERC721.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.11; /// @author thirdweb // $$\ $$\ $$\ $$\ $$\ // $$ | $$ | \__| $$ | $$ | // $$$$$$\ $$$$$$$\ $$\ $$$$$$\ $$$$$$$ |$$\ $$\ $$\ $$$$$$\ $$$$$$$\ // \_$$ _| $$ __$$\ $$ |$$ __$$\ $$ __$$ |$$ | $$ | $$ |$$ __$$\ $$ __$$\ // $$ | $$ | $$ |$$ |$$ | \__|$$ / $$ |$$ | $$ | $$ |$$$$$$$$ |$$ | $$ | // $$ |$$\ $$ | $$ |$$ |$$ | $$ | $$ |$$ | $$ | $$ |$$ ____|$$ | $$ | // \$$$$ |$$ | $$ |$$ |$$ | \$$$$$$$ |\$$$$$\$$$$ |\$$$$$$$\ $$$$$$$ | // \____/ \__| \__|\__|\__| \_______| \_____\____/ \_______|\_______/ // ========== External imports ========== import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol"; import "../../eip/queryable/ERC721AQueryableUpgradeable.sol"; // ========== Internal imports ========== import "../../external-deps/openzeppelin/metatx/ERC2771ContextUpgradeable.sol"; import "../../lib/CurrencyTransferLib.sol"; // ========== Features ========== import "../../extension/Multicall.sol"; import "../../extension/ContractMetadata.sol"; import "../../extension/Royalty.sol"; import "../../extension/PrimarySale.sol"; import "../../extension/Ownable.sol"; import "../../extension/SharedMetadata.sol"; import "../../extension/PermissionsEnumerable.sol"; import "../../extension/Drop.sol"; contract OpenEditionERC721 is Initializable, ContractMetadata, Royalty, PrimarySale, Ownable, SharedMetadata, PermissionsEnumerable, Drop, ERC2771ContextUpgradeable, Multicall, ERC721AQueryableUpgradeable { using StringsUpgradeable for uint256; /*/////////////////////////////////////////////////////////////// State variables //////////////////////////////////////////////////////////////*/ /// @dev Only transfers to or from TRANSFER_ROLE holders are valid, when transfers are restricted. bytes32 private transferRole; /// @dev Only MINTER_ROLE holders can update the shared metadata of tokens. bytes32 private minterRole; /// @dev Max bps in the thirdweb system. uint256 private constant MAX_BPS = 10_000; /*/////////////////////////////////////////////////////////////// Constructor + initializer logic //////////////////////////////////////////////////////////////*/ constructor() initializer {} /// @dev Initializes the contract, like a constructor. function initialize( address _defaultAdmin, string memory _name, string memory _symbol, string memory _contractURI, address[] memory _trustedForwarders, address _saleRecipient, address _royaltyRecipient, uint128 _royaltyBps ) external initializerERC721A initializer { bytes32 _transferRole = keccak256("TRANSFER_ROLE"); bytes32 _minterRole = keccak256("MINTER_ROLE"); // Initialize inherited contracts, most base-like -> most derived. __ERC2771Context_init(_trustedForwarders); __ERC721A_init(_name, _symbol); _setupContractURI(_contractURI); _setupOwner(_defaultAdmin); _setupRole(DEFAULT_ADMIN_ROLE, _defaultAdmin); _setupRole(_minterRole, _defaultAdmin); _setupRole(_transferRole, _defaultAdmin); _setupRole(_transferRole, address(0)); _setupDefaultRoyaltyInfo(_royaltyRecipient, _royaltyBps); _setupPrimarySaleRecipient(_saleRecipient); transferRole = _transferRole; minterRole = _minterRole; } /*/////////////////////////////////////////////////////////////// ERC 165 / 721 / 2981 logic //////////////////////////////////////////////////////////////*/ /// @dev Returns the URI for a given tokenId. function tokenURI( uint256 _tokenId ) public view virtual override(ERC721AUpgradeable, IERC721AUpgradeable) returns (string memory) { if (!_exists(_tokenId)) { revert("!ID"); } return _getURIFromSharedMetadata(_tokenId); } /// @dev See ERC 165 function supportsInterface( bytes4 interfaceId ) public view virtual override(ERC721AUpgradeable, IERC165, IERC721AUpgradeable) returns (bool) { return super.supportsInterface(interfaceId) || type(IERC2981Upgradeable).interfaceId == interfaceId; } /// @dev The start token ID for the contract. function _startTokenId() internal pure override returns (uint256) { return 1; } function startTokenId() public pure returns (uint256) { return _startTokenId(); } /*/////////////////////////////////////////////////////////////// Internal functions //////////////////////////////////////////////////////////////*/ /// @dev Collects and distributes the primary sale value of NFTs being claimed. function _collectPriceOnClaim( address _primarySaleRecipient, uint256 _quantityToClaim, address _currency, uint256 _pricePerToken ) internal override { if (_pricePerToken == 0) { require(msg.value == 0, "!Value"); return; } uint256 totalPrice = _quantityToClaim * _pricePerToken; bool validMsgValue; if (_currency == CurrencyTransferLib.NATIVE_TOKEN) { validMsgValue = msg.value == totalPrice; } else { validMsgValue = msg.value == 0; } require(validMsgValue, "!V"); address saleRecipient = _primarySaleRecipient == address(0) ? primarySaleRecipient() : _primarySaleRecipient; CurrencyTransferLib.transferCurrency(_currency, _msgSender(), saleRecipient, totalPrice); } /// @dev Transfers the NFTs being claimed. function _transferTokensOnClaim( address _to, uint256 _quantityBeingClaimed ) internal override returns (uint256 startTokenId_) { startTokenId_ = _nextTokenId(); _safeMint(_to, _quantityBeingClaimed); } /// @dev Checks whether primary sale recipient can be set in the given execution context. function _canSetPrimarySaleRecipient() internal view override returns (bool) { return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); } /// @dev Checks whether owner can be set in the given execution context. function _canSetOwner() internal view override returns (bool) { return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); } /// @dev Checks whether royalty info can be set in the given execution context. function _canSetRoyaltyInfo() internal view override returns (bool) { return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); } /// @dev Checks whether contract metadata can be set in the given execution context. function _canSetContractURI() internal view override returns (bool) { return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); } /// @dev Checks whether platform fee info can be set in the given execution context. function _canSetClaimConditions() internal view override returns (bool) { return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); } /// @dev Returns whether the shared metadata of tokens can be set in the given execution context. function _canSetSharedMetadata() internal view virtual override returns (bool) { return hasRole(minterRole, _msgSender()); } /*/////////////////////////////////////////////////////////////// Miscellaneous //////////////////////////////////////////////////////////////*/ /** * Returns the total amount of tokens minted in the contract. */ function totalMinted() external view returns (uint256) { unchecked { return _nextTokenId() - _startTokenId(); } } /// @dev The tokenId of the next NFT that will be minted / lazy minted. function nextTokenIdToMint() external view returns (uint256) { return _nextTokenId(); } /// @dev The next token ID of the NFT that can be claimed. function nextTokenIdToClaim() external view returns (uint256) { return _nextTokenId(); } /// @dev Burns `tokenId`. See {ERC721-_burn}. function burn(uint256 tokenId) external virtual { // note: ERC721AUpgradeable's `_burn(uint256,bool)` internally checks for token approvals. _burn(tokenId, true); } /// @dev See {ERC721-_beforeTokenTransfer}. function _beforeTokenTransfers( address from, address to, uint256 startTokenId_, uint256 quantity ) internal virtual override { super._beforeTokenTransfers(from, to, startTokenId_, quantity); // if transfer is restricted on the contract, we still want to allow burning and minting if (!hasRole(transferRole, address(0)) && from != address(0) && to != address(0)) { if (!hasRole(transferRole, from) && !hasRole(transferRole, to)) { revert("!T"); } } } function _dropMsgSender() internal view virtual override returns (address) { return _msgSender(); } function _msgSenderERC721A() internal view virtual override returns (address) { return _msgSender(); } function _msgSender() internal view virtual override(ERC2771ContextUpgradeable, Multicall) returns (address sender) { return ERC2771ContextUpgradeable._msgSender(); } }
contracts/extension/PermissionsEnumerable.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb import "./interface/IPermissionsEnumerable.sol"; import "./Permissions.sol"; /** * @title PermissionsEnumerable * @dev This contracts provides extending-contracts with role-based access control mechanisms. * Also provides interfaces to view all members with a given role, and total count of members. */ contract PermissionsEnumerable is IPermissionsEnumerable, Permissions { /** * @notice A data structure to store data of members for a given role. * * @param index Current index in the list of accounts that have a role. * @param members map from index => address of account that has a role * @param indexOf map from address => index which the account has. */ struct RoleMembers { uint256 index; mapping(uint256 => address) members; mapping(address => uint256) indexOf; } /// @dev map from keccak256 hash of a role to its members' data. See {RoleMembers}. mapping(bytes32 => RoleMembers) private roleMembers; /** * @notice Returns the role-member from a list of members for a role, * at a given index. * @dev Returns `member` who has `role`, at `index` of role-members list. * See struct {RoleMembers}, and mapping {roleMembers} * * @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") * @param index Index in list of current members for the role. * * @return member Address of account that has `role` */ function getRoleMember(bytes32 role, uint256 index) external view override returns (address member) { uint256 currentIndex = roleMembers[role].index; uint256 check; for (uint256 i = 0; i < currentIndex; i += 1) { if (roleMembers[role].members[i] != address(0)) { if (check == index) { member = roleMembers[role].members[i]; return member; } check += 1; } else if (hasRole(role, address(0)) && i == roleMembers[role].indexOf[address(0)]) { check += 1; } } } /** * @notice Returns total number of accounts that have a role. * @dev Returns `count` of accounts that have `role`. * See struct {RoleMembers}, and mapping {roleMembers} * * @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") * * @return count Total number of accounts that have `role` */ function getRoleMemberCount(bytes32 role) external view override returns (uint256 count) { uint256 currentIndex = roleMembers[role].index; for (uint256 i = 0; i < currentIndex; i += 1) { if (roleMembers[role].members[i] != address(0)) { count += 1; } } if (hasRole(role, address(0))) { count += 1; } } /// @dev Revokes `role` from `account`, and removes `account` from {roleMembers} /// See {_removeMember} function _revokeRole(bytes32 role, address account) internal override { super._revokeRole(role, account); _removeMember(role, account); } /// @dev Grants `role` to `account`, and adds `account` to {roleMembers} /// See {_addMember} function _setupRole(bytes32 role, address account) internal override { super._setupRole(role, account); _addMember(role, account); } /// @dev adds `account` to {roleMembers}, for `role` function _addMember(bytes32 role, address account) internal { uint256 idx = roleMembers[role].index; roleMembers[role].index += 1; roleMembers[role].members[idx] = account; roleMembers[role].indexOf[account] = idx; } /// @dev removes `account` from {roleMembers}, for `role` function _removeMember(bytes32 role, address account) internal { uint256 idx = roleMembers[role].indexOf[account]; delete roleMembers[role].members[idx]; delete roleMembers[role].indexOf[account]; } }
lib/openzeppelin-contracts-upgradeable/contracts/utils/introspection/IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
contracts/extension/interface/ISharedMetadata.sol
// SPDX-License-Identifier: Apache 2.0 pragma solidity ^0.8.10; /// @author thirdweb interface ISharedMetadata { /// @notice Emitted when shared metadata is lazy minted. event SharedMetadataUpdated(string name, string description, string imageURI, string animationURI); /** * @notice Structure for metadata shared across all tokens * * @param name Shared name of NFT in metadata * @param description Shared description of NFT in metadata * @param imageURI Shared URI of image to render for NFTs * @param animationURI Shared URI of animation to render for NFTs */ struct SharedMetadataInfo { string name; string description; string imageURI; string animationURI; } /** * @notice Set shared metadata for NFTs * @param _metadata common metadata for all tokens */ function setSharedMetadata(SharedMetadataInfo calldata _metadata) external; }
contracts/extension/Permissions.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb import "./interface/IPermissions.sol"; import "../lib/Strings.sol"; /** * @title Permissions * @dev This contracts provides extending-contracts with role-based access control mechanisms */ contract Permissions is IPermissions { /// @dev Map from keccak256 hash of a role => a map from address => whether address has role. mapping(bytes32 => mapping(address => bool)) private _hasRole; /// @dev Map from keccak256 hash of a role to role admin. See {getRoleAdmin}. mapping(bytes32 => bytes32) private _getRoleAdmin; /// @dev Default admin role for all roles. Only accounts with this role can grant/revoke other roles. bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /// @dev Modifier that checks if an account has the specified role; reverts otherwise. modifier onlyRole(bytes32 role) { _checkRole(role, msg.sender); _; } /** * @notice Checks whether an account has a particular role. * @dev Returns `true` if `account` has been granted `role`. * * @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") * @param account Address of the account for which the role is being checked. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _hasRole[role][account]; } /** * @notice Checks whether an account has a particular role; * role restrictions can be swtiched on and off. * * @dev Returns `true` if `account` has been granted `role`. * Role restrictions can be swtiched on and off: * - If address(0) has ROLE, then the ROLE restrictions * don't apply. * - If address(0) does not have ROLE, then the ROLE * restrictions will apply. * * @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") * @param account Address of the account for which the role is being checked. */ function hasRoleWithSwitch(bytes32 role, address account) public view returns (bool) { if (!_hasRole[role][address(0)]) { return _hasRole[role][account]; } return true; } /** * @notice Returns the admin role that controls the specified role. * @dev See {grantRole} and {revokeRole}. * To change a role's admin, use {_setRoleAdmin}. * * @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") */ function getRoleAdmin(bytes32 role) external view override returns (bytes32) { return _getRoleAdmin[role]; } /** * @notice Grants a role to an account, if not previously granted. * @dev Caller must have admin role for the `role`. * Emits {RoleGranted Event}. * * @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") * @param account Address of the account to which the role is being granted. */ function grantRole(bytes32 role, address account) public virtual override { _checkRole(_getRoleAdmin[role], msg.sender); if (_hasRole[role][account]) { revert("Can only grant to non holders"); } _setupRole(role, account); } /** * @notice Revokes role from an account. * @dev Caller must have admin role for the `role`. * Emits {RoleRevoked Event}. * * @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") * @param account Address of the account from which the role is being revoked. */ function revokeRole(bytes32 role, address account) public virtual override { _checkRole(_getRoleAdmin[role], msg.sender); _revokeRole(role, account); } /** * @notice Revokes role from the account. * @dev Caller must have the `role`, with caller being the same as `account`. * Emits {RoleRevoked Event}. * * @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") * @param account Address of the account from which the role is being revoked. */ function renounceRole(bytes32 role, address account) public virtual override { if (msg.sender != account) { revert("Can only renounce for self"); } _revokeRole(role, account); } /// @dev Sets `adminRole` as `role`'s admin role. function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = _getRoleAdmin[role]; _getRoleAdmin[role] = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /// @dev Sets up `role` for `account` function _setupRole(bytes32 role, address account) internal virtual { _hasRole[role][account] = true; emit RoleGranted(role, account, msg.sender); } /// @dev Revokes `role` from `account` function _revokeRole(bytes32 role, address account) internal virtual { _checkRole(role, account); delete _hasRole[role][account]; emit RoleRevoked(role, account, msg.sender); } /// @dev Checks `role` for `account`. Reverts with a message including the required role. function _checkRole(bytes32 role, address account) internal view virtual { if (!_hasRole[role][account]) { revert( string( abi.encodePacked( "Permissions: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /// @dev Checks `role` for `account`. Reverts with a message including the required role. function _checkRoleWithSwitch(bytes32 role, address account) internal view virtual { if (!hasRoleWithSwitch(role, account)) { revert( string( abi.encodePacked( "Permissions: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } }
lib/openzeppelin-contracts-upgradeable/contracts/utils/StringsUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/MathUpgradeable.sol"; import "./math/SignedMathUpgradeable.sol"; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = MathUpgradeable.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), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toString(int256 value) internal pure returns (string memory) { return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMathUpgradeable.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, MathUpgradeable.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) { 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] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); 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 keccak256(bytes(a)) == keccak256(bytes(b)); } }
contracts/eip/interface/IERC20.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); }
contracts/extension/interface/IPermissions.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IPermissions { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
contracts/extension/interface/IPermissionsEnumerable.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb import "./IPermissions.sol"; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IPermissionsEnumerable is IPermissions { /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * [forum post](https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296) * for more information. */ function getRoleMember(bytes32 role, uint256 index) external view returns (address); /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) external view returns (uint256); }
contracts/extension/ContractMetadata.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb import "./interface/IContractMetadata.sol"; /** * @title Contract Metadata * @notice Thirdweb's `ContractMetadata` is a contract extension for any base contracts. It lets you set a metadata URI * for you contract. * Additionally, `ContractMetadata` is necessary for NFT contracts that want royalties to get distributed on OpenSea. */ abstract contract ContractMetadata is IContractMetadata { /// @notice Returns the contract metadata URI. string public override contractURI; /** * @notice Lets a contract admin set the URI for contract-level metadata. * @dev Caller should be authorized to setup contractURI, e.g. contract admin. * See {_canSetContractURI}. * Emits {ContractURIUpdated Event}. * * @param _uri keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") */ function setContractURI(string memory _uri) external override { if (!_canSetContractURI()) { revert("Not authorized"); } _setupContractURI(_uri); } /// @dev Lets a contract admin set the URI for contract-level metadata. function _setupContractURI(string memory _uri) internal { string memory prevURI = contractURI; contractURI = _uri; emit ContractURIUpdated(prevURI, _uri); } /// @dev Returns whether contract metadata can be set in the given execution context. function _canSetContractURI() internal view virtual returns (bool); }
lib/openzeppelin-contracts-upgradeable/contracts/interfaces/IERC2981Upgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC2981.sol) pragma solidity ^0.8.0; import "../utils/introspection/IERC165Upgradeable.sol"; /** * @dev Interface for the NFT Royalty Standard. * * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal * support for royalty payments across all NFT marketplaces and ecosystem participants. * * _Available since v4.5._ */ interface IERC2981Upgradeable is IERC165Upgradeable { /** * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of * exchange. The royalty amount is denominated and should be paid in that same unit of exchange. */ function royaltyInfo( uint256 tokenId, uint256 salePrice ) external view returns (address receiver, uint256 royaltyAmount); }
contracts/eip/queryable/IERC721AQueryableUpgradeable.sol
// SPDX-License-Identifier: MIT // ERC721A Contracts v4.2.3 // Creator: Chiru Labs pragma solidity ^0.8.4; import "./IERC721AUpgradeable.sol"; /** * @dev Interface of ERC721AQueryable. */ interface IERC721AQueryableUpgradeable is IERC721AUpgradeable { /** * Invalid query range (`start` >= `stop`). */ error InvalidQueryRange(); /** * @dev Returns the `TokenOwnership` struct at `tokenId` without reverting. * * If the `tokenId` is out of bounds: * * - `addr = address(0)` * - `startTimestamp = 0` * - `burned = false` * - `extraData = 0` * * If the `tokenId` is burned: * * - `addr = <Address of owner before token was burned>` * - `startTimestamp = <Timestamp when token was burned>` * - `burned = true` * - `extraData = <Extra data when token was burned>` * * Otherwise: * * - `addr = <Address of owner>` * - `startTimestamp = <Timestamp of start of ownership>` * - `burned = false` * - `extraData = <Extra data at start of ownership>` */ function explicitOwnershipOf(uint256 tokenId) external view returns (TokenOwnership memory); /** * @dev Returns an array of token IDs owned by `owner`, * in the range [`start`, `stop`) * (i.e. `start <= tokenId < stop`). * * This function allows for tokens to be queried if the collection * grows too big for a single call of {ERC721AQueryable-tokensOfOwner}. * * Requirements: * * - `start < stop` */ function tokensOfOwnerIn(address owner, uint256 start, uint256 stop) external view returns (uint256[] memory); /** * @dev Returns an array of token IDs owned by `owner`. * * This function scans the ownership mapping and is O(`totalSupply`) in complexity. * It is meant to be called off-chain. * * See {ERC721AQueryable-tokensOfOwnerIn} for splitting the scan into * multiple smaller scans if the collection is large enough to cause * an out-of-gas error (10K collections should be fine). */ function tokensOfOwner(address owner) external view returns (uint256[] memory); }
contracts/extension/interface/IClaimCondition.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb /** * The interface `IClaimCondition` is written for thirdweb's 'Drop' contracts, which are distribution mechanisms for tokens. * * A claim condition defines criteria under which accounts can mint tokens. Claim conditions can be overwritten * or added to by the contract admin. At any moment, there is only one active claim condition. */ interface IClaimCondition { /** * @notice The criteria that make up a claim condition. * * @param startTimestamp The unix timestamp after which the claim condition applies. * The same claim condition applies until the `startTimestamp` * of the next claim condition. * * @param maxClaimableSupply The maximum total number of tokens that can be claimed under * the claim condition. * * @param supplyClaimed At any given point, the number of tokens that have been claimed * under the claim condition. * * @param quantityLimitPerWallet The maximum number of tokens that can be claimed by a wallet. * * @param merkleRoot The allowlist of addresses that can claim tokens under the claim * condition. * * @param pricePerToken The price required to pay per token claimed. * * @param currency The currency in which the `pricePerToken` must be paid. * * @param metadata Claim condition metadata. */ struct ClaimCondition { uint256 startTimestamp; uint256 maxClaimableSupply; uint256 supplyClaimed; uint256 quantityLimitPerWallet; bytes32 merkleRoot; uint256 pricePerToken; address currency; string metadata; } }
contracts/eip/interface/IERC721.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; }
lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @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 Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 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 functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _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 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _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() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @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 { require(!_initializing, "Initializable: contract is initializing"); if (_initialized != type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
contracts/infra/interface/IWETH.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; interface IWETH { function deposit() external payable; function withdraw(uint256 amount) external; function transfer(address to, uint256 value) external returns (bool); }
lib/openzeppelin-contracts/contracts/utils/Address.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
contracts/extension/interface/IRoyalty.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb import "../../eip/interface/IERC2981.sol"; /** * Thirdweb's `Royalty` is a contract extension to be used with any base contract. It exposes functions for setting and reading * the recipient of royalty fee and the royalty fee basis points, and lets the inheriting contract perform conditional logic * that uses information about royalty fees, if desired. * * The `Royalty` contract is ERC2981 compliant. */ interface IRoyalty is IERC2981 { struct RoyaltyInfo { address recipient; uint256 bps; } /// @dev Returns the royalty recipient and fee bps. function getDefaultRoyaltyInfo() external view returns (address, uint16); /// @dev Lets a module admin update the royalty bps and recipient. function setDefaultRoyaltyInfo(address _royaltyRecipient, uint256 _royaltyBps) external; /// @dev Lets a module admin set the royalty recipient for a particular token Id. function setRoyaltyInfoForToken(uint256 tokenId, address recipient, uint256 bps) external; /// @dev Returns the royalty recipient for a particular token Id. function getRoyaltyInfoForToken(uint256 tokenId) external view returns (address, uint16); /// @dev Emitted when royalty info is updated. event DefaultRoyalty(address indexed newRoyaltyRecipient, uint256 newRoyaltyBps); /// @dev Emitted when royalty recipient for tokenId is set event RoyaltyForToken(uint256 indexed tokenId, address indexed royaltyRecipient, uint256 royaltyBps); }
contracts/eip/interface/IERC2981.sol
// SPDX-License-Identifier: Apache 2.0 pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Interface for the NFT Royalty Standard. * * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal * support for royalty payments across all NFT marketplaces and ecosystem participants. * * _Available since v4.5._ */ interface IERC2981 is IERC165 { /** * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of * exchange. The royalty amount is denominated and should be payed in that same unit of exchange. */ function royaltyInfo( uint256 tokenId, uint256 salePrice ) external view returns (address receiver, uint256 royaltyAmount); }
contracts/eip/queryable/ERC721AUpgradeable.sol
// SPDX-License-Identifier: MIT // ERC721A Contracts v4.2.3 // Creator: Chiru Labs pragma solidity ^0.8.4; import "./IERC721AUpgradeable.sol"; import { ERC721AStorage } from "./ERC721AStorage.sol"; import "./ERC721A__Initializable.sol"; /** * @dev Interface of ERC721 token receiver. */ interface ERC721A__IERC721ReceiverUpgradeable { function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } /** * @title ERC721A * * @dev Implementation of the [ERC721](https://eips.ethereum.org/EIPS/eip-721) * Non-Fungible Token Standard, including the Metadata extension. * Optimized for lower gas during batch mints. * * Token IDs are minted in sequential order (e.g. 0, 1, 2, 3, ...) * starting from `_startTokenId()`. * * Assumptions: * * - An owner cannot have more than 2**64 - 1 (max value of uint64) of supply. * - The maximum token ID cannot exceed 2**256 - 1 (max value of uint256). */ contract ERC721AUpgradeable is ERC721A__Initializable, IERC721AUpgradeable { using ERC721AStorage for ERC721AStorage.Layout; // ============================================================= // CONSTANTS // ============================================================= // Mask of an entry in packed address data. uint256 private constant _BITMASK_ADDRESS_DATA_ENTRY = (1 << 64) - 1; // The bit position of `numberMinted` in packed address data. uint256 private constant _BITPOS_NUMBER_MINTED = 64; // The bit position of `numberBurned` in packed address data. uint256 private constant _BITPOS_NUMBER_BURNED = 128; // The bit position of `aux` in packed address data. uint256 private constant _BITPOS_AUX = 192; // Mask of all 256 bits in packed address data except the 64 bits for `aux`. uint256 private constant _BITMASK_AUX_COMPLEMENT = (1 << 192) - 1; // The bit position of `startTimestamp` in packed ownership. uint256 private constant _BITPOS_START_TIMESTAMP = 160; // The bit mask of the `burned` bit in packed ownership. uint256 private constant _BITMASK_BURNED = 1 << 224; // The bit position of the `nextInitialized` bit in packed ownership. uint256 private constant _BITPOS_NEXT_INITIALIZED = 225; // The bit mask of the `nextInitialized` bit in packed ownership. uint256 private constant _BITMASK_NEXT_INITIALIZED = 1 << 225; // The bit position of `extraData` in packed ownership. uint256 private constant _BITPOS_EXTRA_DATA = 232; // Mask of all 256 bits in a packed ownership except the 24 bits for `extraData`. uint256 private constant _BITMASK_EXTRA_DATA_COMPLEMENT = (1 << 232) - 1; // The mask of the lower 160 bits for addresses. uint256 private constant _BITMASK_ADDRESS = (1 << 160) - 1; // The maximum `quantity` that can be minted with {_mintERC2309}. // This limit is to prevent overflows on the address data entries. // For a limit of 5000, a total of 3.689e15 calls to {_mintERC2309} // is required to cause an overflow, which is unrealistic. uint256 private constant _MAX_MINT_ERC2309_QUANTITY_LIMIT = 5000; // The `Transfer` event signature is given by: // `keccak256(bytes("Transfer(address,address,uint256)"))`. bytes32 private constant _TRANSFER_EVENT_SIGNATURE = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef; // ============================================================= // CONSTRUCTOR // ============================================================= function __ERC721A_init(string memory name_, string memory symbol_) internal onlyInitializingERC721A { __ERC721A_init_unchained(name_, symbol_); } function __ERC721A_init_unchained(string memory name_, string memory symbol_) internal onlyInitializingERC721A { ERC721AStorage.layout()._name = name_; ERC721AStorage.layout()._symbol = symbol_; ERC721AStorage.layout()._currentIndex = _startTokenId(); } // ============================================================= // TOKEN COUNTING OPERATIONS // ============================================================= /** * @dev Returns the starting token ID. * To change the starting token ID, please override this function. */ function _startTokenId() internal view virtual returns (uint256) { return 0; } /** * @dev Returns the next token ID to be minted. */ function _nextTokenId() internal view virtual returns (uint256) { return ERC721AStorage.layout()._currentIndex; } /** * @dev Returns the total number of tokens in existence. * Burned tokens will reduce the count. * To get the total number of tokens minted, please see {_totalMinted}. */ function totalSupply() public view virtual override returns (uint256) { // Counter underflow is impossible as _burnCounter cannot be incremented // more than `_currentIndex - _startTokenId()` times. unchecked { return ERC721AStorage.layout()._currentIndex - ERC721AStorage.layout()._burnCounter - _startTokenId(); } } /** * @dev Returns the total amount of tokens minted in the contract. */ function _totalMinted() internal view virtual returns (uint256) { // Counter underflow is impossible as `_currentIndex` does not decrement, // and it is initialized to `_startTokenId()`. unchecked { return ERC721AStorage.layout()._currentIndex - _startTokenId(); } } /** * @dev Returns the total number of tokens burned. */ function _totalBurned() internal view virtual returns (uint256) { return ERC721AStorage.layout()._burnCounter; } // ============================================================= // ADDRESS DATA OPERATIONS // ============================================================= /** * @dev Returns the number of tokens in `owner`'s account. */ function balanceOf(address owner) public view virtual override returns (uint256) { if (owner == address(0)) _revert(BalanceQueryForZeroAddress.selector); return ERC721AStorage.layout()._packedAddressData[owner] & _BITMASK_ADDRESS_DATA_ENTRY; } /** * Returns the number of tokens minted by `owner`. */ function _numberMinted(address owner) internal view returns (uint256) { return (ERC721AStorage.layout()._packedAddressData[owner] >> _BITPOS_NUMBER_MINTED) & _BITMASK_ADDRESS_DATA_ENTRY; } /** * Returns the number of tokens burned by or on behalf of `owner`. */ function _numberBurned(address owner) internal view returns (uint256) { return (ERC721AStorage.layout()._packedAddressData[owner] >> _BITPOS_NUMBER_BURNED) & _BITMASK_ADDRESS_DATA_ENTRY; } /** * Returns the auxiliary data for `owner`. (e.g. number of whitelist mint slots used). */ function _getAux(address owner) internal view returns (uint64) { return uint64(ERC721AStorage.layout()._packedAddressData[owner] >> _BITPOS_AUX); } /** * Sets the auxiliary data for `owner`. (e.g. number of whitelist mint slots used). * If there are multiple variables, please pack them into a uint64. */ function _setAux(address owner, uint64 aux) internal virtual { uint256 packed = ERC721AStorage.layout()._packedAddressData[owner]; uint256 auxCasted; // Cast `aux` with assembly to avoid redundant masking. assembly { auxCasted := aux } packed = (packed & _BITMASK_AUX_COMPLEMENT) | (auxCasted << _BITPOS_AUX); ERC721AStorage.layout()._packedAddressData[owner] = packed; } // ============================================================= // IERC165 // ============================================================= /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) * to learn more about how these ids are created. * * This function call must use less than 30000 gas. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { // The interface IDs are constants representing the first 4 bytes // of the XOR of all function selectors in the interface. // See: [ERC165](https://eips.ethereum.org/EIPS/eip-165) // (e.g. `bytes4(i.functionA.selector ^ i.functionB.selector ^ ...)`) return interfaceId == 0x01ffc9a7 || // ERC165 interface ID for ERC165. interfaceId == 0x80ac58cd || // ERC165 interface ID for ERC721. interfaceId == 0x5b5e139f; // ERC165 interface ID for ERC721Metadata. } // ============================================================= // IERC721Metadata // ============================================================= /** * @dev Returns the token collection name. */ function name() public view virtual override returns (string memory) { return ERC721AStorage.layout()._name; } /** * @dev Returns the token collection symbol. */ function symbol() public view virtual override returns (string memory) { return ERC721AStorage.layout()._symbol; } /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { if (!_exists(tokenId)) _revert(URIQueryForNonexistentToken.selector); string memory baseURI = _baseURI(); return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, _toString(tokenId))) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, it can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } // ============================================================= // OWNERSHIPS OPERATIONS // ============================================================= /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { return address(uint160(_packedOwnershipOf(tokenId))); } /** * @dev Gas spent here starts off proportional to the maximum mint batch size. * It gradually moves to O(1) as tokens get transferred around over time. */ function _ownershipOf(uint256 tokenId) internal view virtual returns (TokenOwnership memory) { return _unpackedOwnership(_packedOwnershipOf(tokenId)); } /** * @dev Returns the unpacked `TokenOwnership` struct at `index`. */ function _ownershipAt(uint256 index) internal view virtual returns (TokenOwnership memory) { return _unpackedOwnership(ERC721AStorage.layout()._packedOwnerships[index]); } /** * @dev Returns whether the ownership slot at `index` is initialized. * An uninitialized slot does not necessarily mean that the slot has no owner. */ function _ownershipIsInitialized(uint256 index) internal view virtual returns (bool) { return ERC721AStorage.layout()._packedOwnerships[index] != 0; } /** * @dev Initializes the ownership slot minted at `index` for efficiency purposes. */ function _initializeOwnershipAt(uint256 index) internal virtual { if (ERC721AStorage.layout()._packedOwnerships[index] == 0) { ERC721AStorage.layout()._packedOwnerships[index] = _packedOwnershipOf(index); } } /** * Returns the packed ownership data of `tokenId`. */ function _packedOwnershipOf(uint256 tokenId) private view returns (uint256 packed) { if (_startTokenId() <= tokenId) { packed = ERC721AStorage.layout()._packedOwnerships[tokenId]; // If the data at the starting slot does not exist, start the scan. if (packed == 0) { if (tokenId >= ERC721AStorage.layout()._currentIndex) _revert(OwnerQueryForNonexistentToken.selector); // Invariant: // There will always be an initialized ownership slot // (i.e. `ownership.addr != address(0) && ownership.burned == false`) // before an unintialized ownership slot // (i.e. `ownership.addr == address(0) && ownership.burned == false`) // Hence, `tokenId` will not underflow. // // We can directly compare the packed value. // If the address is zero, packed will be zero. for (;;) { unchecked { packed = ERC721AStorage.layout()._packedOwnerships[--tokenId]; } if (packed == 0) continue; if (packed & _BITMASK_BURNED == 0) return packed; // Otherwise, the token is burned, and we must revert. // This handles the case of batch burned tokens, where only the burned bit // of the starting slot is set, and remaining slots are left uninitialized. _revert(OwnerQueryForNonexistentToken.selector); } } // Otherwise, the data exists and we can skip the scan. // This is possible because we have already achieved the target condition. // This saves 2143 gas on transfers of initialized tokens. // If the token is not burned, return `packed`. Otherwise, revert. if (packed & _BITMASK_BURNED == 0) return packed; } _revert(OwnerQueryForNonexistentToken.selector); } /** * @dev Returns the unpacked `TokenOwnership` struct from `packed`. */ function _unpackedOwnership(uint256 packed) private pure returns (TokenOwnership memory ownership) { ownership.addr = address(uint160(packed)); ownership.startTimestamp = uint64(packed >> _BITPOS_START_TIMESTAMP); ownership.burned = packed & _BITMASK_BURNED != 0; ownership.extraData = uint24(packed >> _BITPOS_EXTRA_DATA); } /** * @dev Packs ownership data into a single uint256. */ function _packOwnershipData(address owner, uint256 flags) private view returns (uint256 result) { assembly { // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean. owner := and(owner, _BITMASK_ADDRESS) // `owner | (block.timestamp << _BITPOS_START_TIMESTAMP) | flags`. result := or(owner, or(shl(_BITPOS_START_TIMESTAMP, timestamp()), flags)) } } /** * @dev Returns the `nextInitialized` flag set if `quantity` equals 1. */ function _nextInitializedFlag(uint256 quantity) private pure returns (uint256 result) { // For branchless setting of the `nextInitialized` flag. assembly { // `(quantity == 1) << _BITPOS_NEXT_INITIALIZED`. result := shl(_BITPOS_NEXT_INITIALIZED, eq(quantity, 1)) } } // ============================================================= // APPROVAL OPERATIONS // ============================================================= /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. See {ERC721A-_approve}. * * Requirements: * * - The caller must own the token or be an approved operator. */ function approve(address to, uint256 tokenId) public payable virtual override { _approve(to, tokenId, true); } /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { if (!_exists(tokenId)) _revert(ApprovalQueryForNonexistentToken.selector); return ERC721AStorage.layout()._tokenApprovals[tokenId].value; } /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} * for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) public virtual override { ERC721AStorage.layout()._operatorApprovals[_msgSenderERC721A()][operator] = approved; emit ApprovalForAll(_msgSenderERC721A(), operator, approved); } /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return ERC721AStorage.layout()._operatorApprovals[owner][operator]; } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted. See {_mint}. */ function _exists(uint256 tokenId) internal view virtual returns (bool result) { if (_startTokenId() <= tokenId) { if (tokenId < ERC721AStorage.layout()._currentIndex) { uint256 packed; while ((packed = ERC721AStorage.layout()._packedOwnerships[tokenId]) == 0) --tokenId; result = packed & _BITMASK_BURNED == 0; } } } /** * @dev Returns whether `msgSender` is equal to `approvedAddress` or `owner`. */ function _isSenderApprovedOrOwner( address approvedAddress, address owner, address msgSender ) private pure returns (bool result) { assembly { // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean. owner := and(owner, _BITMASK_ADDRESS) // Mask `msgSender` to the lower 160 bits, in case the upper bits somehow aren't clean. msgSender := and(msgSender, _BITMASK_ADDRESS) // `msgSender == owner || msgSender == approvedAddress`. result := or(eq(msgSender, owner), eq(msgSender, approvedAddress)) } } /** * @dev Returns the storage slot and value for the approved address of `tokenId`. */ function _getApprovedSlotAndAddress( uint256 tokenId ) private view returns (uint256 approvedAddressSlot, address approvedAddress) { ERC721AStorage.TokenApprovalRef storage tokenApproval = ERC721AStorage.layout()._tokenApprovals[tokenId]; // The following is equivalent to `approvedAddress = _tokenApprovals[tokenId].value`. assembly { approvedAddressSlot := tokenApproval.slot approvedAddress := sload(approvedAddressSlot) } } // ============================================================= // TRANSFER OPERATIONS // ============================================================= /** * @dev Transfers `tokenId` from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token * by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) public payable virtual override { uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId); // Mask `from` to the lower 160 bits, in case the upper bits somehow aren't clean. from = address(uint160(uint256(uint160(from)) & _BITMASK_ADDRESS)); if (address(uint160(prevOwnershipPacked)) != from) _revert(TransferFromIncorrectOwner.selector); (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId); // The nested ifs save around 20+ gas over a compound boolean condition. if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A())) if (!isApprovedForAll(from, _msgSenderERC721A())) _revert(TransferCallerNotOwnerNorApproved.selector); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner. assembly { if approvedAddress { // This is equivalent to `delete _tokenApprovals[tokenId]`. sstore(approvedAddressSlot, 0) } } // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256. unchecked { // We can directly increment and decrement the balances. --ERC721AStorage.layout()._packedAddressData[from]; // Updates: `balance -= 1`. ++ERC721AStorage.layout()._packedAddressData[to]; // Updates: `balance += 1`. // Updates: // - `address` to the next owner. // - `startTimestamp` to the timestamp of transfering. // - `burned` to `false`. // - `nextInitialized` to `true`. ERC721AStorage.layout()._packedOwnerships[tokenId] = _packOwnershipData( to, _BITMASK_NEXT_INITIALIZED | _nextExtraData(from, to, prevOwnershipPacked) ); // If the next slot may not have been initialized (i.e. `nextInitialized == false`) . if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) { uint256 nextTokenId = tokenId + 1; // If the next slot's address is zero and not burned (i.e. packed value is zero). if (ERC721AStorage.layout()._packedOwnerships[nextTokenId] == 0) { // If the next slot is within bounds. if (nextTokenId != ERC721AStorage.layout()._currentIndex) { // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`. ERC721AStorage.layout()._packedOwnerships[nextTokenId] = prevOwnershipPacked; } } } } // Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean. uint256 toMasked = uint256(uint160(to)) & _BITMASK_ADDRESS; assembly { // Emit the `Transfer` event. log4( 0, // Start of data (0, since no data). 0, // End of data (0, since no data). _TRANSFER_EVENT_SIGNATURE, // Signature. from, // `from`. toMasked, // `to`. tokenId // `tokenId`. ) } if (toMasked == 0) _revert(TransferToZeroAddress.selector); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`. */ function safeTransferFrom(address from, address to, uint256 tokenId) public payable virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token * by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public payable virtual override { transferFrom(from, to, tokenId); if (to.code.length != 0) if (!_checkContractOnERC721Received(from, to, tokenId, _data)) { _revert(TransferToNonERC721ReceiverImplementer.selector); } } /** * @dev Hook that is called before a set of serially-ordered token IDs * are about to be transferred. This includes minting. * And also called before burning one token. * * `startTokenId` - the first token ID to be transferred. * `quantity` - the amount to be transferred. * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, `tokenId` will be burned by `from`. * - `from` and `to` are never both zero. */ function _beforeTokenTransfers(address from, address to, uint256 startTokenId, uint256 quantity) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token IDs * have been transferred. This includes minting. * And also called after one token has been burned. * * `startTokenId` - the first token ID to be transferred. * `quantity` - the amount to be transferred. * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been * transferred to `to`. * - When `from` is zero, `tokenId` has been minted for `to`. * - When `to` is zero, `tokenId` has been burned by `from`. * - `from` and `to` are never both zero. */ function _afterTokenTransfers(address from, address to, uint256 startTokenId, uint256 quantity) internal virtual {} /** * @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target contract. * * `from` - Previous owner of the given token ID. * `to` - Target address that will receive the token. * `tokenId` - Token ID to be transferred. * `_data` - Optional data to send along with the call. * * Returns whether the call correctly returned the expected magic value. */ function _checkContractOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { try ERC721A__IERC721ReceiverUpgradeable(to).onERC721Received(_msgSenderERC721A(), from, tokenId, _data) returns (bytes4 retval) { return retval == ERC721A__IERC721ReceiverUpgradeable(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { _revert(TransferToNonERC721ReceiverImplementer.selector); } assembly { revert(add(32, reason), mload(reason)) } } } // ============================================================= // MINT OPERATIONS // ============================================================= /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {Transfer} event for each mint. */ function _mint(address to, uint256 quantity) internal virtual { uint256 startTokenId = ERC721AStorage.layout()._currentIndex; if (quantity == 0) _revert(MintZeroQuantity.selector); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are incredibly unrealistic. // `balance` and `numberMinted` have a maximum limit of 2**64. // `tokenId` has a maximum limit of 2**256. unchecked { // Updates: // - `address` to the owner. // - `startTimestamp` to the timestamp of minting. // - `burned` to `false`. // - `nextInitialized` to `quantity == 1`. ERC721AStorage.layout()._packedOwnerships[startTokenId] = _packOwnershipData( to, _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0) ); // Updates: // - `balance += quantity`. // - `numberMinted += quantity`. // // We can directly add to the `balance` and `numberMinted`. ERC721AStorage.layout()._packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1); // Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean. uint256 toMasked = uint256(uint160(to)) & _BITMASK_ADDRESS; if (toMasked == 0) _revert(MintToZeroAddress.selector); uint256 end = startTokenId + quantity; uint256 tokenId = startTokenId; do { assembly { // Emit the `Transfer` event. log4( 0, // Start of data (0, since no data). 0, // End of data (0, since no data). _TRANSFER_EVENT_SIGNATURE, // Signature. 0, // `address(0)`. toMasked, // `to`. tokenId // `tokenId`. ) } // The `!=` check ensures that large values of `quantity` // that overflows uint256 will make the loop run out of gas. } while (++tokenId != end); ERC721AStorage.layout()._currentIndex = end; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * This function is intended for efficient minting only during contract creation. * * It emits only one {ConsecutiveTransfer} as defined in * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309), * instead of a sequence of {Transfer} event(s). * * Calling this function outside of contract creation WILL make your contract * non-compliant with the ERC721 standard. * For full ERC721 compliance, substituting ERC721 {Transfer} event(s) with the ERC2309 * {ConsecutiveTransfer} event is only permissible during contract creation. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {ConsecutiveTransfer} event. */ function _mintERC2309(address to, uint256 quantity) internal virtual { uint256 startTokenId = ERC721AStorage.layout()._currentIndex; if (to == address(0)) _revert(MintToZeroAddress.selector); if (quantity == 0) _revert(MintZeroQuantity.selector); if (quantity > _MAX_MINT_ERC2309_QUANTITY_LIMIT) _revert(MintERC2309QuantityExceedsLimit.selector); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are unrealistic due to the above check for `quantity` to be below the limit. unchecked { // Updates: // - `balance += quantity`. // - `numberMinted += quantity`. // // We can directly add to the `balance` and `numberMinted`. ERC721AStorage.layout()._packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1); // Updates: // - `address` to the owner. // - `startTimestamp` to the timestamp of minting. // - `burned` to `false`. // - `nextInitialized` to `quantity == 1`. ERC721AStorage.layout()._packedOwnerships[startTokenId] = _packOwnershipData( to, _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0) ); emit ConsecutiveTransfer(startTokenId, startTokenId + quantity - 1, address(0), to); ERC721AStorage.layout()._currentIndex = startTokenId + quantity; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Safely mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - If `to` refers to a smart contract, it must implement * {IERC721Receiver-onERC721Received}, which is called for each safe transfer. * - `quantity` must be greater than 0. * * See {_mint}. * * Emits a {Transfer} event for each mint. */ function _safeMint(address to, uint256 quantity, bytes memory _data) internal virtual { _mint(to, quantity); unchecked { if (to.code.length != 0) { uint256 end = ERC721AStorage.layout()._currentIndex; uint256 index = end - quantity; do { if (!_checkContractOnERC721Received(address(0), to, index++, _data)) { _revert(TransferToNonERC721ReceiverImplementer.selector); } } while (index < end); // Reentrancy protection. if (ERC721AStorage.layout()._currentIndex != end) _revert(bytes4(0)); } } } /** * @dev Equivalent to `_safeMint(to, quantity, '')`. */ function _safeMint(address to, uint256 quantity) internal virtual { _safeMint(to, quantity, ""); } // ============================================================= // APPROVAL OPERATIONS // ============================================================= /** * @dev Equivalent to `_approve(to, tokenId, false)`. */ function _approve(address to, uint256 tokenId) internal virtual { _approve(to, tokenId, false); } /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the * zero address clears previous approvals. * * Requirements: * * - `tokenId` must exist. * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId, bool approvalCheck) internal virtual { address owner = ownerOf(tokenId); if (approvalCheck && _msgSenderERC721A() != owner) if (!isApprovedForAll(owner, _msgSenderERC721A())) { _revert(ApprovalCallerNotOwnerNorApproved.selector); } ERC721AStorage.layout()._tokenApprovals[tokenId].value = to; emit Approval(owner, to, tokenId); } // ============================================================= // BURN OPERATIONS // ============================================================= /** * @dev Equivalent to `_burn(tokenId, false)`. */ function _burn(uint256 tokenId) internal virtual { _burn(tokenId, false); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId, bool approvalCheck) internal virtual { uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId); address from = address(uint160(prevOwnershipPacked)); (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId); if (approvalCheck) { // The nested ifs save around 20+ gas over a compound boolean condition. if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A())) if (!isApprovedForAll(from, _msgSenderERC721A())) _revert(TransferCallerNotOwnerNorApproved.selector); } _beforeTokenTransfers(from, address(0), tokenId, 1); // Clear approvals from the previous owner. assembly { if approvedAddress { // This is equivalent to `delete _tokenApprovals[tokenId]`. sstore(approvedAddressSlot, 0) } } // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256. unchecked { // Updates: // - `balance -= 1`. // - `numberBurned += 1`. // // We can directly decrement the balance, and increment the number burned. // This is equivalent to `packed -= 1; packed += 1 << _BITPOS_NUMBER_BURNED;`. ERC721AStorage.layout()._packedAddressData[from] += (1 << _BITPOS_NUMBER_BURNED) - 1; // Updates: // - `address` to the last owner. // - `startTimestamp` to the timestamp of burning. // - `burned` to `true`. // - `nextInitialized` to `true`. ERC721AStorage.layout()._packedOwnerships[tokenId] = _packOwnershipData( from, (_BITMASK_BURNED | _BITMASK_NEXT_INITIALIZED) | _nextExtraData(from, address(0), prevOwnershipPacked) ); // If the next slot may not have been initialized (i.e. `nextInitialized == false`) . if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) { uint256 nextTokenId = tokenId + 1; // If the next slot's address is zero and not burned (i.e. packed value is zero). if (ERC721AStorage.layout()._packedOwnerships[nextTokenId] == 0) { // If the next slot is within bounds. if (nextTokenId != ERC721AStorage.layout()._currentIndex) { // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`. ERC721AStorage.layout()._packedOwnerships[nextTokenId] = prevOwnershipPacked; } } } } emit Transfer(from, address(0), tokenId); _afterTokenTransfers(from, address(0), tokenId, 1); // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times. unchecked { ERC721AStorage.layout()._burnCounter++; } } // ============================================================= // EXTRA DATA OPERATIONS // ============================================================= /** * @dev Directly sets the extra data for the ownership data `index`. */ function _setExtraDataAt(uint256 index, uint24 extraData) internal virtual { uint256 packed = ERC721AStorage.layout()._packedOwnerships[index]; if (packed == 0) _revert(OwnershipNotInitializedForExtraData.selector); uint256 extraDataCasted; // Cast `extraData` with assembly to avoid redundant masking. assembly { extraDataCasted := extraData } packed = (packed & _BITMASK_EXTRA_DATA_COMPLEMENT) | (extraDataCasted << _BITPOS_EXTRA_DATA); ERC721AStorage.layout()._packedOwnerships[index] = packed; } /** * @dev Called during each token transfer to set the 24bit `extraData` field. * Intended to be overridden by the cosumer contract. * * `previousExtraData` - the value of `extraData` before transfer. * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, `tokenId` will be burned by `from`. * - `from` and `to` are never both zero. */ function _extraData(address from, address to, uint24 previousExtraData) internal view virtual returns (uint24) {} /** * @dev Returns the next extra data for the packed ownership data. * The returned result is shifted into position. */ function _nextExtraData(address from, address to, uint256 prevOwnershipPacked) private view returns (uint256) { uint24 extraData = uint24(prevOwnershipPacked >> _BITPOS_EXTRA_DATA); return uint256(_extraData(from, to, extraData)) << _BITPOS_EXTRA_DATA; } // ============================================================= // OTHER OPERATIONS // ============================================================= /** * @dev Returns the message sender (defaults to `msg.sender`). * * If you are writing GSN compatible contracts, you need to override this function. */ function _msgSenderERC721A() internal view virtual returns (address) { return msg.sender; } /** * @dev Converts a uint256 to its ASCII string decimal representation. */ function _toString(uint256 value) internal pure virtual returns (string memory str) { assembly { // The maximum value of a uint256 contains 78 digits (1 byte per digit), but // we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned. // We will need 1 word for the trailing zeros padding, 1 word for the length, // and 3 words for a maximum of 78 digits. Total: 5 * 0x20 = 0xa0. let m := add(mload(0x40), 0xa0) // Update the free memory pointer to allocate. mstore(0x40, m) // Assign the `str` to the end. str := sub(m, 0x20) // Zeroize the slot after the string. 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 {} { 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 } } let length := sub(end, str) // Move the pointer 32 bytes leftwards to make room for the length. str := sub(str, 0x20) // Store the length. mstore(str, length) } } /** * @dev For more efficient reverts. */ function _revert(bytes4 errorSelector) internal pure { assembly { mstore(0x00, errorSelector) revert(0x00, 0x04) } } }
contracts/eip/interface/IERC165.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * [EIP](https://eips.ethereum.org/EIPS/eip-165). * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
contracts/extension/interface/IDrop.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb import "./IClaimConditionMultiPhase.sol"; /** * The interface `IDrop` is written for thirdweb's 'Drop' contracts, which are distribution mechanisms for tokens. * * An authorized wallet can set a series of claim conditions, ordered by their respective `startTimestamp`. * A claim condition defines criteria under which accounts can mint tokens. Claim conditions can be overwritten * or added to by the contract admin. At any moment, there is only one active claim condition. */ interface IDrop is IClaimConditionMultiPhase { /** * @param proof Proof of concerned wallet's inclusion in an allowlist. * @param quantityLimitPerWallet The total quantity of tokens the allowlisted wallet is eligible to claim over time. * @param pricePerToken The price per token the allowlisted wallet must pay to claim tokens. * @param currency The currency in which the allowlisted wallet must pay the price for claiming tokens. */ struct AllowlistProof { bytes32[] proof; uint256 quantityLimitPerWallet; uint256 pricePerToken; address currency; } /// @notice Emitted when tokens are claimed via `claim`. event TokensClaimed( uint256 indexed claimConditionIndex, address indexed claimer, address indexed receiver, uint256 startTokenId, uint256 quantityClaimed ); /// @notice Emitted when the contract's claim conditions are updated. event ClaimConditionsUpdated(ClaimCondition[] claimConditions, bool resetEligibility); /** * @notice Lets an account claim a given quantity of NFTs. * * @param receiver The receiver of the NFTs to claim. * @param quantity The quantity of NFTs to claim. * @param currency The currency in which to pay for the claim. * @param pricePerToken The price per token to pay for the claim. * @param allowlistProof The proof of the claimer's inclusion in the merkle root allowlist * of the claim conditions that apply. * @param data Arbitrary bytes data that can be leveraged in the implementation of this interface. */ function claim( address receiver, uint256 quantity, address currency, uint256 pricePerToken, AllowlistProof calldata allowlistProof, bytes memory data ) external payable; /** * @notice Lets a contract admin (account with `DEFAULT_ADMIN_ROLE`) set claim conditions. * * @param phases Claim conditions in ascending order by `startTimestamp`. * * @param resetClaimEligibility Whether to honor the restrictions applied to wallets who have claimed tokens in the current conditions, * in the new claim conditions being set. * */ function setClaimConditions(ClaimCondition[] calldata phases, bool resetClaimEligibility) external; }
contracts/eip/queryable/ERC721A__InitializableStorage.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev This is a base storage for the initialization function for upgradeable diamond facet contracts **/ library ERC721A__InitializableStorage { struct Layout { /* * Indicates that the contract has been initialized. */ bool _initialized; /* * Indicates that the contract is in the process of being initialized. */ bool _initializing; } bytes32 internal constant STORAGE_SLOT = keccak256("ERC721A.contracts.storage.initializable.facet"); function layout() internal pure returns (Layout storage l) { bytes32 slot = STORAGE_SLOT; assembly { l.slot := slot } } }
contracts/eip/queryable/ERC721A__Initializable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev This is a base contract to aid in writing upgradeable diamond facet 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. * * 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. */ import { ERC721A__InitializableStorage } from "./ERC721A__InitializableStorage.sol"; abstract contract ERC721A__Initializable { using ERC721A__InitializableStorage for ERC721A__InitializableStorage.Layout; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializerERC721A() { // If the contract is initializing we ignore whether _initialized is set in order to support multiple // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the // contract may have been reentered. require( ERC721A__InitializableStorage.layout()._initializing ? _isConstructor() : !ERC721A__InitializableStorage.layout()._initialized, "ERC721A__Initializable: contract is already initialized" ); bool isTopLevelCall = !ERC721A__InitializableStorage.layout()._initializing; if (isTopLevelCall) { ERC721A__InitializableStorage.layout()._initializing = true; ERC721A__InitializableStorage.layout()._initialized = true; } _; if (isTopLevelCall) { ERC721A__InitializableStorage.layout()._initializing = false; } } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} modifier, directly or indirectly. */ modifier onlyInitializingERC721A() { require( ERC721A__InitializableStorage.layout()._initializing, "ERC721A__Initializable: contract is not initializing" ); _; } /// @dev Returns true if and only if the function is running in the constructor function _isConstructor() private view returns (bool) { // extcodesize checks the size of the code stored in an address, and // address returns the current address. Since the code is still not // deployed when running a constructor, any checks on its code size will // yield zero, making it an effective way to detect if a contract is // under construction or not. address self = address(this); uint256 cs; assembly { cs := extcodesize(self) } return cs == 0; } }
contracts/eip/queryable/ERC721AStorage.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library ERC721AStorage { // Bypass for a `--via-ir` bug (https://github.com/chiru-labs/ERC721A/pull/364). struct TokenApprovalRef { address value; } struct Layout { // ============================================================= // STORAGE // ============================================================= // The next token ID to be minted. uint256 _currentIndex; // The number of tokens burned. uint256 _burnCounter; // Token name string _name; // Token symbol string _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. // See {_packedOwnershipOf} implementation for details. // // Bits Layout: // - [0..159] `addr` // - [160..223] `startTimestamp` // - [224] `burned` // - [225] `nextInitialized` // - [232..255] `extraData` mapping(uint256 => uint256) _packedOwnerships; // Mapping owner address to address data. // // Bits Layout: // - [0..63] `balance` // - [64..127] `numberMinted` // - [128..191] `numberBurned` // - [192..255] `aux` mapping(address => uint256) _packedAddressData; // Mapping from token ID to approved address. mapping(uint256 => ERC721AStorage.TokenApprovalRef) _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) _operatorApprovals; } bytes32 internal constant STORAGE_SLOT = keccak256("ERC721A.contracts.storage.ERC721A"); function layout() internal pure returns (Layout storage l) { bytes32 slot = STORAGE_SLOT; assembly { l.slot := slot } } }
contracts/extension/Royalty.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb import "./interface/IRoyalty.sol"; /** * @title Royalty * @notice Thirdweb's `Royalty` is a contract extension to be used with any base contract. It exposes functions for setting and reading * the recipient of royalty fee and the royalty fee basis points, and lets the inheriting contract perform conditional logic * that uses information about royalty fees, if desired. * * @dev The `Royalty` contract is ERC2981 compliant. */ abstract contract Royalty is IRoyalty { /// @dev The (default) address that receives all royalty value. address private royaltyRecipient; /// @dev The (default) % of a sale to take as royalty (in basis points). uint16 private royaltyBps; /// @dev Token ID => royalty recipient and bps for token mapping(uint256 => RoyaltyInfo) private royaltyInfoForToken; /** * @notice View royalty info for a given token and sale price. * @dev Returns royalty amount and recipient for `tokenId` and `salePrice`. * @param tokenId The tokenID of the NFT for which to query royalty info. * @param salePrice Sale price of the token. * * @return receiver Address of royalty recipient account. * @return royaltyAmount Royalty amount calculated at current royaltyBps value. */ function royaltyInfo( uint256 tokenId, uint256 salePrice ) external view virtual override returns (address receiver, uint256 royaltyAmount) { (address recipient, uint256 bps) = getRoyaltyInfoForToken(tokenId); receiver = recipient; royaltyAmount = (salePrice * bps) / 10_000; } /** * @notice View royalty info for a given token. * @dev Returns royalty recipient and bps for `_tokenId`. * @param _tokenId The tokenID of the NFT for which to query royalty info. */ function getRoyaltyInfoForToken(uint256 _tokenId) public view override returns (address, uint16) { RoyaltyInfo memory royaltyForToken = royaltyInfoForToken[_tokenId]; return royaltyForToken.recipient == address(0) ? (royaltyRecipient, uint16(royaltyBps)) : (royaltyForToken.recipient, uint16(royaltyForToken.bps)); } /** * @notice Returns the defualt royalty recipient and BPS for this contract's NFTs. */ function getDefaultRoyaltyInfo() external view override returns (address, uint16) { return (royaltyRecipient, uint16(royaltyBps)); } /** * @notice Updates default royalty recipient and bps. * @dev Caller should be authorized to set royalty info. * See {_canSetRoyaltyInfo}. * Emits {DefaultRoyalty Event}; See {_setupDefaultRoyaltyInfo}. * * @param _royaltyRecipient Address to be set as default royalty recipient. * @param _royaltyBps Updated royalty bps. */ function setDefaultRoyaltyInfo(address _royaltyRecipient, uint256 _royaltyBps) external override { if (!_canSetRoyaltyInfo()) { revert("Not authorized"); } _setupDefaultRoyaltyInfo(_royaltyRecipient, _royaltyBps); } /// @dev Lets a contract admin update the default royalty recipient and bps. function _setupDefaultRoyaltyInfo(address _royaltyRecipient, uint256 _royaltyBps) internal { if (_royaltyBps > 10_000) { revert("Exceeds max bps"); } royaltyRecipient = _royaltyRecipient; royaltyBps = uint16(_royaltyBps); emit DefaultRoyalty(_royaltyRecipient, _royaltyBps); } /** * @notice Updates default royalty recipient and bps for a particular token. * @dev Sets royalty info for `_tokenId`. Caller should be authorized to set royalty info. * See {_canSetRoyaltyInfo}. * Emits {RoyaltyForToken Event}; See {_setupRoyaltyInfoForToken}. * * @param _recipient Address to be set as royalty recipient for given token Id. * @param _bps Updated royalty bps for the token Id. */ function setRoyaltyInfoForToken(uint256 _tokenId, address _recipient, uint256 _bps) external override { if (!_canSetRoyaltyInfo()) { revert("Not authorized"); } _setupRoyaltyInfoForToken(_tokenId, _recipient, _bps); } /// @dev Lets a contract admin set the royalty recipient and bps for a particular token Id. function _setupRoyaltyInfoForToken(uint256 _tokenId, address _recipient, uint256 _bps) internal { if (_bps > 10_000) { revert("Exceeds max bps"); } royaltyInfoForToken[_tokenId] = RoyaltyInfo({ recipient: _recipient, bps: _bps }); emit RoyaltyForToken(_tokenId, _recipient, _bps); } /// @dev Returns whether royalty info can be set in the given execution context. function _canSetRoyaltyInfo() internal view virtual returns (bool); }
contracts/lib/Strings.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { 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_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /// @dev Returns the hexadecimal representation of `value`. /// The output is prefixed with "0x", encoded using 2 hexadecimal digits per byte, /// and the alphabets are capitalized conditionally according to /// https://eips.ethereum.org/EIPS/eip-55 function toHexStringChecksummed(address value) internal pure returns (string memory str) { str = toHexString(value); /// @solidity memory-safe-assembly assembly { let mask := shl(6, div(not(0), 255)) // `0b010000000100000000 ...` let o := add(str, 0x22) let hashed := and(keccak256(o, 40), mul(34, mask)) // `0b10001000 ... ` let t := shl(240, 136) // `0b10001000 << 240` for { let i := 0 } 1 { } { mstore(add(i, i), mul(t, byte(i, hashed))) i := add(i, 1) if eq(i, 20) { break } } mstore(o, xor(mload(o), shr(1, and(mload(0x00), and(mload(o), mask))))) o := add(o, 0x20) mstore(o, xor(mload(o), shr(1, and(mload(0x20), and(mload(o), mask))))) } } /// @dev Returns the hexadecimal representation of `value`. /// The output is prefixed with "0x" and encoded using 2 hexadecimal digits per byte. function toHexString(address value) internal pure returns (string memory str) { str = toHexStringNoPrefix(value); /// @solidity memory-safe-assembly assembly { let strLength := add(mload(str), 2) // Compute the length. mstore(str, 0x3078) // Write the "0x" prefix. str := sub(str, 2) // Move the pointer. mstore(str, strLength) // Write the length. } } /// @dev Returns the hexadecimal representation of `value`. /// The output is encoded using 2 hexadecimal digits per byte. function toHexStringNoPrefix(address value) internal pure returns (string memory str) { /// @solidity memory-safe-assembly assembly { str := mload(0x40) // Allocate the memory. // We need 0x20 bytes for the trailing zeros padding, 0x20 bytes for the length, // 0x02 bytes for the prefix, and 0x28 bytes for the digits. // The next multiple of 0x20 above (0x20 + 0x20 + 0x02 + 0x28) is 0x80. mstore(0x40, add(str, 0x80)) // Store "0123456789abcdef" in scratch space. mstore(0x0f, 0x30313233343536373839616263646566) str := add(str, 2) mstore(str, 40) let o := add(str, 0x20) mstore(add(o, 40), 0) value := shl(96, value) // We write the string from rightmost digit to leftmost digit. // The following is essentially a do-while loop that also handles the zero case. for { let i := 0 } 1 { } { let p := add(o, add(i, i)) let temp := byte(i, value) mstore8(add(p, 1), mload(and(temp, 15))) mstore8(p, mload(shr(4, temp))) i := add(i, 1) if eq(i, 20) { break } } } } /// @dev Returns the hex encoded string from the raw bytes. /// The output is encoded using 2 hexadecimal digits per byte. function toHexString(bytes memory raw) internal pure returns (string memory str) { str = toHexStringNoPrefix(raw); /// @solidity memory-safe-assembly assembly { let strLength := add(mload(str), 2) // Compute the length. mstore(str, 0x3078) // Write the "0x" prefix. str := sub(str, 2) // Move the pointer. mstore(str, strLength) // Write the length. } } /// @dev Returns the hex encoded string from the raw bytes. /// The output is encoded using 2 hexadecimal digits per byte. function toHexStringNoPrefix(bytes memory raw) internal pure returns (string memory str) { /// @solidity memory-safe-assembly assembly { let length := mload(raw) str := add(mload(0x40), 2) // Skip 2 bytes for the optional prefix. mstore(str, add(length, length)) // Store the length of the output. // Store "0123456789abcdef" in scratch space. mstore(0x0f, 0x30313233343536373839616263646566) let o := add(str, 0x20) let end := add(raw, length) for { } iszero(eq(raw, end)) { } { raw := add(raw, 1) mstore8(add(o, 1), mload(and(mload(raw), 15))) mstore8(o, mload(and(shr(4, mload(raw)), 15))) o := add(o, 2) } mstore(o, 0) // Zeroize the slot after the string. mstore(0x40, add(o, 0x20)) // Allocate the memory. } } }
contracts/lib/NFTMetadataRenderer.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /* solhint-disable quotes */ /// @author thirdweb /// credits: Zora import "./Strings.sol"; import "../external-deps/openzeppelin/utils/Base64.sol"; /// NFT metadata library for rendering metadata associated with editions library NFTMetadataRenderer { /** * @notice Generate edition metadata from storage information as base64-json blob * @dev Combines the media data and metadata * @param name Name of NFT in metadata * @param description Description of NFT in metadata * @param imageURI URI of image to render for edition * @param animationURI URI of animation to render for edition * @param tokenOfEdition Token ID for specific token */ function createMetadataEdition( string memory name, string memory description, string memory imageURI, string memory animationURI, uint256 tokenOfEdition ) internal pure returns (string memory) { string memory _tokenMediaData = tokenMediaData(imageURI, animationURI); bytes memory json = createMetadataJSON(name, description, _tokenMediaData, tokenOfEdition); return encodeMetadataJSON(json); } /** * @param name Name of NFT in metadata * @param description Description of NFT in metadata * @param mediaData Data for media to include in json object * @param tokenOfEdition Token ID for specific token */ function createMetadataJSON( string memory name, string memory description, string memory mediaData, uint256 tokenOfEdition ) internal pure returns (bytes memory) { return abi.encodePacked( '{"name": "', name, " ", Strings.toString(tokenOfEdition), '", "', 'description": "', description, '", "', mediaData, 'properties": {"number": ', Strings.toString(tokenOfEdition), ', "name": "', name, '"}}' ); } /// Encodes the argument json bytes into base64-data uri format /// @param json Raw json to base64 and turn into a data-uri function encodeMetadataJSON(bytes memory json) internal pure returns (string memory) { return string(abi.encodePacked("data:application/json;base64,", Base64.encode(json))); } /// Generates edition metadata from storage information as base64-json blob /// Combines the media data and metadata /// @param imageUrl URL of image to render for edition /// @param animationUrl URL of animation to render for edition function tokenMediaData(string memory imageUrl, string memory animationUrl) internal pure returns (string memory) { bool hasImage = bytes(imageUrl).length > 0; bool hasAnimation = bytes(animationUrl).length > 0; if (hasImage && hasAnimation) { return string(abi.encodePacked('image": "', imageUrl, '", "animation_url": "', animationUrl, '", "')); } if (hasImage) { return string(abi.encodePacked('image": "', imageUrl, '", "')); } if (hasAnimation) { return string(abi.encodePacked('animation_url": "', animationUrl, '", "')); } return ""; } }
contracts/lib/CurrencyTransferLib.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb // Helper interfaces import { IWETH } from "../infra/interface/IWETH.sol"; import { SafeERC20, IERC20 } from "../external-deps/openzeppelin/token/ERC20/utils/SafeERC20.sol"; library CurrencyTransferLib { using SafeERC20 for IERC20; /// @dev The address interpreted as native token of the chain. address public constant NATIVE_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; /// @dev Transfers a given amount of currency. function transferCurrency(address _currency, address _from, address _to, uint256 _amount) internal { if (_amount == 0) { return; } if (_currency == NATIVE_TOKEN) { safeTransferNativeToken(_to, _amount); } else { safeTransferERC20(_currency, _from, _to, _amount); } } /// @dev Transfers a given amount of currency. (With native token wrapping) function transferCurrencyWithWrapper( address _currency, address _from, address _to, uint256 _amount, address _nativeTokenWrapper ) internal { if (_amount == 0) { return; } if (_currency == NATIVE_TOKEN) { if (_from == address(this)) { // withdraw from weth then transfer withdrawn native token to recipient IWETH(_nativeTokenWrapper).withdraw(_amount); safeTransferNativeTokenWithWrapper(_to, _amount, _nativeTokenWrapper); } else if (_to == address(this)) { // store native currency in weth require(_amount == msg.value, "msg.value != amount"); IWETH(_nativeTokenWrapper).deposit{ value: _amount }(); } else { safeTransferNativeTokenWithWrapper(_to, _amount, _nativeTokenWrapper); } } else { safeTransferERC20(_currency, _from, _to, _amount); } } /// @dev Transfer `amount` of ERC20 token from `from` to `to`. function safeTransferERC20(address _currency, address _from, address _to, uint256 _amount) internal { if (_from == _to) { return; } if (_from == address(this)) { IERC20(_currency).safeTransfer(_to, _amount); } else { IERC20(_currency).safeTransferFrom(_from, _to, _amount); } } /// @dev Transfers `amount` of native token to `to`. function safeTransferNativeToken(address to, uint256 value) internal { // solhint-disable avoid-low-level-calls // slither-disable-next-line low-level-calls (bool success, ) = to.call{ value: value }(""); require(success, "native token transfer failed"); } /// @dev Transfers `amount` of native token to `to`. (With native token wrapping) function safeTransferNativeTokenWithWrapper(address to, uint256 value, address _nativeTokenWrapper) internal { // solhint-disable avoid-low-level-calls // slither-disable-next-line low-level-calls (bool success, ) = to.call{ value: value }(""); if (!success) { IWETH(_nativeTokenWrapper).deposit{ value: value }(); IERC20(_nativeTokenWrapper).safeTransfer(to, value); } } }
contracts/external-deps/openzeppelin/token/ERC20/utils/SafeERC20.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../../../../../eip/interface/IERC20.sol"; import { Address } from "@openzeppelin/contracts/utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
contracts/lib/MerkleProof.sol
// SPDX-License-Identifier: Apache 2.0 pragma solidity ^0.8.0; /// @author thirdweb library MerkleProof { function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool, uint256) { bytes32 computedHash = leaf; uint256 index = 0; for (uint256 i = 0; i < proof.length; i++) { index *= 2; bytes32 proofElement = proof[i]; if (computedHash <= proofElement) { // Hash(current computed hash + current element of the proof) computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); } else { // Hash(current element of the proof + current computed hash) computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); index += 1; } } // Check if the computed hash (root) is equal to the provided root return (computedHash == root, index); } }
contracts/external-deps/openzeppelin/utils/Base64.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Base64.sol) pragma solidity ^0.8.0; /** * @dev Provides a set of functions to operate with Base64 strings. * * _Available since v4.5._ */ 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, 32) // Run over the input, 3 bytes at a time for { let dataPtr := data let endPtr := add(data, mload(data)) } lt(dataPtr, endPtr) { } { // Advance 3 bytes dataPtr := add(dataPtr, 3) let input := mload(dataPtr) // To write each character, shift the 3 bytes (18 bits) chunk // 4 times in blocks of 6 bits for each character (18, 12, 6, 0) // and apply logical AND with 0x3F which is the number of // the previous character in the ASCII table prior to the Base64 Table // The result is then added to the table to get the character to write, // and finally write it in the result pointer but with a left shift // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits 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 } // 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; } }
contracts/extension/SharedMetadata.sol
// SPDX-License-Identifier: Apache 2.0 pragma solidity ^0.8.10; /// @author thirdweb import "../lib/NFTMetadataRenderer.sol"; import "./interface/ISharedMetadata.sol"; import "../eip/interface/IERC4906.sol"; abstract contract SharedMetadata is ISharedMetadata, IERC4906 { /// @notice Token metadata information SharedMetadataInfo public sharedMetadata; /// @notice Set shared metadata for NFTs function setSharedMetadata(SharedMetadataInfo calldata _metadata) external virtual { if (!_canSetSharedMetadata()) { revert("Not authorized"); } _setSharedMetadata(_metadata); } /** * @dev Sets shared metadata for NFTs. * @param _metadata common metadata for all tokens */ function _setSharedMetadata(SharedMetadataInfo calldata _metadata) internal { sharedMetadata = SharedMetadataInfo({ name: _metadata.name, description: _metadata.description, imageURI: _metadata.imageURI, animationURI: _metadata.animationURI }); emit BatchMetadataUpdate(0, type(uint256).max); emit SharedMetadataUpdated({ name: _metadata.name, description: _metadata.description, imageURI: _metadata.imageURI, animationURI: _metadata.animationURI }); } /** * @dev Token URI information getter * @param tokenId Token ID to get URI for */ function _getURIFromSharedMetadata(uint256 tokenId) internal view returns (string memory) { SharedMetadataInfo memory info = sharedMetadata; return NFTMetadataRenderer.createMetadataEdition({ name: info.name, description: info.description, imageURI: info.imageURI, animationURI: info.animationURI, tokenOfEdition: tokenId }); } /// @dev Returns whether shared metadata can be set in the given execution context. function _canSetSharedMetadata() internal view virtual returns (bool); }
lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../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; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
contracts/extension/interface/IClaimConditionMultiPhase.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb import "./IClaimCondition.sol"; /** * The interface `IClaimConditionMultiPhase` is written for thirdweb's 'Drop' contracts, which are distribution mechanisms for tokens. * * An authorized wallet can set a series of claim conditions, ordered by their respective `startTimestamp`. * A claim condition defines criteria under which accounts can mint tokens. Claim conditions can be overwritten * or added to by the contract admin. At any moment, there is only one active claim condition. */ interface IClaimConditionMultiPhase is IClaimCondition { /** * @notice The set of all claim conditions, at any given moment. * Claim Phase ID = [currentStartId, currentStartId + length - 1]; * * @param currentStartId The uid for the first claim condition amongst the current set of * claim conditions. The uid for each next claim condition is one * more than the previous claim condition's uid. * * @param count The total number of phases / claim conditions in the list * of claim conditions. * * @param conditions The claim conditions at a given uid. Claim conditions * are ordered in an ascending order by their `startTimestamp`. * * @param supplyClaimedByWallet Map from a claim condition uid and account to supply claimed by account. */ struct ClaimConditionList { uint256 currentStartId; uint256 count; mapping(uint256 => ClaimCondition) conditions; mapping(uint256 => mapping(address => uint256)) supplyClaimedByWallet; } }
contracts/extension/interface/IContractMetadata.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb /** * Thirdweb's `ContractMetadata` is a contract extension for any base contracts. It lets you set a metadata URI * for you contract. * * Additionally, `ContractMetadata` is necessary for NFT contracts that want royalties to get distributed on OpenSea. */ interface IContractMetadata { /// @dev Returns the metadata URI of the contract. function contractURI() external view returns (string memory); /** * @dev Sets contract URI for the storefront-level metadata of the contract. * Only module admin can call this function. */ function setContractURI(string calldata _uri) external; /// @dev Emitted when the contract URI is updated. event ContractURIUpdated(string prevURI, string newURI); }
contracts/extension/interface/IMulticall.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author thirdweb /** * @dev Provides a function to batch together multiple calls in a single external call. * * _Available since v4.1._ */ interface IMulticall { /** * @dev Receives and executes a batch of function calls on this contract. */ function multicall(bytes[] calldata data) external returns (bytes[] memory results); }
contracts/extension/Ownable.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb import "./interface/IOwnable.sol"; /** * @title Ownable * @notice Thirdweb's `Ownable` is a contract extension to be used with any base contract. It exposes functions for setting and reading * who the 'owner' of the inheriting smart contract is, and lets the inheriting contract perform conditional logic that uses * information about who the contract's owner is. */ abstract contract Ownable is IOwnable { /// @dev Owner of the contract (purpose: OpenSea compatibility) address private _owner; /// @dev Reverts if caller is not the owner. modifier onlyOwner() { if (msg.sender != _owner) { revert("Not authorized"); } _; } /** * @notice Returns the owner of the contract. */ function owner() public view override returns (address) { return _owner; } /** * @notice Lets an authorized wallet set a new owner for the contract. * @param _newOwner The address to set as the new owner of the contract. */ function setOwner(address _newOwner) external override { if (!_canSetOwner()) { revert("Not authorized"); } _setupOwner(_newOwner); } /// @dev Lets a contract admin set a new owner for the contract. The new owner must be a contract admin. function _setupOwner(address _newOwner) internal { address _prevOwner = _owner; _owner = _newOwner; emit OwnerUpdated(_prevOwner, _newOwner); } /// @dev Returns whether owner can be set in the given execution context. function _canSetOwner() internal view virtual returns (bool); }
contracts/eip/queryable/IERC721AUpgradeable.sol
// SPDX-License-Identifier: MIT // ERC721A Contracts v4.2.3 // Creator: Chiru Labs pragma solidity ^0.8.4; /** * @dev Interface of ERC721A. */ interface IERC721AUpgradeable { /** * The caller must own the token or be an approved operator. */ error ApprovalCallerNotOwnerNorApproved(); /** * The token does not exist. */ error ApprovalQueryForNonexistentToken(); /** * Cannot query the balance for the zero address. */ error BalanceQueryForZeroAddress(); /** * Cannot mint to the zero address. */ error MintToZeroAddress(); /** * The quantity of tokens minted must be more than zero. */ error MintZeroQuantity(); /** * The token does not exist. */ error OwnerQueryForNonexistentToken(); /** * The caller must own the token or be an approved operator. */ error TransferCallerNotOwnerNorApproved(); /** * The token must be owned by `from`. */ error TransferFromIncorrectOwner(); /** * Cannot safely transfer to a contract that does not implement the * ERC721Receiver interface. */ error TransferToNonERC721ReceiverImplementer(); /** * Cannot transfer to the zero address. */ error TransferToZeroAddress(); /** * The token does not exist. */ error URIQueryForNonexistentToken(); /** * The `quantity` minted with ERC2309 exceeds the safety limit. */ error MintERC2309QuantityExceedsLimit(); /** * The `extraData` cannot be set on an unintialized ownership slot. */ error OwnershipNotInitializedForExtraData(); // ============================================================= // STRUCTS // ============================================================= struct TokenOwnership { // The address of the owner. address addr; // Stores the start time of ownership with minimal overhead for tokenomics. uint64 startTimestamp; // Whether the token has been burned. bool burned; // Arbitrary data similar to `startTimestamp` that can be set via {_extraData}. uint24 extraData; } // ============================================================= // TOKEN COUNTERS // ============================================================= /** * @dev Returns the total number of tokens in existence. * Burned tokens will reduce the count. * To get the total number of tokens minted, please see {_totalMinted}. */ function totalSupply() external view returns (uint256); // ============================================================= // IERC165 // ============================================================= /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) * to learn more about how these ids are created. * * This function call must use less than 30000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); // ============================================================= // IERC721 // ============================================================= /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables * (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in `owner`'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, * checking first that contract recipients are aware of the ERC721 protocol * to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move * this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external payable; /** * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`. */ function safeTransferFrom(address from, address to, uint256 tokenId) external payable; /** * @dev Transfers `tokenId` from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} * whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token * by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external payable; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the * zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external payable; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} * for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll}. */ function isApprovedForAll(address owner, address operator) external view returns (bool); // ============================================================= // IERC721Metadata // ============================================================= /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); // ============================================================= // IERC2309 // ============================================================= /** * @dev Emitted when tokens in `fromTokenId` to `toTokenId` * (inclusive) is transferred from `from` to `to`, as defined in the * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309) standard. * * See {_mintERC2309} for more details. */ event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to); }
contracts/extension/interface/IOwnable.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb /** * Thirdweb's `Ownable` is a contract extension to be used with any base contract. It exposes functions for setting and reading * who the 'owner' of the inheriting smart contract is, and lets the inheriting contract perform conditional logic that uses * information about who the contract's owner is. */ interface IOwnable { /// @dev Returns the owner of the contract. function owner() external view returns (address); /// @dev Lets a module admin set a new owner for the contract. The new owner must be a module admin. function setOwner(address _newOwner) external; /// @dev Emitted when a new Owner is set. event OwnerUpdated(address indexed prevOwner, address indexed newOwner); }
contracts/extension/Drop.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb import "./interface/IDrop.sol"; import "../lib/MerkleProof.sol"; abstract contract Drop is IDrop { /*/////////////////////////////////////////////////////////////// State variables //////////////////////////////////////////////////////////////*/ /// @dev The active conditions for claiming tokens. ClaimConditionList public claimCondition; /*/////////////////////////////////////////////////////////////// Drop logic //////////////////////////////////////////////////////////////*/ /// @dev Lets an account claim tokens. function claim( address _receiver, uint256 _quantity, address _currency, uint256 _pricePerToken, AllowlistProof calldata _allowlistProof, bytes memory _data ) public payable virtual override { _beforeClaim(_receiver, _quantity, _currency, _pricePerToken, _allowlistProof, _data); uint256 activeConditionId = getActiveClaimConditionId(); verifyClaim(activeConditionId, _dropMsgSender(), _quantity, _currency, _pricePerToken, _allowlistProof); // Update contract state. claimCondition.conditions[activeConditionId].supplyClaimed += _quantity; claimCondition.supplyClaimedByWallet[activeConditionId][_dropMsgSender()] += _quantity; // If there's a price, collect price. _collectPriceOnClaim(address(0), _quantity, _currency, _pricePerToken); // Mint the relevant tokens to claimer. uint256 startTokenId = _transferTokensOnClaim(_receiver, _quantity); emit TokensClaimed(activeConditionId, _dropMsgSender(), _receiver, startTokenId, _quantity); _afterClaim(_receiver, _quantity, _currency, _pricePerToken, _allowlistProof, _data); } /// @dev Lets a contract admin set claim conditions. function setClaimConditions( ClaimCondition[] calldata _conditions, bool _resetClaimEligibility ) external virtual override { if (!_canSetClaimConditions()) { revert("Not authorized"); } uint256 existingStartIndex = claimCondition.currentStartId; uint256 existingPhaseCount = claimCondition.count; /** * The mapping `supplyClaimedByWallet` uses a claim condition's UID as a key. * * If `_resetClaimEligibility == true`, we assign completely new UIDs to the claim * conditions in `_conditions`, effectively resetting the restrictions on claims expressed * by `supplyClaimedByWallet`. */ uint256 newStartIndex = existingStartIndex; if (_resetClaimEligibility) { newStartIndex = existingStartIndex + existingPhaseCount; } claimCondition.count = _conditions.length; claimCondition.currentStartId = newStartIndex; uint256 lastConditionStartTimestamp; for (uint256 i = 0; i < _conditions.length; i++) { require(i == 0 || lastConditionStartTimestamp < _conditions[i].startTimestamp, "ST"); uint256 supplyClaimedAlready = claimCondition.conditions[newStartIndex + i].supplyClaimed; if (supplyClaimedAlready > _conditions[i].maxClaimableSupply) { revert("max supply claimed"); } claimCondition.conditions[newStartIndex + i] = _conditions[i]; claimCondition.conditions[newStartIndex + i].supplyClaimed = supplyClaimedAlready; lastConditionStartTimestamp = _conditions[i].startTimestamp; } /** * Gas refunds (as much as possible) * * If `_resetClaimEligibility == true`, we assign completely new UIDs to the claim * conditions in `_conditions`. So, we delete claim conditions with UID < `newStartIndex`. * * If `_resetClaimEligibility == false`, and there are more existing claim conditions * than in `_conditions`, we delete the existing claim conditions that don't get replaced * by the conditions in `_conditions`. */ if (_resetClaimEligibility) { for (uint256 i = existingStartIndex; i < newStartIndex; i++) { delete claimCondition.conditions[i]; } } else { if (existingPhaseCount > _conditions.length) { for (uint256 i = _conditions.length; i < existingPhaseCount; i++) { delete claimCondition.conditions[newStartIndex + i]; } } } emit ClaimConditionsUpdated(_conditions, _resetClaimEligibility); } /// @dev Checks a request to claim NFTs against the active claim condition's criteria. function verifyClaim( uint256 _conditionId, address _claimer, uint256 _quantity, address _currency, uint256 _pricePerToken, AllowlistProof calldata _allowlistProof ) public view virtual returns (bool isOverride) { ClaimCondition memory currentClaimPhase = claimCondition.conditions[_conditionId]; uint256 claimLimit = currentClaimPhase.quantityLimitPerWallet; uint256 claimPrice = currentClaimPhase.pricePerToken; address claimCurrency = currentClaimPhase.currency; /* * Here `isOverride` implies that if the merkle proof verification fails, * the claimer would claim through open claim limit instead of allowlisted limit. */ if (currentClaimPhase.merkleRoot != bytes32(0)) { (isOverride, ) = MerkleProof.verify( _allowlistProof.proof, currentClaimPhase.merkleRoot, keccak256( abi.encodePacked( _claimer, _allowlistProof.quantityLimitPerWallet, _allowlistProof.pricePerToken, _allowlistProof.currency ) ) ); } if (isOverride) { claimLimit = _allowlistProof.quantityLimitPerWallet != 0 ? _allowlistProof.quantityLimitPerWallet : claimLimit; claimPrice = _allowlistProof.pricePerToken != type(uint256).max ? _allowlistProof.pricePerToken : claimPrice; claimCurrency = _allowlistProof.pricePerToken != type(uint256).max && _allowlistProof.currency != address(0) ? _allowlistProof.currency : claimCurrency; } uint256 supplyClaimedByWallet = claimCondition.supplyClaimedByWallet[_conditionId][_claimer]; if (_currency != claimCurrency || _pricePerToken != claimPrice) { revert("!PriceOrCurrency"); } if (_quantity == 0 || (_quantity + supplyClaimedByWallet > claimLimit)) { revert("!Qty"); } if (currentClaimPhase.supplyClaimed + _quantity > currentClaimPhase.maxClaimableSupply) { revert("!MaxSupply"); } if (currentClaimPhase.startTimestamp > block.timestamp) { revert("cant claim yet"); } } /// @dev At any given moment, returns the uid for the active claim condition. function getActiveClaimConditionId() public view returns (uint256) { for (uint256 i = claimCondition.currentStartId + claimCondition.count; i > claimCondition.currentStartId; i--) { if (block.timestamp >= claimCondition.conditions[i - 1].startTimestamp) { return i - 1; } } revert("!CONDITION."); } /// @dev Returns the claim condition at the given uid. function getClaimConditionById(uint256 _conditionId) external view returns (ClaimCondition memory condition) { condition = claimCondition.conditions[_conditionId]; } /// @dev Returns the supply claimed by claimer for a given conditionId. function getSupplyClaimedByWallet( uint256 _conditionId, address _claimer ) public view returns (uint256 supplyClaimedByWallet) { supplyClaimedByWallet = claimCondition.supplyClaimedByWallet[_conditionId][_claimer]; } /*//////////////////////////////////////////////////////////////////// Optional hooks that can be implemented in the derived contract ///////////////////////////////////////////////////////////////////*/ /// @dev Exposes the ability to override the msg sender. function _dropMsgSender() internal virtual returns (address) { return msg.sender; } /// @dev Runs before every `claim` function call. function _beforeClaim( address _receiver, uint256 _quantity, address _currency, uint256 _pricePerToken, AllowlistProof calldata _allowlistProof, bytes memory _data ) internal virtual {} /// @dev Runs after every `claim` function call. function _afterClaim( address _receiver, uint256 _quantity, address _currency, uint256 _pricePerToken, AllowlistProof calldata _allowlistProof, bytes memory _data ) internal virtual {} /*/////////////////////////////////////////////////////////////// Virtual functions: to be implemented in derived contract //////////////////////////////////////////////////////////////*/ /// @dev Collects and distributes the primary sale value of NFTs being claimed. function _collectPriceOnClaim( address _primarySaleRecipient, uint256 _quantityToClaim, address _currency, uint256 _pricePerToken ) internal virtual; /// @dev Transfers the NFTs being claimed. function _transferTokensOnClaim( address _to, uint256 _quantityBeingClaimed ) internal virtual returns (uint256 startTokenId); /// @dev Determine what wallet can update claim conditions function _canSetClaimConditions() internal view virtual returns (bool); }
contracts/eip/queryable/ERC721AQueryableUpgradeable.sol
// SPDX-License-Identifier: MIT // ERC721A Contracts v4.2.3 // Creator: Chiru Labs pragma solidity ^0.8.4; import "./IERC721AQueryableUpgradeable.sol"; import "./ERC721AUpgradeable.sol"; import "./ERC721A__Initializable.sol"; /** * @title ERC721AQueryable. * * @dev ERC721A subclass with convenience query functions. */ abstract contract ERC721AQueryableUpgradeable is ERC721A__Initializable, ERC721AUpgradeable, IERC721AQueryableUpgradeable { function __ERC721AQueryable_init() internal onlyInitializingERC721A { __ERC721AQueryable_init_unchained(); } function __ERC721AQueryable_init_unchained() internal onlyInitializingERC721A {} /** * @dev Returns the `TokenOwnership` struct at `tokenId` without reverting. * * If the `tokenId` is out of bounds: * * - `addr = address(0)` * - `startTimestamp = 0` * - `burned = false` * - `extraData = 0` * * If the `tokenId` is burned: * * - `addr = <Address of owner before token was burned>` * - `startTimestamp = <Timestamp when token was burned>` * - `burned = true` * - `extraData = <Extra data when token was burned>` * * Otherwise: * * - `addr = <Address of owner>` * - `startTimestamp = <Timestamp of start of ownership>` * - `burned = false` * - `extraData = <Extra data at start of ownership>` */ function explicitOwnershipOf( uint256 tokenId ) public view virtual override returns (TokenOwnership memory ownership) { unchecked { if (tokenId >= _startTokenId()) { if (tokenId < _nextTokenId()) { // If the `tokenId` is within bounds, // scan backwards for the initialized ownership slot. while (!_ownershipIsInitialized(tokenId)) --tokenId; return _ownershipAt(tokenId); } } } } /** * @dev Returns an array of token IDs owned by `owner`, * in the range [`start`, `stop`) * (i.e. `start <= tokenId < stop`). * * This function allows for tokens to be queried if the collection * grows too big for a single call of {ERC721AQueryable-tokensOfOwner}. * * Requirements: * * - `start < stop` */ function tokensOfOwnerIn( address owner, uint256 start, uint256 stop ) external view virtual override returns (uint256[] memory) { return _tokensOfOwnerIn(owner, start, stop); } /** * @dev Returns an array of token IDs owned by `owner`. * * This function scans the ownership mapping and is O(`totalSupply`) in complexity. * It is meant to be called off-chain. * * See {ERC721AQueryable-tokensOfOwnerIn} for splitting the scan into * multiple smaller scans if the collection is large enough to cause * an out-of-gas error (10K collections should be fine). */ function tokensOfOwner(address owner) external view virtual override returns (uint256[] memory) { uint256 start = _startTokenId(); uint256 stop = _nextTokenId(); uint256[] memory tokenIds; if (start != stop) tokenIds = _tokensOfOwnerIn(owner, start, stop); return tokenIds; } /** * @dev Helper function for returning an array of token IDs owned by `owner`. * * Note that this function is optimized for smaller bytecode size over runtime gas, * since it is meant to be called off-chain. */ function _tokensOfOwnerIn(address owner, uint256 start, uint256 stop) private view returns (uint256[] memory) { unchecked { if (start >= stop) _revert(InvalidQueryRange.selector); // Set `start = max(start, _startTokenId())`. if (start < _startTokenId()) { start = _startTokenId(); } uint256 stopLimit = _nextTokenId(); // Set `stop = min(stop, stopLimit)`. if (stop >= stopLimit) { stop = stopLimit; } uint256[] memory tokenIds; uint256 tokenIdsMaxLength = balanceOf(owner); bool startLtStop = start < stop; assembly { // Set `tokenIdsMaxLength` to zero if `start` is less than `stop`. tokenIdsMaxLength := mul(tokenIdsMaxLength, startLtStop) } if (tokenIdsMaxLength != 0) { // Set `tokenIdsMaxLength = min(balanceOf(owner), stop - start)`, // to cater for cases where `balanceOf(owner)` is too big. if (stop - start <= tokenIdsMaxLength) { tokenIdsMaxLength = stop - start; } assembly { // Grab the free memory pointer. tokenIds := mload(0x40) // Allocate one word for the length, and `tokenIdsMaxLength` words // for the data. `shl(5, x)` is equivalent to `mul(32, x)`. mstore(0x40, add(tokenIds, shl(5, add(tokenIdsMaxLength, 1)))) } // We need to call `explicitOwnershipOf(start)`, // because the slot at `start` may not be initialized. TokenOwnership memory ownership = explicitOwnershipOf(start); address currOwnershipAddr; // If the starting slot exists (i.e. not burned), // initialize `currOwnershipAddr`. // `ownership.address` will not be zero, // as `start` is clamped to the valid token ID range. if (!ownership.burned) { currOwnershipAddr = ownership.addr; } uint256 tokenIdsIdx; // Use a do-while, which is slightly more efficient for this case, // as the array will at least contain one element. do { ownership = _ownershipAt(start); assembly { switch mload(add(ownership, 0x40)) // if `ownership.burned == false`. case 0 { // if `ownership.addr != address(0)`. // The `addr` already has it's upper 96 bits clearned, // since it is written to memory with regular Solidity. if mload(ownership) { currOwnershipAddr := mload(ownership) } // if `currOwnershipAddr == owner`. // The `shl(96, x)` is to make the comparison agnostic to any // dirty upper 96 bits in `owner`. if iszero(shl(96, xor(currOwnershipAddr, owner))) { tokenIdsIdx := add(tokenIdsIdx, 1) mstore(add(tokenIds, shl(5, tokenIdsIdx)), start) } } // Otherwise, reset `currOwnershipAddr`. // This handles the case of batch burned tokens // (burned bit of first slot set, remaining slots left uninitialized). default { currOwnershipAddr := 0 } start := add(start, 1) } } while (!(start == stop || tokenIdsIdx == tokenIdsMaxLength)); // Store the length of the array. assembly { mstore(tokenIds, tokenIdsIdx) } } return tokenIds; } } }
lib/openzeppelin-contracts-upgradeable/contracts/utils/math/MathUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library MathUpgradeable { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @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 up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (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; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) 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. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 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. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); 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 (rounding == Rounding.Up && 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 down. * * 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 + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * 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 + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * 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 + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * 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 + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0); } } }
contracts/external-deps/openzeppelin/metatx/ERC2771ContextUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (metatx/ERC2771Context.sol) pragma solidity ^0.8.11; import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; /** * @dev Context variant with ERC2771 support. */ abstract contract ERC2771ContextUpgradeable is Initializable, ContextUpgradeable { mapping(address => bool) private _trustedForwarder; function __ERC2771Context_init(address[] memory trustedForwarder) internal onlyInitializing { __Context_init_unchained(); __ERC2771Context_init_unchained(trustedForwarder); } function __ERC2771Context_init_unchained(address[] memory trustedForwarder) internal onlyInitializing { for (uint256 i = 0; i < trustedForwarder.length; i++) { _trustedForwarder[trustedForwarder[i]] = true; } } function isTrustedForwarder(address forwarder) public view virtual returns (bool) { return _trustedForwarder[forwarder]; } function _msgSender() internal view virtual override returns (address sender) { if (isTrustedForwarder(msg.sender)) { // The assembly code is more direct than the Solidity version using `abi.decode`. assembly { sender := shr(96, calldataload(sub(calldatasize(), 20))) } } else { return super._msgSender(); } } function _msgData() internal view virtual override returns (bytes calldata) { if (isTrustedForwarder(msg.sender)) { return msg.data[:msg.data.length - 20]; } else { return super._msgData(); } } uint256[49] private __gap; }
contracts/eip/interface/IERC4906.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.11; import "./IERC165.sol"; import "./IERC721.sol"; interface IERC4906 is IERC165 { /// @dev This event emits when the metadata of a token is changed. /// So that the third-party platforms such as NFT market could /// timely update the images and related attributes of the NFT. event MetadataUpdate(uint256 _tokenId); /// @dev This event emits when the metadata of a range of tokens is changed. /// So that the third-party platforms such as NFT market could /// timely update the images and related attributes of the NFTs. event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId); }
contracts/extension/PrimarySale.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb import "./interface/IPrimarySale.sol"; /** * @title Primary Sale * @notice Thirdweb's `PrimarySale` is a contract extension to be used with any base contract. It exposes functions for setting and reading * the recipient of primary sales, and lets the inheriting contract perform conditional logic that uses information about * primary sales, if desired. */ abstract contract PrimarySale is IPrimarySale { /// @dev The address that receives all primary sales value. address private recipient; /// @dev Returns primary sale recipient address. function primarySaleRecipient() public view override returns (address) { return recipient; } /** * @notice Updates primary sale recipient. * @dev Caller should be authorized to set primary sales info. * See {_canSetPrimarySaleRecipient}. * Emits {PrimarySaleRecipientUpdated Event}; See {_setupPrimarySaleRecipient}. * * @param _saleRecipient Address to be set as new recipient of primary sales. */ function setPrimarySaleRecipient(address _saleRecipient) external override { if (!_canSetPrimarySaleRecipient()) { revert("Not authorized"); } _setupPrimarySaleRecipient(_saleRecipient); } /// @dev Lets a contract admin set the recipient for all primary sales. function _setupPrimarySaleRecipient(address _saleRecipient) internal { if (_saleRecipient == address(0)) { revert("Invalid recipient"); } recipient = _saleRecipient; emit PrimarySaleRecipientUpdated(_saleRecipient); } /// @dev Returns whether primary sale recipient can be set in the given execution context. function _canSetPrimarySaleRecipient() internal view virtual returns (bool); }
contracts/extension/Multicall.sol
// SPDX-License-Identifier: Apache 2.0 pragma solidity ^0.8.0; /// @author thirdweb import "../lib/Address.sol"; import "./interface/IMulticall.sol"; /** * @dev Provides a function to batch together multiple calls in a single external call. * * _Available since v4.1._ */ contract Multicall is IMulticall { /** * @notice Receives and executes a batch of function calls on this contract. * @dev Receives and executes a batch of function calls on this contract. * * @param data The bytes data that makes up the batch of function calls to execute. * @return results The bytes data that makes up the result of the batch of function calls executed. */ function multicall(bytes[] calldata data) external returns (bytes[] memory results) { results = new bytes[](data.length); address sender = _msgSender(); bool isForwarder = msg.sender != sender; for (uint256 i = 0; i < data.length; i++) { if (isForwarder) { results[i] = Address.functionDelegateCall(address(this), abi.encodePacked(data[i], sender)); } else { results[i] = Address.functionDelegateCall(address(this), data[i]); } } return results; } /// @notice Returns the sender in the given execution context. function _msgSender() internal view virtual returns (address) { return msg.sender; } }
lib/openzeppelin-contracts-upgradeable/contracts/utils/math/SignedMathUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.0; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMathUpgradeable { /** * @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); } } }
contracts/extension/interface/IPrimarySale.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb /** * Thirdweb's `Primary` is a contract extension to be used with any base contract. It exposes functions for setting and reading * the recipient of primary sales, and lets the inheriting contract perform conditional logic that uses information about * primary sales, if desired. */ interface IPrimarySale { /// @dev The adress that receives all primary sales value. function primarySaleRecipient() external view returns (address); /// @dev Lets a module admin set the default recipient of all primary sales. function setPrimarySaleRecipient(address _saleRecipient) external; /// @dev Emitted when a new sale recipient is set. event PrimarySaleRecipientUpdated(address indexed recipient); }
contracts/lib/Address.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.1; /// @author thirdweb, OpenZeppelin Contracts (v4.9.0) /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{ value: value }(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
lib/openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
Compiler Settings
{"remappings":["@chainlink/=lib/chainlink/","@ds-test/=lib/ds-test/src/","@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/","@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/","@std/=lib/forge-std/src/","@thirdweb-dev/dynamic-contracts/=lib/dynamic-contracts/","ERC721A-Upgradeable/=lib/ERC721A-Upgradeable/contracts/","ERC721A/=lib/ERC721A/contracts/","chainlink/=lib/chainlink/contracts/","contracts/=contracts/","ds-test/=lib/ds-test/src/","dynamic-contracts/=lib/dynamic-contracts/src/","erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/","erc721a-upgradeable/=lib/ERC721A-Upgradeable/","erc721a/=lib/ERC721A/","forge-std/=lib/forge-std/src/","lib/sstore2/=lib/dynamic-contracts/lib/sstore2/","openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/","openzeppelin-contracts/=lib/openzeppelin-contracts/","openzeppelin/=lib/openzeppelin-contracts-upgradeable/contracts/","sstore2/=lib/dynamic-contracts/lib/sstore2/contracts/"],"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers","metadata"],"":["ast"]}},"optimizer":{"runs":20,"enabled":true},"libraries":{},"evmVersion":"london"}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[]},{"type":"error","name":"ApprovalCallerNotOwnerNorApproved","inputs":[]},{"type":"error","name":"ApprovalQueryForNonexistentToken","inputs":[]},{"type":"error","name":"BalanceQueryForZeroAddress","inputs":[]},{"type":"error","name":"InvalidQueryRange","inputs":[]},{"type":"error","name":"MintERC2309QuantityExceedsLimit","inputs":[]},{"type":"error","name":"MintToZeroAddress","inputs":[]},{"type":"error","name":"MintZeroQuantity","inputs":[]},{"type":"error","name":"OwnerQueryForNonexistentToken","inputs":[]},{"type":"error","name":"OwnershipNotInitializedForExtraData","inputs":[]},{"type":"error","name":"TransferCallerNotOwnerNorApproved","inputs":[]},{"type":"error","name":"TransferFromIncorrectOwner","inputs":[]},{"type":"error","name":"TransferToNonERC721ReceiverImplementer","inputs":[]},{"type":"error","name":"TransferToZeroAddress","inputs":[]},{"type":"error","name":"URIQueryForNonexistentToken","inputs":[]},{"type":"event","name":"Approval","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"approved","internalType":"address","indexed":true},{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"ApprovalForAll","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"operator","internalType":"address","indexed":true},{"type":"bool","name":"approved","internalType":"bool","indexed":false}],"anonymous":false},{"type":"event","name":"BatchMetadataUpdate","inputs":[{"type":"uint256","name":"_fromTokenId","internalType":"uint256","indexed":false},{"type":"uint256","name":"_toTokenId","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ClaimConditionsUpdated","inputs":[{"type":"tuple[]","name":"claimConditions","internalType":"struct IClaimCondition.ClaimCondition[]","indexed":false,"components":[{"type":"uint256","name":"startTimestamp","internalType":"uint256"},{"type":"uint256","name":"maxClaimableSupply","internalType":"uint256"},{"type":"uint256","name":"supplyClaimed","internalType":"uint256"},{"type":"uint256","name":"quantityLimitPerWallet","internalType":"uint256"},{"type":"bytes32","name":"merkleRoot","internalType":"bytes32"},{"type":"uint256","name":"pricePerToken","internalType":"uint256"},{"type":"address","name":"currency","internalType":"address"},{"type":"string","name":"metadata","internalType":"string"}]},{"type":"bool","name":"resetEligibility","internalType":"bool","indexed":false}],"anonymous":false},{"type":"event","name":"ConsecutiveTransfer","inputs":[{"type":"uint256","name":"fromTokenId","internalType":"uint256","indexed":true},{"type":"uint256","name":"toTokenId","internalType":"uint256","indexed":false},{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"ContractURIUpdated","inputs":[{"type":"string","name":"prevURI","internalType":"string","indexed":false},{"type":"string","name":"newURI","internalType":"string","indexed":false}],"anonymous":false},{"type":"event","name":"DefaultRoyalty","inputs":[{"type":"address","name":"newRoyaltyRecipient","internalType":"address","indexed":true},{"type":"uint256","name":"newRoyaltyBps","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"type":"uint8","name":"version","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"MetadataUpdate","inputs":[{"type":"uint256","name":"_tokenId","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"OwnerUpdated","inputs":[{"type":"address","name":"prevOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"PrimarySaleRecipientUpdated","inputs":[{"type":"address","name":"recipient","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RoleAdminChanged","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"previousAdminRole","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"newAdminRole","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"RoleGranted","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RoleRevoked","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RoyaltyForToken","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":true},{"type":"address","name":"royaltyRecipient","internalType":"address","indexed":true},{"type":"uint256","name":"royaltyBps","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"SharedMetadataUpdated","inputs":[{"type":"string","name":"name","internalType":"string","indexed":false},{"type":"string","name":"description","internalType":"string","indexed":false},{"type":"string","name":"imageURI","internalType":"string","indexed":false},{"type":"string","name":"animationURI","internalType":"string","indexed":false}],"anonymous":false},{"type":"event","name":"TokensClaimed","inputs":[{"type":"uint256","name":"claimConditionIndex","internalType":"uint256","indexed":true},{"type":"address","name":"claimer","internalType":"address","indexed":true},{"type":"address","name":"receiver","internalType":"address","indexed":true},{"type":"uint256","name":"startTokenId","internalType":"uint256","indexed":false},{"type":"uint256","name":"quantityClaimed","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Transfer","inputs":[{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"DEFAULT_ADMIN_ROLE","inputs":[]},{"type":"function","stateMutability":"payable","outputs":[],"name":"approve","inputs":[{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceOf","inputs":[{"type":"address","name":"owner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"burn","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"claim","inputs":[{"type":"address","name":"_receiver","internalType":"address"},{"type":"uint256","name":"_quantity","internalType":"uint256"},{"type":"address","name":"_currency","internalType":"address"},{"type":"uint256","name":"_pricePerToken","internalType":"uint256"},{"type":"tuple","name":"_allowlistProof","internalType":"struct IDrop.AllowlistProof","components":[{"type":"bytes32[]","name":"proof","internalType":"bytes32[]"},{"type":"uint256","name":"quantityLimitPerWallet","internalType":"uint256"},{"type":"uint256","name":"pricePerToken","internalType":"uint256"},{"type":"address","name":"currency","internalType":"address"}]},{"type":"bytes","name":"_data","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"currentStartId","internalType":"uint256"},{"type":"uint256","name":"count","internalType":"uint256"}],"name":"claimCondition","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"contractURI","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"ownership","internalType":"struct IERC721AUpgradeable.TokenOwnership","components":[{"type":"address","name":"addr","internalType":"address"},{"type":"uint64","name":"startTimestamp","internalType":"uint64"},{"type":"bool","name":"burned","internalType":"bool"},{"type":"uint24","name":"extraData","internalType":"uint24"}]}],"name":"explicitOwnershipOf","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getActiveClaimConditionId","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getApproved","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"condition","internalType":"struct IClaimCondition.ClaimCondition","components":[{"type":"uint256","name":"startTimestamp","internalType":"uint256"},{"type":"uint256","name":"maxClaimableSupply","internalType":"uint256"},{"type":"uint256","name":"supplyClaimed","internalType":"uint256"},{"type":"uint256","name":"quantityLimitPerWallet","internalType":"uint256"},{"type":"bytes32","name":"merkleRoot","internalType":"bytes32"},{"type":"uint256","name":"pricePerToken","internalType":"uint256"},{"type":"address","name":"currency","internalType":"address"},{"type":"string","name":"metadata","internalType":"string"}]}],"name":"getClaimConditionById","inputs":[{"type":"uint256","name":"_conditionId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"},{"type":"uint16","name":"","internalType":"uint16"}],"name":"getDefaultRoyaltyInfo","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getRoleAdmin","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"member","internalType":"address"}],"name":"getRoleMember","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"uint256","name":"index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"count","internalType":"uint256"}],"name":"getRoleMemberCount","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"},{"type":"uint16","name":"","internalType":"uint16"}],"name":"getRoyaltyInfoForToken","inputs":[{"type":"uint256","name":"_tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"supplyClaimedByWallet","internalType":"uint256"}],"name":"getSupplyClaimedByWallet","inputs":[{"type":"uint256","name":"_conditionId","internalType":"uint256"},{"type":"address","name":"_claimer","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"grantRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasRoleWithSwitch","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_defaultAdmin","internalType":"address"},{"type":"string","name":"_name","internalType":"string"},{"type":"string","name":"_symbol","internalType":"string"},{"type":"string","name":"_contractURI","internalType":"string"},{"type":"address[]","name":"_trustedForwarders","internalType":"address[]"},{"type":"address","name":"_saleRecipient","internalType":"address"},{"type":"address","name":"_royaltyRecipient","internalType":"address"},{"type":"uint128","name":"_royaltyBps","internalType":"uint128"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isApprovedForAll","inputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"address","name":"operator","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isTrustedForwarder","inputs":[{"type":"address","name":"forwarder","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bytes[]","name":"results","internalType":"bytes[]"}],"name":"multicall","inputs":[{"type":"bytes[]","name":"data","internalType":"bytes[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"name","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"nextTokenIdToClaim","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"nextTokenIdToMint","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"ownerOf","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"primarySaleRecipient","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"revokeRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"receiver","internalType":"address"},{"type":"uint256","name":"royaltyAmount","internalType":"uint256"}],"name":"royaltyInfo","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"uint256","name":"salePrice","internalType":"uint256"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"safeTransferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"safeTransferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"bytes","name":"_data","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setApprovalForAll","inputs":[{"type":"address","name":"operator","internalType":"address"},{"type":"bool","name":"approved","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setClaimConditions","inputs":[{"type":"tuple[]","name":"_conditions","internalType":"struct IClaimCondition.ClaimCondition[]","components":[{"type":"uint256","name":"startTimestamp","internalType":"uint256"},{"type":"uint256","name":"maxClaimableSupply","internalType":"uint256"},{"type":"uint256","name":"supplyClaimed","internalType":"uint256"},{"type":"uint256","name":"quantityLimitPerWallet","internalType":"uint256"},{"type":"bytes32","name":"merkleRoot","internalType":"bytes32"},{"type":"uint256","name":"pricePerToken","internalType":"uint256"},{"type":"address","name":"currency","internalType":"address"},{"type":"string","name":"metadata","internalType":"string"}]},{"type":"bool","name":"_resetClaimEligibility","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setContractURI","inputs":[{"type":"string","name":"_uri","internalType":"string"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setDefaultRoyaltyInfo","inputs":[{"type":"address","name":"_royaltyRecipient","internalType":"address"},{"type":"uint256","name":"_royaltyBps","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setOwner","inputs":[{"type":"address","name":"_newOwner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setPrimarySaleRecipient","inputs":[{"type":"address","name":"_saleRecipient","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setRoyaltyInfoForToken","inputs":[{"type":"uint256","name":"_tokenId","internalType":"uint256"},{"type":"address","name":"_recipient","internalType":"address"},{"type":"uint256","name":"_bps","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setSharedMetadata","inputs":[{"type":"tuple","name":"_metadata","internalType":"struct ISharedMetadata.SharedMetadataInfo","components":[{"type":"string","name":"name","internalType":"string"},{"type":"string","name":"description","internalType":"string"},{"type":"string","name":"imageURI","internalType":"string"},{"type":"string","name":"animationURI","internalType":"string"}]}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"name","internalType":"string"},{"type":"string","name":"description","internalType":"string"},{"type":"string","name":"imageURI","internalType":"string"},{"type":"string","name":"animationURI","internalType":"string"}],"name":"sharedMetadata","inputs":[]},{"type":"function","stateMutability":"pure","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"startTokenId","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"symbol","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"tokenURI","inputs":[{"type":"uint256","name":"_tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256[]","name":"","internalType":"uint256[]"}],"name":"tokensOfOwner","inputs":[{"type":"address","name":"owner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256[]","name":"","internalType":"uint256[]"}],"name":"tokensOfOwnerIn","inputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"uint256","name":"start","internalType":"uint256"},{"type":"uint256","name":"stop","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalMinted","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalSupply","inputs":[]},{"type":"function","stateMutability":"payable","outputs":[],"name":"transferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"isOverride","internalType":"bool"}],"name":"verifyClaim","inputs":[{"type":"uint256","name":"_conditionId","internalType":"uint256"},{"type":"address","name":"_claimer","internalType":"address"},{"type":"uint256","name":"_quantity","internalType":"uint256"},{"type":"address","name":"_currency","internalType":"address"},{"type":"uint256","name":"_pricePerToken","internalType":"uint256"},{"type":"tuple","name":"_allowlistProof","internalType":"struct IDrop.AllowlistProof","components":[{"type":"bytes32[]","name":"proof","internalType":"bytes32[]"},{"type":"uint256","name":"quantityLimitPerWallet","internalType":"uint256"},{"type":"uint256","name":"pricePerToken","internalType":"uint256"},{"type":"address","name":"currency","internalType":"address"}]}]}]
Contract Creation Code
0x60806040523480156200001157600080fd5b50600054610100900460ff1615808015620000335750600054600160ff909116105b806200004f5750303b1580156200004f575060005460ff166001145b620000b75760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840160405180910390fd5b6000805460ff191660011790558015620000db576000805461ff0019166101001790555b801562000122576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5061598f80620001336000396000f3fe6080604052600436106102755760003560e01c80638da5cb5b1161014b5780638da5cb5b1461061b5780639010d07c1461063957806391d1485414610659578063938e3d7b1461067957806395d89b411461069957806399a2557a146106ae5780639bcf7a15146106ce578063a217fddf146106ee578063a22cb46514610703578063a2309ff814610723578063a32fa5b314610738578063a7d27d9d14610758578063ac9650d814610778578063acd083f814610444578063ad1eefc5146107a5578063b24f2d39146107e7578063b280f70314610812578063b88d4fde14610837578063c23dc68f1461084a578063c68907de146108b6578063c87b56dd146108cb578063ca15c873146108eb578063d547741f1461090b578063d637ed591461092b578063e6798baa1461095b578063e8a3d4851461096f578063e985e9c51461098457600080fd5b806301ffc9a71461027a57806306fdde03146102af578063079fe40e146102d1578063081812fc146102fe578063095ea7b31461031e57806313af40351461033357806318160ddd1461035357806323a2902b1461037657806323b872dd14610396578063248a9ca3146103a95780632a55205a146103d65780632f2ff15d1461040457806336568abe146104245780633b1475a71461044457806342842e0e1461045957806342966c681461046c57806349c5c5b61461048c5780634cc157df146104ac578063572b6c05146104ee578063600dd5ea1461050e5780636352211e1461052e5780636f4f28371461054e5780636f8934f41461056e57806370a082311461059b57806374bc7db7146105bb5780638462151c146105db57806384bb1e4214610608575b600080fd5b34801561028657600080fd5b5061029a6102953660046145a1565b6109a4565b60405190151581526020015b60405180910390f35b3480156102bb57600080fd5b506102c46109d0565b6040516102a6919061460e565b3480156102dd57600080fd5b506102e6610a6b565b6040516001600160a01b0390911681526020016102a6565b34801561030a57600080fd5b506102e6610319366004614621565b610a7a565b61033161032c36600461465a565b610abe565b005b34801561033f57600080fd5b5061033161034e366004614686565b610ace565b34801561035f57600080fd5b50610368610b07565b6040519081526020016102a6565b34801561038257600080fd5b5061029a6103913660046146b5565b610b27565b6103316103a4366004614732565b610eea565b3480156103b557600080fd5b506103686103c4366004614621565b6000908152600b602052604090205490565b3480156103e257600080fd5b506103f66103f1366004614773565b6110ad565b6040516102a6929190614795565b34801561041057600080fd5b5061033161041f3660046147ae565b6110ea565b34801561043057600080fd5b5061033161043f3660046147ae565b611180565b34801561045057600080fd5b506103686111df565b610331610467366004614732565b6111ee565b34801561047857600080fd5b50610331610487366004614621565b61120e565b34801561049857600080fd5b506103316104a7366004614927565b611219565b3480156104b857600080fd5b506104cc6104c7366004614621565b6114fc565b604080516001600160a01b03909316835261ffff9091166020830152016102a6565b3480156104fa57600080fd5b5061029a610509366004614686565b611567565b34801561051a57600080fd5b5061033161052936600461465a565b611585565b34801561053a57600080fd5b506102e6610549366004614621565b6115b3565b34801561055a57600080fd5b50610331610569366004614686565b6115be565b34801561057a57600080fd5b5061058e610589366004614621565b6115eb565b6040516102a69190614a16565b3480156105a757600080fd5b506103686105b6366004614686565b611748565b3480156105c757600080fd5b506103316105d6366004614adc565b6117a7565b3480156105e757600080fd5b506105fb6105f6366004614686565b611aca565b6040516102a69190614b32565b610331610616366004614b6a565b611af9565b34801561062757600080fd5b506005546001600160a01b03166102e6565b34801561064557600080fd5b506102e6610654366004614773565b611c11565b34801561066557600080fd5b5061029a6106743660046147ae565b611cff565b34801561068557600080fd5b50610331610694366004614bf7565b611d2a565b3480156106a557600080fd5b506102c4611d57565b3480156106ba57600080fd5b506105fb6106c9366004614c2b565b611d6f565b3480156106da57600080fd5b506103316106e9366004614c60565b611d7c565b3480156106fa57600080fd5b50610368600081565b34801561070f57600080fd5b5061033161071e366004614c87565b611dab565b34801561072f57600080fd5b50610368611e4d565b34801561074457600080fd5b5061029a6107533660046147ae565b611e5f565b34801561076457600080fd5b50610331610773366004614cb5565b611eb5565b34801561078457600080fd5b50610798610793366004614ce9565b611ee2565b6040516102a69190614d2a565b3480156107b157600080fd5b506103686107c03660046147ae565b60009182526010602090815260408084206001600160a01b03909316845291905290205490565b3480156107f357600080fd5b506002546001600160a01b03811690600160a01b900461ffff166104cc565b34801561081e57600080fd5b50610827612055565b6040516102a69493929190614d8e565b610331610845366004614ddb565b612291565b34801561085657600080fd5b5061086a610865366004614621565b6122d2565b6040516102a6919081516001600160a01b031681526020808301516001600160401b03169082015260408083015115159082015260609182015162ffffff169181019190915260800190565b3480156108c257600080fd5b50610368612319565b3480156108d757600080fd5b506102c46108e6366004614621565b6123bc565b3480156108f757600080fd5b50610368610906366004614621565b612402565b34801561091757600080fd5b506103316109263660046147ae565b61248b565b34801561093757600080fd5b50600d54600e54610946919082565b604080519283526020830191909152016102a6565b34801561096757600080fd5b506001610368565b34801561097b57600080fd5b506102c46124a4565b34801561099057600080fd5b5061029a61099f366004614e46565b612532565b60006109af8261256f565b806109ca575063152a902d60e11b6001600160e01b03198316145b92915050565b60606109da6125bd565b60020180546109e890614e74565b80601f0160208091040260200160405190810160405280929190818152602001828054610a1490614e74565b8015610a615780601f10610a3657610100808354040283529160200191610a61565b820191906000526020600020905b815481529060010190602001808311610a4457829003601f168201915b5050505050905090565b6004546001600160a01b031690565b6000610a85826125e1565b610a9957610a996333d1c03960e21b61263f565b610aa16125bd565b60009283526006016020525060409020546001600160a01b031690565b610aca82826001612649565b5050565b610ad661270c565b610afb5760405162461bcd60e51b8152600401610af290614ea8565b60405180910390fd5b610b048161271a565b50565b60006001610b136125bd565b60010154610b1f6125bd565b540303919050565b6000868152600f60209081526040808320815161010081018352815481526001820154938101939093526002810154918301919091526003810154606083015260048101546080830152600581015460a083015260068101546001600160a01b031660c08301526007810180548493929160e0840191610ba690614e74565b80601f0160208091040260200160405190810160405280929190818152602001828054610bd290614e74565b8015610c1f5780601f10610bf457610100808354040283529160200191610c1f565b820191906000526020600020905b815481529060010190602001808311610c0257829003601f168201915b50505091909252505050606081015160a082015160c08301516080840151939450919290919015610cff57610cfb610c578780614ed0565b80806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250505060808088015191508d9060208b01359060408c013590610cac908d0160608e01614686565b6040516001600160601b0319606095861b811660208301526034820194909452605481019290925290921b1660748201526088016040516020818303038152906040528051906020012061276c565b5094505b8415610d86578560200135600003610d175782610d1d565b85602001355b9250600019866040013503610d325781610d38565b85604001355b9150600019866040013514158015610d6957506000610d5d6080880160608901614686565b6001600160a01b031614155b610d735780610d83565b610d836080870160608801614686565b90505b60008b81526010602090815260408083206001600160a01b03808f16855292529091205490898116908316141580610dbe5750828814155b15610dfe5760405162461bcd60e51b815260206004820152601060248201526f2150726963654f7243757272656e637960801b6044820152606401610af2565b891580610e13575083610e11828c614f2f565b115b15610e495760405162461bcd60e51b8152600401610af2906020808252600490820152632151747960e01b604082015260600190565b84602001518a8660400151610e5e9190614f2f565b1115610e995760405162461bcd60e51b815260206004820152600a602482015269214d6178537570706c7960b01b6044820152606401610af2565b8451421015610edb5760405162461bcd60e51b815260206004820152600e60248201526d18d85b9d0818db185a5b481e595d60921b6044820152606401610af2565b50505050509695505050505050565b6000610ef582612830565b6001600160a01b039485169490915081168414610f1b57610f1b62a1148160e81b61263f565b600080610f27846128f2565b91509150610f4d8187610f3861291a565b6001600160a01b039081169116811491141790565b610f7157610f5d8661099f61291a565b610f7157610f71632ce44b5f60e11b61263f565b610f7e8686866001612924565b8015610f8957600082555b610f916125bd565b6001600160a01b0387166000908152600591909101602052604090208054600019019055610fbd6125bd565b6001600160a01b03861660009081526005919091016020526040902080546001019055610fee85600160e11b6129b3565b610ff66125bd565b60008681526004919091016020526040812091909155600160e11b8416900361106c57600184016110256125bd565b60008281526004919091016020526040812054900361106a576110466125bd565b54811461106a57836110566125bd565b600083815260049190910160205260409020555b505b6001600160a01b03851684818860008051602061593a833981519152600080a4806000036110a4576110a4633a954ecd60e21b61263f565b50505050505050565b6000806000806110bc866114fc565b90945084925061ffff1690506127106110d58287614f42565b6110df9190614f6f565b925050509250929050565b6000828152600b602052604090205461110390336129c8565b6000828152600a602090815260408083206001600160a01b038516845290915290205460ff16156111765760405162461bcd60e51b815260206004820152601d60248201527f43616e206f6e6c79206772616e7420746f206e6f6e20686f6c646572730000006044820152606401610af2565b610aca8282612a48565b336001600160a01b038216146111d55760405162461bcd60e51b815260206004820152601a60248201527921b0b71037b7363c903932b737bab731b2903337b91039b2b63360311b6044820152606401610af2565b610aca8282612a5c565b60006111e9612ab3565b905090565b61120983838360405180602001604052806000815250612291565b505050565b610b04816001612ac3565b611221612c33565b54610100900460ff1661124057611236612c33565b5460ff1615611244565b303b155b6112b05760405162461bcd60e51b815260206004820152603760248201527f455243373231415f5f496e697469616c697a61626c653a20636f6e7472616374604482015276081a5cc8185b1c9958591e481a5b9a5d1a585b1a5e9959604a1b6064820152608401610af2565b60006112ba612c33565b54610100900460ff1615905080156113065760016112d6612c33565b80549115156101000261ff001990921691909117905560016112f6612c33565b805460ff19169115159190911790555b600054610100900460ff16158080156113265750600054600160ff909116105b80611347575061133530612c57565b158015611347575060005460ff166001145b6113aa5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610af2565b6000805460ff1916600117905580156113cd576000805461ff0019166101001790555b7f8502233096d909befbda0999bb8ea2f3a6be3c138b9fbf003752a4c8bce86f6c7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a661141888612c66565b6114228b8b612c9e565b61142b89612cd5565b6114348c61271a565b61143f60008d612a48565b611449818d612a48565b611453828d612a48565b61145e826000612a48565b61147186866001600160801b0316612db1565b61147a87612e35565b60759190915560765580156114c9576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5080156114f15760006114da612c33565b80549115156101000261ff00199092169190911790555b505050505050505050565b6000818152600360209081526040808320815180830190925280546001600160a01b031680835260019091015492820192909252829115611543578051602082015161155d565b6002546001600160a01b03811690600160a01b900461ffff165b9250925050915091565b6001600160a01b031660009081526043602052604090205460ff1690565b61158d61270c565b6115a95760405162461bcd60e51b8152600401610af290614ea8565b610aca8282612db1565b60006109ca82612830565b6115c661270c565b6115e25760405162461bcd60e51b8152600401610af290614ea8565b610b0481612e35565b61163f60405180610100016040528060008152602001600081526020016000815260200160008152602001600080191681526020016000815260200160006001600160a01b03168152602001606081525090565b6000828152600f6020908152604091829020825161010081018452815481526001820154928101929092526002810154928201929092526003820154606082015260048201546080820152600582015460a082015260068201546001600160a01b031660c082015260078201805491929160e0840191906116bf90614e74565b80601f01602080910402602001604051908101604052809291908181526020018280546116eb90614e74565b80156117385780601f1061170d57610100808354040283529160200191611738565b820191906000526020600020905b81548152906001019060200180831161171b57829003601f168201915b5050505050815250509050919050565b60006001600160a01b038216611768576117686323d3ad8160e21b61263f565b6001600160401b036117786125bd565b6005016000846001600160a01b03166001600160a01b0316815260200190815260200160002054169050919050565b6117af61270c565b6117cb5760405162461bcd60e51b8152600401610af290614ea8565b600d54600e548183156117e5576117e28284614f2f565b90505b600e859055600d8190556000805b8681101561198d5780158061182b575087878281811061181557611815614f83565b90506020028101906118279190614f99565b3582105b61185c5760405162461bcd60e51b815260206004820152600260248201526114d560f21b6044820152606401610af2565b6000600f8161186b8487614f2f565b815260200190815260200160002060020154905088888381811061189157611891614f83565b90506020028101906118a39190614f99565b602001358111156118eb5760405162461bcd60e51b81526020600482015260126024820152711b585e081cdd5c1c1b1e4818db185a5b595960721b6044820152606401610af2565b8888838181106118fd576118fd614f83565b905060200281019061190f9190614f99565b600f600061191d8588614f2f565b815260200190815260200160002081816119379190615115565b50819050600f60006119498588614f2f565b815260208101919091526040016000206002015588888381811061196f5761196f614f83565b90506020028101906119819190614f99565b359250506001016117f3565b508415611a0257835b828110156119fc576000818152600f6020526040812081815560018101829055600281018290556003810182905560048101829055600581018290556006810180546001600160a01b0319169055906119f26007830182614511565b5050600101611996565b50611a86565b85831115611a8657855b83811015611a8457600f6000611a228386614f2f565b81526020810191909152604001600090812081815560018101829055600281018290556003810182905560048101829055600581018290556006810180546001600160a01b031916905590611a7a6007830182614511565b5050600101611a0c565b505b7fbf4016fceeaaa4ac5cf4be865b559ff85825ab4ca7aa7b661d16e2f544c03098878787604051611ab993929190615201565b60405180910390a150505050505050565b606060016000611ad8612ab3565b90506060818314611af157611aee858484612ec9565b90505b949350505050565b6000611b03612319565b9050611b1a81611b1161291a565b88888888610b27565b506000818152600f602052604081206002018054889290611b3c908490614f2f565b909155505060008181526010602052604081208791611b5961291a565b6001600160a01b03166001600160a01b031681526020019081526020016000206000828254611b889190614f2f565b90915550611b9b90506000878787612fd9565b6000611ba788886130c5565b9050876001600160a01b0316611bbb61291a565b6001600160a01b0316837ffa76a4010d9533e3e964f2930a65fb6042a12fa6ff5b08281837a10b0be7321e848b604051611bff929190918252602082015260400190565b60405180910390a45050505050505050565b6000828152600c602052604081205481805b82811015611cf6576000868152600c602090815260408083208484526001019091529020546001600160a01b031615611c9f57848203611c8d576000868152600c602090815260408083209383526001909301905220546001600160a01b031692506109ca915050565b611c98600183614f2f565b9150611ce4565b611caa866000611cff565b8015611cd157506000868152600c6020908152604080832083805260020190915290205481145b15611ce457611ce1600183614f2f565b91505b611cef600182614f2f565b9050611c23565b50505092915050565b6000918252600a602090815260408084206001600160a01b0393909316845291905290205460ff1690565b611d3261270c565b611d4e5760405162461bcd60e51b8152600401610af290614ea8565b610b0481612cd5565b6060611d616125bd565b60030180546109e890614e74565b6060611af1848484612ec9565b611d8461270c565b611da05760405162461bcd60e51b8152600401610af290614ea8565b6112098383836130db565b80611db46125bd565b6007016000611dc161291a565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155611e0561291a565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611e41911515815260200190565b60405180910390a35050565b60006001611e59612ab3565b03905090565b6000828152600a6020908152604080832083805290915281205460ff16611eac57506000828152600a602090815260408083206001600160a01b038516845290915290205460ff166109ca565b50600192915050565b611ebd613182565b611ed95760405162461bcd60e51b8152600401610af290614ea8565b610b0481613192565b6060816001600160401b03811115611efc57611efc6147de565b604051908082528060200260200182016040528015611f2f57816020015b6060815260200190600190039081611f1a5790505b5090506000611f3c6133b4565b9050336001600160a01b038216141560005b84811015611cf6578115611fcd57611fab30878784818110611f7257611f72614f83565b9050602002810190611f849190614fb9565b86604051602001611f97939291906152e9565b6040516020818303038152906040526133be565b848281518110611fbd57611fbd614f83565b602002602001018190525061204d565b61202f30878784818110611fe357611fe3614f83565b9050602002810190611ff59190614fb9565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506133be92505050565b84828151811061204157612041614f83565b60200260200101819052505b600101611f4e565b60068054819061206490614e74565b80601f016020809104026020016040519081016040528092919081815260200182805461209090614e74565b80156120dd5780601f106120b2576101008083540402835291602001916120dd565b820191906000526020600020905b8154815290600101906020018083116120c057829003601f168201915b5050505050908060010180546120f290614e74565b80601f016020809104026020016040519081016040528092919081815260200182805461211e90614e74565b801561216b5780601f106121405761010080835404028352916020019161216b565b820191906000526020600020905b81548152906001019060200180831161214e57829003601f168201915b50505050509080600201805461218090614e74565b80601f01602080910402602001604051908101604052809291908181526020018280546121ac90614e74565b80156121f95780601f106121ce576101008083540402835291602001916121f9565b820191906000526020600020905b8154815290600101906020018083116121dc57829003601f168201915b50505050509080600301805461220e90614e74565b80601f016020809104026020016040519081016040528092919081815260200182805461223a90614e74565b80156122875780601f1061225c57610100808354040283529160200191612287565b820191906000526020600020905b81548152906001019060200180831161226a57829003601f168201915b5050505050905084565b61229c848484610eea565b6001600160a01b0383163b156122cc576122b8848484846133ea565b6122cc576122cc6368d2bf6b60e11b61263f565b50505050565b6122da61454b565b60018210612314576122ea612ab3565b821015612314575b6122fb826134d2565b61230b57600019909101906122f2565b6109ca826134f2565b919050565b600e54600d54600091829161232e9190614f2f565b90505b600d5481111561238557600f600061234a60018461530a565b81526020019081526020016000206000015442106123735761236d60018261530a565b91505090565b8061237d8161531d565b915050612331565b5060405162461bcd60e51b815260206004820152600b60248201526a10a1a7a72224aa24a7a71760a91b6044820152606401610af2565b60606123c7826125e1565b6123f95760405162461bcd60e51b815260206004820152600360248201526208525160ea1b6044820152606401610af2565b6109ca8261351d565b6000818152600c6020526040812054815b81811015612466576000848152600c602090815260408083208484526001019091529020546001600160a01b03161561245457612451600184614f2f565b92505b61245f600182614f2f565b9050612413565b50612472836000611cff565b1561248557612482600183614f2f565b91505b50919050565b6000828152600b60205260409020546111d590336129c8565b600180546124b190614e74565b80601f01602080910402602001604051908101604052809291908181526020018280546124dd90614e74565b801561252a5780601f106124ff5761010080835404028352916020019161252a565b820191906000526020600020905b81548152906001019060200180831161250d57829003601f168201915b505050505081565b600061253c6125bd565b6001600160a01b039384166000908152600791909101602090815260408083209490951682529290925250205460ff1690565b60006301ffc9a760e01b6001600160e01b0319831614806125a057506380ac58cd60e01b6001600160e01b03198316145b806109ca5750506001600160e01b031916635b5e139f60e01b1490565b7f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c4090565b600081600111612314576125f36125bd565b548210156123145760005b6126066125bd565b6000848152600491909101602052604081205491508190036126325761262b8361531d565b92506125fe565b600160e01b161592915050565b8060005260046000fd5b6000612654836115b3565b905081801561267c5750806001600160a01b031661267061291a565b6001600160a01b031614155b156126a15761268d8161099f61291a565b6126a1576126a16367d9dca160e11b61263f565b836126aa6125bd565b6000858152600691909101602052604080822080546001600160a01b0319166001600160a01b0394851617905551859287811692908516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259190a450505050565b60006111e9816106746133b4565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d7690600090a35050565b6000808281805b875181101561282457612787600283614f42565b9150600088828151811061279d5761279d614f83565b602002602001015190508084116127df57604080516020810186905290810182905260600160405160208183030381529060405280519060200120935061281b565b60408051602081018390529081018590526060016040516020818303038152906040528051906020012093506001836128189190614f2f565b92505b50600101612773565b50941495939450505050565b6000816001116128e2576128426125bd565b6000838152600491909101602052604081205491508190036128cf576128666125bd565b54821061287d5761287d636f96cda160e11b61263f565b6128856125bd565b60001990920160008181526004939093016020526040909220549050801561287d57600160e01b81166000036128ba57919050565b6128ca636f96cda160e11b61263f565b61287d565b600160e01b81166000036128e257919050565b612314636f96cda160e11b61263f565b60008060006128ff6125bd565b60009485526006016020525050604090912080549092909150565b60006111e96133b4565b6129316075546000611cff565b15801561294657506001600160a01b03841615155b801561295a57506001600160a01b03831615155b156122cc5761296b60755485611cff565b158015612981575061297f60755484611cff565b155b156122cc5760405162461bcd60e51b8152602060048201526002602482015261085560f21b6044820152606401610af2565b4260a01b176001600160a01b03919091161790565b6000828152600a602090815260408083206001600160a01b038516845290915290205460ff16610aca57612a06816001600160a01b03166014613795565b612a11836020613795565b604051602001612a22929190615350565b60408051601f198184030181529082905262461bcd60e51b8252610af29160040161460e565b612a528282613930565b610aca828261398b565b612a6682826139f8565b6000828152600c602090815260408083206001600160a01b03851680855260028201808552838620805487526001909301855292852080546001600160a01b031916905584529152555050565b6000612abd6125bd565b54919050565b6000612ace83612830565b905080600080612add866128f2565b915091508415612b1857612af48184610f3861291a565b612b1857612b048361099f61291a565b612b1857612b18632ce44b5f60e11b61263f565b612b26836000886001612924565b8015612b3157600082555b6001600160801b03612b416125bd565b6001600160a01b0385166000908152600591909101602052604090208054919091019055612b7383600360e01b6129b3565b612b7b6125bd565b60008881526004919091016020526040812091909155600160e11b85169003612bf15760018601612baa6125bd565b600082815260049190910160205260408120549003612bef57612bcb6125bd565b548114612bef5784612bdb6125bd565b600083815260049190910160205260409020555b505b60405186906000906001600160a01b0386169060008051602061593a833981519152908390a4612c1f6125bd565b600190810180549091019055505050505050565b7fee151c8401928dc223602bb187aff91b9a56c7cae5476ef1b3287b085a16c85f90565b6001600160a01b03163b151590565b600054610100900460ff16612c8d5760405162461bcd60e51b8152600401610af2906153bd565b612c95613a5a565b610b0481613a83565b612ca6612c33565b54610100900460ff16612ccb5760405162461bcd60e51b8152600401610af290615408565b610aca8282613b08565b600060018054612ce490614e74565b80601f0160208091040260200160405190810160405280929190818152602001828054612d1090614e74565b8015612d5d5780601f10612d3257610100808354040283529160200191612d5d565b820191906000526020600020905b815481529060010190602001808311612d4057829003601f168201915b505050505090508160019081612d73919061545c565b507fc9c7c3fe08b88b4df9d4d47ef47d2c43d55c025a0ba88ca442580ed9e7348a168183604051612da5929190615515565b60405180910390a15050565b612710811115612dd35760405162461bcd60e51b8152600401610af290615543565b600280546001600160a01b0384166001600160b01b03199091168117600160a01b61ffff851602179091556040518281527f90d7ec04bcb8978719414f82e52e4cb651db41d0e6f8cea6118c2191e6183adb9060200160405180910390a25050565b6001600160a01b038116612e7f5760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c9958da5c1a595b9d607a1b6044820152606401610af2565b600480546001600160a01b0319166001600160a01b0383169081179091556040517f299d17e95023f496e0ffc4909cff1a61f74bb5eb18de6f900f4155bfa1b3b33390600090a250565b6060818310612ee257612ee2631960ccad60e11b61263f565b6001831015612ef057600192505b6000612efa612ab3565b9050808310612f07578092505b60606000612f1487611748565b85871090810291508115612fc5578187870311612f315786860391505b60405192506001820160051b83016040526000612f4d886122d2565b905060008160400151612f5e575080515b60005b612f6a8a6134f2565b9250604083015160008114612f825760009250612fa7565b835115612f8e57835192505b8b831860601b612fa7576001820191508a8260051b8801525b5060018a019950888a1480612fbb57508481145b15612f6157855250505b50909695505050505050565b505050505050565b8060000361301d5734156130185760405162461bcd60e51b81526020600482015260066024820152652156616c756560d01b6044820152606401610af2565b6122cc565b60006130298285614f42565b9050600073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed196001600160a01b0385160161305b575034811461305f565b5034155b806130915760405162461bcd60e51b815260206004820152600260248201526110ab60f11b6044820152606401610af2565b60006001600160a01b038716156130a857866130b0565b6130b0610a6b565b90506110a4856130be6133b4565b8386613b74565b60006130cf612ab3565b90506109ca8383613bb5565b6127108111156130fd5760405162461bcd60e51b8152600401610af290615543565b6040805180820182526001600160a01b038481168083526020808401868152600089815260038352869020945185546001600160a01b031916941693909317845591516001909301929092559151838152909185917f7365cf4122f072a3365c20d54eff9b38d73c096c28e1892ec8f5b0e403a0f12d910160405180910390a3505050565b60006111e96076546106746133b4565b6040805160808101909152806131a88380614fb9565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050908252506020908101906131f190840184614fb9565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050908252506020016132386040840184614fb9565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050509082525060200161327f6060840184614fb9565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050915250805160069081906132c6908261545c565b50602082015160018201906132db908261545c565b50604082015160028201906132f0908261545c565b5060608201516003820190613305908261545c565b5050604080516000815260001960208201527f6bd5c950a8d8df17f772f5af37cb3655737899cbf903264b9795592da439661c92500160405180910390a17f8edd7f36d5f01bd45e59cf55b0a670dcf701fc20f678970a8c243b2346d6acaf61336e8280614fb9565b61337b6020850185614fb9565b6133886040870187614fb9565b6133956060890189614fb9565b6040516133a998979695949392919061556c565b60405180910390a150565b60006111e9613bcf565b60606133e3838360405180606001604052806027815260200161591360279139613bf1565b9392505050565b6000836001600160a01b031663150b7a0261340361291a565b8786866040518563ffffffff1660e01b815260040161342594939291906155cc565b6020604051808303816000875af1925050508015613460575060408051601f3d908101601f1916820190925261345d918101906155ff565b60015b6134b5573d80801561348e576040519150601f19603f3d011682016040523d82523d6000602084013e613493565b606091505b5080516000036134ad576134ad6368d2bf6b60e11b61263f565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050949350505050565b60006134dc6125bd565b6000928352600401602052506040902054151590565b6134fa61454b565b6109ca6135056125bd565b60008481526004919091016020526040902054613c69565b60606000600660405180608001604052908160008201805461353e90614e74565b80601f016020809104026020016040519081016040528092919081815260200182805461356a90614e74565b80156135b75780601f1061358c576101008083540402835291602001916135b7565b820191906000526020600020905b81548152906001019060200180831161359a57829003601f168201915b505050505081526020016001820180546135d090614e74565b80601f01602080910402602001604051908101604052809291908181526020018280546135fc90614e74565b80156136495780601f1061361e57610100808354040283529160200191613649565b820191906000526020600020905b81548152906001019060200180831161362c57829003601f168201915b5050505050815260200160028201805461366290614e74565b80601f016020809104026020016040519081016040528092919081815260200182805461368e90614e74565b80156136db5780601f106136b0576101008083540402835291602001916136db565b820191906000526020600020905b8154815290600101906020018083116136be57829003601f168201915b505050505081526020016003820180546136f490614e74565b80601f016020809104026020016040519081016040528092919081815260200182805461372090614e74565b801561376d5780601f106137425761010080835404028352916020019161376d565b820191906000526020600020905b81548152906001019060200180831161375057829003601f168201915b5050505050815250509050612482816000015182602001518360400151846060015187613cac565b606060006137a4836002614f42565b6137af906002614f2f565b6001600160401b038111156137c6576137c66147de565b6040519080825280601f01601f1916602001820160405280156137f0576020820181803683370190505b509050600360fc1b8160008151811061380b5761380b614f83565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061383a5761383a614f83565b60200101906001600160f81b031916908160001a905350600061385e846002614f42565b613869906001614f2f565b90505b60018111156138e1576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061389d5761389d614f83565b1a60f81b8282815181106138b3576138b3614f83565b60200101906001600160f81b031916908160001a90535060049490941c936138da8161531d565b905061386c565b5083156133e35760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610af2565b6000828152600a602090815260408083206001600160a01b0385168085529252808320805460ff1916600117905551339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b6000828152600c60205260408120805491600191906139aa8385614f2f565b90915550506000928352600c6020908152604080852083865260018101835281862080546001600160a01b039096166001600160a01b03199096168617905593855260029093019052912055565b613a0282826129c8565b6000828152600a602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600054610100900460ff16613a815760405162461bcd60e51b8152600401610af2906153bd565b565b600054610100900460ff16613aaa5760405162461bcd60e51b8152600401610af2906153bd565b60005b8151811015610aca57600160436000848481518110613ace57613ace614f83565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055600101613aad565b613b10612c33565b54610100900460ff16613b355760405162461bcd60e51b8152600401610af290615408565b81613b3e6125bd565b60020190613b4c908261545c565b5080613b566125bd565b60030190613b64908261545c565b506001613b6f6125bd565b555050565b80156122cc5773eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed196001600160a01b03851601613ba9576130188282613ce1565b6122cc84848484613d83565b610aca828260405180602001604052806000815250613dd6565b6000613bda33611567565b15613bec575060131936013560601c90565b503390565b6060600080856001600160a01b031685604051613c0e919061561c565b600060405180830381855af49150503d8060008114613c49576040519150601f19603f3d011682016040523d82523d6000602084013e613c4e565b606091505b5091509150613c5f86838387613e4f565b9695505050505050565b613c7161454b565b6001600160a01b03821681526001600160401b0360a083901c166020820152600160e01b82161515604082015260e89190911c606082015290565b60606000613cba8585613ec6565b90506000613cca88888487613f53565b9050613cd581613f99565b98975050505050505050565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114613d2e576040519150601f19603f3d011682016040523d82523d6000602084013e613d33565b606091505b50509050806112095760405162461bcd60e51b815260206004820152601c60248201527b1b985d1a5d99481d1bdad95b881d1c985b9cd9995c8819985a5b195960221b6044820152606401610af2565b816001600160a01b0316836001600160a01b031603156122cc57306001600160a01b03841603613dc1576130186001600160a01b0385168383613fca565b6122cc6001600160a01b038516848484614020565b613de08383614058565b6001600160a01b0383163b15611209576000613dfa6125bd565b5490508281035b613e1460008683806001019450866133ea565b613e2857613e286368d2bf6b60e11b61263f565b818110613e015781613e386125bd565b5414613e4857613e48600061263f565b5050505050565b60608315613ebc578251600003613eb557613e6985612c57565b613eb55760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610af2565b5081611af1565b611af1838361413e565b81518151606091158015911515908290613edd5750805b15613f0d578484604051602001613ef592919061562e565b604051602081830303815290604052925050506109ca565b8115613f245784604051602001613ef591906156a5565b8015613f3b5783604051602001613ef591906156e5565b50506040805160208101909152600081529392505050565b606084613f5f83614168565b8585613f6a86614168565b89604051602001613f809695949392919061572d565b6040516020818303038152906040529050949350505050565b6060613fa482614268565b604051602001613fb49190615843565b6040516020818303038152906040529050919050565b6112098363a9059cbb60e01b8484604051602401613fe9929190614795565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526143ba565b6040516001600160a01b03808516602483015283166044820152606481018290526122cc9085906323b872dd60e01b90608401613fe9565b60006140626125bd565b549050600082900361407e5761407e63b562e8dd60e01b61263f565b61408b6000848385612924565b61409b836001841460e11b6129b3565b6140a36125bd565b600083815260049190910160205260409020556001600160401b0182026140c86125bd565b6001600160a01b038516600081815260059290920160205260408220805490930190925581900361410257614102622e076360e81b61263f565b818301825b8083600060008051602061593a833981519152600080a481816001019150810361410757816141346125bd565b5550611209915050565b81511561414e5781518083602001fd5b8060405162461bcd60e51b8152600401610af2919061460e565b60608160000361418f5750506040805180820190915260018152600360fc1b602082015290565b8160005b81156141b957806141a381615888565b91506141b29050600a83614f6f565b9150614193565b6000816001600160401b038111156141d3576141d36147de565b6040519080825280601f01601f1916602001820160405280156141fd576020820181803683370190505b5090505b8415611af15761421260018361530a565b915061421f600a866158a1565b61422a906030614f2f565b60f81b81838151811061423f5761423f614f83565b60200101906001600160f81b031916908160001a905350614261600a86614f6f565b9450614201565b6060815160000361428757505060408051602081019091526000815290565b60006040518060600160405280604081526020016158d360409139905060006003845160026142b69190614f2f565b6142c09190614f6f565b6142cb906004614f42565b6001600160401b038111156142e2576142e26147de565b6040519080825280601f01601f19166020018201604052801561430c576020820181803683370190505b509050600182016020820185865187015b80821015614378576003820191508151603f8160121c168501518453600184019350603f81600c1c168501518453600184019350603f8160061c168501518453600184019350603f811685015184535060018301925061431d565b505060038651066001811461439457600281146143a7576143af565b603d6001830353603d60028303536143af565b603d60018303535b509195945050505050565b600061440f826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661448c9092919063ffffffff16565b805190915015611209578080602001905181019061442d91906158b5565b6112095760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610af2565b6060611af1848460008585600080866001600160a01b031685876040516144b3919061561c565b60006040518083038185875af1925050503d80600081146144f0576040519150601f19603f3d011682016040523d82523d6000602084013e6144f5565b606091505b509150915061450687838387613e4f565b979650505050505050565b50805461451d90614e74565b6000825580601f1061452d575050565b601f016020900490600052602060002090810190610b049190614572565b60408051608081018252600080825260208201819052918101829052606081019190915290565b5b808211156145875760008155600101614573565b5090565b6001600160e01b031981168114610b0457600080fd5b6000602082840312156145b357600080fd5b81356133e38161458b565b60005b838110156145d95781810151838201526020016145c1565b50506000910152565b600081518084526145fa8160208601602086016145be565b601f01601f19169290920160200192915050565b6020815260006133e360208301846145e2565b60006020828403121561463357600080fd5b5035919050565b6001600160a01b0381168114610b0457600080fd5b80356123148161463a565b6000806040838503121561466d57600080fd5b82356146788161463a565b946020939093013593505050565b60006020828403121561469857600080fd5b81356133e38161463a565b60006080828403121561248557600080fd5b60008060008060008060c087890312156146ce57600080fd5b8635955060208701356146e08161463a565b94506040870135935060608701356146f78161463a565b92506080870135915060a08701356001600160401b0381111561471957600080fd5b61472589828a016146a3565b9150509295509295509295565b60008060006060848603121561474757600080fd5b83356147528161463a565b925060208401356147628161463a565b929592945050506040919091013590565b6000806040838503121561478657600080fd5b50508035926020909101359150565b6001600160a01b03929092168252602082015260400190565b600080604083850312156147c157600080fd5b8235915060208301356147d38161463a565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171561481c5761481c6147de565b604052919050565b600082601f83011261483557600080fd5b81356001600160401b0381111561484e5761484e6147de565b614861601f8201601f19166020016147f4565b81815284602083860101111561487657600080fd5b816020850160208301376000918101602001919091529392505050565b600082601f8301126148a457600080fd5b813560206001600160401b038211156148bf576148bf6147de565b8160051b6148ce8282016147f4565b92835284810182019282810190878511156148e857600080fd5b83870192505b848310156145065782356149018161463a565b825291830191908301906148ee565b80356001600160801b038116811461231457600080fd5b600080600080600080600080610100898b03121561494457600080fd5b61494d8961464f565b975060208901356001600160401b038082111561496957600080fd5b6149758c838d01614824565b985060408b013591508082111561498b57600080fd5b6149978c838d01614824565b975060608b01359150808211156149ad57600080fd5b6149b98c838d01614824565b965060808b01359150808211156149cf57600080fd5b506149dc8b828c01614893565b9450506149eb60a08a0161464f565b92506149f960c08a0161464f565b9150614a0760e08a01614910565b90509295985092959890939650565b6020815281516020820152602082015160408201526040820151606082015260608201516080820152608082015160a082015260a082015160c082015260018060a01b0360c08301511660e0820152600060e0830151610100808185015250611af16101208401826145e2565b60008083601f840112614a9557600080fd5b5081356001600160401b03811115614aac57600080fd5b6020830191508360208260051b8501011115614ac757600080fd5b9250929050565b8015158114610b0457600080fd5b600080600060408486031215614af157600080fd5b83356001600160401b03811115614b0757600080fd5b614b1386828701614a83565b9094509250506020840135614b2781614ace565b809150509250925092565b6020808252825182820181905260009190848201906040850190845b81811015612fc557835183529284019291840191600101614b4e565b60008060008060008060c08789031215614b8357600080fd5b8635614b8e8161463a565b9550602087013594506040870135614ba58161463a565b93506060870135925060808701356001600160401b0380821115614bc857600080fd5b614bd48a838b016146a3565b935060a0890135915080821115614bea57600080fd5b5061472589828a01614824565b600060208284031215614c0957600080fd5b81356001600160401b03811115614c1f57600080fd5b611af184828501614824565b600080600060608486031215614c4057600080fd5b8335614c4b8161463a565b95602085013595506040909401359392505050565b600080600060608486031215614c7557600080fd5b8335925060208401356147628161463a565b60008060408385031215614c9a57600080fd5b8235614ca58161463a565b915060208301356147d381614ace565b600060208284031215614cc757600080fd5b81356001600160401b03811115614cdd57600080fd5b611af1848285016146a3565b60008060208385031215614cfc57600080fd5b82356001600160401b03811115614d1257600080fd5b614d1e85828601614a83565b90969095509350505050565b600060208083016020845280855180835260408601915060408160051b87010192506020870160005b82811015614d8157603f19888603018452614d6f8583516145e2565b94509285019290850190600101614d53565b5092979650505050505050565b608081526000614da160808301876145e2565b8281036020840152614db381876145e2565b90508281036040840152614dc781866145e2565b9050828103606084015261450681856145e2565b60008060008060808587031215614df157600080fd5b8435614dfc8161463a565b93506020850135614e0c8161463a565b92506040850135915060608501356001600160401b03811115614e2e57600080fd5b614e3a87828801614824565b91505092959194509250565b60008060408385031215614e5957600080fd5b8235614e648161463a565b915060208301356147d38161463a565b600181811c90821680614e8857607f821691505b60208210810361248557634e487b7160e01b600052602260045260246000fd5b6020808252600e908201526d139bdd08185d5d1a1bdc9a5e995960921b604082015260600190565b6000808335601e19843603018112614ee757600080fd5b8301803591506001600160401b03821115614f0157600080fd5b6020019150600581901b3603821315614ac757600080fd5b634e487b7160e01b600052601160045260246000fd5b808201808211156109ca576109ca614f19565b80820281158282048414176109ca576109ca614f19565b634e487b7160e01b600052601260045260246000fd5b600082614f7e57614f7e614f59565b500490565b634e487b7160e01b600052603260045260246000fd5b6000823560fe19833603018112614faf57600080fd5b9190910192915050565b6000808335601e19843603018112614fd057600080fd5b8301803591506001600160401b03821115614fea57600080fd5b602001915036819003821315614ac757600080fd5b601f821115611209576000816000526020600020601f850160051c810160208610156150285750805b601f850160051c820191505b81811015612fd157828155600101615034565b600019600383901b1c191660019190911b1790565b6001600160401b03831115615073576150736147de565b615087836150818354614e74565b83614fff565b6000601f8411600181146150b557600085156150a35750838201355b6150ad8682615047565b845550613e48565b600083815260209020601f19861690835b828110156150e657868501358255602094850194600190920191016150c6565b50868210156151035760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b813581556020820135600182015560408201356002820155606082013560038201556080820135600482015560a082013560058201556006810160c083013561515d8161463a565b81546001600160a01b0319166001600160a01b039190911617905561518560e0830183614fb9565b6122cc81836007860161505c565b6000808335601e198436030181126151aa57600080fd5b83016020810192503590506001600160401b038111156151c957600080fd5b803603821315614ac757600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60408082528181018490526000906060808401600587901b850182018885805b8a8110156152d357888403605f190185528235368d900360fe19018112615246578283fd5b8c018035855260208082013581870152888201358987015287820135888701526080808301359087015260a080830135908701526101009060c08084013561528d8161463a565b6001600160a01b03169088015260e06152a884820185615193565b945083828a01526152bc848a0186836151d8565b998301999850505094909401935050600101615221565b50505086151560208701529350611af192505050565b8284823760609190911b6001600160601b0319169101908152601401919050565b818103818111156109ca576109ca614f19565b60008161532c5761532c614f19565b506000190190565b600081516153468185602086016145be565b9290920192915050565b7402832b936b4b9b9b4b7b7399d1030b1b1b7bab73a1605d1b8152600083516153808160158501602088016145be565b7001034b99036b4b9b9b4b733903937b6329607d1b60159184019182015283516153b18160268401602088016145be565b01602601949350505050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60208082526034908201527f455243373231415f5f496e697469616c697a61626c653a20636f6e7472616374604082015273206973206e6f7420696e697469616c697a696e6760601b606082015260800190565b81516001600160401b03811115615475576154756147de565b615489816154838454614e74565b84614fff565b602080601f8311600181146154b857600084156154a65750858301515b6154b08582615047565b865550612fd1565b600085815260208120601f198616915b828110156154e7578886015182559484019460019091019084016154c8565b50858210156155055787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60408152600061552860408301856145e2565b828103602084015261553a81856145e2565b95945050505050565b6020808252600f908201526e45786365656473206d61782062707360881b604082015260600190565b608081526000615580608083018a8c6151d8565b828103602084015261559381898b6151d8565b905082810360408401526155a88187896151d8565b905082810360608401526155bd8185876151d8565b9b9a5050505050505050505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613c5f908301846145e2565b60006020828403121561561157600080fd5b81516133e38161458b565b60008251614faf8184602087016145be565b6834b6b0b3b2911d101160b91b815282516000906156538160098501602088016145be565b741116101130b734b6b0ba34b7b72fbab936111d101160591b600991840191820152835161568881601e8401602088016145be565b631116101160e11b601e9290910191820152602201949350505050565b6834b6b0b3b2911d101160b91b815281516000906156ca8160098501602087016145be565b631116101160e11b6009939091019283015250600d01919050565b7030b734b6b0ba34b7b72fbab936111d101160791b815281516000906157128160118501602087016145be565b631116101160e11b6011939091019283015250601501919050565b693d913730b6b2911d101160b11b8152865160009061575381600a850160208c016145be565b600160fd1b600a91840191820152875161577481600b840160208c016145be565b631116101160e11b600b929091019182018190526e3232b9b1b934b83a34b7b7111d101160891b600f83015287516157b381601e850160208c016145be565b601e92019182015285516157ce816022840160208a016145be565b770383937b832b93a34b2b9911d103d91373ab6b132b9111d160451b6022929091019182015261583661582761582161580a603a850189615334565b6a1610113730b6b2911d101160a91b8152600b0190565b86615334565b62227d7d60e81b815260030190565b9998505050505050505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c00000081526000825161587b81601d8501602087016145be565b91909101601d0192915050565b60006001820161589a5761589a614f19565b5060010190565b6000826158b0576158b0614f59565b500690565b6000602082840312156158c757600080fd5b81516133e381614ace56fe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220b255ddf5ee3f2f8e238df733f24fa187c7fe7b8a7db015f584c4ac237b7580ae64736f6c63430008170033
Deployed ByteCode
0x6080604052600436106102755760003560e01c80638da5cb5b1161014b5780638da5cb5b1461061b5780639010d07c1461063957806391d1485414610659578063938e3d7b1461067957806395d89b411461069957806399a2557a146106ae5780639bcf7a15146106ce578063a217fddf146106ee578063a22cb46514610703578063a2309ff814610723578063a32fa5b314610738578063a7d27d9d14610758578063ac9650d814610778578063acd083f814610444578063ad1eefc5146107a5578063b24f2d39146107e7578063b280f70314610812578063b88d4fde14610837578063c23dc68f1461084a578063c68907de146108b6578063c87b56dd146108cb578063ca15c873146108eb578063d547741f1461090b578063d637ed591461092b578063e6798baa1461095b578063e8a3d4851461096f578063e985e9c51461098457600080fd5b806301ffc9a71461027a57806306fdde03146102af578063079fe40e146102d1578063081812fc146102fe578063095ea7b31461031e57806313af40351461033357806318160ddd1461035357806323a2902b1461037657806323b872dd14610396578063248a9ca3146103a95780632a55205a146103d65780632f2ff15d1461040457806336568abe146104245780633b1475a71461044457806342842e0e1461045957806342966c681461046c57806349c5c5b61461048c5780634cc157df146104ac578063572b6c05146104ee578063600dd5ea1461050e5780636352211e1461052e5780636f4f28371461054e5780636f8934f41461056e57806370a082311461059b57806374bc7db7146105bb5780638462151c146105db57806384bb1e4214610608575b600080fd5b34801561028657600080fd5b5061029a6102953660046145a1565b6109a4565b60405190151581526020015b60405180910390f35b3480156102bb57600080fd5b506102c46109d0565b6040516102a6919061460e565b3480156102dd57600080fd5b506102e6610a6b565b6040516001600160a01b0390911681526020016102a6565b34801561030a57600080fd5b506102e6610319366004614621565b610a7a565b61033161032c36600461465a565b610abe565b005b34801561033f57600080fd5b5061033161034e366004614686565b610ace565b34801561035f57600080fd5b50610368610b07565b6040519081526020016102a6565b34801561038257600080fd5b5061029a6103913660046146b5565b610b27565b6103316103a4366004614732565b610eea565b3480156103b557600080fd5b506103686103c4366004614621565b6000908152600b602052604090205490565b3480156103e257600080fd5b506103f66103f1366004614773565b6110ad565b6040516102a6929190614795565b34801561041057600080fd5b5061033161041f3660046147ae565b6110ea565b34801561043057600080fd5b5061033161043f3660046147ae565b611180565b34801561045057600080fd5b506103686111df565b610331610467366004614732565b6111ee565b34801561047857600080fd5b50610331610487366004614621565b61120e565b34801561049857600080fd5b506103316104a7366004614927565b611219565b3480156104b857600080fd5b506104cc6104c7366004614621565b6114fc565b604080516001600160a01b03909316835261ffff9091166020830152016102a6565b3480156104fa57600080fd5b5061029a610509366004614686565b611567565b34801561051a57600080fd5b5061033161052936600461465a565b611585565b34801561053a57600080fd5b506102e6610549366004614621565b6115b3565b34801561055a57600080fd5b50610331610569366004614686565b6115be565b34801561057a57600080fd5b5061058e610589366004614621565b6115eb565b6040516102a69190614a16565b3480156105a757600080fd5b506103686105b6366004614686565b611748565b3480156105c757600080fd5b506103316105d6366004614adc565b6117a7565b3480156105e757600080fd5b506105fb6105f6366004614686565b611aca565b6040516102a69190614b32565b610331610616366004614b6a565b611af9565b34801561062757600080fd5b506005546001600160a01b03166102e6565b34801561064557600080fd5b506102e6610654366004614773565b611c11565b34801561066557600080fd5b5061029a6106743660046147ae565b611cff565b34801561068557600080fd5b50610331610694366004614bf7565b611d2a565b3480156106a557600080fd5b506102c4611d57565b3480156106ba57600080fd5b506105fb6106c9366004614c2b565b611d6f565b3480156106da57600080fd5b506103316106e9366004614c60565b611d7c565b3480156106fa57600080fd5b50610368600081565b34801561070f57600080fd5b5061033161071e366004614c87565b611dab565b34801561072f57600080fd5b50610368611e4d565b34801561074457600080fd5b5061029a6107533660046147ae565b611e5f565b34801561076457600080fd5b50610331610773366004614cb5565b611eb5565b34801561078457600080fd5b50610798610793366004614ce9565b611ee2565b6040516102a69190614d2a565b3480156107b157600080fd5b506103686107c03660046147ae565b60009182526010602090815260408084206001600160a01b03909316845291905290205490565b3480156107f357600080fd5b506002546001600160a01b03811690600160a01b900461ffff166104cc565b34801561081e57600080fd5b50610827612055565b6040516102a69493929190614d8e565b610331610845366004614ddb565b612291565b34801561085657600080fd5b5061086a610865366004614621565b6122d2565b6040516102a6919081516001600160a01b031681526020808301516001600160401b03169082015260408083015115159082015260609182015162ffffff169181019190915260800190565b3480156108c257600080fd5b50610368612319565b3480156108d757600080fd5b506102c46108e6366004614621565b6123bc565b3480156108f757600080fd5b50610368610906366004614621565b612402565b34801561091757600080fd5b506103316109263660046147ae565b61248b565b34801561093757600080fd5b50600d54600e54610946919082565b604080519283526020830191909152016102a6565b34801561096757600080fd5b506001610368565b34801561097b57600080fd5b506102c46124a4565b34801561099057600080fd5b5061029a61099f366004614e46565b612532565b60006109af8261256f565b806109ca575063152a902d60e11b6001600160e01b03198316145b92915050565b60606109da6125bd565b60020180546109e890614e74565b80601f0160208091040260200160405190810160405280929190818152602001828054610a1490614e74565b8015610a615780601f10610a3657610100808354040283529160200191610a61565b820191906000526020600020905b815481529060010190602001808311610a4457829003601f168201915b5050505050905090565b6004546001600160a01b031690565b6000610a85826125e1565b610a9957610a996333d1c03960e21b61263f565b610aa16125bd565b60009283526006016020525060409020546001600160a01b031690565b610aca82826001612649565b5050565b610ad661270c565b610afb5760405162461bcd60e51b8152600401610af290614ea8565b60405180910390fd5b610b048161271a565b50565b60006001610b136125bd565b60010154610b1f6125bd565b540303919050565b6000868152600f60209081526040808320815161010081018352815481526001820154938101939093526002810154918301919091526003810154606083015260048101546080830152600581015460a083015260068101546001600160a01b031660c08301526007810180548493929160e0840191610ba690614e74565b80601f0160208091040260200160405190810160405280929190818152602001828054610bd290614e74565b8015610c1f5780601f10610bf457610100808354040283529160200191610c1f565b820191906000526020600020905b815481529060010190602001808311610c0257829003601f168201915b50505091909252505050606081015160a082015160c08301516080840151939450919290919015610cff57610cfb610c578780614ed0565b80806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250505060808088015191508d9060208b01359060408c013590610cac908d0160608e01614686565b6040516001600160601b0319606095861b811660208301526034820194909452605481019290925290921b1660748201526088016040516020818303038152906040528051906020012061276c565b5094505b8415610d86578560200135600003610d175782610d1d565b85602001355b9250600019866040013503610d325781610d38565b85604001355b9150600019866040013514158015610d6957506000610d5d6080880160608901614686565b6001600160a01b031614155b610d735780610d83565b610d836080870160608801614686565b90505b60008b81526010602090815260408083206001600160a01b03808f16855292529091205490898116908316141580610dbe5750828814155b15610dfe5760405162461bcd60e51b815260206004820152601060248201526f2150726963654f7243757272656e637960801b6044820152606401610af2565b891580610e13575083610e11828c614f2f565b115b15610e495760405162461bcd60e51b8152600401610af2906020808252600490820152632151747960e01b604082015260600190565b84602001518a8660400151610e5e9190614f2f565b1115610e995760405162461bcd60e51b815260206004820152600a602482015269214d6178537570706c7960b01b6044820152606401610af2565b8451421015610edb5760405162461bcd60e51b815260206004820152600e60248201526d18d85b9d0818db185a5b481e595d60921b6044820152606401610af2565b50505050509695505050505050565b6000610ef582612830565b6001600160a01b039485169490915081168414610f1b57610f1b62a1148160e81b61263f565b600080610f27846128f2565b91509150610f4d8187610f3861291a565b6001600160a01b039081169116811491141790565b610f7157610f5d8661099f61291a565b610f7157610f71632ce44b5f60e11b61263f565b610f7e8686866001612924565b8015610f8957600082555b610f916125bd565b6001600160a01b0387166000908152600591909101602052604090208054600019019055610fbd6125bd565b6001600160a01b03861660009081526005919091016020526040902080546001019055610fee85600160e11b6129b3565b610ff66125bd565b60008681526004919091016020526040812091909155600160e11b8416900361106c57600184016110256125bd565b60008281526004919091016020526040812054900361106a576110466125bd565b54811461106a57836110566125bd565b600083815260049190910160205260409020555b505b6001600160a01b03851684818860008051602061593a833981519152600080a4806000036110a4576110a4633a954ecd60e21b61263f565b50505050505050565b6000806000806110bc866114fc565b90945084925061ffff1690506127106110d58287614f42565b6110df9190614f6f565b925050509250929050565b6000828152600b602052604090205461110390336129c8565b6000828152600a602090815260408083206001600160a01b038516845290915290205460ff16156111765760405162461bcd60e51b815260206004820152601d60248201527f43616e206f6e6c79206772616e7420746f206e6f6e20686f6c646572730000006044820152606401610af2565b610aca8282612a48565b336001600160a01b038216146111d55760405162461bcd60e51b815260206004820152601a60248201527921b0b71037b7363c903932b737bab731b2903337b91039b2b63360311b6044820152606401610af2565b610aca8282612a5c565b60006111e9612ab3565b905090565b61120983838360405180602001604052806000815250612291565b505050565b610b04816001612ac3565b611221612c33565b54610100900460ff1661124057611236612c33565b5460ff1615611244565b303b155b6112b05760405162461bcd60e51b815260206004820152603760248201527f455243373231415f5f496e697469616c697a61626c653a20636f6e7472616374604482015276081a5cc8185b1c9958591e481a5b9a5d1a585b1a5e9959604a1b6064820152608401610af2565b60006112ba612c33565b54610100900460ff1615905080156113065760016112d6612c33565b80549115156101000261ff001990921691909117905560016112f6612c33565b805460ff19169115159190911790555b600054610100900460ff16158080156113265750600054600160ff909116105b80611347575061133530612c57565b158015611347575060005460ff166001145b6113aa5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610af2565b6000805460ff1916600117905580156113cd576000805461ff0019166101001790555b7f8502233096d909befbda0999bb8ea2f3a6be3c138b9fbf003752a4c8bce86f6c7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a661141888612c66565b6114228b8b612c9e565b61142b89612cd5565b6114348c61271a565b61143f60008d612a48565b611449818d612a48565b611453828d612a48565b61145e826000612a48565b61147186866001600160801b0316612db1565b61147a87612e35565b60759190915560765580156114c9576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5080156114f15760006114da612c33565b80549115156101000261ff00199092169190911790555b505050505050505050565b6000818152600360209081526040808320815180830190925280546001600160a01b031680835260019091015492820192909252829115611543578051602082015161155d565b6002546001600160a01b03811690600160a01b900461ffff165b9250925050915091565b6001600160a01b031660009081526043602052604090205460ff1690565b61158d61270c565b6115a95760405162461bcd60e51b8152600401610af290614ea8565b610aca8282612db1565b60006109ca82612830565b6115c661270c565b6115e25760405162461bcd60e51b8152600401610af290614ea8565b610b0481612e35565b61163f60405180610100016040528060008152602001600081526020016000815260200160008152602001600080191681526020016000815260200160006001600160a01b03168152602001606081525090565b6000828152600f6020908152604091829020825161010081018452815481526001820154928101929092526002810154928201929092526003820154606082015260048201546080820152600582015460a082015260068201546001600160a01b031660c082015260078201805491929160e0840191906116bf90614e74565b80601f01602080910402602001604051908101604052809291908181526020018280546116eb90614e74565b80156117385780601f1061170d57610100808354040283529160200191611738565b820191906000526020600020905b81548152906001019060200180831161171b57829003601f168201915b5050505050815250509050919050565b60006001600160a01b038216611768576117686323d3ad8160e21b61263f565b6001600160401b036117786125bd565b6005016000846001600160a01b03166001600160a01b0316815260200190815260200160002054169050919050565b6117af61270c565b6117cb5760405162461bcd60e51b8152600401610af290614ea8565b600d54600e548183156117e5576117e28284614f2f565b90505b600e859055600d8190556000805b8681101561198d5780158061182b575087878281811061181557611815614f83565b90506020028101906118279190614f99565b3582105b61185c5760405162461bcd60e51b815260206004820152600260248201526114d560f21b6044820152606401610af2565b6000600f8161186b8487614f2f565b815260200190815260200160002060020154905088888381811061189157611891614f83565b90506020028101906118a39190614f99565b602001358111156118eb5760405162461bcd60e51b81526020600482015260126024820152711b585e081cdd5c1c1b1e4818db185a5b595960721b6044820152606401610af2565b8888838181106118fd576118fd614f83565b905060200281019061190f9190614f99565b600f600061191d8588614f2f565b815260200190815260200160002081816119379190615115565b50819050600f60006119498588614f2f565b815260208101919091526040016000206002015588888381811061196f5761196f614f83565b90506020028101906119819190614f99565b359250506001016117f3565b508415611a0257835b828110156119fc576000818152600f6020526040812081815560018101829055600281018290556003810182905560048101829055600581018290556006810180546001600160a01b0319169055906119f26007830182614511565b5050600101611996565b50611a86565b85831115611a8657855b83811015611a8457600f6000611a228386614f2f565b81526020810191909152604001600090812081815560018101829055600281018290556003810182905560048101829055600581018290556006810180546001600160a01b031916905590611a7a6007830182614511565b5050600101611a0c565b505b7fbf4016fceeaaa4ac5cf4be865b559ff85825ab4ca7aa7b661d16e2f544c03098878787604051611ab993929190615201565b60405180910390a150505050505050565b606060016000611ad8612ab3565b90506060818314611af157611aee858484612ec9565b90505b949350505050565b6000611b03612319565b9050611b1a81611b1161291a565b88888888610b27565b506000818152600f602052604081206002018054889290611b3c908490614f2f565b909155505060008181526010602052604081208791611b5961291a565b6001600160a01b03166001600160a01b031681526020019081526020016000206000828254611b889190614f2f565b90915550611b9b90506000878787612fd9565b6000611ba788886130c5565b9050876001600160a01b0316611bbb61291a565b6001600160a01b0316837ffa76a4010d9533e3e964f2930a65fb6042a12fa6ff5b08281837a10b0be7321e848b604051611bff929190918252602082015260400190565b60405180910390a45050505050505050565b6000828152600c602052604081205481805b82811015611cf6576000868152600c602090815260408083208484526001019091529020546001600160a01b031615611c9f57848203611c8d576000868152600c602090815260408083209383526001909301905220546001600160a01b031692506109ca915050565b611c98600183614f2f565b9150611ce4565b611caa866000611cff565b8015611cd157506000868152600c6020908152604080832083805260020190915290205481145b15611ce457611ce1600183614f2f565b91505b611cef600182614f2f565b9050611c23565b50505092915050565b6000918252600a602090815260408084206001600160a01b0393909316845291905290205460ff1690565b611d3261270c565b611d4e5760405162461bcd60e51b8152600401610af290614ea8565b610b0481612cd5565b6060611d616125bd565b60030180546109e890614e74565b6060611af1848484612ec9565b611d8461270c565b611da05760405162461bcd60e51b8152600401610af290614ea8565b6112098383836130db565b80611db46125bd565b6007016000611dc161291a565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155611e0561291a565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611e41911515815260200190565b60405180910390a35050565b60006001611e59612ab3565b03905090565b6000828152600a6020908152604080832083805290915281205460ff16611eac57506000828152600a602090815260408083206001600160a01b038516845290915290205460ff166109ca565b50600192915050565b611ebd613182565b611ed95760405162461bcd60e51b8152600401610af290614ea8565b610b0481613192565b6060816001600160401b03811115611efc57611efc6147de565b604051908082528060200260200182016040528015611f2f57816020015b6060815260200190600190039081611f1a5790505b5090506000611f3c6133b4565b9050336001600160a01b038216141560005b84811015611cf6578115611fcd57611fab30878784818110611f7257611f72614f83565b9050602002810190611f849190614fb9565b86604051602001611f97939291906152e9565b6040516020818303038152906040526133be565b848281518110611fbd57611fbd614f83565b602002602001018190525061204d565b61202f30878784818110611fe357611fe3614f83565b9050602002810190611ff59190614fb9565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506133be92505050565b84828151811061204157612041614f83565b60200260200101819052505b600101611f4e565b60068054819061206490614e74565b80601f016020809104026020016040519081016040528092919081815260200182805461209090614e74565b80156120dd5780601f106120b2576101008083540402835291602001916120dd565b820191906000526020600020905b8154815290600101906020018083116120c057829003601f168201915b5050505050908060010180546120f290614e74565b80601f016020809104026020016040519081016040528092919081815260200182805461211e90614e74565b801561216b5780601f106121405761010080835404028352916020019161216b565b820191906000526020600020905b81548152906001019060200180831161214e57829003601f168201915b50505050509080600201805461218090614e74565b80601f01602080910402602001604051908101604052809291908181526020018280546121ac90614e74565b80156121f95780601f106121ce576101008083540402835291602001916121f9565b820191906000526020600020905b8154815290600101906020018083116121dc57829003601f168201915b50505050509080600301805461220e90614e74565b80601f016020809104026020016040519081016040528092919081815260200182805461223a90614e74565b80156122875780601f1061225c57610100808354040283529160200191612287565b820191906000526020600020905b81548152906001019060200180831161226a57829003601f168201915b5050505050905084565b61229c848484610eea565b6001600160a01b0383163b156122cc576122b8848484846133ea565b6122cc576122cc6368d2bf6b60e11b61263f565b50505050565b6122da61454b565b60018210612314576122ea612ab3565b821015612314575b6122fb826134d2565b61230b57600019909101906122f2565b6109ca826134f2565b919050565b600e54600d54600091829161232e9190614f2f565b90505b600d5481111561238557600f600061234a60018461530a565b81526020019081526020016000206000015442106123735761236d60018261530a565b91505090565b8061237d8161531d565b915050612331565b5060405162461bcd60e51b815260206004820152600b60248201526a10a1a7a72224aa24a7a71760a91b6044820152606401610af2565b60606123c7826125e1565b6123f95760405162461bcd60e51b815260206004820152600360248201526208525160ea1b6044820152606401610af2565b6109ca8261351d565b6000818152600c6020526040812054815b81811015612466576000848152600c602090815260408083208484526001019091529020546001600160a01b03161561245457612451600184614f2f565b92505b61245f600182614f2f565b9050612413565b50612472836000611cff565b1561248557612482600183614f2f565b91505b50919050565b6000828152600b60205260409020546111d590336129c8565b600180546124b190614e74565b80601f01602080910402602001604051908101604052809291908181526020018280546124dd90614e74565b801561252a5780601f106124ff5761010080835404028352916020019161252a565b820191906000526020600020905b81548152906001019060200180831161250d57829003601f168201915b505050505081565b600061253c6125bd565b6001600160a01b039384166000908152600791909101602090815260408083209490951682529290925250205460ff1690565b60006301ffc9a760e01b6001600160e01b0319831614806125a057506380ac58cd60e01b6001600160e01b03198316145b806109ca5750506001600160e01b031916635b5e139f60e01b1490565b7f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c4090565b600081600111612314576125f36125bd565b548210156123145760005b6126066125bd565b6000848152600491909101602052604081205491508190036126325761262b8361531d565b92506125fe565b600160e01b161592915050565b8060005260046000fd5b6000612654836115b3565b905081801561267c5750806001600160a01b031661267061291a565b6001600160a01b031614155b156126a15761268d8161099f61291a565b6126a1576126a16367d9dca160e11b61263f565b836126aa6125bd565b6000858152600691909101602052604080822080546001600160a01b0319166001600160a01b0394851617905551859287811692908516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259190a450505050565b60006111e9816106746133b4565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d7690600090a35050565b6000808281805b875181101561282457612787600283614f42565b9150600088828151811061279d5761279d614f83565b602002602001015190508084116127df57604080516020810186905290810182905260600160405160208183030381529060405280519060200120935061281b565b60408051602081018390529081018590526060016040516020818303038152906040528051906020012093506001836128189190614f2f565b92505b50600101612773565b50941495939450505050565b6000816001116128e2576128426125bd565b6000838152600491909101602052604081205491508190036128cf576128666125bd565b54821061287d5761287d636f96cda160e11b61263f565b6128856125bd565b60001990920160008181526004939093016020526040909220549050801561287d57600160e01b81166000036128ba57919050565b6128ca636f96cda160e11b61263f565b61287d565b600160e01b81166000036128e257919050565b612314636f96cda160e11b61263f565b60008060006128ff6125bd565b60009485526006016020525050604090912080549092909150565b60006111e96133b4565b6129316075546000611cff565b15801561294657506001600160a01b03841615155b801561295a57506001600160a01b03831615155b156122cc5761296b60755485611cff565b158015612981575061297f60755484611cff565b155b156122cc5760405162461bcd60e51b8152602060048201526002602482015261085560f21b6044820152606401610af2565b4260a01b176001600160a01b03919091161790565b6000828152600a602090815260408083206001600160a01b038516845290915290205460ff16610aca57612a06816001600160a01b03166014613795565b612a11836020613795565b604051602001612a22929190615350565b60408051601f198184030181529082905262461bcd60e51b8252610af29160040161460e565b612a528282613930565b610aca828261398b565b612a6682826139f8565b6000828152600c602090815260408083206001600160a01b03851680855260028201808552838620805487526001909301855292852080546001600160a01b031916905584529152555050565b6000612abd6125bd565b54919050565b6000612ace83612830565b905080600080612add866128f2565b915091508415612b1857612af48184610f3861291a565b612b1857612b048361099f61291a565b612b1857612b18632ce44b5f60e11b61263f565b612b26836000886001612924565b8015612b3157600082555b6001600160801b03612b416125bd565b6001600160a01b0385166000908152600591909101602052604090208054919091019055612b7383600360e01b6129b3565b612b7b6125bd565b60008881526004919091016020526040812091909155600160e11b85169003612bf15760018601612baa6125bd565b600082815260049190910160205260408120549003612bef57612bcb6125bd565b548114612bef5784612bdb6125bd565b600083815260049190910160205260409020555b505b60405186906000906001600160a01b0386169060008051602061593a833981519152908390a4612c1f6125bd565b600190810180549091019055505050505050565b7fee151c8401928dc223602bb187aff91b9a56c7cae5476ef1b3287b085a16c85f90565b6001600160a01b03163b151590565b600054610100900460ff16612c8d5760405162461bcd60e51b8152600401610af2906153bd565b612c95613a5a565b610b0481613a83565b612ca6612c33565b54610100900460ff16612ccb5760405162461bcd60e51b8152600401610af290615408565b610aca8282613b08565b600060018054612ce490614e74565b80601f0160208091040260200160405190810160405280929190818152602001828054612d1090614e74565b8015612d5d5780601f10612d3257610100808354040283529160200191612d5d565b820191906000526020600020905b815481529060010190602001808311612d4057829003601f168201915b505050505090508160019081612d73919061545c565b507fc9c7c3fe08b88b4df9d4d47ef47d2c43d55c025a0ba88ca442580ed9e7348a168183604051612da5929190615515565b60405180910390a15050565b612710811115612dd35760405162461bcd60e51b8152600401610af290615543565b600280546001600160a01b0384166001600160b01b03199091168117600160a01b61ffff851602179091556040518281527f90d7ec04bcb8978719414f82e52e4cb651db41d0e6f8cea6118c2191e6183adb9060200160405180910390a25050565b6001600160a01b038116612e7f5760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c9958da5c1a595b9d607a1b6044820152606401610af2565b600480546001600160a01b0319166001600160a01b0383169081179091556040517f299d17e95023f496e0ffc4909cff1a61f74bb5eb18de6f900f4155bfa1b3b33390600090a250565b6060818310612ee257612ee2631960ccad60e11b61263f565b6001831015612ef057600192505b6000612efa612ab3565b9050808310612f07578092505b60606000612f1487611748565b85871090810291508115612fc5578187870311612f315786860391505b60405192506001820160051b83016040526000612f4d886122d2565b905060008160400151612f5e575080515b60005b612f6a8a6134f2565b9250604083015160008114612f825760009250612fa7565b835115612f8e57835192505b8b831860601b612fa7576001820191508a8260051b8801525b5060018a019950888a1480612fbb57508481145b15612f6157855250505b50909695505050505050565b505050505050565b8060000361301d5734156130185760405162461bcd60e51b81526020600482015260066024820152652156616c756560d01b6044820152606401610af2565b6122cc565b60006130298285614f42565b9050600073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed196001600160a01b0385160161305b575034811461305f565b5034155b806130915760405162461bcd60e51b815260206004820152600260248201526110ab60f11b6044820152606401610af2565b60006001600160a01b038716156130a857866130b0565b6130b0610a6b565b90506110a4856130be6133b4565b8386613b74565b60006130cf612ab3565b90506109ca8383613bb5565b6127108111156130fd5760405162461bcd60e51b8152600401610af290615543565b6040805180820182526001600160a01b038481168083526020808401868152600089815260038352869020945185546001600160a01b031916941693909317845591516001909301929092559151838152909185917f7365cf4122f072a3365c20d54eff9b38d73c096c28e1892ec8f5b0e403a0f12d910160405180910390a3505050565b60006111e96076546106746133b4565b6040805160808101909152806131a88380614fb9565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050908252506020908101906131f190840184614fb9565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050908252506020016132386040840184614fb9565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050509082525060200161327f6060840184614fb9565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050915250805160069081906132c6908261545c565b50602082015160018201906132db908261545c565b50604082015160028201906132f0908261545c565b5060608201516003820190613305908261545c565b5050604080516000815260001960208201527f6bd5c950a8d8df17f772f5af37cb3655737899cbf903264b9795592da439661c92500160405180910390a17f8edd7f36d5f01bd45e59cf55b0a670dcf701fc20f678970a8c243b2346d6acaf61336e8280614fb9565b61337b6020850185614fb9565b6133886040870187614fb9565b6133956060890189614fb9565b6040516133a998979695949392919061556c565b60405180910390a150565b60006111e9613bcf565b60606133e3838360405180606001604052806027815260200161591360279139613bf1565b9392505050565b6000836001600160a01b031663150b7a0261340361291a565b8786866040518563ffffffff1660e01b815260040161342594939291906155cc565b6020604051808303816000875af1925050508015613460575060408051601f3d908101601f1916820190925261345d918101906155ff565b60015b6134b5573d80801561348e576040519150601f19603f3d011682016040523d82523d6000602084013e613493565b606091505b5080516000036134ad576134ad6368d2bf6b60e11b61263f565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050949350505050565b60006134dc6125bd565b6000928352600401602052506040902054151590565b6134fa61454b565b6109ca6135056125bd565b60008481526004919091016020526040902054613c69565b60606000600660405180608001604052908160008201805461353e90614e74565b80601f016020809104026020016040519081016040528092919081815260200182805461356a90614e74565b80156135b75780601f1061358c576101008083540402835291602001916135b7565b820191906000526020600020905b81548152906001019060200180831161359a57829003601f168201915b505050505081526020016001820180546135d090614e74565b80601f01602080910402602001604051908101604052809291908181526020018280546135fc90614e74565b80156136495780601f1061361e57610100808354040283529160200191613649565b820191906000526020600020905b81548152906001019060200180831161362c57829003601f168201915b5050505050815260200160028201805461366290614e74565b80601f016020809104026020016040519081016040528092919081815260200182805461368e90614e74565b80156136db5780601f106136b0576101008083540402835291602001916136db565b820191906000526020600020905b8154815290600101906020018083116136be57829003601f168201915b505050505081526020016003820180546136f490614e74565b80601f016020809104026020016040519081016040528092919081815260200182805461372090614e74565b801561376d5780601f106137425761010080835404028352916020019161376d565b820191906000526020600020905b81548152906001019060200180831161375057829003601f168201915b5050505050815250509050612482816000015182602001518360400151846060015187613cac565b606060006137a4836002614f42565b6137af906002614f2f565b6001600160401b038111156137c6576137c66147de565b6040519080825280601f01601f1916602001820160405280156137f0576020820181803683370190505b509050600360fc1b8160008151811061380b5761380b614f83565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061383a5761383a614f83565b60200101906001600160f81b031916908160001a905350600061385e846002614f42565b613869906001614f2f565b90505b60018111156138e1576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061389d5761389d614f83565b1a60f81b8282815181106138b3576138b3614f83565b60200101906001600160f81b031916908160001a90535060049490941c936138da8161531d565b905061386c565b5083156133e35760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610af2565b6000828152600a602090815260408083206001600160a01b0385168085529252808320805460ff1916600117905551339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b6000828152600c60205260408120805491600191906139aa8385614f2f565b90915550506000928352600c6020908152604080852083865260018101835281862080546001600160a01b039096166001600160a01b03199096168617905593855260029093019052912055565b613a0282826129c8565b6000828152600a602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600054610100900460ff16613a815760405162461bcd60e51b8152600401610af2906153bd565b565b600054610100900460ff16613aaa5760405162461bcd60e51b8152600401610af2906153bd565b60005b8151811015610aca57600160436000848481518110613ace57613ace614f83565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055600101613aad565b613b10612c33565b54610100900460ff16613b355760405162461bcd60e51b8152600401610af290615408565b81613b3e6125bd565b60020190613b4c908261545c565b5080613b566125bd565b60030190613b64908261545c565b506001613b6f6125bd565b555050565b80156122cc5773eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed196001600160a01b03851601613ba9576130188282613ce1565b6122cc84848484613d83565b610aca828260405180602001604052806000815250613dd6565b6000613bda33611567565b15613bec575060131936013560601c90565b503390565b6060600080856001600160a01b031685604051613c0e919061561c565b600060405180830381855af49150503d8060008114613c49576040519150601f19603f3d011682016040523d82523d6000602084013e613c4e565b606091505b5091509150613c5f86838387613e4f565b9695505050505050565b613c7161454b565b6001600160a01b03821681526001600160401b0360a083901c166020820152600160e01b82161515604082015260e89190911c606082015290565b60606000613cba8585613ec6565b90506000613cca88888487613f53565b9050613cd581613f99565b98975050505050505050565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114613d2e576040519150601f19603f3d011682016040523d82523d6000602084013e613d33565b606091505b50509050806112095760405162461bcd60e51b815260206004820152601c60248201527b1b985d1a5d99481d1bdad95b881d1c985b9cd9995c8819985a5b195960221b6044820152606401610af2565b816001600160a01b0316836001600160a01b031603156122cc57306001600160a01b03841603613dc1576130186001600160a01b0385168383613fca565b6122cc6001600160a01b038516848484614020565b613de08383614058565b6001600160a01b0383163b15611209576000613dfa6125bd565b5490508281035b613e1460008683806001019450866133ea565b613e2857613e286368d2bf6b60e11b61263f565b818110613e015781613e386125bd565b5414613e4857613e48600061263f565b5050505050565b60608315613ebc578251600003613eb557613e6985612c57565b613eb55760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610af2565b5081611af1565b611af1838361413e565b81518151606091158015911515908290613edd5750805b15613f0d578484604051602001613ef592919061562e565b604051602081830303815290604052925050506109ca565b8115613f245784604051602001613ef591906156a5565b8015613f3b5783604051602001613ef591906156e5565b50506040805160208101909152600081529392505050565b606084613f5f83614168565b8585613f6a86614168565b89604051602001613f809695949392919061572d565b6040516020818303038152906040529050949350505050565b6060613fa482614268565b604051602001613fb49190615843565b6040516020818303038152906040529050919050565b6112098363a9059cbb60e01b8484604051602401613fe9929190614795565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526143ba565b6040516001600160a01b03808516602483015283166044820152606481018290526122cc9085906323b872dd60e01b90608401613fe9565b60006140626125bd565b549050600082900361407e5761407e63b562e8dd60e01b61263f565b61408b6000848385612924565b61409b836001841460e11b6129b3565b6140a36125bd565b600083815260049190910160205260409020556001600160401b0182026140c86125bd565b6001600160a01b038516600081815260059290920160205260408220805490930190925581900361410257614102622e076360e81b61263f565b818301825b8083600060008051602061593a833981519152600080a481816001019150810361410757816141346125bd565b5550611209915050565b81511561414e5781518083602001fd5b8060405162461bcd60e51b8152600401610af2919061460e565b60608160000361418f5750506040805180820190915260018152600360fc1b602082015290565b8160005b81156141b957806141a381615888565b91506141b29050600a83614f6f565b9150614193565b6000816001600160401b038111156141d3576141d36147de565b6040519080825280601f01601f1916602001820160405280156141fd576020820181803683370190505b5090505b8415611af15761421260018361530a565b915061421f600a866158a1565b61422a906030614f2f565b60f81b81838151811061423f5761423f614f83565b60200101906001600160f81b031916908160001a905350614261600a86614f6f565b9450614201565b6060815160000361428757505060408051602081019091526000815290565b60006040518060600160405280604081526020016158d360409139905060006003845160026142b69190614f2f565b6142c09190614f6f565b6142cb906004614f42565b6001600160401b038111156142e2576142e26147de565b6040519080825280601f01601f19166020018201604052801561430c576020820181803683370190505b509050600182016020820185865187015b80821015614378576003820191508151603f8160121c168501518453600184019350603f81600c1c168501518453600184019350603f8160061c168501518453600184019350603f811685015184535060018301925061431d565b505060038651066001811461439457600281146143a7576143af565b603d6001830353603d60028303536143af565b603d60018303535b509195945050505050565b600061440f826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661448c9092919063ffffffff16565b805190915015611209578080602001905181019061442d91906158b5565b6112095760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610af2565b6060611af1848460008585600080866001600160a01b031685876040516144b3919061561c565b60006040518083038185875af1925050503d80600081146144f0576040519150601f19603f3d011682016040523d82523d6000602084013e6144f5565b606091505b509150915061450687838387613e4f565b979650505050505050565b50805461451d90614e74565b6000825580601f1061452d575050565b601f016020900490600052602060002090810190610b049190614572565b60408051608081018252600080825260208201819052918101829052606081019190915290565b5b808211156145875760008155600101614573565b5090565b6001600160e01b031981168114610b0457600080fd5b6000602082840312156145b357600080fd5b81356133e38161458b565b60005b838110156145d95781810151838201526020016145c1565b50506000910152565b600081518084526145fa8160208601602086016145be565b601f01601f19169290920160200192915050565b6020815260006133e360208301846145e2565b60006020828403121561463357600080fd5b5035919050565b6001600160a01b0381168114610b0457600080fd5b80356123148161463a565b6000806040838503121561466d57600080fd5b82356146788161463a565b946020939093013593505050565b60006020828403121561469857600080fd5b81356133e38161463a565b60006080828403121561248557600080fd5b60008060008060008060c087890312156146ce57600080fd5b8635955060208701356146e08161463a565b94506040870135935060608701356146f78161463a565b92506080870135915060a08701356001600160401b0381111561471957600080fd5b61472589828a016146a3565b9150509295509295509295565b60008060006060848603121561474757600080fd5b83356147528161463a565b925060208401356147628161463a565b929592945050506040919091013590565b6000806040838503121561478657600080fd5b50508035926020909101359150565b6001600160a01b03929092168252602082015260400190565b600080604083850312156147c157600080fd5b8235915060208301356147d38161463a565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171561481c5761481c6147de565b604052919050565b600082601f83011261483557600080fd5b81356001600160401b0381111561484e5761484e6147de565b614861601f8201601f19166020016147f4565b81815284602083860101111561487657600080fd5b816020850160208301376000918101602001919091529392505050565b600082601f8301126148a457600080fd5b813560206001600160401b038211156148bf576148bf6147de565b8160051b6148ce8282016147f4565b92835284810182019282810190878511156148e857600080fd5b83870192505b848310156145065782356149018161463a565b825291830191908301906148ee565b80356001600160801b038116811461231457600080fd5b600080600080600080600080610100898b03121561494457600080fd5b61494d8961464f565b975060208901356001600160401b038082111561496957600080fd5b6149758c838d01614824565b985060408b013591508082111561498b57600080fd5b6149978c838d01614824565b975060608b01359150808211156149ad57600080fd5b6149b98c838d01614824565b965060808b01359150808211156149cf57600080fd5b506149dc8b828c01614893565b9450506149eb60a08a0161464f565b92506149f960c08a0161464f565b9150614a0760e08a01614910565b90509295985092959890939650565b6020815281516020820152602082015160408201526040820151606082015260608201516080820152608082015160a082015260a082015160c082015260018060a01b0360c08301511660e0820152600060e0830151610100808185015250611af16101208401826145e2565b60008083601f840112614a9557600080fd5b5081356001600160401b03811115614aac57600080fd5b6020830191508360208260051b8501011115614ac757600080fd5b9250929050565b8015158114610b0457600080fd5b600080600060408486031215614af157600080fd5b83356001600160401b03811115614b0757600080fd5b614b1386828701614a83565b9094509250506020840135614b2781614ace565b809150509250925092565b6020808252825182820181905260009190848201906040850190845b81811015612fc557835183529284019291840191600101614b4e565b60008060008060008060c08789031215614b8357600080fd5b8635614b8e8161463a565b9550602087013594506040870135614ba58161463a565b93506060870135925060808701356001600160401b0380821115614bc857600080fd5b614bd48a838b016146a3565b935060a0890135915080821115614bea57600080fd5b5061472589828a01614824565b600060208284031215614c0957600080fd5b81356001600160401b03811115614c1f57600080fd5b611af184828501614824565b600080600060608486031215614c4057600080fd5b8335614c4b8161463a565b95602085013595506040909401359392505050565b600080600060608486031215614c7557600080fd5b8335925060208401356147628161463a565b60008060408385031215614c9a57600080fd5b8235614ca58161463a565b915060208301356147d381614ace565b600060208284031215614cc757600080fd5b81356001600160401b03811115614cdd57600080fd5b611af1848285016146a3565b60008060208385031215614cfc57600080fd5b82356001600160401b03811115614d1257600080fd5b614d1e85828601614a83565b90969095509350505050565b600060208083016020845280855180835260408601915060408160051b87010192506020870160005b82811015614d8157603f19888603018452614d6f8583516145e2565b94509285019290850190600101614d53565b5092979650505050505050565b608081526000614da160808301876145e2565b8281036020840152614db381876145e2565b90508281036040840152614dc781866145e2565b9050828103606084015261450681856145e2565b60008060008060808587031215614df157600080fd5b8435614dfc8161463a565b93506020850135614e0c8161463a565b92506040850135915060608501356001600160401b03811115614e2e57600080fd5b614e3a87828801614824565b91505092959194509250565b60008060408385031215614e5957600080fd5b8235614e648161463a565b915060208301356147d38161463a565b600181811c90821680614e8857607f821691505b60208210810361248557634e487b7160e01b600052602260045260246000fd5b6020808252600e908201526d139bdd08185d5d1a1bdc9a5e995960921b604082015260600190565b6000808335601e19843603018112614ee757600080fd5b8301803591506001600160401b03821115614f0157600080fd5b6020019150600581901b3603821315614ac757600080fd5b634e487b7160e01b600052601160045260246000fd5b808201808211156109ca576109ca614f19565b80820281158282048414176109ca576109ca614f19565b634e487b7160e01b600052601260045260246000fd5b600082614f7e57614f7e614f59565b500490565b634e487b7160e01b600052603260045260246000fd5b6000823560fe19833603018112614faf57600080fd5b9190910192915050565b6000808335601e19843603018112614fd057600080fd5b8301803591506001600160401b03821115614fea57600080fd5b602001915036819003821315614ac757600080fd5b601f821115611209576000816000526020600020601f850160051c810160208610156150285750805b601f850160051c820191505b81811015612fd157828155600101615034565b600019600383901b1c191660019190911b1790565b6001600160401b03831115615073576150736147de565b615087836150818354614e74565b83614fff565b6000601f8411600181146150b557600085156150a35750838201355b6150ad8682615047565b845550613e48565b600083815260209020601f19861690835b828110156150e657868501358255602094850194600190920191016150c6565b50868210156151035760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b813581556020820135600182015560408201356002820155606082013560038201556080820135600482015560a082013560058201556006810160c083013561515d8161463a565b81546001600160a01b0319166001600160a01b039190911617905561518560e0830183614fb9565b6122cc81836007860161505c565b6000808335601e198436030181126151aa57600080fd5b83016020810192503590506001600160401b038111156151c957600080fd5b803603821315614ac757600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60408082528181018490526000906060808401600587901b850182018885805b8a8110156152d357888403605f190185528235368d900360fe19018112615246578283fd5b8c018035855260208082013581870152888201358987015287820135888701526080808301359087015260a080830135908701526101009060c08084013561528d8161463a565b6001600160a01b03169088015260e06152a884820185615193565b945083828a01526152bc848a0186836151d8565b998301999850505094909401935050600101615221565b50505086151560208701529350611af192505050565b8284823760609190911b6001600160601b0319169101908152601401919050565b818103818111156109ca576109ca614f19565b60008161532c5761532c614f19565b506000190190565b600081516153468185602086016145be565b9290920192915050565b7402832b936b4b9b9b4b7b7399d1030b1b1b7bab73a1605d1b8152600083516153808160158501602088016145be565b7001034b99036b4b9b9b4b733903937b6329607d1b60159184019182015283516153b18160268401602088016145be565b01602601949350505050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60208082526034908201527f455243373231415f5f496e697469616c697a61626c653a20636f6e7472616374604082015273206973206e6f7420696e697469616c697a696e6760601b606082015260800190565b81516001600160401b03811115615475576154756147de565b615489816154838454614e74565b84614fff565b602080601f8311600181146154b857600084156154a65750858301515b6154b08582615047565b865550612fd1565b600085815260208120601f198616915b828110156154e7578886015182559484019460019091019084016154c8565b50858210156155055787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60408152600061552860408301856145e2565b828103602084015261553a81856145e2565b95945050505050565b6020808252600f908201526e45786365656473206d61782062707360881b604082015260600190565b608081526000615580608083018a8c6151d8565b828103602084015261559381898b6151d8565b905082810360408401526155a88187896151d8565b905082810360608401526155bd8185876151d8565b9b9a5050505050505050505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613c5f908301846145e2565b60006020828403121561561157600080fd5b81516133e38161458b565b60008251614faf8184602087016145be565b6834b6b0b3b2911d101160b91b815282516000906156538160098501602088016145be565b741116101130b734b6b0ba34b7b72fbab936111d101160591b600991840191820152835161568881601e8401602088016145be565b631116101160e11b601e9290910191820152602201949350505050565b6834b6b0b3b2911d101160b91b815281516000906156ca8160098501602087016145be565b631116101160e11b6009939091019283015250600d01919050565b7030b734b6b0ba34b7b72fbab936111d101160791b815281516000906157128160118501602087016145be565b631116101160e11b6011939091019283015250601501919050565b693d913730b6b2911d101160b11b8152865160009061575381600a850160208c016145be565b600160fd1b600a91840191820152875161577481600b840160208c016145be565b631116101160e11b600b929091019182018190526e3232b9b1b934b83a34b7b7111d101160891b600f83015287516157b381601e850160208c016145be565b601e92019182015285516157ce816022840160208a016145be565b770383937b832b93a34b2b9911d103d91373ab6b132b9111d160451b6022929091019182015261583661582761582161580a603a850189615334565b6a1610113730b6b2911d101160a91b8152600b0190565b86615334565b62227d7d60e81b815260030190565b9998505050505050505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c00000081526000825161587b81601d8501602087016145be565b91909101601d0192915050565b60006001820161589a5761589a614f19565b5060010190565b6000826158b0576158b0614f59565b500690565b6000602082840312156158c757600080fd5b81516133e381614ace56fe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220b255ddf5ee3f2f8e238df733f24fa187c7fe7b8a7db015f584c4ac237b7580ae64736f6c63430008170033