Source Code
Overview
POL Balance
More Info
ContractCreator
Multichain Info
N/A
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Source Code Verified (Exact Match)
Contract Name:
MusicalToken
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
No with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.22; import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155URIStorageUpgradeable.sol"; import {ERC1155BurnableUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155BurnableUpgradeable.sol"; import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; /// @title MusicalToken - An ERC1155 Token Contract with Custom Royalty Management /// @notice This contract allows minting of ERC1155 tokens with extended royalty management capabilities /// @dev Implements UUPSUpgradeable and royalty features contract MusicalToken is Initializable, ERC1155URIStorageUpgradeable, ERC1155BurnableUpgradeable, OwnableUpgradeable, UUPSUpgradeable { uint256 public nextTokenId; uint256 public constant MAX_ROYALTY_PERCENTAGE = 2000; // max 20% can be distributed as royalty uint96 public constant FEE_DENOMINATOR = 10000; address public marketplace; struct RoyaltyInfo { address[] recipients; uint256[] percentages; uint256 totalPercentage; } mapping(uint256 => address) public tokenRoyaltyManager; mapping(uint256 => RoyaltyInfo) private royalties; event RoyaltyRecipientsAdded( uint256 tokenId, address[] recipients, uint256[] percentages ); event RoyaltyRecipientRemoved(uint256 tokenId, address recipient); event RoyaltyManagementTransferred( uint256 tokenId, address oldManager, address newManager ); // errors error UnauthorizedAccess(address caller); error InvalidAddress(address addr); error TotalRoyaltyExceedsLimit(uint256 attempted, uint256 max); error RecipientsAndPercentagesMismatch(); error RecipientNotFound(address recipient); /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } /// @notice Initializes the contract with an owner /// @param _initialOwner The initial owner of the contract function initialize( address _initialOwner, string memory _baseURI ) public initializer { __ERC1155_init(""); _setBaseURI(_baseURI); __Ownable_init(_initialOwner); __ERC1155Burnable_init(); __UUPSUpgradeable_init(); } /// @notice Mints a new token to the specified address /// @param _to The address to receive the minted token /// @param _tokenURI The URI for the token's metadata function mint( address _to, uint256 _amount, string memory _tokenURI ) external { if (address(_to) == address(0)) { revert InvalidAddress(_to); } uint256 tokenId = nextTokenId++; _mint(_to, tokenId, _amount, ""); _setURI(tokenId, _tokenURI); tokenRoyaltyManager[tokenId] = _to; } /// @notice to update the base uri contract /// @dev only owner will be able to call this function /// @param _baseURI URI of base nft metadata function updateBaseURI(string memory _baseURI) external onlyOwner { _setBaseURI(_baseURI); } /// @notice to set theb marketplace contract address /// @dev only owner will be able to call this function /// @param _marketplace marketplace contract address function setMarketplaceContractAddress( address _marketplace ) external onlyOwner { marketplace = _marketplace; } /// @notice Adds royalty recipients and percentages to a token /// @dev Ensures the total percentage does not exceed MAX_ROYALTY_PERCENTAGE /// @param _tokenId The ID of the token /// @param _recipients Array of addresses to receive royalties /// @param _percentages Array of percentages corresponding to each recipient function addRoyaltyRecipients( uint256 _tokenId, address[] calldata _recipients, uint256[] calldata _percentages ) external { if (msg.sender != tokenRoyaltyManager[_tokenId]) { revert UnauthorizedAccess(msg.sender); } if (_recipients.length != _percentages.length) { revert RecipientsAndPercentagesMismatch(); } RoyaltyInfo storage info = royalties[_tokenId]; uint256 currentTotalPercentage = 0; uint256 oldTotalPercentage = getRoyaltyTotalPercentage(_tokenId); for (uint256 i = 0; i < _recipients.length; i++) { require(_percentages[i] > 0, "Percentage must be greater than 0"); currentTotalPercentage += _percentages[i]; if ( currentTotalPercentage + oldTotalPercentage > MAX_ROYALTY_PERCENTAGE ) { revert TotalRoyaltyExceedsLimit( currentTotalPercentage + oldTotalPercentage, MAX_ROYALTY_PERCENTAGE ); } // Enforce max royalty limit // Append new recipient and percentage to arrays info.recipients.push(_recipients[i]); info.percentages.push(_percentages[i]); } info.totalPercentage += currentTotalPercentage; emit RoyaltyRecipientsAdded(_tokenId, _recipients, _percentages); } /// @notice Returns the total royalty percentage for a token /// @param _tokenId The ID of the token /// @return The total royalty percentage in basis points function getRoyaltyTotalPercentage( uint256 _tokenId ) public view returns (uint256) { RoyaltyInfo memory info = royalties[_tokenId]; return info.totalPercentage; } /// @notice Removes a royalty recipient from a token /// @param _tokenId The ID of the token /// @param _recipient The address of the recipient to remove function removeRoyaltyRecipient( uint256 _tokenId, address _recipient ) external { if (msg.sender != tokenRoyaltyManager[_tokenId]) { revert UnauthorizedAccess(msg.sender); } RoyaltyInfo storage info = royalties[_tokenId]; uint256 length = info.recipients.length; for (uint256 i = 0; i < length; i++) { if (info.recipients[i] == _recipient) { info.totalPercentage -= info.percentages[i]; info.recipients[i] = info.recipients[length - 1]; info.percentages[i] = info.percentages[length - 1]; info.recipients.pop(); info.percentages.pop(); emit RoyaltyRecipientRemoved(_tokenId, _recipient); return; } } revert RecipientNotFound(_recipient); } /// @notice Transfers royalty management of a token to a new manager /// @param _tokenId The ID of the token /// @param _newManager The address of the new manager function transferRoyaltyManagement( uint256 _tokenId, address _newManager ) external { if (msg.sender != marketplace) { revert UnauthorizedAccess(msg.sender); } if (_newManager == address(0)) { revert InvalidAddress(_newManager); } address oldManager = tokenRoyaltyManager[_tokenId]; tokenRoyaltyManager[_tokenId] = _newManager; delete royalties[_tokenId]; emit RoyaltyManagementTransferred(_tokenId, oldManager, _newManager); } /// @notice Fetches royalty information for a token /// @param _tokenId The ID of the token /// @return recipients Array of royalty recipient addresses /// @return percentages Array of royalty percentages /// @return totalPercentage Total royalty percentage in basis points function getRoyaltyInfo( uint256 _tokenId ) external view returns ( address[] memory recipients, uint256[] memory percentages, uint256 totalPercentage ) { RoyaltyInfo memory info = royalties[_tokenId]; return (info.recipients, info.percentages, info.totalPercentage); } /// @notice Overrides the uri function to use ERC155URIStorage /// @param _tokenId The ID of the token /// @return The URI of the token function uri( uint256 _tokenId ) public view override(ERC1155Upgradeable, ERC1155URIStorageUpgradeable) returns (string memory) { return super.uri(_tokenId); } /// @notice Authorizes contract upgrades /// @param newImplementation The address of the new implementation function _authorizeUpgrade( address newImplementation ) internal override onlyOwner {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is set to the address provided by the deployer. This can * later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { /// @custom:storage-location erc7201:openzeppelin.storage.Ownable struct OwnableStorage { address _owner; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300; function _getOwnableStorage() private pure returns (OwnableStorage storage $) { assembly { $.slot := OwnableStorageLocation } } /** * @dev The caller account is not authorized to perform an operation. */ error OwnableUnauthorizedAccount(address account); /** * @dev The owner is not a valid owner account. (eg. `address(0)`) */ error OwnableInvalidOwner(address owner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the address provided by the deployer as the initial owner. */ function __Ownable_init(address initialOwner) internal onlyInitializing { __Ownable_init_unchained(initialOwner); } function __Ownable_init_unchained(address initialOwner) internal onlyInitializing { if (initialOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(initialOwner); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { OwnableStorage storage $ = _getOwnableStorage(); return $._owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { if (owner() != _msgSender()) { revert OwnableUnauthorizedAccount(_msgSender()); } } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { if (newOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { OwnableStorage storage $ = _getOwnableStorage(); address oldOwner = $._owner; $._owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.20; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Storage of the initializable contract. * * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions * when using with upgradeable contracts. * * @custom:storage-location erc7201:openzeppelin.storage.Initializable */ struct InitializableStorage { /** * @dev Indicates that the contract has been initialized. */ uint64 _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool _initializing; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00; /** * @dev The contract is already initialized. */ error InvalidInitialization(); /** * @dev The contract is not initializing. */ error NotInitializing(); /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint64 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in * production. * * Emits an {Initialized} event. */ modifier initializer() { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); // Cache values to avoid duplicated sloads bool isTopLevelCall = !$._initializing; uint64 initialized = $._initialized; // Allowed calls: // - initialSetup: the contract is not in the initializing state and no previous version was // initialized // - construction: the contract is initialized at version 1 (no reininitialization) and the // current contract is just being deployed bool initialSetup = initialized == 0 && isTopLevelCall; bool construction = initialized == 1 && address(this).code.length == 0; if (!initialSetup && !construction) { revert InvalidInitialization(); } $._initialized = 1; if (isTopLevelCall) { $._initializing = true; } _; if (isTopLevelCall) { $._initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint64 version) { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing || $._initialized >= version) { revert InvalidInitialization(); } $._initialized = version; $._initializing = true; _; $._initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { _checkInitializing(); _; } /** * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}. */ function _checkInitializing() internal view virtual { if (!_isInitializing()) { revert NotInitializing(); } } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing) { revert InvalidInitialization(); } if ($._initialized != type(uint64).max) { $._initialized = type(uint64).max; emit Initialized(type(uint64).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint64) { return _getInitializableStorage()._initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _getInitializableStorage()._initializing; } /** * @dev Returns a pointer to the storage namespace. */ // solhint-disable-next-line var-name-mixedcase function _getInitializableStorage() private pure returns (InitializableStorage storage $) { assembly { $.slot := INITIALIZABLE_STORAGE } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.20; import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol"; import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol"; import {Initializable} from "./Initializable.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. */ abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable { /// @custom:oz-upgrades-unsafe-allow state-variable-immutable address private immutable __self = address(this); /** * @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)` * and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called, * while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string. * If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must * be the empty byte string if no function should be called, making it impossible to invoke the `receive` function * during an upgrade. */ string public constant UPGRADE_INTERFACE_VERSION = "5.0.0"; /** * @dev The call is from an unauthorized context. */ error UUPSUnauthorizedCallContext(); /** * @dev The storage `slot` is unsupported as a UUID. */ error UUPSUnsupportedProxiableUUID(bytes32 slot); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC-1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC-1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { _checkProxy(); _; } /** * @dev Check that the execution is not being performed through a delegate call. This allows a function to be * callable on the implementing contract but not through proxies. */ modifier notDelegated() { _checkNotDelegated(); _; } function __UUPSUpgradeable_init() internal onlyInitializing { } function __UUPSUpgradeable_init_unchained() internal onlyInitializing { } /** * @dev Implementation of the ERC-1822 {proxiableUUID} function. This returns the storage slot used by the * implementation. It is used to validate the implementation's compatibility when performing an upgrade. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier. */ function proxiableUUID() external view virtual notDelegated returns (bytes32) { return ERC1967Utils.IMPLEMENTATION_SLOT; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. * * @custom:oz-upgrades-unsafe-allow-reachable delegatecall */ function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, data); } /** * @dev Reverts if the execution is not performed via delegatecall or the execution * context is not of a proxy with an ERC-1967 compliant implementation pointing to self. * See {_onlyProxy}. */ function _checkProxy() internal view virtual { if ( address(this) == __self || // Must be called through delegatecall ERC1967Utils.getImplementation() != __self // Must be called through an active proxy ) { revert UUPSUnauthorizedCallContext(); } } /** * @dev Reverts if the execution is performed via delegatecall. * See {notDelegated}. */ function _checkNotDelegated() internal view virtual { if (address(this) != __self) { // Must not be called through delegatecall revert UUPSUnauthorizedCallContext(); } } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; /** * @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call. * * As a security check, {proxiableUUID} is invoked in the new implementation, and the return value * is expected to be the implementation slot in ERC-1967. * * Emits an {IERC1967-Upgraded} event. */ function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private { try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) { if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) { revert UUPSUnsupportedProxiableUUID(slot); } ERC1967Utils.upgradeToAndCall(newImplementation, data); } catch { // The implementation is not UUPS revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC1155/ERC1155.sol) pragma solidity ^0.8.20; import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; import {IERC1155MetadataURI} from "@openzeppelin/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol"; import {ERC1155Utils} from "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Utils.sol"; import {ContextUpgradeable} from "../../utils/ContextUpgradeable.sol"; import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import {ERC165Upgradeable} from "../../utils/introspection/ERC165Upgradeable.sol"; import {Arrays} from "@openzeppelin/contracts/utils/Arrays.sol"; import {IERC1155Errors} from "@openzeppelin/contracts/interfaces/draft-IERC6093.sol"; import {Initializable} from "../../proxy/utils/Initializable.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 ERC1155Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC1155, IERC1155MetadataURI, IERC1155Errors { using Arrays for uint256[]; using Arrays for address[]; /// @custom:storage-location erc7201:openzeppelin.storage.ERC1155 struct ERC1155Storage { mapping(uint256 id => mapping(address account => uint256)) _balances; mapping(address account => mapping(address operator => bool)) _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string _uri; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC1155")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ERC1155StorageLocation = 0x88be536d5240c274a3b1d3a1be54482fd9caa294f08c62a7cde569f49a3c4500; function _getERC1155Storage() private pure returns (ERC1155Storage storage $) { assembly { $.slot := ERC1155StorageLocation } } /** * @dev See {_setURI}. */ function __ERC1155_init(string memory uri_) internal onlyInitializing { __ERC1155_init_unchained(uri_); } function __ERC1155_init_unchained(string memory uri_) internal onlyInitializing { _setURI(uri_); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, 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) { ERC1155Storage storage $ = _getERC1155Storage(); return $._uri; } /** * @dev See {IERC1155-balanceOf}. */ function balanceOf(address account, uint256 id) public view virtual returns (uint256) { ERC1155Storage storage $ = _getERC1155Storage(); 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; } /** * @dev See {IERC1155-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC1155-isApprovedForAll}. */ function isApprovedForAll(address account, address operator) public view virtual returns (bool) { ERC1155Storage storage $ = _getERC1155Storage(); return $._operatorApprovals[account][operator]; } /** * @dev See {IERC1155-safeTransferFrom}. */ 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); } /** * @dev See {IERC1155-safeBatchTransferFrom}. */ 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 { ERC1155Storage storage $ = _getERC1155Storage(); 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 { ERC1155Storage storage $ = _getERC1155Storage(); $._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 { ERC1155Storage storage $ = _getERC1155Storage(); 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.0.0) (token/ERC1155/extensions/ERC1155Burnable.sol) pragma solidity ^0.8.20; import {ERC1155Upgradeable} from "../ERC1155Upgradeable.sol"; import {Initializable} from "../../../proxy/utils/Initializable.sol"; /** * @dev Extension of {ERC1155} that allows token holders to destroy both their * own tokens and those that they have been approved to use. */ abstract contract ERC1155BurnableUpgradeable is Initializable, ERC1155Upgradeable { function __ERC1155Burnable_init() internal onlyInitializing { } function __ERC1155Burnable_init_unchained() internal onlyInitializing { } function burn(address account, uint256 id, uint256 value) public virtual { if (account != _msgSender() && !isApprovedForAll(account, _msgSender())) { revert ERC1155MissingApprovalForAll(_msgSender(), account); } _burn(account, id, value); } function burnBatch(address account, uint256[] memory ids, uint256[] memory values) public virtual { if (account != _msgSender() && !isApprovedForAll(account, _msgSender())) { revert ERC1155MissingApprovalForAll(_msgSender(), account); } _burnBatch(account, ids, values); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC1155/extensions/ERC1155URIStorage.sol) pragma solidity ^0.8.20; import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; import {ERC1155Upgradeable} from "../ERC1155Upgradeable.sol"; import {Initializable} from "../../../proxy/utils/Initializable.sol"; /** * @dev ERC-1155 token with storage based token URI management. * Inspired by the {ERC721URIStorage} extension */ abstract contract ERC1155URIStorageUpgradeable is Initializable, ERC1155Upgradeable { using Strings for uint256; /// @custom:storage-location erc7201:openzeppelin.storage.ERC1155URIStorage struct ERC1155URIStorageStorage { // Optional base URI string _baseURI; // Optional mapping for token URIs mapping(uint256 tokenId => string) _tokenURIs; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC1155URIStorage")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ERC1155URIStorageStorageLocation = 0x89fc852226e759c7c636cf34d732f0198fc56a54876b2374a52beb7b0c558600; function _getERC1155URIStorageStorage() private pure returns (ERC1155URIStorageStorage storage $) { assembly { $.slot := ERC1155URIStorageStorageLocation } } function __ERC1155URIStorage_init() internal onlyInitializing { __ERC1155URIStorage_init_unchained(); } function __ERC1155URIStorage_init_unchained() internal onlyInitializing { ERC1155URIStorageStorage storage $ = _getERC1155URIStorageStorage(); $._baseURI = ""; } /** * @dev See {IERC1155MetadataURI-uri}. * * This implementation returns the concatenation of the `_baseURI` * and the token-specific uri if the latter is set * * This enables the following behaviors: * * - if `_tokenURIs[tokenId]` is set, then the result is the concatenation * of `_baseURI` and `_tokenURIs[tokenId]` (keep in mind that `_baseURI` * is empty per default); * * - if `_tokenURIs[tokenId]` is NOT set then we fallback to `super.uri()` * which in most cases will contain `ERC1155._uri`; * * - if `_tokenURIs[tokenId]` is NOT set, and if the parents do not have a * uri value set, then the result is empty. */ function uri(uint256 tokenId) public view virtual override returns (string memory) { ERC1155URIStorageStorage storage $ = _getERC1155URIStorageStorage(); string memory tokenURI = $._tokenURIs[tokenId]; // If token URI is set, concatenate base URI and tokenURI (via string.concat). return bytes(tokenURI).length > 0 ? string.concat($._baseURI, tokenURI) : super.uri(tokenId); } /** * @dev Sets `tokenURI` as the tokenURI of `tokenId`. */ function _setURI(uint256 tokenId, string memory tokenURI) internal virtual { ERC1155URIStorageStorage storage $ = _getERC1155URIStorageStorage(); $._tokenURIs[tokenId] = tokenURI; emit URI(uri(tokenId), tokenId); } /** * @dev Sets `baseURI` as the `_baseURI` for all tokens */ function _setBaseURI(string memory baseURI) internal virtual { ERC1155URIStorageStorage storage $ = _getERC1155URIStorageStorage(); $._baseURI = baseURI; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import {Initializable} from "../../proxy/utils/Initializable.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 ERC165Upgradeable is Initializable, IERC165 { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.20; /** * @dev ERC-1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified * proxy whose upgrades are fully controlled by the current implementation. */ interface IERC1822Proxiable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC6093.sol) pragma solidity ^0.8.20; /** * @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.0.0) (interfaces/IERC1967.sol) pragma solidity ^0.8.20; /** * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC. */ interface IERC1967 { /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Emitted when the beacon is changed. */ event BeaconUpgraded(address indexed beacon); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.20; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeacon { /** * @dev Must return an address that can be used as a delegate call target. * * {UpgradeableBeacon} will check that this address is a contract. */ function implementation() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (proxy/ERC1967/ERC1967Utils.sol) pragma solidity ^0.8.21; import {IBeacon} from "../beacon/IBeacon.sol"; import {IERC1967} from "../../interfaces/IERC1967.sol"; import {Address} from "../../utils/Address.sol"; import {StorageSlot} from "../../utils/StorageSlot.sol"; /** * @dev This library provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] slots. */ library ERC1967Utils { /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev The `implementation` of the proxy is invalid. */ error ERC1967InvalidImplementation(address implementation); /** * @dev The `admin` of the proxy is invalid. */ error ERC1967InvalidAdmin(address admin); /** * @dev The `beacon` of the proxy is invalid. */ error ERC1967InvalidBeacon(address beacon); /** * @dev An upgrade function sees `msg.value > 0` that may be lost. */ error ERC1967NonPayable(); /** * @dev Returns the current implementation address. */ function getImplementation() internal view returns (address) { return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the ERC-1967 implementation slot. */ function _setImplementation(address newImplementation) private { if (newImplementation.code.length == 0) { revert ERC1967InvalidImplementation(newImplementation); } StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Performs implementation upgrade with additional setup call if data is nonempty. * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected * to avoid stuck value in the contract. * * Emits an {IERC1967-Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) internal { _setImplementation(newImplementation); emit IERC1967.Upgraded(newImplementation); if (data.length > 0) { Address.functionDelegateCall(newImplementation, data); } else { _checkNonPayable(); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Returns the current admin. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using * the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103` */ function getAdmin() internal view returns (address) { return StorageSlot.getAddressSlot(ADMIN_SLOT).value; } /** * @dev Stores a new address in the ERC-1967 admin slot. */ function _setAdmin(address newAdmin) private { if (newAdmin == address(0)) { revert ERC1967InvalidAdmin(address(0)); } StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {IERC1967-AdminChanged} event. */ function changeAdmin(address newAdmin) internal { emit IERC1967.AdminChanged(getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Returns the current beacon. */ function getBeacon() internal view returns (address) { return StorageSlot.getAddressSlot(BEACON_SLOT).value; } /** * @dev Stores a new beacon in the ERC-1967 beacon slot. */ function _setBeacon(address newBeacon) private { if (newBeacon.code.length == 0) { revert ERC1967InvalidBeacon(newBeacon); } StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon; address beaconImplementation = IBeacon(newBeacon).implementation(); if (beaconImplementation.code.length == 0) { revert ERC1967InvalidImplementation(beaconImplementation); } } /** * @dev Change the beacon and trigger a setup call if data is nonempty. * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected * to avoid stuck value in the contract. * * Emits an {IERC1967-BeaconUpgraded} event. * * CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since * it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for * efficiency. */ function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal { _setBeacon(newBeacon); emit IERC1967.BeaconUpgraded(newBeacon); if (data.length > 0) { Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data); } else { _checkNonPayable(); } } /** * @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract * if an upgrade doesn't perform an initialization call. */ function _checkNonPayable() private { if (msg.value > 0) { revert ERC1967NonPayable(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC1155/extensions/IERC1155MetadataURI.sol) pragma solidity ^0.8.20; 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.1.0) (token/ERC1155/IERC1155.sol) pragma solidity ^0.8.20; 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 {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 {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.1.0) (token/ERC1155/IERC1155Receiver.sol) pragma solidity ^0.8.20; 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.1.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 {IERC1155-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(32, reason), mload(reason)) } } } } } /** * @dev Performs a batch acceptance check for the provided `operator` by calling {IERC1155-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(32, reason), mload(reason)) } } } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Address.sol) pragma solidity ^0.8.20; import {Errors} from "./Errors.sol"; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert Errors.InsufficientBalance(address(this).balance, amount); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert Errors.FailedCall(); } } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {Errors.FailedCall} error. * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert Errors.InsufficientBalance(address(this).balance, value); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case * of an unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {Errors.FailedCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}. */ function _revert(bytes memory returndata) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly ("memory-safe") { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert Errors.FailedCall(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.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 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 Helper to set the length of an 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 an 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 an 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) } } }
// 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.1.0) (utils/Errors.sol) pragma solidity ^0.8.20; /** * @dev Collection of common custom errors used in multiple contracts * * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library. * It is recommended to avoid relying on the error API for critical functionality. * * _Available since v5.1._ */ library Errors { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error InsufficientBalance(uint256 balance, uint256 needed); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedCall(); /** * @dev The deployment failed. */ error FailedDeployment(); /** * @dev A necessary precompile is missing. */ error MissingPrecompile(address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @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.1.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 Returns the addition of two unsigned integers, with an success flag (no overflow). */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an success flag (no overflow). */ function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an success flag (no overflow). */ function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a success flag (no division by zero). */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { if (b == 0) return (false, 0); return (true, 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 { if (b == 0) return (false, 0); return (true, a % b); } } /** * @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 { // 512-bit multiply [prod1 prod0] = 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 = prod1 * 2²⁵⁶ + prod0. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0. if (denominator <= prod1) { Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW)); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. // Always >= 1. See https://cs.stackexchange.com/q/138556/92363. uint256 twos = denominator & (0 - denominator); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2²⁵⁶ / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2²⁵⁶. 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 prod1 // is no longer required. result = prod0 * 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 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 value) internal pure returns (uint256) { uint256 result = 0; uint256 exp; unchecked { exp = 128 * SafeCast.toUint(value > (1 << 128) - 1); value >>= exp; result += exp; exp = 64 * SafeCast.toUint(value > (1 << 64) - 1); value >>= exp; result += exp; exp = 32 * SafeCast.toUint(value > (1 << 32) - 1); value >>= exp; result += exp; exp = 16 * SafeCast.toUint(value > (1 << 16) - 1); value >>= exp; result += exp; exp = 8 * SafeCast.toUint(value > (1 << 8) - 1); value >>= exp; result += exp; exp = 4 * SafeCast.toUint(value > (1 << 4) - 1); value >>= exp; result += exp; exp = 2 * SafeCast.toUint(value > (1 << 2) - 1); value >>= exp; result += exp; result += SafeCast.toUint(value > 1); } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + 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 value) internal pure returns (uint256) { uint256 result = 0; uint256 isGt; unchecked { isGt = SafeCast.toUint(value > (1 << 128) - 1); value >>= isGt * 128; result += isGt * 16; isGt = SafeCast.toUint(value > (1 << 64) - 1); value >>= isGt * 64; result += isGt * 8; isGt = SafeCast.toUint(value > (1 << 32) - 1); value >>= isGt * 32; result += isGt * 4; isGt = SafeCast.toUint(value > (1 << 16) - 1); value >>= isGt * 16; result += isGt * 2; result += SafeCast.toUint(value > (1 << 8) - 1); } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + 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.1.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.1.0) (utils/Strings.sol) pragma solidity ^0.8.20; import {Math} from "./math/Math.sol"; import {SignedMath} from "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant HEX_DIGITS = "0123456789abcdef"; uint8 private constant ADDRESS_LENGTH = 20; /** * @dev The `value` string doesn't fit in the specified `length`. */ error StringsInsufficientHexLength(uint256 value, uint256 length); /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; assembly ("memory-safe") { ptr := add(buffer, add(32, 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)); } }
{ "evmVersion": "paris", "optimizer": { "enabled": false, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","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":[{"internalType":"address","name":"implementation","type":"address"}],"name":"ERC1967InvalidImplementation","type":"error"},{"inputs":[],"name":"ERC1967NonPayable","type":"error"},{"inputs":[],"name":"FailedCall","type":"error"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"InvalidAddress","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"}],"name":"RecipientNotFound","type":"error"},{"inputs":[],"name":"RecipientsAndPercentagesMismatch","type":"error"},{"inputs":[{"internalType":"uint256","name":"attempted","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"TotalRoyaltyExceedsLimit","type":"error"},{"inputs":[],"name":"UUPSUnauthorizedCallContext","type":"error"},{"inputs":[{"internalType":"bytes32","name":"slot","type":"bytes32"}],"name":"UUPSUnsupportedProxiableUUID","type":"error"},{"inputs":[{"internalType":"address","name":"caller","type":"address"}],"name":"UnauthorizedAccess","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":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"oldManager","type":"address"},{"indexed":false,"internalType":"address","name":"newManager","type":"address"}],"name":"RoyaltyManagementTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"}],"name":"RoyaltyRecipientRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address[]","name":"recipients","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"percentages","type":"uint256[]"}],"name":"RoyaltyRecipientsAdded","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":false,"internalType":"string","name":"value","type":"string"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"URI","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"FEE_DENOMINATOR","outputs":[{"internalType":"uint96","name":"","type":"uint96"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_ROYALTY_PERCENTAGE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UPGRADE_INTERFACE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address[]","name":"_recipients","type":"address[]"},{"internalType":"uint256[]","name":"_percentages","type":"uint256[]"}],"name":"addRoyaltyRecipients","outputs":[],"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":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"burnBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getRoyaltyInfo","outputs":[{"internalType":"address[]","name":"recipients","type":"address[]"},{"internalType":"uint256[]","name":"percentages","type":"uint256[]"},{"internalType":"uint256","name":"totalPercentage","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getRoyaltyTotalPercentage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_initialOwner","type":"address"},{"internalType":"string","name":"_baseURI","type":"string"}],"name":"initialize","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":[],"name":"marketplace","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"string","name":"_tokenURI","type":"string"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nextTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_recipient","type":"address"}],"name":"removeRoyaltyRecipient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"values","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":"id","type":"uint256"},{"internalType":"uint256","name":"value","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":"address","name":"_marketplace","type":"address"}],"name":"setMarketplaceContractAddress","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":"","type":"uint256"}],"name":"tokenRoyaltyManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_newManager","type":"address"}],"name":"transferRoyaltyManagement","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_baseURI","type":"string"}],"name":"updateBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"uri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60a06040523073ffffffffffffffffffffffffffffffffffffffff1660809073ffffffffffffffffffffffffffffffffffffffff1681525034801561004357600080fd5b5061005261005760201b60201c565b6101c1565b600061006761015b60201b60201c565b90508060000160089054906101000a900460ff16156100b2576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b67ffffffffffffffff80168160000160009054906101000a900467ffffffffffffffff1667ffffffffffffffff16146101585767ffffffffffffffff8160000160006101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055507fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d267ffffffffffffffff60405161014f91906101a6565b60405180910390a15b50565b60007ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00905090565b600067ffffffffffffffff82169050919050565b6101a081610183565b82525050565b60006020820190506101bb6000830184610197565b92915050565b6080516150636101ea600039600081816120370152818161208c015261224701526150636000f3fe6080604052600436106101cc5760003560e01c80638da5cb5b116100f7578063b76c632b11610095578063f242432a11610064578063f242432a1461068c578063f2fde38b146106b5578063f399e22e146106de578063f5298aca14610707576101cc565b8063b76c632b146105bc578063d3fc9864146105fb578063d73792a914610624578063e985e9c51461064f576101cc565b8063a22cb465116100d1578063a22cb46514610512578063a9225d1b1461053b578063abc8c7af14610566578063ad3cb1cc14610591576101cc565b80638da5cb5b14610495578063931688cb146104c05780639c53536a146104e9576101cc565b80634e1273f41161016f578063715018a61161013e578063715018a6146103ed57806372b5623d1461040457806375794a3c1461042d5780637ded1a7a14610458576101cc565b80634e1273f4146103405780634f1ef2861461037d57806352d1902d146103995780636b20c454146103c4576101cc565b80630e89341c116101ab5780630e89341c146102885780631d259375146102c55780632eb2c2d6146102ee5780634ad3203014610317576101cc565b8062fdd58e146101d157806301ffc9a71461020e5780630a2887bb1461024b575b600080fd5b3480156101dd57600080fd5b506101f860048036038101906101f3919061374f565b610730565b604051610205919061379e565b60405180910390f35b34801561021a57600080fd5b5061023560048036038101906102309190613811565b610799565b6040516102429190613859565b60405180910390f35b34801561025757600080fd5b50610272600480360381019061026d9190613874565b61087b565b60405161027f91906138b0565b60405180910390f35b34801561029457600080fd5b506102af60048036038101906102aa9190613874565b6108ae565b6040516102bc919061395b565b60405180910390f35b3480156102d157600080fd5b506102ec60048036038101906102e7919061397d565b6108c0565b005b3480156102fa57600080fd5b5061031560048036038101906103109190613bba565b610c3e565b005b34801561032357600080fd5b5061033e60048036038101906103399190613c89565b610ce6565b005b34801561034c57600080fd5b5061036760048036038101906103629190613d79565b610d32565b6040516103749190613eaf565b60405180910390f35b61039760048036038101906103929190613ed1565b610e3b565b005b3480156103a557600080fd5b506103ae610e5a565b6040516103bb9190613f46565b60405180910390f35b3480156103d057600080fd5b506103eb60048036038101906103e69190613f61565b610e8d565b005b3480156103f957600080fd5b50610402610f39565b005b34801561041057600080fd5b5061042b6004803603810190610426919061409d565b610f4d565b005b34801561043957600080fd5b50610442611288565b60405161044f919061379e565b60405180910390f35b34801561046457600080fd5b5061047f600480360381019061047a9190613874565b61128e565b60405161048c919061379e565b60405180910390f35b3480156104a157600080fd5b506104aa6113ae565b6040516104b791906138b0565b60405180910390f35b3480156104cc57600080fd5b506104e760048036038101906104e291906141d3565b6113e6565b005b3480156104f557600080fd5b50610510600480360381019061050b919061397d565b6113fa565b005b34801561051e57600080fd5b5061053960048036038101906105349190614248565b611605565b005b34801561054757600080fd5b5061055061161b565b60405161055d919061379e565b60405180910390f35b34801561057257600080fd5b5061057b611621565b60405161058891906138b0565b60405180910390f35b34801561059d57600080fd5b506105a6611647565b6040516105b3919061395b565b60405180910390f35b3480156105c857600080fd5b506105e360048036038101906105de9190613874565b611680565b6040516105f293929190614346565b60405180910390f35b34801561060757600080fd5b50610622600480360381019061061d919061438b565b6117b3565b005b34801561063057600080fd5b506106396118bb565b6040516106469190614421565b60405180910390f35b34801561065b57600080fd5b506106766004803603810190610671919061443c565b6118c1565b6040516106839190613859565b60405180910390f35b34801561069857600080fd5b506106b360048036038101906106ae919061447c565b611963565b005b3480156106c157600080fd5b506106dc60048036038101906106d79190613c89565b611a0b565b005b3480156106ea57600080fd5b5061070560048036038101906107009190614513565b611a91565b005b34801561071357600080fd5b5061072e6004803603810190610729919061456f565b611c52565b005b60008061073b611cfe565b905080600001600084815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205491505092915050565b60007fd9b67a26000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061086457507f0e89341c000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610874575061087382611d26565b5b9050919050565b60026020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60606108b982611d90565b9050919050565b6002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461096357336040517fdccef96400000000000000000000000000000000000000000000000000000000815260040161095a91906138b0565b60405180910390fd5b600060036000848152602001908152602001600020905060008160000180549050905060005b81811015610bfc578373ffffffffffffffffffffffffffffffffffffffff168360000182815481106109be576109bd6145c2565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1603610bef57826001018181548110610a1a57610a196145c2565b5b9060005260206000200154836002016000828254610a389190614620565b9250508190555082600001600183610a509190614620565b81548110610a6157610a606145c2565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836000018281548110610aa257610aa16145c2565b5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082600101600183610afb9190614620565b81548110610b0c57610b0b6145c2565b5b9060005260206000200154836001018281548110610b2d57610b2c6145c2565b5b906000526020600020018190555082600001805480610b4f57610b4e614654565b5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055905582600101805480610b9857610b97614654565b5b600190038181906000526020600020016000905590557ffb8e3287db254c9edc344e33b802d2efd42d68c737505ee1d3e787ee56da928a8585604051610bdf929190614683565b60405180910390a1505050610c3a565b8080600101915050610989565b50826040517f3f597b9a000000000000000000000000000000000000000000000000000000008152600401610c3191906138b0565b60405180910390fd5b5050565b6000610c48611e86565b90508073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614158015610c8d5750610c8b86826118c1565b155b15610cd15780866040517fe237d922000000000000000000000000000000000000000000000000000000008152600401610cc89291906146ac565b60405180910390fd5b610cde8686868686611e8e565b505050505050565b610cee611f86565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60608151835114610d7e57815183516040517f5b059991000000000000000000000000000000000000000000000000000000008152600401610d759291906146d5565b60405180910390fd5b6000835167ffffffffffffffff811115610d9b57610d9a6139c2565b5b604051908082528060200260200182016040528015610dc95781602001602082028036833780820191505090505b50905060005b8451811015610e3057610e06610dee828761200d90919063ffffffff16565b610e01838761202190919063ffffffff16565b610730565b828281518110610e1957610e186145c2565b5b602002602001018181525050806001019050610dcf565b508091505092915050565b610e43612035565b610e4c8261211b565b610e568282612126565b5050565b6000610e64612245565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b905090565b610e95611e86565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614158015610ede5750610edc83610ed7611e86565b6118c1565b155b15610f2957610eeb611e86565b836040517fe237d922000000000000000000000000000000000000000000000000000000008152600401610f209291906146ac565b60405180910390fd5b610f348383836122cc565b505050565b610f41611f86565b610f4b6000612360565b565b6002600086815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610ff057336040517fdccef964000000000000000000000000000000000000000000000000000000008152600401610fe791906138b0565b60405180910390fd5b81819050848490501461102f576040517ff2009c3800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006003600087815260200190815260200160002090506000806110528861128e565b905060005b87879050811015611223576000868683818110611077576110766145c2565b5b90506020020135116110be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110b590614770565b60405180910390fd5b8585828181106110d1576110d06145c2565b5b90506020020135836110e39190614790565b92506107d082846110f49190614790565b11156111465781836111069190614790565b6107d06040517fe4c0790500000000000000000000000000000000000000000000000000000000815260040161113d9291906146d5565b60405180910390fd5b8360000188888381811061115d5761115c6145c2565b5b90506020020160208101906111729190613c89565b9080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550836001018686838181106111e9576111e86145c2565b5b9050602002013590806001815401808255809150506001900390600052602060002001600090919091909150558080600101915050611057565b50818360020160008282546112389190614790565b925050819055507f199859b6da50e2f42752979aaf9e717621f769ec8885091064a38e7acc8e0cad88888888886040516112769594939291906148b9565b60405180910390a15050505050505050565b60005481565b600080600360008481526020019081526020016000206040518060600160405290816000820180548060200260200160405190810160405280929190818152602001828054801561133457602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116112ea575b505050505081526020016001820180548060200260200160405190810160405280929190818152602001828054801561138c57602002820191906000526020600020905b815481526020019060010190808311611378575b5050505050815260200160028201548152505090508060400151915050919050565b6000806113b9612437565b90508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1691505090565b6113ee611f86565b6113f78161245f565b50565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461148c57336040517fdccef96400000000000000000000000000000000000000000000000000000000815260040161148391906138b0565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036114fd57806040517f8e4c8aa60000000000000000000000000000000000000000000000000000000081526004016114f491906138b0565b60405180910390fd5b60006002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816002600085815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060036000848152602001908152602001600020600080820160006115ab9190613648565b6001820160006115bb9190613669565b600282016000905550507f5004aff1ffc468d21342c115e6ec5267e0a70ef1cd1d5d2ee79cc7a8cc2653268382846040516115f893929190614902565b60405180910390a1505050565b611617611610611e86565b8383612481565b5050565b6107d081565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6040518060400160405280600581526020017f352e302e3000000000000000000000000000000000000000000000000000000081525081565b606080600080600360008681526020019081526020016000206040518060600160405290816000820180548060200260200160405190810160405280929190818152602001828054801561172957602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116116df575b505050505081526020016001820180548060200260200160405190810160405280929190818152602001828054801561178157602002820191906000526020600020905b81548152602001906001019080831161176d575b505050505081526020016002820154815250509050806000015181602001518260400151935093509350509193909250565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361182457826040517f8e4c8aa600000000000000000000000000000000000000000000000000000000815260040161181b91906138b0565b60405180910390fd5b600080600081548092919061183890614939565b91905055905061185984828560405180602001604052806000815250612600565b6118638183612699565b836002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050565b61271081565b6000806118cc611cfe565b90508060010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1691505092915050565b600061196d611e86565b90508073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16141580156119b257506119b086826118c1565b155b156119f65780866040517fe237d9220000000000000000000000000000000000000000000000000000000081526004016119ed9291906146ac565b60405180910390fd5b611a03868686868661270d565b505050505050565b611a13611f86565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603611a855760006040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600401611a7c91906138b0565b60405180910390fd5b611a8e81612360565b50565b6000611a9b612818565b905060008160000160089054906101000a900460ff1615905060008260000160009054906101000a900467ffffffffffffffff1690506000808267ffffffffffffffff16148015611ae95750825b9050600060018367ffffffffffffffff16148015611b1e575060003073ffffffffffffffffffffffffffffffffffffffff163b145b905081158015611b2c575080155b15611b63576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60018560000160006101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055508315611bb35760018560000160086101000a81548160ff0219169083151502179055505b611bcb60405180602001604052806000815250612840565b611bd48661245f565b611bdd87612854565b611be5612868565b611bed612872565b8315611c495760008560000160086101000a81548160ff0219169083151502179055507fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d26001604051611c4091906149da565b60405180910390a15b50505050505050565b611c5a611e86565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614158015611ca35750611ca183611c9c611e86565b6118c1565b155b15611cee57611cb0611e86565b836040517fe237d922000000000000000000000000000000000000000000000000000000008152600401611ce59291906146ac565b60405180910390fd5b611cf983838361287c565b505050565b60007f88be536d5240c274a3b1d3a1be54482fd9caa294f08c62a7cde569f49a3c4500905090565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60606000611d9c612923565b905060008160010160008581526020019081526020016000208054611dc090614a24565b80601f0160208091040260200160405190810160405280929190818152602001828054611dec90614a24565b8015611e395780601f10611e0e57610100808354040283529160200191611e39565b820191906000526020600020905b815481529060010190602001808311611e1c57829003601f168201915b505050505090506000815111611e5757611e528461294b565b611e7d565b8160000181604051602001611e6d929190614b29565b6040516020818303038152906040525b92505050919050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603611f005760006040517f57f447ce000000000000000000000000000000000000000000000000000000008152600401611ef791906138b0565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1603611f725760006040517f01a83514000000000000000000000000000000000000000000000000000000008152600401611f6991906138b0565b60405180910390fd5b611f7f85858585856129ee565b5050505050565b611f8e611e86565b73ffffffffffffffffffffffffffffffffffffffff16611fac6113ae565b73ffffffffffffffffffffffffffffffffffffffff161461200b57611fcf611e86565b6040517f118cdaa700000000000000000000000000000000000000000000000000000000815260040161200291906138b0565b60405180910390fd5b565b600060208202602084010151905092915050565b600060208202602084010151905092915050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1614806120e257507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166120c9612aa0565b73ffffffffffffffffffffffffffffffffffffffff1614155b15612119576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b612123611f86565b50565b8173ffffffffffffffffffffffffffffffffffffffff166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801561218e57506040513d601f19601f8201168201806040525081019061218b9190614b79565b60015b6121cf57816040517f4c9c8ce30000000000000000000000000000000000000000000000000000000081526004016121c691906138b0565b60405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b811461223657806040517faa1d49a400000000000000000000000000000000000000000000000000000000815260040161222d9190613f46565b60405180910390fd5b6122408383612af7565b505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff16146122ca576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361233e5760006040517f01a8351400000000000000000000000000000000000000000000000000000000815260040161233591906138b0565b60405180910390fd5b61235b8360008484604051806020016040528060008152506129ee565b505050565b600061236a612437565b905060008160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050828260000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508273ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3505050565b60007f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300905090565b6000612469612923565b90508181600001908161247c9190614d33565b505050565b600061248b611cfe565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036124ff5760006040517fced3e1000000000000000000000000000000000000000000000000000000000081526004016124f691906138b0565b60405180910390fd5b818160010160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31846040516125f29190613859565b60405180910390a350505050565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16036126725760006040517f57f447ce00000000000000000000000000000000000000000000000000000000815260040161266991906138b0565b60405180910390fd5b60008061267f8585612b6a565b915091506126916000878484876129ee565b505050505050565b60006126a3612923565b90508181600101600085815260200190815260200160002090816126c79190614d33565b50827f6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b6126f3856108ae565b604051612700919061395b565b60405180910390a2505050565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff160361277f5760006040517f57f447ce00000000000000000000000000000000000000000000000000000000815260040161277691906138b0565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16036127f15760006040517f01a835140000000000000000000000000000000000000000000000000000000081526004016127e891906138b0565b60405180910390fd5b6000806127fe8585612b6a565b9150915061280f87878484876129ee565b50505050505050565b60007ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00905090565b612848612b9a565b61285181612bda565b50565b61285c612b9a565b61286581612bee565b50565b612870612b9a565b565b61287a612b9a565b565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036128ee5760006040517f01a835140000000000000000000000000000000000000000000000000000000081526004016128e591906138b0565b60405180910390fd5b6000806128fb8484612b6a565b9150915061291c8560008484604051806020016040528060008152506129ee565b5050505050565b60007f89fc852226e759c7c636cf34d732f0198fc56a54876b2374a52beb7b0c558600905090565b60606000612957611cfe565b905080600201805461296890614a24565b80601f016020809104026020016040519081016040528092919081815260200182805461299490614a24565b80156129e15780601f106129b6576101008083540402835291602001916129e1565b820191906000526020600020905b8154815290600101906020018083116129c457829003601f168201915b5050505050915050919050565b6129fa85858585612c74565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614612a99576000612a38611e86565b90506001845103612a88576000612a5960008661202190919063ffffffff16565b90506000612a7160008661202190919063ffffffff16565b9050612a81838989858589613032565b5050612a97565b612a968187878787876131e6565b5b505b5050505050565b6000612ace7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b61339a565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b612b00826133a4565b8173ffffffffffffffffffffffffffffffffffffffff167fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b60405160405180910390a2600081511115612b5d57612b578282613471565b50612b66565b612b656134f5565b5b5050565b60608060405191506001825283602083015260408201905060018152826020820152604081016040529250929050565b612ba2613532565b612bd8576040517fd7e6bcf800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b612be2612b9a565b612beb81613552565b50565b612bf6612b9a565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603612c685760006040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600401612c5f91906138b0565b60405180910390fd5b612c7181612360565b50565b6000612c7e611cfe565b90508151835114612cca57825182516040517f5b059991000000000000000000000000000000000000000000000000000000008152600401612cc19291906146d5565b60405180910390fd5b6000612cd4611e86565b905060005b8451811015612eec576000612cf7828761202190919063ffffffff16565b90506000612d0e838761202190919063ffffffff16565b9050600073ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1614612e4157600085600001600084815260200190815260200160002060008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015612de657898183856040517f03dee4c5000000000000000000000000000000000000000000000000000000008152600401612ddd9493929190614e05565b60405180910390fd5b81810386600001600085815260200190815260200160002060008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505b600073ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff1614612edf578085600001600084815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612ed79190614790565b925050819055505b5050806001019050612cd9565b506001845103612fab576000612f0c60008661202190919063ffffffff16565b90506000612f2460008661202190919063ffffffff16565b90508673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628585604051612f9c9291906146d5565b60405180910390a4505061302a565b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051613021929190614e4a565b60405180910390a45b505050505050565b60008473ffffffffffffffffffffffffffffffffffffffff163b11156131de578373ffffffffffffffffffffffffffffffffffffffff1663f23a6e6187878686866040518663ffffffff1660e01b8152600401613093959493929190614ed6565b6020604051808303816000875af19250505080156130cf57506040513d601f19601f820116820180604052508101906130cc9190614f45565b60015b613153573d80600081146130ff576040519150601f19603f3d011682016040523d82523d6000602084013e613104565b606091505b50600081510361314b57846040517f57f447ce00000000000000000000000000000000000000000000000000000000815260040161314291906138b0565b60405180910390fd5b805181602001fd5b63f23a6e6160e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916146131dc57846040517f57f447ce0000000000000000000000000000000000000000000000000000000081526004016131d391906138b0565b60405180910390fd5b505b505050505050565b60008473ffffffffffffffffffffffffffffffffffffffff163b1115613392578373ffffffffffffffffffffffffffffffffffffffff1663bc197c8187878686866040518663ffffffff1660e01b8152600401613247959493929190614f72565b6020604051808303816000875af192505050801561328357506040513d601f19601f820116820180604052508101906132809190614f45565b60015b613307573d80600081146132b3576040519150601f19603f3d011682016040523d82523d6000602084013e6132b8565b606091505b5060008151036132ff57846040517f57f447ce0000000000000000000000000000000000000000000000000000000081526004016132f691906138b0565b60405180910390fd5b805181602001fd5b63bc197c8160e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161461339057846040517f57f447ce00000000000000000000000000000000000000000000000000000000815260040161338791906138b0565b60405180910390fd5b505b505050505050565b6000819050919050565b60008173ffffffffffffffffffffffffffffffffffffffff163b0361340057806040517f4c9c8ce30000000000000000000000000000000000000000000000000000000081526004016133f791906138b0565b60405180910390fd5b8061342d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b61339a565b60000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60606000808473ffffffffffffffffffffffffffffffffffffffff168460405161349b9190615016565b600060405180830381855af49150503d80600081146134d6576040519150601f19603f3d011682016040523d82523d6000602084013e6134db565b606091505b50915091506134eb858383613574565b9250505092915050565b6000341115613530576040517fb398979f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b600061353c612818565b60000160089054906101000a900460ff16905090565b600061355c611cfe565b90508181600201908161356f9190614d33565b505050565b6060826135895761358482613603565b6135fb565b600082511480156135b1575060008473ffffffffffffffffffffffffffffffffffffffff163b145b156135f357836040517f9996b3150000000000000000000000000000000000000000000000000000000081526004016135ea91906138b0565b60405180910390fd5b8190506135fc565b5b9392505050565b6000815111156136165780518082602001fd5b6040517fd6bda27500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5080546000825590600052602060002090810190613666919061368a565b50565b5080546000825590600052602060002090810190613687919061368a565b50565b5b808211156136a357600081600090555060010161368b565b5090565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006136e6826136bb565b9050919050565b6136f6816136db565b811461370157600080fd5b50565b600081359050613713816136ed565b92915050565b6000819050919050565b61372c81613719565b811461373757600080fd5b50565b60008135905061374981613723565b92915050565b60008060408385031215613766576137656136b1565b5b600061377485828601613704565b92505060206137858582860161373a565b9150509250929050565b61379881613719565b82525050565b60006020820190506137b3600083018461378f565b92915050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6137ee816137b9565b81146137f957600080fd5b50565b60008135905061380b816137e5565b92915050565b600060208284031215613827576138266136b1565b5b6000613835848285016137fc565b91505092915050565b60008115159050919050565b6138538161383e565b82525050565b600060208201905061386e600083018461384a565b92915050565b60006020828403121561388a576138896136b1565b5b60006138988482850161373a565b91505092915050565b6138aa816136db565b82525050565b60006020820190506138c560008301846138a1565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b838110156139055780820151818401526020810190506138ea565b60008484015250505050565b6000601f19601f8301169050919050565b600061392d826138cb565b61393781856138d6565b93506139478185602086016138e7565b61395081613911565b840191505092915050565b600060208201905081810360008301526139758184613922565b905092915050565b60008060408385031215613994576139936136b1565b5b60006139a28582860161373a565b92505060206139b385828601613704565b9150509250929050565b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6139fa82613911565b810181811067ffffffffffffffff82111715613a1957613a186139c2565b5b80604052505050565b6000613a2c6136a7565b9050613a3882826139f1565b919050565b600067ffffffffffffffff821115613a5857613a576139c2565b5b602082029050602081019050919050565b600080fd5b6000613a81613a7c84613a3d565b613a22565b90508083825260208201905060208402830185811115613aa457613aa3613a69565b5b835b81811015613acd5780613ab9888261373a565b845260208401935050602081019050613aa6565b5050509392505050565b600082601f830112613aec57613aeb6139bd565b5b8135613afc848260208601613a6e565b91505092915050565b600080fd5b600067ffffffffffffffff821115613b2557613b246139c2565b5b613b2e82613911565b9050602081019050919050565b82818337600083830152505050565b6000613b5d613b5884613b0a565b613a22565b905082815260208101848484011115613b7957613b78613b05565b5b613b84848285613b3b565b509392505050565b600082601f830112613ba157613ba06139bd565b5b8135613bb1848260208601613b4a565b91505092915050565b600080600080600060a08688031215613bd657613bd56136b1565b5b6000613be488828901613704565b9550506020613bf588828901613704565b945050604086013567ffffffffffffffff811115613c1657613c156136b6565b5b613c2288828901613ad7565b935050606086013567ffffffffffffffff811115613c4357613c426136b6565b5b613c4f88828901613ad7565b925050608086013567ffffffffffffffff811115613c7057613c6f6136b6565b5b613c7c88828901613b8c565b9150509295509295909350565b600060208284031215613c9f57613c9e6136b1565b5b6000613cad84828501613704565b91505092915050565b600067ffffffffffffffff821115613cd157613cd06139c2565b5b602082029050602081019050919050565b6000613cf5613cf084613cb6565b613a22565b90508083825260208201905060208402830185811115613d1857613d17613a69565b5b835b81811015613d415780613d2d8882613704565b845260208401935050602081019050613d1a565b5050509392505050565b600082601f830112613d6057613d5f6139bd565b5b8135613d70848260208601613ce2565b91505092915050565b60008060408385031215613d9057613d8f6136b1565b5b600083013567ffffffffffffffff811115613dae57613dad6136b6565b5b613dba85828601613d4b565b925050602083013567ffffffffffffffff811115613ddb57613dda6136b6565b5b613de785828601613ad7565b9150509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b613e2681613719565b82525050565b6000613e388383613e1d565b60208301905092915050565b6000602082019050919050565b6000613e5c82613df1565b613e668185613dfc565b9350613e7183613e0d565b8060005b83811015613ea2578151613e898882613e2c565b9750613e9483613e44565b925050600181019050613e75565b5085935050505092915050565b60006020820190508181036000830152613ec98184613e51565b905092915050565b60008060408385031215613ee857613ee76136b1565b5b6000613ef685828601613704565b925050602083013567ffffffffffffffff811115613f1757613f166136b6565b5b613f2385828601613b8c565b9150509250929050565b6000819050919050565b613f4081613f2d565b82525050565b6000602082019050613f5b6000830184613f37565b92915050565b600080600060608486031215613f7a57613f796136b1565b5b6000613f8886828701613704565b935050602084013567ffffffffffffffff811115613fa957613fa86136b6565b5b613fb586828701613ad7565b925050604084013567ffffffffffffffff811115613fd657613fd56136b6565b5b613fe286828701613ad7565b9150509250925092565b600080fd5b60008083601f840112614007576140066139bd565b5b8235905067ffffffffffffffff81111561402457614023613fec565b5b6020830191508360208202830111156140405761403f613a69565b5b9250929050565b60008083601f84011261405d5761405c6139bd565b5b8235905067ffffffffffffffff81111561407a57614079613fec565b5b60208301915083602082028301111561409657614095613a69565b5b9250929050565b6000806000806000606086880312156140b9576140b86136b1565b5b60006140c78882890161373a565b955050602086013567ffffffffffffffff8111156140e8576140e76136b6565b5b6140f488828901613ff1565b9450945050604086013567ffffffffffffffff811115614117576141166136b6565b5b61412388828901614047565b92509250509295509295909350565b600067ffffffffffffffff82111561414d5761414c6139c2565b5b61415682613911565b9050602081019050919050565b600061417661417184614132565b613a22565b90508281526020810184848401111561419257614191613b05565b5b61419d848285613b3b565b509392505050565b600082601f8301126141ba576141b96139bd565b5b81356141ca848260208601614163565b91505092915050565b6000602082840312156141e9576141e86136b1565b5b600082013567ffffffffffffffff811115614207576142066136b6565b5b614213848285016141a5565b91505092915050565b6142258161383e565b811461423057600080fd5b50565b6000813590506142428161421c565b92915050565b6000806040838503121561425f5761425e6136b1565b5b600061426d85828601613704565b925050602061427e85828601614233565b9150509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6142bd816136db565b82525050565b60006142cf83836142b4565b60208301905092915050565b6000602082019050919050565b60006142f382614288565b6142fd8185614293565b9350614308836142a4565b8060005b8381101561433957815161432088826142c3565b975061432b836142db565b92505060018101905061430c565b5085935050505092915050565b6000606082019050818103600083015261436081866142e8565b905081810360208301526143748185613e51565b9050614383604083018461378f565b949350505050565b6000806000606084860312156143a4576143a36136b1565b5b60006143b286828701613704565b93505060206143c38682870161373a565b925050604084013567ffffffffffffffff8111156143e4576143e36136b6565b5b6143f0868287016141a5565b9150509250925092565b60006bffffffffffffffffffffffff82169050919050565b61441b816143fa565b82525050565b60006020820190506144366000830184614412565b92915050565b60008060408385031215614453576144526136b1565b5b600061446185828601613704565b925050602061447285828601613704565b9150509250929050565b600080600080600060a08688031215614498576144976136b1565b5b60006144a688828901613704565b95505060206144b788828901613704565b94505060406144c88882890161373a565b93505060606144d98882890161373a565b925050608086013567ffffffffffffffff8111156144fa576144f96136b6565b5b61450688828901613b8c565b9150509295509295909350565b6000806040838503121561452a576145296136b1565b5b600061453885828601613704565b925050602083013567ffffffffffffffff811115614559576145586136b6565b5b614565858286016141a5565b9150509250929050565b600080600060608486031215614588576145876136b1565b5b600061459686828701613704565b93505060206145a78682870161373a565b92505060406145b88682870161373a565b9150509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061462b82613719565b915061463683613719565b925082820390508181111561464e5761464d6145f1565b5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6000604082019050614698600083018561378f565b6146a560208301846138a1565b9392505050565b60006040820190506146c160008301856138a1565b6146ce60208301846138a1565b9392505050565b60006040820190506146ea600083018561378f565b6146f7602083018461378f565b9392505050565b7f50657263656e74616765206d7573742062652067726561746572207468616e2060008201527f3000000000000000000000000000000000000000000000000000000000000000602082015250565b600061475a6021836138d6565b9150614765826146fe565b604082019050919050565b600060208201905081810360008301526147898161474d565b9050919050565b600061479b82613719565b91506147a683613719565b92508282019050808211156147be576147bd6145f1565b5b92915050565b6000819050919050565b60006147dd6020840184613704565b905092915050565b6000602082019050919050565b60006147fe8385614293565b9350614809826147c4565b8060005b858110156148425761481f82846147ce565b61482988826142c3565b9750614834836147e5565b92505060018101905061480d565b5085925050509392505050565b600080fd5b82818337505050565b60006148698385613dfc565b93507f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83111561489c5761489b61484f565b5b6020830292506148ad838584614854565b82840190509392505050565b60006060820190506148ce600083018861378f565b81810360208301526148e18186886147f2565b905081810360408301526148f681848661485d565b90509695505050505050565b6000606082019050614917600083018661378f565b61492460208301856138a1565b61493160408301846138a1565b949350505050565b600061494482613719565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203614976576149756145f1565b5b600182019050919050565b6000819050919050565b600067ffffffffffffffff82169050919050565b6000819050919050565b60006149c46149bf6149ba84614981565b61499f565b61498b565b9050919050565b6149d4816149a9565b82525050565b60006020820190506149ef60008301846149cb565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680614a3c57607f821691505b602082108103614a4f57614a4e6149f5565b5b50919050565b600081905092915050565b60008190508160005260206000209050919050565b60008154614a8281614a24565b614a8c8186614a55565b94506001821660008114614aa75760018114614abc57614aef565b60ff1983168652811515820286019350614aef565b614ac585614a60565b60005b83811015614ae757815481890152600182019150602081019050614ac8565b838801955050505b50505092915050565b6000614b03826138cb565b614b0d8185614a55565b9350614b1d8185602086016138e7565b80840191505092915050565b6000614b358285614a75565b9150614b418284614af8565b91508190509392505050565b614b5681613f2d565b8114614b6157600080fd5b50565b600081519050614b7381614b4d565b92915050565b600060208284031215614b8f57614b8e6136b1565b5b6000614b9d84828501614b64565b91505092915050565b60006020601f8301049050919050565b600082821b905092915050565b600060088302614bf37fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82614bb6565b614bfd8683614bb6565b95508019841693508086168417925050509392505050565b6000614c30614c2b614c2684613719565b61499f565b613719565b9050919050565b6000819050919050565b614c4a83614c15565b614c5e614c5682614c37565b848454614bc3565b825550505050565b600090565b614c73614c66565b614c7e818484614c41565b505050565b5b81811015614ca257614c97600082614c6b565b600181019050614c84565b5050565b601f821115614ce757614cb881614a60565b614cc184614ba6565b81016020851015614cd0578190505b614ce4614cdc85614ba6565b830182614c83565b50505b505050565b600082821c905092915050565b6000614d0a60001984600802614cec565b1980831691505092915050565b6000614d238383614cf9565b9150826002028217905092915050565b614d3c826138cb565b67ffffffffffffffff811115614d5557614d546139c2565b5b614d5f8254614a24565b614d6a828285614ca6565b600060209050601f831160018114614d9d5760008415614d8b578287015190505b614d958582614d17565b865550614dfd565b601f198416614dab86614a60565b60005b82811015614dd357848901518255600182019150602085019450602081019050614dae565b86831015614df05784890151614dec601f891682614cf9565b8355505b6001600288020188555050505b505050505050565b6000608082019050614e1a60008301876138a1565b614e27602083018661378f565b614e34604083018561378f565b614e41606083018461378f565b95945050505050565b60006040820190508181036000830152614e648185613e51565b90508181036020830152614e788184613e51565b90509392505050565b600081519050919050565b600082825260208201905092915050565b6000614ea882614e81565b614eb28185614e8c565b9350614ec28185602086016138e7565b614ecb81613911565b840191505092915050565b600060a082019050614eeb60008301886138a1565b614ef860208301876138a1565b614f05604083018661378f565b614f12606083018561378f565b8181036080830152614f248184614e9d565b90509695505050505050565b600081519050614f3f816137e5565b92915050565b600060208284031215614f5b57614f5a6136b1565b5b6000614f6984828501614f30565b91505092915050565b600060a082019050614f8760008301886138a1565b614f9460208301876138a1565b8181036040830152614fa68186613e51565b90508181036060830152614fba8185613e51565b90508181036080830152614fce8184614e9d565b90509695505050505050565b600081905092915050565b6000614ff082614e81565b614ffa8185614fda565b935061500a8185602086016138e7565b80840191505092915050565b60006150228284614fe5565b91508190509291505056fea26469706673582212205e6d489d1b60574ae74090ed5205b7c2ddfe96753bd97164fbe8ff4cca3d482c64736f6c634300081c0033
Deployed Bytecode
0x6080604052600436106101cc5760003560e01c80638da5cb5b116100f7578063b76c632b11610095578063f242432a11610064578063f242432a1461068c578063f2fde38b146106b5578063f399e22e146106de578063f5298aca14610707576101cc565b8063b76c632b146105bc578063d3fc9864146105fb578063d73792a914610624578063e985e9c51461064f576101cc565b8063a22cb465116100d1578063a22cb46514610512578063a9225d1b1461053b578063abc8c7af14610566578063ad3cb1cc14610591576101cc565b80638da5cb5b14610495578063931688cb146104c05780639c53536a146104e9576101cc565b80634e1273f41161016f578063715018a61161013e578063715018a6146103ed57806372b5623d1461040457806375794a3c1461042d5780637ded1a7a14610458576101cc565b80634e1273f4146103405780634f1ef2861461037d57806352d1902d146103995780636b20c454146103c4576101cc565b80630e89341c116101ab5780630e89341c146102885780631d259375146102c55780632eb2c2d6146102ee5780634ad3203014610317576101cc565b8062fdd58e146101d157806301ffc9a71461020e5780630a2887bb1461024b575b600080fd5b3480156101dd57600080fd5b506101f860048036038101906101f3919061374f565b610730565b604051610205919061379e565b60405180910390f35b34801561021a57600080fd5b5061023560048036038101906102309190613811565b610799565b6040516102429190613859565b60405180910390f35b34801561025757600080fd5b50610272600480360381019061026d9190613874565b61087b565b60405161027f91906138b0565b60405180910390f35b34801561029457600080fd5b506102af60048036038101906102aa9190613874565b6108ae565b6040516102bc919061395b565b60405180910390f35b3480156102d157600080fd5b506102ec60048036038101906102e7919061397d565b6108c0565b005b3480156102fa57600080fd5b5061031560048036038101906103109190613bba565b610c3e565b005b34801561032357600080fd5b5061033e60048036038101906103399190613c89565b610ce6565b005b34801561034c57600080fd5b5061036760048036038101906103629190613d79565b610d32565b6040516103749190613eaf565b60405180910390f35b61039760048036038101906103929190613ed1565b610e3b565b005b3480156103a557600080fd5b506103ae610e5a565b6040516103bb9190613f46565b60405180910390f35b3480156103d057600080fd5b506103eb60048036038101906103e69190613f61565b610e8d565b005b3480156103f957600080fd5b50610402610f39565b005b34801561041057600080fd5b5061042b6004803603810190610426919061409d565b610f4d565b005b34801561043957600080fd5b50610442611288565b60405161044f919061379e565b60405180910390f35b34801561046457600080fd5b5061047f600480360381019061047a9190613874565b61128e565b60405161048c919061379e565b60405180910390f35b3480156104a157600080fd5b506104aa6113ae565b6040516104b791906138b0565b60405180910390f35b3480156104cc57600080fd5b506104e760048036038101906104e291906141d3565b6113e6565b005b3480156104f557600080fd5b50610510600480360381019061050b919061397d565b6113fa565b005b34801561051e57600080fd5b5061053960048036038101906105349190614248565b611605565b005b34801561054757600080fd5b5061055061161b565b60405161055d919061379e565b60405180910390f35b34801561057257600080fd5b5061057b611621565b60405161058891906138b0565b60405180910390f35b34801561059d57600080fd5b506105a6611647565b6040516105b3919061395b565b60405180910390f35b3480156105c857600080fd5b506105e360048036038101906105de9190613874565b611680565b6040516105f293929190614346565b60405180910390f35b34801561060757600080fd5b50610622600480360381019061061d919061438b565b6117b3565b005b34801561063057600080fd5b506106396118bb565b6040516106469190614421565b60405180910390f35b34801561065b57600080fd5b506106766004803603810190610671919061443c565b6118c1565b6040516106839190613859565b60405180910390f35b34801561069857600080fd5b506106b360048036038101906106ae919061447c565b611963565b005b3480156106c157600080fd5b506106dc60048036038101906106d79190613c89565b611a0b565b005b3480156106ea57600080fd5b5061070560048036038101906107009190614513565b611a91565b005b34801561071357600080fd5b5061072e6004803603810190610729919061456f565b611c52565b005b60008061073b611cfe565b905080600001600084815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205491505092915050565b60007fd9b67a26000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061086457507f0e89341c000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610874575061087382611d26565b5b9050919050565b60026020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60606108b982611d90565b9050919050565b6002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461096357336040517fdccef96400000000000000000000000000000000000000000000000000000000815260040161095a91906138b0565b60405180910390fd5b600060036000848152602001908152602001600020905060008160000180549050905060005b81811015610bfc578373ffffffffffffffffffffffffffffffffffffffff168360000182815481106109be576109bd6145c2565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1603610bef57826001018181548110610a1a57610a196145c2565b5b9060005260206000200154836002016000828254610a389190614620565b9250508190555082600001600183610a509190614620565b81548110610a6157610a606145c2565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836000018281548110610aa257610aa16145c2565b5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082600101600183610afb9190614620565b81548110610b0c57610b0b6145c2565b5b9060005260206000200154836001018281548110610b2d57610b2c6145c2565b5b906000526020600020018190555082600001805480610b4f57610b4e614654565b5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055905582600101805480610b9857610b97614654565b5b600190038181906000526020600020016000905590557ffb8e3287db254c9edc344e33b802d2efd42d68c737505ee1d3e787ee56da928a8585604051610bdf929190614683565b60405180910390a1505050610c3a565b8080600101915050610989565b50826040517f3f597b9a000000000000000000000000000000000000000000000000000000008152600401610c3191906138b0565b60405180910390fd5b5050565b6000610c48611e86565b90508073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614158015610c8d5750610c8b86826118c1565b155b15610cd15780866040517fe237d922000000000000000000000000000000000000000000000000000000008152600401610cc89291906146ac565b60405180910390fd5b610cde8686868686611e8e565b505050505050565b610cee611f86565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60608151835114610d7e57815183516040517f5b059991000000000000000000000000000000000000000000000000000000008152600401610d759291906146d5565b60405180910390fd5b6000835167ffffffffffffffff811115610d9b57610d9a6139c2565b5b604051908082528060200260200182016040528015610dc95781602001602082028036833780820191505090505b50905060005b8451811015610e3057610e06610dee828761200d90919063ffffffff16565b610e01838761202190919063ffffffff16565b610730565b828281518110610e1957610e186145c2565b5b602002602001018181525050806001019050610dcf565b508091505092915050565b610e43612035565b610e4c8261211b565b610e568282612126565b5050565b6000610e64612245565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b905090565b610e95611e86565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614158015610ede5750610edc83610ed7611e86565b6118c1565b155b15610f2957610eeb611e86565b836040517fe237d922000000000000000000000000000000000000000000000000000000008152600401610f209291906146ac565b60405180910390fd5b610f348383836122cc565b505050565b610f41611f86565b610f4b6000612360565b565b6002600086815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610ff057336040517fdccef964000000000000000000000000000000000000000000000000000000008152600401610fe791906138b0565b60405180910390fd5b81819050848490501461102f576040517ff2009c3800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006003600087815260200190815260200160002090506000806110528861128e565b905060005b87879050811015611223576000868683818110611077576110766145c2565b5b90506020020135116110be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110b590614770565b60405180910390fd5b8585828181106110d1576110d06145c2565b5b90506020020135836110e39190614790565b92506107d082846110f49190614790565b11156111465781836111069190614790565b6107d06040517fe4c0790500000000000000000000000000000000000000000000000000000000815260040161113d9291906146d5565b60405180910390fd5b8360000188888381811061115d5761115c6145c2565b5b90506020020160208101906111729190613c89565b9080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550836001018686838181106111e9576111e86145c2565b5b9050602002013590806001815401808255809150506001900390600052602060002001600090919091909150558080600101915050611057565b50818360020160008282546112389190614790565b925050819055507f199859b6da50e2f42752979aaf9e717621f769ec8885091064a38e7acc8e0cad88888888886040516112769594939291906148b9565b60405180910390a15050505050505050565b60005481565b600080600360008481526020019081526020016000206040518060600160405290816000820180548060200260200160405190810160405280929190818152602001828054801561133457602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116112ea575b505050505081526020016001820180548060200260200160405190810160405280929190818152602001828054801561138c57602002820191906000526020600020905b815481526020019060010190808311611378575b5050505050815260200160028201548152505090508060400151915050919050565b6000806113b9612437565b90508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1691505090565b6113ee611f86565b6113f78161245f565b50565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461148c57336040517fdccef96400000000000000000000000000000000000000000000000000000000815260040161148391906138b0565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036114fd57806040517f8e4c8aa60000000000000000000000000000000000000000000000000000000081526004016114f491906138b0565b60405180910390fd5b60006002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816002600085815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060036000848152602001908152602001600020600080820160006115ab9190613648565b6001820160006115bb9190613669565b600282016000905550507f5004aff1ffc468d21342c115e6ec5267e0a70ef1cd1d5d2ee79cc7a8cc2653268382846040516115f893929190614902565b60405180910390a1505050565b611617611610611e86565b8383612481565b5050565b6107d081565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6040518060400160405280600581526020017f352e302e3000000000000000000000000000000000000000000000000000000081525081565b606080600080600360008681526020019081526020016000206040518060600160405290816000820180548060200260200160405190810160405280929190818152602001828054801561172957602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116116df575b505050505081526020016001820180548060200260200160405190810160405280929190818152602001828054801561178157602002820191906000526020600020905b81548152602001906001019080831161176d575b505050505081526020016002820154815250509050806000015181602001518260400151935093509350509193909250565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361182457826040517f8e4c8aa600000000000000000000000000000000000000000000000000000000815260040161181b91906138b0565b60405180910390fd5b600080600081548092919061183890614939565b91905055905061185984828560405180602001604052806000815250612600565b6118638183612699565b836002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050565b61271081565b6000806118cc611cfe565b90508060010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1691505092915050565b600061196d611e86565b90508073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16141580156119b257506119b086826118c1565b155b156119f65780866040517fe237d9220000000000000000000000000000000000000000000000000000000081526004016119ed9291906146ac565b60405180910390fd5b611a03868686868661270d565b505050505050565b611a13611f86565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603611a855760006040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600401611a7c91906138b0565b60405180910390fd5b611a8e81612360565b50565b6000611a9b612818565b905060008160000160089054906101000a900460ff1615905060008260000160009054906101000a900467ffffffffffffffff1690506000808267ffffffffffffffff16148015611ae95750825b9050600060018367ffffffffffffffff16148015611b1e575060003073ffffffffffffffffffffffffffffffffffffffff163b145b905081158015611b2c575080155b15611b63576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60018560000160006101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055508315611bb35760018560000160086101000a81548160ff0219169083151502179055505b611bcb60405180602001604052806000815250612840565b611bd48661245f565b611bdd87612854565b611be5612868565b611bed612872565b8315611c495760008560000160086101000a81548160ff0219169083151502179055507fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d26001604051611c4091906149da565b60405180910390a15b50505050505050565b611c5a611e86565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614158015611ca35750611ca183611c9c611e86565b6118c1565b155b15611cee57611cb0611e86565b836040517fe237d922000000000000000000000000000000000000000000000000000000008152600401611ce59291906146ac565b60405180910390fd5b611cf983838361287c565b505050565b60007f88be536d5240c274a3b1d3a1be54482fd9caa294f08c62a7cde569f49a3c4500905090565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60606000611d9c612923565b905060008160010160008581526020019081526020016000208054611dc090614a24565b80601f0160208091040260200160405190810160405280929190818152602001828054611dec90614a24565b8015611e395780601f10611e0e57610100808354040283529160200191611e39565b820191906000526020600020905b815481529060010190602001808311611e1c57829003601f168201915b505050505090506000815111611e5757611e528461294b565b611e7d565b8160000181604051602001611e6d929190614b29565b6040516020818303038152906040525b92505050919050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603611f005760006040517f57f447ce000000000000000000000000000000000000000000000000000000008152600401611ef791906138b0565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1603611f725760006040517f01a83514000000000000000000000000000000000000000000000000000000008152600401611f6991906138b0565b60405180910390fd5b611f7f85858585856129ee565b5050505050565b611f8e611e86565b73ffffffffffffffffffffffffffffffffffffffff16611fac6113ae565b73ffffffffffffffffffffffffffffffffffffffff161461200b57611fcf611e86565b6040517f118cdaa700000000000000000000000000000000000000000000000000000000815260040161200291906138b0565b60405180910390fd5b565b600060208202602084010151905092915050565b600060208202602084010151905092915050565b7f000000000000000000000000c52329f1e51e09d9a2b5da6426d9f946d6b1607973ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1614806120e257507f000000000000000000000000c52329f1e51e09d9a2b5da6426d9f946d6b1607973ffffffffffffffffffffffffffffffffffffffff166120c9612aa0565b73ffffffffffffffffffffffffffffffffffffffff1614155b15612119576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b612123611f86565b50565b8173ffffffffffffffffffffffffffffffffffffffff166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801561218e57506040513d601f19601f8201168201806040525081019061218b9190614b79565b60015b6121cf57816040517f4c9c8ce30000000000000000000000000000000000000000000000000000000081526004016121c691906138b0565b60405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b811461223657806040517faa1d49a400000000000000000000000000000000000000000000000000000000815260040161222d9190613f46565b60405180910390fd5b6122408383612af7565b505050565b7f000000000000000000000000c52329f1e51e09d9a2b5da6426d9f946d6b1607973ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff16146122ca576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361233e5760006040517f01a8351400000000000000000000000000000000000000000000000000000000815260040161233591906138b0565b60405180910390fd5b61235b8360008484604051806020016040528060008152506129ee565b505050565b600061236a612437565b905060008160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050828260000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508273ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3505050565b60007f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300905090565b6000612469612923565b90508181600001908161247c9190614d33565b505050565b600061248b611cfe565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036124ff5760006040517fced3e1000000000000000000000000000000000000000000000000000000000081526004016124f691906138b0565b60405180910390fd5b818160010160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31846040516125f29190613859565b60405180910390a350505050565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16036126725760006040517f57f447ce00000000000000000000000000000000000000000000000000000000815260040161266991906138b0565b60405180910390fd5b60008061267f8585612b6a565b915091506126916000878484876129ee565b505050505050565b60006126a3612923565b90508181600101600085815260200190815260200160002090816126c79190614d33565b50827f6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b6126f3856108ae565b604051612700919061395b565b60405180910390a2505050565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff160361277f5760006040517f57f447ce00000000000000000000000000000000000000000000000000000000815260040161277691906138b0565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16036127f15760006040517f01a835140000000000000000000000000000000000000000000000000000000081526004016127e891906138b0565b60405180910390fd5b6000806127fe8585612b6a565b9150915061280f87878484876129ee565b50505050505050565b60007ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00905090565b612848612b9a565b61285181612bda565b50565b61285c612b9a565b61286581612bee565b50565b612870612b9a565b565b61287a612b9a565b565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036128ee5760006040517f01a835140000000000000000000000000000000000000000000000000000000081526004016128e591906138b0565b60405180910390fd5b6000806128fb8484612b6a565b9150915061291c8560008484604051806020016040528060008152506129ee565b5050505050565b60007f89fc852226e759c7c636cf34d732f0198fc56a54876b2374a52beb7b0c558600905090565b60606000612957611cfe565b905080600201805461296890614a24565b80601f016020809104026020016040519081016040528092919081815260200182805461299490614a24565b80156129e15780601f106129b6576101008083540402835291602001916129e1565b820191906000526020600020905b8154815290600101906020018083116129c457829003601f168201915b5050505050915050919050565b6129fa85858585612c74565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614612a99576000612a38611e86565b90506001845103612a88576000612a5960008661202190919063ffffffff16565b90506000612a7160008661202190919063ffffffff16565b9050612a81838989858589613032565b5050612a97565b612a968187878787876131e6565b5b505b5050505050565b6000612ace7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b61339a565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b612b00826133a4565b8173ffffffffffffffffffffffffffffffffffffffff167fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b60405160405180910390a2600081511115612b5d57612b578282613471565b50612b66565b612b656134f5565b5b5050565b60608060405191506001825283602083015260408201905060018152826020820152604081016040529250929050565b612ba2613532565b612bd8576040517fd7e6bcf800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b612be2612b9a565b612beb81613552565b50565b612bf6612b9a565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603612c685760006040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600401612c5f91906138b0565b60405180910390fd5b612c7181612360565b50565b6000612c7e611cfe565b90508151835114612cca57825182516040517f5b059991000000000000000000000000000000000000000000000000000000008152600401612cc19291906146d5565b60405180910390fd5b6000612cd4611e86565b905060005b8451811015612eec576000612cf7828761202190919063ffffffff16565b90506000612d0e838761202190919063ffffffff16565b9050600073ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1614612e4157600085600001600084815260200190815260200160002060008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015612de657898183856040517f03dee4c5000000000000000000000000000000000000000000000000000000008152600401612ddd9493929190614e05565b60405180910390fd5b81810386600001600085815260200190815260200160002060008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505b600073ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff1614612edf578085600001600084815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612ed79190614790565b925050819055505b5050806001019050612cd9565b506001845103612fab576000612f0c60008661202190919063ffffffff16565b90506000612f2460008661202190919063ffffffff16565b90508673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628585604051612f9c9291906146d5565b60405180910390a4505061302a565b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051613021929190614e4a565b60405180910390a45b505050505050565b60008473ffffffffffffffffffffffffffffffffffffffff163b11156131de578373ffffffffffffffffffffffffffffffffffffffff1663f23a6e6187878686866040518663ffffffff1660e01b8152600401613093959493929190614ed6565b6020604051808303816000875af19250505080156130cf57506040513d601f19601f820116820180604052508101906130cc9190614f45565b60015b613153573d80600081146130ff576040519150601f19603f3d011682016040523d82523d6000602084013e613104565b606091505b50600081510361314b57846040517f57f447ce00000000000000000000000000000000000000000000000000000000815260040161314291906138b0565b60405180910390fd5b805181602001fd5b63f23a6e6160e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916146131dc57846040517f57f447ce0000000000000000000000000000000000000000000000000000000081526004016131d391906138b0565b60405180910390fd5b505b505050505050565b60008473ffffffffffffffffffffffffffffffffffffffff163b1115613392578373ffffffffffffffffffffffffffffffffffffffff1663bc197c8187878686866040518663ffffffff1660e01b8152600401613247959493929190614f72565b6020604051808303816000875af192505050801561328357506040513d601f19601f820116820180604052508101906132809190614f45565b60015b613307573d80600081146132b3576040519150601f19603f3d011682016040523d82523d6000602084013e6132b8565b606091505b5060008151036132ff57846040517f57f447ce0000000000000000000000000000000000000000000000000000000081526004016132f691906138b0565b60405180910390fd5b805181602001fd5b63bc197c8160e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161461339057846040517f57f447ce00000000000000000000000000000000000000000000000000000000815260040161338791906138b0565b60405180910390fd5b505b505050505050565b6000819050919050565b60008173ffffffffffffffffffffffffffffffffffffffff163b0361340057806040517f4c9c8ce30000000000000000000000000000000000000000000000000000000081526004016133f791906138b0565b60405180910390fd5b8061342d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b61339a565b60000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60606000808473ffffffffffffffffffffffffffffffffffffffff168460405161349b9190615016565b600060405180830381855af49150503d80600081146134d6576040519150601f19603f3d011682016040523d82523d6000602084013e6134db565b606091505b50915091506134eb858383613574565b9250505092915050565b6000341115613530576040517fb398979f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b600061353c612818565b60000160089054906101000a900460ff16905090565b600061355c611cfe565b90508181600201908161356f9190614d33565b505050565b6060826135895761358482613603565b6135fb565b600082511480156135b1575060008473ffffffffffffffffffffffffffffffffffffffff163b145b156135f357836040517f9996b3150000000000000000000000000000000000000000000000000000000081526004016135ea91906138b0565b60405180910390fd5b8190506135fc565b5b9392505050565b6000815111156136165780518082602001fd5b6040517fd6bda27500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5080546000825590600052602060002090810190613666919061368a565b50565b5080546000825590600052602060002090810190613687919061368a565b50565b5b808211156136a357600081600090555060010161368b565b5090565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006136e6826136bb565b9050919050565b6136f6816136db565b811461370157600080fd5b50565b600081359050613713816136ed565b92915050565b6000819050919050565b61372c81613719565b811461373757600080fd5b50565b60008135905061374981613723565b92915050565b60008060408385031215613766576137656136b1565b5b600061377485828601613704565b92505060206137858582860161373a565b9150509250929050565b61379881613719565b82525050565b60006020820190506137b3600083018461378f565b92915050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6137ee816137b9565b81146137f957600080fd5b50565b60008135905061380b816137e5565b92915050565b600060208284031215613827576138266136b1565b5b6000613835848285016137fc565b91505092915050565b60008115159050919050565b6138538161383e565b82525050565b600060208201905061386e600083018461384a565b92915050565b60006020828403121561388a576138896136b1565b5b60006138988482850161373a565b91505092915050565b6138aa816136db565b82525050565b60006020820190506138c560008301846138a1565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b838110156139055780820151818401526020810190506138ea565b60008484015250505050565b6000601f19601f8301169050919050565b600061392d826138cb565b61393781856138d6565b93506139478185602086016138e7565b61395081613911565b840191505092915050565b600060208201905081810360008301526139758184613922565b905092915050565b60008060408385031215613994576139936136b1565b5b60006139a28582860161373a565b92505060206139b385828601613704565b9150509250929050565b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6139fa82613911565b810181811067ffffffffffffffff82111715613a1957613a186139c2565b5b80604052505050565b6000613a2c6136a7565b9050613a3882826139f1565b919050565b600067ffffffffffffffff821115613a5857613a576139c2565b5b602082029050602081019050919050565b600080fd5b6000613a81613a7c84613a3d565b613a22565b90508083825260208201905060208402830185811115613aa457613aa3613a69565b5b835b81811015613acd5780613ab9888261373a565b845260208401935050602081019050613aa6565b5050509392505050565b600082601f830112613aec57613aeb6139bd565b5b8135613afc848260208601613a6e565b91505092915050565b600080fd5b600067ffffffffffffffff821115613b2557613b246139c2565b5b613b2e82613911565b9050602081019050919050565b82818337600083830152505050565b6000613b5d613b5884613b0a565b613a22565b905082815260208101848484011115613b7957613b78613b05565b5b613b84848285613b3b565b509392505050565b600082601f830112613ba157613ba06139bd565b5b8135613bb1848260208601613b4a565b91505092915050565b600080600080600060a08688031215613bd657613bd56136b1565b5b6000613be488828901613704565b9550506020613bf588828901613704565b945050604086013567ffffffffffffffff811115613c1657613c156136b6565b5b613c2288828901613ad7565b935050606086013567ffffffffffffffff811115613c4357613c426136b6565b5b613c4f88828901613ad7565b925050608086013567ffffffffffffffff811115613c7057613c6f6136b6565b5b613c7c88828901613b8c565b9150509295509295909350565b600060208284031215613c9f57613c9e6136b1565b5b6000613cad84828501613704565b91505092915050565b600067ffffffffffffffff821115613cd157613cd06139c2565b5b602082029050602081019050919050565b6000613cf5613cf084613cb6565b613a22565b90508083825260208201905060208402830185811115613d1857613d17613a69565b5b835b81811015613d415780613d2d8882613704565b845260208401935050602081019050613d1a565b5050509392505050565b600082601f830112613d6057613d5f6139bd565b5b8135613d70848260208601613ce2565b91505092915050565b60008060408385031215613d9057613d8f6136b1565b5b600083013567ffffffffffffffff811115613dae57613dad6136b6565b5b613dba85828601613d4b565b925050602083013567ffffffffffffffff811115613ddb57613dda6136b6565b5b613de785828601613ad7565b9150509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b613e2681613719565b82525050565b6000613e388383613e1d565b60208301905092915050565b6000602082019050919050565b6000613e5c82613df1565b613e668185613dfc565b9350613e7183613e0d565b8060005b83811015613ea2578151613e898882613e2c565b9750613e9483613e44565b925050600181019050613e75565b5085935050505092915050565b60006020820190508181036000830152613ec98184613e51565b905092915050565b60008060408385031215613ee857613ee76136b1565b5b6000613ef685828601613704565b925050602083013567ffffffffffffffff811115613f1757613f166136b6565b5b613f2385828601613b8c565b9150509250929050565b6000819050919050565b613f4081613f2d565b82525050565b6000602082019050613f5b6000830184613f37565b92915050565b600080600060608486031215613f7a57613f796136b1565b5b6000613f8886828701613704565b935050602084013567ffffffffffffffff811115613fa957613fa86136b6565b5b613fb586828701613ad7565b925050604084013567ffffffffffffffff811115613fd657613fd56136b6565b5b613fe286828701613ad7565b9150509250925092565b600080fd5b60008083601f840112614007576140066139bd565b5b8235905067ffffffffffffffff81111561402457614023613fec565b5b6020830191508360208202830111156140405761403f613a69565b5b9250929050565b60008083601f84011261405d5761405c6139bd565b5b8235905067ffffffffffffffff81111561407a57614079613fec565b5b60208301915083602082028301111561409657614095613a69565b5b9250929050565b6000806000806000606086880312156140b9576140b86136b1565b5b60006140c78882890161373a565b955050602086013567ffffffffffffffff8111156140e8576140e76136b6565b5b6140f488828901613ff1565b9450945050604086013567ffffffffffffffff811115614117576141166136b6565b5b61412388828901614047565b92509250509295509295909350565b600067ffffffffffffffff82111561414d5761414c6139c2565b5b61415682613911565b9050602081019050919050565b600061417661417184614132565b613a22565b90508281526020810184848401111561419257614191613b05565b5b61419d848285613b3b565b509392505050565b600082601f8301126141ba576141b96139bd565b5b81356141ca848260208601614163565b91505092915050565b6000602082840312156141e9576141e86136b1565b5b600082013567ffffffffffffffff811115614207576142066136b6565b5b614213848285016141a5565b91505092915050565b6142258161383e565b811461423057600080fd5b50565b6000813590506142428161421c565b92915050565b6000806040838503121561425f5761425e6136b1565b5b600061426d85828601613704565b925050602061427e85828601614233565b9150509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6142bd816136db565b82525050565b60006142cf83836142b4565b60208301905092915050565b6000602082019050919050565b60006142f382614288565b6142fd8185614293565b9350614308836142a4565b8060005b8381101561433957815161432088826142c3565b975061432b836142db565b92505060018101905061430c565b5085935050505092915050565b6000606082019050818103600083015261436081866142e8565b905081810360208301526143748185613e51565b9050614383604083018461378f565b949350505050565b6000806000606084860312156143a4576143a36136b1565b5b60006143b286828701613704565b93505060206143c38682870161373a565b925050604084013567ffffffffffffffff8111156143e4576143e36136b6565b5b6143f0868287016141a5565b9150509250925092565b60006bffffffffffffffffffffffff82169050919050565b61441b816143fa565b82525050565b60006020820190506144366000830184614412565b92915050565b60008060408385031215614453576144526136b1565b5b600061446185828601613704565b925050602061447285828601613704565b9150509250929050565b600080600080600060a08688031215614498576144976136b1565b5b60006144a688828901613704565b95505060206144b788828901613704565b94505060406144c88882890161373a565b93505060606144d98882890161373a565b925050608086013567ffffffffffffffff8111156144fa576144f96136b6565b5b61450688828901613b8c565b9150509295509295909350565b6000806040838503121561452a576145296136b1565b5b600061453885828601613704565b925050602083013567ffffffffffffffff811115614559576145586136b6565b5b614565858286016141a5565b9150509250929050565b600080600060608486031215614588576145876136b1565b5b600061459686828701613704565b93505060206145a78682870161373a565b92505060406145b88682870161373a565b9150509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061462b82613719565b915061463683613719565b925082820390508181111561464e5761464d6145f1565b5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6000604082019050614698600083018561378f565b6146a560208301846138a1565b9392505050565b60006040820190506146c160008301856138a1565b6146ce60208301846138a1565b9392505050565b60006040820190506146ea600083018561378f565b6146f7602083018461378f565b9392505050565b7f50657263656e74616765206d7573742062652067726561746572207468616e2060008201527f3000000000000000000000000000000000000000000000000000000000000000602082015250565b600061475a6021836138d6565b9150614765826146fe565b604082019050919050565b600060208201905081810360008301526147898161474d565b9050919050565b600061479b82613719565b91506147a683613719565b92508282019050808211156147be576147bd6145f1565b5b92915050565b6000819050919050565b60006147dd6020840184613704565b905092915050565b6000602082019050919050565b60006147fe8385614293565b9350614809826147c4565b8060005b858110156148425761481f82846147ce565b61482988826142c3565b9750614834836147e5565b92505060018101905061480d565b5085925050509392505050565b600080fd5b82818337505050565b60006148698385613dfc565b93507f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83111561489c5761489b61484f565b5b6020830292506148ad838584614854565b82840190509392505050565b60006060820190506148ce600083018861378f565b81810360208301526148e18186886147f2565b905081810360408301526148f681848661485d565b90509695505050505050565b6000606082019050614917600083018661378f565b61492460208301856138a1565b61493160408301846138a1565b949350505050565b600061494482613719565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203614976576149756145f1565b5b600182019050919050565b6000819050919050565b600067ffffffffffffffff82169050919050565b6000819050919050565b60006149c46149bf6149ba84614981565b61499f565b61498b565b9050919050565b6149d4816149a9565b82525050565b60006020820190506149ef60008301846149cb565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680614a3c57607f821691505b602082108103614a4f57614a4e6149f5565b5b50919050565b600081905092915050565b60008190508160005260206000209050919050565b60008154614a8281614a24565b614a8c8186614a55565b94506001821660008114614aa75760018114614abc57614aef565b60ff1983168652811515820286019350614aef565b614ac585614a60565b60005b83811015614ae757815481890152600182019150602081019050614ac8565b838801955050505b50505092915050565b6000614b03826138cb565b614b0d8185614a55565b9350614b1d8185602086016138e7565b80840191505092915050565b6000614b358285614a75565b9150614b418284614af8565b91508190509392505050565b614b5681613f2d565b8114614b6157600080fd5b50565b600081519050614b7381614b4d565b92915050565b600060208284031215614b8f57614b8e6136b1565b5b6000614b9d84828501614b64565b91505092915050565b60006020601f8301049050919050565b600082821b905092915050565b600060088302614bf37fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82614bb6565b614bfd8683614bb6565b95508019841693508086168417925050509392505050565b6000614c30614c2b614c2684613719565b61499f565b613719565b9050919050565b6000819050919050565b614c4a83614c15565b614c5e614c5682614c37565b848454614bc3565b825550505050565b600090565b614c73614c66565b614c7e818484614c41565b505050565b5b81811015614ca257614c97600082614c6b565b600181019050614c84565b5050565b601f821115614ce757614cb881614a60565b614cc184614ba6565b81016020851015614cd0578190505b614ce4614cdc85614ba6565b830182614c83565b50505b505050565b600082821c905092915050565b6000614d0a60001984600802614cec565b1980831691505092915050565b6000614d238383614cf9565b9150826002028217905092915050565b614d3c826138cb565b67ffffffffffffffff811115614d5557614d546139c2565b5b614d5f8254614a24565b614d6a828285614ca6565b600060209050601f831160018114614d9d5760008415614d8b578287015190505b614d958582614d17565b865550614dfd565b601f198416614dab86614a60565b60005b82811015614dd357848901518255600182019150602085019450602081019050614dae565b86831015614df05784890151614dec601f891682614cf9565b8355505b6001600288020188555050505b505050505050565b6000608082019050614e1a60008301876138a1565b614e27602083018661378f565b614e34604083018561378f565b614e41606083018461378f565b95945050505050565b60006040820190508181036000830152614e648185613e51565b90508181036020830152614e788184613e51565b90509392505050565b600081519050919050565b600082825260208201905092915050565b6000614ea882614e81565b614eb28185614e8c565b9350614ec28185602086016138e7565b614ecb81613911565b840191505092915050565b600060a082019050614eeb60008301886138a1565b614ef860208301876138a1565b614f05604083018661378f565b614f12606083018561378f565b8181036080830152614f248184614e9d565b90509695505050505050565b600081519050614f3f816137e5565b92915050565b600060208284031215614f5b57614f5a6136b1565b5b6000614f6984828501614f30565b91505092915050565b600060a082019050614f8760008301886138a1565b614f9460208301876138a1565b8181036040830152614fa68186613e51565b90508181036060830152614fba8185613e51565b90508181036080830152614fce8184614e9d565b90509695505050505050565b600081905092915050565b6000614ff082614e81565b614ffa8185614fda565b935061500a8185602086016138e7565b80840191505092915050565b60006150228284614fe5565b91508190509291505056fea26469706673582212205e6d489d1b60574ae74090ed5205b7c2ddfe96753bd97164fbe8ff4cca3d482c64736f6c634300081c0033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Loading...
Loading
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.