Overview
APE Balance
APE Value
$0.00More Info
Private Name Tags
ContractCreator
TokenTracker
Multichain Info
Latest 25 from a total of 109 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Purchase Item | 32640443 | 3 days ago | IN | 0 APE | 0.0125571 | ||||
| Update Item | 32447663 | 8 days ago | IN | 0 APE | 0.01247118 | ||||
| Create Item | 32447660 | 8 days ago | IN | 0 APE | 0.01468837 | ||||
| Update Item | 32447656 | 8 days ago | IN | 0 APE | 0.01247118 | ||||
| Create Item | 32447651 | 8 days ago | IN | 0 APE | 0.01468837 | ||||
| Update Item | 32447646 | 8 days ago | IN | 0 APE | 0.01247118 | ||||
| Create Item | 32447642 | 8 days ago | IN | 0 APE | 0.01468837 | ||||
| Update Item | 32447634 | 8 days ago | IN | 0 APE | 0.01247118 | ||||
| Create Item | 32447631 | 8 days ago | IN | 0 APE | 0.01468837 | ||||
| Update Item | 32447627 | 8 days ago | IN | 0 APE | 0.01247118 | ||||
| Create Item | 32447624 | 8 days ago | IN | 0 APE | 0.01468837 | ||||
| Update Item | 32447621 | 8 days ago | IN | 0 APE | 0.01247118 | ||||
| Create Item | 32447616 | 8 days ago | IN | 0 APE | 0.01468837 | ||||
| Update Item | 32447611 | 8 days ago | IN | 0 APE | 0.01247118 | ||||
| Create Item | 32447608 | 8 days ago | IN | 0 APE | 0.01468837 | ||||
| Update Item | 32447607 | 8 days ago | IN | 0 APE | 0.01247118 | ||||
| Create Item | 32447602 | 8 days ago | IN | 0 APE | 0.01468837 | ||||
| Update Item | 32447599 | 8 days ago | IN | 0 APE | 0.01247118 | ||||
| Create Item | 32447596 | 8 days ago | IN | 0 APE | 0.01468837 | ||||
| Update Item | 32447592 | 8 days ago | IN | 0 APE | 0.01247118 | ||||
| Create Item | 32447589 | 8 days ago | IN | 0 APE | 0.01468837 | ||||
| Update Item | 32447586 | 8 days ago | IN | 0 APE | 0.01247118 | ||||
| Create Item | 32447581 | 8 days ago | IN | 0 APE | 0.01468837 | ||||
| Update Item | 32447577 | 8 days ago | IN | 0 APE | 0.01247118 | ||||
| Create Item | 32447574 | 8 days ago | IN | 0 APE | 0.01468837 |
View more zero value Internal Transactions in Advanced View mode
Cross-Chain Transactions
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.28; import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; import "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import "@openzeppelin/contracts/utils/Pausable.sol"; import "@openzeppelin/contracts/interfaces/IERC2981.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "operator-filter-registry/src/DefaultOperatorFilterer.sol"; import "operator-filter-registry/src/IOperatorFilterRegistry.sol"; /** * @title GeezItems1155 - Fixed & Audited Version * @notice Central Item Registry for the Geez Ecosystem - ERC-1155 Multi-Token * @dev Production Implementation Features: * - DYNAMIC CATEGORIES: Unlimited category expansion without contract upgrade * - Flexible Supply: Hard caps with admin ability to increase/decrease * - Equipment System: Slot-based with conflict detection (two-handed, full-body) * - Redeem Mechanics: Burn-only and burn-to-souvenir patterns with helper functions * - Taxonomy: Category (logic) + SubCategory (display) for maximum flexibility * - Gas Optimized: Packed structs and efficient storage patterns * - Dynamic Royalties: 0% for official marketplace, 5% for external (adjustable) * - Security Hardened: Fixed all critical audit findings * * @custom:security-contact [email protected] * @custom:version 1.3.0 - Audit Fixed */ contract GeezItems1155 is ERC1155, AccessControl, ReentrancyGuard, Pausable, IERC2981, DefaultOperatorFilterer { using Strings for uint256; // ═══════════════════════════════════════════════════════════ // TYPES & CONSTANTS // ═══════════════════════════════════════════════════════════ /// @notice Role for minting and burning (GameController) bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); /// @notice Role for pausing contract bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); /// @notice Equipment target enumeration enum Target { NONE, // Not equippable GEEZ, // Only Geez can equip MOUNT, // Only Mount can equip BOTH // Both Geez and Mount can equip } /// @notice Redemption behavior enumeration enum RedeemStyle { BURN_ONLY, // Burn item completely BURN_AND_SOUVENIR // Burn and mint souvenir token } /// @notice Dynamic category structure /// @dev Categories can be added infinitely by admin struct Category { string name; // Display name (e.g., "Weapon", "Consumable") bool active; // Is this category usable? uint256 createdAt; // Timestamp for tracking } /// @notice Complete item configuration - OPTIMIZED STRUCT PACKING /// @dev Reordered for gas efficiency (saves ~2,100 gas per read) struct ItemConfig { // Slot 1: Pack small values together (7 bytes used, 25 bytes free) uint8 categoryId; // 1 byte - Dynamic category ID uint8 slot; // 1 byte - Equipment slot (0 = not equippable) Target target; // 1 byte - Who can equip this item bool active; // 1 byte - Is minting enabled? bool isRedeemable; // 1 byte - Can be burned for value? RedeemStyle redeemStyle; // 1 byte - Behavior on redemption // Slot 2-8: Large values in separate slots uint256 maxSupply; // Slot 2 - Hard supply cap uint256 minted; // Slot 3 - Current minted amount uint256 burned; // Slot 4 - Total burned amount (for supply tracking) uint256 souvenirItemId; // Slot 5 - If BURN_AND_SOUVENIR, mint this uint256 price; // Slot 6 - Price in PNutz (with 18 decimals) string subCategory; // Slot 7 - Detailed type (e.g., "Sword") string uri; // Slot 8 - Custom URI (overrides base) uint8[] conflictSlots; // Slot 9 - Slots blocked by this item } // ═══════════════════════════════════════════════════════════ // EQUIPMENT SLOT DEFINITIONS // ═══════════════════════════════════════════════════════════ // GEEZ SLOTS (1-20) uint8 public constant SLOT_HEAD = 1; uint8 public constant SLOT_FACE = 2; uint8 public constant SLOT_NECK = 3; uint8 public constant SLOT_TOP = 4; uint8 public constant SLOT_BOTTOM = 5; uint8 public constant SLOT_FEET = 6; uint8 public constant SLOT_HAND_L = 7; uint8 public constant SLOT_HAND_R = 8; uint8 public constant SLOT_BACK = 9; uint8 public constant SLOT_WAIST = 10; uint8 public constant SLOT_ACCESSORY_1 = 11; uint8 public constant SLOT_ACCESSORY_2 = 12; uint8 public constant SLOT_ACCESSORY_3 = 13; // MOUNT SLOTS (21-30) uint8 public constant SLOT_MOUNT_SADDLE = 21; uint8 public constant SLOT_MOUNT_ARMOR = 22; uint8 public constant SLOT_MOUNT_ACCESSORY_1 = 23; uint8 public constant SLOT_MOUNT_ACCESSORY_2 = 24; // WEAPON SLOTS (31-40) uint8 public constant SLOT_WEAPON_MAINHAND = 31; uint8 public constant SLOT_WEAPON_OFFHAND = 32; uint8 public constant SLOT_WEAPON_TWOHAND = 33; // ═══════════════════════════════════════════════════════════ // CUSTOMIZATION CATEGORIES (for slot = 0 items) // ═══════════════════════════════════════════════════════════ /// @notice Customization category IDs /// @dev These are category IDs, not slots (slot = 0 for all customization items) uint8 public constant CATEGORY_EMOTES = 5; // Emotes: gestures, reactions uint8 public constant CATEGORY_MUSIC = 6; // Music: background tracks uint8 public constant CATEGORY_TRAILS = 7; // Trails: visual effects uint8 public constant CATEGORY_STYLES = 8; // Styles: UI themes, borders // ═══════════════════════════════════════════════════════════ // STATE VARIABLES // ═══════════════════════════════════════════════════════════ /// @notice Next item ID to assign uint256 public nextItemId = 1; /// @notice Next category ID to assign uint8 public nextCategoryId = 1; /// @notice Mapping: itemId => ItemConfig mapping(uint256 => ItemConfig) public items; /// @notice Mapping: categoryId => Category mapping(uint8 => Category) public categories; /// @notice Mapping of official marketplace addresses (0% royalty) /// @dev Allows multiple marketplace contracts (frontend, backend, proxy) mapping(address => bool) public officialMarketplaces; /// @notice External marketplace royalty basis points (default: 500 = 5%) uint96 public externalRoyaltyBps; /// @notice Royalty receiver address address public royaltyReceiver; /// @notice PNutz token for payments IERC20 public pnutz; /// @notice Treasury address (receives PNutz payments) address public treasury; /// @notice Operator filtering enabled flag (can disable to allow Blur/LooksRare) /// @dev Set to false to disable filtering and allow all marketplaces bool public operatorFilteringEnabled; // ═══════════════════════════════════════════════════════════ // EVENTS // ═══════════════════════════════════════════════════════════ /// @notice Emitted when a new category is registered event CategoryAdded(uint8 indexed categoryId, string name); /// @notice Emitted when a category is updated event CategoryUpdated(uint8 indexed categoryId, string name, bool active); /// @notice Emitted when a new item is created event ItemCreated( uint256 indexed itemId, uint8 categoryId, string subCategory, uint256 maxSupply, bool isRedeemable ); /// @notice Emitted when item settings are updated event ItemUpdated(uint256 indexed itemId, bool active, string uri); /// @notice Emitted when max supply is increased event SupplyIncreased(uint256 indexed itemId, uint256 newMaxSupply); /// @notice Emitted when max supply is decreased event SupplyDecreased(uint256 indexed itemId, uint256 newMaxSupply); /// @notice Emitted when items are minted event ItemsMinted(address indexed to, uint256 indexed itemId, uint256 amount, uint256 newTotal); /// @notice Emitted when items are redeemed event ItemsRedeemed( address indexed user, uint256 indexed itemId, uint256 amount, uint256 souvenirItemId, uint256 souvenirAmount ); /// @notice Emitted when items are purchased with PNutz event ItemsPurchased( address indexed buyer, uint256 indexed itemId, uint256 amount, uint256 totalPrice ); /// @notice Emitted when items are batch purchased with PNutz event ItemsBatchPurchased( address indexed buyer, uint256[] itemIds, uint256[] amounts, uint256 totalPrice ); /// @notice Emitted when item price is updated event ItemPriceUpdated(uint256 indexed itemId, uint256 newPrice); /// @notice Emitted when treasury address is updated event TreasuryUpdated(address indexed newTreasury); /// @notice Emitted when PNutz token address is updated event PnutzUpdated(address indexed newPnutz); /// @notice Emitted when game controller address is updated event GameControllerUpdated( address indexed oldController, address indexed newController ); /// @notice Emitted when royalty settings change event RoyaltyUpdated(address indexed receiver, uint96 externalBps); /// @notice Emitted when official marketplace status is updated event OfficialMarketplaceUpdated(address indexed marketplace, bool isOfficial); /// @notice Emitted when operator filtering is enabled/disabled event OperatorFilteringUpdated(bool enabled); /// @notice Emitted when item is transferred (for auto-unequip tracking) event ItemTransferred( address indexed from, address indexed to, uint256 indexed itemId, uint256 amount ); // ═══════════════════════════════════════════════════════════ // ERRORS // ═══════════════════════════════════════════════════════════ error InvalidAddress(); error InvalidRoyaltyBps(); error InvalidCategory(); error InvalidSupply(); error ItemDoesNotExist(); error ItemInactive(); error MaxSupplyReached(); error LengthMismatch(); error ItemNotRedeemable(); error CannotDecreaseSupplyBelowMinted(); error InvalidConflictSlot(); error ConflictWithOwnSlot(); error InvalidSlotForTarget(); error InvalidReceiverContract(); // ═══════════════════════════════════════════════════════════ // MODIFIERS // ═══════════════════════════════════════════════════════════ /// @notice Check if item exists modifier itemExists(uint256 itemId) { if (itemId == 0 || itemId >= nextItemId) revert ItemDoesNotExist(); _; } // ═══════════════════════════════════════════════════════════ // CONSTRUCTOR // ═══════════════════════════════════════════════════════════ /** * @notice Initialize the GeezItems1155 contract * @param baseURI_ Base URI for metadata * @param admin_ Address to receive admin role * @param officialMarketplace_ Official marketplace address (0% royalty) * @param royaltyReceiver_ Address to receive royalties * @param externalRoyaltyBps_ External marketplace royalty (e.g., 500 = 5%) * @param pnutz_ PNutz token address for payments * @param treasury_ Treasury address to receive PNutz payments */ constructor( string memory baseURI_, address admin_, address officialMarketplace_, address royaltyReceiver_, uint96 externalRoyaltyBps_, address pnutz_, address treasury_ ) ERC1155(baseURI_) { if (admin_ == address(0)) revert InvalidAddress(); if (royaltyReceiver_ == address(0)) revert InvalidAddress(); if (pnutz_ == address(0)) revert InvalidAddress(); if (treasury_ == address(0)) revert InvalidAddress(); if (externalRoyaltyBps_ > 10000) revert InvalidRoyaltyBps(); _grantRole(DEFAULT_ADMIN_ROLE, admin_); _grantRole(PAUSER_ROLE, admin_); // Set initial official marketplace if (officialMarketplace_ != address(0)) { officialMarketplaces[officialMarketplace_] = true; emit OfficialMarketplaceUpdated(officialMarketplace_, true); } royaltyReceiver = royaltyReceiver_; externalRoyaltyBps = externalRoyaltyBps_; pnutz = IERC20(pnutz_); treasury = treasury_; // Enable operator filtering by default to enforce royalties operatorFilteringEnabled = true; emit RoyaltyUpdated(royaltyReceiver_, externalRoyaltyBps_); emit OperatorFilteringUpdated(true); } // ═══════════════════════════════════════════════════════════ // ADMIN: DYNAMIC CATEGORY SYSTEM // ═══════════════════════════════════════════════════════════ /** * @notice Register a new category * @dev Allows unlimited category expansion without contract upgrade * @param name Display name for the category * @return categoryId The newly created category ID */ function addCategory(string calldata name) external onlyRole(DEFAULT_ADMIN_ROLE) returns (uint8 categoryId) { categoryId = nextCategoryId++; categories[categoryId] = Category({ name: name, active: true, createdAt: block.timestamp }); emit CategoryAdded(categoryId, name); } /** * @notice Update existing category * @param categoryId Category to update * @param name New display name * @param active Whether category is usable */ function updateCategory( uint8 categoryId, string calldata name, bool active ) external onlyRole(DEFAULT_ADMIN_ROLE) { if (categoryId == 0 || categoryId >= nextCategoryId) revert InvalidCategory(); Category storage cat = categories[categoryId]; cat.name = name; cat.active = active; emit CategoryUpdated(categoryId, name, active); } /** * @notice Deactivate category and all its items * @dev Prevents orphaned items when category is disabled * @param categoryId Category to deactivate */ function deactivateCategoryAndItems(uint8 categoryId) external onlyRole(DEFAULT_ADMIN_ROLE) { if (categoryId == 0 || categoryId >= nextCategoryId) revert InvalidCategory(); categories[categoryId].active = false; // Deactivate all items in this category uint256 totalItems = nextItemId; for (uint256 i = 1; i < totalItems;) { if (items[i].categoryId == categoryId) { items[i].active = false; } unchecked { ++i; } } emit CategoryUpdated(categoryId, categories[categoryId].name, false); } // ═══════════════════════════════════════════════════════════ // ADMIN: ITEM MANAGEMENT // ═══════════════════════════════════════════════════════════ /** * @notice Create a new item type * @dev Validates category/target/slot combinations for equipment * @param categoryId Category ID (must be registered) * @param subCategory Detailed type string (e.g., "Fire Sword") * @param slot Equipment slot (0 if not equippable) * @param target Who can equip (NONE/GEEZ/MOUNT/BOTH) * @param conflictSlots Array of slots blocked by this item * @param maxSupply Maximum mintable supply * @param isRedeemable Can be burned for value * @param redeemStyle Behavior on redemption * @param souvenirItemId Token to mint if BURN_AND_SOUVENIR * @param uri_ Custom metadata URI * @param active Is minting enabled * @param price Price in PNutz (with 18 decimals, e.g., 100e18 = 100 PNutz) * @return itemId The newly created item ID */ function createItem( uint8 categoryId, string calldata subCategory, uint8 slot, Target target, uint8[] calldata conflictSlots, uint256 maxSupply, bool isRedeemable, RedeemStyle redeemStyle, uint256 souvenirItemId, string calldata uri_, bool active, uint256 price ) external onlyRole(DEFAULT_ADMIN_ROLE) returns (uint256 itemId) { // Validate inputs first (reduces stack usage) _validateCreateItemInputs(categoryId, maxSupply, slot, target, conflictSlots); // Convert calldata to memory to reduce stack pressure string memory subCategoryMem = subCategory; uint8[] memory conflictSlotsMem = conflictSlots; string memory uriMem = uri_; // Generate item ID itemId = nextItemId++; // Use internal helper with memory parameters _createItemInternal( itemId, categoryId, subCategoryMem, slot, target, conflictSlotsMem, maxSupply, isRedeemable, redeemStyle, souvenirItemId, uriMem, active, price ); emit ItemCreated(itemId, categoryId, subCategoryMem, maxSupply, isRedeemable); } /** * @notice Internal helper to create item with memory parameters * @dev Uses memory instead of calldata to reduce stack depth */ function _createItemInternal( uint256 itemId, uint8 categoryId, string memory subCategory, uint8 slot, Target target, uint8[] memory conflictSlots, uint256 maxSupply, bool isRedeemable, RedeemStyle redeemStyle, uint256 souvenirItemId, string memory uri_, bool active, uint256 price ) internal { ItemConfig storage item = items[itemId]; // Set all fields (optimized struct layout) item.categoryId = categoryId; item.slot = slot; item.target = target; item.active = active; item.isRedeemable = isRedeemable; item.redeemStyle = redeemStyle; item.maxSupply = maxSupply; item.minted = 0; item.burned = 0; // Initialize burned counter item.souvenirItemId = souvenirItemId; item.price = price; item.subCategory = subCategory; item.uri = uri_; item.conflictSlots = conflictSlots; } /** * @notice Internal function to validate createItem inputs * @dev Extracted to reduce stack depth in createItem */ function _validateCreateItemInputs( uint8 categoryId, uint256 maxSupply, uint8 slot, Target target, uint8[] calldata conflictSlots ) internal view { if (categoryId == 0 || categoryId >= nextCategoryId) revert InvalidCategory(); if (!categories[categoryId].active) revert InvalidCategory(); if (maxSupply == 0) revert InvalidSupply(); if (slot > 0) { _validateSlotConfiguration(slot, target); } // Validate conflict slots uint256 conflictsLength = conflictSlots.length; require(conflictsLength <= 10, "Max 10 conflict slots"); for (uint256 i = 0; i < conflictsLength;) { uint8 conflictSlot = conflictSlots[i]; // Cannot conflict with own slot if (conflictSlot == slot) revert ConflictWithOwnSlot(); // Must be valid slot number (1-40) if (conflictSlot == 0 || conflictSlot > 40) revert InvalidConflictSlot(); unchecked { ++i; } } } /** * @notice Internal function to validate slot configuration * @dev Extracted to avoid stack too deep in createItem */ function _validateSlotConfiguration(uint8 slot, Target target) internal pure { if (target == Target.NONE) revert InvalidSlotForTarget(); // Validate slot ranges for Geez if (target == Target.GEEZ || target == Target.BOTH) { if (!((slot >= 1 && slot <= 20) || (slot >= 31 && slot <= 40))) { revert InvalidSlotForTarget(); } } // Validate slot ranges for Mount if (target == Target.MOUNT || target == Target.BOTH) { if (!(slot >= 21 && slot <= 30)) { revert InvalidSlotForTarget(); } } } /** * @notice Increase max supply for existing item * @dev Enables flexible supply management * @param itemId Item to modify * @param additionalSupply Amount to add to max supply */ function increaseMaxSupply(uint256 itemId, uint256 additionalSupply) external onlyRole(DEFAULT_ADMIN_ROLE) itemExists(itemId) { ItemConfig storage item = items[itemId]; item.maxSupply += additionalSupply; emit SupplyIncreased(itemId, item.maxSupply); } /** * @notice Decrease max supply for existing item * @dev Cannot decrease below already minted amount * @param itemId Item to modify * @param newMaxSupply New maximum supply */ function decreaseMaxSupply(uint256 itemId, uint256 newMaxSupply) external onlyRole(DEFAULT_ADMIN_ROLE) itemExists(itemId) { ItemConfig storage item = items[itemId]; if (newMaxSupply < item.minted) revert CannotDecreaseSupplyBelowMinted(); item.maxSupply = newMaxSupply; emit SupplyDecreased(itemId, newMaxSupply); } /** * @notice Update item metadata and active status * @param itemId Item to update * @param active Is minting enabled * @param uri_ New metadata URI */ function updateItem(uint256 itemId, bool active, string calldata uri_) external onlyRole(DEFAULT_ADMIN_ROLE) itemExists(itemId) { ItemConfig storage item = items[itemId]; item.active = active; item.uri = uri_; emit ItemUpdated(itemId, active, uri_); } /** * @notice Batch deactivate multiple items * @dev Gas-efficient way to disable multiple items at once * @param itemIds Array of item IDs to deactivate */ function batchDeactivateItems(uint256[] calldata itemIds) external onlyRole(DEFAULT_ADMIN_ROLE) { uint256 length = itemIds.length; uint256 totalItems = nextItemId; for (uint256 i = 0; i < length;) { uint256 itemId = itemIds[i]; if (itemId > 0 && itemId < totalItems) { items[itemId].active = false; emit ItemUpdated(itemId, false, items[itemId].uri); } unchecked { ++i; } } } /** * @notice Update item redemption settings * @param itemId Item to modify * @param isRedeemable Can be redeemed * @param style Redemption behavior * @param souvenirId Token to mint if BURN_AND_SOUVENIR */ function setItemRedeemable( uint256 itemId, bool isRedeemable, RedeemStyle style, uint256 souvenirId ) external onlyRole(DEFAULT_ADMIN_ROLE) itemExists(itemId) { ItemConfig storage item = items[itemId]; item.isRedeemable = isRedeemable; item.redeemStyle = style; item.souvenirItemId = souvenirId; } /** * @notice Update base URI for all tokens * @param newuri New base URI */ function setBaseURI(string memory newuri) external onlyRole(DEFAULT_ADMIN_ROLE) { _setURI(newuri); } // ═══════════════════════════════════════════════════════════ // MINTING & BURNING (CONTROLLER ONLY) // ═══════════════════════════════════════════════════════════ /** * @notice Mint items to an address * @dev Only callable by MINTER_ROLE (GameController) * @dev Validates receiver if it's a contract * @param to Recipient address * @param itemId Item to mint * @param amount Quantity to mint */ function mint(address to, uint256 itemId, uint256 amount) external onlyRole(MINTER_ROLE) whenNotPaused nonReentrant { // Validate receiver if it's a contract _validateReceiver(to); _mintValidate(itemId, amount); _mint(to, itemId, amount, ""); emit ItemsMinted(to, itemId, amount, items[itemId].minted); } /** * @notice Batch mint multiple items * @dev Only callable by MINTER_ROLE (GameController) * @param to Recipient address * @param itemIds Array of item IDs * @param amounts Array of quantities */ function mintBatch( address to, uint256[] calldata itemIds, uint256[] calldata amounts ) external onlyRole(MINTER_ROLE) whenNotPaused nonReentrant { if (itemIds.length != amounts.length) revert LengthMismatch(); // Validate receiver if it's a contract _validateReceiver(to); uint256 length = itemIds.length; for (uint256 i = 0; i < length;) { _mintValidate(itemIds[i], amounts[i]); unchecked { ++i; } } _mintBatch(to, itemIds, amounts, ""); } /** * @notice Burn items from an address * @dev Only callable by MINTER_ROLE (GameController) * @param from Address to burn from * @param itemId Item to burn * @param amount Quantity to burn */ function burn(address from, uint256 itemId, uint256 amount) external onlyRole(MINTER_ROLE) nonReentrant { _burn(from, itemId, amount); // Track burned amount for supply visibility if (itemId > 0 && itemId < nextItemId) { items[itemId].burned += amount; } } /** * @notice Batch burn multiple items * @dev Only callable by MINTER_ROLE (GameController) * @param from Address to burn from * @param itemIds Array of item IDs * @param amounts Array of quantities */ function burnBatch(address from, uint256[] calldata itemIds, uint256[] calldata amounts) external onlyRole(MINTER_ROLE) nonReentrant { if (itemIds.length != amounts.length) revert LengthMismatch(); _burnBatch(from, itemIds, amounts); // Track burned amounts for supply visibility uint256 length = itemIds.length; uint256 totalItems = nextItemId; for (uint256 i = 0; i < length;) { uint256 itemId = itemIds[i]; if (itemId > 0 && itemId < totalItems) { items[itemId].burned += amounts[i]; } unchecked { ++i; } } } // ═══════════════════════════════════════════════════════════ // PURCHASE SYSTEM (PNUTZ PAYMENT) // ═══════════════════════════════════════════════════════════ /** * @notice Purchase items with PNutz * @dev Users pay PNutz to mint items * @param itemId Item to purchase * @param amount Quantity to purchase */ function purchaseItem(uint256 itemId, uint256 amount) external whenNotPaused nonReentrant { require(amount > 0, "Amount must be greater than 0"); if (itemId == 0 || itemId >= nextItemId) revert ItemDoesNotExist(); ItemConfig storage item = items[itemId]; if (!item.active) revert ItemInactive(); // Check supply uint256 newMinted = item.minted + amount; if (newMinted > item.maxSupply) revert MaxSupplyReached(); // Charge PNutz uint256 totalPrice = item.price * amount; if (totalPrice > 0) { // Transfer PNutz from user to treasury bool success = pnutz.transferFrom(msg.sender, treasury, totalPrice); require(success, "PNutz payment failed"); } // Update state item.minted = newMinted; // Mint items to user _mint(msg.sender, itemId, amount, ""); emit ItemsPurchased(msg.sender, itemId, amount, totalPrice); } /** * @notice Batch purchase multiple items with PNutz * @dev More gas efficient than individual purchases * @param itemIds Array of item IDs to purchase * @param amounts Array of quantities to purchase */ function purchaseItemBatch( uint256[] calldata itemIds, uint256[] calldata amounts ) external whenNotPaused nonReentrant { if (itemIds.length != amounts.length) revert LengthMismatch(); require(itemIds.length > 0, "Empty batch"); uint256 totalCost = 0; // Calculate total cost and validate uint256 length = itemIds.length; for (uint256 i = 0; i < length;) { uint256 itemId = itemIds[i]; uint256 amount = amounts[i]; require(amount > 0, "Amount must be greater than 0"); if (itemId == 0 || itemId >= nextItemId) revert ItemDoesNotExist(); ItemConfig storage item = items[itemId]; if (!item.active) revert ItemInactive(); uint256 newMinted = item.minted + amount; if (newMinted > item.maxSupply) revert MaxSupplyReached(); totalCost += item.price * amount; item.minted = newMinted; unchecked { ++i; } } // Charge total PNutz if (totalCost > 0) { bool success = pnutz.transferFrom(msg.sender, treasury, totalCost); require(success, "PNutz payment failed"); } // Mint all items _mintBatch(msg.sender, itemIds, amounts, ""); emit ItemsBatchPurchased(msg.sender, itemIds, amounts, totalCost); } // ═══════════════════════════════════════════════════════════ // REDEMPTION SYSTEM // ═══════════════════════════════════════════════════════════ /** * @notice Redeem items for rewards * @dev Burns items and optionally mints souvenir tokens * @param user User address to redeem from * @param itemId Item to redeem * @param amount Quantity to redeem * @return souvenirMinted Amount of souvenir tokens minted (0 if BURN_ONLY) */ function redeemItem(address user, uint256 itemId, uint256 amount) external onlyRole(MINTER_ROLE) nonReentrant itemExists(itemId) returns (uint256 souvenirMinted) { ItemConfig storage item = items[itemId]; if (!item.isRedeemable) revert ItemNotRedeemable(); // Burn the item _burn(user, itemId, amount); // Track burned amount item.burned += amount; // If BURN_AND_SOUVENIR, mint souvenir token if (item.redeemStyle == RedeemStyle.BURN_AND_SOUVENIR && item.souvenirItemId > 0) { _mintValidate(item.souvenirItemId, amount); _mint(user, item.souvenirItemId, amount, ""); souvenirMinted = amount; } emit ItemsRedeemed(user, itemId, amount, item.souvenirItemId, souvenirMinted); return souvenirMinted; } /** * @notice Batch redeem multiple items * @param user User address to redeem from * @param itemIds Array of item IDs to redeem * @param amounts Array of quantities to redeem * @return souvenirItemIds Array of souvenir item IDs minted * @return souvenirAmounts Array of souvenir amounts minted */ function redeemItemBatch( address user, uint256[] calldata itemIds, uint256[] calldata amounts ) external onlyRole(MINTER_ROLE) nonReentrant returns (uint256[] memory souvenirItemIds, uint256[] memory souvenirAmounts) { if (itemIds.length != amounts.length) revert LengthMismatch(); // Convert calldata to memory to reduce stack pressure uint256[] memory itemIdsMem = itemIds; uint256[] memory amountsMem = amounts; souvenirItemIds = new uint256[](itemIdsMem.length); uint256 length = itemIdsMem.length; souvenirAmounts = new uint256[](length); uint256 totalItems = nextItemId; for (uint256 i = 0; i < length;) { uint256 itemId = itemIdsMem[i]; if (itemId == 0 || itemId >= totalItems) revert ItemDoesNotExist(); ItemConfig storage item = items[itemIdsMem[i]]; if (!item.isRedeemable) revert ItemNotRedeemable(); // Burn the item _burn(user, itemIdsMem[i], amountsMem[i]); // Track burned amount item.burned += amountsMem[i]; // If BURN_AND_SOUVENIR, mint souvenir token if (item.redeemStyle == RedeemStyle.BURN_AND_SOUVENIR && item.souvenirItemId > 0) { _mintValidate(item.souvenirItemId, amountsMem[i]); _mint(user, item.souvenirItemId, amountsMem[i], ""); souvenirItemIds[i] = item.souvenirItemId; souvenirAmounts[i] = amountsMem[i]; } emit ItemsRedeemed(user, itemIdsMem[i], amountsMem[i], item.souvenirItemId, souvenirAmounts[i]); unchecked { ++i; } } return (souvenirItemIds, souvenirAmounts); } // ═══════════════════════════════════════════════════════════ // INTERNAL HELPERS // ═══════════════════════════════════════════════════════════ /** * @notice Validate minting constraints * @dev Internal helper to check item validity and supply * @dev Updates minted BEFORE external call (CEI pattern) */ function _mintValidate(uint256 itemId, uint256 amount) internal { if (itemId == 0 || itemId >= nextItemId) revert ItemDoesNotExist(); ItemConfig storage item = items[itemId]; if (!item.active) revert ItemInactive(); // Calculate new minted value first (supply accounting safety) uint256 newMinted = item.minted + amount; if (newMinted > item.maxSupply) revert MaxSupplyReached(); // Update state BEFORE external call (CEI pattern) item.minted = newMinted; } /** * @notice Validate receiver contract supports ERC1155 * @dev Prevents tokens being locked in incompatible contracts * @param to Address to validate */ function _validateReceiver(address to) internal view { // Skip validation for EOAs if (to.code.length == 0) return; // For contracts, check if they support ERC1155Receiver interface // This prevents tokens being locked in contracts that can't handle them try IERC165(to).supportsInterface(type(IERC1155Receiver).interfaceId) returns (bool supported) { if (!supported) revert InvalidReceiverContract(); } catch { // If supportsInterface call fails, reject the receiver revert InvalidReceiverContract(); } } /** * @notice Override _update to add pause functionality and auto-unequip on transfer * @dev Pauses all token operations including transfers * @dev Auto-unequips items when transferred to different wallet */ function _update( address from, address to, uint256[] memory ids, uint256[] memory values ) internal virtual override whenNotPaused { super._update(from, to, ids, values); // Auto-unequip on transfer (not on mint/burn) if (from != address(0) && to != address(0) && from != to) { _autoUnequipOnTransfer(from, to, ids, values); } } /** * @notice Automatically unequip items when transferred between wallets * @dev Called internally on every transfer * @dev Emits UnequipOnTransfer event for each affected item * @param from Sender address * @param to Receiver address * @param ids Item IDs being transferred * @param values Amounts being transferred */ /// @notice GameController contract address for auto-unequip (optional) address public gameController; /** * @notice Set GameController address for auto-unequip functionality * @param controller GameController contract address */ function setGameController(address controller) external onlyRole(DEFAULT_ADMIN_ROLE) { address oldController = gameController; gameController = controller; emit GameControllerUpdated(oldController, controller); } function _autoUnequipOnTransfer( address from, address to, uint256[] memory ids, uint256[] memory values ) internal { // Only process if GameController is set if (gameController == address(0)) return; // For each transferred item for (uint256 i = 0; i < ids.length; i++) { uint256 itemId = ids[i]; uint256 amount = values[i]; if (amount == 0) continue; // Try to call handleItemTransfer on the controller // Use low-level call to prevent reverting the transfer if controller doesn't support it (bool success, ) = gameController.call( abi.encodeWithSignature( "handleItemTransfer(address,address,uint256,uint256)", from, to, itemId, amount ) ); // Silently continue if controller doesn't support handleItemTransfer if (!success) continue; emit ItemTransferred(from, to, itemId, amount); } } // ═══════════════════════════════════════════════════════════ // VIEW FUNCTIONS // ═══════════════════════════════════════════════════════════ /** * @notice Get token metadata URI * @dev Returns custom URI if set, otherwise base URI with {id} replaced * @dev OpenSea requires {id} to be replaced with actual token ID */ function uri(uint256 itemId) public view override returns (string memory) { string memory itemUri = items[itemId].uri; if (bytes(itemUri).length > 0) { return itemUri; } // Get base URI from parent (contains {id} placeholder) string memory baseURI = super.uri(itemId); // Replace {id} with actual token ID for OpenSea compatibility // OpenSea expects the contract to do the replacement, not the client bytes memory baseURIBytes = bytes(baseURI); // Find {id} in baseURI and replace it for (uint256 i = 0; i < baseURIBytes.length - 3; i++) { if (baseURIBytes[i] == '{' && baseURIBytes[i + 1] == 'i' && baseURIBytes[i + 2] == 'd' && baseURIBytes[i + 3] == '}') { // Replace {id} with actual token ID return string(abi.encodePacked( _substring(baseURI, 0, i), itemId.toString(), _substring(baseURI, i + 4, baseURIBytes.length) )); } } // If no {id} found, return base URI as-is return baseURI; } /** * @notice Internal helper to extract substring * @dev Helper function for URI replacement */ function _substring(string memory str, uint256 start, uint256 end) internal pure returns (string memory) { bytes memory strBytes = bytes(str); bytes memory result = new bytes(end - start); for (uint256 i = start; i < end; i++) { result[i - start] = strBytes[i]; } return string(result); } /** * @notice Get complete item configuration * @param itemId Item to query * @return Item configuration struct */ function getItem(uint256 itemId) external view returns (ItemConfig memory) { return items[itemId]; } /** * @notice Get item supply information (minted, burned, circulating) * @dev Provides clear visibility into actual supply vs total minted * @param itemId Item to query * @return totalMinted Total amount ever minted * @return totalBurned Total amount ever burned * @return circulating Current circulating supply (minted - burned) */ function getItemSupply(uint256 itemId) external view itemExists(itemId) returns ( uint256 totalMinted, uint256 totalBurned, uint256 circulating ) { ItemConfig memory item = items[itemId]; totalMinted = item.minted; totalBurned = item.burned; circulating = totalMinted > totalBurned ? totalMinted - totalBurned : 0; } /** * @notice Get total supply for a token ID (ERC1155 standard) * @dev OpenSea uses this to display total supply * @param itemId Token ID to query * @return Max supply for this token ID */ function totalSupply(uint256 itemId) external view itemExists(itemId) returns (uint256) { return items[itemId].maxSupply; } /** * @notice Get multiple items in one call (gas efficient) * @param itemIds Array of item IDs to query * @return Array of ItemConfig structs */ function getItemsBatch(uint256[] calldata itemIds) external view returns (ItemConfig[] memory) { uint256 length = itemIds.length; ItemConfig[] memory result = new ItemConfig[](length); for (uint256 i = 0; i < length;) { result[i] = items[itemIds[i]]; unchecked { ++i; } } return result; } /** * @notice Get category information * @param categoryId Category to query * @return Category struct */ function getCategory(uint8 categoryId) external view returns (Category memory) { return categories[categoryId]; } /** * @notice Validate if item can be equipped in slot for target * @dev Used by GameController for equipment validation * @param itemId Item to validate * @param slot Slot to check * @param targetType 1=Geez, 2=Mount * @return true if valid equipment combination */ function isValidForEquip(uint256 itemId, uint8 slot, uint8 targetType) external view returns (bool) { if (itemId == 0 || itemId >= nextItemId) return false; ItemConfig memory item = items[itemId]; if (!item.active) return false; if (item.slot != slot) return false; // targetType: 1=Geez, 2=Mount if (targetType == 1) { return item.target == Target.GEEZ || item.target == Target.BOTH; } else if (targetType == 2) { return item.target == Target.MOUNT || item.target == Target.BOTH; } return false; } /** * @notice Check if slot is valid for Geez */ function isValidGeezSlot(uint8 slot) public pure returns (bool) { return (slot >= 1 && slot <= 20) || (slot >= 31 && slot <= 40); } /** * @notice Check if slot is valid for Mount */ function isValidMountSlot(uint8 slot) public pure returns (bool) { return slot >= 21 && slot <= 30; } // ═══════════════════════════════════════════════════════════ // ERC-2981 DYNAMIC ROYALTIES // ═══════════════════════════════════════════════════════════ /** * @notice Update royalty settings * @param receiver Address to receive royalties * @param externalBps Basis points for external marketplaces (10000 = 100%) */ function setRoyalties(address receiver, uint96 externalBps) external onlyRole(DEFAULT_ADMIN_ROLE) { if (receiver == address(0)) revert InvalidAddress(); if (externalBps > 10000) revert InvalidRoyaltyBps(); royaltyReceiver = receiver; externalRoyaltyBps = externalBps; emit RoyaltyUpdated(receiver, externalBps); } /** * @notice Set official marketplace status (0% royalty) * @dev Allows multiple marketplace addresses (frontend, backend, proxy contracts) * @param marketplace Marketplace address to set * @param isOfficial Whether this address should receive 0% royalty */ function setOfficialMarketplace(address marketplace, bool isOfficial) external onlyRole(DEFAULT_ADMIN_ROLE) { if (marketplace == address(0)) revert InvalidAddress(); officialMarketplaces[marketplace] = isOfficial; emit OfficialMarketplaceUpdated(marketplace, isOfficial); } /** * @notice Calculate royalty info (ERC-2981) * @dev Returns 0% royalty for official marketplace, configured % for others * @dev Uses overflow-safe calculation for extreme sale prices * @dev ENFORCED: Royalties are MANDATORY via operator filtering (not optional) * @param salePrice Sale price in wei * @return receiver Royalty receiver address * @return royaltyAmount Royalty amount in wei */ function royaltyInfo(uint256 /* tokenId */, uint256 salePrice) external view override returns (address receiver, uint256 royaltyAmount) { // If queried by any official marketplace, return 0% royalty if (officialMarketplaces[msg.sender]) { return (royaltyReceiver, 0); } // For external marketplaces, return configured royalty // Use overflow-safe calculation if (salePrice > type(uint256).max / externalRoyaltyBps) { // For extremely high prices, calculate safely royaltyAmount = (salePrice / 10000) * externalRoyaltyBps; } else { // Normal calculation royaltyAmount = (salePrice * externalRoyaltyBps) / 10000; } return (royaltyReceiver, royaltyAmount); } // ═══════════════════════════════════════════════════════════ // ADMIN: PNUTZ PAYMENT MANAGEMENT // ═══════════════════════════════════════════════════════════ /** * @notice Update item price * @param itemId Item to update * @param newPrice New price in PNutz (with 18 decimals) */ function setItemPrice(uint256 itemId, uint256 newPrice) external onlyRole(DEFAULT_ADMIN_ROLE) itemExists(itemId) { items[itemId].price = newPrice; emit ItemPriceUpdated(itemId, newPrice); } /** * @notice Batch update item prices * @param itemIds Array of item IDs to update * @param newPrices Array of new prices (must match itemIds length) */ function batchSetItemPrices( uint256[] calldata itemIds, uint256[] calldata newPrices ) external onlyRole(DEFAULT_ADMIN_ROLE) { if (itemIds.length != newPrices.length) revert LengthMismatch(); uint256 length = itemIds.length; uint256 totalItems = nextItemId; for (uint256 i = 0; i < length;) { uint256 itemId = itemIds[i]; if (itemId > 0 && itemId < totalItems) { items[itemId].price = newPrices[i]; emit ItemPriceUpdated(itemId, newPrices[i]); } unchecked { ++i; } } } /** * @notice Update treasury address * @param newTreasury New treasury address to receive PNutz payments */ function setTreasury(address newTreasury) external onlyRole(DEFAULT_ADMIN_ROLE) { if (newTreasury == address(0)) revert InvalidAddress(); treasury = newTreasury; emit TreasuryUpdated(newTreasury); } /** * @notice Update PNutz token address * @param newPnutz New PNutz token address */ function setPnutz(address newPnutz) external onlyRole(DEFAULT_ADMIN_ROLE) { if (newPnutz == address(0)) revert InvalidAddress(); pnutz = IERC20(newPnutz); emit PnutzUpdated(newPnutz); } // ═══════════════════════════════════════════════════════════ // EMERGENCY FUNCTIONS // ═══════════════════════════════════════════════════════════ /** * @notice Emergency withdrawal of stuck tokens/ETH * @dev Only callable by admin in case of accidents * @param token Token address (address(0) for ETH) * @param to Recipient address * @param amount Amount to withdraw */ function emergencyWithdraw(address token, address to, uint256 amount) external onlyRole(DEFAULT_ADMIN_ROLE) nonReentrant { if (to == address(0)) revert InvalidAddress(); if (token == address(0)) { // Withdraw ETH (bool success, ) = to.call{value: amount}(""); require(success, "ETH transfer failed"); } else { // Withdraw ERC20 (bool success, bytes memory data) = token.call( abi.encodeWithSignature("transfer(address,uint256)", to, amount) ); require(success && (data.length == 0 || abi.decode(data, (bool))), "Token transfer failed"); } } // ═══════════════════════════════════════════════════════════ // PAUSABLE // ═══════════════════════════════════════════════════════════ /** * @notice Pause all token operations (minting, burning, transfers) */ function pause() external onlyRole(PAUSER_ROLE) { _pause(); } /** * @notice Unpause all token operations */ function unpause() external onlyRole(PAUSER_ROLE) { _unpause(); } /** * @notice Enable or disable operator filtering * @dev Allows admin to turn off filtering to allow Blur/LooksRare if needed * @param enabled True to enable filtering (block Blur/LooksRare), false to disable */ function setOperatorFilteringEnabled(bool enabled) external onlyRole(DEFAULT_ADMIN_ROLE) { operatorFilteringEnabled = enabled; emit OperatorFilteringUpdated(enabled); } /** * @notice Override setApprovalForAll to enforce royalties via operator filtering * @dev Blocks non-royalty-paying marketplaces from being approved * @dev Can be disabled via setOperatorFilteringEnabled(false) */ function setApprovalForAll(address operator, bool approved) public override { // Only apply filter if enabled if (operatorFilteringEnabled) { // Use the modifier - this will revert if operator is filtered _checkFilterOperatorApproval(operator); } super.setApprovalForAll(operator, approved); } /** * @notice Internal function to check if operator can be approved * @dev Replicates onlyAllowedOperatorApproval modifier logic */ function _checkFilterOperatorApproval(address operator) internal view { IOperatorFilterRegistry registry = IOperatorFilterRegistry(OPERATOR_FILTER_REGISTRY); if (address(registry).code.length > 0) { if (!registry.isOperatorAllowed(address(this), operator)) { revert OperatorNotAllowed(operator); } } } /** * @notice Internal function to check if operator can execute transfers * @dev Overrides parent to add conditional check */ function _checkFilterOperator(address operator) internal view override { // Only check if filtering is enabled if (operatorFilteringEnabled) { super._checkFilterOperator(operator); } } /** * @notice Override safeTransferFrom to enforce operator filtering * @dev Prevents transfers through non-royalty-paying marketplaces * @dev Can be disabled via setOperatorFilteringEnabled(false) */ function safeTransferFrom( address from, address to, uint256 tokenId, uint256 amount, bytes memory data ) public override { // Only apply filter if enabled AND caller is not the owner if (operatorFilteringEnabled && from != msg.sender) { _checkFilterOperator(msg.sender); } super.safeTransferFrom(from, to, tokenId, amount, data); } /** * @notice Override safeBatchTransferFrom to enforce operator filtering * @dev Prevents batch transfers through non-royalty-paying marketplaces * @dev Can be disabled via setOperatorFilteringEnabled(false) */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public override { // Only apply filter if enabled AND caller is not the owner if (operatorFilteringEnabled && from != msg.sender) { _checkFilterOperator(msg.sender); } super.safeBatchTransferFrom(from, to, ids, amounts, data); } // ═══════════════════════════════════════════════════════════ // INTERFACE SUPPORT // ═══════════════════════════════════════════════════════════ /** * @notice Check interface support */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC1155, AccessControl, IERC165) returns (bool) { return interfaceId == type(IERC2981).interfaceId || super.supportsInterface(interfaceId); } /** * @notice Receive ETH (for emergency situations) */ receive() external payable {} }
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (access/AccessControl.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {IERC165, ERC165} from "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address account => bool) hasRole;
bytes32 adminRole;
}
mapping(bytes32 role => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with an {AccessControlUnauthorizedAccount} error including the required role.
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/// @inheritdoc IERC165
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual returns (bool) {
return _roles[role].hasRole[account];
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
* is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
* is missing `role`.
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert AccessControlUnauthorizedAccount(account, role);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address callerConfirmation) public virtual {
if (callerConfirmation != _msgSender()) {
revert AccessControlBadConfirmation();
}
_revokeRole(role, callerConfirmation);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
if (!hasRole(role, account)) {
_roles[role].hasRole[account] = true;
emit RoleGranted(role, account, _msgSender());
return true;
} else {
return false;
}
}
/**
* @dev Attempts to revoke `role` from `account` and returns a boolean indicating if `role` was revoked.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
if (hasRole(role, account)) {
_roles[role].hasRole[account] = false;
emit RoleRevoked(role, account, _msgSender());
return true;
} else {
return false;
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (access/IAccessControl.sol)
pragma solidity >=0.8.4;
/**
* @dev External interface of AccessControl declared to support ERC-165 detection.
*/
interface IAccessControl {
/**
* @dev The `account` is missing a role.
*/
error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
/**
* @dev The caller of a function is not the expected one.
*
* NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
*/
error AccessControlBadConfirmation();
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted to signal this.
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call. This account bears the admin role (for the granted role).
* Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*/
function renounceRole(bytes32 role, address callerConfirmation) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/draft-IERC6093.sol)
pragma solidity >=0.8.4;
/**
* @dev Standard ERC-20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC20InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
* @param spender Address that may be allowed to operate on tokens without being their owner.
* @param allowance Amount of tokens a `spender` is allowed to operate with.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC20InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `spender` to be approved. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC20InvalidSpender(address spender);
}
/**
* @dev Standard ERC-721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
/**
* @dev Standard ERC-1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.
*/
interface IERC1155Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
* @param tokenId Identifier number of a token.
*/
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC1155InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC1155InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param owner Address of the current owner of a token.
*/
error ERC1155MissingApprovalForAll(address operator, address owner);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC1155InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC1155InvalidOperator(address operator);
/**
* @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
* Used in batch transfers.
* @param idsLength Length of the array of token identifiers
* @param valuesLength Length of the array of token amounts
*/
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC2981.sol)
pragma solidity >=0.6.2;
import {IERC165} from "../utils/introspection/IERC165.sol";
/**
* @dev Interface for the NFT Royalty Standard.
*
* A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal
* support for royalty payments across all NFT marketplaces and ecosystem participants.
*/
interface IERC2981 is IERC165 {
/**
* @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of
* exchange. The royalty amount is denominated and should be paid in that same unit of exchange.
*
* NOTE: ERC-2981 allows setting the royalty to 100% of the price. In that case all the price would be sent to the
* royalty receiver and 0 tokens to the seller. Contracts dealing with royalty should consider empty transfers.
*/
function royaltyInfo(
uint256 tokenId,
uint256 salePrice
) external view returns (address receiver, uint256 royaltyAmount);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC1155/ERC1155.sol)
pragma solidity ^0.8.20;
import {IERC1155} from "./IERC1155.sol";
import {IERC1155MetadataURI} from "./extensions/IERC1155MetadataURI.sol";
import {ERC1155Utils} from "./utils/ERC1155Utils.sol";
import {Context} from "../../utils/Context.sol";
import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol";
import {Arrays} from "../../utils/Arrays.sol";
import {IERC1155Errors} from "../../interfaces/draft-IERC6093.sol";
/**
* @dev Implementation of the basic standard multi-token.
* See https://eips.ethereum.org/EIPS/eip-1155
* Originally based on code by Enjin: https://github.com/enjin/erc-1155
*/
abstract contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI, IERC1155Errors {
using Arrays for uint256[];
using Arrays for address[];
mapping(uint256 id => mapping(address account => uint256)) private _balances;
mapping(address account => mapping(address operator => bool)) private _operatorApprovals;
// Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
string private _uri;
/**
* @dev See {_setURI}.
*/
constructor(string memory uri_) {
_setURI(uri_);
}
/// @inheritdoc IERC165
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC1155).interfaceId ||
interfaceId == type(IERC1155MetadataURI).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC1155MetadataURI-uri}.
*
* This implementation returns the same URI for *all* token types. It relies
* on the token type ID substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the ERC].
*
* Clients calling this function must replace the `\{id\}` substring with the
* actual token type ID.
*/
function uri(uint256 /* id */) public view virtual returns (string memory) {
return _uri;
}
/// @inheritdoc IERC1155
function balanceOf(address account, uint256 id) public view virtual returns (uint256) {
return _balances[id][account];
}
/**
* @dev See {IERC1155-balanceOfBatch}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(
address[] memory accounts,
uint256[] memory ids
) public view virtual returns (uint256[] memory) {
if (accounts.length != ids.length) {
revert ERC1155InvalidArrayLength(ids.length, accounts.length);
}
uint256[] memory batchBalances = new uint256[](accounts.length);
for (uint256 i = 0; i < accounts.length; ++i) {
batchBalances[i] = balanceOf(accounts.unsafeMemoryAccess(i), ids.unsafeMemoryAccess(i));
}
return batchBalances;
}
/// @inheritdoc IERC1155
function setApprovalForAll(address operator, bool approved) public virtual {
_setApprovalForAll(_msgSender(), operator, approved);
}
/// @inheritdoc IERC1155
function isApprovedForAll(address account, address operator) public view virtual returns (bool) {
return _operatorApprovals[account][operator];
}
/// @inheritdoc IERC1155
function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) public virtual {
address sender = _msgSender();
if (from != sender && !isApprovedForAll(from, sender)) {
revert ERC1155MissingApprovalForAll(sender, from);
}
_safeTransferFrom(from, to, id, value, data);
}
/// @inheritdoc IERC1155
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
) public virtual {
address sender = _msgSender();
if (from != sender && !isApprovedForAll(from, sender)) {
revert ERC1155MissingApprovalForAll(sender, from);
}
_safeBatchTransferFrom(from, to, ids, values, data);
}
/**
* @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`. Will mint (or burn) if `from`
* (or `to`) is the zero address.
*
* Emits a {TransferSingle} event if the arrays contain one element, and {TransferBatch} otherwise.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement either {IERC1155Receiver-onERC1155Received}
* or {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value.
* - `ids` and `values` must have the same length.
*
* NOTE: The ERC-1155 acceptance check is not performed in this function. See {_updateWithAcceptanceCheck} instead.
*/
function _update(address from, address to, uint256[] memory ids, uint256[] memory values) internal virtual {
if (ids.length != values.length) {
revert ERC1155InvalidArrayLength(ids.length, values.length);
}
address operator = _msgSender();
for (uint256 i = 0; i < ids.length; ++i) {
uint256 id = ids.unsafeMemoryAccess(i);
uint256 value = values.unsafeMemoryAccess(i);
if (from != address(0)) {
uint256 fromBalance = _balances[id][from];
if (fromBalance < value) {
revert ERC1155InsufficientBalance(from, fromBalance, value, id);
}
unchecked {
// Overflow not possible: value <= fromBalance
_balances[id][from] = fromBalance - value;
}
}
if (to != address(0)) {
_balances[id][to] += value;
}
}
if (ids.length == 1) {
uint256 id = ids.unsafeMemoryAccess(0);
uint256 value = values.unsafeMemoryAccess(0);
emit TransferSingle(operator, from, to, id, value);
} else {
emit TransferBatch(operator, from, to, ids, values);
}
}
/**
* @dev Version of {_update} that performs the token acceptance check by calling
* {IERC1155Receiver-onERC1155Received} or {IERC1155Receiver-onERC1155BatchReceived} on the receiver address if it
* contains code (eg. is a smart contract at the moment of execution).
*
* IMPORTANT: Overriding this function is discouraged because it poses a reentrancy risk from the receiver. So any
* update to the contract state after this function would break the check-effect-interaction pattern. Consider
* overriding {_update} instead.
*/
function _updateWithAcceptanceCheck(
address from,
address to,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
) internal virtual {
_update(from, to, ids, values);
if (to != address(0)) {
address operator = _msgSender();
if (ids.length == 1) {
uint256 id = ids.unsafeMemoryAccess(0);
uint256 value = values.unsafeMemoryAccess(0);
ERC1155Utils.checkOnERC1155Received(operator, from, to, id, value, data);
} else {
ERC1155Utils.checkOnERC1155BatchReceived(operator, from, to, ids, values, data);
}
}
}
/**
* @dev Transfers a `value` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `from` must have a balance of tokens of type `id` of at least `value` amount.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) internal {
if (to == address(0)) {
revert ERC1155InvalidReceiver(address(0));
}
if (from == address(0)) {
revert ERC1155InvalidSender(address(0));
}
(uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value);
_updateWithAcceptanceCheck(from, to, ids, values, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
* - `ids` and `values` must have the same length.
*/
function _safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
) internal {
if (to == address(0)) {
revert ERC1155InvalidReceiver(address(0));
}
if (from == address(0)) {
revert ERC1155InvalidSender(address(0));
}
_updateWithAcceptanceCheck(from, to, ids, values, data);
}
/**
* @dev Sets a new URI for all token types, by relying on the token type ID
* substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the ERC].
*
* By this mechanism, any occurrence of the `\{id\}` substring in either the
* URI or any of the values in the JSON file at said URI will be replaced by
* clients with the token type ID.
*
* For example, the `https://token-cdn-domain/\{id\}.json` URI would be
* interpreted by clients as
* `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
* for token type ID 0x4cce0.
*
* See {uri}.
*
* Because these URIs cannot be meaningfully represented by the {URI} event,
* this function emits no events.
*/
function _setURI(string memory newuri) internal virtual {
_uri = newuri;
}
/**
* @dev Creates a `value` amount of tokens of type `id`, and assigns them to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _mint(address to, uint256 id, uint256 value, bytes memory data) internal {
if (to == address(0)) {
revert ERC1155InvalidReceiver(address(0));
}
(uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value);
_updateWithAcceptanceCheck(address(0), to, ids, values, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `values` must have the same length.
* - `to` cannot be the zero address.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function _mintBatch(address to, uint256[] memory ids, uint256[] memory values, bytes memory data) internal {
if (to == address(0)) {
revert ERC1155InvalidReceiver(address(0));
}
_updateWithAcceptanceCheck(address(0), to, ids, values, data);
}
/**
* @dev Destroys a `value` amount of tokens of type `id` from `from`
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `from` must have at least `value` amount of tokens of type `id`.
*/
function _burn(address from, uint256 id, uint256 value) internal {
if (from == address(0)) {
revert ERC1155InvalidSender(address(0));
}
(uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value);
_updateWithAcceptanceCheck(from, address(0), ids, values, "");
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `from` must have at least `value` amount of tokens of type `id`.
* - `ids` and `values` must have the same length.
*/
function _burnBatch(address from, uint256[] memory ids, uint256[] memory values) internal {
if (from == address(0)) {
revert ERC1155InvalidSender(address(0));
}
_updateWithAcceptanceCheck(from, address(0), ids, values, "");
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the zero address.
*/
function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
if (operator == address(0)) {
revert ERC1155InvalidOperator(address(0));
}
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Creates an array in memory with only one value for each of the elements provided.
*/
function _asSingletonArrays(
uint256 element1,
uint256 element2
) private pure returns (uint256[] memory array1, uint256[] memory array2) {
assembly ("memory-safe") {
// Load the free memory pointer
array1 := mload(0x40)
// Set array length to 1
mstore(array1, 1)
// Store the single element at the next word after the length (where content starts)
mstore(add(array1, 0x20), element1)
// Repeat for next array locating it right after the first array
array2 := add(array1, 0x40)
mstore(array2, 1)
mstore(add(array2, 0x20), element2)
// Update the free memory pointer by pointing after the second array
mstore(0x40, add(array2, 0x40))
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC1155/extensions/IERC1155MetadataURI.sol)
pragma solidity >=0.6.2;
import {IERC1155} from "../IERC1155.sol";
/**
* @dev Interface of the optional ERC1155MetadataExtension interface, as defined
* in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[ERC].
*/
interface IERC1155MetadataURI is IERC1155 {
/**
* @dev Returns the URI for token type `id`.
*
* If the `\{id\}` substring is present in the URI, it must be replaced by
* clients with the actual token type ID.
*/
function uri(uint256 id) external view returns (string memory);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC1155/IERC1155.sol)
pragma solidity >=0.6.2;
import {IERC165} from "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC-1155 compliant contract, as defined in the
* https://eips.ethereum.org/EIPS/eip-1155[ERC].
*/
interface IERC1155 is IERC165 {
/**
* @dev Emitted when `value` amount of tokens of type `id` are transferred from `from` to `to` by `operator`.
*/
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
/**
* @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
* transfers.
*/
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] values
);
/**
* @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
* `approved`.
*/
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
/**
* @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
*
* If an {URI} event was emitted for `id`, the standard
* https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
* returned by {IERC1155MetadataURI-uri}.
*/
event URI(string value, uint256 indexed id);
/**
* @dev Returns the value of tokens of token type `id` owned by `account`.
*/
function balanceOf(address account, uint256 id) external view returns (uint256);
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(
address[] calldata accounts,
uint256[] calldata ids
) external view returns (uint256[] memory);
/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the zero address.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address account, address operator) external view returns (bool);
/**
* @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`.
*
* WARNING: This function can potentially allow a reentrancy attack when transferring tokens
* to an untrusted contract, when invoking {IERC1155Receiver-onERC1155Received} on the receiver.
* Ensure to follow the checks-effects-interactions pattern and consider employing
* reentrancy guards when interacting with untrusted contracts.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
* - `from` must have a balance of tokens of type `id` of at least `value` amount.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external;
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* WARNING: This function can potentially allow a reentrancy attack when transferring tokens
* to an untrusted contract, when invoking {IERC1155Receiver-onERC1155BatchReceived} on the receiver.
* Ensure to follow the checks-effects-interactions pattern and consider employing
* reentrancy guards when interacting with untrusted contracts.
*
* Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments.
*
* Requirements:
*
* - `ids` and `values` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC1155/IERC1155Receiver.sol)
pragma solidity >=0.6.2;
import {IERC165} from "../../utils/introspection/IERC165.sol";
/**
* @dev Interface that must be implemented by smart contracts in order to receive
* ERC-1155 token transfers.
*/
interface IERC1155Receiver is IERC165 {
/**
* @dev Handles the receipt of a single ERC-1155 token type. This function is
* called at the end of a `safeTransferFrom` after the balance has been updated.
*
* NOTE: To accept the transfer, this must return
* `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
* (i.e. 0xf23a6e61, or its own function selector).
*
* @param operator The address which initiated the transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param id The ID of the token being transferred
* @param value The amount of tokens being transferred
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
*/
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
) external returns (bytes4);
/**
* @dev Handles the receipt of a multiple ERC-1155 token types. This function
* is called at the end of a `safeBatchTransferFrom` after the balances have
* been updated.
*
* NOTE: To accept the transfer(s), this must return
* `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
* (i.e. 0xbc197c81, or its own function selector).
*
* @param operator The address which initiated the batch transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param ids An array containing ids of each token being transferred (order and length must match values array)
* @param values An array containing amounts of each token being transferred (order and length must match ids array)
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
*/
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external returns (bytes4);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC1155/utils/ERC1155Utils.sol)
pragma solidity ^0.8.20;
import {IERC1155Receiver} from "../IERC1155Receiver.sol";
import {IERC1155Errors} from "../../../interfaces/draft-IERC6093.sol";
/**
* @dev Library that provide common ERC-1155 utility functions.
*
* See https://eips.ethereum.org/EIPS/eip-1155[ERC-1155].
*
* _Available since v5.1._
*/
library ERC1155Utils {
/**
* @dev Performs an acceptance check for the provided `operator` by calling {IERC1155Receiver-onERC1155Received}
* on the `to` address. The `operator` is generally the address that initiated the token transfer (i.e. `msg.sender`).
*
* The acceptance call is not executed and treated as a no-op if the target address doesn't contain code (i.e. an EOA).
* Otherwise, the recipient must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value to accept
* the transfer.
*/
function checkOnERC1155Received(
address operator,
address from,
address to,
uint256 id,
uint256 value,
bytes memory data
) internal {
if (to.code.length > 0) {
try IERC1155Receiver(to).onERC1155Received(operator, from, id, value, data) returns (bytes4 response) {
if (response != IERC1155Receiver.onERC1155Received.selector) {
// Tokens rejected
revert IERC1155Errors.ERC1155InvalidReceiver(to);
}
} catch (bytes memory reason) {
if (reason.length == 0) {
// non-IERC1155Receiver implementer
revert IERC1155Errors.ERC1155InvalidReceiver(to);
} else {
assembly ("memory-safe") {
revert(add(reason, 0x20), mload(reason))
}
}
}
}
}
/**
* @dev Performs a batch acceptance check for the provided `operator` by calling {IERC1155Receiver-onERC1155BatchReceived}
* on the `to` address. The `operator` is generally the address that initiated the token transfer (i.e. `msg.sender`).
*
* The acceptance call is not executed and treated as a no-op if the target address doesn't contain code (i.e. an EOA).
* Otherwise, the recipient must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value to accept
* the transfer.
*/
function checkOnERC1155BatchReceived(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
) internal {
if (to.code.length > 0) {
try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, values, data) returns (
bytes4 response
) {
if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
// Tokens rejected
revert IERC1155Errors.ERC1155InvalidReceiver(to);
}
} catch (bytes memory reason) {
if (reason.length == 0) {
// non-IERC1155Receiver implementer
revert IERC1155Errors.ERC1155InvalidReceiver(to);
} else {
assembly ("memory-safe") {
revert(add(reason, 0x20), mload(reason))
}
}
}
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/Arrays.sol)
// This file was procedurally generated from scripts/generate/templates/Arrays.js.
pragma solidity ^0.8.20;
import {Comparators} from "./Comparators.sol";
import {SlotDerivation} from "./SlotDerivation.sol";
import {StorageSlot} from "./StorageSlot.sol";
import {Math} from "./math/Math.sol";
/**
* @dev Collection of functions related to array types.
*/
library Arrays {
using SlotDerivation for bytes32;
using StorageSlot for bytes32;
/**
* @dev Sort an array of uint256 (in memory) following the provided comparator function.
*
* This function does the sorting "in place", meaning that it overrides the input. The object is returned for
* convenience, but that returned value can be discarded safely if the caller has a memory pointer to the array.
*
* NOTE: this function's cost is `O(n · log(n))` in average and `O(n²)` in the worst case, with n the length of the
* array. Using it in view functions that are executed through `eth_call` is safe, but one should be very careful
* when executing this as part of a transaction. If the array being sorted is too large, the sort operation may
* consume more gas than is available in a block, leading to potential DoS.
*
* IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way.
*/
function sort(
uint256[] memory array,
function(uint256, uint256) pure returns (bool) comp
) internal pure returns (uint256[] memory) {
_quickSort(_begin(array), _end(array), comp);
return array;
}
/**
* @dev Variant of {sort} that sorts an array of uint256 in increasing order.
*/
function sort(uint256[] memory array) internal pure returns (uint256[] memory) {
sort(array, Comparators.lt);
return array;
}
/**
* @dev Sort an array of address (in memory) following the provided comparator function.
*
* This function does the sorting "in place", meaning that it overrides the input. The object is returned for
* convenience, but that returned value can be discarded safely if the caller has a memory pointer to the array.
*
* NOTE: this function's cost is `O(n · log(n))` in average and `O(n²)` in the worst case, with n the length of the
* array. Using it in view functions that are executed through `eth_call` is safe, but one should be very careful
* when executing this as part of a transaction. If the array being sorted is too large, the sort operation may
* consume more gas than is available in a block, leading to potential DoS.
*
* IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way.
*/
function sort(
address[] memory array,
function(address, address) pure returns (bool) comp
) internal pure returns (address[] memory) {
sort(_castToUint256Array(array), _castToUint256Comp(comp));
return array;
}
/**
* @dev Variant of {sort} that sorts an array of address in increasing order.
*/
function sort(address[] memory array) internal pure returns (address[] memory) {
sort(_castToUint256Array(array), Comparators.lt);
return array;
}
/**
* @dev Sort an array of bytes32 (in memory) following the provided comparator function.
*
* This function does the sorting "in place", meaning that it overrides the input. The object is returned for
* convenience, but that returned value can be discarded safely if the caller has a memory pointer to the array.
*
* NOTE: this function's cost is `O(n · log(n))` in average and `O(n²)` in the worst case, with n the length of the
* array. Using it in view functions that are executed through `eth_call` is safe, but one should be very careful
* when executing this as part of a transaction. If the array being sorted is too large, the sort operation may
* consume more gas than is available in a block, leading to potential DoS.
*
* IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way.
*/
function sort(
bytes32[] memory array,
function(bytes32, bytes32) pure returns (bool) comp
) internal pure returns (bytes32[] memory) {
sort(_castToUint256Array(array), _castToUint256Comp(comp));
return array;
}
/**
* @dev Variant of {sort} that sorts an array of bytes32 in increasing order.
*/
function sort(bytes32[] memory array) internal pure returns (bytes32[] memory) {
sort(_castToUint256Array(array), Comparators.lt);
return array;
}
/**
* @dev Performs a quick sort of a segment of memory. The segment sorted starts at `begin` (inclusive), and stops
* at end (exclusive). Sorting follows the `comp` comparator.
*
* Invariant: `begin <= end`. This is the case when initially called by {sort} and is preserved in subcalls.
*
* IMPORTANT: Memory locations between `begin` and `end` are not validated/zeroed. This function should
* be used only if the limits are within a memory array.
*/
function _quickSort(uint256 begin, uint256 end, function(uint256, uint256) pure returns (bool) comp) private pure {
unchecked {
if (end - begin < 0x40) return;
// Use first element as pivot
uint256 pivot = _mload(begin);
// Position where the pivot should be at the end of the loop
uint256 pos = begin;
for (uint256 it = begin + 0x20; it < end; it += 0x20) {
if (comp(_mload(it), pivot)) {
// If the value stored at the iterator's position comes before the pivot, we increment the
// position of the pivot and move the value there.
pos += 0x20;
_swap(pos, it);
}
}
_swap(begin, pos); // Swap pivot into place
_quickSort(begin, pos, comp); // Sort the left side of the pivot
_quickSort(pos + 0x20, end, comp); // Sort the right side of the pivot
}
}
/**
* @dev Pointer to the memory location of the first element of `array`.
*/
function _begin(uint256[] memory array) private pure returns (uint256 ptr) {
assembly ("memory-safe") {
ptr := add(array, 0x20)
}
}
/**
* @dev Pointer to the memory location of the first memory word (32bytes) after `array`. This is the memory word
* that comes just after the last element of the array.
*/
function _end(uint256[] memory array) private pure returns (uint256 ptr) {
unchecked {
return _begin(array) + array.length * 0x20;
}
}
/**
* @dev Load memory word (as a uint256) at location `ptr`.
*/
function _mload(uint256 ptr) private pure returns (uint256 value) {
assembly {
value := mload(ptr)
}
}
/**
* @dev Swaps the elements memory location `ptr1` and `ptr2`.
*/
function _swap(uint256 ptr1, uint256 ptr2) private pure {
assembly {
let value1 := mload(ptr1)
let value2 := mload(ptr2)
mstore(ptr1, value2)
mstore(ptr2, value1)
}
}
/// @dev Helper: low level cast address memory array to uint256 memory array
function _castToUint256Array(address[] memory input) private pure returns (uint256[] memory output) {
assembly {
output := input
}
}
/// @dev Helper: low level cast bytes32 memory array to uint256 memory array
function _castToUint256Array(bytes32[] memory input) private pure returns (uint256[] memory output) {
assembly {
output := input
}
}
/// @dev Helper: low level cast address comp function to uint256 comp function
function _castToUint256Comp(
function(address, address) pure returns (bool) input
) private pure returns (function(uint256, uint256) pure returns (bool) output) {
assembly {
output := input
}
}
/// @dev Helper: low level cast bytes32 comp function to uint256 comp function
function _castToUint256Comp(
function(bytes32, bytes32) pure returns (bool) input
) private pure returns (function(uint256, uint256) pure returns (bool) output) {
assembly {
output := input
}
}
/**
* @dev Searches a sorted `array` and returns the first index that contains
* a value greater or equal to `element`. If no such index exists (i.e. all
* values in the array are strictly less than `element`), the array length is
* returned. Time complexity O(log n).
*
* NOTE: The `array` is expected to be sorted in ascending order, and to
* contain no repeated elements.
*
* IMPORTANT: Deprecated. This implementation behaves as {lowerBound} but lacks
* support for repeated elements in the array. The {lowerBound} function should
* be used instead.
*/
function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {
uint256 low = 0;
uint256 high = array.length;
if (high == 0) {
return 0;
}
while (low < high) {
uint256 mid = Math.average(low, high);
// Note that mid will always be strictly less than high (i.e. it will be a valid array index)
// because Math.average rounds towards zero (it does integer division with truncation).
if (unsafeAccess(array, mid).value > element) {
high = mid;
} else {
low = mid + 1;
}
}
// At this point `low` is the exclusive upper bound. We will return the inclusive upper bound.
if (low > 0 && unsafeAccess(array, low - 1).value == element) {
return low - 1;
} else {
return low;
}
}
/**
* @dev Searches an `array` sorted in ascending order and returns the first
* index that contains a value greater or equal than `element`. If no such index
* exists (i.e. all values in the array are strictly less than `element`), the array
* length is returned. Time complexity O(log n).
*
* See C++'s https://en.cppreference.com/w/cpp/algorithm/lower_bound[lower_bound].
*/
function lowerBound(uint256[] storage array, uint256 element) internal view returns (uint256) {
uint256 low = 0;
uint256 high = array.length;
if (high == 0) {
return 0;
}
while (low < high) {
uint256 mid = Math.average(low, high);
// Note that mid will always be strictly less than high (i.e. it will be a valid array index)
// because Math.average rounds towards zero (it does integer division with truncation).
if (unsafeAccess(array, mid).value < element) {
// this cannot overflow because mid < high
unchecked {
low = mid + 1;
}
} else {
high = mid;
}
}
return low;
}
/**
* @dev Searches an `array` sorted in ascending order and returns the first
* index that contains a value strictly greater than `element`. If no such index
* exists (i.e. all values in the array are strictly less than `element`), the array
* length is returned. Time complexity O(log n).
*
* See C++'s https://en.cppreference.com/w/cpp/algorithm/upper_bound[upper_bound].
*/
function upperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {
uint256 low = 0;
uint256 high = array.length;
if (high == 0) {
return 0;
}
while (low < high) {
uint256 mid = Math.average(low, high);
// Note that mid will always be strictly less than high (i.e. it will be a valid array index)
// because Math.average rounds towards zero (it does integer division with truncation).
if (unsafeAccess(array, mid).value > element) {
high = mid;
} else {
// this cannot overflow because mid < high
unchecked {
low = mid + 1;
}
}
}
return low;
}
/**
* @dev Same as {lowerBound}, but with an array in memory.
*/
function lowerBoundMemory(uint256[] memory array, uint256 element) internal pure returns (uint256) {
uint256 low = 0;
uint256 high = array.length;
if (high == 0) {
return 0;
}
while (low < high) {
uint256 mid = Math.average(low, high);
// Note that mid will always be strictly less than high (i.e. it will be a valid array index)
// because Math.average rounds towards zero (it does integer division with truncation).
if (unsafeMemoryAccess(array, mid) < element) {
// this cannot overflow because mid < high
unchecked {
low = mid + 1;
}
} else {
high = mid;
}
}
return low;
}
/**
* @dev Same as {upperBound}, but with an array in memory.
*/
function upperBoundMemory(uint256[] memory array, uint256 element) internal pure returns (uint256) {
uint256 low = 0;
uint256 high = array.length;
if (high == 0) {
return 0;
}
while (low < high) {
uint256 mid = Math.average(low, high);
// Note that mid will always be strictly less than high (i.e. it will be a valid array index)
// because Math.average rounds towards zero (it does integer division with truncation).
if (unsafeMemoryAccess(array, mid) > element) {
high = mid;
} else {
// this cannot overflow because mid < high
unchecked {
low = mid + 1;
}
}
}
return low;
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeAccess(address[] storage arr, uint256 pos) internal pure returns (StorageSlot.AddressSlot storage) {
bytes32 slot;
assembly ("memory-safe") {
slot := arr.slot
}
return slot.deriveArray().offset(pos).getAddressSlot();
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeAccess(bytes32[] storage arr, uint256 pos) internal pure returns (StorageSlot.Bytes32Slot storage) {
bytes32 slot;
assembly ("memory-safe") {
slot := arr.slot
}
return slot.deriveArray().offset(pos).getBytes32Slot();
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeAccess(uint256[] storage arr, uint256 pos) internal pure returns (StorageSlot.Uint256Slot storage) {
bytes32 slot;
assembly ("memory-safe") {
slot := arr.slot
}
return slot.deriveArray().offset(pos).getUint256Slot();
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeAccess(bytes[] storage arr, uint256 pos) internal pure returns (StorageSlot.BytesSlot storage) {
bytes32 slot;
assembly ("memory-safe") {
slot := arr.slot
}
return slot.deriveArray().offset(pos).getBytesSlot();
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeAccess(string[] storage arr, uint256 pos) internal pure returns (StorageSlot.StringSlot storage) {
bytes32 slot;
assembly ("memory-safe") {
slot := arr.slot
}
return slot.deriveArray().offset(pos).getStringSlot();
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeMemoryAccess(address[] memory arr, uint256 pos) internal pure returns (address res) {
assembly {
res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
}
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeMemoryAccess(bytes32[] memory arr, uint256 pos) internal pure returns (bytes32 res) {
assembly {
res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
}
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeMemoryAccess(uint256[] memory arr, uint256 pos) internal pure returns (uint256 res) {
assembly {
res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
}
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeMemoryAccess(bytes[] memory arr, uint256 pos) internal pure returns (bytes memory res) {
assembly {
res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
}
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeMemoryAccess(string[] memory arr, uint256 pos) internal pure returns (string memory res) {
assembly {
res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
}
}
/**
* @dev Helper to set the length of a dynamic array. Directly writing to `.length` is forbidden.
*
* WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased.
*/
function unsafeSetLength(address[] storage array, uint256 len) internal {
assembly ("memory-safe") {
sstore(array.slot, len)
}
}
/**
* @dev Helper to set the length of a dynamic array. Directly writing to `.length` is forbidden.
*
* WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased.
*/
function unsafeSetLength(bytes32[] storage array, uint256 len) internal {
assembly ("memory-safe") {
sstore(array.slot, len)
}
}
/**
* @dev Helper to set the length of a dynamic array. Directly writing to `.length` is forbidden.
*
* WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased.
*/
function unsafeSetLength(uint256[] storage array, uint256 len) internal {
assembly ("memory-safe") {
sstore(array.slot, len)
}
}
/**
* @dev Helper to set the length of a dynamic array. Directly writing to `.length` is forbidden.
*
* WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased.
*/
function unsafeSetLength(bytes[] storage array, uint256 len) internal {
assembly ("memory-safe") {
sstore(array.slot, len)
}
}
/**
* @dev Helper to set the length of a dynamic array. Directly writing to `.length` is forbidden.
*
* WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased.
*/
function unsafeSetLength(string[] storage array, uint256 len) internal {
assembly ("memory-safe") {
sstore(array.slot, len)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Comparators.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides a set of functions to compare values.
*
* _Available since v5.1._
*/
library Comparators {
function lt(uint256 a, uint256 b) internal pure returns (bool) {
return a < b;
}
function gt(uint256 a, uint256 b) internal pure returns (bool) {
return a > b;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*/
abstract contract ERC165 is IERC165 {
/// @inheritdoc IERC165
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
import {Panic} from "../Panic.sol";
import {SafeCast} from "./SafeCast.sol";
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Return the 512-bit addition of two uint256.
*
* The result is stored in two 256 variables such that sum = high * 2²⁵⁶ + low.
*/
function add512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
assembly ("memory-safe") {
low := add(a, b)
high := lt(low, a)
}
}
/**
* @dev Return the 512-bit multiplication of two uint256.
*
* The result is stored in two 256 variables such that product = high * 2²⁵⁶ + low.
*/
function mul512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
// 512-bit multiply [high low] = x * y. Compute the product mod 2²⁵⁶ and mod 2²⁵⁶ - 1, then use
// the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = high * 2²⁵⁶ + low.
assembly ("memory-safe") {
let mm := mulmod(a, b, not(0))
low := mul(a, b)
high := sub(sub(mm, low), lt(mm, low))
}
}
/**
* @dev Returns the addition of two unsigned integers, with a success flag (no overflow).
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a + b;
success = c >= a;
result = c * SafeCast.toUint(success);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with a success flag (no overflow).
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a - b;
success = c <= a;
result = c * SafeCast.toUint(success);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with a success flag (no overflow).
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a * b;
assembly ("memory-safe") {
// Only true when the multiplication doesn't overflow
// (c / a == b) || (a == 0)
success := or(eq(div(c, a), b), iszero(a))
}
// equivalent to: success ? c : 0
result = c * SafeCast.toUint(success);
}
}
/**
* @dev Returns the division of two unsigned integers, with a success flag (no division by zero).
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
success = b > 0;
assembly ("memory-safe") {
// The `DIV` opcode returns zero when the denominator is 0.
result := div(a, b)
}
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
success = b > 0;
assembly ("memory-safe") {
// The `MOD` opcode returns zero when the denominator is 0.
result := mod(a, b)
}
}
}
/**
* @dev Unsigned saturating addition, bounds to `2²⁵⁶ - 1` instead of overflowing.
*/
function saturatingAdd(uint256 a, uint256 b) internal pure returns (uint256) {
(bool success, uint256 result) = tryAdd(a, b);
return ternary(success, result, type(uint256).max);
}
/**
* @dev Unsigned saturating subtraction, bounds to zero instead of overflowing.
*/
function saturatingSub(uint256 a, uint256 b) internal pure returns (uint256) {
(, uint256 result) = trySub(a, b);
return result;
}
/**
* @dev Unsigned saturating multiplication, bounds to `2²⁵⁶ - 1` instead of overflowing.
*/
function saturatingMul(uint256 a, uint256 b) internal pure returns (uint256) {
(bool success, uint256 result) = tryMul(a, b);
return ternary(success, result, type(uint256).max);
}
/**
* @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
*
* IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
* However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
* one branch when needed, making this function more expensive.
*/
function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {
unchecked {
// branchless ternary works because:
// b ^ (a ^ b) == a
// b ^ 0 == b
return b ^ ((a ^ b) * SafeCast.toUint(condition));
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a > b, a, b);
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a < b, a, b);
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
Panic.panic(Panic.DIVISION_BY_ZERO);
}
// The following calculation ensures accurate ceiling division without overflow.
// Since a is non-zero, (a - 1) / b will not overflow.
// The largest possible result occurs when (a - 1) / b is type(uint256).max,
// but the largest value we can obtain is type(uint256).max - 1, which happens
// when a = type(uint256).max and b = 1.
unchecked {
return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);
}
}
/**
* @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
*
* Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
* Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
(uint256 high, uint256 low) = mul512(x, y);
// Handle non-overflow cases, 256 by 256 division.
if (high == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return low / denominator;
}
// Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0.
if (denominator <= high) {
Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [high low].
uint256 remainder;
assembly ("memory-safe") {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
high := sub(high, gt(remainder, low))
low := sub(low, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
assembly ("memory-safe") {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [high low] by twos.
low := div(low, twos)
// Flip twos such that it is 2²⁵⁶ / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from high into low.
low |= high * twos;
// Invert denominator mod 2²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such
// that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv ≡ 1 mod 2⁴.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
// works in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2⁸
inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶
inverse *= 2 - denominator * inverse; // inverse mod 2³²
inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴
inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸
inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2²⁵⁶. Since the preconditions guarantee that the outcome is
// less than 2²⁵⁶, this is the final result. We don't need to compute the high bits of the result and high
// is no longer required.
result = low * inverse;
return result;
}
}
/**
* @dev Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);
}
/**
* @dev Calculates floor(x * y >> n) with full precision. Throws if result overflows a uint256.
*/
function mulShr(uint256 x, uint256 y, uint8 n) internal pure returns (uint256 result) {
unchecked {
(uint256 high, uint256 low) = mul512(x, y);
if (high >= 1 << n) {
Panic.panic(Panic.UNDER_OVERFLOW);
}
return (high << (256 - n)) | (low >> n);
}
}
/**
* @dev Calculates x * y >> n with full precision, following the selected rounding direction.
*/
function mulShr(uint256 x, uint256 y, uint8 n, Rounding rounding) internal pure returns (uint256) {
return mulShr(x, y, n) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, 1 << n) > 0);
}
/**
* @dev Calculate the modular multiplicative inverse of a number in Z/nZ.
*
* If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.
* If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.
*
* If the input value is not inversible, 0 is returned.
*
* NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the
* inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.
*/
function invMod(uint256 a, uint256 n) internal pure returns (uint256) {
unchecked {
if (n == 0) return 0;
// The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)
// Used to compute integers x and y such that: ax + ny = gcd(a, n).
// When the gcd is 1, then the inverse of a modulo n exists and it's x.
// ax + ny = 1
// ax = 1 + (-y)n
// ax ≡ 1 (mod n) # x is the inverse of a modulo n
// If the remainder is 0 the gcd is n right away.
uint256 remainder = a % n;
uint256 gcd = n;
// Therefore the initial coefficients are:
// ax + ny = gcd(a, n) = n
// 0a + 1n = n
int256 x = 0;
int256 y = 1;
while (remainder != 0) {
uint256 quotient = gcd / remainder;
(gcd, remainder) = (
// The old remainder is the next gcd to try.
remainder,
// Compute the next remainder.
// Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd
// where gcd is at most n (capped to type(uint256).max)
gcd - remainder * quotient
);
(x, y) = (
// Increment the coefficient of a.
y,
// Decrement the coefficient of n.
// Can overflow, but the result is casted to uint256 so that the
// next value of y is "wrapped around" to a value between 0 and n - 1.
x - y * int256(quotient)
);
}
if (gcd != 1) return 0; // No inverse exists.
return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.
}
}
/**
* @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.
*
* From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is
* prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that
* `a**(p-2)` is the modular multiplicative inverse of a in Fp.
*
* NOTE: this function does NOT check that `p` is a prime greater than `2`.
*/
function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {
unchecked {
return Math.modExp(a, p - 2, p);
}
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)
*
* Requirements:
* - modulus can't be zero
* - underlying staticcall to precompile must succeed
*
* IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make
* sure the chain you're using it on supports the precompiled contract for modular exponentiation
* at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,
* the underlying function will succeed given the lack of a revert, but the result may be incorrectly
* interpreted as 0.
*/
function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {
(bool success, uint256 result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).
* It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying
* to operate modulo 0 or if the underlying precompile reverted.
*
* IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain
* you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in
* https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack
* of a revert, but the result may be incorrectly interpreted as 0.
*/
function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {
if (m == 0) return (false, 0);
assembly ("memory-safe") {
let ptr := mload(0x40)
// | Offset | Content | Content (Hex) |
// |-----------|------------|--------------------------------------------------------------------|
// | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x60:0x7f | value of b | 0x<.............................................................b> |
// | 0x80:0x9f | value of e | 0x<.............................................................e> |
// | 0xa0:0xbf | value of m | 0x<.............................................................m> |
mstore(ptr, 0x20)
mstore(add(ptr, 0x20), 0x20)
mstore(add(ptr, 0x40), 0x20)
mstore(add(ptr, 0x60), b)
mstore(add(ptr, 0x80), e)
mstore(add(ptr, 0xa0), m)
// Given the result < m, it's guaranteed to fit in 32 bytes,
// so we can use the memory scratch space located at offset 0.
success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)
result := mload(0x00)
}
}
/**
* @dev Variant of {modExp} that supports inputs of arbitrary length.
*/
function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {
(bool success, bytes memory result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Variant of {tryModExp} that supports inputs of arbitrary length.
*/
function tryModExp(
bytes memory b,
bytes memory e,
bytes memory m
) internal view returns (bool success, bytes memory result) {
if (_zeroBytes(m)) return (false, new bytes(0));
uint256 mLen = m.length;
// Encode call args in result and move the free memory pointer
result = abi.encodePacked(b.length, e.length, mLen, b, e, m);
assembly ("memory-safe") {
let dataPtr := add(result, 0x20)
// Write result on top of args to avoid allocating extra memory.
success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)
// Overwrite the length.
// result.length > returndatasize() is guaranteed because returndatasize() == m.length
mstore(result, mLen)
// Set the memory pointer after the returned data.
mstore(0x40, add(dataPtr, mLen))
}
}
/**
* @dev Returns whether the provided byte array is zero.
*/
function _zeroBytes(bytes memory byteArray) private pure returns (bool) {
for (uint256 i = 0; i < byteArray.length; ++i) {
if (byteArray[i] != 0) {
return false;
}
}
return true;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* This method is based on Newton's method for computing square roots; the algorithm is restricted to only
* using integer operations.
*/
function sqrt(uint256 a) internal pure returns (uint256) {
unchecked {
// Take care of easy edge cases when a == 0 or a == 1
if (a <= 1) {
return a;
}
// In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a
// sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between
// the current value as `ε_n = | x_n - sqrt(a) |`.
//
// For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root
// of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is
// bigger than any uint256.
//
// By noticing that
// `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`
// we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar
// to the msb function.
uint256 aa = a;
uint256 xn = 1;
if (aa >= (1 << 128)) {
aa >>= 128;
xn <<= 64;
}
if (aa >= (1 << 64)) {
aa >>= 64;
xn <<= 32;
}
if (aa >= (1 << 32)) {
aa >>= 32;
xn <<= 16;
}
if (aa >= (1 << 16)) {
aa >>= 16;
xn <<= 8;
}
if (aa >= (1 << 8)) {
aa >>= 8;
xn <<= 4;
}
if (aa >= (1 << 4)) {
aa >>= 4;
xn <<= 2;
}
if (aa >= (1 << 2)) {
xn <<= 1;
}
// We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).
//
// We can refine our estimation by noticing that the middle of that interval minimizes the error.
// If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).
// This is going to be our x_0 (and ε_0)
xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)
// From here, Newton's method give us:
// x_{n+1} = (x_n + a / x_n) / 2
//
// One should note that:
// x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a
// = ((x_n² + a) / (2 * x_n))² - a
// = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a
// = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)
// = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)
// = (x_n² - a)² / (2 * x_n)²
// = ((x_n² - a) / (2 * x_n))²
// ≥ 0
// Which proves that for all n ≥ 1, sqrt(a) ≤ x_n
//
// This gives us the proof of quadratic convergence of the sequence:
// ε_{n+1} = | x_{n+1} - sqrt(a) |
// = | (x_n + a / x_n) / 2 - sqrt(a) |
// = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |
// = | (x_n - sqrt(a))² / (2 * x_n) |
// = | ε_n² / (2 * x_n) |
// = ε_n² / | (2 * x_n) |
//
// For the first iteration, we have a special case where x_0 is known:
// ε_1 = ε_0² / | (2 * x_0) |
// ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))
// ≤ 2**(2*e-4) / (3 * 2**(e-1))
// ≤ 2**(e-3) / 3
// ≤ 2**(e-3-log2(3))
// ≤ 2**(e-4.5)
//
// For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:
// ε_{n+1} = ε_n² / | (2 * x_n) |
// ≤ (2**(e-k))² / (2 * 2**(e-1))
// ≤ 2**(2*e-2*k) / 2**e
// ≤ 2**(e-2*k)
xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5) -- special case, see above
xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9) -- general case with k = 4.5
xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18) -- general case with k = 9
xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36) -- general case with k = 18
xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72) -- general case with k = 36
xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144) -- general case with k = 72
// Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision
// ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either
// sqrt(a) or sqrt(a) + 1.
return xn - SafeCast.toUint(xn > a / xn);
}
}
/**
* @dev Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 x) internal pure returns (uint256 r) {
// If value has upper 128 bits set, log2 result is at least 128
r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
// If upper 64 bits of 128-bit half set, add 64 to result
r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
// If upper 32 bits of 64-bit half set, add 32 to result
r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
// If upper 16 bits of 32-bit half set, add 16 to result
r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
// If upper 8 bits of 16-bit half set, add 8 to result
r |= SafeCast.toUint((x >> r) > 0xff) << 3;
// If upper 4 bits of 8-bit half set, add 4 to result
r |= SafeCast.toUint((x >> r) > 0xf) << 2;
// Shifts value right by the current result and use it as an index into this lookup table:
//
// | x (4 bits) | index | table[index] = MSB position |
// |------------|---------|-----------------------------|
// | 0000 | 0 | table[0] = 0 |
// | 0001 | 1 | table[1] = 0 |
// | 0010 | 2 | table[2] = 1 |
// | 0011 | 3 | table[3] = 1 |
// | 0100 | 4 | table[4] = 2 |
// | 0101 | 5 | table[5] = 2 |
// | 0110 | 6 | table[6] = 2 |
// | 0111 | 7 | table[7] = 2 |
// | 1000 | 8 | table[8] = 3 |
// | 1001 | 9 | table[9] = 3 |
// | 1010 | 10 | table[10] = 3 |
// | 1011 | 11 | table[11] = 3 |
// | 1100 | 12 | table[12] = 3 |
// | 1101 | 13 | table[13] = 3 |
// | 1110 | 14 | table[14] = 3 |
// | 1111 | 15 | table[15] = 3 |
//
// The lookup table is represented as a 32-byte value with the MSB positions for 0-15 in the last 16 bytes.
assembly ("memory-safe") {
r := or(r, byte(shr(r, x), 0x0000010102020202030303030303030300000000000000000000000000000000))
}
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 x) internal pure returns (uint256 r) {
// If value has upper 128 bits set, log2 result is at least 128
r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
// If upper 64 bits of 128-bit half set, add 64 to result
r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
// If upper 32 bits of 64-bit half set, add 32 to result
r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
// If upper 16 bits of 32-bit half set, add 16 to result
r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
// Add 1 if upper 8 bits of 16-bit half set, and divide accumulated result by 8
return (r >> 3) | SafeCast.toUint((x >> r) > 0xff);
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.20;
/**
* @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeCast {
/**
* @dev Value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);
/**
* @dev An int value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedIntToUint(int256 value);
/**
* @dev Value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);
/**
* @dev An uint value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedUintToInt(uint256 value);
/**
* @dev Returns the downcasted uint248 from uint256, reverting on
* overflow (when the input is greater than largest uint248).
*
* Counterpart to Solidity's `uint248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toUint248(uint256 value) internal pure returns (uint248) {
if (value > type(uint248).max) {
revert SafeCastOverflowedUintDowncast(248, value);
}
return uint248(value);
}
/**
* @dev Returns the downcasted uint240 from uint256, reverting on
* overflow (when the input is greater than largest uint240).
*
* Counterpart to Solidity's `uint240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toUint240(uint256 value) internal pure returns (uint240) {
if (value > type(uint240).max) {
revert SafeCastOverflowedUintDowncast(240, value);
}
return uint240(value);
}
/**
* @dev Returns the downcasted uint232 from uint256, reverting on
* overflow (when the input is greater than largest uint232).
*
* Counterpart to Solidity's `uint232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toUint232(uint256 value) internal pure returns (uint232) {
if (value > type(uint232).max) {
revert SafeCastOverflowedUintDowncast(232, value);
}
return uint232(value);
}
/**
* @dev Returns the downcasted uint224 from uint256, reverting on
* overflow (when the input is greater than largest uint224).
*
* Counterpart to Solidity's `uint224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toUint224(uint256 value) internal pure returns (uint224) {
if (value > type(uint224).max) {
revert SafeCastOverflowedUintDowncast(224, value);
}
return uint224(value);
}
/**
* @dev Returns the downcasted uint216 from uint256, reverting on
* overflow (when the input is greater than largest uint216).
*
* Counterpart to Solidity's `uint216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toUint216(uint256 value) internal pure returns (uint216) {
if (value > type(uint216).max) {
revert SafeCastOverflowedUintDowncast(216, value);
}
return uint216(value);
}
/**
* @dev Returns the downcasted uint208 from uint256, reverting on
* overflow (when the input is greater than largest uint208).
*
* Counterpart to Solidity's `uint208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toUint208(uint256 value) internal pure returns (uint208) {
if (value > type(uint208).max) {
revert SafeCastOverflowedUintDowncast(208, value);
}
return uint208(value);
}
/**
* @dev Returns the downcasted uint200 from uint256, reverting on
* overflow (when the input is greater than largest uint200).
*
* Counterpart to Solidity's `uint200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toUint200(uint256 value) internal pure returns (uint200) {
if (value > type(uint200).max) {
revert SafeCastOverflowedUintDowncast(200, value);
}
return uint200(value);
}
/**
* @dev Returns the downcasted uint192 from uint256, reverting on
* overflow (when the input is greater than largest uint192).
*
* Counterpart to Solidity's `uint192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toUint192(uint256 value) internal pure returns (uint192) {
if (value > type(uint192).max) {
revert SafeCastOverflowedUintDowncast(192, value);
}
return uint192(value);
}
/**
* @dev Returns the downcasted uint184 from uint256, reverting on
* overflow (when the input is greater than largest uint184).
*
* Counterpart to Solidity's `uint184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toUint184(uint256 value) internal pure returns (uint184) {
if (value > type(uint184).max) {
revert SafeCastOverflowedUintDowncast(184, value);
}
return uint184(value);
}
/**
* @dev Returns the downcasted uint176 from uint256, reverting on
* overflow (when the input is greater than largest uint176).
*
* Counterpart to Solidity's `uint176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toUint176(uint256 value) internal pure returns (uint176) {
if (value > type(uint176).max) {
revert SafeCastOverflowedUintDowncast(176, value);
}
return uint176(value);
}
/**
* @dev Returns the downcasted uint168 from uint256, reverting on
* overflow (when the input is greater than largest uint168).
*
* Counterpart to Solidity's `uint168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toUint168(uint256 value) internal pure returns (uint168) {
if (value > type(uint168).max) {
revert SafeCastOverflowedUintDowncast(168, value);
}
return uint168(value);
}
/**
* @dev Returns the downcasted uint160 from uint256, reverting on
* overflow (when the input is greater than largest uint160).
*
* Counterpart to Solidity's `uint160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toUint160(uint256 value) internal pure returns (uint160) {
if (value > type(uint160).max) {
revert SafeCastOverflowedUintDowncast(160, value);
}
return uint160(value);
}
/**
* @dev Returns the downcasted uint152 from uint256, reverting on
* overflow (when the input is greater than largest uint152).
*
* Counterpart to Solidity's `uint152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toUint152(uint256 value) internal pure returns (uint152) {
if (value > type(uint152).max) {
revert SafeCastOverflowedUintDowncast(152, value);
}
return uint152(value);
}
/**
* @dev Returns the downcasted uint144 from uint256, reverting on
* overflow (when the input is greater than largest uint144).
*
* Counterpart to Solidity's `uint144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toUint144(uint256 value) internal pure returns (uint144) {
if (value > type(uint144).max) {
revert SafeCastOverflowedUintDowncast(144, value);
}
return uint144(value);
}
/**
* @dev Returns the downcasted uint136 from uint256, reverting on
* overflow (when the input is greater than largest uint136).
*
* Counterpart to Solidity's `uint136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toUint136(uint256 value) internal pure returns (uint136) {
if (value > type(uint136).max) {
revert SafeCastOverflowedUintDowncast(136, value);
}
return uint136(value);
}
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toUint128(uint256 value) internal pure returns (uint128) {
if (value > type(uint128).max) {
revert SafeCastOverflowedUintDowncast(128, value);
}
return uint128(value);
}
/**
* @dev Returns the downcasted uint120 from uint256, reverting on
* overflow (when the input is greater than largest uint120).
*
* Counterpart to Solidity's `uint120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toUint120(uint256 value) internal pure returns (uint120) {
if (value > type(uint120).max) {
revert SafeCastOverflowedUintDowncast(120, value);
}
return uint120(value);
}
/**
* @dev Returns the downcasted uint112 from uint256, reverting on
* overflow (when the input is greater than largest uint112).
*
* Counterpart to Solidity's `uint112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toUint112(uint256 value) internal pure returns (uint112) {
if (value > type(uint112).max) {
revert SafeCastOverflowedUintDowncast(112, value);
}
return uint112(value);
}
/**
* @dev Returns the downcasted uint104 from uint256, reverting on
* overflow (when the input is greater than largest uint104).
*
* Counterpart to Solidity's `uint104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toUint104(uint256 value) internal pure returns (uint104) {
if (value > type(uint104).max) {
revert SafeCastOverflowedUintDowncast(104, value);
}
return uint104(value);
}
/**
* @dev Returns the downcasted uint96 from uint256, reverting on
* overflow (when the input is greater than largest uint96).
*
* Counterpart to Solidity's `uint96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toUint96(uint256 value) internal pure returns (uint96) {
if (value > type(uint96).max) {
revert SafeCastOverflowedUintDowncast(96, value);
}
return uint96(value);
}
/**
* @dev Returns the downcasted uint88 from uint256, reverting on
* overflow (when the input is greater than largest uint88).
*
* Counterpart to Solidity's `uint88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toUint88(uint256 value) internal pure returns (uint88) {
if (value > type(uint88).max) {
revert SafeCastOverflowedUintDowncast(88, value);
}
return uint88(value);
}
/**
* @dev Returns the downcasted uint80 from uint256, reverting on
* overflow (when the input is greater than largest uint80).
*
* Counterpart to Solidity's `uint80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toUint80(uint256 value) internal pure returns (uint80) {
if (value > type(uint80).max) {
revert SafeCastOverflowedUintDowncast(80, value);
}
return uint80(value);
}
/**
* @dev Returns the downcasted uint72 from uint256, reverting on
* overflow (when the input is greater than largest uint72).
*
* Counterpart to Solidity's `uint72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toUint72(uint256 value) internal pure returns (uint72) {
if (value > type(uint72).max) {
revert SafeCastOverflowedUintDowncast(72, value);
}
return uint72(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toUint64(uint256 value) internal pure returns (uint64) {
if (value > type(uint64).max) {
revert SafeCastOverflowedUintDowncast(64, value);
}
return uint64(value);
}
/**
* @dev Returns the downcasted uint56 from uint256, reverting on
* overflow (when the input is greater than largest uint56).
*
* Counterpart to Solidity's `uint56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toUint56(uint256 value) internal pure returns (uint56) {
if (value > type(uint56).max) {
revert SafeCastOverflowedUintDowncast(56, value);
}
return uint56(value);
}
/**
* @dev Returns the downcasted uint48 from uint256, reverting on
* overflow (when the input is greater than largest uint48).
*
* Counterpart to Solidity's `uint48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toUint48(uint256 value) internal pure returns (uint48) {
if (value > type(uint48).max) {
revert SafeCastOverflowedUintDowncast(48, value);
}
return uint48(value);
}
/**
* @dev Returns the downcasted uint40 from uint256, reverting on
* overflow (when the input is greater than largest uint40).
*
* Counterpart to Solidity's `uint40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toUint40(uint256 value) internal pure returns (uint40) {
if (value > type(uint40).max) {
revert SafeCastOverflowedUintDowncast(40, value);
}
return uint40(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toUint32(uint256 value) internal pure returns (uint32) {
if (value > type(uint32).max) {
revert SafeCastOverflowedUintDowncast(32, value);
}
return uint32(value);
}
/**
* @dev Returns the downcasted uint24 from uint256, reverting on
* overflow (when the input is greater than largest uint24).
*
* Counterpart to Solidity's `uint24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toUint24(uint256 value) internal pure returns (uint24) {
if (value > type(uint24).max) {
revert SafeCastOverflowedUintDowncast(24, value);
}
return uint24(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toUint16(uint256 value) internal pure returns (uint16) {
if (value > type(uint16).max) {
revert SafeCastOverflowedUintDowncast(16, value);
}
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toUint8(uint256 value) internal pure returns (uint8) {
if (value > type(uint8).max) {
revert SafeCastOverflowedUintDowncast(8, value);
}
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*/
function toUint256(int256 value) internal pure returns (uint256) {
if (value < 0) {
revert SafeCastOverflowedIntToUint(value);
}
return uint256(value);
}
/**
* @dev Returns the downcasted int248 from int256, reverting on
* overflow (when the input is less than smallest int248 or
* greater than largest int248).
*
* Counterpart to Solidity's `int248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(248, value);
}
}
/**
* @dev Returns the downcasted int240 from int256, reverting on
* overflow (when the input is less than smallest int240 or
* greater than largest int240).
*
* Counterpart to Solidity's `int240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(240, value);
}
}
/**
* @dev Returns the downcasted int232 from int256, reverting on
* overflow (when the input is less than smallest int232 or
* greater than largest int232).
*
* Counterpart to Solidity's `int232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(232, value);
}
}
/**
* @dev Returns the downcasted int224 from int256, reverting on
* overflow (when the input is less than smallest int224 or
* greater than largest int224).
*
* Counterpart to Solidity's `int224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(224, value);
}
}
/**
* @dev Returns the downcasted int216 from int256, reverting on
* overflow (when the input is less than smallest int216 or
* greater than largest int216).
*
* Counterpart to Solidity's `int216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(216, value);
}
}
/**
* @dev Returns the downcasted int208 from int256, reverting on
* overflow (when the input is less than smallest int208 or
* greater than largest int208).
*
* Counterpart to Solidity's `int208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(208, value);
}
}
/**
* @dev Returns the downcasted int200 from int256, reverting on
* overflow (when the input is less than smallest int200 or
* greater than largest int200).
*
* Counterpart to Solidity's `int200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(200, value);
}
}
/**
* @dev Returns the downcasted int192 from int256, reverting on
* overflow (when the input is less than smallest int192 or
* greater than largest int192).
*
* Counterpart to Solidity's `int192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(192, value);
}
}
/**
* @dev Returns the downcasted int184 from int256, reverting on
* overflow (when the input is less than smallest int184 or
* greater than largest int184).
*
* Counterpart to Solidity's `int184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(184, value);
}
}
/**
* @dev Returns the downcasted int176 from int256, reverting on
* overflow (when the input is less than smallest int176 or
* greater than largest int176).
*
* Counterpart to Solidity's `int176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(176, value);
}
}
/**
* @dev Returns the downcasted int168 from int256, reverting on
* overflow (when the input is less than smallest int168 or
* greater than largest int168).
*
* Counterpart to Solidity's `int168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(168, value);
}
}
/**
* @dev Returns the downcasted int160 from int256, reverting on
* overflow (when the input is less than smallest int160 or
* greater than largest int160).
*
* Counterpart to Solidity's `int160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(160, value);
}
}
/**
* @dev Returns the downcasted int152 from int256, reverting on
* overflow (when the input is less than smallest int152 or
* greater than largest int152).
*
* Counterpart to Solidity's `int152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(152, value);
}
}
/**
* @dev Returns the downcasted int144 from int256, reverting on
* overflow (when the input is less than smallest int144 or
* greater than largest int144).
*
* Counterpart to Solidity's `int144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(144, value);
}
}
/**
* @dev Returns the downcasted int136 from int256, reverting on
* overflow (when the input is less than smallest int136 or
* greater than largest int136).
*
* Counterpart to Solidity's `int136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(136, value);
}
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(128, value);
}
}
/**
* @dev Returns the downcasted int120 from int256, reverting on
* overflow (when the input is less than smallest int120 or
* greater than largest int120).
*
* Counterpart to Solidity's `int120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(120, value);
}
}
/**
* @dev Returns the downcasted int112 from int256, reverting on
* overflow (when the input is less than smallest int112 or
* greater than largest int112).
*
* Counterpart to Solidity's `int112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(112, value);
}
}
/**
* @dev Returns the downcasted int104 from int256, reverting on
* overflow (when the input is less than smallest int104 or
* greater than largest int104).
*
* Counterpart to Solidity's `int104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(104, value);
}
}
/**
* @dev Returns the downcasted int96 from int256, reverting on
* overflow (when the input is less than smallest int96 or
* greater than largest int96).
*
* Counterpart to Solidity's `int96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(96, value);
}
}
/**
* @dev Returns the downcasted int88 from int256, reverting on
* overflow (when the input is less than smallest int88 or
* greater than largest int88).
*
* Counterpart to Solidity's `int88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(88, value);
}
}
/**
* @dev Returns the downcasted int80 from int256, reverting on
* overflow (when the input is less than smallest int80 or
* greater than largest int80).
*
* Counterpart to Solidity's `int80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(80, value);
}
}
/**
* @dev Returns the downcasted int72 from int256, reverting on
* overflow (when the input is less than smallest int72 or
* greater than largest int72).
*
* Counterpart to Solidity's `int72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(72, value);
}
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(64, value);
}
}
/**
* @dev Returns the downcasted int56 from int256, reverting on
* overflow (when the input is less than smallest int56 or
* greater than largest int56).
*
* Counterpart to Solidity's `int56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(56, value);
}
}
/**
* @dev Returns the downcasted int48 from int256, reverting on
* overflow (when the input is less than smallest int48 or
* greater than largest int48).
*
* Counterpart to Solidity's `int48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(48, value);
}
}
/**
* @dev Returns the downcasted int40 from int256, reverting on
* overflow (when the input is less than smallest int40 or
* greater than largest int40).
*
* Counterpart to Solidity's `int40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(40, value);
}
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(32, value);
}
}
/**
* @dev Returns the downcasted int24 from int256, reverting on
* overflow (when the input is less than smallest int24 or
* greater than largest int24).
*
* Counterpart to Solidity's `int24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(24, value);
}
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(16, value);
}
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(8, value);
}
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
if (value > uint256(type(int256).max)) {
revert SafeCastOverflowedUintToInt(value);
}
return int256(value);
}
/**
* @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
*/
function toUint(bool b) internal pure returns (uint256 u) {
assembly ("memory-safe") {
u := iszero(iszero(b))
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.20;
import {SafeCast} from "./SafeCast.sol";
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
*
* IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
* However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
* one branch when needed, making this function more expensive.
*/
function ternary(bool condition, int256 a, int256 b) internal pure returns (int256) {
unchecked {
// branchless ternary works because:
// b ^ (a ^ b) == a
// b ^ 0 == b
return b ^ ((a ^ b) * int256(SafeCast.toUint(condition)));
}
}
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return ternary(a > b, a, b);
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return ternary(a < b, a, b);
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// Formula from the "Bit Twiddling Hacks" by Sean Eron Anderson.
// Since `n` is a signed integer, the generated bytecode will use the SAR opcode to perform the right shift,
// taking advantage of the most significant (or "sign" bit) in two's complement representation.
// This opcode adds new most significant bits set to the value of the previous most significant bit. As a result,
// the mask will either be `bytes32(0)` (if n is positive) or `~bytes32(0)` (if n is negative).
int256 mask = n >> 255;
// A `bytes32(0)` mask leaves the input unchanged, while a `~bytes32(0)` mask complements it.
return uint256((n + mask) ^ mask);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol)
pragma solidity ^0.8.20;
/**
* @dev Helper library for emitting standardized panic codes.
*
* ```solidity
* contract Example {
* using Panic for uint256;
*
* // Use any of the declared internal constants
* function foo() { Panic.GENERIC.panic(); }
*
* // Alternatively
* function foo() { Panic.panic(Panic.GENERIC); }
* }
* ```
*
* Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].
*
* _Available since v5.1._
*/
// slither-disable-next-line unused-state
library Panic {
/// @dev generic / unspecified error
uint256 internal constant GENERIC = 0x00;
/// @dev used by the assert() builtin
uint256 internal constant ASSERT = 0x01;
/// @dev arithmetic underflow or overflow
uint256 internal constant UNDER_OVERFLOW = 0x11;
/// @dev division or modulo by zero
uint256 internal constant DIVISION_BY_ZERO = 0x12;
/// @dev enum conversion error
uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;
/// @dev invalid encoding in storage
uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;
/// @dev empty array pop
uint256 internal constant EMPTY_ARRAY_POP = 0x31;
/// @dev array out of bounds access
uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;
/// @dev resource error (too large allocation or too large array)
uint256 internal constant RESOURCE_ERROR = 0x41;
/// @dev calling invalid internal function
uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;
/// @dev Reverts with a panic code. Recommended to use with
/// the internal constants with predefined codes.
function panic(uint256 code) internal pure {
assembly ("memory-safe") {
mstore(0x00, 0x4e487b71)
mstore(0x20, code)
revert(0x1c, 0x24)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/Pausable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
bool private _paused;
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
/**
* @dev The operation failed because the contract is paused.
*/
error EnforcedPause();
/**
* @dev The operation failed because the contract is not paused.
*/
error ExpectedPause();
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
if (paused()) {
revert EnforcedPause();
}
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
if (!paused()) {
revert ExpectedPause();
}
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
* consider using {ReentrancyGuardTransient} instead.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/SlotDerivation.sol)
// This file was procedurally generated from scripts/generate/templates/SlotDerivation.js.
pragma solidity ^0.8.20;
/**
* @dev Library for computing storage (and transient storage) locations from namespaces and deriving slots
* corresponding to standard patterns. The derivation method for array and mapping matches the storage layout used by
* the solidity language / compiler.
*
* See https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays[Solidity docs for mappings and dynamic arrays.].
*
* Example usage:
* ```solidity
* contract Example {
* // Add the library methods
* using StorageSlot for bytes32;
* using SlotDerivation for bytes32;
*
* // Declare a namespace
* string private constant _NAMESPACE = "<namespace>"; // eg. OpenZeppelin.Slot
*
* function setValueInNamespace(uint256 key, address newValue) internal {
* _NAMESPACE.erc7201Slot().deriveMapping(key).getAddressSlot().value = newValue;
* }
*
* function getValueInNamespace(uint256 key) internal view returns (address) {
* return _NAMESPACE.erc7201Slot().deriveMapping(key).getAddressSlot().value;
* }
* }
* ```
*
* TIP: Consider using this library along with {StorageSlot}.
*
* NOTE: This library provides a way to manipulate storage locations in a non-standard way. Tooling for checking
* upgrade safety will ignore the slots accessed through this library.
*
* _Available since v5.1._
*/
library SlotDerivation {
/**
* @dev Derive an ERC-7201 slot from a string (namespace).
*/
function erc7201Slot(string memory namespace) internal pure returns (bytes32 slot) {
assembly ("memory-safe") {
mstore(0x00, sub(keccak256(add(namespace, 0x20), mload(namespace)), 1))
slot := and(keccak256(0x00, 0x20), not(0xff))
}
}
/**
* @dev Add an offset to a slot to get the n-th element of a structure or an array.
*/
function offset(bytes32 slot, uint256 pos) internal pure returns (bytes32 result) {
unchecked {
return bytes32(uint256(slot) + pos);
}
}
/**
* @dev Derive the location of the first element in an array from the slot where the length is stored.
*/
function deriveArray(bytes32 slot) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
mstore(0x00, slot)
result := keccak256(0x00, 0x20)
}
}
/**
* @dev Derive the location of a mapping element from the key.
*/
function deriveMapping(bytes32 slot, address key) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
mstore(0x00, and(key, shr(96, not(0))))
mstore(0x20, slot)
result := keccak256(0x00, 0x40)
}
}
/**
* @dev Derive the location of a mapping element from the key.
*/
function deriveMapping(bytes32 slot, bool key) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
mstore(0x00, iszero(iszero(key)))
mstore(0x20, slot)
result := keccak256(0x00, 0x40)
}
}
/**
* @dev Derive the location of a mapping element from the key.
*/
function deriveMapping(bytes32 slot, bytes32 key) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
mstore(0x00, key)
mstore(0x20, slot)
result := keccak256(0x00, 0x40)
}
}
/**
* @dev Derive the location of a mapping element from the key.
*/
function deriveMapping(bytes32 slot, uint256 key) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
mstore(0x00, key)
mstore(0x20, slot)
result := keccak256(0x00, 0x40)
}
}
/**
* @dev Derive the location of a mapping element from the key.
*/
function deriveMapping(bytes32 slot, int256 key) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
mstore(0x00, key)
mstore(0x20, slot)
result := keccak256(0x00, 0x40)
}
}
/**
* @dev Derive the location of a mapping element from the key.
*/
function deriveMapping(bytes32 slot, string memory key) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
let length := mload(key)
let begin := add(key, 0x20)
let end := add(begin, length)
let cache := mload(end)
mstore(end, slot)
result := keccak256(begin, add(length, 0x20))
mstore(end, cache)
}
}
/**
* @dev Derive the location of a mapping element from the key.
*/
function deriveMapping(bytes32 slot, bytes memory key) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
let length := mload(key)
let begin := add(key, 0x20)
let end := add(begin, length)
let cache := mload(end)
mstore(end, slot)
result := keccak256(begin, add(length, 0x20))
mstore(end, cache)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.20;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC-1967 implementation slot:
* ```solidity
* contract ERC1967 {
* // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(newImplementation.code.length > 0);
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* TIP: Consider using this library along with {SlotDerivation}.
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct Int256Slot {
int256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Int256Slot` with member `value` located at `slot`.
*/
function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
/**
* @dev Returns a `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/Strings.sol)
pragma solidity ^0.8.20;
import {Math} from "./math/Math.sol";
import {SafeCast} from "./math/SafeCast.sol";
import {SignedMath} from "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
using SafeCast for *;
bytes16 private constant HEX_DIGITS = "0123456789abcdef";
uint8 private constant ADDRESS_LENGTH = 20;
uint256 private constant SPECIAL_CHARS_LOOKUP =
(1 << 0x08) | // backspace
(1 << 0x09) | // tab
(1 << 0x0a) | // newline
(1 << 0x0c) | // form feed
(1 << 0x0d) | // carriage return
(1 << 0x22) | // double quote
(1 << 0x5c); // backslash
/**
* @dev The `value` string doesn't fit in the specified `length`.
*/
error StringsInsufficientHexLength(uint256 value, uint256 length);
/**
* @dev The string being parsed contains characters that are not in scope of the given base.
*/
error StringsInvalidChar();
/**
* @dev The string being parsed is not a properly formatted address.
*/
error StringsInvalidAddressFormat();
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
assembly ("memory-safe") {
ptr := add(add(buffer, 0x20), length)
}
while (true) {
ptr--;
assembly ("memory-safe") {
mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toStringSigned(int256 value) internal pure returns (string memory) {
return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
uint256 localValue = value;
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = HEX_DIGITS[localValue & 0xf];
localValue >>= 4;
}
if (localValue != 0) {
revert StringsInsufficientHexLength(value, length);
}
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal
* representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its checksummed ASCII `string` hexadecimal
* representation, according to EIP-55.
*/
function toChecksumHexString(address addr) internal pure returns (string memory) {
bytes memory buffer = bytes(toHexString(addr));
// hash the hex part of buffer (skip length + 2 bytes, length 40)
uint256 hashValue;
assembly ("memory-safe") {
hashValue := shr(96, keccak256(add(buffer, 0x22), 40))
}
for (uint256 i = 41; i > 1; --i) {
// possible values for buffer[i] are 48 (0) to 57 (9) and 97 (a) to 102 (f)
if (hashValue & 0xf > 7 && uint8(buffer[i]) > 96) {
// case shift by xoring with 0x20
buffer[i] ^= 0x20;
}
hashValue >>= 4;
}
return string(buffer);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
}
/**
* @dev Parse a decimal string and returns the value as a `uint256`.
*
* Requirements:
* - The string must be formatted as `[0-9]*`
* - The result must fit into an `uint256` type
*/
function parseUint(string memory input) internal pure returns (uint256) {
return parseUint(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseUint-string} that parses a substring of `input` located between position `begin` (included) and
* `end` (excluded).
*
* Requirements:
* - The substring must be formatted as `[0-9]*`
* - The result must fit into an `uint256` type
*/
function parseUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) {
(bool success, uint256 value) = tryParseUint(input, begin, end);
if (!success) revert StringsInvalidChar();
return value;
}
/**
* @dev Variant of {parseUint-string} that returns false if the parsing fails because of an invalid character.
*
* NOTE: This function will revert if the result does not fit in a `uint256`.
*/
function tryParseUint(string memory input) internal pure returns (bool success, uint256 value) {
return _tryParseUintUncheckedBounds(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseUint-string-uint256-uint256} that returns false if the parsing fails because of an invalid
* character.
*
* NOTE: This function will revert if the result does not fit in a `uint256`.
*/
function tryParseUint(
string memory input,
uint256 begin,
uint256 end
) internal pure returns (bool success, uint256 value) {
if (end > bytes(input).length || begin > end) return (false, 0);
return _tryParseUintUncheckedBounds(input, begin, end);
}
/**
* @dev Implementation of {tryParseUint-string-uint256-uint256} that does not check bounds. Caller should make sure that
* `begin <= end <= input.length`. Other inputs would result in undefined behavior.
*/
function _tryParseUintUncheckedBounds(
string memory input,
uint256 begin,
uint256 end
) private pure returns (bool success, uint256 value) {
bytes memory buffer = bytes(input);
uint256 result = 0;
for (uint256 i = begin; i < end; ++i) {
uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i)));
if (chr > 9) return (false, 0);
result *= 10;
result += chr;
}
return (true, result);
}
/**
* @dev Parse a decimal string and returns the value as a `int256`.
*
* Requirements:
* - The string must be formatted as `[-+]?[0-9]*`
* - The result must fit in an `int256` type.
*/
function parseInt(string memory input) internal pure returns (int256) {
return parseInt(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseInt-string} that parses a substring of `input` located between position `begin` (included) and
* `end` (excluded).
*
* Requirements:
* - The substring must be formatted as `[-+]?[0-9]*`
* - The result must fit in an `int256` type.
*/
function parseInt(string memory input, uint256 begin, uint256 end) internal pure returns (int256) {
(bool success, int256 value) = tryParseInt(input, begin, end);
if (!success) revert StringsInvalidChar();
return value;
}
/**
* @dev Variant of {parseInt-string} that returns false if the parsing fails because of an invalid character or if
* the result does not fit in a `int256`.
*
* NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`.
*/
function tryParseInt(string memory input) internal pure returns (bool success, int256 value) {
return _tryParseIntUncheckedBounds(input, 0, bytes(input).length);
}
uint256 private constant ABS_MIN_INT256 = 2 ** 255;
/**
* @dev Variant of {parseInt-string-uint256-uint256} that returns false if the parsing fails because of an invalid
* character or if the result does not fit in a `int256`.
*
* NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`.
*/
function tryParseInt(
string memory input,
uint256 begin,
uint256 end
) internal pure returns (bool success, int256 value) {
if (end > bytes(input).length || begin > end) return (false, 0);
return _tryParseIntUncheckedBounds(input, begin, end);
}
/**
* @dev Implementation of {tryParseInt-string-uint256-uint256} that does not check bounds. Caller should make sure that
* `begin <= end <= input.length`. Other inputs would result in undefined behavior.
*/
function _tryParseIntUncheckedBounds(
string memory input,
uint256 begin,
uint256 end
) private pure returns (bool success, int256 value) {
bytes memory buffer = bytes(input);
// Check presence of a negative sign.
bytes1 sign = begin == end ? bytes1(0) : bytes1(_unsafeReadBytesOffset(buffer, begin)); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
bool positiveSign = sign == bytes1("+");
bool negativeSign = sign == bytes1("-");
uint256 offset = (positiveSign || negativeSign).toUint();
(bool absSuccess, uint256 absValue) = tryParseUint(input, begin + offset, end);
if (absSuccess && absValue < ABS_MIN_INT256) {
return (true, negativeSign ? -int256(absValue) : int256(absValue));
} else if (absSuccess && negativeSign && absValue == ABS_MIN_INT256) {
return (true, type(int256).min);
} else return (false, 0);
}
/**
* @dev Parse a hexadecimal string (with or without "0x" prefix), and returns the value as a `uint256`.
*
* Requirements:
* - The string must be formatted as `(0x)?[0-9a-fA-F]*`
* - The result must fit in an `uint256` type.
*/
function parseHexUint(string memory input) internal pure returns (uint256) {
return parseHexUint(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseHexUint-string} that parses a substring of `input` located between position `begin` (included) and
* `end` (excluded).
*
* Requirements:
* - The substring must be formatted as `(0x)?[0-9a-fA-F]*`
* - The result must fit in an `uint256` type.
*/
function parseHexUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) {
(bool success, uint256 value) = tryParseHexUint(input, begin, end);
if (!success) revert StringsInvalidChar();
return value;
}
/**
* @dev Variant of {parseHexUint-string} that returns false if the parsing fails because of an invalid character.
*
* NOTE: This function will revert if the result does not fit in a `uint256`.
*/
function tryParseHexUint(string memory input) internal pure returns (bool success, uint256 value) {
return _tryParseHexUintUncheckedBounds(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseHexUint-string-uint256-uint256} that returns false if the parsing fails because of an
* invalid character.
*
* NOTE: This function will revert if the result does not fit in a `uint256`.
*/
function tryParseHexUint(
string memory input,
uint256 begin,
uint256 end
) internal pure returns (bool success, uint256 value) {
if (end > bytes(input).length || begin > end) return (false, 0);
return _tryParseHexUintUncheckedBounds(input, begin, end);
}
/**
* @dev Implementation of {tryParseHexUint-string-uint256-uint256} that does not check bounds. Caller should make sure that
* `begin <= end <= input.length`. Other inputs would result in undefined behavior.
*/
function _tryParseHexUintUncheckedBounds(
string memory input,
uint256 begin,
uint256 end
) private pure returns (bool success, uint256 value) {
bytes memory buffer = bytes(input);
// skip 0x prefix if present
bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(buffer, begin)) == bytes2("0x"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
uint256 offset = hasPrefix.toUint() * 2;
uint256 result = 0;
for (uint256 i = begin + offset; i < end; ++i) {
uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i)));
if (chr > 15) return (false, 0);
result *= 16;
unchecked {
// Multiplying by 16 is equivalent to a shift of 4 bits (with additional overflow check).
// This guarantees that adding a value < 16 will not cause an overflow, hence the unchecked.
result += chr;
}
}
return (true, result);
}
/**
* @dev Parse a hexadecimal string (with or without "0x" prefix), and returns the value as an `address`.
*
* Requirements:
* - The string must be formatted as `(0x)?[0-9a-fA-F]{40}`
*/
function parseAddress(string memory input) internal pure returns (address) {
return parseAddress(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseAddress-string} that parses a substring of `input` located between position `begin` (included) and
* `end` (excluded).
*
* Requirements:
* - The substring must be formatted as `(0x)?[0-9a-fA-F]{40}`
*/
function parseAddress(string memory input, uint256 begin, uint256 end) internal pure returns (address) {
(bool success, address value) = tryParseAddress(input, begin, end);
if (!success) revert StringsInvalidAddressFormat();
return value;
}
/**
* @dev Variant of {parseAddress-string} that returns false if the parsing fails because the input is not a properly
* formatted address. See {parseAddress-string} requirements.
*/
function tryParseAddress(string memory input) internal pure returns (bool success, address value) {
return tryParseAddress(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseAddress-string-uint256-uint256} that returns false if the parsing fails because input is not a properly
* formatted address. See {parseAddress-string-uint256-uint256} requirements.
*/
function tryParseAddress(
string memory input,
uint256 begin,
uint256 end
) internal pure returns (bool success, address value) {
if (end > bytes(input).length || begin > end) return (false, address(0));
bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(bytes(input), begin)) == bytes2("0x"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
uint256 expectedLength = 40 + hasPrefix.toUint() * 2;
// check that input is the correct length
if (end - begin == expectedLength) {
// length guarantees that this does not overflow, and value is at most type(uint160).max
(bool s, uint256 v) = _tryParseHexUintUncheckedBounds(input, begin, end);
return (s, address(uint160(v)));
} else {
return (false, address(0));
}
}
function _tryParseChr(bytes1 chr) private pure returns (uint8) {
uint8 value = uint8(chr);
// Try to parse `chr`:
// - Case 1: [0-9]
// - Case 2: [a-f]
// - Case 3: [A-F]
// - otherwise not supported
unchecked {
if (value > 47 && value < 58) value -= 48;
else if (value > 96 && value < 103) value -= 87;
else if (value > 64 && value < 71) value -= 55;
else return type(uint8).max;
}
return value;
}
/**
* @dev Escape special characters in JSON strings. This can be useful to prevent JSON injection in NFT metadata.
*
* WARNING: This function should only be used in double quoted JSON strings. Single quotes are not escaped.
*
* NOTE: This function escapes all unicode characters, and not just the ones in ranges defined in section 2.5 of
* RFC-4627 (U+0000 to U+001F, U+0022 and U+005C). ECMAScript's `JSON.parse` does recover escaped unicode
* characters that are not in this range, but other tooling may provide different results.
*/
function escapeJSON(string memory input) internal pure returns (string memory) {
bytes memory buffer = bytes(input);
bytes memory output = new bytes(2 * buffer.length); // worst case scenario
uint256 outputLength = 0;
for (uint256 i; i < buffer.length; ++i) {
bytes1 char = bytes1(_unsafeReadBytesOffset(buffer, i));
if (((SPECIAL_CHARS_LOOKUP & (1 << uint8(char))) != 0)) {
output[outputLength++] = "\\";
if (char == 0x08) output[outputLength++] = "b";
else if (char == 0x09) output[outputLength++] = "t";
else if (char == 0x0a) output[outputLength++] = "n";
else if (char == 0x0c) output[outputLength++] = "f";
else if (char == 0x0d) output[outputLength++] = "r";
else if (char == 0x5c) output[outputLength++] = "\\";
else if (char == 0x22) {
// solhint-disable-next-line quotes
output[outputLength++] = '"';
}
} else {
output[outputLength++] = char;
}
}
// write the actual length and deallocate unused memory
assembly ("memory-safe") {
mstore(output, outputLength)
mstore(0x40, add(output, shl(5, shr(5, add(outputLength, 63)))))
}
return string(output);
}
/**
* @dev Reads a bytes32 from a bytes array without bounds checking.
*
* NOTE: making this function internal would mean it could be used with memory unsafe offset, and marking the
* assembly block as such would prevent some optimizations.
*/
function _unsafeReadBytesOffset(bytes memory buffer, uint256 offset) private pure returns (bytes32 value) {
// This is not memory safe in the general case, but all calls to this private function are within bounds.
assembly ("memory-safe") {
value := mload(add(add(buffer, 0x20), offset))
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import {OperatorFilterer} from "./OperatorFilterer.sol";
import {CANONICAL_CORI_SUBSCRIPTION} from "./lib/Constants.sol";
/**
* @title DefaultOperatorFilterer
* @notice Inherits from OperatorFilterer and automatically subscribes to the default OpenSea subscription.
* @dev Please note that if your token contract does not provide an owner with EIP-173, it must provide
* administration methods on the contract itself to interact with the registry otherwise the subscription
* will be locked to the options set during construction.
*/
abstract contract DefaultOperatorFilterer is OperatorFilterer {
/// @dev The constructor that is called when the contract is being deployed.
constructor() OperatorFilterer(CANONICAL_CORI_SUBSCRIPTION, true) {}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
interface IOperatorFilterRegistry {
/**
* @notice Returns true if operator is not filtered for a given token, either by address or codeHash. Also returns
* true if supplied registrant address is not registered.
*/
function isOperatorAllowed(address registrant, address operator) external view returns (bool);
/**
* @notice Registers an address with the registry. May be called by address itself or by EIP-173 owner.
*/
function register(address registrant) external;
/**
* @notice Registers an address with the registry and "subscribes" to another address's filtered operators and codeHashes.
*/
function registerAndSubscribe(address registrant, address subscription) external;
/**
* @notice Registers an address with the registry and copies the filtered operators and codeHashes from another
* address without subscribing.
*/
function registerAndCopyEntries(address registrant, address registrantToCopy) external;
/**
* @notice Unregisters an address with the registry and removes its subscription. May be called by address itself or by EIP-173 owner.
* Note that this does not remove any filtered addresses or codeHashes.
* Also note that any subscriptions to this registrant will still be active and follow the existing filtered addresses and codehashes.
*/
function unregister(address addr) external;
/**
* @notice Update an operator address for a registered address - when filtered is true, the operator is filtered.
*/
function updateOperator(address registrant, address operator, bool filtered) external;
/**
* @notice Update multiple operators for a registered address - when filtered is true, the operators will be filtered. Reverts on duplicates.
*/
function updateOperators(address registrant, address[] calldata operators, bool filtered) external;
/**
* @notice Update a codeHash for a registered address - when filtered is true, the codeHash is filtered.
*/
function updateCodeHash(address registrant, bytes32 codehash, bool filtered) external;
/**
* @notice Update multiple codeHashes for a registered address - when filtered is true, the codeHashes will be filtered. Reverts on duplicates.
*/
function updateCodeHashes(address registrant, bytes32[] calldata codeHashes, bool filtered) external;
/**
* @notice Subscribe an address to another registrant's filtered operators and codeHashes. Will remove previous
* subscription if present.
* Note that accounts with subscriptions may go on to subscribe to other accounts - in this case,
* subscriptions will not be forwarded. Instead the former subscription's existing entries will still be
* used.
*/
function subscribe(address registrant, address registrantToSubscribe) external;
/**
* @notice Unsubscribe an address from its current subscribed registrant, and optionally copy its filtered operators and codeHashes.
*/
function unsubscribe(address registrant, bool copyExistingEntries) external;
/**
* @notice Get the subscription address of a given registrant, if any.
*/
function subscriptionOf(address addr) external returns (address registrant);
/**
* @notice Get the set of addresses subscribed to a given registrant.
* Note that order is not guaranteed as updates are made.
*/
function subscribers(address registrant) external returns (address[] memory);
/**
* @notice Get the subscriber at a given index in the set of addresses subscribed to a given registrant.
* Note that order is not guaranteed as updates are made.
*/
function subscriberAt(address registrant, uint256 index) external returns (address);
/**
* @notice Copy filtered operators and codeHashes from a different registrantToCopy to addr.
*/
function copyEntriesOf(address registrant, address registrantToCopy) external;
/**
* @notice Returns true if operator is filtered by a given address or its subscription.
*/
function isOperatorFiltered(address registrant, address operator) external returns (bool);
/**
* @notice Returns true if the hash of an address's code is filtered by a given address or its subscription.
*/
function isCodeHashOfFiltered(address registrant, address operatorWithCode) external returns (bool);
/**
* @notice Returns true if a codeHash is filtered by a given address or its subscription.
*/
function isCodeHashFiltered(address registrant, bytes32 codeHash) external returns (bool);
/**
* @notice Returns a list of filtered operators for a given address or its subscription.
*/
function filteredOperators(address addr) external returns (address[] memory);
/**
* @notice Returns the set of filtered codeHashes for a given address or its subscription.
* Note that order is not guaranteed as updates are made.
*/
function filteredCodeHashes(address addr) external returns (bytes32[] memory);
/**
* @notice Returns the filtered operator at the given index of the set of filtered operators for a given address or
* its subscription.
* Note that order is not guaranteed as updates are made.
*/
function filteredOperatorAt(address registrant, uint256 index) external returns (address);
/**
* @notice Returns the filtered codeHash at the given index of the list of filtered codeHashes for a given address or
* its subscription.
* Note that order is not guaranteed as updates are made.
*/
function filteredCodeHashAt(address registrant, uint256 index) external returns (bytes32);
/**
* @notice Returns true if an address has registered
*/
function isRegistered(address addr) external returns (bool);
/**
* @dev Convenience method to compute the code hash of an arbitrary contract
*/
function codeHashOf(address addr) external returns (bytes32);
}// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; address constant CANONICAL_OPERATOR_FILTER_REGISTRY_ADDRESS = 0x000000000000AAeB6D7670E522A718067333cd4E; address constant CANONICAL_CORI_SUBSCRIPTION = 0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6;
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import {IOperatorFilterRegistry} from "./IOperatorFilterRegistry.sol";
import {CANONICAL_OPERATOR_FILTER_REGISTRY_ADDRESS} from "./lib/Constants.sol";
/**
* @title OperatorFilterer
* @notice Abstract contract whose constructor automatically registers and optionally subscribes to or copies another
* registrant's entries in the OperatorFilterRegistry.
* @dev This smart contract is meant to be inherited by token contracts so they can use the following:
* - `onlyAllowedOperator` modifier for `transferFrom` and `safeTransferFrom` methods.
* - `onlyAllowedOperatorApproval` modifier for `approve` and `setApprovalForAll` methods.
* Please note that if your token contract does not provide an owner with EIP-173, it must provide
* administration methods on the contract itself to interact with the registry otherwise the subscription
* will be locked to the options set during construction.
*/
abstract contract OperatorFilterer {
/// @dev Emitted when an operator is not allowed.
error OperatorNotAllowed(address operator);
IOperatorFilterRegistry public constant OPERATOR_FILTER_REGISTRY =
IOperatorFilterRegistry(CANONICAL_OPERATOR_FILTER_REGISTRY_ADDRESS);
/// @dev The constructor that is called when the contract is being deployed.
constructor(address subscriptionOrRegistrantToCopy, bool subscribe) {
// If an inheriting token contract is deployed to a network without the registry deployed, the modifier
// will not revert, but the contract will need to be registered with the registry once it is deployed in
// order for the modifier to filter addresses.
if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {
if (subscribe) {
OPERATOR_FILTER_REGISTRY.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy);
} else {
if (subscriptionOrRegistrantToCopy != address(0)) {
OPERATOR_FILTER_REGISTRY.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy);
} else {
OPERATOR_FILTER_REGISTRY.register(address(this));
}
}
}
}
/**
* @dev A helper function to check if an operator is allowed.
*/
modifier onlyAllowedOperator(address from) virtual {
// Allow spending tokens from addresses with balance
// Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred
// from an EOA.
if (from != msg.sender) {
_checkFilterOperator(msg.sender);
}
_;
}
/**
* @dev A helper function to check if an operator approval is allowed.
*/
modifier onlyAllowedOperatorApproval(address operator) virtual {
_checkFilterOperator(operator);
_;
}
/**
* @dev A helper function to check if an operator is allowed.
*/
function _checkFilterOperator(address operator) internal view virtual {
// Check registry code length to facilitate testing in environments without a deployed registry.
if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {
// under normal circumstances, this function will revert rather than return false, but inheriting contracts
// may specify their own OperatorFilterRegistry implementations, which may behave differently
if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), operator)) {
revert OperatorNotAllowed(operator);
}
}
}
}{
"optimizer": {
"enabled": true,
"runs": 1
},
"viaIR": true,
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"string","name":"baseURI_","type":"string"},{"internalType":"address","name":"admin_","type":"address"},{"internalType":"address","name":"officialMarketplace_","type":"address"},{"internalType":"address","name":"royaltyReceiver_","type":"address"},{"internalType":"uint96","name":"externalRoyaltyBps_","type":"uint96"},{"internalType":"address","name":"pnutz_","type":"address"},{"internalType":"address","name":"treasury_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[],"name":"CannotDecreaseSupplyBelowMinted","type":"error"},{"inputs":[],"name":"ConflictWithOwnSlot","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ERC1155InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC1155InvalidApprover","type":"error"},{"inputs":[{"internalType":"uint256","name":"idsLength","type":"uint256"},{"internalType":"uint256","name":"valuesLength","type":"uint256"}],"name":"ERC1155InvalidArrayLength","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"ERC1155InvalidOperator","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC1155InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC1155InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"ERC1155MissingApprovalForAll","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"InvalidAddress","type":"error"},{"inputs":[],"name":"InvalidCategory","type":"error"},{"inputs":[],"name":"InvalidConflictSlot","type":"error"},{"inputs":[],"name":"InvalidReceiverContract","type":"error"},{"inputs":[],"name":"InvalidRoyaltyBps","type":"error"},{"inputs":[],"name":"InvalidSlotForTarget","type":"error"},{"inputs":[],"name":"InvalidSupply","type":"error"},{"inputs":[],"name":"ItemDoesNotExist","type":"error"},{"inputs":[],"name":"ItemInactive","type":"error"},{"inputs":[],"name":"ItemNotRedeemable","type":"error"},{"inputs":[],"name":"LengthMismatch","type":"error"},{"inputs":[],"name":"MaxSupplyReached","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"OperatorNotAllowed","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","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":"uint8","name":"categoryId","type":"uint8"},{"indexed":false,"internalType":"string","name":"name","type":"string"}],"name":"CategoryAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint8","name":"categoryId","type":"uint8"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"bool","name":"active","type":"bool"}],"name":"CategoryUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldController","type":"address"},{"indexed":true,"internalType":"address","name":"newController","type":"address"}],"name":"GameControllerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"itemId","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"categoryId","type":"uint8"},{"indexed":false,"internalType":"string","name":"subCategory","type":"string"},{"indexed":false,"internalType":"uint256","name":"maxSupply","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isRedeemable","type":"bool"}],"name":"ItemCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"itemId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newPrice","type":"uint256"}],"name":"ItemPriceUpdated","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":"itemId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ItemTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"itemId","type":"uint256"},{"indexed":false,"internalType":"bool","name":"active","type":"bool"},{"indexed":false,"internalType":"string","name":"uri","type":"string"}],"name":"ItemUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"itemIds","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"totalPrice","type":"uint256"}],"name":"ItemsBatchPurchased","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"itemId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTotal","type":"uint256"}],"name":"ItemsMinted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":true,"internalType":"uint256","name":"itemId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalPrice","type":"uint256"}],"name":"ItemsPurchased","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"itemId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"souvenirItemId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"souvenirAmount","type":"uint256"}],"name":"ItemsRedeemed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"marketplace","type":"address"},{"indexed":false,"internalType":"bool","name":"isOfficial","type":"bool"}],"name":"OfficialMarketplaceUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"OperatorFilteringUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newPnutz","type":"address"}],"name":"PnutzUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint96","name":"externalBps","type":"uint96"}],"name":"RoyaltyUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"itemId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newMaxSupply","type":"uint256"}],"name":"SupplyDecreased","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"itemId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newMaxSupply","type":"uint256"}],"name":"SupplyIncreased","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferSingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newTreasury","type":"address"}],"name":"TreasuryUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"value","type":"string"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"URI","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"CATEGORY_EMOTES","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CATEGORY_MUSIC","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CATEGORY_STYLES","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CATEGORY_TRAILS","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINTER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OPERATOR_FILTER_REGISTRY","outputs":[{"internalType":"contract IOperatorFilterRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAUSER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SLOT_ACCESSORY_1","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SLOT_ACCESSORY_2","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SLOT_ACCESSORY_3","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SLOT_BACK","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SLOT_BOTTOM","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SLOT_FACE","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SLOT_FEET","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SLOT_HAND_L","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SLOT_HAND_R","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SLOT_HEAD","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SLOT_MOUNT_ACCESSORY_1","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SLOT_MOUNT_ACCESSORY_2","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SLOT_MOUNT_ARMOR","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SLOT_MOUNT_SADDLE","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SLOT_NECK","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SLOT_TOP","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SLOT_WAIST","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SLOT_WEAPON_MAINHAND","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SLOT_WEAPON_OFFHAND","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SLOT_WEAPON_TWOHAND","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"}],"name":"addCategory","outputs":[{"internalType":"uint8","name":"categoryId","type":"uint8"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"balanceOfBatch","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"itemIds","type":"uint256[]"}],"name":"batchDeactivateItems","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"itemIds","type":"uint256[]"},{"internalType":"uint256[]","name":"newPrices","type":"uint256[]"}],"name":"batchSetItemPrices","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"itemId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256[]","name":"itemIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"burnBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"","type":"uint8"}],"name":"categories","outputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"bool","name":"active","type":"bool"},{"internalType":"uint256","name":"createdAt","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"categoryId","type":"uint8"},{"internalType":"string","name":"subCategory","type":"string"},{"internalType":"uint8","name":"slot","type":"uint8"},{"internalType":"enum GeezItems1155.Target","name":"target","type":"uint8"},{"internalType":"uint8[]","name":"conflictSlots","type":"uint8[]"},{"internalType":"uint256","name":"maxSupply","type":"uint256"},{"internalType":"bool","name":"isRedeemable","type":"bool"},{"internalType":"enum GeezItems1155.RedeemStyle","name":"redeemStyle","type":"uint8"},{"internalType":"uint256","name":"souvenirItemId","type":"uint256"},{"internalType":"string","name":"uri_","type":"string"},{"internalType":"bool","name":"active","type":"bool"},{"internalType":"uint256","name":"price","type":"uint256"}],"name":"createItem","outputs":[{"internalType":"uint256","name":"itemId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"categoryId","type":"uint8"}],"name":"deactivateCategoryAndItems","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"itemId","type":"uint256"},{"internalType":"uint256","name":"newMaxSupply","type":"uint256"}],"name":"decreaseMaxSupply","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"externalRoyaltyBps","outputs":[{"internalType":"uint96","name":"","type":"uint96"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gameController","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"categoryId","type":"uint8"}],"name":"getCategory","outputs":[{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"bool","name":"active","type":"bool"},{"internalType":"uint256","name":"createdAt","type":"uint256"}],"internalType":"struct GeezItems1155.Category","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"itemId","type":"uint256"}],"name":"getItem","outputs":[{"components":[{"internalType":"uint8","name":"categoryId","type":"uint8"},{"internalType":"uint8","name":"slot","type":"uint8"},{"internalType":"enum GeezItems1155.Target","name":"target","type":"uint8"},{"internalType":"bool","name":"active","type":"bool"},{"internalType":"bool","name":"isRedeemable","type":"bool"},{"internalType":"enum GeezItems1155.RedeemStyle","name":"redeemStyle","type":"uint8"},{"internalType":"uint256","name":"maxSupply","type":"uint256"},{"internalType":"uint256","name":"minted","type":"uint256"},{"internalType":"uint256","name":"burned","type":"uint256"},{"internalType":"uint256","name":"souvenirItemId","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"string","name":"subCategory","type":"string"},{"internalType":"string","name":"uri","type":"string"},{"internalType":"uint8[]","name":"conflictSlots","type":"uint8[]"}],"internalType":"struct GeezItems1155.ItemConfig","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"itemId","type":"uint256"}],"name":"getItemSupply","outputs":[{"internalType":"uint256","name":"totalMinted","type":"uint256"},{"internalType":"uint256","name":"totalBurned","type":"uint256"},{"internalType":"uint256","name":"circulating","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"itemIds","type":"uint256[]"}],"name":"getItemsBatch","outputs":[{"components":[{"internalType":"uint8","name":"categoryId","type":"uint8"},{"internalType":"uint8","name":"slot","type":"uint8"},{"internalType":"enum GeezItems1155.Target","name":"target","type":"uint8"},{"internalType":"bool","name":"active","type":"bool"},{"internalType":"bool","name":"isRedeemable","type":"bool"},{"internalType":"enum GeezItems1155.RedeemStyle","name":"redeemStyle","type":"uint8"},{"internalType":"uint256","name":"maxSupply","type":"uint256"},{"internalType":"uint256","name":"minted","type":"uint256"},{"internalType":"uint256","name":"burned","type":"uint256"},{"internalType":"uint256","name":"souvenirItemId","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"string","name":"subCategory","type":"string"},{"internalType":"string","name":"uri","type":"string"},{"internalType":"uint8[]","name":"conflictSlots","type":"uint8[]"}],"internalType":"struct GeezItems1155.ItemConfig[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"itemId","type":"uint256"},{"internalType":"uint256","name":"additionalSupply","type":"uint256"}],"name":"increaseMaxSupply","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"itemId","type":"uint256"},{"internalType":"uint8","name":"slot","type":"uint8"},{"internalType":"uint8","name":"targetType","type":"uint8"}],"name":"isValidForEquip","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"slot","type":"uint8"}],"name":"isValidGeezSlot","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint8","name":"slot","type":"uint8"}],"name":"isValidMountSlot","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"items","outputs":[{"internalType":"uint8","name":"categoryId","type":"uint8"},{"internalType":"uint8","name":"slot","type":"uint8"},{"internalType":"enum GeezItems1155.Target","name":"target","type":"uint8"},{"internalType":"bool","name":"active","type":"bool"},{"internalType":"bool","name":"isRedeemable","type":"bool"},{"internalType":"enum GeezItems1155.RedeemStyle","name":"redeemStyle","type":"uint8"},{"internalType":"uint256","name":"maxSupply","type":"uint256"},{"internalType":"uint256","name":"minted","type":"uint256"},{"internalType":"uint256","name":"burned","type":"uint256"},{"internalType":"uint256","name":"souvenirItemId","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"string","name":"subCategory","type":"string"},{"internalType":"string","name":"uri","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"itemId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"itemIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"mintBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nextCategoryId","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextItemId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"officialMarketplaces","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"operatorFilteringEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pnutz","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"itemId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"purchaseItem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"itemIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"purchaseItemBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"itemId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"redeemItem","outputs":[{"internalType":"uint256","name":"souvenirMinted","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256[]","name":"itemIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"redeemItemBatch","outputs":[{"internalType":"uint256[]","name":"souvenirItemIds","type":"uint256[]"},{"internalType":"uint256[]","name":"souvenirAmounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"royaltyAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"royaltyReceiver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeBatchTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"newuri","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"controller","type":"address"}],"name":"setGameController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"itemId","type":"uint256"},{"internalType":"uint256","name":"newPrice","type":"uint256"}],"name":"setItemPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"itemId","type":"uint256"},{"internalType":"bool","name":"isRedeemable","type":"bool"},{"internalType":"enum GeezItems1155.RedeemStyle","name":"style","type":"uint8"},{"internalType":"uint256","name":"souvenirId","type":"uint256"}],"name":"setItemRedeemable","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"marketplace","type":"address"},{"internalType":"bool","name":"isOfficial","type":"bool"}],"name":"setOfficialMarketplace","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"enabled","type":"bool"}],"name":"setOperatorFilteringEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newPnutz","type":"address"}],"name":"setPnutz","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint96","name":"externalBps","type":"uint96"}],"name":"setRoyalties","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":[{"internalType":"uint256","name":"itemId","type":"uint256"}],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"categoryId","type":"uint8"},{"internalType":"string","name":"name","type":"string"},{"internalType":"bool","name":"active","type":"bool"}],"name":"updateCategory","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"itemId","type":"uint256"},{"internalType":"bool","name":"active","type":"bool"},{"internalType":"string","name":"uri_","type":"string"}],"name":"updateItem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"itemId","type":"uint256"}],"name":"uri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
608080604052346104c957600061650e803803809161001e82866104ce565b8439820160e0838203126104a65782516001600160401b0381116104c557830181601f820112156104c5578051906001600160401b0382116104925760405192610072601f8401601f1916602001856104ce565b828452602083830101116104c157908391825b8281106104aa575050602090830101526100a160208401610507565b906100ae60408501610507565b926100bb60608601610507565b60808601516001600160601b03811695919291908690036104a6576100ee60c06100e760a08a01610507565b9801610507565b845190946001600160401b03821161049257600254600181811c91168015610488575b6020821014610474579081601f849311610406575b50602090601f83116001146103a1578592610396575b50508160011b916000199060031b1c1916176002555b60016004556daaeb6d7670e522a718067333cd4e3b61030c575b600160068190556007805460ff191690911790556001600160a01b038516156102fd576001600160a01b0383169687156102ee576001600160a01b03169384156102ee576001600160a01b03169485156102ee5761271087116102df57928694927f8039bd6e4e7dba001c8840eb2e118d9d131246faa7d0d04335f7305127ec0b1097926102068661020060209a9861051b565b50610597565b506001600160a01b03169081610298575b505060601b6001600160601b03191617600b55600c80546001600160a01b031916919091179055600d80546001600160a81b031916909117600160a01b179055604051908152a27f2494457da7b4d830d1d7068d3a8f70d04121c4e4760cd189f8caaa151813d8e0602060405160018152a1604051615e7e90816106308239f35b808260409252600a895220600160ff198254161790557f8c8e13f02021bf1f396c6c75b2b9f60e00b992612bc1ba1654a38025cd4704778760405160018152a23880610217565b63012b44a960e51b8352600483fd5b63e6c4247b60e01b8352600483fd5b63e6c4247b60e01b8252600482fd5b906daaeb6d7670e522a718067333cd4e3b1561039357604051633e9f1edf60e11b8152306004820152733cc6cdda760b79bafa08df41ecfa224f810dceb660248201528181604481836daaeb6d7670e522a718067333cd4e5af1801561038857610378575b509061016c565b81610382916104ce565b38610371565b6040513d84823e3d90fd5b80fd5b01519050388061013c565b600286528186209250601f198416865b8181106103ee57509084600195949392106103d5575b505050811b01600255610152565b015160001960f88460031b161c191690553880806103c7565b929360206001819287860151815501950193016103b1565b600286529091507f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace601f840160051c8101916020851061046a575b90601f859493920160051c01905b81811061045c5750610126565b86815584935060010161044f565b9091508190610441565b634e487b7160e01b85526022600452602485fd5b90607f1690610111565b634e487b7160e01b84526041600452602484fd5b5080fd5b602082820181015186830182015286945001610085565b8380fd5b8280fd5b600080fd5b601f909101601f19168101906001600160401b038211908210176104f157604052565b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b03821682036104c957565b6001600160a01b03811660009081526000805160206164ee833981519152602052604090205460ff16610591576001600160a01b031660008181526000805160206164ee83398151915260205260408120805460ff191660011790553391906000805160206164ae8339815191528180a4600190565b50600090565b6001600160a01b03811660009081526000805160206164ce833981519152602052604090205460ff16610591576001600160a01b031660008181526000805160206164ce83398151915260205260408120805460ff191660011790553391907f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a906000805160206164ae8339815191529080a460019056fe6080604052600436101561001b575b361561001957600080fd5b005b60003560e01c8062fdd58e146105b657806301ffc9a7146105b15780630e89341c146105ac57806313098dde146105a7578063156e29f6146105a257806315c5ec121461059d5780631ba42149146105985780631ee7a7bc1461059357806322080a891461058e5780632273d3b814610589578063248a9ca3146105845780632a55205a1461057f5780632cf5ab941461057a5780632e0dcbf7146105755780632eb2c2d6146105705780632f2ff15d1461056b5780632f789759146105665780633129e7731461056157806336568abe1461055c57806338b27e75146105575780633be087f3146104495780633f4ba83a14610552578063415ba8091461054d57806341f43434146105485780634229c35e146105435780634e1273f41461053e578063543fd7251461053957806355f804b31461053457806356f67e771461052f5780635b3edfd71461052a5780635c975abb1461052557806361d027b31461052057806362094e9f1461051b57806362c217331461051657806364763f20146105115780636a8689741461050c5780636b20c454146105075780636ce04675146105025780636d73cc95146104fd578063724b7568146104f8578063764b7c71146104f35780637be6277b146104ee57806381dfee06146104e9578063843ee984146104e45780638456cb59146104df578063887b98b9146104da5780638bf314ac146104d55780638e799ae5146104d057806391d14854146104cb5780639301a10b146104c657806396d640b9146104c65780639834ca3b146104c15780639fbc8713146104bc578063a09a4674146104b7578063a217fddf146104b2578063a22cb465146104ad578063a56d6340146104a8578063a5844841146104a3578063a73e9a461461049e578063ac79ee3014610499578063b6f302dc14610494578063b7c0b8e81461048f578063bab4de491461048a578063bc32443814610485578063bd85b03914610480578063bfb231d21461047b578063c047267114610467578063c21b471b14610476578063c369ed7414610471578063c7eda34a1461046c578063c9c5c0c91461046c578063ca55345d14610467578063d0c79b3414610462578063d53913931461045d578063d547741f14610458578063d81d0a1514610453578063db7d40221461044e578063dc9505b314610449578063e067569814610444578063e63ab1e91461043f578063e63ea4081461043a578063e985e9c514610435578063e9d0c0ad14610430578063f0f442601461042b578063f242432a14610426578063f3ba6d8914610421578063f5298aca1461041c578063f6456e4414610417578063f68256a814610412578063fb796e6c1461040d5763ff3d1cbc0361000e57613429565b6133de565b6133b5565b613399565b61332b565b6132b5565b6131a6565b61313d565b613121565b6130dc565b612fdc565b612fb3565b612e5e565b6113f0565b612d0f565b612c4f565b612c1e565b612bf5565b612abd565b612855565b612aa1565b612926565b612871565b6127bc565b6126c0565b61269f565b61261a565b6125ae565b61252b565b612502565b6124e6565b61243a565b612370565b6122b9565b61229d565b612258565b612237565b61221b565b6121ff565b6121be565b6120c6565b6120aa565b612014565b611f89565b611f6d565b611e95565b611df4565b611cee565b611cd2565b611c20565b611c04565b611b15565b611a96565b611a2b565b611a0f565b6119f3565b6119ca565b611996565b611957565b6117cd565b61169d565b611623565b611564565b6114ba565b611491565b611475565b61140c565b6113af565b611344565b611221565b611092565b611050565b610fc4565b610d60565b610c95565b610c3f565b610bfe565b610be2565b610bc6565b610baa565b610b8e565b610af9565b610a49565b6107ef565b610738565b61064d565b610600565b600435906001600160a01b03821682036105d157565b600080fd5b602435906001600160a01b03821682036105d157565b35906001600160a01b03821682036105d157565b346105d15760403660031901126105d157602061063261061e6105bb565b602435600052600083526040600020611940565b54604051908152f35b6001600160e01b03198116036105d157565b346105d15760203660031901126105d15760043561066a8161063b565b63ffffffff60e01b1663152a902d60e11b8114908115610693575b506040519015158152602090f35b637965db0b60e01b8114915081156106ad575b5038610685565b636cdb3d1360e11b8114915081156106df575b81156106ce575b50386106a6565b6301ffc9a760e01b149050386106c7565b6303a24d0760e21b811491506106c0565b60005b8381106107035750506000910152565b81810151838201526020016106f3565b9060209161072c815180928185528580860191016106f0565b601f01601f1916010190565b346105d15760203660031901126105d15761076b6107576004356136cf565b604051918291602083526020830190610713565b0390f35b9181601f840112156105d1578235916001600160401b0383116105d1576020808501948460051b0101116105d157565b60406003198201126105d1576004356001600160401b0381116105d157816107c99160040161076f565b90929091602435906001600160401b0382116105d1576107eb9160040161076f565b9091565b346105d1576107fd3661079f565b91610806614d0d565b61080e614d2a565b828103610a0e57610820811515613822565b600092835b82811061093b57508361088a575b600080516020615d098339815191529361087d9161086f61085536868a610eed565b610860368489610eed565b610868613951565b9133614d4c565b60405194859433988661398a565b0390a26100196001600455565b8360206108ce956108a461089f600c54611086565b611086565b6108af600d54611086565b6000604051809a819582946323b872dd60e01b845233600485016138e0565b03925af1918215610936576108fe61087d93600080516020615d0983398151915297600091610907575b5061390e565b91509350610833565b610929915060203d60201161092f575b6109218183610e92565b8101906138cb565b386108f8565b503d610917565b613902565b9361094785848861385c565b359461095481848761385c565b359561096187151561386c565b80158015610a02575b6109f15761097790612708565b9161098e61098a845460ff9060181c1690565b1590565b6109e05760028301966109a28189546136ab565b91600185015483116109cf576109c16109c792600560019701546138b8565b906136ab565b965501610825565b63d05cb60960e01b60005260046000fd5b632189a1af60e21b60005260046000fd5b639a749d8160e01b60005260046000fd5b5060065481101561096a565b631fec674760e31b60005260046000fd5b60609060031901126105d1576004356001600160a01b03811681036105d157906024359060443590565b346105d1577f9034a31cdc6adf3aa5808e15bcfc4ece48ee9ed42da9427448b7c87c77b5f04b610a7836610a1f565b91610a84939193614d67565b610a8c614d0d565b610a94614d2a565b610a9d81614ee0565b610aa78385614f72565b610ac4604051610ab8602082610e92565b60008152848684614fcb565b83600052600860205260026040600020015490610aef60405192839260018060a01b031695836139b9565b0390a36001600455005b346105d15760403660031901126105d157600435602435610b18614dda565b81158015610b82575b6109f157816000526008602052604060002060028101548210610b7157817f314d0f34164f20ee7ef4433df38ab623d5f45c063a260cd6b5425b67d1a11abc9260016020930155604051908152a2005b6317fb2f2760e21b60005260046000fd5b50600654821015610b21565b346105d15760003660031901126105d1576020604051600c8152f35b346105d15760003660031901126105d157602060405160218152f35b346105d15760003660031901126105d1576020604051600d8152f35b346105d15760003660031901126105d157602060405160178152f35b346105d15760203660031901126105d1576020610c1c6004356139ca565b604051908152f35b6001600160a01b039091168152602081019190915260400190565b346105d15760403660031901126105d157610c5b6024356139de565b9061076b60405192839283610c24565b60206003198201126105d157600435906001600160401b0382116105d1576107eb9160040161076f565b346105d157610ca336610c6b565b610cab614dda565b60065460005b828110610cba57005b80610cc8600192858761385c565b3580151580610d2a575b610cde575b5001610cb1565b806000526008602052604060002063ff000000198154169055600080516020615e29833981519152610d216007610d1484612708565b0160405191829182613a88565b0390a238610cd7565b50838110610cd2565b9181601f840112156105d1578235916001600160401b0383116105d157602083818601950101116105d157565b346105d15760203660031901126105d1576004356001600160401b0381116105d157610d90903690600401610d33565b90610d99614dda565b6007549060ff82169160ff8314610e3b5760ff19166001830160ff161760075561076b9282917ff3ecfcc2269255fcc22a28954eae1b224df081095ec51cb9d4d804eeff86605b9190610e15610ded610eb5565b610df8368585610f72565b815260016020820152426040820152610e1086611d09565b613c11565b610e2460405192839283613d1a565b0390a260405160ff90911681529081906020820190565b613615565b634e487b7160e01b600052604160045260246000fd5b606081019081106001600160401b03821117610e7157604052565b610e40565b6101c081019081106001600160401b03821117610e7157604052565b601f909101601f19168101906001600160401b03821190821017610e7157604052565b60405190610ec4606083610e92565b565b60405190610ec46101c083610e92565b6001600160401b038111610e715760051b60200190565b929190610ef981610ed6565b93610f076040519586610e92565b602085838152019160051b81019283116105d157905b828210610f2957505050565b8135815260209182019101610f1d565b9080601f830112156105d157816020610f5493359101610eed565b90565b6001600160401b038111610e7157601f01601f191660200190565b929192610f7e82610f57565b91610f8c6040519384610e92565b8294818452818301116105d1578281602093846000960137010152565b9080601f830112156105d157816020610f5493359101610f72565b346105d15760a03660031901126105d157610fdd6105bb565b610fe56105d6565b906044356001600160401b0381116105d157611005903690600401610f39565b6064356001600160401b0381116105d157611024903690600401610f39565b608435939091906001600160401b0385116105d15761104a610019953690600401610fa9565b93613d2b565b346105d15760403660031901126105d15761001960043561106f6105d6565b9061108161107c826139ca565b614ea5565b61500a565b6001600160a01b031690565b346105d15760003660031901126105d157600c546040516001600160a01b039091168152602090f35b634e487b7160e01b600052602160045260246000fd5b600411156110db57565b6110bb565b9060048210156110db5752565b600211156110db57565b9060028210156110db5752565b906020808351928381520192019060005b8181106111225750505090565b825160ff16845260209384019390920191600101611115565b805160ff168252610f549160208281015160ff1690820152611165604083015160408301906110e0565b60608281015115159082015260808281015115159082015261118f60a083015160a08301906110f7565b60c082015160c082015260e082015160e08201526101008201516101008201526101208201516101208201526101408201516101408201526101a06111fe6111ea6101608501516101c06101608601526101c0850190610713565b610180850151848203610180860152610713565b920151906101a0818403910152611104565b906020610f5492818152019061113b565b346105d15760203660031901126105d15760043561123d613dbb565b50600052600860205261076b6040600020611332600861125b610ec6565b926112d36112ca82546112786112718260ff1690565b60ff168852565b60ff600882901c166020880152611299601082901c60ff1660408901613e2c565b6112ad601882901c60ff1615156060890152565b6112c1602082901c60ff1615156080890152565b60281c60ff1690565b60a08601613e38565b600181015460c0850152600281015460e085015260038101546101008501526004810154610120850152600581015461014085015261131460068201611dd9565b61016085015261132660078201611dd9565b61018085015201613e44565b6101a082015260405191829182611210565b346105d15760403660031901126105d1576004356113606105d6565b336001600160a01b038216036113795761001991615081565b63334bd91960e11b60005260046000fd5b60ff8116036105d157565b60043590610ec48261138a565b60443590610ec48261138a565b346105d15760603660031901126105d15760206113e66004356024356113d48161138a565b604435916113e18361138a565b614509565b6040519015158152f35b346105d15760003660031901126105d157602060405160068152f35b346105d15760003660031901126105d157611425614e32565b60055460ff8116156114645760ff19166005557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b638dfc202b60e01b60005260046000fd5b346105d15760003660031901126105d1576020604051600a8152f35b346105d15760003660031901126105d15760206040516daaeb6d7670e522a718067333cd4e8152f35b346105d15760403660031901126105d1576004356024356114d9614dda565b81158015611513575b6109f1576020600080516020615d8983398151915291836000526008825280600560406000200155604051908152a2005b506006548210156114e2565b906020808351928381520192019060005b81811061153d5750505090565b8251845260209384019390920191600101611530565b906020610f5492818152019061151f565b346105d15760403660031901126105d1576004356001600160401b0381116105d157366023820112156105d1578060040135906115a082610ed6565b916115ae6040519384610e92565b8083526024602084019160051b830101913683116105d157602401905b82821061160b57836024356001600160401b0381116105d15761076b916115f96115ff923690600401610f39565b9061461e565b60405191829182611553565b60208091611618846105ec565b8152019101906115cb565b346105d15760203660031901126105d15761163c6105bb565b611644614dda565b6001600160a01b0316801561168c57600c80546001600160a01b031916821790557fb64df2e17db66fa14415f6e6eca1b47619d7ae9b7e3fd1e8247212bfb6461b7f600080a2005b63e6c4247b60e01b60005260046000fd5b346105d15760203660031901126105d1576004356001600160401b0381116105d157366023820112156105d1576116de903690602481600401359101610f72565b6116e6614dda565b80516001600160401b038111610e715761170a81611705600254611d1c565b613ab7565b602091601f821160011461173c5761172c9260009183611731575b5050613b36565b600255005b015190503880611725565b6002600052601f19821692600080516020615d698339815191529160005b85811061179057508360019510611777575b505050811b01600255005b015160001960f88460031b161c1916905538808061176c565b9192602060018192868501518155019401920161175a565b801515036105d157565b60c43590610ec4826117a8565b6101443590610ec4826117a8565b346105d15760603660031901126105d1576024356004356117ed826117a8565b6044356001600160401b0381116105d15761180c903690600401610d33565b92611815614dda565b82158015611934575b6109f1578260005260086020526007604060002061183c8382613a6c565b016001600160401b038511610e715761185f856118598354611d1c565b83613afc565b6000601f86116001146118b457946118a4916118958280600080516020615e2983398151915298996000916118a9575b50613b36565b90555b6040519384938461469e565b0390a2005b90508701353861188f565b601f198616906118c983600052602060002090565b91815b81811061191c5750916118a4939188600080516020615e2983398151915298999410611902575b5050600182811b019055611898565b860135600019600385901b60f8161c1916905538806118f3565b9192602060018192868a0135815501940192016118cc565b5060065483101561181e565b9060018060a01b0316600052602052604060002090565b346105d15760203660031901126105d1576001600160a01b036119786105bb565b16600052600a602052602060ff604060002054166040519015158152f35b346105d15760003660031901126105d157602060ff600554166040519015158152f35b6001600160a01b0316600452602490565b346105d15760003660031901126105d157600d546040516001600160a01b039091168152602090f35b346105d15760003660031901126105d157602060405160188152f35b346105d15760003660031901126105d157602060405160158152f35b346105d15760203660031901126105d15760ff600435611a4a8161138a565b1660018110159081611a8a575b8115611a6b57506040519015158152602090f35b601f811015915081611a7e575038610685565b602891501115386106a6565b60148111159150611a57565b346105d15760003660031901126105d1576020600654604051908152f35b9060606003198301126105d1576004356001600160a01b03811681036105d157916024356001600160401b0381116105d15781611af39160040161076f565b90929091604435906001600160401b0382116105d1576107eb9160040161076f565b346105d157611b2336611ab4565b929193611b2e614d67565b611b36614d2a565b838503610a0e57611b48368685610eed565b90611b54368685610eed565b6001600160a01b03821615611bef57611b7f9260405192611b76602085610e92565b60008452615419565b6006549160005b858110611b97576100196001600455565b80611ba5600192888561385c565b3580151580611be6575b611bbb575b5001611b86565b611bde6003611bd5611bce858b8a61385c565b3593612708565b019182546136ab565b905538611bb4565b50858110611baf565b626a0d4560e21b600052600060045260246000fd5b346105d15760003660031901126105d157602060405160098152f35b346105d157611c2e3661079f565b909192611c39614dda565b818403610a0e576006549160005b858110611c5057005b80611c5e600192888661385c565b3580151580611cc9575b611c74575b5001611c47565b611c7f82858961385c565b35816000526008602052600560406000200155600080516020615d89833981519152611cc0611caf84878b61385c565b604051903581529081906020820190565b0390a238611c6d565b50858110611c68565b346105d15760003660031901126105d1576020604051601f8152f35b346105d15760003660031901126105d1576020604051818152f35b60ff166000526009602052604060002090565b90600182811c92168015611d4c575b6020831014611d3657565b634e487b7160e01b600052602260045260246000fd5b91607f1691611d2b565b60009291815491611d6683611d1c565b8083529260018116908115611dbc5750600114611d8257505050565b60009081526020812093945091925b838310611da2575060209250010190565b600181602092949394548385870101520191019190611d91565b915050602093945060ff929192191683830152151560051b010190565b90610ec4611ded9260405193848092611d56565b0383610e92565b346105d15760203660031901126105d15760ff600435611e138161138a565b166000526009602052611e57604060002060405190611e3682611ded8184611d56565b600260ff600183015416910154604051938493606085526060850190610713565b911515602084015260408301520390f35b6064359060048210156105d157565b60e4359060028210156105d157565b6044359060028210156105d157565b346105d1576101803660031901126105d157611eaf611395565b6024356001600160401b0381116105d157611ece903690600401610d33565b9091611ed86113a2565b92611ee1611e68565b936084356001600160401b0381116105d157611f0190369060040161076f565b90949060a435611f0f6117b2565b611f17611e77565b916101043561012435999094906001600160401b038b116105d15761076b9b611f47611f5d9c3690600401610d33565b999098611f526117bf565b9b610164359d6146b7565b6040519081529081906020820190565b346105d15760003660031901126105d1576020604051600b8152f35b346105d15760003660031901126105d157611fa2614e32565b611faa614d0d565b600160ff1960055416176005557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b602081526060604061200084518360208601526080850190610713565b936020810151151582850152015191015290565b346105d15760203660031901126105d15760ff6004356120338161138a565b60006040805161204281610e56565b60608152826020820152015216600052600960205261076b604060002060026040519161206e83610e56565b6040516120868161207f8185611d56565b0382610e92565b835260ff600182015416151560208401520154604082015260405191829182611fe3565b346105d15760003660031901126105d157602060405160168152f35b346105d15760203660031901126105d1576004356120e38161138a565b6120eb614dda565b60ff811690811580156121a6575b61219557612116600161210b83611d09565b01805460ff19169055565b60065460015b81811061214b5783600080516020615d498339815191526118a461213f86611d09565b604051918291826148d5565b808461216b61216561215e600195612708565b5460ff1690565b60ff1690565b14612177575b0161211c565b61219061218382612708565b805463ff00000019169055565b612171565b636b3ac97b60e11b60005260046000fd5b506121b661216560075460ff1690565b8210156120f9565b346105d15760403660031901126105d157602060ff6121f36004356121e16105d6565b90600052600384526040600020611940565b54166040519015158152f35b346105d15760003660031901126105d157602060405160088152f35b346105d15760003660031901126105d157602060405160048152f35b346105d15760003660031901126105d1576020600b5460601c604051908152f35b346105d15760203660031901126105d157602060ff6004356122798161138a565b1660158110159081612291575b506040519015158152f35b601e9150111538612286565b346105d15760003660031901126105d157602060405160008152f35b346105d15760403660031901126105d1576122d26105bb565b6024356122de816117a8565b60ff600d5460a01c16612362575b6001600160a01b03821691821561234d578161231861231d923360005260016020526040600020611940565b613c00565b60405190151581527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160203392a3005b62ced3e160e81b600052600060045260246000fd5b61236b8261534d565b6122ec565b346105d15760203660031901126105d1576123896105bb565b612391614dda565b600e80546001600160a01b039283166001600160a01b0319821681179092559091167f769910e94ac27ed200e1d1600628cdf76c85900b5011ea093a6a00edb9564033600080a3005b602081016020825282518091526040820191602060408360051b8301019401926000915b83831061240d57505050505090565b909192939460208061242b600193603f19868203018752895161113b565b970193019301919392906123fe565b346105d15761244836610c6b565b9061245282610ed6565b916124606040519384610e92565b808352601f1961246f82610ed6565b0160005b8181106124cf57505060005b818110612494576040518061076b86826123da565b806124b36124ae6124a8600194868861385c565b35612708565b614443565b6124bd828761460a565b526124c8818661460a565b500161247f565b6020906124da613dbb565b82828801015201612473565b346105d15760003660031901126105d157602060405160038152f35b346105d15760003660031901126105d157600b546040516001600160601b039091168152602090f35b346105d15760403660031901126105d1576125446105bb565b60243590612551826117a8565b612559614dda565b6001600160a01b031690811561168c5760207f8c8e13f02021bf1f396c6c75b2b9f60e00b992612bc1ba1654a38025cd4704779183600052600a82526125a3816040600020613c00565b6040519015158152a2005b346105d15760203660031901126105d1577f2494457da7b4d830d1d7068d3a8f70d04121c4e4760cd189f8caaa151813d8e060206004356125ee816117a8565b6125f6614dda565b1515600d5460ff60a01b8260a01b169060ff60a01b191617600d55604051908152a1005b346105d15760403660031901126105d157600435602435612639614dda565b81158015612693575b6109f15781600052600860205260016040600020018054918201809211610e3b57817fef18524e45a9c3793f74939b40ae82cfa0160b2993a65ceee104545152736f879260209255604051908152a2005b50600654821015612642565b346105d15760003660031901126105d157602060ff60075416604051908152f35b346105d15760203660031901126105d157600435801580156126fc575b6109f15760005260086020526020600160406000200154604051908152f35b506006548110156126dd565b6000526008602052604060002090565b6000526000602052604060002090565b9b9895919461276a6127ad9b9895610f549f9d9a978f61276261277d9860ff606094816127739a16855216602084015260408301906110e0565b019015159052565b151560808d0152565b60a08b01906110f7565b60c089015260e08801526101008701526101208601526101408501526101a06101608501526101a0840190610713565b91610180818403910152610713565b346105d15760203660031901126105d15760043560005260086020526040600020805461076b6127f08260ff9060201c1690565b92602883901c60ff169060018101546002820154600383015460048401549160058501549361282d600761282660068901611dd9565b9701611dd9565b966040519a8a60ff8d9c60181c169060ff8160101c16908d60ff808360081c16921690612728565b346105d15760003660031901126105d157602060405160058152f35b346105d15760403660031901126105d15761288a6105bb565b602435906001600160601b038216908183036105d1576128a8614dda565b6001600160a01b03811692831561168c5761271083116129155760609190911b6001600160601b031916909117600b556040516001600160601b039190911681527f8039bd6e4e7dba001c8840eb2e118d9d131246faa7d0d04335f7305127ec0b109080602081016118a4565b63012b44a960e51b60005260046000fd5b346105d15760603660031901126105d1576004356129438161138a565b6024356001600160401b0381116105d157612962903690600401610d33565b60ff60443593612971856117a8565b612979614dda565b169182158015612a92575b6121955760008381526009602052604090206001600160401b038311610e71576129b2836118598354611d1c565b6000601f8411600114612a0d57946129f68160016118a4946129ed8880600080516020615d498339815191529b9c600091612a025750613b36565b81555b01613c00565b604051938493846148ed565b90508901353861188f565b601f19841690612a2283600052602060002090565b91815b818110612a7a57509660016118a49482946129f69489600080516020615d498339815191529b9c10612a60575b50508188811b0181556129f0565b88013560001960038b901b60f8161c191690553880612a52565b91926020600181928689013581550194019201612a25565b5060ff60075416831015612984565b346105d15760003660031901126105d157602060405160078152f35b346105d157612acb36610a1f565b90612ad4614d67565b612adc614d2a565b80158015612be9575b6109f157600091612af582612708565b93612b0861098a865460ff9060201c1690565b612bd85761076b94612b1b8385846153ec565b60038101612b2a8482546136ab565b9055805460019060281c60ff16612b40816110ed565b1480612bcb575b612b8b575b600401546040516001600160a01b0390921692600080516020615da983398151915292918291612b7e91889184612cf9565b0390a3611f5d6001600455565b9350600080516020615da983398151915290612bc060048601612baf858254614f72565b5484612bb9613951565b9184614fcb565b919384929150612b4c565b5060048101541515612b47565b63021d672760e11b60005260046000fd5b50600654811015612ae5565b346105d15760003660031901126105d1576020604051600080516020615de98339815191528152f35b346105d15760403660031901126105d157610019600435612c3d6105d6565b90612c4a61107c826139ca565b615081565b346105d157612c5d36611ab4565b91612c69949394614d67565b612c71614d0d565b612c79614d2a565b828103610a0e57612c8984614ee0565b60005b818110612ccf575090612ca7612cc895612caf933691610eed565b923691610eed565b9060405192612cbf602085610e92565b60008452614d4c565b6001600455005b80612cf3612ce0600193858a61385c565b35612cec83888861385c565b3590614f72565b01612c8c565b6040919493926060820195825260208201520152565b346105d15760203660031901126105d15760043580158015612e52575b6109f15760005260086020526040600020612d45610ec6565b612db3612daa8354612d61612d5a8260ff1690565b60ff168552565b60ff600882901c166020850152612d82601082901c60ff1660408601613e2c565b612d96601882901c60ff1615156060860152565b6112c1602082901c60ff1615156080860152565b60a08301613e38565b600182015460c082015260028201549060e081019182526101a0612e206008600386015495610100850196875260048101546101208601526005810154610140860152612e0260068201611dd9565b610160860152612e1460078201611dd9565b61018086015201613e44565b9101525190519081811115612e485761076b612e3c838361363a565b60405193849384612cf9565b61076b6000612e3c565b50600654811015612d2c565b346105d15760403660031901126105d157600435602435612e7d614d0d565b612e85614d2a565b612e9081151561386c565b81158015612fa7575b6109f157612ea682612708565b8054612eb69060181c60ff161590565b6109e05760028101612ec98382546136ab565b91600181015483116109cf57836005612ee39201546138b8565b9081612f2e575b90600080516020615e0983398151915292612f219255612f13612f0b613951565b858733614fcb565b6040519182913395836139b9565b0390a36100196001600455565b90612f6e92602082612f4461089f600c54611086565b612f4f600d54611086565b60006040518099819582946323b872dd60e01b845233600485016138e0565b03925af192831561093657612f9d612f2194600080516020615e0983398151915296600091610907575061390e565b9192509250612eea565b50600654821015612e99565b346105d15760003660031901126105d1576020604051600080516020615dc98339815191528152f35b346105d15760603660031901126105d157612ff56105bb565b612ffd6105d6565b60443591613009614dda565b613011614d2a565b6001600160a01b0382161561168c576001600160a01b0381166130535750600080806130499481945af161304361490e565b50614982565b6100196001600455565b600091908291826130826130906130a897604051928391602083019663a9059cbb60e01b885260248401610c24565b03601f198101835282610e92565b51925af161309c61490e565b816130ad575b5061493e565b613049565b80518015925082156130c2575b5050386130a2565b6130d592506020809183010191016138cb565b38806130ba565b346105d15760403660031901126105d157602060ff6121f36130fc6105bb565b6131046105d6565b6001600160a01b0390911660009081526001855260409020611940565b346105d15760003660031901126105d157602060405160018152f35b346105d15760203660031901126105d1576131566105bb565b61315e614dda565b6001600160a01b0316801561168c57600d80546001600160a01b031916821790557f7dae230f18360d76a040c81f050aa14eb9d6dc7901b20fc5d855e2a20fe814d1600080a2005b346105d15760a03660031901126105d1576131bf6105bb565b6131c76105d6565b60443590606435926084356001600160401b0381116105d1576131ee903690600401610fa9565b9260ff600d5460a01c16806132a2575b613294575b6001600160a01b0382163381141580613272575b61325a576001600160a01b038416156132445715611bef576100199461323c91615873565b9290916156a8565b632bfa23e760e11b600052600060045260246000fd5b63711bec9160e11b6000523360045260245260446000fd5b5080600052600160205260ff61328c336040600020611940565b541615613217565b61329d33614ff1565b613203565b506001600160a01b0382163314156131fe565b346105d15760803660031901126105d1576004356024356132d5816117a8565b6132dd611e86565b90606435926132ea614dda565b8015801561331f575b6109f15760049261331b916000526008602052613315604060002093846149c4565b826149e1565b0155005b506006548110156132f3565b346105d15761335661333c36610a1f565b8181949293613349614d67565b613351614d2a565b6153ec565b8015158061338e575b61336a576001600455005b600052600860205260036040600020018054918201809211610e3b57553880612cc8565b50600654811061335f565b346105d15760003660031901126105d157602060405160028152f35b346105d15760003660031901126105d157600e546040516001600160a01b039091168152602090f35b346105d15760003660031901126105d157602060ff600d5460a01c166040519015158152f35b909161341b610f549360408452604084019061151f565b91602081840391015261151f565b346105d15761343736611ab4565b9291613441614d67565b613449614d2a565b838103610a0e5761345f92612ca7913691610eed565b9061346a81516145d8565b91815190613477826145d8565b9460065460005b8481106134a05787876134916001600455565b61076b60405192839283613404565b6134aa818761460a565b5182811591821561360a575b50506109f1576134cf6134c9828861460a565b51612708565b906134e261098a835460ff9060201c1690565b612bd8576001916135096134f6838a61460a565b51613501848961460a565b5190876153ec565b613513828761460a565b51613523600383019182546136ab565b90558054839060281c60ff16613538816110ed565b14806135fd575b61359d575b61354e828961460a565b5190600080516020615da98339815191528b61357a856004613570828d61460a565b519501549261460a565b5190613594604051928392898060a01b038c169684612cf9565b0390a30161347e565b600481016135b781546135b0858a61460a565b5190614f72565b6135d681546135c6858a61460a565b516135cf613951565b9189614fcb565b546135e1838b61460a565b526135ec828761460a565b516135f7838c61460a565b52613544565b506004810154151561353f565b1015905082386134b6565b634e487b7160e01b600052601160045260246000fd5b600219810191908211610e3b57565b91908203918211610e3b57565b634e487b7160e01b600052603260045260246000fd5b90815181101561366e570160200190565b613647565b9060018201809211610e3b57565b9060028201809211610e3b57565b9060038201809211610e3b57565b9060048201809211610e3b57565b91908201809211610e3b57565b906136cb602092828151948592016106f0565b0190565b6136e360076136dd83612708565b01611dd9565b805161381d57506136f2614a05565b9060005b613700835161362b565b81101561381857607b60f81b61373761372a61371c848761365d565b516001600160f81b03191690565b6001600160f81b03191690565b14806137f3575b806137ce575b806137a3575b613756576001016136f6565b906130828261379d61378c8661378461377e613778610f549961379d9b614aa8565b97614bbc565b9461369d565b815191614b14565b9160405196879560208701906136b8565b906136b8565b50607d60f81b6001600160f81b03196137c761371c6137c18561368f565b8761365d565b161461374a565b50601960fa1b6001600160f81b03196137ec61371c6137c185613681565b1614613744565b50606960f81b6001600160f81b031961381161371c6137c185613673565b161461373e565b505090565b905090565b1561382957565b60405162461bcd60e51b815260206004820152600b60248201526a08adae0e8f240c4c2e8c6d60ab1b6044820152606490fd5b919081101561366e5760051b0190565b1561387357565b60405162461bcd60e51b815260206004820152601d60248201527f416d6f756e74206d7573742062652067726561746572207468616e20300000006044820152606490fd5b81810292918115918404141715610e3b57565b908160209103126105d15751610f54816117a8565b6001600160a01b03918216815291166020820152604081019190915260600190565b6040513d6000823e3d90fd5b1561391557565b60405162461bcd60e51b815260206004820152601460248201527314139d5d1e881c185e5b595b9d0819985a5b195960621b6044820152606490fd5b60405190613960602083610e92565b60008252565b81835290916001600160fb1b0383116105d15760209260051b809284830137010190565b9594936139a6604094926139b49460608a5260608a0191613966565b918783036020890152613966565b930152565b908152602081019190915260400190565b600052600360205260016040600020015490565b9033600052600a60205260ff60406000205416613a5f57600b54916001600160601b038316908115613a4957613a3091600019819004821115613a3457613a299161271090046138b8565b9260601c90565b9190565b613a4190613a29926138b8565b612710900490565b634e487b7160e01b600052601260045260246000fd5b600b5460601c9150600090565b9063ff000000825491151560181b169063ff0000001916179055565b906040610f5492600081528160208201520190611d56565b818110613aab575050565b60008155600101613aa0565b90601f8211613ac4575050565b610ec49160026000526020600020906020601f840160051c83019310613af2575b601f0160051c0190613aa0565b9091508190613ae5565b9190601f8111613b0b57505050565b610ec4926000526020600020906020601f840160051c83019310613af257601f0160051c0190613aa0565b8160011b916000199060031b1c19161790565b81519192916001600160401b038111610e7157613b7081613b6a8454611d1c565b84613afc565b6020601f8211600114613b97578190613b93939495600092611731575050613b36565b9055565b601f19821690613bac84600052602060002090565b9160005b818110613be857509583600195969710613bcf575b505050811b019055565b015160001960f88460031b161c19169055388080613bc5565b9192602060018192868b015181550194019201613bb0565b9060ff801983541691151516179055565b81518051919291906001600160401b038211610e7157613c3b82613c358654611d1c565b86613afc565b602090601f8311600114613c86578260409360029593613c6393600092611731575050613b36565b84555b613c7f613c766020830151151590565b60018601613c00565b0151910155565b90601f19831691613c9c86600052602060002090565b9260005b818110613ce157509260019285926040966002989610613cc8575b505050811b018455613c66565b015160001960f88460031b161c19169055388080613cbb565b92936020600181928786015181550195019301613ca0565b908060209392818452848401376000828201840152601f01601f1916010190565b916020610f54938181520191613cf9565b9392919060ff600d5460a01c1680613da8575b613d9a575b6001600160a01b0385163381141580613d78575b61325a576001600160a01b038216156132445715611bef57610ec4946156a8565b5080600052600160205260ff613d92336040600020611940565b541615613d57565b613da333614ff1565b613d43565b506001600160a01b038516331415613d3e565b60405190613dc882610e76565b60606101a08360008152600060208201526000604082015260008382015260006080820152600060a0820152600060c0820152600060e082015260006101008201526000610120820152600061014082015282610160820152826101808201520152565b60048210156110db5752565b60028210156110db5752565b60405181548082529092918390613e646020830191600052602060002090565b926000905b80601f83011061427057610ec494549181811061425c575b818110614244575b81811061422c575b818110614214575b8181106141fd575b8181106141e5575b8181106141cd575b8181106141b5575b81811061419d575b818110614185575b81811061416d575b818110614155575b81811061413d575b818110614125575b81811061410d575b8181106140f5575b8181106140dd575b8181106140c5575b8181106140ad575b818110614095575b81811061407d575b818110614065575b81811061404d575b818110614035575b81811061401d575b818110614005575b818110613fed575b818110613fd5575b818110613fbd575b818110613fa5575b818110613f8d575b10613f7f575b500383610e92565b60f81c815260200138613f77565b60f083901c60ff168452926001906020019301613f71565b60e883901c60ff168452926001906020019301613f69565b60e083901c60ff168452926001906020019301613f61565b60d883901c60ff168452926001906020019301613f59565b60d083901c60ff168452926001906020019301613f51565b60c883901c60ff168452926001906020019301613f49565b60c083901c60ff168452926001906020019301613f41565b60b883901c60ff168452926001906020019301613f39565b60b083901c60ff168452926001906020019301613f31565b60a883901c60ff168452926001906020019301613f29565b60a083901c60ff168452926001906020019301613f21565b609883901c60ff168452926001906020019301613f19565b609083901c60ff168452926001906020019301613f11565b608883901c60ff168452926001906020019301613f09565b608083901c60ff168452926001906020019301613f01565b607883901c60ff168452926001906020019301613ef9565b607083901c60ff168452926001906020019301613ef1565b606883901c60ff168452926001906020019301613ee9565b606083901c60ff168452926001906020019301613ee1565b605883901c60ff168452926001906020019301613ed9565b605083901c60ff168452926001906020019301613ed1565b604883901c60ff168452926001906020019301613ec9565b604083901c60ff168452926001906020019301613ec1565b603883901c60ff168452926001906020019301613eb9565b603083901c60ff168452926001906020019301613eb1565b602883901c60ff168452926001906020019301613ea9565b602083811c60ff1685529093600191019301613ea1565b601883901c60ff168452926001906020019301613e99565b601083901c60ff168452926001906020019301613e91565b600883901c60ff168452926001906020019301613e89565b60ff83168452926001906020019301613e81565b91602091935061040060019161443587546142908360ff831660ff169052565b600881901c60ff1683870152601081901c60ff166040840152601881901c60ff16606084015280861c60ff166080840152602881901c60ff1660a0840152603081901c60ff1660c0840152603881901c60ff1660e0840152604081901c60ff16610100840152604881901c60ff16610120840152605081901c60ff16610140840152605881901c60ff16610160840152606081901c60ff16610180840152606881901c60ff166101a0840152607081901c60ff166101c0840152607881901c60ff166101e0840152608081901c60ff16610200840152608881901c60ff16610220840152609081901c60ff16610240840152609881901c60ff1661026084015260a081901c60ff1661028084015260a881901c60ff166102a084015260b081901c60ff166102c084015260b881901c60ff166102e084015260c081901c60ff1661030084015260c881901c60ff1661032084015260d081901c60ff1661034084015260d881901c60ff1661036084015260e081901c60ff1661038084015260e881901c60ff166103a084015260f081901c60ff166103c084015260f81c6103e0830152565b019401920185929391613e69565b906145016008614451610ec6565b936144c06144b7825461446e6144678260ff1690565b60ff168952565b60ff600882901c16602089015261448f601082901c60ff1660408a01613e2c565b6144a3601882901c60ff16151560608a0152565b6112c1602082901c60ff16151560808a0152565b60a08701613e38565b600181015460c0860152600281015460e0860152600381015461010086015260048101546101208601526005810154610140860152612e0260068201611dd9565b6101a0830152565b919091801580156145cc575b6145c4576124ae61452591612708565b9161453661098a6060850151151590565b6145c45760ff8061454b602086015160ff1690565b92169116036145bd5760ff16600181036145a0575060400160018151614570816110d1565b614579816110d1565b14908115614585575090565b6003915051614593816110d1565b61459c816110d1565b1490565b6002146145ad5750600090565b60400160028151614570816110d1565b5050600090565b505050600090565b50600654811015614515565b906145e282610ed6565b6145ef6040519182610e92565b8281528092614600601f1991610ed6565b0190602036910137565b805182101561366e5760209160051b010190565b9190918051835180820361468757505061463881516145d8565b9060005b8151811015614680578061466e60019260051b6020808287010151918901015160005260006020526040600020611940565b54614679828661460a565b520161463c565b5090925050565b635b05999160e01b60005260045260245260446000fd5b604090610f549492151581528160208201520191613cf9565b99939c959a92979894919d969b9d6146cd614dda565b60ff8b168015908115614829575b50612195576146f961098a60016146f18e611d09565b015460ff1690565b612195578c15614818578d60ff8a16614808575b5061471b600a8d11156150f6565b60005b8c8082106147a4575050369061473392610f72565b99369061473f92614842565b9b369061474b92610f72565b91868a6006549d8e9d8e998d8d6147618d614898565b60065561476d9c6152a7565b60405193849361477d93856148a7565b037fa3c42004ac018ce69d8909dc090172edb94410550cbf5ec3bdeb9439fee4d1c991a290565b6121656147b5836147ba938861385c565b61513a565b60ff8b1681146147f75780159081156147ec575b506147db5760010161471e565b6303780dc560e41b60005260046000fd5b6028915011386147ce565b63bfc0bebd60e01b60005260046000fd5b614812908a615898565b8d61470d565b6315ae672760e01b60005260046000fd5b905061483a61216560075460ff1690565b1115386146db565b92919061484e81610ed6565b9361485c6040519586610e92565b602085838152019160051b81019283116105d157905b82821061487e57505050565b60208091833561488d8161138a565b815201910190614872565b6000198114610e3b5760010190565b9294939060609260ff6148c892168552608060208601526080850190610713565b9460408401521515910152565b919060206139b4600092604086526040860190611d56565b9160209161490691959495604085526040850191613cf9565b931515910152565b3d15614939573d9061491f82610f57565b9161492d6040519384610e92565b82523d6000602084013e565b606090565b1561494557565b60405162461bcd60e51b8152602060048201526015602482015274151bdad95b881d1c985b9cd9995c8819985a5b1959605a1b6044820152606490fd5b1561498957565b60405162461bcd60e51b8152602060048201526013602482015272115512081d1c985b9cd9995c8819985a5b1959606a1b6044820152606490fd5b805460ff60201b191691151560201b60ff60201b16919091179055565b9060028110156110db57815460ff60281b191660289190911b60ff60281b16179055565b604051600254816000614a1783611d1c565b8083529260018116908115614a895750600114614a3b575b610f5492500382610e92565b50600260009081529091600080516020615d698339815191525b818310614a6d575050906020610f5492820101614a2f565b6020919350806001915483858801015201910190918392614a55565b60209250610f5494915060ff191682840152151560051b820101614a2f565b9190614ab381610f57565b90614ac16040519283610e92565b808252601f19614ad082610f57565b0136602084013760005b818110614ae8575090925050565b6001906001600160f81b0319614afe828861365d565b511660001a614b0d828661365d565b5301614ada565b9181810392818411610e3b57614b2984610f57565b93614b376040519586610e92565b808552614b46601f1991610f57565b01366020860137825b828110614b5d575050505090565b6001600160f81b0319614b70828461365d565b511690848103818111610e3b57614b8d60019360001a918861365d565b5301614b4f565b90614b9e82610f57565b614bab6040519182610e92565b8281528092614600601f1991610f57565b6000908072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b811015614cea575b600a906904ee2d6d415b85acef8160201b811015614ccf575b662386f26fc10000811015614cba575b6305f5e100811015614ca8575b612710811015614c98575b6064811015614c89575b1015614c7e575b614c6e6021614c4260018501614b94565b938401015b60001901916f181899199a1a9b1b9c1cb0b131b232b360811b600a82061a8353600a900490565b801561381857614c6e9091614c47565b600190910190614c31565b60029060649004930192614c2a565b6004906127109004930192614c20565b6008906305f5e1009004930192614c15565b601090662386f26fc100009004930192614c08565b6020906904ee2d6d415b85acef8160201b9004930192614bf8565b506040915072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8104614bdf565b60ff60055416614d1957565b63d93c066560e01b60005260046000fd5b600260045414614d3b576002600455565b633ee5aeb560e01b60005260046000fd5b9291906001600160a01b0384161561324457610ec49361557d565b600080516020615de9833981519152600052600360205260ff614daa337f5562e70da342db81569f3094d36be279beaca7ad8e08f434ea188e79d2bfe10c611940565b541615614db357565b63e2517d3f60e01b60005233600452600080516020615de983398151915260245260446000fd5b60008052600360205260ff614e0f337f3617319a054d772f909f7c479a2cebe5066e836a939412e32403c99029b92eff611940565b541615614e1857565b63e2517d3f60e01b60005233600452600060245260446000fd5b600080516020615dc9833981519152600052600360205260ff614e75337f30adeb818ef77f204f5a603c30fa5332397b6e28fb3b7f9d937ae6a6914716de611940565b541615614e7e57565b63e2517d3f60e01b60005233600452600080516020615dc983398151915260245260446000fd5b80600052600360205260ff614ebe336040600020611940565b541615614ec85750565b63e2517d3f60e01b6000523360045260245260446000fd5b803b15614f6f576040516301ffc9a760e01b8152630271189760e51b600482015290602090829060249082906001600160a01b03165afa60009181614f4e575b50614f365763dcbdf9e760e01b60005260046000fd5b15614f3d57565b63dcbdf9e760e01b60005260046000fd5b614f6891925060203d60201161092f576109218183610e92565b9038614f20565b50565b80158015614fbf575b6109f1576000526008602052604060002090614f9e60ff835460181c1615151590565b6109e0576001614fb3600284019283546136ab565b92015482116109cf5755565b50600654811015614f7b565b919291906001600160a01b0382161561324457610ec493614feb91615873565b9161557d565b60ff600d5460a01c166150015750565b610ec49061534d565b80600052600360205260ff615023836040600020611940565b54166145bd57806000526003602052615040826040600020611940565b805460ff1916600117905533916001600160a01b0316907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d600080a4600190565b80600052600360205260ff61509a836040600020611940565b5416156145bd578060005260036020526150b8826040600020611940565b805460ff1916905533916001600160a01b0316907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b600080a4600190565b156150fd57565b60405162461bcd60e51b81526020600482015260156024820152744d617820313020636f6e666c69637420736c6f747360581b6044820152606490fd5b35610f548161138a565b9060048110156110db5762ff000082549160101b169062ff00001916179055565b90600160401b8111610e7157815481835580821061518257505050565b610ec492600052601f6020600020918180850160051c84019416806151ae575b500160051c0190613aa0565b6000198501908154906000199060200360031b1c169055386151a2565b815190916001600160401b038211610e715760206151fa916151ed8486615165565b0192600052602060002090565b8160051c9160005b83811061526f5750601f19811690038061521d575b50505050565b9260009360005b81811061523957505050015538808080615217565b9091946020615265600192846152508a5160ff1690565b919060ff809160031b9316831b921b19161790565b9601929101615224565b6000805b60208110615288575083820155600101615202565b9590602061529e60019289615250865160ff1690565b92019601615273565b9b97949b9a92909a9896939198600052600860205260406000209a60ff1660ff198c5416178b558a549060081b61ff00169061ff001916178a556152eb908a615144565b6152f59089613a6c565b6152ff90886149c4565b61530990876149e1565b60018601556000600286018190556003860155600485015560058401556153339060068401613b49565b6153409060078301613b49565b60080190610ec4916151cb565b6daaeb6d7670e522a718067333cd4e3b6153645750565b604051633185c44d60e21b81523060048201526001600160a01b03821660248201526020816044816daaeb6d7670e522a718067333cd4e5afa908115610936576000916153cd575b50156153b55750565b633b79c77360e21b6000526153c9906119b9565b6000fd5b6153e6915060203d60201161092f576109218183610e92565b386153ac565b906001600160a01b03821615611bef57610ec49261540991615873565b9060405192611b76602085610e92565b909250615424614d0d565b82518251908181036155665750506001600160a01b0381168015159490939060005b82518110156154ca578060051b876020808387010151928801015190615471575b5050600101615446565b6154838661547e84612718565b611940565b548181106154a7578661547e600195949361549f930393612718565b559038615467565b866154c684846040519485946303dee4c560e01b865260048601615bbc565b0390fd5b50949091936000906001845114821461553e576020840151600080516020615d2983398151915261550760208801516040519182913395836139b9565b0390a45b8080615535575b8161552d575b5061552257505050565b6000610ec493615be0565b905038615518565b60009150615512565b604051600080516020615ce983398151915233918061555e898983613404565b0390a461550b565b635b05999160e01b60005260045260245260446000fd5b93929190615589614d0d565b80518251908181036155665750506001600160a01b038516938415159360005b83518110156155f95780868960019360051b602080828a010151918a010151926155d7575b505050016155a9565b6155ef9161547e6155e792612718565b9182546136ab565b90553889816155ce565b5093909594600183511460001461567e5760006020840151600080516020615d2983398151915261563660208801516040519182913395836139b9565b0390a45b6156445750505050565b805160010361566d57906020806156649593015191015191600033615b1c565b38808080615217565b615679936000336159fa565b615664565b6000604051600080516020615ce98339815191523391806156a0898983613404565b0390a461563a565b9493929091936156b6614d0d565b84518251908181036155665750506001600160a01b0386811695861515959185168015159391929060005b845181101561578a578060051b90898988602080868b010151958c01015192615731575b93600194615717575b505050016156e1565b6157279161547e6155e792612718565b905538898161570e565b505090916157428d61547e83612718565b5482811061576b578291898f615762600197968f95039161547e85612718565b55909450615705565b8d6154c683856040519485946303dee4c560e01b865260048601615bbc565b509096919895939297600189511460001461584957818160208b0151600080516020615d298339815191526157cb60208b01516040519182913395836139b9565b0390a45b82615841575b82615836575b5050615825575b6157ee575b5050505050565b84516001036158145760208061580a9601519201519233615b1c565b38808080806157e7565b615820949192336159fa565b61580a565b61583183878487615be0565b6157e2565b1415905038806157db565b8392506157d5565b81818a600080516020615ce98339815191526040518061586b8c339583613404565b0390a46157cf565b9160405192600184526020840152604083019160018352606084015260808301604052565b906158a2816110d1565b80156158f5576158b1816110d1565b60018114801561597f575b615926575b6158ca816110d1565b60028114908115615912575b506158de5750565b60ff1660158110159081615906575b50156158f557565b637d7b22cf60e11b60005260046000fd5b601e91501115386158ed565b6003915061591f816110d1565b14386158d6565b60ff821660018110159081615973575b8115615953575b506158c157637d7b22cf60e11b60005260046000fd5b601f811015915081615967575b503861593d565b60289150111538615960565b60148111159150615936565b50615989816110d1565b600381146158bc565b908160209103126105d15751610f548161063b565b6001600160a01b0391821681529116602082015260a060408201819052610f5494919391926159ec92916159de919086019061151f565b90848203606086015261151f565b916080818403910152610713565b9091949293853b615a0e575b505050505050565b602093615a3091604051968795869563bc197c8160e01b8752600487016159a7565b038160006001600160a01b0387165af160009181615ab2575b50615a7b5750615a5761490e565b8051919082615a7457632bfa23e760e11b6000526153c9826119b9565b6020915001fd5b6001600160e01b0319166343e6837f60e01b01615a9e5750388080808080615a06565b632bfa23e760e11b6000526153c9906119b9565b615ad591925060203d602011615adc575b615acd8183610e92565b810190615992565b9038615a49565b503d615ac3565b6001600160a01b039182168152911660208201526040810191909152606081019190915260a060808201819052610f5492910190610713565b9091949293853b615b2f57505050505050565b602093615b5191604051968795869563f23a6e6160e01b875260048701615ae3565b038160006001600160a01b0387165af160009181615b9b575b50615b785750615a5761490e565b6001600160e01b031916630dc5919f60e01b01615a9e5750388080808080615a06565b615bb591925060203d602011615adc57615acd8183610e92565b9038615b6a565b90949392606092608083019660018060a01b03168352602083015260408201520152565b909392919360018060a01b03615bf7600e54611086565b1615615ce15760005b8551811015615cd95780615c166001928861460a565b51615c21828761460a565b518015615cd257600080615c36600e54611086565b60405163c16ec6dd60e01b602082019081526001600160a01b03808c1660248401528a1660448301526064820187905260848201869052908390615c7d8160a48101613082565b51925af1615c8961490e565b5015615cd25760405190815260a084901b84900385811691908716907f51e866c8533d4385f872db5ecbbc78914e718cec9fa5481105c30369d8c22e7f90602090a45b01615c00565b5050615ccc565b505050509050565b505050905056fe4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb26eca058065f266ad114168050ab2d71e8fb15b84a95aad5684bce2e2af8ef8ac3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62ba51f4ef4a9aab57746cf07cdc0402bd05666695385ff9ca304705b57c02b0da405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0bfd84f586f186e4e2a0b575593a4b4b7735b4229f86de082fd9662d9324bb27662e54e548e1246fd88fa9377d2b81bb41d763f54eef72121a5f8029f26728cf65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a69d357202c083ccb2d1379a9af250503bb1cda8e0402c1093fab74b83dd8af89b8079f6073f7ca73569e857af00512eccf66e4b86a5f5b8011a8403354130e4dfa264697066735822122079d5ceccd2207c0d591672fb709c065afd56e8d7a478a214c55fe85568c0e22664736f6c634300081c00332f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d30adeb818ef77f204f5a603c30fa5332397b6e28fb3b7f9d937ae6a6914716de3617319a054d772f909f7c479a2cebe5066e836a939412e32403c99029b92eff00000000000000000000000000000000000000000000000000000000000000e000000000000000000000000042ea0d051206aee8bcd23379939224177a38dc0f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b75a5d2013c9ee66bc5385ce9d845cd518ee16a00000000000000000000000000000000000000000000000000000000000001f400000000000000000000000054a70516e9c0223f4a92be3a4832a06f546e783b0000000000000000000000001b75a5d2013c9ee66bc5385ce9d845cd518ee16a000000000000000000000000000000000000000000000000000000000000003e68747470733a2f2f73746f726167652e676f6f676c65617069732e636f6d2f6765657a2d7075626c69632f7765617261626c65732f6d65746164617461340000
Deployed Bytecode
0x6080604052600436101561001b575b361561001957600080fd5b005b60003560e01c8062fdd58e146105b657806301ffc9a7146105b15780630e89341c146105ac57806313098dde146105a7578063156e29f6146105a257806315c5ec121461059d5780631ba42149146105985780631ee7a7bc1461059357806322080a891461058e5780632273d3b814610589578063248a9ca3146105845780632a55205a1461057f5780632cf5ab941461057a5780632e0dcbf7146105755780632eb2c2d6146105705780632f2ff15d1461056b5780632f789759146105665780633129e7731461056157806336568abe1461055c57806338b27e75146105575780633be087f3146104495780633f4ba83a14610552578063415ba8091461054d57806341f43434146105485780634229c35e146105435780634e1273f41461053e578063543fd7251461053957806355f804b31461053457806356f67e771461052f5780635b3edfd71461052a5780635c975abb1461052557806361d027b31461052057806362094e9f1461051b57806362c217331461051657806364763f20146105115780636a8689741461050c5780636b20c454146105075780636ce04675146105025780636d73cc95146104fd578063724b7568146104f8578063764b7c71146104f35780637be6277b146104ee57806381dfee06146104e9578063843ee984146104e45780638456cb59146104df578063887b98b9146104da5780638bf314ac146104d55780638e799ae5146104d057806391d14854146104cb5780639301a10b146104c657806396d640b9146104c65780639834ca3b146104c15780639fbc8713146104bc578063a09a4674146104b7578063a217fddf146104b2578063a22cb465146104ad578063a56d6340146104a8578063a5844841146104a3578063a73e9a461461049e578063ac79ee3014610499578063b6f302dc14610494578063b7c0b8e81461048f578063bab4de491461048a578063bc32443814610485578063bd85b03914610480578063bfb231d21461047b578063c047267114610467578063c21b471b14610476578063c369ed7414610471578063c7eda34a1461046c578063c9c5c0c91461046c578063ca55345d14610467578063d0c79b3414610462578063d53913931461045d578063d547741f14610458578063d81d0a1514610453578063db7d40221461044e578063dc9505b314610449578063e067569814610444578063e63ab1e91461043f578063e63ea4081461043a578063e985e9c514610435578063e9d0c0ad14610430578063f0f442601461042b578063f242432a14610426578063f3ba6d8914610421578063f5298aca1461041c578063f6456e4414610417578063f68256a814610412578063fb796e6c1461040d5763ff3d1cbc0361000e57613429565b6133de565b6133b5565b613399565b61332b565b6132b5565b6131a6565b61313d565b613121565b6130dc565b612fdc565b612fb3565b612e5e565b6113f0565b612d0f565b612c4f565b612c1e565b612bf5565b612abd565b612855565b612aa1565b612926565b612871565b6127bc565b6126c0565b61269f565b61261a565b6125ae565b61252b565b612502565b6124e6565b61243a565b612370565b6122b9565b61229d565b612258565b612237565b61221b565b6121ff565b6121be565b6120c6565b6120aa565b612014565b611f89565b611f6d565b611e95565b611df4565b611cee565b611cd2565b611c20565b611c04565b611b15565b611a96565b611a2b565b611a0f565b6119f3565b6119ca565b611996565b611957565b6117cd565b61169d565b611623565b611564565b6114ba565b611491565b611475565b61140c565b6113af565b611344565b611221565b611092565b611050565b610fc4565b610d60565b610c95565b610c3f565b610bfe565b610be2565b610bc6565b610baa565b610b8e565b610af9565b610a49565b6107ef565b610738565b61064d565b610600565b600435906001600160a01b03821682036105d157565b600080fd5b602435906001600160a01b03821682036105d157565b35906001600160a01b03821682036105d157565b346105d15760403660031901126105d157602061063261061e6105bb565b602435600052600083526040600020611940565b54604051908152f35b6001600160e01b03198116036105d157565b346105d15760203660031901126105d15760043561066a8161063b565b63ffffffff60e01b1663152a902d60e11b8114908115610693575b506040519015158152602090f35b637965db0b60e01b8114915081156106ad575b5038610685565b636cdb3d1360e11b8114915081156106df575b81156106ce575b50386106a6565b6301ffc9a760e01b149050386106c7565b6303a24d0760e21b811491506106c0565b60005b8381106107035750506000910152565b81810151838201526020016106f3565b9060209161072c815180928185528580860191016106f0565b601f01601f1916010190565b346105d15760203660031901126105d15761076b6107576004356136cf565b604051918291602083526020830190610713565b0390f35b9181601f840112156105d1578235916001600160401b0383116105d1576020808501948460051b0101116105d157565b60406003198201126105d1576004356001600160401b0381116105d157816107c99160040161076f565b90929091602435906001600160401b0382116105d1576107eb9160040161076f565b9091565b346105d1576107fd3661079f565b91610806614d0d565b61080e614d2a565b828103610a0e57610820811515613822565b600092835b82811061093b57508361088a575b600080516020615d098339815191529361087d9161086f61085536868a610eed565b610860368489610eed565b610868613951565b9133614d4c565b60405194859433988661398a565b0390a26100196001600455565b8360206108ce956108a461089f600c54611086565b611086565b6108af600d54611086565b6000604051809a819582946323b872dd60e01b845233600485016138e0565b03925af1918215610936576108fe61087d93600080516020615d0983398151915297600091610907575b5061390e565b91509350610833565b610929915060203d60201161092f575b6109218183610e92565b8101906138cb565b386108f8565b503d610917565b613902565b9361094785848861385c565b359461095481848761385c565b359561096187151561386c565b80158015610a02575b6109f15761097790612708565b9161098e61098a845460ff9060181c1690565b1590565b6109e05760028301966109a28189546136ab565b91600185015483116109cf576109c16109c792600560019701546138b8565b906136ab565b965501610825565b63d05cb60960e01b60005260046000fd5b632189a1af60e21b60005260046000fd5b639a749d8160e01b60005260046000fd5b5060065481101561096a565b631fec674760e31b60005260046000fd5b60609060031901126105d1576004356001600160a01b03811681036105d157906024359060443590565b346105d1577f9034a31cdc6adf3aa5808e15bcfc4ece48ee9ed42da9427448b7c87c77b5f04b610a7836610a1f565b91610a84939193614d67565b610a8c614d0d565b610a94614d2a565b610a9d81614ee0565b610aa78385614f72565b610ac4604051610ab8602082610e92565b60008152848684614fcb565b83600052600860205260026040600020015490610aef60405192839260018060a01b031695836139b9565b0390a36001600455005b346105d15760403660031901126105d157600435602435610b18614dda565b81158015610b82575b6109f157816000526008602052604060002060028101548210610b7157817f314d0f34164f20ee7ef4433df38ab623d5f45c063a260cd6b5425b67d1a11abc9260016020930155604051908152a2005b6317fb2f2760e21b60005260046000fd5b50600654821015610b21565b346105d15760003660031901126105d1576020604051600c8152f35b346105d15760003660031901126105d157602060405160218152f35b346105d15760003660031901126105d1576020604051600d8152f35b346105d15760003660031901126105d157602060405160178152f35b346105d15760203660031901126105d1576020610c1c6004356139ca565b604051908152f35b6001600160a01b039091168152602081019190915260400190565b346105d15760403660031901126105d157610c5b6024356139de565b9061076b60405192839283610c24565b60206003198201126105d157600435906001600160401b0382116105d1576107eb9160040161076f565b346105d157610ca336610c6b565b610cab614dda565b60065460005b828110610cba57005b80610cc8600192858761385c565b3580151580610d2a575b610cde575b5001610cb1565b806000526008602052604060002063ff000000198154169055600080516020615e29833981519152610d216007610d1484612708565b0160405191829182613a88565b0390a238610cd7565b50838110610cd2565b9181601f840112156105d1578235916001600160401b0383116105d157602083818601950101116105d157565b346105d15760203660031901126105d1576004356001600160401b0381116105d157610d90903690600401610d33565b90610d99614dda565b6007549060ff82169160ff8314610e3b5760ff19166001830160ff161760075561076b9282917ff3ecfcc2269255fcc22a28954eae1b224df081095ec51cb9d4d804eeff86605b9190610e15610ded610eb5565b610df8368585610f72565b815260016020820152426040820152610e1086611d09565b613c11565b610e2460405192839283613d1a565b0390a260405160ff90911681529081906020820190565b613615565b634e487b7160e01b600052604160045260246000fd5b606081019081106001600160401b03821117610e7157604052565b610e40565b6101c081019081106001600160401b03821117610e7157604052565b601f909101601f19168101906001600160401b03821190821017610e7157604052565b60405190610ec4606083610e92565b565b60405190610ec46101c083610e92565b6001600160401b038111610e715760051b60200190565b929190610ef981610ed6565b93610f076040519586610e92565b602085838152019160051b81019283116105d157905b828210610f2957505050565b8135815260209182019101610f1d565b9080601f830112156105d157816020610f5493359101610eed565b90565b6001600160401b038111610e7157601f01601f191660200190565b929192610f7e82610f57565b91610f8c6040519384610e92565b8294818452818301116105d1578281602093846000960137010152565b9080601f830112156105d157816020610f5493359101610f72565b346105d15760a03660031901126105d157610fdd6105bb565b610fe56105d6565b906044356001600160401b0381116105d157611005903690600401610f39565b6064356001600160401b0381116105d157611024903690600401610f39565b608435939091906001600160401b0385116105d15761104a610019953690600401610fa9565b93613d2b565b346105d15760403660031901126105d15761001960043561106f6105d6565b9061108161107c826139ca565b614ea5565b61500a565b6001600160a01b031690565b346105d15760003660031901126105d157600c546040516001600160a01b039091168152602090f35b634e487b7160e01b600052602160045260246000fd5b600411156110db57565b6110bb565b9060048210156110db5752565b600211156110db57565b9060028210156110db5752565b906020808351928381520192019060005b8181106111225750505090565b825160ff16845260209384019390920191600101611115565b805160ff168252610f549160208281015160ff1690820152611165604083015160408301906110e0565b60608281015115159082015260808281015115159082015261118f60a083015160a08301906110f7565b60c082015160c082015260e082015160e08201526101008201516101008201526101208201516101208201526101408201516101408201526101a06111fe6111ea6101608501516101c06101608601526101c0850190610713565b610180850151848203610180860152610713565b920151906101a0818403910152611104565b906020610f5492818152019061113b565b346105d15760203660031901126105d15760043561123d613dbb565b50600052600860205261076b6040600020611332600861125b610ec6565b926112d36112ca82546112786112718260ff1690565b60ff168852565b60ff600882901c166020880152611299601082901c60ff1660408901613e2c565b6112ad601882901c60ff1615156060890152565b6112c1602082901c60ff1615156080890152565b60281c60ff1690565b60a08601613e38565b600181015460c0850152600281015460e085015260038101546101008501526004810154610120850152600581015461014085015261131460068201611dd9565b61016085015261132660078201611dd9565b61018085015201613e44565b6101a082015260405191829182611210565b346105d15760403660031901126105d1576004356113606105d6565b336001600160a01b038216036113795761001991615081565b63334bd91960e11b60005260046000fd5b60ff8116036105d157565b60043590610ec48261138a565b60443590610ec48261138a565b346105d15760603660031901126105d15760206113e66004356024356113d48161138a565b604435916113e18361138a565b614509565b6040519015158152f35b346105d15760003660031901126105d157602060405160068152f35b346105d15760003660031901126105d157611425614e32565b60055460ff8116156114645760ff19166005557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b638dfc202b60e01b60005260046000fd5b346105d15760003660031901126105d1576020604051600a8152f35b346105d15760003660031901126105d15760206040516daaeb6d7670e522a718067333cd4e8152f35b346105d15760403660031901126105d1576004356024356114d9614dda565b81158015611513575b6109f1576020600080516020615d8983398151915291836000526008825280600560406000200155604051908152a2005b506006548210156114e2565b906020808351928381520192019060005b81811061153d5750505090565b8251845260209384019390920191600101611530565b906020610f5492818152019061151f565b346105d15760403660031901126105d1576004356001600160401b0381116105d157366023820112156105d1578060040135906115a082610ed6565b916115ae6040519384610e92565b8083526024602084019160051b830101913683116105d157602401905b82821061160b57836024356001600160401b0381116105d15761076b916115f96115ff923690600401610f39565b9061461e565b60405191829182611553565b60208091611618846105ec565b8152019101906115cb565b346105d15760203660031901126105d15761163c6105bb565b611644614dda565b6001600160a01b0316801561168c57600c80546001600160a01b031916821790557fb64df2e17db66fa14415f6e6eca1b47619d7ae9b7e3fd1e8247212bfb6461b7f600080a2005b63e6c4247b60e01b60005260046000fd5b346105d15760203660031901126105d1576004356001600160401b0381116105d157366023820112156105d1576116de903690602481600401359101610f72565b6116e6614dda565b80516001600160401b038111610e715761170a81611705600254611d1c565b613ab7565b602091601f821160011461173c5761172c9260009183611731575b5050613b36565b600255005b015190503880611725565b6002600052601f19821692600080516020615d698339815191529160005b85811061179057508360019510611777575b505050811b01600255005b015160001960f88460031b161c1916905538808061176c565b9192602060018192868501518155019401920161175a565b801515036105d157565b60c43590610ec4826117a8565b6101443590610ec4826117a8565b346105d15760603660031901126105d1576024356004356117ed826117a8565b6044356001600160401b0381116105d15761180c903690600401610d33565b92611815614dda565b82158015611934575b6109f1578260005260086020526007604060002061183c8382613a6c565b016001600160401b038511610e715761185f856118598354611d1c565b83613afc565b6000601f86116001146118b457946118a4916118958280600080516020615e2983398151915298996000916118a9575b50613b36565b90555b6040519384938461469e565b0390a2005b90508701353861188f565b601f198616906118c983600052602060002090565b91815b81811061191c5750916118a4939188600080516020615e2983398151915298999410611902575b5050600182811b019055611898565b860135600019600385901b60f8161c1916905538806118f3565b9192602060018192868a0135815501940192016118cc565b5060065483101561181e565b9060018060a01b0316600052602052604060002090565b346105d15760203660031901126105d1576001600160a01b036119786105bb565b16600052600a602052602060ff604060002054166040519015158152f35b346105d15760003660031901126105d157602060ff600554166040519015158152f35b6001600160a01b0316600452602490565b346105d15760003660031901126105d157600d546040516001600160a01b039091168152602090f35b346105d15760003660031901126105d157602060405160188152f35b346105d15760003660031901126105d157602060405160158152f35b346105d15760203660031901126105d15760ff600435611a4a8161138a565b1660018110159081611a8a575b8115611a6b57506040519015158152602090f35b601f811015915081611a7e575038610685565b602891501115386106a6565b60148111159150611a57565b346105d15760003660031901126105d1576020600654604051908152f35b9060606003198301126105d1576004356001600160a01b03811681036105d157916024356001600160401b0381116105d15781611af39160040161076f565b90929091604435906001600160401b0382116105d1576107eb9160040161076f565b346105d157611b2336611ab4565b929193611b2e614d67565b611b36614d2a565b838503610a0e57611b48368685610eed565b90611b54368685610eed565b6001600160a01b03821615611bef57611b7f9260405192611b76602085610e92565b60008452615419565b6006549160005b858110611b97576100196001600455565b80611ba5600192888561385c565b3580151580611be6575b611bbb575b5001611b86565b611bde6003611bd5611bce858b8a61385c565b3593612708565b019182546136ab565b905538611bb4565b50858110611baf565b626a0d4560e21b600052600060045260246000fd5b346105d15760003660031901126105d157602060405160098152f35b346105d157611c2e3661079f565b909192611c39614dda565b818403610a0e576006549160005b858110611c5057005b80611c5e600192888661385c565b3580151580611cc9575b611c74575b5001611c47565b611c7f82858961385c565b35816000526008602052600560406000200155600080516020615d89833981519152611cc0611caf84878b61385c565b604051903581529081906020820190565b0390a238611c6d565b50858110611c68565b346105d15760003660031901126105d1576020604051601f8152f35b346105d15760003660031901126105d1576020604051818152f35b60ff166000526009602052604060002090565b90600182811c92168015611d4c575b6020831014611d3657565b634e487b7160e01b600052602260045260246000fd5b91607f1691611d2b565b60009291815491611d6683611d1c565b8083529260018116908115611dbc5750600114611d8257505050565b60009081526020812093945091925b838310611da2575060209250010190565b600181602092949394548385870101520191019190611d91565b915050602093945060ff929192191683830152151560051b010190565b90610ec4611ded9260405193848092611d56565b0383610e92565b346105d15760203660031901126105d15760ff600435611e138161138a565b166000526009602052611e57604060002060405190611e3682611ded8184611d56565b600260ff600183015416910154604051938493606085526060850190610713565b911515602084015260408301520390f35b6064359060048210156105d157565b60e4359060028210156105d157565b6044359060028210156105d157565b346105d1576101803660031901126105d157611eaf611395565b6024356001600160401b0381116105d157611ece903690600401610d33565b9091611ed86113a2565b92611ee1611e68565b936084356001600160401b0381116105d157611f0190369060040161076f565b90949060a435611f0f6117b2565b611f17611e77565b916101043561012435999094906001600160401b038b116105d15761076b9b611f47611f5d9c3690600401610d33565b999098611f526117bf565b9b610164359d6146b7565b6040519081529081906020820190565b346105d15760003660031901126105d1576020604051600b8152f35b346105d15760003660031901126105d157611fa2614e32565b611faa614d0d565b600160ff1960055416176005557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b602081526060604061200084518360208601526080850190610713565b936020810151151582850152015191015290565b346105d15760203660031901126105d15760ff6004356120338161138a565b60006040805161204281610e56565b60608152826020820152015216600052600960205261076b604060002060026040519161206e83610e56565b6040516120868161207f8185611d56565b0382610e92565b835260ff600182015416151560208401520154604082015260405191829182611fe3565b346105d15760003660031901126105d157602060405160168152f35b346105d15760203660031901126105d1576004356120e38161138a565b6120eb614dda565b60ff811690811580156121a6575b61219557612116600161210b83611d09565b01805460ff19169055565b60065460015b81811061214b5783600080516020615d498339815191526118a461213f86611d09565b604051918291826148d5565b808461216b61216561215e600195612708565b5460ff1690565b60ff1690565b14612177575b0161211c565b61219061218382612708565b805463ff00000019169055565b612171565b636b3ac97b60e11b60005260046000fd5b506121b661216560075460ff1690565b8210156120f9565b346105d15760403660031901126105d157602060ff6121f36004356121e16105d6565b90600052600384526040600020611940565b54166040519015158152f35b346105d15760003660031901126105d157602060405160088152f35b346105d15760003660031901126105d157602060405160048152f35b346105d15760003660031901126105d1576020600b5460601c604051908152f35b346105d15760203660031901126105d157602060ff6004356122798161138a565b1660158110159081612291575b506040519015158152f35b601e9150111538612286565b346105d15760003660031901126105d157602060405160008152f35b346105d15760403660031901126105d1576122d26105bb565b6024356122de816117a8565b60ff600d5460a01c16612362575b6001600160a01b03821691821561234d578161231861231d923360005260016020526040600020611940565b613c00565b60405190151581527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160203392a3005b62ced3e160e81b600052600060045260246000fd5b61236b8261534d565b6122ec565b346105d15760203660031901126105d1576123896105bb565b612391614dda565b600e80546001600160a01b039283166001600160a01b0319821681179092559091167f769910e94ac27ed200e1d1600628cdf76c85900b5011ea093a6a00edb9564033600080a3005b602081016020825282518091526040820191602060408360051b8301019401926000915b83831061240d57505050505090565b909192939460208061242b600193603f19868203018752895161113b565b970193019301919392906123fe565b346105d15761244836610c6b565b9061245282610ed6565b916124606040519384610e92565b808352601f1961246f82610ed6565b0160005b8181106124cf57505060005b818110612494576040518061076b86826123da565b806124b36124ae6124a8600194868861385c565b35612708565b614443565b6124bd828761460a565b526124c8818661460a565b500161247f565b6020906124da613dbb565b82828801015201612473565b346105d15760003660031901126105d157602060405160038152f35b346105d15760003660031901126105d157600b546040516001600160601b039091168152602090f35b346105d15760403660031901126105d1576125446105bb565b60243590612551826117a8565b612559614dda565b6001600160a01b031690811561168c5760207f8c8e13f02021bf1f396c6c75b2b9f60e00b992612bc1ba1654a38025cd4704779183600052600a82526125a3816040600020613c00565b6040519015158152a2005b346105d15760203660031901126105d1577f2494457da7b4d830d1d7068d3a8f70d04121c4e4760cd189f8caaa151813d8e060206004356125ee816117a8565b6125f6614dda565b1515600d5460ff60a01b8260a01b169060ff60a01b191617600d55604051908152a1005b346105d15760403660031901126105d157600435602435612639614dda565b81158015612693575b6109f15781600052600860205260016040600020018054918201809211610e3b57817fef18524e45a9c3793f74939b40ae82cfa0160b2993a65ceee104545152736f879260209255604051908152a2005b50600654821015612642565b346105d15760003660031901126105d157602060ff60075416604051908152f35b346105d15760203660031901126105d157600435801580156126fc575b6109f15760005260086020526020600160406000200154604051908152f35b506006548110156126dd565b6000526008602052604060002090565b6000526000602052604060002090565b9b9895919461276a6127ad9b9895610f549f9d9a978f61276261277d9860ff606094816127739a16855216602084015260408301906110e0565b019015159052565b151560808d0152565b60a08b01906110f7565b60c089015260e08801526101008701526101208601526101408501526101a06101608501526101a0840190610713565b91610180818403910152610713565b346105d15760203660031901126105d15760043560005260086020526040600020805461076b6127f08260ff9060201c1690565b92602883901c60ff169060018101546002820154600383015460048401549160058501549361282d600761282660068901611dd9565b9701611dd9565b966040519a8a60ff8d9c60181c169060ff8160101c16908d60ff808360081c16921690612728565b346105d15760003660031901126105d157602060405160058152f35b346105d15760403660031901126105d15761288a6105bb565b602435906001600160601b038216908183036105d1576128a8614dda565b6001600160a01b03811692831561168c5761271083116129155760609190911b6001600160601b031916909117600b556040516001600160601b039190911681527f8039bd6e4e7dba001c8840eb2e118d9d131246faa7d0d04335f7305127ec0b109080602081016118a4565b63012b44a960e51b60005260046000fd5b346105d15760603660031901126105d1576004356129438161138a565b6024356001600160401b0381116105d157612962903690600401610d33565b60ff60443593612971856117a8565b612979614dda565b169182158015612a92575b6121955760008381526009602052604090206001600160401b038311610e71576129b2836118598354611d1c565b6000601f8411600114612a0d57946129f68160016118a4946129ed8880600080516020615d498339815191529b9c600091612a025750613b36565b81555b01613c00565b604051938493846148ed565b90508901353861188f565b601f19841690612a2283600052602060002090565b91815b818110612a7a57509660016118a49482946129f69489600080516020615d498339815191529b9c10612a60575b50508188811b0181556129f0565b88013560001960038b901b60f8161c191690553880612a52565b91926020600181928689013581550194019201612a25565b5060ff60075416831015612984565b346105d15760003660031901126105d157602060405160078152f35b346105d157612acb36610a1f565b90612ad4614d67565b612adc614d2a565b80158015612be9575b6109f157600091612af582612708565b93612b0861098a865460ff9060201c1690565b612bd85761076b94612b1b8385846153ec565b60038101612b2a8482546136ab565b9055805460019060281c60ff16612b40816110ed565b1480612bcb575b612b8b575b600401546040516001600160a01b0390921692600080516020615da983398151915292918291612b7e91889184612cf9565b0390a3611f5d6001600455565b9350600080516020615da983398151915290612bc060048601612baf858254614f72565b5484612bb9613951565b9184614fcb565b919384929150612b4c565b5060048101541515612b47565b63021d672760e11b60005260046000fd5b50600654811015612ae5565b346105d15760003660031901126105d1576020604051600080516020615de98339815191528152f35b346105d15760403660031901126105d157610019600435612c3d6105d6565b90612c4a61107c826139ca565b615081565b346105d157612c5d36611ab4565b91612c69949394614d67565b612c71614d0d565b612c79614d2a565b828103610a0e57612c8984614ee0565b60005b818110612ccf575090612ca7612cc895612caf933691610eed565b923691610eed565b9060405192612cbf602085610e92565b60008452614d4c565b6001600455005b80612cf3612ce0600193858a61385c565b35612cec83888861385c565b3590614f72565b01612c8c565b6040919493926060820195825260208201520152565b346105d15760203660031901126105d15760043580158015612e52575b6109f15760005260086020526040600020612d45610ec6565b612db3612daa8354612d61612d5a8260ff1690565b60ff168552565b60ff600882901c166020850152612d82601082901c60ff1660408601613e2c565b612d96601882901c60ff1615156060860152565b6112c1602082901c60ff1615156080860152565b60a08301613e38565b600182015460c082015260028201549060e081019182526101a0612e206008600386015495610100850196875260048101546101208601526005810154610140860152612e0260068201611dd9565b610160860152612e1460078201611dd9565b61018086015201613e44565b9101525190519081811115612e485761076b612e3c838361363a565b60405193849384612cf9565b61076b6000612e3c565b50600654811015612d2c565b346105d15760403660031901126105d157600435602435612e7d614d0d565b612e85614d2a565b612e9081151561386c565b81158015612fa7575b6109f157612ea682612708565b8054612eb69060181c60ff161590565b6109e05760028101612ec98382546136ab565b91600181015483116109cf57836005612ee39201546138b8565b9081612f2e575b90600080516020615e0983398151915292612f219255612f13612f0b613951565b858733614fcb565b6040519182913395836139b9565b0390a36100196001600455565b90612f6e92602082612f4461089f600c54611086565b612f4f600d54611086565b60006040518099819582946323b872dd60e01b845233600485016138e0565b03925af192831561093657612f9d612f2194600080516020615e0983398151915296600091610907575061390e565b9192509250612eea565b50600654821015612e99565b346105d15760003660031901126105d1576020604051600080516020615dc98339815191528152f35b346105d15760603660031901126105d157612ff56105bb565b612ffd6105d6565b60443591613009614dda565b613011614d2a565b6001600160a01b0382161561168c576001600160a01b0381166130535750600080806130499481945af161304361490e565b50614982565b6100196001600455565b600091908291826130826130906130a897604051928391602083019663a9059cbb60e01b885260248401610c24565b03601f198101835282610e92565b51925af161309c61490e565b816130ad575b5061493e565b613049565b80518015925082156130c2575b5050386130a2565b6130d592506020809183010191016138cb565b38806130ba565b346105d15760403660031901126105d157602060ff6121f36130fc6105bb565b6131046105d6565b6001600160a01b0390911660009081526001855260409020611940565b346105d15760003660031901126105d157602060405160018152f35b346105d15760203660031901126105d1576131566105bb565b61315e614dda565b6001600160a01b0316801561168c57600d80546001600160a01b031916821790557f7dae230f18360d76a040c81f050aa14eb9d6dc7901b20fc5d855e2a20fe814d1600080a2005b346105d15760a03660031901126105d1576131bf6105bb565b6131c76105d6565b60443590606435926084356001600160401b0381116105d1576131ee903690600401610fa9565b9260ff600d5460a01c16806132a2575b613294575b6001600160a01b0382163381141580613272575b61325a576001600160a01b038416156132445715611bef576100199461323c91615873565b9290916156a8565b632bfa23e760e11b600052600060045260246000fd5b63711bec9160e11b6000523360045260245260446000fd5b5080600052600160205260ff61328c336040600020611940565b541615613217565b61329d33614ff1565b613203565b506001600160a01b0382163314156131fe565b346105d15760803660031901126105d1576004356024356132d5816117a8565b6132dd611e86565b90606435926132ea614dda565b8015801561331f575b6109f15760049261331b916000526008602052613315604060002093846149c4565b826149e1565b0155005b506006548110156132f3565b346105d15761335661333c36610a1f565b8181949293613349614d67565b613351614d2a565b6153ec565b8015158061338e575b61336a576001600455005b600052600860205260036040600020018054918201809211610e3b57553880612cc8565b50600654811061335f565b346105d15760003660031901126105d157602060405160028152f35b346105d15760003660031901126105d157600e546040516001600160a01b039091168152602090f35b346105d15760003660031901126105d157602060ff600d5460a01c166040519015158152f35b909161341b610f549360408452604084019061151f565b91602081840391015261151f565b346105d15761343736611ab4565b9291613441614d67565b613449614d2a565b838103610a0e5761345f92612ca7913691610eed565b9061346a81516145d8565b91815190613477826145d8565b9460065460005b8481106134a05787876134916001600455565b61076b60405192839283613404565b6134aa818761460a565b5182811591821561360a575b50506109f1576134cf6134c9828861460a565b51612708565b906134e261098a835460ff9060201c1690565b612bd8576001916135096134f6838a61460a565b51613501848961460a565b5190876153ec565b613513828761460a565b51613523600383019182546136ab565b90558054839060281c60ff16613538816110ed565b14806135fd575b61359d575b61354e828961460a565b5190600080516020615da98339815191528b61357a856004613570828d61460a565b519501549261460a565b5190613594604051928392898060a01b038c169684612cf9565b0390a30161347e565b600481016135b781546135b0858a61460a565b5190614f72565b6135d681546135c6858a61460a565b516135cf613951565b9189614fcb565b546135e1838b61460a565b526135ec828761460a565b516135f7838c61460a565b52613544565b506004810154151561353f565b1015905082386134b6565b634e487b7160e01b600052601160045260246000fd5b600219810191908211610e3b57565b91908203918211610e3b57565b634e487b7160e01b600052603260045260246000fd5b90815181101561366e570160200190565b613647565b9060018201809211610e3b57565b9060028201809211610e3b57565b9060038201809211610e3b57565b9060048201809211610e3b57565b91908201809211610e3b57565b906136cb602092828151948592016106f0565b0190565b6136e360076136dd83612708565b01611dd9565b805161381d57506136f2614a05565b9060005b613700835161362b565b81101561381857607b60f81b61373761372a61371c848761365d565b516001600160f81b03191690565b6001600160f81b03191690565b14806137f3575b806137ce575b806137a3575b613756576001016136f6565b906130828261379d61378c8661378461377e613778610f549961379d9b614aa8565b97614bbc565b9461369d565b815191614b14565b9160405196879560208701906136b8565b906136b8565b50607d60f81b6001600160f81b03196137c761371c6137c18561368f565b8761365d565b161461374a565b50601960fa1b6001600160f81b03196137ec61371c6137c185613681565b1614613744565b50606960f81b6001600160f81b031961381161371c6137c185613673565b161461373e565b505090565b905090565b1561382957565b60405162461bcd60e51b815260206004820152600b60248201526a08adae0e8f240c4c2e8c6d60ab1b6044820152606490fd5b919081101561366e5760051b0190565b1561387357565b60405162461bcd60e51b815260206004820152601d60248201527f416d6f756e74206d7573742062652067726561746572207468616e20300000006044820152606490fd5b81810292918115918404141715610e3b57565b908160209103126105d15751610f54816117a8565b6001600160a01b03918216815291166020820152604081019190915260600190565b6040513d6000823e3d90fd5b1561391557565b60405162461bcd60e51b815260206004820152601460248201527314139d5d1e881c185e5b595b9d0819985a5b195960621b6044820152606490fd5b60405190613960602083610e92565b60008252565b81835290916001600160fb1b0383116105d15760209260051b809284830137010190565b9594936139a6604094926139b49460608a5260608a0191613966565b918783036020890152613966565b930152565b908152602081019190915260400190565b600052600360205260016040600020015490565b9033600052600a60205260ff60406000205416613a5f57600b54916001600160601b038316908115613a4957613a3091600019819004821115613a3457613a299161271090046138b8565b9260601c90565b9190565b613a4190613a29926138b8565b612710900490565b634e487b7160e01b600052601260045260246000fd5b600b5460601c9150600090565b9063ff000000825491151560181b169063ff0000001916179055565b906040610f5492600081528160208201520190611d56565b818110613aab575050565b60008155600101613aa0565b90601f8211613ac4575050565b610ec49160026000526020600020906020601f840160051c83019310613af2575b601f0160051c0190613aa0565b9091508190613ae5565b9190601f8111613b0b57505050565b610ec4926000526020600020906020601f840160051c83019310613af257601f0160051c0190613aa0565b8160011b916000199060031b1c19161790565b81519192916001600160401b038111610e7157613b7081613b6a8454611d1c565b84613afc565b6020601f8211600114613b97578190613b93939495600092611731575050613b36565b9055565b601f19821690613bac84600052602060002090565b9160005b818110613be857509583600195969710613bcf575b505050811b019055565b015160001960f88460031b161c19169055388080613bc5565b9192602060018192868b015181550194019201613bb0565b9060ff801983541691151516179055565b81518051919291906001600160401b038211610e7157613c3b82613c358654611d1c565b86613afc565b602090601f8311600114613c86578260409360029593613c6393600092611731575050613b36565b84555b613c7f613c766020830151151590565b60018601613c00565b0151910155565b90601f19831691613c9c86600052602060002090565b9260005b818110613ce157509260019285926040966002989610613cc8575b505050811b018455613c66565b015160001960f88460031b161c19169055388080613cbb565b92936020600181928786015181550195019301613ca0565b908060209392818452848401376000828201840152601f01601f1916010190565b916020610f54938181520191613cf9565b9392919060ff600d5460a01c1680613da8575b613d9a575b6001600160a01b0385163381141580613d78575b61325a576001600160a01b038216156132445715611bef57610ec4946156a8565b5080600052600160205260ff613d92336040600020611940565b541615613d57565b613da333614ff1565b613d43565b506001600160a01b038516331415613d3e565b60405190613dc882610e76565b60606101a08360008152600060208201526000604082015260008382015260006080820152600060a0820152600060c0820152600060e082015260006101008201526000610120820152600061014082015282610160820152826101808201520152565b60048210156110db5752565b60028210156110db5752565b60405181548082529092918390613e646020830191600052602060002090565b926000905b80601f83011061427057610ec494549181811061425c575b818110614244575b81811061422c575b818110614214575b8181106141fd575b8181106141e5575b8181106141cd575b8181106141b5575b81811061419d575b818110614185575b81811061416d575b818110614155575b81811061413d575b818110614125575b81811061410d575b8181106140f5575b8181106140dd575b8181106140c5575b8181106140ad575b818110614095575b81811061407d575b818110614065575b81811061404d575b818110614035575b81811061401d575b818110614005575b818110613fed575b818110613fd5575b818110613fbd575b818110613fa5575b818110613f8d575b10613f7f575b500383610e92565b60f81c815260200138613f77565b60f083901c60ff168452926001906020019301613f71565b60e883901c60ff168452926001906020019301613f69565b60e083901c60ff168452926001906020019301613f61565b60d883901c60ff168452926001906020019301613f59565b60d083901c60ff168452926001906020019301613f51565b60c883901c60ff168452926001906020019301613f49565b60c083901c60ff168452926001906020019301613f41565b60b883901c60ff168452926001906020019301613f39565b60b083901c60ff168452926001906020019301613f31565b60a883901c60ff168452926001906020019301613f29565b60a083901c60ff168452926001906020019301613f21565b609883901c60ff168452926001906020019301613f19565b609083901c60ff168452926001906020019301613f11565b608883901c60ff168452926001906020019301613f09565b608083901c60ff168452926001906020019301613f01565b607883901c60ff168452926001906020019301613ef9565b607083901c60ff168452926001906020019301613ef1565b606883901c60ff168452926001906020019301613ee9565b606083901c60ff168452926001906020019301613ee1565b605883901c60ff168452926001906020019301613ed9565b605083901c60ff168452926001906020019301613ed1565b604883901c60ff168452926001906020019301613ec9565b604083901c60ff168452926001906020019301613ec1565b603883901c60ff168452926001906020019301613eb9565b603083901c60ff168452926001906020019301613eb1565b602883901c60ff168452926001906020019301613ea9565b602083811c60ff1685529093600191019301613ea1565b601883901c60ff168452926001906020019301613e99565b601083901c60ff168452926001906020019301613e91565b600883901c60ff168452926001906020019301613e89565b60ff83168452926001906020019301613e81565b91602091935061040060019161443587546142908360ff831660ff169052565b600881901c60ff1683870152601081901c60ff166040840152601881901c60ff16606084015280861c60ff166080840152602881901c60ff1660a0840152603081901c60ff1660c0840152603881901c60ff1660e0840152604081901c60ff16610100840152604881901c60ff16610120840152605081901c60ff16610140840152605881901c60ff16610160840152606081901c60ff16610180840152606881901c60ff166101a0840152607081901c60ff166101c0840152607881901c60ff166101e0840152608081901c60ff16610200840152608881901c60ff16610220840152609081901c60ff16610240840152609881901c60ff1661026084015260a081901c60ff1661028084015260a881901c60ff166102a084015260b081901c60ff166102c084015260b881901c60ff166102e084015260c081901c60ff1661030084015260c881901c60ff1661032084015260d081901c60ff1661034084015260d881901c60ff1661036084015260e081901c60ff1661038084015260e881901c60ff166103a084015260f081901c60ff166103c084015260f81c6103e0830152565b019401920185929391613e69565b906145016008614451610ec6565b936144c06144b7825461446e6144678260ff1690565b60ff168952565b60ff600882901c16602089015261448f601082901c60ff1660408a01613e2c565b6144a3601882901c60ff16151560608a0152565b6112c1602082901c60ff16151560808a0152565b60a08701613e38565b600181015460c0860152600281015460e0860152600381015461010086015260048101546101208601526005810154610140860152612e0260068201611dd9565b6101a0830152565b919091801580156145cc575b6145c4576124ae61452591612708565b9161453661098a6060850151151590565b6145c45760ff8061454b602086015160ff1690565b92169116036145bd5760ff16600181036145a0575060400160018151614570816110d1565b614579816110d1565b14908115614585575090565b6003915051614593816110d1565b61459c816110d1565b1490565b6002146145ad5750600090565b60400160028151614570816110d1565b5050600090565b505050600090565b50600654811015614515565b906145e282610ed6565b6145ef6040519182610e92565b8281528092614600601f1991610ed6565b0190602036910137565b805182101561366e5760209160051b010190565b9190918051835180820361468757505061463881516145d8565b9060005b8151811015614680578061466e60019260051b6020808287010151918901015160005260006020526040600020611940565b54614679828661460a565b520161463c565b5090925050565b635b05999160e01b60005260045260245260446000fd5b604090610f549492151581528160208201520191613cf9565b99939c959a92979894919d969b9d6146cd614dda565b60ff8b168015908115614829575b50612195576146f961098a60016146f18e611d09565b015460ff1690565b612195578c15614818578d60ff8a16614808575b5061471b600a8d11156150f6565b60005b8c8082106147a4575050369061473392610f72565b99369061473f92614842565b9b369061474b92610f72565b91868a6006549d8e9d8e998d8d6147618d614898565b60065561476d9c6152a7565b60405193849361477d93856148a7565b037fa3c42004ac018ce69d8909dc090172edb94410550cbf5ec3bdeb9439fee4d1c991a290565b6121656147b5836147ba938861385c565b61513a565b60ff8b1681146147f75780159081156147ec575b506147db5760010161471e565b6303780dc560e41b60005260046000fd5b6028915011386147ce565b63bfc0bebd60e01b60005260046000fd5b614812908a615898565b8d61470d565b6315ae672760e01b60005260046000fd5b905061483a61216560075460ff1690565b1115386146db565b92919061484e81610ed6565b9361485c6040519586610e92565b602085838152019160051b81019283116105d157905b82821061487e57505050565b60208091833561488d8161138a565b815201910190614872565b6000198114610e3b5760010190565b9294939060609260ff6148c892168552608060208601526080850190610713565b9460408401521515910152565b919060206139b4600092604086526040860190611d56565b9160209161490691959495604085526040850191613cf9565b931515910152565b3d15614939573d9061491f82610f57565b9161492d6040519384610e92565b82523d6000602084013e565b606090565b1561494557565b60405162461bcd60e51b8152602060048201526015602482015274151bdad95b881d1c985b9cd9995c8819985a5b1959605a1b6044820152606490fd5b1561498957565b60405162461bcd60e51b8152602060048201526013602482015272115512081d1c985b9cd9995c8819985a5b1959606a1b6044820152606490fd5b805460ff60201b191691151560201b60ff60201b16919091179055565b9060028110156110db57815460ff60281b191660289190911b60ff60281b16179055565b604051600254816000614a1783611d1c565b8083529260018116908115614a895750600114614a3b575b610f5492500382610e92565b50600260009081529091600080516020615d698339815191525b818310614a6d575050906020610f5492820101614a2f565b6020919350806001915483858801015201910190918392614a55565b60209250610f5494915060ff191682840152151560051b820101614a2f565b9190614ab381610f57565b90614ac16040519283610e92565b808252601f19614ad082610f57565b0136602084013760005b818110614ae8575090925050565b6001906001600160f81b0319614afe828861365d565b511660001a614b0d828661365d565b5301614ada565b9181810392818411610e3b57614b2984610f57565b93614b376040519586610e92565b808552614b46601f1991610f57565b01366020860137825b828110614b5d575050505090565b6001600160f81b0319614b70828461365d565b511690848103818111610e3b57614b8d60019360001a918861365d565b5301614b4f565b90614b9e82610f57565b614bab6040519182610e92565b8281528092614600601f1991610f57565b6000908072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b811015614cea575b600a906904ee2d6d415b85acef8160201b811015614ccf575b662386f26fc10000811015614cba575b6305f5e100811015614ca8575b612710811015614c98575b6064811015614c89575b1015614c7e575b614c6e6021614c4260018501614b94565b938401015b60001901916f181899199a1a9b1b9c1cb0b131b232b360811b600a82061a8353600a900490565b801561381857614c6e9091614c47565b600190910190614c31565b60029060649004930192614c2a565b6004906127109004930192614c20565b6008906305f5e1009004930192614c15565b601090662386f26fc100009004930192614c08565b6020906904ee2d6d415b85acef8160201b9004930192614bf8565b506040915072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8104614bdf565b60ff60055416614d1957565b63d93c066560e01b60005260046000fd5b600260045414614d3b576002600455565b633ee5aeb560e01b60005260046000fd5b9291906001600160a01b0384161561324457610ec49361557d565b600080516020615de9833981519152600052600360205260ff614daa337f5562e70da342db81569f3094d36be279beaca7ad8e08f434ea188e79d2bfe10c611940565b541615614db357565b63e2517d3f60e01b60005233600452600080516020615de983398151915260245260446000fd5b60008052600360205260ff614e0f337f3617319a054d772f909f7c479a2cebe5066e836a939412e32403c99029b92eff611940565b541615614e1857565b63e2517d3f60e01b60005233600452600060245260446000fd5b600080516020615dc9833981519152600052600360205260ff614e75337f30adeb818ef77f204f5a603c30fa5332397b6e28fb3b7f9d937ae6a6914716de611940565b541615614e7e57565b63e2517d3f60e01b60005233600452600080516020615dc983398151915260245260446000fd5b80600052600360205260ff614ebe336040600020611940565b541615614ec85750565b63e2517d3f60e01b6000523360045260245260446000fd5b803b15614f6f576040516301ffc9a760e01b8152630271189760e51b600482015290602090829060249082906001600160a01b03165afa60009181614f4e575b50614f365763dcbdf9e760e01b60005260046000fd5b15614f3d57565b63dcbdf9e760e01b60005260046000fd5b614f6891925060203d60201161092f576109218183610e92565b9038614f20565b50565b80158015614fbf575b6109f1576000526008602052604060002090614f9e60ff835460181c1615151590565b6109e0576001614fb3600284019283546136ab565b92015482116109cf5755565b50600654811015614f7b565b919291906001600160a01b0382161561324457610ec493614feb91615873565b9161557d565b60ff600d5460a01c166150015750565b610ec49061534d565b80600052600360205260ff615023836040600020611940565b54166145bd57806000526003602052615040826040600020611940565b805460ff1916600117905533916001600160a01b0316907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d600080a4600190565b80600052600360205260ff61509a836040600020611940565b5416156145bd578060005260036020526150b8826040600020611940565b805460ff1916905533916001600160a01b0316907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b600080a4600190565b156150fd57565b60405162461bcd60e51b81526020600482015260156024820152744d617820313020636f6e666c69637420736c6f747360581b6044820152606490fd5b35610f548161138a565b9060048110156110db5762ff000082549160101b169062ff00001916179055565b90600160401b8111610e7157815481835580821061518257505050565b610ec492600052601f6020600020918180850160051c84019416806151ae575b500160051c0190613aa0565b6000198501908154906000199060200360031b1c169055386151a2565b815190916001600160401b038211610e715760206151fa916151ed8486615165565b0192600052602060002090565b8160051c9160005b83811061526f5750601f19811690038061521d575b50505050565b9260009360005b81811061523957505050015538808080615217565b9091946020615265600192846152508a5160ff1690565b919060ff809160031b9316831b921b19161790565b9601929101615224565b6000805b60208110615288575083820155600101615202565b9590602061529e60019289615250865160ff1690565b92019601615273565b9b97949b9a92909a9896939198600052600860205260406000209a60ff1660ff198c5416178b558a549060081b61ff00169061ff001916178a556152eb908a615144565b6152f59089613a6c565b6152ff90886149c4565b61530990876149e1565b60018601556000600286018190556003860155600485015560058401556153339060068401613b49565b6153409060078301613b49565b60080190610ec4916151cb565b6daaeb6d7670e522a718067333cd4e3b6153645750565b604051633185c44d60e21b81523060048201526001600160a01b03821660248201526020816044816daaeb6d7670e522a718067333cd4e5afa908115610936576000916153cd575b50156153b55750565b633b79c77360e21b6000526153c9906119b9565b6000fd5b6153e6915060203d60201161092f576109218183610e92565b386153ac565b906001600160a01b03821615611bef57610ec49261540991615873565b9060405192611b76602085610e92565b909250615424614d0d565b82518251908181036155665750506001600160a01b0381168015159490939060005b82518110156154ca578060051b876020808387010151928801015190615471575b5050600101615446565b6154838661547e84612718565b611940565b548181106154a7578661547e600195949361549f930393612718565b559038615467565b866154c684846040519485946303dee4c560e01b865260048601615bbc565b0390fd5b50949091936000906001845114821461553e576020840151600080516020615d2983398151915261550760208801516040519182913395836139b9565b0390a45b8080615535575b8161552d575b5061552257505050565b6000610ec493615be0565b905038615518565b60009150615512565b604051600080516020615ce983398151915233918061555e898983613404565b0390a461550b565b635b05999160e01b60005260045260245260446000fd5b93929190615589614d0d565b80518251908181036155665750506001600160a01b038516938415159360005b83518110156155f95780868960019360051b602080828a010151918a010151926155d7575b505050016155a9565b6155ef9161547e6155e792612718565b9182546136ab565b90553889816155ce565b5093909594600183511460001461567e5760006020840151600080516020615d2983398151915261563660208801516040519182913395836139b9565b0390a45b6156445750505050565b805160010361566d57906020806156649593015191015191600033615b1c565b38808080615217565b615679936000336159fa565b615664565b6000604051600080516020615ce98339815191523391806156a0898983613404565b0390a461563a565b9493929091936156b6614d0d565b84518251908181036155665750506001600160a01b0386811695861515959185168015159391929060005b845181101561578a578060051b90898988602080868b010151958c01015192615731575b93600194615717575b505050016156e1565b6157279161547e6155e792612718565b905538898161570e565b505090916157428d61547e83612718565b5482811061576b578291898f615762600197968f95039161547e85612718565b55909450615705565b8d6154c683856040519485946303dee4c560e01b865260048601615bbc565b509096919895939297600189511460001461584957818160208b0151600080516020615d298339815191526157cb60208b01516040519182913395836139b9565b0390a45b82615841575b82615836575b5050615825575b6157ee575b5050505050565b84516001036158145760208061580a9601519201519233615b1c565b38808080806157e7565b615820949192336159fa565b61580a565b61583183878487615be0565b6157e2565b1415905038806157db565b8392506157d5565b81818a600080516020615ce98339815191526040518061586b8c339583613404565b0390a46157cf565b9160405192600184526020840152604083019160018352606084015260808301604052565b906158a2816110d1565b80156158f5576158b1816110d1565b60018114801561597f575b615926575b6158ca816110d1565b60028114908115615912575b506158de5750565b60ff1660158110159081615906575b50156158f557565b637d7b22cf60e11b60005260046000fd5b601e91501115386158ed565b6003915061591f816110d1565b14386158d6565b60ff821660018110159081615973575b8115615953575b506158c157637d7b22cf60e11b60005260046000fd5b601f811015915081615967575b503861593d565b60289150111538615960565b60148111159150615936565b50615989816110d1565b600381146158bc565b908160209103126105d15751610f548161063b565b6001600160a01b0391821681529116602082015260a060408201819052610f5494919391926159ec92916159de919086019061151f565b90848203606086015261151f565b916080818403910152610713565b9091949293853b615a0e575b505050505050565b602093615a3091604051968795869563bc197c8160e01b8752600487016159a7565b038160006001600160a01b0387165af160009181615ab2575b50615a7b5750615a5761490e565b8051919082615a7457632bfa23e760e11b6000526153c9826119b9565b6020915001fd5b6001600160e01b0319166343e6837f60e01b01615a9e5750388080808080615a06565b632bfa23e760e11b6000526153c9906119b9565b615ad591925060203d602011615adc575b615acd8183610e92565b810190615992565b9038615a49565b503d615ac3565b6001600160a01b039182168152911660208201526040810191909152606081019190915260a060808201819052610f5492910190610713565b9091949293853b615b2f57505050505050565b602093615b5191604051968795869563f23a6e6160e01b875260048701615ae3565b038160006001600160a01b0387165af160009181615b9b575b50615b785750615a5761490e565b6001600160e01b031916630dc5919f60e01b01615a9e5750388080808080615a06565b615bb591925060203d602011615adc57615acd8183610e92565b9038615b6a565b90949392606092608083019660018060a01b03168352602083015260408201520152565b909392919360018060a01b03615bf7600e54611086565b1615615ce15760005b8551811015615cd95780615c166001928861460a565b51615c21828761460a565b518015615cd257600080615c36600e54611086565b60405163c16ec6dd60e01b602082019081526001600160a01b03808c1660248401528a1660448301526064820187905260848201869052908390615c7d8160a48101613082565b51925af1615c8961490e565b5015615cd25760405190815260a084901b84900385811691908716907f51e866c8533d4385f872db5ecbbc78914e718cec9fa5481105c30369d8c22e7f90602090a45b01615c00565b5050615ccc565b505050509050565b505050905056fe4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb26eca058065f266ad114168050ab2d71e8fb15b84a95aad5684bce2e2af8ef8ac3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62ba51f4ef4a9aab57746cf07cdc0402bd05666695385ff9ca304705b57c02b0da405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0bfd84f586f186e4e2a0b575593a4b4b7735b4229f86de082fd9662d9324bb27662e54e548e1246fd88fa9377d2b81bb41d763f54eef72121a5f8029f26728cf65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a69d357202c083ccb2d1379a9af250503bb1cda8e0402c1093fab74b83dd8af89b8079f6073f7ca73569e857af00512eccf66e4b86a5f5b8011a8403354130e4dfa264697066735822122079d5ceccd2207c0d591672fb709c065afd56e8d7a478a214c55fe85568c0e22664736f6c634300081c0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000000000000000000000000000000000000000000e000000000000000000000000042ea0d051206aee8bcd23379939224177a38dc0f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b75a5d2013c9ee66bc5385ce9d845cd518ee16a00000000000000000000000000000000000000000000000000000000000001f400000000000000000000000054a70516e9c0223f4a92be3a4832a06f546e783b0000000000000000000000001b75a5d2013c9ee66bc5385ce9d845cd518ee16a000000000000000000000000000000000000000000000000000000000000003e68747470733a2f2f73746f726167652e676f6f676c65617069732e636f6d2f6765657a2d7075626c69632f7765617261626c65732f6d65746164617461340000
-----Decoded View---------------
Arg [0] : baseURI_ (string): https://storage.googleapis.com/geez-public/wearables/metadata4
Arg [1] : admin_ (address): 0x42ea0D051206aeE8bcd23379939224177A38DC0f
Arg [2] : officialMarketplace_ (address): 0x0000000000000000000000000000000000000000
Arg [3] : royaltyReceiver_ (address): 0x1B75A5D2013c9ee66bC5385Ce9D845CD518eE16a
Arg [4] : externalRoyaltyBps_ (uint96): 500
Arg [5] : pnutz_ (address): 0x54A70516e9c0223F4a92bE3a4832a06f546e783B
Arg [6] : treasury_ (address): 0x1B75A5D2013c9ee66bC5385Ce9D845CD518eE16a
-----Encoded View---------------
10 Constructor Arguments found :
Arg [0] : 00000000000000000000000000000000000000000000000000000000000000e0
Arg [1] : 00000000000000000000000042ea0d051206aee8bcd23379939224177a38dc0f
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [3] : 0000000000000000000000001b75a5d2013c9ee66bc5385ce9d845cd518ee16a
Arg [4] : 00000000000000000000000000000000000000000000000000000000000001f4
Arg [5] : 00000000000000000000000054a70516e9c0223f4a92be3a4832a06f546e783b
Arg [6] : 0000000000000000000000001b75a5d2013c9ee66bc5385ce9d845cd518ee16a
Arg [7] : 000000000000000000000000000000000000000000000000000000000000003e
Arg [8] : 68747470733a2f2f73746f726167652e676f6f676c65617069732e636f6d2f67
Arg [9] : 65657a2d7075626c69632f7765617261626c65732f6d65746164617461340000
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.