Feature Tip: Add private address tag to any address under My Name Tag !
Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
0x60806040 | 16827943 | 623 days ago | IN | 0 ETH | 0.21041695 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
BaseFacet
Compiler Version
v0.8.19+commit.7dd6d404
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import {AddressUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import {ERC721AUpgradeable} from "erc721a-upgradeable/contracts/ERC721AUpgradeable.sol"; import {ERC2981} from "@solidstate/contracts/token/common/ERC2981/ERC2981.sol"; import {ERC2981Storage} from "@solidstate/contracts/token/common/ERC2981/ERC2981Storage.sol"; import {IERC165} from "@solidstate/contracts/interfaces/IERC165.sol"; import {OperatorFilterer} from "closedsea/src/OperatorFilterer.sol"; import {MinimalOwnableRoles} from "../internals/MinimalOwnableRoles.sol"; import {INiftyKitAppRegistry} from "../interfaces/INiftyKitAppRegistry.sol"; import {IDiamondCut} from "../interfaces/IDiamondCut.sol"; import {DiamondLoupeFacet} from "./DiamondLoupeFacet.sol"; import {LibDiamond} from "../libraries/LibDiamond.sol"; import {BaseStorage} from "./BaseStorage.sol"; contract BaseFacet is ERC721AUpgradeable, MinimalOwnableRoles, ERC2981, OperatorFilterer, DiamondLoupeFacet { modifier preventTransfers(address from, uint256 tokenId) virtual { BaseStorage.Layout storage layout = BaseStorage.layout(); BaseStorage.Transfer status = layout._transferStatus; if ( status == BaseStorage.Transfer.BlockAll || (status == BaseStorage.Transfer.AllowedOperatorsOnly && !layout._allowedOperators[from] && from != msg.sender) || (layout._blockedTokenIds[tokenId]) ) { revert("Transfers not allowed"); } _; } constructor() initializerERC721A {} function _initialize( address owner_, string calldata name_, string calldata symbol_, address royalty_, uint16 royaltyBps_ ) external initializerERC721A { __ERC721A_init(name_, symbol_); _initializeOwner(owner_); ERC2981Storage.Layout storage layout = ERC2981Storage.layout(); layout.defaultRoyaltyBPS = royaltyBps_; layout.defaultRoyaltyReceiver = royalty_; } function setBaseURI( string memory newBaseURI ) external onlyRolesOrOwner(BaseStorage.MANAGER_ROLE) { BaseStorage.layout()._baseURI = newBaseURI; } function setTreasury(address newTreasury) external onlyOwner { BaseStorage.layout()._treasury = newTreasury; } function withdraw() external onlyOwner { BaseStorage.Layout storage layout = BaseStorage.layout(); uint256 balance = address(this).balance; require(balance > 0, "0 balance"); AddressUpgradeable.sendValue(payable(layout._treasury), balance); } function installApp(bytes32 name) external onlyOwner { _installApp(name, address(0), ""); } function installApp(bytes32 name, bytes memory data) external onlyOwner { _installApp(name, address(this), data); } function removeApp(bytes32 name) external onlyOwner { _removeApp(name, address(0), ""); } function removeApp(bytes32 name, bytes memory data) external onlyOwner { _removeApp(name, address(this), data); } function isApprovedForAll( address owner, address operator ) public view override returns (bool) { BaseStorage.Layout storage layout = BaseStorage.layout(); if ( layout._transferStatus == BaseStorage.Transfer.AllowedOperatorsOnly ) { return layout._allowedOperators[operator]; } return super.isApprovedForAll(owner, operator); } function setApprovalForAll( address operator, bool approved ) public override preventTransfers(operator, 0) onlyAllowedOperatorApproval(operator) { super.setApprovalForAll(operator, approved); } function approve( address operator, uint256 tokenId ) public payable override preventTransfers(operator, tokenId) onlyAllowedOperatorApproval(operator) { super.approve(operator, tokenId); } function transferFrom( address from, address to, uint256 tokenId ) public payable override preventTransfers(from, tokenId) onlyAllowedOperator(from) { super.transferFrom(from, to, tokenId); } function safeTransferFrom( address from, address to, uint256 tokenId ) public payable override preventTransfers(from, tokenId) onlyAllowedOperator(from) { super.safeTransferFrom(from, to, tokenId); } function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory data ) public payable override preventTransfers(from, tokenId) onlyAllowedOperator(from) { super.safeTransferFrom(from, to, tokenId, data); } function tokenURI( uint256 tokenId ) public view virtual override returns (string memory) { if (!_exists(tokenId)) revert URIQueryForNonexistentToken(); BaseStorage.URIEntry memory uri = BaseStorage.layout()._tokenURIs[ tokenId ]; if (uri.isValue) return uri.tokenURI; string memory baseURI = _baseURI(); return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, _toString(tokenId))) : ""; } function treasury() external view returns (address) { return BaseStorage.layout()._treasury; } function getApp( bytes32 name ) external view returns (INiftyKitAppRegistry.App memory) { return BaseStorage.layout()._apps[name]; } function _baseURI() internal view virtual override returns (string memory) { return BaseStorage.layout()._baseURI; } function _isPriorityOperator( address operator ) internal view override returns (bool) { return BaseStorage.layout()._allowedOperators[operator]; } function _operatorFilteringEnabled() internal view override returns (bool) { return BaseStorage.layout()._operatorFilteringEnabled; } function _startTokenId() internal pure override returns (uint256) { return 1; } function _installApp( bytes32 name, address init, bytes memory data ) internal { BaseStorage.Layout storage layout = BaseStorage.layout(); LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); INiftyKitAppRegistry registry = INiftyKitAppRegistry( layout._niftyKit.appRegistry() ); INiftyKitAppRegistry.App memory app = registry.getApp(name); require(app.version > 0, "App does not exist"); IDiamondCut.FacetCut[] memory facetCuts = new IDiamondCut.FacetCut[](1); facetCuts[0] = IDiamondCut.FacetCut({ facetAddress: app.implementation, action: IDiamondCut.FacetCutAction.Add, functionSelectors: app.selectors }); ds.supportedInterfaces[app.interfaceId] = true; LibDiamond.diamondCut(facetCuts, init, data); layout._apps[name] = app; } function _removeApp( bytes32 name, address init, bytes memory data ) internal { BaseStorage.Layout storage layout = BaseStorage.layout(); LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); INiftyKitAppRegistry.App memory app = layout._apps[name]; require(app.version > 0, "App does not exist"); IDiamondCut.FacetCut[] memory facetCuts = new IDiamondCut.FacetCut[](1); facetCuts[0] = IDiamondCut.FacetCut({ facetAddress: address(0), action: IDiamondCut.FacetCutAction.Remove, functionSelectors: app.selectors }); ds.supportedInterfaces[app.interfaceId] = false; // execute callback function before performing a diamond cut LibDiamond.initializeDiamondCut(init, data); LibDiamond.diamondCut(facetCuts, address(0), ""); delete layout._apps[name]; } function supportsInterface( bytes4 interfaceId ) public view virtual override(DiamondLoupeFacet, ERC721AUpgradeable, IERC165) returns (bool) { LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); return ds.supportedInterfaces[interfaceId]; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.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 * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "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"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(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) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason 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 { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.8; import { IERC165Internal } from './IERC165Internal.sol'; /** * @title ERC165 interface registration interface * @dev see https://eips.ethereum.org/EIPS/eip-165 */ interface IERC165 is IERC165Internal { /** * @notice query whether contract has registered support for given interface * @param interfaceId interface id * @return bool whether interface is supported */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.8; import { IERC165Internal } from './IERC165Internal.sol'; /** * @title ERC165 interface registration interface */ interface IERC165Internal { }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.8; import { IERC165 } from './IERC165.sol'; import { IERC2981Internal } from './IERC2981Internal.sol'; /** * @title ERC2981 interface * @dev see https://eips.ethereum.org/EIPS/eip-2981 */ interface IERC2981 is IERC2981Internal, IERC165 { /** * @notice called with the sale price to determine how much royalty is owed and to whom * @param tokenId the ERC721 or ERC1155 token id to query for royalty information * @param salePrice the sale price of the given asset * @return receiever rightful recipient of royalty * @return royaltyAmount amount of royalty owed */ function royaltyInfo( uint256 tokenId, uint256 salePrice ) external view returns (address receiever, uint256 royaltyAmount); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.8; /** * @title ERC2981 interface */ interface IERC2981Internal { }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.8; import { IERC2981 } from '../../../interfaces/IERC2981.sol'; import { ERC2981Storage } from './ERC2981Storage.sol'; import { ERC2981Internal } from './ERC2981Internal.sol'; /** * @title ERC2981 implementation */ abstract contract ERC2981 is IERC2981, ERC2981Internal { /** * @notice inheritdoc IERC2981 */ function royaltyInfo( uint256 tokenId, uint256 salePrice ) external view returns (address, uint256) { return _royaltyInfo(tokenId, salePrice); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.8; import { ERC2981Storage } from './ERC2981Storage.sol'; import { IERC2981Internal } from '../../../interfaces/IERC2981Internal.sol'; /** * @title ERC2981 internal functions */ abstract contract ERC2981Internal is IERC2981Internal { /** * @notice calculate how much royalty is owed and to whom * @dev royalty must be paid in addition to, rather than deducted from, salePrice * @param tokenId the ERC721 or ERC1155 token id to query for royalty information * @param salePrice the sale price of the given asset * @return royaltyReceiver rightful recipient of royalty * @return royalty amount of royalty owed */ function _royaltyInfo( uint256 tokenId, uint256 salePrice ) internal view virtual returns (address royaltyReceiver, uint256 royalty) { uint256 royaltyBPS = _getRoyaltyBPS(tokenId); // intermediate multiplication overflow is theoretically possible here, but // not an issue in practice because of practical constraints of salePrice return (_getRoyaltyReceiver(tokenId), (royaltyBPS * salePrice) / 10000); } /** * @notice query the royalty rate (denominated in basis points) for given token id * @dev implementation supports per-token-id values as well as a global default * @param tokenId token whose royalty rate to query * @return royaltyBPS royalty rate */ function _getRoyaltyBPS( uint256 tokenId ) internal view virtual returns (uint16 royaltyBPS) { ERC2981Storage.Layout storage l = ERC2981Storage.layout(); royaltyBPS = l.royaltiesBPS[tokenId]; if (royaltyBPS == 0) { royaltyBPS = l.defaultRoyaltyBPS; } } /** * @notice query the royalty receiver for given token id * @dev implementation supports per-token-id values as well as a global default * @param tokenId token whose royalty receiver to query * @return royaltyReceiver royalty receiver */ function _getRoyaltyReceiver( uint256 tokenId ) internal view virtual returns (address royaltyReceiver) { ERC2981Storage.Layout storage l = ERC2981Storage.layout(); royaltyReceiver = l.royaltyReceivers[tokenId]; if (royaltyReceiver == address(0)) { royaltyReceiver = l.defaultRoyaltyReceiver; } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.8; library ERC2981Storage { struct Layout { // token id -> royalty (denominated in basis points) mapping(uint256 => uint16) royaltiesBPS; uint16 defaultRoyaltyBPS; // token id -> receiver address mapping(uint256 => address) royaltyReceivers; address defaultRoyaltyReceiver; } bytes32 internal constant STORAGE_SLOT = keccak256('solidstate.contracts.storage.ERC2981'); function layout() internal pure returns (Layout storage l) { bytes32 slot = STORAGE_SLOT; assembly { l.slot := slot } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; /// @notice Optimized and flexible operator filterer to abide to OpenSea's /// mandatory on-chain royalty enforcement in order for new collections to /// receive royalties. /// For more information, see: /// See: https://github.com/ProjectOpenSea/operator-filter-registry abstract contract OperatorFilterer { /// @dev The default OpenSea operator blocklist subscription. address internal constant _DEFAULT_SUBSCRIPTION = 0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6; /// @dev The OpenSea operator filter registry. address internal constant _OPERATOR_FILTER_REGISTRY = 0x000000000000AAeB6D7670E522A718067333cd4E; /// @dev Registers the current contract to OpenSea's operator filter, /// and subscribe to the default OpenSea operator blocklist. /// Note: Will not revert nor update existing settings for repeated registration. function _registerForOperatorFiltering() internal virtual { _registerForOperatorFiltering(_DEFAULT_SUBSCRIPTION, true); } /// @dev Registers the current contract to OpenSea's operator filter. /// Note: Will not revert nor update existing settings for repeated registration. function _registerForOperatorFiltering(address subscriptionOrRegistrantToCopy, bool subscribe) internal virtual { /// @solidity memory-safe-assembly assembly { let functionSelector := 0x7d3e3dbe // `registerAndSubscribe(address,address)`. // Clean the upper 96 bits of `subscriptionOrRegistrantToCopy` in case they are dirty. subscriptionOrRegistrantToCopy := shr(96, shl(96, subscriptionOrRegistrantToCopy)) for {} iszero(subscribe) {} { if iszero(subscriptionOrRegistrantToCopy) { functionSelector := 0x4420e486 // `register(address)`. break } functionSelector := 0xa0af2903 // `registerAndCopyEntries(address,address)`. break } // Store the function selector. mstore(0x00, shl(224, functionSelector)) // Store the `address(this)`. mstore(0x04, address()) // Store the `subscriptionOrRegistrantToCopy`. mstore(0x24, subscriptionOrRegistrantToCopy) // Register into the registry. if iszero(call(gas(), _OPERATOR_FILTER_REGISTRY, 0, 0x00, 0x44, 0x00, 0x04)) { // If the function selector has not been overwritten, // it is an out-of-gas error. if eq(shr(224, mload(0x00)), functionSelector) { // To prevent gas under-estimation. revert(0, 0) } } // Restore the part of the free memory pointer that was overwritten, // which is guaranteed to be zero, because of Solidity's memory size limits. mstore(0x24, 0) } } /// @dev Modifier to guard a function and revert if the caller is a blocked operator. modifier onlyAllowedOperator(address from) virtual { if (from != msg.sender) { if (!_isPriorityOperator(msg.sender)) { if (_operatorFilteringEnabled()) _revertIfBlocked(msg.sender); } } _; } /// @dev Modifier to guard a function from approving a blocked operator.. modifier onlyAllowedOperatorApproval(address operator) virtual { if (!_isPriorityOperator(operator)) { if (_operatorFilteringEnabled()) _revertIfBlocked(operator); } _; } /// @dev Helper function that reverts if the `operator` is blocked by the registry. function _revertIfBlocked(address operator) private view { /// @solidity memory-safe-assembly assembly { // Store the function selector of `isOperatorAllowed(address,address)`, // shifted left by 6 bytes, which is enough for 8tb of memory. // We waste 6-3 = 3 bytes to save on 6 runtime gas (PUSH1 0x224 SHL). mstore(0x00, 0xc6171134001122334455) // Store the `address(this)`. mstore(0x1a, address()) // Store the `operator`. mstore(0x3a, operator) // `isOperatorAllowed` always returns true if it does not revert. if iszero(staticcall(gas(), _OPERATOR_FILTER_REGISTRY, 0x16, 0x44, 0x00, 0x00)) { // Bubble up the revert if the staticcall reverts. returndatacopy(0x00, 0x00, returndatasize()) revert(0x00, returndatasize()) } // We'll skip checking if `from` is inside the blacklist. // Even though that can block transferring out of wrapper contracts, // we don't want tokens to be stuck. // Restore the part of the free memory pointer that was overwritten, // which is guaranteed to be zero, if less than 8tb of memory is used. mstore(0x3a, 0) } } /// @dev For deriving contracts to override, so that operator filtering /// can be turned on / off. /// Returns true by default. function _operatorFilteringEnabled() internal view virtual returns (bool) { return true; } /// @dev For deriving contracts to override, so that preferred marketplaces can /// skip operator filtering, helping users save gas. /// Returns false for all inputs by default. function _isPriorityOperator(address) internal view virtual returns (bool) { return false; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import {INiftyKitAppRegistry} from "../interfaces/INiftyKitAppRegistry.sol"; import {INiftyKitV3} from "../interfaces/INiftyKitV3.sol"; library BaseStorage { enum Transfer { AllowAll, AllowedOperatorsOnly, BlockAll } struct URIEntry { bool isValue; string tokenURI; } bytes32 private constant STORAGE_SLOT = keccak256("niftykit.base.storage"); uint256 public constant ADMIN_ROLE = 1 << 0; uint256 public constant MANAGER_ROLE = 1 << 1; uint256 public constant API_ROLE = 1 << 2; struct Layout { mapping(bytes32 => INiftyKitAppRegistry.App) _apps; mapping(address => bool) _allowedOperators; mapping(uint256 => bool) _blockedTokenIds; mapping(uint256 => URIEntry) _tokenURIs; bool _operatorFilteringEnabled; Transfer _transferStatus; INiftyKitV3 _niftyKit; uint8 _baseVersion; address _treasury; string _baseURI; } function layout() internal pure returns (Layout storage ds) { bytes32 position = STORAGE_SLOT; // solhint-disable-next-line no-inline-assembly assembly { ds.slot := position } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /******************************************************************************\ * Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen) * EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 /******************************************************************************/ import { LibDiamond } from "../libraries/LibDiamond.sol"; import { IDiamondLoupe } from "../interfaces/IDiamondLoupe.sol"; import { IERC165 } from "../interfaces/IERC165.sol"; // The functions in DiamondLoupeFacet MUST be added to a diamond. // The EIP-2535 Diamond standard requires these functions contract DiamondLoupeFacet is IDiamondLoupe, IERC165 { // Diamond Loupe Functions //////////////////////////////////////////////////////////////////// /// These functions are expected to be called frequently by tools. // // struct Facet { // address facetAddress; // bytes4[] functionSelectors; // } /// @notice Gets all facets and their selectors. /// @return facets_ Facet function facets() external override view returns (Facet[] memory facets_) { LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); facets_ = new Facet[](ds.selectorCount); uint16[] memory numFacetSelectors = new uint16[](ds.selectorCount); uint256 numFacets; uint256 selectorIndex; // loop through function selectors for (uint256 slotIndex; selectorIndex < ds.selectorCount; slotIndex++) { bytes32 slot = ds.selectorSlots[slotIndex]; for (uint256 selectorSlotIndex; selectorSlotIndex < 8; selectorSlotIndex++) { selectorIndex++; if (selectorIndex > ds.selectorCount) { break; } // " << 5 is the same as multiplying by 32 ( * 32) bytes4 selector = bytes4(slot << (selectorSlotIndex << 5)); address facetAddress_ = address(bytes20(ds.facets[selector])); bool continueLoop; for (uint256 facetIndex; facetIndex < numFacets; facetIndex++) { if (facets_[facetIndex].facetAddress == facetAddress_) { facets_[facetIndex].functionSelectors[numFacetSelectors[facetIndex]] = selector; // probably will never have more than 256 functions from one facet contract require(numFacetSelectors[facetIndex] < 255); numFacetSelectors[facetIndex]++; continueLoop = true; break; } } if (continueLoop) { continue; } facets_[numFacets].facetAddress = facetAddress_; facets_[numFacets].functionSelectors = new bytes4[](ds.selectorCount); facets_[numFacets].functionSelectors[0] = selector; numFacetSelectors[numFacets] = 1; numFacets++; } } for (uint256 facetIndex; facetIndex < numFacets; facetIndex++) { uint256 numSelectors = numFacetSelectors[facetIndex]; bytes4[] memory selectors = facets_[facetIndex].functionSelectors; // setting the number of selectors assembly { mstore(selectors, numSelectors) } } // setting the number of facets assembly { mstore(facets_, numFacets) } } /// @notice Gets all the function selectors supported by a specific facet. /// @param _facet The facet address. /// @return _facetFunctionSelectors The selectors associated with a facet address. function facetFunctionSelectors(address _facet) external override view returns (bytes4[] memory _facetFunctionSelectors) { LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); uint256 numSelectors; _facetFunctionSelectors = new bytes4[](ds.selectorCount); uint256 selectorIndex; // loop through function selectors for (uint256 slotIndex; selectorIndex < ds.selectorCount; slotIndex++) { bytes32 slot = ds.selectorSlots[slotIndex]; for (uint256 selectorSlotIndex; selectorSlotIndex < 8; selectorSlotIndex++) { selectorIndex++; if (selectorIndex > ds.selectorCount) { break; } // " << 5 is the same as multiplying by 32 ( * 32) bytes4 selector = bytes4(slot << (selectorSlotIndex << 5)); address facet = address(bytes20(ds.facets[selector])); if (_facet == facet) { _facetFunctionSelectors[numSelectors] = selector; numSelectors++; } } } // Set the number of selectors in the array assembly { mstore(_facetFunctionSelectors, numSelectors) } } /// @notice Get all the facet addresses used by a diamond. /// @return facetAddresses_ function facetAddresses() external override view returns (address[] memory facetAddresses_) { LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); facetAddresses_ = new address[](ds.selectorCount); uint256 numFacets; uint256 selectorIndex; // loop through function selectors for (uint256 slotIndex; selectorIndex < ds.selectorCount; slotIndex++) { bytes32 slot = ds.selectorSlots[slotIndex]; for (uint256 selectorSlotIndex; selectorSlotIndex < 8; selectorSlotIndex++) { selectorIndex++; if (selectorIndex > ds.selectorCount) { break; } // " << 5 is the same as multiplying by 32 ( * 32) bytes4 selector = bytes4(slot << (selectorSlotIndex << 5)); address facetAddress_ = address(bytes20(ds.facets[selector])); bool continueLoop; for (uint256 facetIndex; facetIndex < numFacets; facetIndex++) { if (facetAddress_ == facetAddresses_[facetIndex]) { continueLoop = true; break; } } if (continueLoop) { continue; } facetAddresses_[numFacets] = facetAddress_; numFacets++; } } // Set the number of facet addresses in the array assembly { mstore(facetAddresses_, numFacets) } } /// @notice Gets the facet that supports the given selector. /// @dev If facet is not found return address(0). /// @param _functionSelector The function selector. /// @return facetAddress_ The facet address. function facetAddress(bytes4 _functionSelector) external override view returns (address facetAddress_) { LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); facetAddress_ = address(bytes20(ds.facets[_functionSelector])); } // This implements ERC-165. function supportsInterface(bytes4 _interfaceId) external virtual override view returns (bool) { LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); return ds.supportedInterfaces[_interfaceId]; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /******************************************************************************\ * Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen) * EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 /******************************************************************************/ interface IDiamondCut { enum FacetCutAction {Add, Replace, Remove} // Add=0, Replace=1, Remove=2 struct FacetCut { address facetAddress; FacetCutAction action; bytes4[] functionSelectors; } /// @notice Add/replace/remove any number of functions and optionally execute /// a function with delegatecall /// @param _diamondCut Contains the facet addresses and function selectors /// @param _init The address of the contract or facet to execute _calldata /// @param _calldata A function call, including function selector and arguments /// _calldata is executed with delegatecall on _init function diamondCut( FacetCut[] calldata _diamondCut, address _init, bytes calldata _calldata ) external; event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /******************************************************************************\ * Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen) * EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 /******************************************************************************/ // A loupe is a small magnifying glass used to look at diamonds. // These functions look at diamonds interface IDiamondLoupe { /// These functions are expected to be called frequently /// by tools. struct Facet { address facetAddress; bytes4[] functionSelectors; } /// @notice Gets all facet addresses and their four byte function selectors. /// @return facets_ Facet function facets() external view returns (Facet[] memory facets_); /// @notice Gets all the function selectors supported by a specific facet. /// @param _facet The facet address. /// @return facetFunctionSelectors_ function facetFunctionSelectors(address _facet) external view returns (bytes4[] memory facetFunctionSelectors_); /// @notice Get all the facet addresses used by a diamond. /// @return facetAddresses_ function facetAddresses() external view returns (address[] memory facetAddresses_); /// @notice Gets the facet that supports the given selector. /// @dev If facet is not found return address(0). /// @param _functionSelector The function selector. /// @return facetAddress_ The facet address. function facetAddress(bytes4 _functionSelector) external view returns (address facetAddress_); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IERC165 { /// @notice Query if a contract implements an interface /// @param interfaceId The interface identifier, as specified in ERC-165 /// @dev Interface identification is specified in ERC-165. This function /// uses less than 30,000 gas. /// @return `true` if the contract implements `interfaceID` and /// `interfaceID` is not 0xffffffff, `false` otherwise function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; interface INiftyKitAppRegistry { struct App { address implementation; bytes4 interfaceId; bytes4[] selectors; uint8 version; } struct Base { address implementation; bytes4[] interfaceIds; bytes4[] selectors; uint8 version; } /** * Get App Facet by app name * @param name app name */ function getApp(bytes32 name) external view returns (App memory); /** * Get base Facet */ function getBase() external view returns (Base memory); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; interface INiftyKitV3 { /** * @dev Returns app registry address. */ function appRegistry() external returns (address); /** * @dev Returns the commission amount (sellerFee, buyerFee). */ function commission( address collection, uint256 amount ) external view returns (uint256, uint256); /** * @dev Get fees by amount (called from collection) */ function getFees(uint256 amount) external view returns (uint256, uint256); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; /// @notice Simple single owner authorization mixin. /// @author Solady (https://github.com/vectorized/solady/blob/main/src/auth/Ownable.sol) /// @dev While the ownable portion follows [EIP-173](https://eips.ethereum.org/EIPS/eip-173) /// for compatibility, the nomenclature for the 2-step ownership handover /// may be unique to this codebase. abstract contract MinimalOwnable { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CUSTOM ERRORS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The caller is not authorized to call the function. error Unauthorized(); /// @dev The `newOwner` cannot be the zero address. error NewOwnerIsZeroAddress(); /// @dev The `pendingOwner` does not have a valid handover request. error NoHandoverRequest(); /// @dev `bytes4(keccak256(bytes("Unauthorized()")))`. uint256 private constant _UNAUTHORIZED_ERROR_SELECTOR = 0x82b42900; /// @dev `bytes4(keccak256(bytes("NewOwnerIsZeroAddress()")))`. uint256 private constant _NEW_OWNER_IS_ZERO_ADDRESS_ERROR_SELECTOR = 0x7448fbae; /// @dev `bytes4(keccak256(bytes("NoHandoverRequest()")))`. uint256 private constant _NO_HANDOVER_REQUEST_ERROR_SELECTOR = 0x6f5e8818; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* EVENTS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The ownership is transferred from `oldOwner` to `newOwner`. /// This event is intentionally kept the same as OpenZeppelin's Ownable to be /// compatible with indexers and [EIP-173](https://eips.ethereum.org/EIPS/eip-173), /// despite it not being as lightweight as a single argument event. event OwnershipTransferred(address indexed oldOwner, address indexed newOwner); /// @dev An ownership handover to `pendingOwner` has been requested. event OwnershipHandoverRequested(address indexed pendingOwner); /// @dev The ownership handover to `pendingOwner` has been canceled. event OwnershipHandoverCanceled(address indexed pendingOwner); /// @dev `keccak256(bytes("OwnershipTransferred(address,address)"))`. uint256 private constant _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE = 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0; /// @dev `keccak256(bytes("OwnershipHandoverRequested(address)"))`. uint256 private constant _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE = 0xdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d; /// @dev `keccak256(bytes("OwnershipHandoverCanceled(address)"))`. uint256 private constant _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE = 0xfa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* STORAGE */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The owner slot is given by: `not(_OWNER_SLOT_NOT)`. /// It is intentionally choosen to be a high value /// to avoid collision with lower slots. /// The choice of manual storage layout is to enable compatibility /// with both regular and upgradeable contracts. uint256 private constant _OWNER_SLOT_NOT = 0x8b78c6d8; /// The ownership handover slot of `newOwner` is given by: /// ``` /// mstore(0x00, or(shl(96, user), _HANDOVER_SLOT_SEED)) /// let handoverSlot := keccak256(0x00, 0x20) /// ``` /// It stores the expiry timestamp of the two-step ownership handover. uint256 private constant _HANDOVER_SLOT_SEED = 0x389a75e1; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* INTERNAL FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Initializes the owner directly without authorization guard. /// This function must be called upon initialization, /// regardless of whether the contract is upgradeable or not. /// This is to enable generalization to both regular and upgradeable contracts, /// and to save gas in case the initial owner is not the caller. /// For performance reasons, this function will not check if there /// is an existing owner. function _initializeOwner(address newOwner) internal virtual { /// @solidity memory-safe-assembly assembly { // Clean the upper 96 bits. newOwner := shr(96, shl(96, newOwner)) // Store the new value. sstore(not(_OWNER_SLOT_NOT), newOwner) // Emit the {OwnershipTransferred} event. log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, 0, newOwner) } } /// @dev Sets the owner directly without authorization guard. function _setOwner(address newOwner) internal virtual { /// @solidity memory-safe-assembly assembly { let ownerSlot := not(_OWNER_SLOT_NOT) // Clean the upper 96 bits. newOwner := shr(96, shl(96, newOwner)) // Emit the {OwnershipTransferred} event. log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, sload(ownerSlot), newOwner) // Store the new value. sstore(ownerSlot, newOwner) } } /// @dev Throws if the sender is not the owner. function _checkOwner() internal view virtual { /// @solidity memory-safe-assembly assembly { // If the caller is not the stored owner, revert. if iszero(eq(caller(), sload(not(_OWNER_SLOT_NOT)))) { mstore(0x00, _UNAUTHORIZED_ERROR_SELECTOR) revert(0x1c, 0x04) } } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* PUBLIC UPDATE FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Allows the owner to transfer the ownership to `newOwner`. function transferOwnership(address newOwner) public payable virtual onlyOwner { /// @solidity memory-safe-assembly assembly { if iszero(shl(96, newOwner)) { mstore(0x00, _NEW_OWNER_IS_ZERO_ADDRESS_ERROR_SELECTOR) revert(0x1c, 0x04) } } _setOwner(newOwner); } /// @dev Allows the owner to renounce their ownership. function renounceOwnership() public payable virtual onlyOwner { _setOwner(address(0)); } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* PUBLIC READ FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns the owner of the contract. function owner() public view virtual returns (address result) { /// @solidity memory-safe-assembly assembly { result := sload(not(_OWNER_SLOT_NOT)) } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* MODIFIERS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Marks a function as only callable by the owner. modifier onlyOwner() virtual { _checkOwner(); _; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "./MinimalOwnable.sol"; /// @notice Simple single owner and multiroles authorization mixin. /// @author Solady (https://github.com/vectorized/solady/blob/main/src/auth/Ownable.sol) /// @dev While the ownable portion follows [EIP-173](https://eips.ethereum.org/EIPS/eip-173) /// for compatibility, the nomenclature for the 2-step ownership handover and roles /// may be unique to this codebase. abstract contract MinimalOwnableRoles is MinimalOwnable { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CUSTOM ERRORS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev `bytes4(keccak256(bytes("Unauthorized()")))`. uint256 private constant _UNAUTHORIZED_ERROR_SELECTOR = 0x82b42900; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* EVENTS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The `user`'s roles is updated to `roles`. /// Each bit of `roles` represents whether the role is set. event RolesUpdated(address indexed user, uint256 indexed roles); /// @dev `keccak256(bytes("RolesUpdated(address,uint256)"))`. uint256 private constant _ROLES_UPDATED_EVENT_SIGNATURE = 0x715ad5ce61fc9595c7b415289d59cf203f23a94fa06f04af7e489a0a76e1fe26; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* STORAGE */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The role slot of `user` is given by: /// ``` /// mstore(0x00, or(shl(96, user), _ROLE_SLOT_SEED)) /// let roleSlot := keccak256(0x00, 0x20) /// ``` /// This automatically ignores the upper bits of the `user` in case /// they are not clean, as well as keep the `keccak256` under 32-bytes. /// /// Note: This is equal to `_OWNER_SLOT_NOT` in for gas efficiency. uint256 private constant _ROLE_SLOT_SEED = 0x8b78c6d8; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* INTERNAL FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Grants the roles directly without authorization guard. /// Each bit of `roles` represents the role to turn on. function _grantRoles(address user, uint256 roles) internal virtual { /// @solidity memory-safe-assembly assembly { // Compute the role slot. mstore(0x0c, _ROLE_SLOT_SEED) mstore(0x00, user) let roleSlot := keccak256(0x0c, 0x20) // Load the current value and `or` it with `roles`. roles := or(sload(roleSlot), roles) // Store the new value. sstore(roleSlot, roles) // Emit the {RolesUpdated} event. log3(0, 0, _ROLES_UPDATED_EVENT_SIGNATURE, shr(96, mload(0x0c)), roles) } } /// @dev Removes the roles directly without authorization guard. /// Each bit of `roles` represents the role to turn off. function _removeRoles(address user, uint256 roles) internal virtual { /// @solidity memory-safe-assembly assembly { // Compute the role slot. mstore(0x0c, _ROLE_SLOT_SEED) mstore(0x00, user) let roleSlot := keccak256(0x0c, 0x20) // Load the current value. let currentRoles := sload(roleSlot) // Use `and` to compute the intersection of `currentRoles` and `roles`, // `xor` it with `currentRoles` to flip the bits in the intersection. roles := xor(currentRoles, and(currentRoles, roles)) // Then, store the new value. sstore(roleSlot, roles) // Emit the {RolesUpdated} event. log3(0, 0, _ROLES_UPDATED_EVENT_SIGNATURE, shr(96, mload(0x0c)), roles) } } /// @dev Throws if the sender does not have any of the `roles`. function _checkRoles(uint256 roles) internal view virtual { /// @solidity memory-safe-assembly assembly { // Compute the role slot. mstore(0x0c, _ROLE_SLOT_SEED) mstore(0x00, caller()) // Load the stored value, and if the `and` intersection // of the value and `roles` is zero, revert. if iszero(and(sload(keccak256(0x0c, 0x20)), roles)) { mstore(0x00, _UNAUTHORIZED_ERROR_SELECTOR) revert(0x1c, 0x04) } } } /// @dev Throws if the sender is not the owner, /// and does not have any of the `roles`. /// Checks for ownership first, then lazily checks for roles. function _checkOwnerOrRoles(uint256 roles) internal view virtual { /// @solidity memory-safe-assembly assembly { // If the caller is not the stored owner. // Note: `_ROLE_SLOT_SEED` is equal to `_OWNER_SLOT_NOT`. if iszero(eq(caller(), sload(not(_ROLE_SLOT_SEED)))) { // Compute the role slot. mstore(0x0c, _ROLE_SLOT_SEED) mstore(0x00, caller()) // Load the stored value, and if the `and` intersection // of the value and `roles` is zero, revert. if iszero(and(sload(keccak256(0x0c, 0x20)), roles)) { mstore(0x00, _UNAUTHORIZED_ERROR_SELECTOR) revert(0x1c, 0x04) } } } } /// @dev Throws if the sender does not have any of the `roles`, /// and is not the owner. /// Checks for roles first, then lazily checks for ownership. function _checkRolesOrOwner(uint256 roles) internal view virtual { /// @solidity memory-safe-assembly assembly { // Compute the role slot. mstore(0x0c, _ROLE_SLOT_SEED) mstore(0x00, caller()) // Load the stored value, and if the `and` intersection // of the value and `roles` is zero, revert. if iszero(and(sload(keccak256(0x0c, 0x20)), roles)) { // If the caller is not the stored owner. // Note: `_ROLE_SLOT_SEED` is equal to `_OWNER_SLOT_NOT`. if iszero(eq(caller(), sload(not(_ROLE_SLOT_SEED)))) { mstore(0x00, _UNAUTHORIZED_ERROR_SELECTOR) revert(0x1c, 0x04) } } } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* PUBLIC UPDATE FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Allows the owner to grant `user` `roles`. /// If the `user` already has a role, then it will be an no-op for the role. function grantRoles(address user, uint256 roles) public payable virtual onlyOwner { _grantRoles(user, roles); } /// @dev Allows the owner to remove `user` `roles`. /// If the `user` does not have a role, then it will be an no-op for the role. function revokeRoles(address user, uint256 roles) public payable virtual onlyOwner { _removeRoles(user, roles); } /// @dev Allow the caller to remove their own roles. /// If the caller does not have a role, then it will be an no-op for the role. function renounceRoles(uint256 roles) public payable virtual { _removeRoles(msg.sender, roles); } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* PUBLIC READ FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns the roles of `user`. function rolesOf(address user) public view virtual returns (uint256 roles) { /// @solidity memory-safe-assembly assembly { // Compute the role slot. mstore(0x0c, _ROLE_SLOT_SEED) mstore(0x00, user) // Load the stored value. roles := sload(keccak256(0x0c, 0x20)) } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* MODIFIERS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Marks a function as only callable by an account with `roles`. modifier onlyRoles(uint256 roles) virtual { _checkRoles(roles); _; } /// @dev Marks a function as only callable by the owner or by an account /// with `roles`. Checks for ownership first, then lazily checks for roles. modifier onlyOwnerOrRoles(uint256 roles) virtual { _checkOwnerOrRoles(roles); _; } /// @dev Marks a function as only callable by an account with `roles` /// or the owner. Checks for roles first, then lazily checks for ownership. modifier onlyRolesOrOwner(uint256 roles) virtual { _checkRolesOrOwner(roles); _; } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* ROLE CONSTANTS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ // IYKYK uint256 internal constant _ROLE_0 = 1 << 0; uint256 internal constant _ROLE_1 = 1 << 1; uint256 internal constant _ROLE_2 = 1 << 2; uint256 internal constant _ROLE_3 = 1 << 3; uint256 internal constant _ROLE_4 = 1 << 4; uint256 internal constant _ROLE_5 = 1 << 5; uint256 internal constant _ROLE_6 = 1 << 6; uint256 internal constant _ROLE_7 = 1 << 7; uint256 internal constant _ROLE_8 = 1 << 8; uint256 internal constant _ROLE_9 = 1 << 9; uint256 internal constant _ROLE_10 = 1 << 10; uint256 internal constant _ROLE_11 = 1 << 11; uint256 internal constant _ROLE_12 = 1 << 12; uint256 internal constant _ROLE_13 = 1 << 13; uint256 internal constant _ROLE_14 = 1 << 14; uint256 internal constant _ROLE_15 = 1 << 15; uint256 internal constant _ROLE_16 = 1 << 16; uint256 internal constant _ROLE_17 = 1 << 17; uint256 internal constant _ROLE_18 = 1 << 18; uint256 internal constant _ROLE_19 = 1 << 19; uint256 internal constant _ROLE_20 = 1 << 20; uint256 internal constant _ROLE_21 = 1 << 21; uint256 internal constant _ROLE_22 = 1 << 22; uint256 internal constant _ROLE_23 = 1 << 23; uint256 internal constant _ROLE_24 = 1 << 24; uint256 internal constant _ROLE_25 = 1 << 25; uint256 internal constant _ROLE_26 = 1 << 26; uint256 internal constant _ROLE_27 = 1 << 27; uint256 internal constant _ROLE_28 = 1 << 28; uint256 internal constant _ROLE_29 = 1 << 29; uint256 internal constant _ROLE_30 = 1 << 30; uint256 internal constant _ROLE_31 = 1 << 31; uint256 internal constant _ROLE_32 = 1 << 32; uint256 internal constant _ROLE_33 = 1 << 33; uint256 internal constant _ROLE_34 = 1 << 34; uint256 internal constant _ROLE_35 = 1 << 35; uint256 internal constant _ROLE_36 = 1 << 36; uint256 internal constant _ROLE_37 = 1 << 37; uint256 internal constant _ROLE_38 = 1 << 38; uint256 internal constant _ROLE_39 = 1 << 39; uint256 internal constant _ROLE_40 = 1 << 40; uint256 internal constant _ROLE_41 = 1 << 41; uint256 internal constant _ROLE_42 = 1 << 42; uint256 internal constant _ROLE_43 = 1 << 43; uint256 internal constant _ROLE_44 = 1 << 44; uint256 internal constant _ROLE_45 = 1 << 45; uint256 internal constant _ROLE_46 = 1 << 46; uint256 internal constant _ROLE_47 = 1 << 47; uint256 internal constant _ROLE_48 = 1 << 48; uint256 internal constant _ROLE_49 = 1 << 49; uint256 internal constant _ROLE_50 = 1 << 50; uint256 internal constant _ROLE_51 = 1 << 51; uint256 internal constant _ROLE_52 = 1 << 52; uint256 internal constant _ROLE_53 = 1 << 53; uint256 internal constant _ROLE_54 = 1 << 54; uint256 internal constant _ROLE_55 = 1 << 55; uint256 internal constant _ROLE_56 = 1 << 56; uint256 internal constant _ROLE_57 = 1 << 57; uint256 internal constant _ROLE_58 = 1 << 58; uint256 internal constant _ROLE_59 = 1 << 59; uint256 internal constant _ROLE_60 = 1 << 60; uint256 internal constant _ROLE_61 = 1 << 61; uint256 internal constant _ROLE_62 = 1 << 62; uint256 internal constant _ROLE_63 = 1 << 63; uint256 internal constant _ROLE_64 = 1 << 64; uint256 internal constant _ROLE_65 = 1 << 65; uint256 internal constant _ROLE_66 = 1 << 66; uint256 internal constant _ROLE_67 = 1 << 67; uint256 internal constant _ROLE_68 = 1 << 68; uint256 internal constant _ROLE_69 = 1 << 69; uint256 internal constant _ROLE_70 = 1 << 70; uint256 internal constant _ROLE_71 = 1 << 71; uint256 internal constant _ROLE_72 = 1 << 72; uint256 internal constant _ROLE_73 = 1 << 73; uint256 internal constant _ROLE_74 = 1 << 74; uint256 internal constant _ROLE_75 = 1 << 75; uint256 internal constant _ROLE_76 = 1 << 76; uint256 internal constant _ROLE_77 = 1 << 77; uint256 internal constant _ROLE_78 = 1 << 78; uint256 internal constant _ROLE_79 = 1 << 79; uint256 internal constant _ROLE_80 = 1 << 80; uint256 internal constant _ROLE_81 = 1 << 81; uint256 internal constant _ROLE_82 = 1 << 82; uint256 internal constant _ROLE_83 = 1 << 83; uint256 internal constant _ROLE_84 = 1 << 84; uint256 internal constant _ROLE_85 = 1 << 85; uint256 internal constant _ROLE_86 = 1 << 86; uint256 internal constant _ROLE_87 = 1 << 87; uint256 internal constant _ROLE_88 = 1 << 88; uint256 internal constant _ROLE_89 = 1 << 89; uint256 internal constant _ROLE_90 = 1 << 90; uint256 internal constant _ROLE_91 = 1 << 91; uint256 internal constant _ROLE_92 = 1 << 92; uint256 internal constant _ROLE_93 = 1 << 93; uint256 internal constant _ROLE_94 = 1 << 94; uint256 internal constant _ROLE_95 = 1 << 95; uint256 internal constant _ROLE_96 = 1 << 96; uint256 internal constant _ROLE_97 = 1 << 97; uint256 internal constant _ROLE_98 = 1 << 98; uint256 internal constant _ROLE_99 = 1 << 99; uint256 internal constant _ROLE_100 = 1 << 100; uint256 internal constant _ROLE_101 = 1 << 101; uint256 internal constant _ROLE_102 = 1 << 102; uint256 internal constant _ROLE_103 = 1 << 103; uint256 internal constant _ROLE_104 = 1 << 104; uint256 internal constant _ROLE_105 = 1 << 105; uint256 internal constant _ROLE_106 = 1 << 106; uint256 internal constant _ROLE_107 = 1 << 107; uint256 internal constant _ROLE_108 = 1 << 108; uint256 internal constant _ROLE_109 = 1 << 109; uint256 internal constant _ROLE_110 = 1 << 110; uint256 internal constant _ROLE_111 = 1 << 111; uint256 internal constant _ROLE_112 = 1 << 112; uint256 internal constant _ROLE_113 = 1 << 113; uint256 internal constant _ROLE_114 = 1 << 114; uint256 internal constant _ROLE_115 = 1 << 115; uint256 internal constant _ROLE_116 = 1 << 116; uint256 internal constant _ROLE_117 = 1 << 117; uint256 internal constant _ROLE_118 = 1 << 118; uint256 internal constant _ROLE_119 = 1 << 119; uint256 internal constant _ROLE_120 = 1 << 120; uint256 internal constant _ROLE_121 = 1 << 121; uint256 internal constant _ROLE_122 = 1 << 122; uint256 internal constant _ROLE_123 = 1 << 123; uint256 internal constant _ROLE_124 = 1 << 124; uint256 internal constant _ROLE_125 = 1 << 125; uint256 internal constant _ROLE_126 = 1 << 126; uint256 internal constant _ROLE_127 = 1 << 127; uint256 internal constant _ROLE_128 = 1 << 128; uint256 internal constant _ROLE_129 = 1 << 129; uint256 internal constant _ROLE_130 = 1 << 130; uint256 internal constant _ROLE_131 = 1 << 131; uint256 internal constant _ROLE_132 = 1 << 132; uint256 internal constant _ROLE_133 = 1 << 133; uint256 internal constant _ROLE_134 = 1 << 134; uint256 internal constant _ROLE_135 = 1 << 135; uint256 internal constant _ROLE_136 = 1 << 136; uint256 internal constant _ROLE_137 = 1 << 137; uint256 internal constant _ROLE_138 = 1 << 138; uint256 internal constant _ROLE_139 = 1 << 139; uint256 internal constant _ROLE_140 = 1 << 140; uint256 internal constant _ROLE_141 = 1 << 141; uint256 internal constant _ROLE_142 = 1 << 142; uint256 internal constant _ROLE_143 = 1 << 143; uint256 internal constant _ROLE_144 = 1 << 144; uint256 internal constant _ROLE_145 = 1 << 145; uint256 internal constant _ROLE_146 = 1 << 146; uint256 internal constant _ROLE_147 = 1 << 147; uint256 internal constant _ROLE_148 = 1 << 148; uint256 internal constant _ROLE_149 = 1 << 149; uint256 internal constant _ROLE_150 = 1 << 150; uint256 internal constant _ROLE_151 = 1 << 151; uint256 internal constant _ROLE_152 = 1 << 152; uint256 internal constant _ROLE_153 = 1 << 153; uint256 internal constant _ROLE_154 = 1 << 154; uint256 internal constant _ROLE_155 = 1 << 155; uint256 internal constant _ROLE_156 = 1 << 156; uint256 internal constant _ROLE_157 = 1 << 157; uint256 internal constant _ROLE_158 = 1 << 158; uint256 internal constant _ROLE_159 = 1 << 159; uint256 internal constant _ROLE_160 = 1 << 160; uint256 internal constant _ROLE_161 = 1 << 161; uint256 internal constant _ROLE_162 = 1 << 162; uint256 internal constant _ROLE_163 = 1 << 163; uint256 internal constant _ROLE_164 = 1 << 164; uint256 internal constant _ROLE_165 = 1 << 165; uint256 internal constant _ROLE_166 = 1 << 166; uint256 internal constant _ROLE_167 = 1 << 167; uint256 internal constant _ROLE_168 = 1 << 168; uint256 internal constant _ROLE_169 = 1 << 169; uint256 internal constant _ROLE_170 = 1 << 170; uint256 internal constant _ROLE_171 = 1 << 171; uint256 internal constant _ROLE_172 = 1 << 172; uint256 internal constant _ROLE_173 = 1 << 173; uint256 internal constant _ROLE_174 = 1 << 174; uint256 internal constant _ROLE_175 = 1 << 175; uint256 internal constant _ROLE_176 = 1 << 176; uint256 internal constant _ROLE_177 = 1 << 177; uint256 internal constant _ROLE_178 = 1 << 178; uint256 internal constant _ROLE_179 = 1 << 179; uint256 internal constant _ROLE_180 = 1 << 180; uint256 internal constant _ROLE_181 = 1 << 181; uint256 internal constant _ROLE_182 = 1 << 182; uint256 internal constant _ROLE_183 = 1 << 183; uint256 internal constant _ROLE_184 = 1 << 184; uint256 internal constant _ROLE_185 = 1 << 185; uint256 internal constant _ROLE_186 = 1 << 186; uint256 internal constant _ROLE_187 = 1 << 187; uint256 internal constant _ROLE_188 = 1 << 188; uint256 internal constant _ROLE_189 = 1 << 189; uint256 internal constant _ROLE_190 = 1 << 190; uint256 internal constant _ROLE_191 = 1 << 191; uint256 internal constant _ROLE_192 = 1 << 192; uint256 internal constant _ROLE_193 = 1 << 193; uint256 internal constant _ROLE_194 = 1 << 194; uint256 internal constant _ROLE_195 = 1 << 195; uint256 internal constant _ROLE_196 = 1 << 196; uint256 internal constant _ROLE_197 = 1 << 197; uint256 internal constant _ROLE_198 = 1 << 198; uint256 internal constant _ROLE_199 = 1 << 199; uint256 internal constant _ROLE_200 = 1 << 200; uint256 internal constant _ROLE_201 = 1 << 201; uint256 internal constant _ROLE_202 = 1 << 202; uint256 internal constant _ROLE_203 = 1 << 203; uint256 internal constant _ROLE_204 = 1 << 204; uint256 internal constant _ROLE_205 = 1 << 205; uint256 internal constant _ROLE_206 = 1 << 206; uint256 internal constant _ROLE_207 = 1 << 207; uint256 internal constant _ROLE_208 = 1 << 208; uint256 internal constant _ROLE_209 = 1 << 209; uint256 internal constant _ROLE_210 = 1 << 210; uint256 internal constant _ROLE_211 = 1 << 211; uint256 internal constant _ROLE_212 = 1 << 212; uint256 internal constant _ROLE_213 = 1 << 213; uint256 internal constant _ROLE_214 = 1 << 214; uint256 internal constant _ROLE_215 = 1 << 215; uint256 internal constant _ROLE_216 = 1 << 216; uint256 internal constant _ROLE_217 = 1 << 217; uint256 internal constant _ROLE_218 = 1 << 218; uint256 internal constant _ROLE_219 = 1 << 219; uint256 internal constant _ROLE_220 = 1 << 220; uint256 internal constant _ROLE_221 = 1 << 221; uint256 internal constant _ROLE_222 = 1 << 222; uint256 internal constant _ROLE_223 = 1 << 223; uint256 internal constant _ROLE_224 = 1 << 224; uint256 internal constant _ROLE_225 = 1 << 225; uint256 internal constant _ROLE_226 = 1 << 226; uint256 internal constant _ROLE_227 = 1 << 227; uint256 internal constant _ROLE_228 = 1 << 228; uint256 internal constant _ROLE_229 = 1 << 229; uint256 internal constant _ROLE_230 = 1 << 230; uint256 internal constant _ROLE_231 = 1 << 231; uint256 internal constant _ROLE_232 = 1 << 232; uint256 internal constant _ROLE_233 = 1 << 233; uint256 internal constant _ROLE_234 = 1 << 234; uint256 internal constant _ROLE_235 = 1 << 235; uint256 internal constant _ROLE_236 = 1 << 236; uint256 internal constant _ROLE_237 = 1 << 237; uint256 internal constant _ROLE_238 = 1 << 238; uint256 internal constant _ROLE_239 = 1 << 239; uint256 internal constant _ROLE_240 = 1 << 240; uint256 internal constant _ROLE_241 = 1 << 241; uint256 internal constant _ROLE_242 = 1 << 242; uint256 internal constant _ROLE_243 = 1 << 243; uint256 internal constant _ROLE_244 = 1 << 244; uint256 internal constant _ROLE_245 = 1 << 245; uint256 internal constant _ROLE_246 = 1 << 246; uint256 internal constant _ROLE_247 = 1 << 247; uint256 internal constant _ROLE_248 = 1 << 248; uint256 internal constant _ROLE_249 = 1 << 249; uint256 internal constant _ROLE_250 = 1 << 250; uint256 internal constant _ROLE_251 = 1 << 251; uint256 internal constant _ROLE_252 = 1 << 252; uint256 internal constant _ROLE_253 = 1 << 253; uint256 internal constant _ROLE_254 = 1 << 254; uint256 internal constant _ROLE_255 = 1 << 255; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /******************************************************************************\ * Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen) * EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 /******************************************************************************/ import { IDiamondCut } from "../interfaces/IDiamondCut.sol"; // Remember to add the loupe functions from DiamondLoupeFacet to the diamond. // The loupe functions are required by the EIP2535 Diamonds standard error InitializationFunctionReverted(address _initializationContractAddress, bytes _calldata); library LibDiamond { bytes32 constant DIAMOND_STORAGE_POSITION = keccak256("diamond.standard.diamond.storage"); struct DiamondStorage { // maps function selectors to the facets that execute the functions. // and maps the selectors to their position in the selectorSlots array. // func selector => address facet, selector position mapping(bytes4 => bytes32) facets; // array of slots of function selectors. // each slot holds 8 function selectors. mapping(uint256 => bytes32) selectorSlots; // The number of function selectors in selectorSlots uint16 selectorCount; // Used to query if a contract implements an interface. // Used to implement ERC-165. mapping(bytes4 => bool) supportedInterfaces; // owner of the contract address contractOwner; } function diamondStorage() internal pure returns (DiamondStorage storage ds) { bytes32 position = DIAMOND_STORAGE_POSITION; assembly { ds.slot := position } } event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function setContractOwner(address _newOwner) internal { DiamondStorage storage ds = diamondStorage(); address previousOwner = ds.contractOwner; ds.contractOwner = _newOwner; emit OwnershipTransferred(previousOwner, _newOwner); } function contractOwner() internal view returns (address contractOwner_) { contractOwner_ = diamondStorage().contractOwner; } function enforceIsContractOwner() internal view { require(msg.sender == diamondStorage().contractOwner, "LibDiamond: Must be contract owner"); } event DiamondCut(IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata); bytes32 constant CLEAR_ADDRESS_MASK = bytes32(uint256(0xffffffffffffffffffffffff)); bytes32 constant CLEAR_SELECTOR_MASK = bytes32(uint256(0xffffffff << 224)); // Internal function version of diamondCut // This code is almost the same as the external diamondCut, // except it is using 'Facet[] memory _diamondCut' instead of // 'Facet[] calldata _diamondCut'. // The code is duplicated to prevent copying calldata to memory which // causes an error for a two dimensional array. function diamondCut( IDiamondCut.FacetCut[] memory _diamondCut, address _init, bytes memory _calldata ) internal { DiamondStorage storage ds = diamondStorage(); uint256 originalSelectorCount = ds.selectorCount; uint256 selectorCount = originalSelectorCount; bytes32 selectorSlot; // Check if last selector slot is not full // "selectorCount & 7" is a gas efficient modulo by eight "selectorCount % 8" if (selectorCount & 7 > 0) { // get last selectorSlot // "selectorSlot >> 3" is a gas efficient division by 8 "selectorSlot / 8" selectorSlot = ds.selectorSlots[selectorCount >> 3]; } // loop through diamond cut for (uint256 facetIndex; facetIndex < _diamondCut.length; ) { (selectorCount, selectorSlot) = addReplaceRemoveFacetSelectors( selectorCount, selectorSlot, _diamondCut[facetIndex].facetAddress, _diamondCut[facetIndex].action, _diamondCut[facetIndex].functionSelectors ); unchecked { facetIndex++; } } if (selectorCount != originalSelectorCount) { ds.selectorCount = uint16(selectorCount); } // If last selector slot is not full // "selectorCount & 7" is a gas efficient modulo by eight "selectorCount % 8" if (selectorCount & 7 > 0) { // "selectorSlot >> 3" is a gas efficient division by 8 "selectorSlot / 8" ds.selectorSlots[selectorCount >> 3] = selectorSlot; } emit DiamondCut(_diamondCut, _init, _calldata); initializeDiamondCut(_init, _calldata); } function addReplaceRemoveFacetSelectors( uint256 _selectorCount, bytes32 _selectorSlot, address _newFacetAddress, IDiamondCut.FacetCutAction _action, bytes4[] memory _selectors ) internal returns (uint256, bytes32) { DiamondStorage storage ds = diamondStorage(); require(_selectors.length > 0, "LibDiamondCut: No selectors in facet to cut"); if (_action == IDiamondCut.FacetCutAction.Add) { enforceHasContractCode(_newFacetAddress, "LibDiamondCut: Add facet has no code"); for (uint256 selectorIndex; selectorIndex < _selectors.length; ) { bytes4 selector = _selectors[selectorIndex]; bytes32 oldFacet = ds.facets[selector]; require(address(bytes20(oldFacet)) == address(0), "LibDiamondCut: Can't add function that already exists"); // add facet for selector ds.facets[selector] = bytes20(_newFacetAddress) | bytes32(_selectorCount); // "_selectorCount & 7" is a gas efficient modulo by eight "_selectorCount % 8" // " << 5 is the same as multiplying by 32 ( * 32) uint256 selectorInSlotPosition = (_selectorCount & 7) << 5; // clear selector position in slot and add selector _selectorSlot = (_selectorSlot & ~(CLEAR_SELECTOR_MASK >> selectorInSlotPosition)) | (bytes32(selector) >> selectorInSlotPosition); // if slot is full then write it to storage if (selectorInSlotPosition == 224) { // "_selectorSlot >> 3" is a gas efficient division by 8 "_selectorSlot / 8" ds.selectorSlots[_selectorCount >> 3] = _selectorSlot; _selectorSlot = 0; } _selectorCount++; unchecked { selectorIndex++; } } } else if (_action == IDiamondCut.FacetCutAction.Replace) { enforceHasContractCode(_newFacetAddress, "LibDiamondCut: Replace facet has no code"); for (uint256 selectorIndex; selectorIndex < _selectors.length; ) { bytes4 selector = _selectors[selectorIndex]; bytes32 oldFacet = ds.facets[selector]; address oldFacetAddress = address(bytes20(oldFacet)); // only useful if immutable functions exist require(oldFacetAddress != address(this), "LibDiamondCut: Can't replace immutable function"); require(oldFacetAddress != _newFacetAddress, "LibDiamondCut: Can't replace function with same function"); require(oldFacetAddress != address(0), "LibDiamondCut: Can't replace function that doesn't exist"); // replace old facet address ds.facets[selector] = (oldFacet & CLEAR_ADDRESS_MASK) | bytes20(_newFacetAddress); unchecked { selectorIndex++; } } } else if (_action == IDiamondCut.FacetCutAction.Remove) { require(_newFacetAddress == address(0), "LibDiamondCut: Remove facet address must be address(0)"); // "_selectorCount >> 3" is a gas efficient division by 8 "_selectorCount / 8" uint256 selectorSlotCount = _selectorCount >> 3; // "_selectorCount & 7" is a gas efficient modulo by eight "_selectorCount % 8" uint256 selectorInSlotIndex = _selectorCount & 7; for (uint256 selectorIndex; selectorIndex < _selectors.length; ) { if (_selectorSlot == 0) { // get last selectorSlot selectorSlotCount--; _selectorSlot = ds.selectorSlots[selectorSlotCount]; selectorInSlotIndex = 7; } else { selectorInSlotIndex--; } bytes4 lastSelector; uint256 oldSelectorsSlotCount; uint256 oldSelectorInSlotPosition; // adding a block here prevents stack too deep error { bytes4 selector = _selectors[selectorIndex]; bytes32 oldFacet = ds.facets[selector]; require(address(bytes20(oldFacet)) != address(0), "LibDiamondCut: Can't remove function that doesn't exist"); // only useful if immutable functions exist require(address(bytes20(oldFacet)) != address(this), "LibDiamondCut: Can't remove immutable function"); // replace selector with last selector in ds.facets // gets the last selector // " << 5 is the same as multiplying by 32 ( * 32) lastSelector = bytes4(_selectorSlot << (selectorInSlotIndex << 5)); if (lastSelector != selector) { // update last selector slot position info ds.facets[lastSelector] = (oldFacet & CLEAR_ADDRESS_MASK) | bytes20(ds.facets[lastSelector]); } delete ds.facets[selector]; uint256 oldSelectorCount = uint16(uint256(oldFacet)); // "oldSelectorCount >> 3" is a gas efficient division by 8 "oldSelectorCount / 8" oldSelectorsSlotCount = oldSelectorCount >> 3; // "oldSelectorCount & 7" is a gas efficient modulo by eight "oldSelectorCount % 8" // " << 5 is the same as multiplying by 32 ( * 32) oldSelectorInSlotPosition = (oldSelectorCount & 7) << 5; } if (oldSelectorsSlotCount != selectorSlotCount) { bytes32 oldSelectorSlot = ds.selectorSlots[oldSelectorsSlotCount]; // clears the selector we are deleting and puts the last selector in its place. oldSelectorSlot = (oldSelectorSlot & ~(CLEAR_SELECTOR_MASK >> oldSelectorInSlotPosition)) | (bytes32(lastSelector) >> oldSelectorInSlotPosition); // update storage with the modified slot ds.selectorSlots[oldSelectorsSlotCount] = oldSelectorSlot; } else { // clears the selector we are deleting and puts the last selector in its place. _selectorSlot = (_selectorSlot & ~(CLEAR_SELECTOR_MASK >> oldSelectorInSlotPosition)) | (bytes32(lastSelector) >> oldSelectorInSlotPosition); } if (selectorInSlotIndex == 0) { delete ds.selectorSlots[selectorSlotCount]; _selectorSlot = 0; } unchecked { selectorIndex++; } } _selectorCount = selectorSlotCount * 8 + selectorInSlotIndex; } else { revert("LibDiamondCut: Incorrect FacetCutAction"); } return (_selectorCount, _selectorSlot); } function initializeDiamondCut(address _init, bytes memory _calldata) internal { if (_init == address(0)) { return; } enforceHasContractCode(_init, "LibDiamondCut: _init address has no code"); (bool success, bytes memory error) = _init.delegatecall(_calldata); if (!success) { if (error.length > 0) { // bubble up error /// @solidity memory-safe-assembly assembly { let returndata_size := mload(error) revert(add(32, error), returndata_size) } } else { revert InitializationFunctionReverted(_init, _calldata); } } } function enforceHasContractCode(address _contract, string memory _errorMessage) internal view { uint256 contractSize; assembly { contractSize := extcodesize(_contract) } require(contractSize > 0, _errorMessage); } }
// 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; } }
// 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 } } }
// 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 } } }
// 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(); 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(); 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 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 not burned. if (packed & _BITMASK_BURNED == 0) { // If the data at the starting slot does not exist, start the scan. if (packed == 0) { if (tokenId >= ERC721AStorage.layout()._currentIndex) revert OwnerQueryForNonexistentToken(); // 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; return packed; } } // Otherwise, the data exists and is not burned. 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. return packed; } } revert OwnerQueryForNonexistentToken(); } /** * @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(); 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) { return _startTokenId() <= tokenId && tokenId < ERC721AStorage.layout()._currentIndex && // If within bounds, ERC721AStorage.layout()._packedOwnerships[tokenId] & _BITMASK_BURNED == 0; // and not burned. } /** * @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); if (address(uint160(prevOwnershipPacked)) != from) revert TransferFromIncorrectOwner(); (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(); if (to == address(0)) revert TransferToZeroAddress(); _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; } } } } emit Transfer(from, to, tokenId); _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(); } } /** * @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(); } else { 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(); _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: // - `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) ); uint256 toMasked; uint256 end = startTokenId + quantity; // Use assembly to loop and emit the `Transfer` event for gas savings. // The duplicated `log4` removes an extra check and reduces stack juggling. // The assembly, together with the surrounding Solidity code, have been // delicately arranged to nudge the compiler into producing optimized opcodes. assembly { // Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean. toMasked := and(to, _BITMASK_ADDRESS) // 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`. startTokenId // `tokenId`. ) // The `iszero(eq(,))` check ensures that large values of `quantity` // that overflows uint256 will make the loop run out of gas. // The compiler will optimize the `iszero` away for performance. for { let tokenId := add(startTokenId, 1) } iszero(eq(tokenId, end)) { tokenId := add(tokenId, 1) } { // Emit the `Transfer` event. Similar to above. log4(0, 0, _TRANSFER_EVENT_SIGNATURE, 0, toMasked, tokenId) } } if (toMasked == 0) revert MintToZeroAddress(); 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(); if (quantity == 0) revert MintZeroQuantity(); if (quantity > _MAX_MINT_ERC2309_QUANTITY_LIMIT) revert MintERC2309QuantityExceedsLimit(); _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(); } } while (index < end); // Reentrancy protection. if (ERC721AStorage.layout()._currentIndex != end) revert(); } } } /** * @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) if (_msgSenderERC721A() != owner) if (!isApprovedForAll(owner, _msgSenderERC721A())) { revert ApprovalCallerNotOwnerNorApproved(); } 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(); } _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(); 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) } } }
// 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); }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ApprovalCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"ApprovalQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"BalanceQueryForZeroAddress","type":"error"},{"inputs":[{"internalType":"address","name":"_initializationContractAddress","type":"address"},{"internalType":"bytes","name":"_calldata","type":"bytes"}],"name":"InitializationFunctionReverted","type":"error"},{"inputs":[],"name":"MintERC2309QuantityExceedsLimit","type":"error"},{"inputs":[],"name":"MintToZeroAddress","type":"error"},{"inputs":[],"name":"MintZeroQuantity","type":"error"},{"inputs":[],"name":"NewOwnerIsZeroAddress","type":"error"},{"inputs":[],"name":"NoHandoverRequest","type":"error"},{"inputs":[],"name":"OwnerQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"OwnershipNotInitializedForExtraData","type":"error"},{"inputs":[],"name":"TransferCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"TransferFromIncorrectOwner","type":"error"},{"inputs":[],"name":"TransferToNonERC721ReceiverImplementer","type":"error"},{"inputs":[],"name":"TransferToZeroAddress","type":"error"},{"inputs":[],"name":"URIQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"fromTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"toTokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"ConsecutiveTransfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pendingOwner","type":"address"}],"name":"OwnershipHandoverCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pendingOwner","type":"address"}],"name":"OwnershipHandoverRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"roles","type":"uint256"}],"name":"RolesUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"owner_","type":"address"},{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"address","name":"royalty_","type":"address"},{"internalType":"uint16","name":"royaltyBps_","type":"uint16"}],"name":"_initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_functionSelector","type":"bytes4"}],"name":"facetAddress","outputs":[{"internalType":"address","name":"facetAddress_","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"facetAddresses","outputs":[{"internalType":"address[]","name":"facetAddresses_","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_facet","type":"address"}],"name":"facetFunctionSelectors","outputs":[{"internalType":"bytes4[]","name":"_facetFunctionSelectors","type":"bytes4[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"facets","outputs":[{"components":[{"internalType":"address","name":"facetAddress","type":"address"},{"internalType":"bytes4[]","name":"functionSelectors","type":"bytes4[]"}],"internalType":"struct IDiamondLoupe.Facet[]","name":"facets_","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"name","type":"bytes32"}],"name":"getApp","outputs":[{"components":[{"internalType":"address","name":"implementation","type":"address"},{"internalType":"bytes4","name":"interfaceId","type":"bytes4"},{"internalType":"bytes4[]","name":"selectors","type":"bytes4[]"},{"internalType":"uint8","name":"version","type":"uint8"}],"internalType":"struct INiftyKitAppRegistry.App","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"roles","type":"uint256"}],"name":"grantRoles","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"name","type":"bytes32"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"installApp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"name","type":"bytes32"}],"name":"installApp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"result","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"name","type":"bytes32"}],"name":"removeApp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"name","type":"bytes32"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"removeApp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"roles","type":"uint256"}],"name":"renounceRoles","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"roles","type":"uint256"}],"name":"revokeRoles","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"rolesOf","outputs":[{"internalType":"uint256","name":"roles","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"newBaseURI","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newTreasury","type":"address"}],"name":"setTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b506000805160206200452d83398151915254610100900460ff166200004b576000805160206200452d8339815191525460ff16156200004f565b303b155b620000c65760405162461bcd60e51b815260206004820152603760248201527f455243373231415f5f496e697469616c697a61626c653a20636f6e747261637460448201527f20697320616c726561647920696e697469616c697a6564000000000000000000606482015260840160405180910390fd5b6000805160206200452d83398151915254610100900460ff1615801562000105576000805160206200452d833981519152805461ffff19166101011790555b801562000126576000805160206200452d833981519152805461ff00191690555b506143f680620001376000396000f3fe60806040526004361061020f5760003560e01c806355f804b31161011857806395d89b41116100a0578063c87b56dd1161006f578063c87b56dd1461063e578063cdffacc61461065e578063e985e9c5146106a5578063f0f44260146106c5578063f2fde38b146106e557600080fd5b806395d89b41146105c9578063a22cb465146105de578063adfca15e146105fe578063b88d4fde1461062b57600080fd5b8063715018a6116100e7578063715018a61461054657806375a284031461054e5780637a0ed6271461056e5780638aebc353146105905780638da5cb5b146105b057600080fd5b806355f804b3146104a957806361d027b3146104c95780636352211e1461050657806370a082311461052657600080fd5b806323b872dd1161019b5780633ccfd60b1161016a5780633ccfd60b1461041f57806342842e0e1461043457806342c71f1d146104475780634a4ee7b11461047457806352ef6b2c1461048757600080fd5b806323b872dd1461037a5780632a55205a1461038d5780632de94807146103cc5780632fa8374b146103ff57600080fd5b806318160ddd116101e257806318160ddd146102f1578063183a4f6e146103145780631c10893f146103275780631f1bf78b1461033a5780632099ba841461035a57600080fd5b806301ffc9a71461021457806306fdde0314610282578063081812fc146102a4578063095ea7b3146102dc575b600080fd5b34801561022057600080fd5b5061026d61022f366004613725565b6001600160e01b03191660009081527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131f602052604090205460ff1690565b60405190151581526020015b60405180910390f35b34801561028e57600080fd5b506102976106f8565b6040516102799190613799565b3480156102b057600080fd5b506102c46102bf3660046137ac565b610793565b6040516001600160a01b039091168152602001610279565b6102ef6102ea3660046137da565b6107e0565b005b3480156102fd57600080fd5b506103066108fa565b604051908152602001610279565b6102ef6103223660046137ac565b61091a565b6102ef6103353660046137da565b610927565b34801561034657600080fd5b506102ef6103553660046137ac565b61093d565b34801561036657600080fd5b506102ef6103753660046138eb565b610960565b6102ef610388366004613931565b610973565b34801561039957600080fd5b506103ad6103a8366004613972565b610a96565b604080516001600160a01b039093168352602083019190915201610279565b3480156103d857600080fd5b506103066103e7366004613994565b638b78c6d8600c908152600091909152602090205490565b34801561040b57600080fd5b506102ef61041a3660046137ac565b610aaf565b34801561042b57600080fd5b506102ef610ad2565b6102ef610442366004613931565b610b3b565b34801561045357600080fd5b506104676104623660046137ac565b610c54565b60405161027991906139f6565b6102ef6104823660046137da565b610d55565b34801561049357600080fd5b5061049c610d67565b6040516102799190613a53565b3480156104b557600080fd5b506102ef6104c4366004613aa0565b610f18565b3480156104d557600080fd5b507f45f38af8fd646bf817698fe2be76218d850d401ba88ffd7c9cd1b4f5c9a1db5b546001600160a01b03166102c4565b34801561051257600080fd5b506102c46105213660046137ac565b610f53565b34801561053257600080fd5b50610306610541366004613994565b610f64565b6102ef610fcc565b34801561055a57600080fd5b506102ef610569366004613b29565b610fe0565b34801561057a57600080fd5b506105836111d5565b6040516102799190613bd8565b34801561059c57600080fd5b506102ef6105ab3660046138eb565b61160e565b3480156105bc57600080fd5b50638b78c6d819546102c4565b3480156105d557600080fd5b50610297611621565b3480156105ea57600080fd5b506102ef6105f9366004613c55565b611639565b34801561060a57600080fd5b5061061e610619366004613994565b611742565b6040516102799190613c93565b6102ef610639366004613ca6565b6118a1565b34801561064a57600080fd5b506102976106593660046137ac565b6119c6565b34801561066a57600080fd5b506102c4610679366004613725565b6001600160e01b03191660009081526000805160206142ad833981519152602052604090205460601c90565b3480156106b157600080fd5b5061026d6106c0366004613d11565b611b3b565b3480156106d157600080fd5b506102ef6106e0366004613994565b611baf565b6102ef6106f3366004613994565b611bf8565b6060610702611c1f565b600201805461071090613d3f565b80601f016020809104026020016040519081016040528092919081815260200182805461073c90613d3f565b80156107895780601f1061075e57610100808354040283529160200191610789565b820191906000526020600020905b81548152906001019060200180831161076c57829003601f168201915b5050505050905090565b600061079e82611c43565b6107bb576040516333d1c03960e21b815260040160405180910390fd5b6107c3611c1f565b60009283526006016020525060409020546001600160a01b031690565b6000805160206142cd833981519152548290829060008051602061433983398151915290610100900460ff166002818181111561081f5761081f613d73565b14806108775750600181600281111561083a5761083a613d73565b14801561086257506001600160a01b038416600090815260018301602052604090205460ff16155b801561087757506001600160a01b0384163314155b806108925750600083815260028301602052604090205460ff165b156108b85760405162461bcd60e51b81526004016108af90613d89565b60405180910390fd5b856108c281611c8c565b6108e7576000805160206142cd8339815191525460ff16156108e7576108e781611cc9565b6108f18787611d0d565b50505050505050565b60006001610906611c1f565b60010154610912611c1f565b540303919050565b6109243382611d19565b50565b61092f611d68565b6109398282611d83565b5050565b610945611d68565b61092481600060405180602001604052806000815250611dce565b610968611d68565b610939823083612025565b6000805160206142cd833981519152548390829060008051602061433983398151915290610100900460ff16600281818111156109b2576109b2613d73565b1480610a0a575060018160028111156109cd576109cd613d73565b1480156109f557506001600160a01b038416600090815260018301602052604090205460ff16155b8015610a0a57506001600160a01b0384163314155b80610a255750600083815260028301602052604090205460ff165b15610a425760405162461bcd60e51b81526004016108af90613d89565b866001600160a01b0381163314610a8157610a5c33611c8c565b610a81576000805160206142cd8339815191525460ff1615610a8157610a8133611cc9565b610a8c8888886122d4565b5050505050505050565b600080610aa384846124cb565b915091505b9250929050565b610ab7611d68565b61092481600060405180602001604052806000815250612025565b610ada611d68565b6000805160206143398339815191524780610b235760405162461bcd60e51b8152602060048201526009602482015268302062616c616e636560b81b60448201526064016108af565b6005820154610939906001600160a01b03168261250b565b6000805160206142cd833981519152548390829060008051602061433983398151915290610100900460ff1660028181811115610b7a57610b7a613d73565b1480610bd257506001816002811115610b9557610b95613d73565b148015610bbd57506001600160a01b038416600090815260018301602052604090205460ff16155b8015610bd257506001600160a01b0384163314155b80610bed5750600083815260028301602052604090205460ff165b15610c0a5760405162461bcd60e51b81526004016108af90613d89565b866001600160a01b0381163314610c4957610c2433611c8c565b610c49576000805160206142cd8339815191525460ff1615610c4957610c4933611cc9565b610a8c888888612624565b604080516080808201835260008083526020808401829052606084860181905284018290528582526000805160206143398339815191528152908490208451928301855280546001600160a01b0381168452600160a01b900460e01b6001600160e01b031916838301526001810180548651818502810185018852818152959694959294860193830182828015610d3757602002820191906000526020600020906000905b82829054906101000a900460e01b6001600160e01b03191681526020019060040190602082600301049283019260010382029150808411610cf95790505b50505091835250506002919091015460ff1660209091015292915050565b610d5d611d68565b6109398282611d19565b600080516020614359833981519152546060906000805160206142ad8339815191529061ffff166001600160401b03811115610da557610da5613806565b604051908082528060200260200182016040528015610dce578160200160208202803683370190505b50915060008060005b600284015461ffff16821015610f10576000818152600185016020526040812054905b6008811015610efb5783610e0d81613dce565b600288015490955061ffff1685119050610efb57600581901b82901b6001600160e01b0319811660009081526020889052604081205460601c90805b88811015610e9e578a8181518110610e6357610e63613de7565b60200260200101516001600160a01b0316836001600160a01b031603610e8c5760019150610e9e565b80610e9681613dce565b915050610e49565b508015610ead57505050610ee9565b818a8981518110610ec057610ec0613de7565b6001600160a01b039092166020928302919091019091015287610ee281613dce565b9850505050505b80610ef381613dce565b915050610dfa565b50508080610f0890613dce565b915050610dd7565b505082525090565b6002610f238161263f565b7f45f38af8fd646bf817698fe2be76218d850d401ba88ffd7c9cd1b4f5c9a1db5c610f4e8382613e43565b505050565b6000610f5e82612672565b92915050565b60006001600160a01b038216610f8d576040516323d3ad8160e21b815260040160405180910390fd5b6001600160401b03610f9d611c1f565b6005016000846001600160a01b03166001600160a01b0316815260200190815260200160002054169050919050565b610fd4611d68565b610fde600061271f565b565b6000805160206143a183398151915254610100900460ff16611015576000805160206143a18339815191525460ff1615611019565b303b155b61108b5760405162461bcd60e51b815260206004820152603760248201527f455243373231415f5f496e697469616c697a61626c653a20636f6e747261637460448201527f20697320616c726561647920696e697469616c697a656400000000000000000060648201526084016108af565b6000805160206143a183398151915254610100900460ff161580156110c7576000805160206143a1833981519152805461ffff19166101011790555b61113a87878080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8b01819004810282018101909252898152925089915088908190840183828082843760009201919091525061275d92505050565b6111438861279b565b7ff298352fd56f58214bf2245c2b202523f72fca3199077ce992640958228b2820805461ffff191661ffff84161790557ff298352fd56f58214bf2245c2b202523f72fca3199077ce992640958228b282280546001600160a01b0319166001600160a01b0385161790558015610a8c5750506000805160206143a1833981519152805461ff0019169055505050505050565b600080516020614359833981519152546060906000805160206142ad8339815191529061ffff166001600160401b0381111561121357611213613806565b60405190808252806020026020018201604052801561125957816020015b6040805180820190915260008152606060208201528152602001906001900390816112315790505b50600282015490925060009061ffff166001600160401b0381111561128057611280613806565b6040519080825280602002602001820160405280156112a9578160200160208202803683370190505b50905060008060005b600285015461ffff1682101561159b576000818152600186016020526040812054905b600881101561158657836112e881613dce565b600289015490955061ffff168511905061158657600581901b82901b6001600160e01b0319811660009081526020899052604081205460601c90805b8881101561144457826001600160a01b03168c828151811061134857611348613de7565b6020026020010151600001516001600160a01b03160361143257838c828151811061137557611375613de7565b6020026020010151602001518b838151811061139357611393613de7565b602002602001015161ffff16815181106113af576113af613de7565b60200260200101906001600160e01b03191690816001600160e01b0319168152505060ff8a82815181106113e5576113e5613de7565b602002602001015161ffff16106113fb57600080fd5b89818151811061140d5761140d613de7565b60200260200101805180919061142290613f02565b61ffff1690525060019150611444565b8061143c81613dce565b915050611324565b50801561145357505050611574565b818b898151811061146657611466613de7565b60209081029190910101516001600160a01b03909116905260028a015461ffff166001600160401b0381111561149e5761149e613806565b6040519080825280602002602001820160405280156114c7578160200160208202803683370190505b508b89815181106114da576114da613de7565b602002602001015160200181905250828b89815181106114fc576114fc613de7565b60200260200101516020015160008151811061151a5761151a613de7565b60200260200101906001600160e01b03191690816001600160e01b03191681525050600189898151811061155057611550613de7565b61ffff909216602092830291909101909101528761156d81613dce565b9850505050505b8061157e81613dce565b9150506112d5565b5050808061159390613dce565b9150506112b2565b5060005b828110156116035760008482815181106115bb576115bb613de7565b602002602001015161ffff16905060008783815181106115dd576115dd613de7565b6020026020010151602001519050818152505080806115fb90613dce565b91505061159f565b508185525050505090565b611616611d68565b610939823083611dce565b606061162b611c1f565b600301805461071090613d3f565b6000805160206142cd83398151915254829060009060008051602061433983398151915290610100900460ff166002818181111561167957611679613d73565b14806116d15750600181600281111561169457611694613d73565b1480156116bc57506001600160a01b038416600090815260018301602052604090205460ff16155b80156116d157506001600160a01b0384163314155b806116ec5750600083815260028301602052604090205460ff165b156117095760405162461bcd60e51b81526004016108af90613d89565b8561171381611c8c565b611738576000805160206142cd8339815191525460ff16156117385761173881611cc9565b6108f187876127d7565b600080516020614359833981519152546060906000805160206142ad8339815191529060009061ffff166001600160401b0381111561178357611783613806565b6040519080825280602002602001820160405280156117ac578160200160208202803683370190505b5092506000805b600284015461ffff16821015611897576000818152600185016020526040812054905b600881101561188257836117e981613dce565b600288015490955061ffff168511905061188257600581901b82901b6001600160e01b0319811660009081526020889052604090205460601c6001600160a01b038a1681900361186d578189888151811061184657611846613de7565b6001600160e01b0319909216602092830291909101909101528661186981613dce565b9750505b5050808061187a90613dce565b9150506117d6565b5050808061188f90613dce565b9150506117b3565b5050825250919050565b6000805160206142cd833981519152548490839060008051602061433983398151915290610100900460ff16600281818111156118e0576118e0613d73565b1480611938575060018160028111156118fb576118fb613d73565b14801561192357506001600160a01b038416600090815260018301602052604090205460ff16155b801561193857506001600160a01b0384163314155b806119535750600083815260028301602052604090205460ff165b156119705760405162461bcd60e51b81526004016108af90613d89565b876001600160a01b03811633146119af5761198a33611c8c565b6119af576000805160206142cd8339815191525460ff16156119af576119af33611cc9565b6119bb89898989612854565b505050505050505050565b60606119d182611c43565b6119ee57604051630a14c4b560e41b815260040160405180910390fd5b60008281527f45f38af8fd646bf817698fe2be76218d850d401ba88ffd7c9cd1b4f5c9a1db59602090815260408083208151808301909252805460ff16151582526001810180549293919291840191611a4690613d3f565b80601f0160208091040260200160405190810160405280929190818152602001828054611a7290613d3f565b8015611abf5780601f10611a9457610100808354040283529160200191611abf565b820191906000526020600020905b815481529060010190602001808311611aa257829003601f168201915b5050505050815250509050806000015115611ade576020015192915050565b6000611ae861289e565b90508051600003611b085760405180602001604052806000815250611b33565b80611b12856128bd565b604051602001611b23929190613f23565b6040516020818303038152906040525b949350505050565b6000805160206142cd8339815191525460009060008051602061433983398151915290600190610100900460ff166002811115611b7a57611b7a613d73565b03611ba5576001600160a01b03831660009081526001909101602052604090205460ff169050610f5e565b611b338484612901565b611bb7611d68565b7f45f38af8fd646bf817698fe2be76218d850d401ba88ffd7c9cd1b4f5c9a1db5b80546001600160a01b0319166001600160a01b0392909216919091179055565b611c00611d68565b8060601b611c1657637448fbae6000526004601cfd5b6109248161271f565b7f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c4090565b600081600111158015611c5d5750611c59611c1f565b5482105b8015610f5e5750600160e01b611c71611c1f565b60008481526004919091016020526040902054161592915050565b6001600160a01b031660009081527f45f38af8fd646bf817698fe2be76218d850d401ba88ffd7c9cd1b4f5c9a1db57602052604090205460ff1690565b69c617113400112233445560005230601a5280603a52600080604460166daaeb6d7670e522a718067333cd4e5afa611d05573d6000803e3d6000fd5b6000603a5250565b6109398282600161293e565b638b78c6d8600c52816000526020600c20805482811681189250508181555080600c5160601c7f715ad5ce61fc9595c7b415289d59cf203f23a94fa06f04af7e489a0a76e1fe26600080a35050565b638b78c6d819543314610fde576382b429006000526004601cfd5b638b78c6d8600c52816000526020600c208181541791508181555080600c5160601c7f715ad5ce61fc9595c7b415289d59cf203f23a94fa06f04af7e489a0a76e1fe26600080a35050565b600083815260008051602061433983398151915260208181526040808420815160808101835281546001600160a01b0381168252600160a01b900460e01b6001600160e01b03191681850152600182018054845181870281018701865281815296976000805160206142ad833981519152979096939586019390929190830182828015611ea757602002820191906000526020600020906000905b82829054906101000a900460e01b6001600160e01b03191681526020019060040190602082600301049283019260010382029150808411611e695790505b50505091835250506002919091015460ff908116602090920191909152606082015191925016611f0e5760405162461bcd60e51b8152602060048201526012602482015271105c1c08191bd95cc81b9bdd08195e1a5cdd60721b60448201526064016108af565b604080516001808252818301909252600091816020015b60408051606080820183526000808352602083015291810191909152815260200190600190039081611f25579050506040805160608101909152600081529091506020810160028152602001836040015181525081600081518110611f8c57611f8c613de7565b602090810291909101810191909152828101516001600160e01b03191660009081526003850190915260409020805460ff19169055611fcb86866129f3565b611fe681600060405180602001604052806000815250612ab9565b600087815260208590526040812080546001600160c01b0319168155906120106001830182613629565b50600201805460ff1916905550505050505050565b6000600080516020614339833981519152905060006000805160206142ad833981519152905060008260040160029054906101000a90046001600160a01b03166001600160a01b031663bb4fceb96040518163ffffffff1660e01b81526004016020604051808303816000875af11580156120a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120c89190613f52565b6040516342c71f1d60e01b8152600481018890529091506000906001600160a01b038316906342c71f1d90602401600060405180830381865afa158015612113573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261213b9190810190613f80565b90506000816060015160ff16116121895760405162461bcd60e51b8152602060048201526012602482015271105c1c08191bd95cc81b9bdd08195e1a5cdd60721b60448201526064016108af565b604080516001808252818301909252600091816020015b604080516060808201835260008083526020830152918101919091528152602001906001900390816121a057905050604080516060810190915283516001600160a01b03168152909150602081016000815260200183604001518152508160008151811061221057612210613de7565b602090810291909101810191909152828101516001600160e01b03191660009081526003860190915260409020805460ff19166001179055612253818888612ab9565b60008881526020868152604091829020845181548387015160e01c600160a01b026001600160c01b03199091166001600160a01b03909216919091171781559184015180518593926122ac92600185019291019061364e565b50606091909101516002909101805460ff191660ff9092169190911790555050505050505050565b60006122df82612672565b9050836001600160a01b0316816001600160a01b0316146123125760405162a1148160e81b815260040160405180910390fd5b60008061231e84612c04565b91509150612343818761232e3390565b6001600160a01b039081169116811491141790565b61236e576123518633611b3b565b61236e57604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b03851661239557604051633a954ecd60e21b815260040160405180910390fd5b80156123a057600082555b6123a8611c1f565b6001600160a01b03871660009081526005919091016020526040902080546000190190556123d4611c1f565b6001600160a01b03861660008181526005929092016020526040909120805460010190554260a01b17600160e11b1761240b611c1f565b60008681526004919091016020526040812091909155600160e11b84169003612481576001840161243a611c1f565b60008281526004919091016020526040812054900361247f5761245b611c1f565b54811461247f578361246b611c1f565b600083815260049190910160205260409020555b505b83856001600160a01b0316876001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45b505050505050565b60008060006124d985612c2c565b61ffff1690506124e885612c7a565b6127106124f58684614092565b6124ff91906140a9565b92509250509250929050565b8047101561255b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e636500000060448201526064016108af565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146125a8576040519150601f19603f3d011682016040523d82523d6000602084013e6125ad565b606091505b5050905080610f4e5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d6179206861766520726576657274656400000000000060648201526084016108af565b610f4e838383604051806020016040528060008152506118a1565b638b78c6d8600c5233600052806020600c20541661092457638b78c6d819543314610924576382b429006000526004601cfd5b60008160011161270657612684611c1f565b600083815260049190910160205260408120549150600160e01b821690036127065780600003612701576126b6611c1f565b5482106126d657604051636f96cda160e11b815260040160405180910390fd5b6126de611c1f565b6000199092016000818152600493909301602052604090922054905080156126d6575b919050565b604051636f96cda160e11b815260040160405180910390fd5b638b78c6d81980546001600160a01b039092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a355565b6000805160206143a183398151915254610100900460ff166127915760405162461bcd60e51b81526004016108af906140cb565b6109398282612cea565b6001600160a01b0316638b78c6d8198190558060007f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a350565b806127e0611c1f565b336000818152600792909201602090815260408084206001600160a01b03881680865290835293819020805460ff19169515159590951790945592518415158152919290917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b61285f848484610973565b6001600160a01b0383163b156128985761287b84848484612d5d565b612898576040516368d2bf6b60e11b815260040160405180910390fd5b50505050565b6060600080516020614339833981519152600601805461071090613d3f565b606060a06040510180604052602081039150506000815280825b600183039250600a81066030018353600a9004806128d75750819003601f19909101908152919050565b600061290b611c1f565b6001600160a01b039384166000908152600791909101602090815260408083209490951682529290925250205460ff1690565b600061294983610f53565b9050811561298857336001600160a01b038216146129885761296b8133611b3b565b612988576040516367d9dca160e11b815260040160405180910390fd5b83612991611c1f565b6000858152600691909101602052604080822080546001600160a01b0319166001600160a01b0394851617905551859287811692908516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259190a450505050565b6001600160a01b038216612a05575050565b612a278260405180606001604052806028815260200161431160289139612e48565b600080836001600160a01b031683604051612a42919061411f565b600060405180830381855af49150503d8060008114612a7d576040519150601f19603f3d011682016040523d82523d6000602084013e612a82565b606091505b50915091508161289857805115612a9c5780518082602001fd5b838360405163192105d760e01b81526004016108af92919061413b565b600080516020614359833981519152546000805160206142ad8339815191529061ffff811690819060009060071615612b045750600381901c60009081526001840160205260409020545b60005b8751811015612b8157612b7483838a8481518110612b2757612b27613de7565b6020026020010151600001518b8581518110612b4557612b45613de7565b6020026020010151602001518c8681518110612b6357612b63613de7565b602002602001015160400151612e69565b9093509150600101612b07565b50828214612b9d5760028401805461ffff191661ffff84161790555b6007821615612bbf57600382901c600090815260018501602052604090208190555b7f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb673878787604051612bf29392919061415f565b60405180910390a16108f186866129f3565b6000806000612c11611c1f565b60009485526006016020525050604090912080549092909150565b60008181527ff298352fd56f58214bf2245c2b202523f72fca3199077ce992640958228b281f6020819052604082205461ffff1691829003612c7457600181015461ffff1691505b50919050565b60008181527ff298352fd56f58214bf2245c2b202523f72fca3199077ce992640958228b282160205260409020546001600160a01b03167ff298352fd56f58214bf2245c2b202523f72fca3199077ce992640958228b281f81612c7457600301546001600160a01b031692915050565b6000805160206143a183398151915254610100900460ff16612d1e5760405162461bcd60e51b81526004016108af906140cb565b81612d27611c1f565b60020190612d359082613e43565b5080612d3f611c1f565b60030190612d4d9082613e43565b506001612d58611c1f565b555050565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a0290612d92903390899088908890600401614228565b6020604051808303816000875af1925050508015612dcd575060408051601f3d908101601f19168201909252612dca91810190614265565b60015b612e2b573d808015612dfb576040519150601f19603f3d011682016040523d82523d6000602084013e612e00565b606091505b508051600003612e23576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050949350505050565b813b81816128985760405162461bcd60e51b81526004016108af9190613799565b600080806000805160206142ad83398151915290506000845111612ee35760405162461bcd60e51b815260206004820152602b60248201527f4c69624469616d6f6e644375743a204e6f2073656c6563746f727320696e206660448201526a1858d95d081d1bc818dd5d60aa1b60648201526084016108af565b6000856002811115612ef757612ef7613d73565b0361305d57612f1e866040518060600160405280602481526020016142ed60249139612e48565b60005b8451811015613057576000858281518110612f3e57612f3e613de7565b6020908102919091018101516001600160e01b03198116600090815291859052604090912054909150606081901c15612fd75760405162461bcd60e51b815260206004820152603560248201527f4c69624469616d6f6e644375743a2043616e2774206164642066756e6374696f6044820152746e207468617420616c72656164792065786973747360581b60648201526084016108af565b6001600160e01b031980831660008181526020879052604090206001600160601b031960608d901b168e17905560e060058e901b811692831c199c909c1690821c179a81900361303b5760038c901c600090815260018601602052604081209b909b555b8b61304581613dce565b9c505060019093019250612f21915050565b5061361d565b600185600281111561307157613071613d73565b03613296576130988660405180606001604052806028815260200161437960289139612e48565b60005b84518110156130575760008582815181106130b8576130b8613de7565b6020908102919091018101516001600160e01b03198116600090815291859052604090912054909150606081901c30810361314d5760405162461bcd60e51b815260206004820152602f60248201527f4c69624469616d6f6e644375743a2043616e2774207265706c61636520696d6d60448201526e3aba30b1363290333ab731ba34b7b760891b60648201526084016108af565b896001600160a01b0316816001600160a01b0316036131d45760405162461bcd60e51b815260206004820152603860248201527f4c69624469616d6f6e644375743a2043616e2774207265706c6163652066756e60448201527f6374696f6e20776974682073616d652066756e6374696f6e000000000000000060648201526084016108af565b6001600160a01b0381166132505760405162461bcd60e51b815260206004820152603860248201527f4c69624469616d6f6e644375743a2043616e2774207265706c6163652066756e60448201527f6374696f6e207468617420646f65736e2774206578697374000000000000000060648201526084016108af565b506001600160e01b031990911660009081526020849052604090206bffffffffffffffffffffffff919091166001600160601b031960608a901b1617905560010161309b565b60028560028111156132aa576132aa613d73565b036135c5576001600160a01b038616156133255760405162461bcd60e51b815260206004820152603660248201527f4c69624469616d6f6e644375743a2052656d6f76652066616365742061646472604482015275657373206d757374206265206164647265737328302960501b60648201526084016108af565b600388901c6007891660005b86518110156135a55760008a900361336d578261334d81614282565b60008181526001870160205260409020549b5093506007925061337b9050565b8161337781614282565b9250505b6000806000808a858151811061339357613393613de7565b6020908102919091018101516001600160e01b031981166000908152918a9052604090912054909150606081901c6134335760405162461bcd60e51b815260206004820152603760248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f76652066756e6360448201527f74696f6e207468617420646f65736e277420657869737400000000000000000060648201526084016108af565b30606082901c0361349d5760405162461bcd60e51b815260206004820152602e60248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f766520696d6d7560448201526d3a30b1363290333ab731ba34b7b760911b60648201526084016108af565b600587901b8f901b94506001600160e01b0319808616908316146134f3576001600160e01b03198516600090815260208a90526040902080546001600160601b0319166bffffffffffffffffffffffff83161790555b6001600160e01b031991909116600090815260208990526040812055600381901c611fff16925060051b60e0169050858214613558576000828152600188016020526040902080546001600160e01b031980841c19909116908516831c17905561357c565b80836001600160e01b031916901c816001600160e01b031960001b901c198e16179c505b8460000361359a57600086815260018801602052604081208190559c505b505050600101613331565b50806135b2836008614092565b6135bc9190614299565b9950505061361d565b60405162461bcd60e51b815260206004820152602760248201527f4c69624469616d6f6e644375743a20496e636f727265637420466163657443756044820152663a20b1ba34b7b760c91b60648201526084016108af565b50959694955050505050565b50805460008255600701600890049060005260206000209081019061092491906136fa565b828054828255906000526020600020906007016008900481019282156136ea5791602002820160005b838211156136b857835183826101000a81548163ffffffff021916908360e01c02179055509260200192600401602081600301049283019260010302613677565b80156136e85782816101000a81549063ffffffff02191690556004016020816003010492830192600103026136b8565b505b506136f69291506136fa565b5090565b5b808211156136f657600081556001016136fb565b6001600160e01b03198116811461092457600080fd5b60006020828403121561373757600080fd5b81356137428161370f565b9392505050565b60005b8381101561376457818101518382015260200161374c565b50506000910152565b60008151808452613785816020860160208601613749565b601f01601f19169290920160200192915050565b602081526000613742602083018461376d565b6000602082840312156137be57600080fd5b5035919050565b6001600160a01b038116811461092457600080fd5b600080604083850312156137ed57600080fd5b82356137f8816137c5565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b604051608081016001600160401b038111828210171561383e5761383e613806565b60405290565b604051601f8201601f191681016001600160401b038111828210171561386c5761386c613806565b604052919050565b60006001600160401b0383111561388d5761388d613806565b6138a0601f8401601f1916602001613844565b90508281528383830111156138b457600080fd5b828260208301376000602084830101529392505050565b600082601f8301126138dc57600080fd5b61374283833560208501613874565b600080604083850312156138fe57600080fd5b8235915060208301356001600160401b0381111561391b57600080fd5b613927858286016138cb565b9150509250929050565b60008060006060848603121561394657600080fd5b8335613951816137c5565b92506020840135613961816137c5565b929592945050506040919091013590565b6000806040838503121561398557600080fd5b50508035926020909101359150565b6000602082840312156139a657600080fd5b8135613742816137c5565b600081518084526020808501945080840160005b838110156139eb5781516001600160e01b031916875295820195908201906001016139c5565b509495945050505050565b602080825282516001600160a01b0316828201528201516001600160e01b03191660408083019190915282015160806060830152600090613a3a60a08401826139b1565b905060ff60608501511660808401528091505092915050565b6020808252825182820181905260009190848201906040850190845b81811015613a945783516001600160a01b031683529284019291840191600101613a6f565b50909695505050505050565b600060208284031215613ab257600080fd5b81356001600160401b03811115613ac857600080fd5b8201601f81018413613ad957600080fd5b611b3384823560208401613874565b60008083601f840112613afa57600080fd5b5081356001600160401b03811115613b1157600080fd5b602083019150836020828501011115610aa857600080fd5b600080600080600080600060a0888a031215613b4457600080fd5b8735613b4f816137c5565b965060208801356001600160401b0380821115613b6b57600080fd5b613b778b838c01613ae8565b909850965060408a0135915080821115613b9057600080fd5b50613b9d8a828b01613ae8565b9095509350506060880135613bb1816137c5565b9150608088013561ffff81168114613bc857600080fd5b8091505092959891949750929550565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b83811015613c4757888303603f19018552815180516001600160a01b03168452870151878401879052613c34878501826139b1565b9588019593505090860190600101613bff565b509098975050505050505050565b60008060408385031215613c6857600080fd5b8235613c73816137c5565b915060208301358015158114613c8857600080fd5b809150509250929050565b60208152600061374260208301846139b1565b60008060008060808587031215613cbc57600080fd5b8435613cc7816137c5565b93506020850135613cd7816137c5565b92506040850135915060608501356001600160401b03811115613cf957600080fd5b613d05878288016138cb565b91505092959194509250565b60008060408385031215613d2457600080fd5b8235613d2f816137c5565b91506020830135613c88816137c5565b600181811c90821680613d5357607f821691505b602082108103612c7457634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b602080825260159082015274151c985b9cd9995c9cc81b9bdd08185b1b1bddd959605a1b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b600060018201613de057613de0613db8565b5060010190565b634e487b7160e01b600052603260045260246000fd5b601f821115610f4e57600081815260208120601f850160051c81016020861015613e245750805b601f850160051c820191505b818110156124c357828155600101613e30565b81516001600160401b03811115613e5c57613e5c613806565b613e7081613e6a8454613d3f565b84613dfd565b602080601f831160018114613ea55760008415613e8d5750858301515b600019600386901b1c1916600185901b1785556124c3565b600085815260208120601f198616915b82811015613ed457888601518255948401946001909101908401613eb5565b5085821015613ef25787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600061ffff808316818103613f1957613f19613db8565b6001019392505050565b60008351613f35818460208801613749565b835190830190613f49818360208801613749565b01949350505050565b600060208284031215613f6457600080fd5b8151613742816137c5565b805160ff8116811461270157600080fd5b60006020808385031215613f9357600080fd5b82516001600160401b0380821115613faa57600080fd5b9084019060808287031215613fbe57600080fd5b613fc661381c565b8251613fd1816137c5565b815282840151613fe08161370f565b81850152604083015182811115613ff657600080fd5b8301601f8101881361400757600080fd5b80518381111561401957614019613806565b8060051b935061402a868501613844565b818152938201860193868101908a86111561404457600080fd5b928701925b8584101561406e578351925061405e8361370f565b8282529287019290870190614049565b60408501525061408391505060608401613f6f565b60608201529695505050505050565b8082028115828204841417610f5e57610f5e613db8565b6000826140c657634e487b7160e01b600052601260045260246000fd5b500490565b60208082526034908201527f455243373231415f5f496e697469616c697a61626c653a20636f6e7472616374604082015273206973206e6f7420696e697469616c697a696e6760601b606082015260800190565b60008251614131818460208701613749565b9190910192915050565b6001600160a01b0383168152604060208201819052600090611b339083018461376d565b6000606080830181845280875180835260808601915060808160051b87010192506020808a016000805b848110156141f857898703607f19018652825180516001600160a01b0316885284810151600381106141c957634e487b7160e01b84526021600452602484fd5b888601526040908101519088018990526141e5898901826139b1565b9750509483019491830191600101614189565b5050506001600160a01b038916908701525050838103604085015261421d818661376d565b979650505050505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061425b9083018461376d565b9695505050505050565b60006020828403121561427757600080fd5b81516137428161370f565b60008161429157614291613db8565b506000190190565b80820180821115610f5e57610f5e613db856fec8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c45f38af8fd646bf817698fe2be76218d850d401ba88ffd7c9cd1b4f5c9a1db5a4c69624469616d6f6e644375743a2041646420666163657420686173206e6f20636f64654c69624469616d6f6e644375743a205f696e6974206164647265737320686173206e6f20636f646545f38af8fd646bf817698fe2be76218d850d401ba88ffd7c9cd1b4f5c9a1db56c8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e4c69624469616d6f6e644375743a205265706c61636520666163657420686173206e6f20636f6465ee151c8401928dc223602bb187aff91b9a56c7cae5476ef1b3287b085a16c85fa2646970667358221220eb656ee3b3ce6390e3a0b21c190f1929f215f21fe7b78c9986c42fb145bcf46664736f6c63430008130033ee151c8401928dc223602bb187aff91b9a56c7cae5476ef1b3287b085a16c85f
Deployed Bytecode
0x60806040526004361061020f5760003560e01c806355f804b31161011857806395d89b41116100a0578063c87b56dd1161006f578063c87b56dd1461063e578063cdffacc61461065e578063e985e9c5146106a5578063f0f44260146106c5578063f2fde38b146106e557600080fd5b806395d89b41146105c9578063a22cb465146105de578063adfca15e146105fe578063b88d4fde1461062b57600080fd5b8063715018a6116100e7578063715018a61461054657806375a284031461054e5780637a0ed6271461056e5780638aebc353146105905780638da5cb5b146105b057600080fd5b806355f804b3146104a957806361d027b3146104c95780636352211e1461050657806370a082311461052657600080fd5b806323b872dd1161019b5780633ccfd60b1161016a5780633ccfd60b1461041f57806342842e0e1461043457806342c71f1d146104475780634a4ee7b11461047457806352ef6b2c1461048757600080fd5b806323b872dd1461037a5780632a55205a1461038d5780632de94807146103cc5780632fa8374b146103ff57600080fd5b806318160ddd116101e257806318160ddd146102f1578063183a4f6e146103145780631c10893f146103275780631f1bf78b1461033a5780632099ba841461035a57600080fd5b806301ffc9a71461021457806306fdde0314610282578063081812fc146102a4578063095ea7b3146102dc575b600080fd5b34801561022057600080fd5b5061026d61022f366004613725565b6001600160e01b03191660009081527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131f602052604090205460ff1690565b60405190151581526020015b60405180910390f35b34801561028e57600080fd5b506102976106f8565b6040516102799190613799565b3480156102b057600080fd5b506102c46102bf3660046137ac565b610793565b6040516001600160a01b039091168152602001610279565b6102ef6102ea3660046137da565b6107e0565b005b3480156102fd57600080fd5b506103066108fa565b604051908152602001610279565b6102ef6103223660046137ac565b61091a565b6102ef6103353660046137da565b610927565b34801561034657600080fd5b506102ef6103553660046137ac565b61093d565b34801561036657600080fd5b506102ef6103753660046138eb565b610960565b6102ef610388366004613931565b610973565b34801561039957600080fd5b506103ad6103a8366004613972565b610a96565b604080516001600160a01b039093168352602083019190915201610279565b3480156103d857600080fd5b506103066103e7366004613994565b638b78c6d8600c908152600091909152602090205490565b34801561040b57600080fd5b506102ef61041a3660046137ac565b610aaf565b34801561042b57600080fd5b506102ef610ad2565b6102ef610442366004613931565b610b3b565b34801561045357600080fd5b506104676104623660046137ac565b610c54565b60405161027991906139f6565b6102ef6104823660046137da565b610d55565b34801561049357600080fd5b5061049c610d67565b6040516102799190613a53565b3480156104b557600080fd5b506102ef6104c4366004613aa0565b610f18565b3480156104d557600080fd5b507f45f38af8fd646bf817698fe2be76218d850d401ba88ffd7c9cd1b4f5c9a1db5b546001600160a01b03166102c4565b34801561051257600080fd5b506102c46105213660046137ac565b610f53565b34801561053257600080fd5b50610306610541366004613994565b610f64565b6102ef610fcc565b34801561055a57600080fd5b506102ef610569366004613b29565b610fe0565b34801561057a57600080fd5b506105836111d5565b6040516102799190613bd8565b34801561059c57600080fd5b506102ef6105ab3660046138eb565b61160e565b3480156105bc57600080fd5b50638b78c6d819546102c4565b3480156105d557600080fd5b50610297611621565b3480156105ea57600080fd5b506102ef6105f9366004613c55565b611639565b34801561060a57600080fd5b5061061e610619366004613994565b611742565b6040516102799190613c93565b6102ef610639366004613ca6565b6118a1565b34801561064a57600080fd5b506102976106593660046137ac565b6119c6565b34801561066a57600080fd5b506102c4610679366004613725565b6001600160e01b03191660009081526000805160206142ad833981519152602052604090205460601c90565b3480156106b157600080fd5b5061026d6106c0366004613d11565b611b3b565b3480156106d157600080fd5b506102ef6106e0366004613994565b611baf565b6102ef6106f3366004613994565b611bf8565b6060610702611c1f565b600201805461071090613d3f565b80601f016020809104026020016040519081016040528092919081815260200182805461073c90613d3f565b80156107895780601f1061075e57610100808354040283529160200191610789565b820191906000526020600020905b81548152906001019060200180831161076c57829003601f168201915b5050505050905090565b600061079e82611c43565b6107bb576040516333d1c03960e21b815260040160405180910390fd5b6107c3611c1f565b60009283526006016020525060409020546001600160a01b031690565b6000805160206142cd833981519152548290829060008051602061433983398151915290610100900460ff166002818181111561081f5761081f613d73565b14806108775750600181600281111561083a5761083a613d73565b14801561086257506001600160a01b038416600090815260018301602052604090205460ff16155b801561087757506001600160a01b0384163314155b806108925750600083815260028301602052604090205460ff165b156108b85760405162461bcd60e51b81526004016108af90613d89565b60405180910390fd5b856108c281611c8c565b6108e7576000805160206142cd8339815191525460ff16156108e7576108e781611cc9565b6108f18787611d0d565b50505050505050565b60006001610906611c1f565b60010154610912611c1f565b540303919050565b6109243382611d19565b50565b61092f611d68565b6109398282611d83565b5050565b610945611d68565b61092481600060405180602001604052806000815250611dce565b610968611d68565b610939823083612025565b6000805160206142cd833981519152548390829060008051602061433983398151915290610100900460ff16600281818111156109b2576109b2613d73565b1480610a0a575060018160028111156109cd576109cd613d73565b1480156109f557506001600160a01b038416600090815260018301602052604090205460ff16155b8015610a0a57506001600160a01b0384163314155b80610a255750600083815260028301602052604090205460ff165b15610a425760405162461bcd60e51b81526004016108af90613d89565b866001600160a01b0381163314610a8157610a5c33611c8c565b610a81576000805160206142cd8339815191525460ff1615610a8157610a8133611cc9565b610a8c8888886122d4565b5050505050505050565b600080610aa384846124cb565b915091505b9250929050565b610ab7611d68565b61092481600060405180602001604052806000815250612025565b610ada611d68565b6000805160206143398339815191524780610b235760405162461bcd60e51b8152602060048201526009602482015268302062616c616e636560b81b60448201526064016108af565b6005820154610939906001600160a01b03168261250b565b6000805160206142cd833981519152548390829060008051602061433983398151915290610100900460ff1660028181811115610b7a57610b7a613d73565b1480610bd257506001816002811115610b9557610b95613d73565b148015610bbd57506001600160a01b038416600090815260018301602052604090205460ff16155b8015610bd257506001600160a01b0384163314155b80610bed5750600083815260028301602052604090205460ff165b15610c0a5760405162461bcd60e51b81526004016108af90613d89565b866001600160a01b0381163314610c4957610c2433611c8c565b610c49576000805160206142cd8339815191525460ff1615610c4957610c4933611cc9565b610a8c888888612624565b604080516080808201835260008083526020808401829052606084860181905284018290528582526000805160206143398339815191528152908490208451928301855280546001600160a01b0381168452600160a01b900460e01b6001600160e01b031916838301526001810180548651818502810185018852818152959694959294860193830182828015610d3757602002820191906000526020600020906000905b82829054906101000a900460e01b6001600160e01b03191681526020019060040190602082600301049283019260010382029150808411610cf95790505b50505091835250506002919091015460ff1660209091015292915050565b610d5d611d68565b6109398282611d19565b600080516020614359833981519152546060906000805160206142ad8339815191529061ffff166001600160401b03811115610da557610da5613806565b604051908082528060200260200182016040528015610dce578160200160208202803683370190505b50915060008060005b600284015461ffff16821015610f10576000818152600185016020526040812054905b6008811015610efb5783610e0d81613dce565b600288015490955061ffff1685119050610efb57600581901b82901b6001600160e01b0319811660009081526020889052604081205460601c90805b88811015610e9e578a8181518110610e6357610e63613de7565b60200260200101516001600160a01b0316836001600160a01b031603610e8c5760019150610e9e565b80610e9681613dce565b915050610e49565b508015610ead57505050610ee9565b818a8981518110610ec057610ec0613de7565b6001600160a01b039092166020928302919091019091015287610ee281613dce565b9850505050505b80610ef381613dce565b915050610dfa565b50508080610f0890613dce565b915050610dd7565b505082525090565b6002610f238161263f565b7f45f38af8fd646bf817698fe2be76218d850d401ba88ffd7c9cd1b4f5c9a1db5c610f4e8382613e43565b505050565b6000610f5e82612672565b92915050565b60006001600160a01b038216610f8d576040516323d3ad8160e21b815260040160405180910390fd5b6001600160401b03610f9d611c1f565b6005016000846001600160a01b03166001600160a01b0316815260200190815260200160002054169050919050565b610fd4611d68565b610fde600061271f565b565b6000805160206143a183398151915254610100900460ff16611015576000805160206143a18339815191525460ff1615611019565b303b155b61108b5760405162461bcd60e51b815260206004820152603760248201527f455243373231415f5f496e697469616c697a61626c653a20636f6e747261637460448201527f20697320616c726561647920696e697469616c697a656400000000000000000060648201526084016108af565b6000805160206143a183398151915254610100900460ff161580156110c7576000805160206143a1833981519152805461ffff19166101011790555b61113a87878080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8b01819004810282018101909252898152925089915088908190840183828082843760009201919091525061275d92505050565b6111438861279b565b7ff298352fd56f58214bf2245c2b202523f72fca3199077ce992640958228b2820805461ffff191661ffff84161790557ff298352fd56f58214bf2245c2b202523f72fca3199077ce992640958228b282280546001600160a01b0319166001600160a01b0385161790558015610a8c5750506000805160206143a1833981519152805461ff0019169055505050505050565b600080516020614359833981519152546060906000805160206142ad8339815191529061ffff166001600160401b0381111561121357611213613806565b60405190808252806020026020018201604052801561125957816020015b6040805180820190915260008152606060208201528152602001906001900390816112315790505b50600282015490925060009061ffff166001600160401b0381111561128057611280613806565b6040519080825280602002602001820160405280156112a9578160200160208202803683370190505b50905060008060005b600285015461ffff1682101561159b576000818152600186016020526040812054905b600881101561158657836112e881613dce565b600289015490955061ffff168511905061158657600581901b82901b6001600160e01b0319811660009081526020899052604081205460601c90805b8881101561144457826001600160a01b03168c828151811061134857611348613de7565b6020026020010151600001516001600160a01b03160361143257838c828151811061137557611375613de7565b6020026020010151602001518b838151811061139357611393613de7565b602002602001015161ffff16815181106113af576113af613de7565b60200260200101906001600160e01b03191690816001600160e01b0319168152505060ff8a82815181106113e5576113e5613de7565b602002602001015161ffff16106113fb57600080fd5b89818151811061140d5761140d613de7565b60200260200101805180919061142290613f02565b61ffff1690525060019150611444565b8061143c81613dce565b915050611324565b50801561145357505050611574565b818b898151811061146657611466613de7565b60209081029190910101516001600160a01b03909116905260028a015461ffff166001600160401b0381111561149e5761149e613806565b6040519080825280602002602001820160405280156114c7578160200160208202803683370190505b508b89815181106114da576114da613de7565b602002602001015160200181905250828b89815181106114fc576114fc613de7565b60200260200101516020015160008151811061151a5761151a613de7565b60200260200101906001600160e01b03191690816001600160e01b03191681525050600189898151811061155057611550613de7565b61ffff909216602092830291909101909101528761156d81613dce565b9850505050505b8061157e81613dce565b9150506112d5565b5050808061159390613dce565b9150506112b2565b5060005b828110156116035760008482815181106115bb576115bb613de7565b602002602001015161ffff16905060008783815181106115dd576115dd613de7565b6020026020010151602001519050818152505080806115fb90613dce565b91505061159f565b508185525050505090565b611616611d68565b610939823083611dce565b606061162b611c1f565b600301805461071090613d3f565b6000805160206142cd83398151915254829060009060008051602061433983398151915290610100900460ff166002818181111561167957611679613d73565b14806116d15750600181600281111561169457611694613d73565b1480156116bc57506001600160a01b038416600090815260018301602052604090205460ff16155b80156116d157506001600160a01b0384163314155b806116ec5750600083815260028301602052604090205460ff165b156117095760405162461bcd60e51b81526004016108af90613d89565b8561171381611c8c565b611738576000805160206142cd8339815191525460ff16156117385761173881611cc9565b6108f187876127d7565b600080516020614359833981519152546060906000805160206142ad8339815191529060009061ffff166001600160401b0381111561178357611783613806565b6040519080825280602002602001820160405280156117ac578160200160208202803683370190505b5092506000805b600284015461ffff16821015611897576000818152600185016020526040812054905b600881101561188257836117e981613dce565b600288015490955061ffff168511905061188257600581901b82901b6001600160e01b0319811660009081526020889052604090205460601c6001600160a01b038a1681900361186d578189888151811061184657611846613de7565b6001600160e01b0319909216602092830291909101909101528661186981613dce565b9750505b5050808061187a90613dce565b9150506117d6565b5050808061188f90613dce565b9150506117b3565b5050825250919050565b6000805160206142cd833981519152548490839060008051602061433983398151915290610100900460ff16600281818111156118e0576118e0613d73565b1480611938575060018160028111156118fb576118fb613d73565b14801561192357506001600160a01b038416600090815260018301602052604090205460ff16155b801561193857506001600160a01b0384163314155b806119535750600083815260028301602052604090205460ff165b156119705760405162461bcd60e51b81526004016108af90613d89565b876001600160a01b03811633146119af5761198a33611c8c565b6119af576000805160206142cd8339815191525460ff16156119af576119af33611cc9565b6119bb89898989612854565b505050505050505050565b60606119d182611c43565b6119ee57604051630a14c4b560e41b815260040160405180910390fd5b60008281527f45f38af8fd646bf817698fe2be76218d850d401ba88ffd7c9cd1b4f5c9a1db59602090815260408083208151808301909252805460ff16151582526001810180549293919291840191611a4690613d3f565b80601f0160208091040260200160405190810160405280929190818152602001828054611a7290613d3f565b8015611abf5780601f10611a9457610100808354040283529160200191611abf565b820191906000526020600020905b815481529060010190602001808311611aa257829003601f168201915b5050505050815250509050806000015115611ade576020015192915050565b6000611ae861289e565b90508051600003611b085760405180602001604052806000815250611b33565b80611b12856128bd565b604051602001611b23929190613f23565b6040516020818303038152906040525b949350505050565b6000805160206142cd8339815191525460009060008051602061433983398151915290600190610100900460ff166002811115611b7a57611b7a613d73565b03611ba5576001600160a01b03831660009081526001909101602052604090205460ff169050610f5e565b611b338484612901565b611bb7611d68565b7f45f38af8fd646bf817698fe2be76218d850d401ba88ffd7c9cd1b4f5c9a1db5b80546001600160a01b0319166001600160a01b0392909216919091179055565b611c00611d68565b8060601b611c1657637448fbae6000526004601cfd5b6109248161271f565b7f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c4090565b600081600111158015611c5d5750611c59611c1f565b5482105b8015610f5e5750600160e01b611c71611c1f565b60008481526004919091016020526040902054161592915050565b6001600160a01b031660009081527f45f38af8fd646bf817698fe2be76218d850d401ba88ffd7c9cd1b4f5c9a1db57602052604090205460ff1690565b69c617113400112233445560005230601a5280603a52600080604460166daaeb6d7670e522a718067333cd4e5afa611d05573d6000803e3d6000fd5b6000603a5250565b6109398282600161293e565b638b78c6d8600c52816000526020600c20805482811681189250508181555080600c5160601c7f715ad5ce61fc9595c7b415289d59cf203f23a94fa06f04af7e489a0a76e1fe26600080a35050565b638b78c6d819543314610fde576382b429006000526004601cfd5b638b78c6d8600c52816000526020600c208181541791508181555080600c5160601c7f715ad5ce61fc9595c7b415289d59cf203f23a94fa06f04af7e489a0a76e1fe26600080a35050565b600083815260008051602061433983398151915260208181526040808420815160808101835281546001600160a01b0381168252600160a01b900460e01b6001600160e01b03191681850152600182018054845181870281018701865281815296976000805160206142ad833981519152979096939586019390929190830182828015611ea757602002820191906000526020600020906000905b82829054906101000a900460e01b6001600160e01b03191681526020019060040190602082600301049283019260010382029150808411611e695790505b50505091835250506002919091015460ff908116602090920191909152606082015191925016611f0e5760405162461bcd60e51b8152602060048201526012602482015271105c1c08191bd95cc81b9bdd08195e1a5cdd60721b60448201526064016108af565b604080516001808252818301909252600091816020015b60408051606080820183526000808352602083015291810191909152815260200190600190039081611f25579050506040805160608101909152600081529091506020810160028152602001836040015181525081600081518110611f8c57611f8c613de7565b602090810291909101810191909152828101516001600160e01b03191660009081526003850190915260409020805460ff19169055611fcb86866129f3565b611fe681600060405180602001604052806000815250612ab9565b600087815260208590526040812080546001600160c01b0319168155906120106001830182613629565b50600201805460ff1916905550505050505050565b6000600080516020614339833981519152905060006000805160206142ad833981519152905060008260040160029054906101000a90046001600160a01b03166001600160a01b031663bb4fceb96040518163ffffffff1660e01b81526004016020604051808303816000875af11580156120a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120c89190613f52565b6040516342c71f1d60e01b8152600481018890529091506000906001600160a01b038316906342c71f1d90602401600060405180830381865afa158015612113573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261213b9190810190613f80565b90506000816060015160ff16116121895760405162461bcd60e51b8152602060048201526012602482015271105c1c08191bd95cc81b9bdd08195e1a5cdd60721b60448201526064016108af565b604080516001808252818301909252600091816020015b604080516060808201835260008083526020830152918101919091528152602001906001900390816121a057905050604080516060810190915283516001600160a01b03168152909150602081016000815260200183604001518152508160008151811061221057612210613de7565b602090810291909101810191909152828101516001600160e01b03191660009081526003860190915260409020805460ff19166001179055612253818888612ab9565b60008881526020868152604091829020845181548387015160e01c600160a01b026001600160c01b03199091166001600160a01b03909216919091171781559184015180518593926122ac92600185019291019061364e565b50606091909101516002909101805460ff191660ff9092169190911790555050505050505050565b60006122df82612672565b9050836001600160a01b0316816001600160a01b0316146123125760405162a1148160e81b815260040160405180910390fd5b60008061231e84612c04565b91509150612343818761232e3390565b6001600160a01b039081169116811491141790565b61236e576123518633611b3b565b61236e57604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b03851661239557604051633a954ecd60e21b815260040160405180910390fd5b80156123a057600082555b6123a8611c1f565b6001600160a01b03871660009081526005919091016020526040902080546000190190556123d4611c1f565b6001600160a01b03861660008181526005929092016020526040909120805460010190554260a01b17600160e11b1761240b611c1f565b60008681526004919091016020526040812091909155600160e11b84169003612481576001840161243a611c1f565b60008281526004919091016020526040812054900361247f5761245b611c1f565b54811461247f578361246b611c1f565b600083815260049190910160205260409020555b505b83856001600160a01b0316876001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45b505050505050565b60008060006124d985612c2c565b61ffff1690506124e885612c7a565b6127106124f58684614092565b6124ff91906140a9565b92509250509250929050565b8047101561255b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e636500000060448201526064016108af565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146125a8576040519150601f19603f3d011682016040523d82523d6000602084013e6125ad565b606091505b5050905080610f4e5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d6179206861766520726576657274656400000000000060648201526084016108af565b610f4e838383604051806020016040528060008152506118a1565b638b78c6d8600c5233600052806020600c20541661092457638b78c6d819543314610924576382b429006000526004601cfd5b60008160011161270657612684611c1f565b600083815260049190910160205260408120549150600160e01b821690036127065780600003612701576126b6611c1f565b5482106126d657604051636f96cda160e11b815260040160405180910390fd5b6126de611c1f565b6000199092016000818152600493909301602052604090922054905080156126d6575b919050565b604051636f96cda160e11b815260040160405180910390fd5b638b78c6d81980546001600160a01b039092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a355565b6000805160206143a183398151915254610100900460ff166127915760405162461bcd60e51b81526004016108af906140cb565b6109398282612cea565b6001600160a01b0316638b78c6d8198190558060007f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a350565b806127e0611c1f565b336000818152600792909201602090815260408084206001600160a01b03881680865290835293819020805460ff19169515159590951790945592518415158152919290917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b61285f848484610973565b6001600160a01b0383163b156128985761287b84848484612d5d565b612898576040516368d2bf6b60e11b815260040160405180910390fd5b50505050565b6060600080516020614339833981519152600601805461071090613d3f565b606060a06040510180604052602081039150506000815280825b600183039250600a81066030018353600a9004806128d75750819003601f19909101908152919050565b600061290b611c1f565b6001600160a01b039384166000908152600791909101602090815260408083209490951682529290925250205460ff1690565b600061294983610f53565b9050811561298857336001600160a01b038216146129885761296b8133611b3b565b612988576040516367d9dca160e11b815260040160405180910390fd5b83612991611c1f565b6000858152600691909101602052604080822080546001600160a01b0319166001600160a01b0394851617905551859287811692908516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259190a450505050565b6001600160a01b038216612a05575050565b612a278260405180606001604052806028815260200161431160289139612e48565b600080836001600160a01b031683604051612a42919061411f565b600060405180830381855af49150503d8060008114612a7d576040519150601f19603f3d011682016040523d82523d6000602084013e612a82565b606091505b50915091508161289857805115612a9c5780518082602001fd5b838360405163192105d760e01b81526004016108af92919061413b565b600080516020614359833981519152546000805160206142ad8339815191529061ffff811690819060009060071615612b045750600381901c60009081526001840160205260409020545b60005b8751811015612b8157612b7483838a8481518110612b2757612b27613de7565b6020026020010151600001518b8581518110612b4557612b45613de7565b6020026020010151602001518c8681518110612b6357612b63613de7565b602002602001015160400151612e69565b9093509150600101612b07565b50828214612b9d5760028401805461ffff191661ffff84161790555b6007821615612bbf57600382901c600090815260018501602052604090208190555b7f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb673878787604051612bf29392919061415f565b60405180910390a16108f186866129f3565b6000806000612c11611c1f565b60009485526006016020525050604090912080549092909150565b60008181527ff298352fd56f58214bf2245c2b202523f72fca3199077ce992640958228b281f6020819052604082205461ffff1691829003612c7457600181015461ffff1691505b50919050565b60008181527ff298352fd56f58214bf2245c2b202523f72fca3199077ce992640958228b282160205260409020546001600160a01b03167ff298352fd56f58214bf2245c2b202523f72fca3199077ce992640958228b281f81612c7457600301546001600160a01b031692915050565b6000805160206143a183398151915254610100900460ff16612d1e5760405162461bcd60e51b81526004016108af906140cb565b81612d27611c1f565b60020190612d359082613e43565b5080612d3f611c1f565b60030190612d4d9082613e43565b506001612d58611c1f565b555050565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a0290612d92903390899088908890600401614228565b6020604051808303816000875af1925050508015612dcd575060408051601f3d908101601f19168201909252612dca91810190614265565b60015b612e2b573d808015612dfb576040519150601f19603f3d011682016040523d82523d6000602084013e612e00565b606091505b508051600003612e23576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050949350505050565b813b81816128985760405162461bcd60e51b81526004016108af9190613799565b600080806000805160206142ad83398151915290506000845111612ee35760405162461bcd60e51b815260206004820152602b60248201527f4c69624469616d6f6e644375743a204e6f2073656c6563746f727320696e206660448201526a1858d95d081d1bc818dd5d60aa1b60648201526084016108af565b6000856002811115612ef757612ef7613d73565b0361305d57612f1e866040518060600160405280602481526020016142ed60249139612e48565b60005b8451811015613057576000858281518110612f3e57612f3e613de7565b6020908102919091018101516001600160e01b03198116600090815291859052604090912054909150606081901c15612fd75760405162461bcd60e51b815260206004820152603560248201527f4c69624469616d6f6e644375743a2043616e2774206164642066756e6374696f6044820152746e207468617420616c72656164792065786973747360581b60648201526084016108af565b6001600160e01b031980831660008181526020879052604090206001600160601b031960608d901b168e17905560e060058e901b811692831c199c909c1690821c179a81900361303b5760038c901c600090815260018601602052604081209b909b555b8b61304581613dce565b9c505060019093019250612f21915050565b5061361d565b600185600281111561307157613071613d73565b03613296576130988660405180606001604052806028815260200161437960289139612e48565b60005b84518110156130575760008582815181106130b8576130b8613de7565b6020908102919091018101516001600160e01b03198116600090815291859052604090912054909150606081901c30810361314d5760405162461bcd60e51b815260206004820152602f60248201527f4c69624469616d6f6e644375743a2043616e2774207265706c61636520696d6d60448201526e3aba30b1363290333ab731ba34b7b760891b60648201526084016108af565b896001600160a01b0316816001600160a01b0316036131d45760405162461bcd60e51b815260206004820152603860248201527f4c69624469616d6f6e644375743a2043616e2774207265706c6163652066756e60448201527f6374696f6e20776974682073616d652066756e6374696f6e000000000000000060648201526084016108af565b6001600160a01b0381166132505760405162461bcd60e51b815260206004820152603860248201527f4c69624469616d6f6e644375743a2043616e2774207265706c6163652066756e60448201527f6374696f6e207468617420646f65736e2774206578697374000000000000000060648201526084016108af565b506001600160e01b031990911660009081526020849052604090206bffffffffffffffffffffffff919091166001600160601b031960608a901b1617905560010161309b565b60028560028111156132aa576132aa613d73565b036135c5576001600160a01b038616156133255760405162461bcd60e51b815260206004820152603660248201527f4c69624469616d6f6e644375743a2052656d6f76652066616365742061646472604482015275657373206d757374206265206164647265737328302960501b60648201526084016108af565b600388901c6007891660005b86518110156135a55760008a900361336d578261334d81614282565b60008181526001870160205260409020549b5093506007925061337b9050565b8161337781614282565b9250505b6000806000808a858151811061339357613393613de7565b6020908102919091018101516001600160e01b031981166000908152918a9052604090912054909150606081901c6134335760405162461bcd60e51b815260206004820152603760248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f76652066756e6360448201527f74696f6e207468617420646f65736e277420657869737400000000000000000060648201526084016108af565b30606082901c0361349d5760405162461bcd60e51b815260206004820152602e60248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f766520696d6d7560448201526d3a30b1363290333ab731ba34b7b760911b60648201526084016108af565b600587901b8f901b94506001600160e01b0319808616908316146134f3576001600160e01b03198516600090815260208a90526040902080546001600160601b0319166bffffffffffffffffffffffff83161790555b6001600160e01b031991909116600090815260208990526040812055600381901c611fff16925060051b60e0169050858214613558576000828152600188016020526040902080546001600160e01b031980841c19909116908516831c17905561357c565b80836001600160e01b031916901c816001600160e01b031960001b901c198e16179c505b8460000361359a57600086815260018801602052604081208190559c505b505050600101613331565b50806135b2836008614092565b6135bc9190614299565b9950505061361d565b60405162461bcd60e51b815260206004820152602760248201527f4c69624469616d6f6e644375743a20496e636f727265637420466163657443756044820152663a20b1ba34b7b760c91b60648201526084016108af565b50959694955050505050565b50805460008255600701600890049060005260206000209081019061092491906136fa565b828054828255906000526020600020906007016008900481019282156136ea5791602002820160005b838211156136b857835183826101000a81548163ffffffff021916908360e01c02179055509260200192600401602081600301049283019260010302613677565b80156136e85782816101000a81549063ffffffff02191690556004016020816003010492830192600103026136b8565b505b506136f69291506136fa565b5090565b5b808211156136f657600081556001016136fb565b6001600160e01b03198116811461092457600080fd5b60006020828403121561373757600080fd5b81356137428161370f565b9392505050565b60005b8381101561376457818101518382015260200161374c565b50506000910152565b60008151808452613785816020860160208601613749565b601f01601f19169290920160200192915050565b602081526000613742602083018461376d565b6000602082840312156137be57600080fd5b5035919050565b6001600160a01b038116811461092457600080fd5b600080604083850312156137ed57600080fd5b82356137f8816137c5565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b604051608081016001600160401b038111828210171561383e5761383e613806565b60405290565b604051601f8201601f191681016001600160401b038111828210171561386c5761386c613806565b604052919050565b60006001600160401b0383111561388d5761388d613806565b6138a0601f8401601f1916602001613844565b90508281528383830111156138b457600080fd5b828260208301376000602084830101529392505050565b600082601f8301126138dc57600080fd5b61374283833560208501613874565b600080604083850312156138fe57600080fd5b8235915060208301356001600160401b0381111561391b57600080fd5b613927858286016138cb565b9150509250929050565b60008060006060848603121561394657600080fd5b8335613951816137c5565b92506020840135613961816137c5565b929592945050506040919091013590565b6000806040838503121561398557600080fd5b50508035926020909101359150565b6000602082840312156139a657600080fd5b8135613742816137c5565b600081518084526020808501945080840160005b838110156139eb5781516001600160e01b031916875295820195908201906001016139c5565b509495945050505050565b602080825282516001600160a01b0316828201528201516001600160e01b03191660408083019190915282015160806060830152600090613a3a60a08401826139b1565b905060ff60608501511660808401528091505092915050565b6020808252825182820181905260009190848201906040850190845b81811015613a945783516001600160a01b031683529284019291840191600101613a6f565b50909695505050505050565b600060208284031215613ab257600080fd5b81356001600160401b03811115613ac857600080fd5b8201601f81018413613ad957600080fd5b611b3384823560208401613874565b60008083601f840112613afa57600080fd5b5081356001600160401b03811115613b1157600080fd5b602083019150836020828501011115610aa857600080fd5b600080600080600080600060a0888a031215613b4457600080fd5b8735613b4f816137c5565b965060208801356001600160401b0380821115613b6b57600080fd5b613b778b838c01613ae8565b909850965060408a0135915080821115613b9057600080fd5b50613b9d8a828b01613ae8565b9095509350506060880135613bb1816137c5565b9150608088013561ffff81168114613bc857600080fd5b8091505092959891949750929550565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b83811015613c4757888303603f19018552815180516001600160a01b03168452870151878401879052613c34878501826139b1565b9588019593505090860190600101613bff565b509098975050505050505050565b60008060408385031215613c6857600080fd5b8235613c73816137c5565b915060208301358015158114613c8857600080fd5b809150509250929050565b60208152600061374260208301846139b1565b60008060008060808587031215613cbc57600080fd5b8435613cc7816137c5565b93506020850135613cd7816137c5565b92506040850135915060608501356001600160401b03811115613cf957600080fd5b613d05878288016138cb565b91505092959194509250565b60008060408385031215613d2457600080fd5b8235613d2f816137c5565b91506020830135613c88816137c5565b600181811c90821680613d5357607f821691505b602082108103612c7457634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b602080825260159082015274151c985b9cd9995c9cc81b9bdd08185b1b1bddd959605a1b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b600060018201613de057613de0613db8565b5060010190565b634e487b7160e01b600052603260045260246000fd5b601f821115610f4e57600081815260208120601f850160051c81016020861015613e245750805b601f850160051c820191505b818110156124c357828155600101613e30565b81516001600160401b03811115613e5c57613e5c613806565b613e7081613e6a8454613d3f565b84613dfd565b602080601f831160018114613ea55760008415613e8d5750858301515b600019600386901b1c1916600185901b1785556124c3565b600085815260208120601f198616915b82811015613ed457888601518255948401946001909101908401613eb5565b5085821015613ef25787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600061ffff808316818103613f1957613f19613db8565b6001019392505050565b60008351613f35818460208801613749565b835190830190613f49818360208801613749565b01949350505050565b600060208284031215613f6457600080fd5b8151613742816137c5565b805160ff8116811461270157600080fd5b60006020808385031215613f9357600080fd5b82516001600160401b0380821115613faa57600080fd5b9084019060808287031215613fbe57600080fd5b613fc661381c565b8251613fd1816137c5565b815282840151613fe08161370f565b81850152604083015182811115613ff657600080fd5b8301601f8101881361400757600080fd5b80518381111561401957614019613806565b8060051b935061402a868501613844565b818152938201860193868101908a86111561404457600080fd5b928701925b8584101561406e578351925061405e8361370f565b8282529287019290870190614049565b60408501525061408391505060608401613f6f565b60608201529695505050505050565b8082028115828204841417610f5e57610f5e613db8565b6000826140c657634e487b7160e01b600052601260045260246000fd5b500490565b60208082526034908201527f455243373231415f5f496e697469616c697a61626c653a20636f6e7472616374604082015273206973206e6f7420696e697469616c697a696e6760601b606082015260800190565b60008251614131818460208701613749565b9190910192915050565b6001600160a01b0383168152604060208201819052600090611b339083018461376d565b6000606080830181845280875180835260808601915060808160051b87010192506020808a016000805b848110156141f857898703607f19018652825180516001600160a01b0316885284810151600381106141c957634e487b7160e01b84526021600452602484fd5b888601526040908101519088018990526141e5898901826139b1565b9750509483019491830191600101614189565b5050506001600160a01b038916908701525050838103604085015261421d818661376d565b979650505050505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061425b9083018461376d565b9695505050505050565b60006020828403121561427757600080fd5b81516137428161370f565b60008161429157614291613db8565b506000190190565b80820180821115610f5e57610f5e613db856fec8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c45f38af8fd646bf817698fe2be76218d850d401ba88ffd7c9cd1b4f5c9a1db5a4c69624469616d6f6e644375743a2041646420666163657420686173206e6f20636f64654c69624469616d6f6e644375743a205f696e6974206164647265737320686173206e6f20636f646545f38af8fd646bf817698fe2be76218d850d401ba88ffd7c9cd1b4f5c9a1db56c8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e4c69624469616d6f6e644375743a205265706c61636520666163657420686173206e6f20636f6465ee151c8401928dc223602bb187aff91b9a56c7cae5476ef1b3287b085a16c85fa2646970667358221220eb656ee3b3ce6390e3a0b21c190f1929f215f21fe7b78c9986c42fb145bcf46664736f6c63430008130033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.