Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
0x60806040 | 16342414 | 555 days ago | IN | Create: Anomura | 0 ETH | 0.08347091 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
Anomura
Compiler Version
v0.8.13+commit.abaa5c0e
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.13; import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import {CountersUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol"; import {ERC721Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; import {ERC721EnumerableUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol"; import {StringsUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol"; import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import {IAnomuraData} from "./AnomuraData.sol"; import { IUniversalEquipmentManager } from "./UniversalEquipmentManager.sol"; interface IAnomura { function ownerOf(uint256 tokenId) external view returns (address); } /// @notice Anomura contract /// Allow a bowl owner to hatch an anomura contract Anomura is Initializable, ERC721Upgradeable, ERC721EnumerableUpgradeable, ReentrancyGuardUpgradeable, OwnableUpgradeable { IAnomuraData public anomuraData; using CountersUpgradeable for CountersUpgradeable.Counter; CountersUpgradeable.Counter private _tokenIds; string private baseURI; /// @dev Emit an event when the contract is deployed event ContractDeployed(address owner); /// @dev Emit an event so an offchain source can build the metadata URI event NewAnomura( uint256 indexed crabId, string claws, string legs, string body, string shell, string background, string headpieces ); /// @dev Emit an event when bowl address changed event UpdatedBowlContractAddress(address bowlAddress, address sender); /// @dev Emit an event when public sale is changed event UpdatedPauseContract(bool isPaused, address updatedBy); address public bowlAddress; bytes32 internal entropyMix; struct AnomuraEntity { string body; string claws; string legs; string shell; string headPieces; string background; } /** * @dev Keep track of Anomura from tokenId */ mapping(uint256 => AnomuraEntity) public anomuraMap; bool public isPaused; IUniversalEquipmentManager public universalEquipmentManager; // ============ ACCESS CONTROL/SANITY MODIFIERS ============ /** * @dev Throws if called when contract is paused. */ modifier isNotPaused() { require(isPaused == false, "Contract is paused"); _; } /// @notice Only bowl contract can call the function /// if succeed, use the last address hash to add entropy to next address who calls the function modifier onlyBowlContract() { require(msg.sender == bowlAddress, "Can only be called by Bowl"); _; } modifier isTokenExists(uint256 _tokenId) { require(_exists(_tokenId), "Non existed token"); _; } function initialize( address _bowlAddress, address _anomuraDataAddress, string calldata _baseURI ) external initializer { require(_bowlAddress != address(0x0), "Bowl contract address is 0"); require( _anomuraDataAddress != address(0x0), "Anomura Data address is 0" ); __ERC721_init("Anomura", "ANOMURA"); __ERC721Enumerable_init(); __ReentrancyGuard_init(); __Ownable_init(); baseURI = _baseURI; bowlAddress = _bowlAddress; anomuraData = IAnomuraData(_anomuraDataAddress); isPaused = false; // to start tokenId at 1, instead of 0. _tokenIds.increment(); // emit event contract is deployed emit ContractDeployed(msg.sender); } /// @notice Generate random uint256 /// @return Random uint256 function random(string memory input) internal view returns (uint256) { return uint256( keccak256( abi.encodePacked( input, tx.gasprice, msg.sender, block.timestamp, block.basefee, blockhash(block.number - 1), entropyMix ) ) ); } /** @notice return anomura part as string a. We generate a random number, then modulo 94 to get a greatness value. b. If greatness > 92, ~1.07% chance then the output would have an unique part. If greatness > 83, ~10.64% chance then the output would have prefix, and suffix. If greatness > 74, ~20.22% chance then the output would have suffix only. If greatness > 65, ~29.79% chance then the output would have prefix only. Else the output would only contain the name of the part, a val within the sourceArray */ function pluck( uint256 tokenId, string memory keyPrefix, string[] memory sourceArray, string[] memory prefixes, string[] memory suffixes, string[] memory unique ) internal view returns (string memory) { uint256 rand = random( string( abi.encodePacked( keyPrefix, StringsUpgradeable.toString(tokenId) ) ) ); string memory output = sourceArray[rand % sourceArray.length]; uint256 greatness = rand % 94; if (greatness > 92) { output = string( abi.encodePacked(unique[rand % unique.length], " ", output) ); return output; } if (greatness > 83) { output = string( abi.encodePacked( prefixes[rand % prefixes.length], " ", output, " ", suffixes[rand % suffixes.length] ) ); return output; } if (greatness > 74) { output = string( abi.encodePacked(output, " ", suffixes[rand % suffixes.length]) ); return output; } if (greatness > 65) { output = string( abi.encodePacked(prefixes[rand % prefixes.length], " ", output) ); return output; } // does not have any special attributes return output; } /** @notice return background part as string output a. We generate a random number, then modulo 51 to get a greatness value. b. If greatness > 45, ~10% chance then the output would have background prefix. Else the output would only contain the name of the part, a val within the sourceArray */ function pluckBackground( uint256 tokenId, string memory keyPrefix, string[] memory sourceArray, string[] memory backgroundPrefixes ) internal view returns (string memory) { uint256 rand = random( string( abi.encodePacked( keyPrefix, StringsUpgradeable.toString(tokenId) ) ) ); string memory output = sourceArray[rand % sourceArray.length]; uint256 greatness = rand % 51; if (greatness > 45) { output = string( abi.encodePacked( backgroundPrefixes[rand % backgroundPrefixes.length], " ", output ) ); } return output; } /** @notice return true or false Initial hasHeadpiece is false by default. 4% of having headpiece */ function shouldHaveHeadpieces(uint256 tokenId, string memory keyPrefix) internal view returns (bool hasHeadpiece) { uint256 rand = random( string( abi.encodePacked( keyPrefix, StringsUpgradeable.toString(tokenId) ) ) ) % 101; if (rand > 95) { hasHeadpiece = true; } return hasHeadpiece; } /** @notice To set new baseURI for tokenId @param _baseURI new baseURI */ function setBaseURI(string calldata _baseURI) external onlyOwner { baseURI = _baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { require(_exists(tokenId), "Nonexistent token"); return string( abi.encodePacked(baseURI, StringsUpgradeable.toString(tokenId)) ); } /** @notice mint an anomura, only owner can call this function @param _address Address of who's going to receive the token We generate each part of the anomura, and store in the mapping to be viewed later */ function ownerMintAnomura(address _address) external isNotPaused nonReentrant onlyOwner { require( address(anomuraData) != address(0x0), "Anomura data address is 0" ); entropyMix = keccak256(abi.encodePacked(_address, block.coinbase)); uint256 newTokenId = _tokenIds.current(); IAnomuraData.Data memory data; data = anomuraData.getAnomuraData(); string memory generatedClaws = pluck( newTokenId, "CLAW", data.claws, data.prefixes, data.suffixes, data.unique ); string memory generatedLegs = pluck( newTokenId, "LEG", data.legs, data.prefixes, data.suffixes, data.unique ); string memory generatedBody = pluck( newTokenId, "BODY", data.body, data.prefixes, data.suffixes, data.unique ); string memory generatedShell = pluck( newTokenId, "SHELL", data.shell, data.prefixes, data.suffixes, data.unique ); string memory generatedBackground = pluckBackground( newTokenId, "BACKGROUND", data.background, data.backgroundPrefixes ); bool hasHeadpiece = shouldHaveHeadpieces(newTokenId, "HAVE_HEADPIECE"); string memory generatedHeadPieces = hasHeadpiece == true ? pluck( newTokenId, "HEADPIECE", data.headPieces, data.prefixes, data.suffixes, data.unique ) : "None"; anomuraMap[newTokenId] = AnomuraEntity({ body: generatedBody, claws: generatedClaws, legs: generatedLegs, shell: generatedShell, headPieces: generatedHeadPieces, background: generatedBackground }); _tokenIds.increment(); _safeMint(_address, newTokenId); emit NewAnomura( newTokenId, generatedClaws, generatedLegs, generatedBody, generatedShell, generatedBackground, generatedHeadPieces ); } /** @notice mint an anomura, only Bowl Contract can call this function @param _address Address of who's going to receive the token We generate each part of the anomura, and store in the mapping to be viewed later */ function mintAnomura(address _address) external isNotPaused nonReentrant onlyBowlContract returns (uint256 anomuraId) { require( address(anomuraData) != address(0x0), "Anomura data address is 0" ); entropyMix = keccak256(abi.encodePacked(_address, block.coinbase)); anomuraId = _tokenIds.current(); IAnomuraData.Data memory data; data = anomuraData.getAnomuraData(); string memory generatedClaws = pluck( anomuraId, "CLAW", data.claws, data.prefixes, data.suffixes, data.unique ); string memory generatedLegs = pluck( anomuraId, "LEG", data.legs, data.prefixes, data.suffixes, data.unique ); string memory generatedBody = pluck( anomuraId, "BODY", data.body, data.prefixes, data.suffixes, data.unique ); string memory generatedShell = pluck( anomuraId, "SHELL", data.shell, data.prefixes, data.suffixes, data.unique ); string memory generatedBackground = pluckBackground( anomuraId, "BACKGROUND", data.background, data.backgroundPrefixes ); bool hasHeadpiece = shouldHaveHeadpieces(anomuraId, "HAVE_HEADPIECE"); string memory generatedHeadPieces = hasHeadpiece == true ? pluck( anomuraId, "HEADPIECE", data.headPieces, data.prefixes, data.suffixes, data.unique ) : "None"; anomuraMap[anomuraId] = AnomuraEntity({ body: generatedBody, claws: generatedClaws, legs: generatedLegs, shell: generatedShell, headPieces: generatedHeadPieces, background: generatedBackground }); _tokenIds.increment(); _safeMint(_address, anomuraId); emit NewAnomura( anomuraId, generatedClaws, generatedLegs, generatedBody, generatedShell, generatedBackground, generatedHeadPieces ); } function tokensOfOwner(address _ownerAddr) external view returns (uint256[] memory) { uint256 tokenCount = balanceOf(_ownerAddr); // number of token owned by this address uint256[] memory tokenIds = new uint256[](tokenCount); // array should be same as number of token owned for (uint256 i = 0; i < tokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_ownerAddr, i); } return tokenIds; } /** @notice withdraw current balance to msg.sender address */ function withdrawAvailableBalance() external onlyOwner { uint256 balance = address(this).balance; payable(msg.sender).transfer(balance); } /** @notice Manual set the address of the Bowl contract deployed @param _bowlAddress Bowl's address deployed */ function setBowlAddress(address _bowlAddress) external onlyOwner { // require(address(anomuraContract) == address(0x0), "The anomura address has been set before."); // accidentally we may put a wrong address and we cannot revert so comment out the require bowlAddress = _bowlAddress; emit UpdatedBowlContractAddress(_bowlAddress, msg.sender); } /** @notice Manual set the address of the Anomura Data contract deployed @param _anomuraDataAddress Bowl's address deployed */ function setAnomuraData(address _anomuraDataAddress) external onlyOwner { anomuraData = IAnomuraData(_anomuraDataAddress); } /** @notice Change status of isPaused, to pause all minting functions @param _isPaused boolean to pause */ function setContractPaused(bool _isPaused) external onlyOwner { isPaused = _isPaused; emit UpdatedPauseContract(_isPaused, msg.sender); } function setUniversalManager(address universalManager_) external onlyOwner { universalEquipmentManager = IUniversalEquipmentManager(universalManager_); } // The following functions are overrides required by Solidity. function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal override(ERC721Upgradeable, ERC721EnumerableUpgradeable) { uint256 _lastActionOfAnomura = universalEquipmentManager.getLastActionOnNft(address(this), tokenId); if((_lastActionOfAnomura + 4) > block.number){ revert("No transfer right after action"); } super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721Upgradeable, ERC721EnumerableUpgradeable) returns (bool) { return super.supportsInterface(interfaceId); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol) pragma solidity ^0.8.0; import "./IAccessControlEnumerableUpgradeable.sol"; import "./AccessControlUpgradeable.sol"; import "../utils/structs/EnumerableSetUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */ abstract contract AccessControlEnumerableUpgradeable is Initializable, IAccessControlEnumerableUpgradeable, AccessControlUpgradeable { function __AccessControlEnumerable_init() internal onlyInitializing { } function __AccessControlEnumerable_init_unchained() internal onlyInitializing { } using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; mapping(bytes32 => EnumerableSetUpgradeable.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) { return _roleMembers[role].at(index); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) { return _roleMembers[role].length(); } /** * @dev Overload {_grantRole} to track enumerable memberships */ function _grantRole(bytes32 role, address account) internal virtual override { super._grantRole(role, account); _roleMembers[role].add(account); } /** * @dev Overload {_revokeRole} to track enumerable memberships */ function _revokeRole(bytes32 role, address account) internal virtual override { super._revokeRole(role, account); _roleMembers[role].remove(account); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../utils/StringsUpgradeable.sol"; import "../utils/introspection/ERC165Upgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable { function __AccessControl_init() internal onlyInitializing { } function __AccessControl_init_unchained() internal onlyInitializing { } struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", StringsUpgradeable.toHexString(uint160(account), 20), " is missing role ", StringsUpgradeable.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol) pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IAccessControlEnumerableUpgradeable is IAccessControlUpgradeable { /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) external view returns (address); /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../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. * * By default, the owner account will be the one that deploys the contract. 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 { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _transferOwnership(_msgSender()); } /** * @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) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing 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 { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ``` * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * `initializer` is equivalent to `reinitializer(1)`, so 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. * * 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. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized < type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev _Available since v3.1._ */ interface IERC1155ReceiverUpgradeable is IERC165Upgradeable { /** * @dev Handles the receipt of a single ERC1155 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 ERC1155 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 v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol) pragma solidity ^0.8.0; import "../IERC1155ReceiverUpgradeable.sol"; import "../../../utils/introspection/ERC165Upgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @dev _Available since v3.1._ */ abstract contract ERC1155ReceiverUpgradeable is Initializable, ERC165Upgradeable, IERC1155ReceiverUpgradeable { function __ERC1155Receiver_init() internal onlyInitializing { } function __ERC1155Receiver_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) { return interfaceId == type(IERC1155ReceiverUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721Upgradeable.sol"; import "./IERC721ReceiverUpgradeable.sol"; import "./extensions/IERC721MetadataUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../utils/StringsUpgradeable.sol"; import "../../utils/introspection/ERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable { using AddressUpgradeable for address; using StringsUpgradeable for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing { __ERC721_init_unchained(name_, symbol_); } function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) { return interfaceId == type(IERC721Upgradeable).interfaceId || interfaceId == type(IERC721MetadataUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: address zero is not a valid owner"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: invalid token ID"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { _requireMinted(tokenId); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721Upgradeable.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not token owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { _requireMinted(tokenId); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved"); _safeTransfer(from, to, tokenId, data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { address owner = ERC721Upgradeable.ownerOf(tokenId); return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721Upgradeable.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Reverts if the `tokenId` has not been minted yet. */ function _requireMinted(uint256 tokenId) internal view virtual { require(_exists(tokenId), "ERC721: invalid token ID"); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory data ) private returns (bool) { if (to.isContract()) { try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) { return retval == IERC721ReceiverUpgradeable.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[44] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; import "../ERC721Upgradeable.sol"; import "./IERC721EnumerableUpgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721EnumerableUpgradeable is Initializable, ERC721Upgradeable, IERC721EnumerableUpgradeable { function __ERC721Enumerable_init() internal onlyInitializing { } function __ERC721Enumerable_init_unchained() internal onlyInitializing { } // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165Upgradeable, ERC721Upgradeable) returns (bool) { return interfaceId == type(IERC721EnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721Upgradeable.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721EnumerableUpgradeable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721Upgradeable.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721Upgradeable.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[46] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721EnumerableUpgradeable is IERC721Upgradeable { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721MetadataUpgradeable is IERC721Upgradeable { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721ReceiverUpgradeable { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/utils/ERC721Holder.sol) pragma solidity ^0.8.0; import "../IERC721ReceiverUpgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC721Receiver} interface. * * Accepts all token transfers. * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}. */ contract ERC721HolderUpgradeable is Initializable, IERC721ReceiverUpgradeable { function __ERC721Holder_init() internal onlyInitializing { } function __ERC721Holder_init_unchained() internal onlyInitializing { } /** * @dev See {IERC721Receiver-onERC721Received}. * * Always returns `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address, address, uint256, bytes memory ) public virtual override returns (bytes4) { return this.onERC721Received.selector; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library CountersUpgradeable { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 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); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev 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); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol) pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet. * ==== */ library EnumerableSetUpgradeable { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastValue; // Update the index for the moved value set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.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. * * By default, the owner account will be the one that deploys the contract. 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 Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @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) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing 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 { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface 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[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // Barely modified version of OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol) pragma solidity ^0.8.6; library ActionsSet { struct Set { // Storage of action names string[] _names; // Storage of action selectors bytes4[] _selectors; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes4 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Set storage set, string memory name) internal returns (bool) { bytes4 selector = bytes4(keccak256(bytes(name))); if (!contains(set, selector)) { set._selectors.push(selector); set._names.push(name); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[selector] = set._selectors.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Set storage set, bytes4 value) internal returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _selectors array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._selectors.length - 1; if (lastIndex != toDeleteIndex) { bytes4 lastValue = set._selectors[lastIndex]; // Move the last value to the index where the value to delete is set._selectors[toDeleteIndex] = lastValue; // Update the index for the moved value set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex } // Delete the slot where the moved value was stored set._selectors.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Set storage set, bytes4 value) internal view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function length(Set storage set) internal view returns (uint256) { return set._selectors.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Set storage set, uint256 index) internal view returns (bytes4) { return set._selectors[index]; } /** * @dev Return the entire set of action names * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function names(Set storage set) internal view returns (string[] memory) { return set._names; } /** * @dev Return the entire set of action selectors * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function selectors(Set storage set) internal view returns (bytes4[] memory) { return set._selectors; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.6; /*********************************************************************************************\ * Author: Hypervisor <[email protected]> (https://twitter.com/0xalxi) * EIP-5050 Interactive NFTs with Modular Environments: https://eips.ethereum.org/EIPS/eip-5050 /*********************************************************************************************/ /// @title EIP-5050 Action Controller interface IControllable { /// @notice Enable or disable approval for a third party ("controller") to force /// handling of a given action without performing EIP-5050 validity checks. /// @dev Emits the ControllerApproval event. The contract MUST allow /// an unbounded number of controllers per action. /// @param _controller Address to add to the set of authorized controllers /// @param _action Selector of the action for which the controller is approved / disapproved /// @param _approved True if the controller is approved, false to revoke approval function setControllerApproval(address _controller, bytes4 _action, bool _approved) external; /// @notice Enable or disable approval for a third party ("controller") to force /// action handling without performing EIP-5050 validity checks. /// @dev Emits the ControllerApproval event. The contract MUST allow /// an unbounded number of controllers per action. /// @param _controller Address to add to the set of authorized controllers /// @param _approved True if the controller is approved, false to revoke approval function setControllerApprovalForAll(address _controller, bool _approved) external; /// @notice Query if an address is an authorized controller for a given action. /// @param _controller The trusted third party address that can force action handling /// @param _action The action selector to query against /// @return True if `_controller` is an approved operator for `_account`, false otherwise function isApprovedController(address _controller, bytes4 _action) external view returns (bool); /// @dev This emits when a controller is enabled or disabled for the given /// action. The controller can force `action` handling on the emitting contract, /// bypassing the standard EIP-5050 validity checks. event ControllerApproval( address indexed _controller, bytes4 indexed _action, bool _approved ); /// @dev This emits when a controller is enabled or disabled for all actions. /// Disabling all action approval for a controller does not override explicit action /// action approvals. Controller's approved for all actions can force action handling /// on the emitting contract for any action. event ControllerApprovalForAll( address indexed _controller, bool _approved ); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.6; /*********************************************************************************************\ * Author: Hypervisor <[email protected]> (https://twitter.com/0xalxi) * EIP-5050 Interactive NFTs with Modular Environments: https://eips.ethereum.org/EIPS/eip-5050 /*********************************************************************************************/ /// @title ERC-5050 Token Interaction Standard /// @dev See https://eips.ethereum.org/EIPS/eip-xxx interface IERC5050Sender { /// @notice Send an action to the target address /// @dev The action's `fromContract` is automatically set to `address(this)`, /// and the `from` parameter is set to `msg.sender`. /// @param action The action to send function sendAction(Action memory action) external payable; /// @notice Check if an action is valid based on its hash and nonce /// @dev When an action passes through all three possible contracts /// (`fromContract`, `to`, and `state`) the `state` contract validates the /// action with the initating `fromContract` using a nonced action hash. /// This hash is calculated and saved to storage on the `fromContract` before /// action handling is initiated. The `state` contract calculates the hash /// and verifies it and nonce with the `fromContract`. /// @param _hash The hash to validate /// @param _nonce The nonce to validate function isValid(bytes32 _hash, uint256 _nonce) external returns (bool); /// @notice Retrieve list of actions that can be sent. /// @dev Intended for use by off-chain applications to query compatible contracts, /// and to advertise functionality in human-readable form. function sendableActions() external view returns (string[] memory); /// @notice Change or reaffirm the approved address for an action /// @dev The zero address indicates there is no approved address. /// Throws unless `msg.sender` is the `_account`, or an authorized /// operator of the `_account`. /// @param _account The account of the account-action pair to approve /// @param _action The action of the account-action pair to approve /// @param _approved The new approved account-action controller function approveForAction( address _account, bytes4 _action, address _approved ) external returns (bool); /// @notice Enable or disable approval for a third party ("operator") to conduct /// all actions on behalf of `msg.sender` /// @dev Emits the ApprovalForAll event. The contract MUST allow /// an unbounded number of operators per owner. /// @param _operator Address to add to the set of authorized operators /// @param _approved True if the operator is approved, false to revoke approval function setApprovalForAllActions(address _operator, bool _approved) external; /// @notice Get the approved address for an account-action pair /// @dev Throws if `_tokenId` is not a valid NFT. /// @param _account The account of the account-action to find the approved address for /// @param _action The action of the account-action to find the approved address for /// @return The approved address for this account-action, or the zero address if /// there is none function getApprovedForAction(address _account, bytes4 _action) external view returns (address); /// @notice Query if an address is an authorized operator for another address /// @param _account The address on whose behalf actions are performed /// @param _operator The address that acts on behalf of the account /// @return True if `_operator` is an approved operator for `_account`, false otherwise function isApprovedForAllActions(address _account, address _operator) external view returns (bool); /// @dev This emits when an action is sent (`sendAction()`) event SendAction( bytes4 indexed name, address _from, address indexed _fromContract, uint256 _tokenId, address indexed _to, uint256 _toTokenId, address _state, bytes _data ); /// @dev This emits when the approved address for an account-action pair /// is changed or reaffirmed. The zero address indicates there is no /// approved address. event ApprovalForAction( address indexed _account, bytes4 indexed _action, address indexed _approved ); /// @dev This emits when an operator is enabled or disabled for an account. /// The operator can conduct all actions on behalf of the account. event ApprovalForAllActions( address indexed _account, address indexed _operator, bool _approved ); } interface IERC5050Receiver { /// @notice Handle an action /// @dev Both the `to` contract and `state` contract are called via /// `onActionReceived()`. /// @param action The action to handle function onActionReceived(Action calldata action, uint256 _nonce) external payable; /// @notice Retrieve list of actions that can be received. /// @dev Intended for use by off-chain applications to query compatible contracts, /// and to advertise functionality in human-readable form. function receivableActions() external view returns (string[] memory); /// @dev This emits when a valid action is received. event ActionReceived( bytes4 indexed name, address _from, address indexed _fromContract, uint256 _fromTokenId, address indexed _to, uint256 _toTokenId, address _state, bytes _data ); } /// @param _address The address of the interactive object /// @param tokenId The token that is interacting (optional) struct Object { address _address; uint256 _tokenId; } /// @param selector The bytes4(keccack256()) encoding of the action string /// @param user The address of the sender /// @param from The initiating object /// @param to The receiving object /// @param state The state contract /// @param data Additional data with no specified format struct Action { bytes4 selector; address user; Object from; Object to; address state; bytes data; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.6; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; import {ERC5050StateStorage, IERC5050RegistryClient} from "./ERC5050StateStorage.sol"; import {IERC5050Sender, IERC5050Receiver, Action, Object} from "../../interfaces/IERC5050.sol"; import {IControllable} from "../../interfaces/IControllable.sol"; import {ActionsSet} from "../../common/ActionsSet.sol"; contract ERC5050State is IERC5050Receiver, IControllable { using ERC5050StateStorage for ERC5050StateStorage.Layout; using Address for address; using ActionsSet for ActionsSet.Set; error ZeroAddressDestination(); error TransferToNonERC5050ReceiverImplementer(); uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; modifier onlyReceivableAction(Action calldata action, uint256 nonce) { if (_isApprovedController(msg.sender, action.selector)) { _; return; } require( action.state == address(this), "ERC5050: invalid state" ); ERC5050StateStorage.Layout storage store = ERC5050StateStorage.layout(); require(store.receiverLock != _ENTERED, "ERC5050: no re-entrancy"); require( store._receivableActions.contains(action.selector), "ERC5050: invalid action" ); address _proxiedFromAddress; address expectedSender = action.to._address; if (expectedSender == address(0)) { if (action.from._address != address(0)) { _proxiedFromAddress = ERC5050StateStorage.getSenderProxy(action.from._address); expectedSender = _proxiedFromAddress; } else { expectedSender = action.user; } } else { expectedSender = ERC5050StateStorage.getReceiverProxy(expectedSender); } require(msg.sender == expectedSender, "ERC5050: invalid sender"); if ( action.to._address.isContract() && action.from._address.isContract() ) { bytes32 actionHash = bytes32( keccak256( abi.encodePacked( action.selector, action.user, action.from._address, action.from._tokenId, action.to._address, action.to._tokenId, action.state, action.data, nonce ) ) ); if(_proxiedFromAddress == address(0)) { _proxiedFromAddress = ERC5050StateStorage.getSenderProxy(action.from._address); } try IERC5050Sender(_proxiedFromAddress).isValid(actionHash, nonce) returns (bool ok) { require(ok, "ERC5050: action not validated"); } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC5050: call to non ERC5050Sender"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } store.receiverLock = _ENTERED; _; store.receiverLock = _NOT_ENTERED; } function onActionReceived(Action calldata action, uint256 nonce) external payable virtual override(IERC5050Receiver) onlyReceivableAction(action, nonce) { _onActionReceived(action); } function _onActionReceived(Action calldata action) internal virtual { emit ActionReceived( action.selector, action.user, action.from._address, action.from._tokenId, action.to._address, action.to._tokenId, action.state, action.data ); } modifier onlyCommittableAction(Action calldata action) { require(msg.sender == action.user, "invalid sender"); require(address(this) == action.state, "invalid state"); require( ERC5050StateStorage.layout()._receivableActions.contains(action.selector), "ERC5050: invalid action" ); _; emit ActionReceived( action.selector, action.user, action.from._address, action.from._tokenId, action.to._address, action.to._tokenId, action.state, action.data ); } function _beforeCommitAction(Action calldata action, uint256 nonce) internal virtual { // Commit action as controller on sender address _from = action.from._address; if (action.from._address != address(0)) { _from = ERC5050StateStorage.getSenderProxy(action.from._address); } if(_from.isContract()){ try IERC5050Sender(_from).sendAction{ value: msg.value }(action) {} catch (bytes memory reason) { if (reason.length == 0) { revert("call to non ERC5050Sender"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } // Commit action as controller on receiver address _to = action.to._address; if (action.to._address != address(0)) { _to = ERC5050StateStorage.getReceiverProxy(action.to._address); } if(_to.isContract()){ try IERC5050Receiver(_to).onActionReceived{ value: msg.value }(action, nonce) {} catch (bytes memory reason) { if (reason.length == 0) { revert("call to non ERC5050Receiver"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } } function commitAction(Action calldata action, uint256 nonce) external payable virtual onlyCommittableAction(action) { _beforeCommitAction(action, nonce); } function setControllerApproval(address _controller, bytes4 _action, bool _approved) external virtual override(IControllable) { ERC5050StateStorage.layout()._actionControllers[_controller][_action] = _approved; emit ControllerApproval( _controller, _action, _approved ); } function setControllerApprovalForAll(address _controller, bool _approved) external virtual override(IControllable) { ERC5050StateStorage.layout()._universalControllers[_controller] = _approved; emit ControllerApprovalForAll( _controller, _approved ); } function isApprovedController(address _controller, bytes4 _action) external view override(IControllable) returns (bool) { return _isApprovedController(_controller, _action); } function _isApprovedController(address _controller, bytes4 _action) internal view returns (bool) { ERC5050StateStorage.Layout storage store = ERC5050StateStorage.layout(); if (store._universalControllers[_controller]) { return true; } return store._actionControllers[_controller][_action]; } function receivableActions() external view override(IERC5050Receiver) returns (string[] memory) { return ERC5050StateStorage.layout()._receivableActions.names(); } function _registerReceivable(string memory action) internal { ERC5050StateStorage.layout()._receivableActions.add(action); } function _setProxyRegistry(address registry) internal { ERC5050StateStorage.layout().proxyRegistry = IERC5050RegistryClient(registry); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.6; /*********************************************************************************************\ * Author: Hypervisor <[email protected]> (https://twitter.com/0xalxi) * EIP-5050 Interactive NFTs with Modular Environments: https://eips.ethereum.org/EIPS/eip-5050 /*********************************************************************************************/ import {Action, IERC5050Receiver, IERC5050Sender} from "../../interfaces/IERC5050.sol"; import {ActionsSet} from "../../common/ActionsSet.sol"; /// @title ERC-5050 Proxy Registry /// Note: the ERC-165 identifier for this interface is 0x01ffc9a7 interface IERC5050RegistryClient { /// @dev This emits when ownership of a contract changes. event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /// @notice Query if an address implements an interface and through which contract. /// @param _addr Address being queried for the implementer of an interface. /// (If '_addr' is the zero address then 'msg.sender' is assumed.) /// @param _interfaceHash Keccak256 hash of the name of the interface as a string. /// E.g., 'web3.utils.keccak256("ERC777TokensRecipient")' for the 'ERC777TokensRecipient' interface. /// @return The address of the contract which implements the interface '_interfaceHash' for '_addr' /// or '0' if '_addr' did not register an implementer for this interface. function getInterfaceImplementer(address _addr, bytes4 _interfaceHash) external view returns (address); } library ERC5050StateStorage { using ActionsSet for ActionsSet.Set; bytes32 constant ERC_5050_STORAGE_POSITION = keccak256("erc5050.storage.location"); IERC5050RegistryClient constant ERC_5050_PROXY_REGISTRY = IERC5050RegistryClient(0x5050f71E270671315B460F5C4C37A82deAE6F77D); struct Layout { IERC5050RegistryClient proxyRegistry; bool proxyDisabled; ActionsSet.Set _receivableActions; mapping(address => mapping(bytes4 => bool)) _actionControllers; mapping(address => bool) _universalControllers; uint256 receiverLock; } function layout() internal pure returns (Layout storage es) { bytes32 position = ERC_5050_STORAGE_POSITION; assembly { es.slot := position } } function getProxyRegistry() internal view returns (IERC5050RegistryClient) { Layout storage store = layout(); if(address(store.proxyRegistry) == address(0) && !store.proxyDisabled){ return ERC_5050_PROXY_REGISTRY; } return store.proxyRegistry; } function getReceiverProxy(address _addr) internal view returns (address) { IERC5050RegistryClient proxyRegistry = getProxyRegistry(); if(address(proxyRegistry) == address(0)){ return _addr; } if(_addr == address(0)) { return _addr; } return proxyRegistry.getInterfaceImplementer(_addr, type(IERC5050Receiver).interfaceId); } function getSenderProxy(address _addr) internal view returns (address) { IERC5050RegistryClient proxyRegistry = getProxyRegistry(); if(address(proxyRegistry) == address(0)){ return _addr; } if(_addr == address(0)) { return _addr; } return proxyRegistry.getInterfaceImplementer(_addr, type(IERC5050Sender).interfaceId); } function setProxyRegistry(address _addr) internal { layout().proxyRegistry = IERC5050RegistryClient(_addr); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.13; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; interface IAnomuraData { struct Data { string[] body; string[] claws; string[] legs; string[] shell; string[] headPieces; string[] background; string[] prefixes; string[] suffixes; string[] unique; string[] backgroundPrefixes; } function getAnomuraData() external view returns (Data memory); } contract AnomuraData is IAnomuraData, Ownable { string[] private clawData; string[] private legData; string[] private bodyData; string[] private shellData; string[] private backgroundData; string[] private headpiecesData; string[] private prefixesData; string[] private uniqueData; string[] private suffixesData; string[] private backgroundPrefixesData; constructor() { clawData.push("Natural Claw"); clawData.push("Coral Claw"); clawData.push("Titian Claw"); clawData.push("Pliers"); clawData.push("Scissorhands"); clawData.push("Laser Gun"); clawData.push("Snow Claw"); clawData.push("Sky Claw"); clawData.push("Icicle Claw"); clawData.push("Pincers"); clawData.push("Hammer Logs"); clawData.push("Carnivora Claw"); clawData.push("Adventure Claw"); clawData.push("Asteroids Lasergun"); clawData.push("Pong Claw"); legData.push("Argent Leg"); legData.push("Sunlit Leg"); legData.push("Auroral Leg"); legData.push("Steel Leg"); legData.push("Tungsten Leg"); legData.push("Titanium Leg"); legData.push("Crystal Leg"); legData.push("Empyrean Leg"); legData.push("Azure Leg"); legData.push("Bamboo Leg"); legData.push("Walmara Leg"); legData.push("Pintobortri Leg"); legData.push("Adventure Leg"); legData.push("Asteroids Leg"); legData.push("Pong Leg"); bodyData.push("Premier Body"); bodyData.push("Unhinged Body"); bodyData.push("Mesmerizing Body"); bodyData.push("Rave Body"); bodyData.push("Combustion Body"); bodyData.push("Radiating Eye"); bodyData.push("Charring Body"); bodyData.push("Inferno Body"); bodyData.push("Siberian Body"); bodyData.push("Antarctic Body"); bodyData.push("Glacial Body"); bodyData.push("Amethyst Body"); bodyData.push("Beast"); bodyData.push("Panga Panga"); bodyData.push("Ceylon Ebony"); bodyData.push("Katalox"); bodyData.push("Diamond"); bodyData.push("Golden"); bodyData.push("Adventure Body"); bodyData.push("Asteroids Body"); bodyData.push("Pong Body"); shellData.push("Auger Shell"); shellData.push("Seasnail Shell"); shellData.push("Miter Shell"); shellData.push("Alembic"); shellData.push("Chimney"); shellData.push("Starship"); shellData.push("Ice Cube"); shellData.push("Ice Shell"); shellData.push("Frosty"); shellData.push("Mora"); shellData.push("Carnivora"); shellData.push("Pure Runes"); shellData.push("Architect"); shellData.push("Bee Hive"); shellData.push("Coral"); shellData.push("Crystal"); shellData.push("Diamond"); shellData.push("Ethereum"); shellData.push("Golden Skull"); shellData.push("Japan Temple"); shellData.push("Planter"); shellData.push("Snail"); shellData.push("Tentacles"); shellData.push("Tesla Coil"); shellData.push("Cherry Blossom"); shellData.push("Maple Green"); shellData.push("Volcano"); shellData.push("Adventure Shell"); shellData.push("Asteroids Shell"); shellData.push("Pong Shell"); backgroundData.push("Crystal Cave"); backgroundData.push("Crystal Cave Rainbow"); backgroundData.push("Emerald Forest"); backgroundData.push("Garden of Eden"); backgroundData.push("Golden Glade"); backgroundData.push("Beach"); backgroundData.push("Magical Deep Sea"); backgroundData.push("Natural Sea"); backgroundData.push("Bioluminescent Abyss"); backgroundData.push("Blazing Furnace"); backgroundData.push("Steam Apparatus"); backgroundData.push("Science Lab"); backgroundData.push("Starship Throne"); backgroundData.push("Happy Snowfield"); backgroundData.push("Midnight Mountain"); backgroundData.push("Cosmic Star"); backgroundData.push("Sunset Cliffs"); backgroundData.push("Space Nebula"); backgroundData.push("Plains of Vietnam"); backgroundData.push("ZED Run"); backgroundData.push("African Savannah"); backgroundData.push("Adventure Space"); backgroundData.push("Asteroids Space"); backgroundData.push("Pong Space"); headpiecesData.push("Morning Sun Starfish"); headpiecesData.push("Granulated Starfish"); headpiecesData.push("Royal Starfish"); headpiecesData.push("Sapphire"); headpiecesData.push("Emerald"); headpiecesData.push("Kunzite"); headpiecesData.push("Rhodonite"); headpiecesData.push("Aventurine"); headpiecesData.push("Peridot"); headpiecesData.push("Moldavite"); headpiecesData.push("Jasper"); headpiecesData.push("Alexandrite"); headpiecesData.push("Copper Fire"); headpiecesData.push("Chemical Fire"); headpiecesData.push("Carmine Fire"); headpiecesData.push("Adventure Key"); prefixesData.push("Briny"); prefixesData.push("Tempestuous"); prefixesData.push("Limpid"); prefixesData.push("Pacific"); prefixesData.push("Atlantic"); prefixesData.push("Abysmal"); prefixesData.push("Profound"); prefixesData.push("Misty"); prefixesData.push("Solar"); prefixesData.push("Empyrean"); prefixesData.push("Sideral"); prefixesData.push("Astral"); prefixesData.push("Ethereal"); prefixesData.push("Crystal"); prefixesData.push("Quantum"); prefixesData.push("Empiric"); prefixesData.push("Alchemic"); prefixesData.push("Crash Test"); prefixesData.push("Nuclear"); prefixesData.push("Syntethic"); prefixesData.push("Tempered"); prefixesData.push("Fossil"); prefixesData.push("Craggy"); prefixesData.push("Gemmed"); prefixesData.push("Verdant"); prefixesData.push("Lymphatic"); prefixesData.push("Gnarled"); prefixesData.push("Lithic"); suffixesData.push("of the Coast"); suffixesData.push("of Maelstrom"); suffixesData.push("of Depths"); suffixesData.push("of Eternity"); suffixesData.push("of Peace"); suffixesData.push("of Equilibrium"); suffixesData.push("of the Universe"); suffixesData.push("of the Galaxy"); suffixesData.push("of Absolute Zero"); suffixesData.push("of Constellations"); suffixesData.push("of the Moon"); suffixesData.push("of Lightspeed"); suffixesData.push("of Evidence"); suffixesData.push("of Relativity"); suffixesData.push("of Evolution"); suffixesData.push("of Consumption"); suffixesData.push("of Progress"); suffixesData.push("of Damascus"); suffixesData.push("of Gaia"); suffixesData.push("of The Wild"); suffixesData.push("of Overgrowth"); suffixesData.push("of Rebirth"); suffixesData.push("of World Roots"); suffixesData.push("of Stability"); uniqueData.push("The Leviathan"); uniqueData.push("Will of Oceanus"); uniqueData.push("Suijin's Touch"); uniqueData.push("Tiamat Kiss"); uniqueData.push("Poseidon Vow"); uniqueData.push("Long bao"); uniqueData.push("Uranus Wish"); uniqueData.push("Aim of Indra"); uniqueData.push("Cry of Yuki Onna"); uniqueData.push("Sirius"); uniqueData.push("Vega"); uniqueData.push("Altair"); uniqueData.push("Ephestos Skill"); uniqueData.push("Gift of Prometheus"); uniqueData.push("Pandora's"); uniqueData.push("Wit of Lu Dongbin"); uniqueData.push("Thoth's Trick"); uniqueData.push("Cyclopes Plan"); uniqueData.push("Root of Dimu"); uniqueData.push("Bhumi's Throne"); uniqueData.push("Rive of Daphne"); uniqueData.push("The Minotaur"); uniqueData.push("Call of Cernunnos"); uniqueData.push("Graze of Terra"); backgroundPrefixesData.push("Bountiful"); backgroundPrefixesData.push("Isolated"); backgroundPrefixesData.push("Mechanical"); backgroundPrefixesData.push("Reborn"); } function getAnomuraData() external view returns (Data memory anomuraData) { anomuraData = Data({ body: bodyData, claws: clawData, legs: legData, shell: shellData, headPieces: headpiecesData, background: backgroundData, prefixes: prefixesData, suffixes: suffixesData, unique: uniqueData, backgroundPrefixes: backgroundPrefixesData }); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.13; import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import { AccessControlEnumerableUpgradeable, IAccessControlEnumerableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; import {ERC721HolderUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol"; import {ERC1155ReceiverUpgradeable, IERC1155ReceiverUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC1155/utils/ERC1155ReceiverUpgradeable.sol"; import { IERC5050Sender, IERC5050Receiver, Action, Object } from "@sharedstate/verbs/contracts/interfaces/IERC5050.sol"; import { ERC5050State } from "@sharedstate/verbs/contracts/upgradeable/state/ERC5050State.sol"; import { ERC5050StateStorage } from "@sharedstate/verbs/contracts/upgradeable/state/ERC5050StateStorage.sol"; import { IERC721 } from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import { ActionsSet } from "@sharedstate/verbs/contracts/common/ActionsSet.sol"; interface IUniversalEquipmentManager { error InvalidCollectionType(); error AlreadyEquipped(); error RecursiveEquip(); function getLastActionOnNft(address _address, uint256 _id) external view returns(uint256); } /// @notice UniversalEquipmentManager contract contract UniversalEquipmentManager is IUniversalEquipmentManager, Initializable, AccessControlEnumerableUpgradeable, ERC721HolderUpgradeable, ERC1155ReceiverUpgradeable, ERC5050State { using ActionsSet for ActionsSet.Set; using ERC5050StateStorage for ERC5050StateStorage.Layout; /// @notice Bind action from a token in general collection event UniversalBind(address fromAddress, uint256 fromToken, address toAddress, uint256 toToken, address user); /// @notice Unbind action from a token in general collection event UniversalUnbind(address fromAddress, uint256 fromToken, address toAddress, uint256 toToken, address user); bytes4 constant ERC721_TYPE = bytes4(keccak256(abi.encodePacked("ERC721"))); bytes4 constant ERC1155_TYPE = bytes4(keccak256(abi.encodePacked("ERC1155"))); bytes4 constant EQUIP_SELECTOR = bytes4(keccak256("equip")); bytes4 constant UNEQUIP_SELECTOR = bytes4(keccak256("unequip")); /// @notice maps holder token ids to number of equipments bound to them. mapping(address=>mapping(uint256 => uint256)) public equipmentCountOf; /// @notice maps holder token ids to map of their equipments. mapping(address=>mapping(uint256 => mapping(uint256 => Object))) public equipmentsOf; /// @notice maps holder token ids to map of equipment data indexes. mapping(address=>mapping(uint256 => mapping(address => mapping(uint256 => uint256)))) public equipmentIndexOf; /// @notice maps ERC721 equipment to its holder token id (not ERC1155 compatible) mapping(address=>mapping(uint256 => Object)) public equippedTo; bytes32 public constant EXTERNAL_BIND = keccak256("EXTERNAL_BIND"); bool public isPaused; event Log(string msg); /** * @dev Keep track of last action from */ mapping(address=>mapping(uint256 => uint256)) private lastActionAtBlock; function initialize() external initializer { __ERC721Holder_init(); __AccessControlEnumerable_init(); isPaused = false; _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _registerReceivable("equip"); _registerReceivable("unequip"); } function onActionReceived(Action calldata action, uint256 _nonce) external payable override onlyReceivableAction(action, _nonce) { // TODO: require action.from._address.supportsInterface(ERC721InterfaceId) // Need to be able to check ownerOf tokenId on sender, which we cannot do with ERC1155 // Pass action to state receiver if (action.selector == EQUIP_SELECTOR) { bytes4 collectionType; bytes calldata _data = action.data; assembly { // Get first 4 bytes collectionType := calldataload(_data.offset) } _equip( action.from, action.to, collectionType ); } else if (action.selector == UNEQUIP_SELECTOR) { bytes4 collectionType; bytes calldata _data = action.data; assembly { // Get first 4 bytes collectionType := calldataload(_data.offset) } _unequip( action.from, action.to, collectionType ); } _onActionReceived(action); } /** @notice Bound an `_equipmentId` from `_equipmentContract` into `_anomuraId` @dev Get index of next bound equipment by using equipmentCountOf @dev Cache this new equipment to be at this index, within equimentIndexOf @dev Cache new backpack data into equipmentOf, using this index @dev increase equipment count for this anomura @param from Object of where the action initiated from @param to Object of where the action perform to @param _collectionType type of collection ~ ERC721 ERC1155 */ function _equip( Object memory from, Object memory to, bytes4 _collectionType ) internal { // Prevent equipped items from themselves equipping other items if (equippedTo[from._address][from._tokenId]._address != address(0)) { revert RecursiveEquip(); } if(equippedTo[to._address][to._tokenId]._address != address(0)){ revert ("Already equipped"); } if (isPaused) { revert ("Paused"); } uint256 equipmentIndex = equipmentCountOf[from._address][from._tokenId]; equipmentIndexOf[from._address][from._tokenId][to._address][to._tokenId] = equipmentIndex; equipmentsOf[from._address][from._tokenId][equipmentIndex] = to; equipmentCountOf[from._address][from._tokenId] = equipmentIndex + 1; if(_collectionType == ERC721_TYPE){ // Allows equipment to be transferred by address owner = IERC721(to._address).ownerOf(to._tokenId); if(owner != address(this)){ IERC721(to._address).transferFrom(owner, address(this), to._tokenId); } equippedTo[to._address][to._tokenId] = from; } else if(_collectionType == ERC1155_TYPE){ revert ("Not yet supported 1155"); } else { revert ("Invalid collection equip type"); } emit UniversalBind( from._address, from._tokenId, to._address, to._tokenId, tx.origin ); } /** @notice Unbound an `_equipmentId` of `_equipmentContract` from `_anomuraId`, sends to owner of `_anomuraId` @param from Object of where the action initiated from @param to Object of where the action perform to @param _collectionType type of collection ~ ERC721 ERC1155 */ function _unequip( Object memory from, Object memory to, bytes4 _collectionType ) internal { uint256 equipmentIndex = equipmentIndexOf[from._address][from._tokenId][to._address][to._tokenId]; { if(equipmentsOf[from._address][from._tokenId][equipmentIndex]._tokenId != to._tokenId){ revert("Not equipped" ); } if (isPaused) { revert ("Paused"); } } uint256 lastIndex = --equipmentCountOf[from._address][from._tokenId]; Object memory lastEquipment = equipmentsOf[from._address][from._tokenId][lastIndex]; equipmentsOf[from._address][from._tokenId][equipmentIndex] = lastEquipment; equipmentIndexOf[from._address][from._tokenId][lastEquipment._address][lastEquipment._tokenId] = equipmentIndex; delete equipmentIndexOf[from._address][from._tokenId][to._address][to._tokenId]; delete equipmentsOf[from._address][from._tokenId][lastIndex]; if(_collectionType == ERC721_TYPE){ address holderOwner; try IERC721(from._address).ownerOf(from._tokenId) returns (address _owner) { holderOwner = _owner; } catch (bytes memory reason) { if (reason.length == 0) { revert("call to non ERC721"); } else { assembly { revert(add(32, reason), mload(reason)) } } } // address holderOwner = IERC721(from._address).ownerOf(from._tokenId); if(holderOwner != address(this)){ IERC721(to._address).transferFrom(address(this), holderOwner, to._tokenId); } delete equippedTo[to._address][to._tokenId]; }else if(_collectionType == ERC1155_TYPE){ revert ("Not yet supported 1155"); } else { revert InvalidCollectionType(); } lastActionAtBlock[from._address][from._tokenId] = block.number; emit UniversalUnbind( from._address, from._tokenId, to._address, to._tokenId, tx.origin ); } /** @notice Directly commit actions without passing through sender and receiver. Saves gas by bypassing all validation steps, requires the sender and receiver both have approved this contract as a Controller (ex: call `setControllerApprovalForAll(this_address, true)` on the sending/receiving contract). */ function commitAction(Action calldata action, uint256 _nonce) external payable virtual override(ERC5050State) onlyCommittableAction(action) { // // check ownership of nfts is either msg.sender // if (IERC721(action.from._address).ownerOf(action.from._tokenId) != _msgSender()) { // revert ("Invalid Owner"); // } _beforeCommitAction(action, _nonce); if (action.selector == EQUIP_SELECTOR) { bytes4 collectionType; bytes calldata _data = action.data; assembly { // Get first 4 bytes collectionType := calldataload(_data.offset) } _equip( action.from, action.to, collectionType ); } else if (action.selector == UNEQUIP_SELECTOR) { bytes4 collectionType; bytes calldata _data = action.data; assembly { // Get first 4 bytes collectionType := calldataload(_data.offset) } _unequip( action.from, action.to, collectionType ); } } /// @notice returns all equipments bound to an anomura. /// @param _tokenId id of the anomura to get the equipment list. /// @return equipments array. function allEquipmentsOf(address _contract, uint256 _tokenId) external view returns (Object[] memory equipments) { uint256 count = equipmentCountOf[_contract][_tokenId]; equipments = new Object[](count); for (uint256 i = 0; i < count; i++) equipments[i] = equipmentsOf[_contract][_tokenId][i]; } function supportsInterface(bytes4 interfaceId) public view override(AccessControlEnumerableUpgradeable, ERC1155ReceiverUpgradeable) returns (bool) { return type(IAccessControlEnumerableUpgradeable).interfaceId == interfaceId || type(IERC1155ReceiverUpgradeable).interfaceId == interfaceId || type(IERC5050Receiver).interfaceId == interfaceId || super.supportsInterface(interfaceId); } function onERC1155Received( address, address, uint256, uint256, bytes calldata ) external pure override returns (bytes4) { return IERC1155ReceiverUpgradeable.onERC1155Received.selector; } function onERC1155BatchReceived( address, address, uint256[] calldata, uint256[] calldata, bytes calldata ) external pure override returns (bytes4) { return IERC1155ReceiverUpgradeable.onERC1155BatchReceived.selector; } function setContractPause(bool isPaused_) external onlyRole(DEFAULT_ADMIN_ROLE) { isPaused = isPaused_; } function registerReceivable(string memory action) external onlyRole(DEFAULT_ADMIN_ROLE) { _registerReceivable(action); } function setProxyRegistry(address registry) external onlyRole(DEFAULT_ADMIN_ROLE) { _setProxyRegistry(registry); } function getProxyRegistry() external view returns (address) { return address(ERC5050StateStorage.layout().proxyRegistry); } function getLastActionOnNft(address _address, uint256 _id) external view returns (uint256) { return lastActionAtBlock[_address][_id]; } }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"owner","type":"address"}],"name":"ContractDeployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"crabId","type":"uint256"},{"indexed":false,"internalType":"string","name":"claws","type":"string"},{"indexed":false,"internalType":"string","name":"legs","type":"string"},{"indexed":false,"internalType":"string","name":"body","type":"string"},{"indexed":false,"internalType":"string","name":"shell","type":"string"},{"indexed":false,"internalType":"string","name":"background","type":"string"},{"indexed":false,"internalType":"string","name":"headpieces","type":"string"}],"name":"NewAnomura","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"bowlAddress","type":"address"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"UpdatedBowlContractAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isPaused","type":"bool"},{"indexed":false,"internalType":"address","name":"updatedBy","type":"address"}],"name":"UpdatedPauseContract","type":"event"},{"inputs":[],"name":"anomuraData","outputs":[{"internalType":"contract IAnomuraData","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"anomuraMap","outputs":[{"internalType":"string","name":"body","type":"string"},{"internalType":"string","name":"claws","type":"string"},{"internalType":"string","name":"legs","type":"string"},{"internalType":"string","name":"shell","type":"string"},{"internalType":"string","name":"headPieces","type":"string"},{"internalType":"string","name":"background","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bowlAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_bowlAddress","type":"address"},{"internalType":"address","name":"_anomuraDataAddress","type":"address"},{"internalType":"string","name":"_baseURI","type":"string"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"mintAnomura","outputs":[{"internalType":"uint256","name":"anomuraId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"ownerMintAnomura","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_anomuraDataAddress","type":"address"}],"name":"setAnomuraData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_baseURI","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_bowlAddress","type":"address"}],"name":"setBowlAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_isPaused","type":"bool"}],"name":"setContractPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"universalManager_","type":"address"}],"name":"setUniversalManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_ownerAddr","type":"address"}],"name":"tokensOfOwner","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"universalEquipmentManager","outputs":[{"internalType":"contract IUniversalEquipmentManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdrawAvailableBalance","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50613a17806100206000396000f3fe608060405234801561001057600080fd5b50600436106102065760003560e01c80638697897e1161011a578063b1111359116100ad578063c87b56dd1161007c578063c87b56dd1461045b578063d148433f1461046e578063e985e9c514610487578063f2fde38b146104c3578063fd01179d146104d657600080fd5b8063b11113591461041e578063b187bd2614610426578063b3b446e214610434578063b88d4fde1461044857600080fd5b806395d89b41116100e957806395d89b41146103cb57806399708b4f146103d3578063a22cb465146103f8578063a84df8b51461040b57600080fd5b80638697897e14610380578063882796f1146103935780638da5cb5b146103a657806395854efb146103b757600080fd5b80634571e3a61161019d57806357dd845b1161016c57806357dd845b1461031f5780636352211e1461033257806370a0823114610345578063715018a6146103585780638462151c1461036057600080fd5b80634571e3a6146102d35780634cab291d146102e65780634f6ccce7146102f957806355f804b31461030c57600080fd5b806318160ddd116101d957806318160ddd1461028857806323b872dd1461029a5780632f745c59146102ad57806342842e0e146102c057600080fd5b806301ffc9a71461020b57806306fdde0314610233578063081812fc14610248578063095ea7b314610273575b600080fd5b61021e610219366004612e60565b6104e9565b60405190151581526020015b60405180910390f35b61023b6104fa565b60405161022a9190612edc565b61025b610256366004612eef565b61058c565b6040516001600160a01b03909116815260200161022a565b610286610281366004612f24565b6105b3565b005b6099545b60405190815260200161022a565b6102866102a8366004612f4e565b6106cd565b61028c6102bb366004612f24565b6106fe565b6102866102ce366004612f4e565b610794565b6102866102e1366004612fd3565b6107af565b6102866102f4366004613034565b610a55565b61028c610307366004612eef565b610a86565b61028661031a36600461304f565b610b19565b61028c61032d366004613034565b610b2e565b61025b610340366004612eef565b61107a565b61028c610353366004613034565b6110da565b610286611160565b61037361036e366004613034565b611174565b60405161022a9190613091565b61028661038e366004613034565b611216565b6102866103a13660046130e5565b611279565b60fb546001600160a01b031661025b565b6101305461025b906001600160a01b031681565b61023b6112c8565b6103e66103e1366004612eef565b6112d7565b60405161022a96959493929190613100565b610286610406366004613182565b61163c565b610286610419366004613034565b61164b565b610286611b47565b6101335461021e9060ff1681565b61012d5461025b906001600160a01b031681565b61028661045636600461324e565b611b7e565b61023b610469366004612eef565b611bb6565b6101335461025b9061010090046001600160a01b031681565b61021e6104953660046132f9565b6001600160a01b039182166000908152606a6020908152604080832093909416825291909152205460ff1690565b6102866104d1366004613034565b611c44565b6102866104e4366004613034565b611cbd565b60006104f482611ce8565b92915050565b60606065805461050990613323565b80601f016020809104026020016040519081016040528092919081815260200182805461053590613323565b80156105825780601f1061055757610100808354040283529160200191610582565b820191906000526020600020905b81548152906001019060200180831161056557829003601f168201915b5050505050905090565b600061059782611d0d565b506000908152606960205260409020546001600160a01b031690565b60006105be8261107a565b9050806001600160a01b0316836001600160a01b0316036106305760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b038216148061064c575061064c8133610495565b6106be5760405162461bcd60e51b815260206004820152603e60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206e6f7220617070726f76656420666f7220616c6c00006064820152608401610627565b6106c88383611d6c565b505050565b6106d73382611dda565b6106f35760405162461bcd60e51b81526004016106279061335d565b6106c8838383611e59565b6000610709836110da565b821061076b5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610627565b506001600160a01b03919091166000908152609760209081526040808320938352929052205490565b6106c883838360405180602001604052806000815250611b7e565b600054610100900460ff16158080156107cf5750600054600160ff909116105b806107e95750303b1580156107e9575060005460ff166001145b61084c5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610627565b6000805460ff19166001179055801561086f576000805461ff0019166101001790555b6001600160a01b0385166108c55760405162461bcd60e51b815260206004820152601a60248201527f426f776c20636f6e7472616374206164647265737320697320300000000000006044820152606401610627565b6001600160a01b03841661091b5760405162461bcd60e51b815260206004820152601960248201527f416e6f6d757261204461746120616464726573732069732030000000000000006044820152606401610627565b61096360405180604001604052806007815260200166416e6f6d75726160c81b81525060405180604001604052806007815260200166414e4f4d55524160c81b815250612000565b61096b612031565b610973612058565b61097b612087565b61098861012f8484612cea565b5061013080546001600160a01b038088166001600160a01b03199283161790925561012d805492871692909116919091179055610133805460ff191690556109d561012e80546001019055565b6040513381527f8ffcdc15a283d706d38281f500270d8b5a656918f555de0913d7455e3e6bc1bf9060200160405180910390a18015610a4e576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050565b610a5d6120b6565b61013380546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b6000610a9160995490565b8210610af45760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610627565b60998281548110610b0757610b076133ab565b90600052602060002001549050919050565b610b216120b6565b6106c861012f8383612cea565b6101335460009060ff1615610b7a5760405162461bcd60e51b815260206004820152601260248201527110dbdb9d1c9858dd081a5cc81c185d5cd95960721b6044820152606401610627565b600260c95403610bcc5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610627565b600260c955610130546001600160a01b03163314610c2c5760405162461bcd60e51b815260206004820152601a60248201527f43616e206f6e6c792062652063616c6c656420627920426f776c0000000000006044820152606401610627565b61012d546001600160a01b0316610c815760405162461bcd60e51b81526020600482015260196024820152780416e6f6d75726120646174612061646472657373206973203603c1b6044820152606401610627565b6040516001600160601b0319606084811b8216602084015241901b16603482015260480160408051808303601f1901815291905280516020909101206101315561012e549050610ccf612d6e565b61012d60009054906101000a90046001600160a01b03166001600160a01b03166366030e486040518163ffffffff1660e01b8152600401600060405180830381865afa158015610d23573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610d4b919081019061349c565b90506000610d8a8360405180604001604052806004815260200163434c415760e01b81525084602001518560c001518660e00151876101000151612110565b90506000610dc884604051806040016040528060038152602001624c454760e81b81525085604001518660c001518760e00151886101000151612110565b90506000610e078560405180604001604052806004815260200163424f445960e01b81525086600001518760c001518860e00151896101000151612110565b90506000610e47866040518060400160405280600581526020016414d211531360da1b81525087606001518860c001518960e001518a6101000151612110565b90506000610e82876040518060400160405280600a815260200169109050d2d1d493d5539160b21b8152508860a001518961012001516122ae565b90506000610eb6886040518060400160405280600e81526020016d484156455f48454144504945434560901b81525061235a565b90506000600182151514610ee657604051806040016040528060048152602001634e6f6e6560e01b815250610f26565b610f26896040518060400160405280600981526020016848454144504945434560b81b8152508a608001518b60c001518c60e001518d6101000151612110565b90506040518060c001604052808681526020018881526020018781526020018581526020018281526020018481525061013260008b81526020019081526020016000206000820151816000019080519060200190610f85929190612dc1565b506020828101518051610f9e9260018501920190612dc1565b5060408201518051610fba916002840191602090910190612dc1565b5060608201518051610fd6916003840191602090910190612dc1565b5060808201518051610ff2916004840191602090910190612dc1565b5060a0820151805161100e916005840191602090910190612dc1565b505061012e80546001019055506110258a8a61238d565b887f27201f19e2a284a0ddc5b13bb865386f850f040a07ebeb082286ffa24f2c192588888888888760405161105f96959493929190613100565b60405180910390a25050600160c95550949695505050505050565b6000818152606760205260408120546001600160a01b0316806104f45760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610627565b60006001600160a01b0382166111445760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610627565b506001600160a01b031660009081526068602052604090205490565b6111686120b6565b61117260006123a7565b565b60606000611181836110da565b905060008167ffffffffffffffff81111561119e5761119e6131b5565b6040519080825280602002602001820160405280156111c7578160200160208202803683370190505b50905060005b8281101561120e576111df85826106fe565b8282815181106111f1576111f16133ab565b6020908102919091010152806112068161366a565b9150506111cd565b509392505050565b61121e6120b6565b61013080546001600160a01b0319166001600160a01b038316908117909155604080519182523360208301527f1fc93c6e1b3d3cbdf21cb6110d2bd30ce9c831461f83aab2c2cce8f2a30d4c6f91015b60405180910390a150565b6112816120b6565b610133805460ff1916821515908117909155604080519182523360208301527fa06b5a80dcb0a794bdf9b8683ec488cb83588c4e69e0945b2f87afa8a8448ce0910161126e565b60606066805461050990613323565b610132602052600090815260409020805481906112f390613323565b80601f016020809104026020016040519081016040528092919081815260200182805461131f90613323565b801561136c5780601f106113415761010080835404028352916020019161136c565b820191906000526020600020905b81548152906001019060200180831161134f57829003601f168201915b50505050509080600101805461138190613323565b80601f01602080910402602001604051908101604052809291908181526020018280546113ad90613323565b80156113fa5780601f106113cf576101008083540402835291602001916113fa565b820191906000526020600020905b8154815290600101906020018083116113dd57829003601f168201915b50505050509080600201805461140f90613323565b80601f016020809104026020016040519081016040528092919081815260200182805461143b90613323565b80156114885780601f1061145d57610100808354040283529160200191611488565b820191906000526020600020905b81548152906001019060200180831161146b57829003601f168201915b50505050509080600301805461149d90613323565b80601f01602080910402602001604051908101604052809291908181526020018280546114c990613323565b80156115165780601f106114eb57610100808354040283529160200191611516565b820191906000526020600020905b8154815290600101906020018083116114f957829003601f168201915b50505050509080600401805461152b90613323565b80601f016020809104026020016040519081016040528092919081815260200182805461155790613323565b80156115a45780601f10611579576101008083540402835291602001916115a4565b820191906000526020600020905b81548152906001019060200180831161158757829003601f168201915b5050505050908060050180546115b990613323565b80601f01602080910402602001604051908101604052809291908181526020018280546115e590613323565b80156116325780601f1061160757610100808354040283529160200191611632565b820191906000526020600020905b81548152906001019060200180831161161557829003601f168201915b5050505050905086565b6116473383836123f9565b5050565b6101335460ff16156116945760405162461bcd60e51b815260206004820152601260248201527110dbdb9d1c9858dd081a5cc81c185d5cd95960721b6044820152606401610627565b600260c954036116e65760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610627565b600260c9556116f36120b6565b61012d546001600160a01b03166117485760405162461bcd60e51b81526020600482015260196024820152780416e6f6d75726120646174612061646472657373206973203603c1b6044820152606401610627565b6040516001600160601b0319606083811b8216602084015241901b16603482015260480160408051601f19818403018152919052805160209091012061013155600061179461012e5490565b905061179e612d6e565b61012d60009054906101000a90046001600160a01b03166001600160a01b03166366030e486040518163ffffffff1660e01b8152600401600060405180830381865afa1580156117f2573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261181a919081019061349c565b905060006118598360405180604001604052806004815260200163434c415760e01b81525084602001518560c001518660e00151876101000151612110565b9050600061189784604051806040016040528060038152602001624c454760e81b81525085604001518660c001518760e00151886101000151612110565b905060006118d68560405180604001604052806004815260200163424f445960e01b81525086600001518760c001518860e00151896101000151612110565b90506000611916866040518060400160405280600581526020016414d211531360da1b81525087606001518860c001518960e001518a6101000151612110565b90506000611951876040518060400160405280600a815260200169109050d2d1d493d5539160b21b8152508860a001518961012001516122ae565b90506000611985886040518060400160405280600e81526020016d484156455f48454144504945434560901b81525061235a565b905060006001821515146119b557604051806040016040528060048152602001634e6f6e6560e01b8152506119f5565b6119f5896040518060400160405280600981526020016848454144504945434560b81b8152508a608001518b60c001518c60e001518d6101000151612110565b90506040518060c001604052808681526020018881526020018781526020018581526020018281526020018481525061013260008b81526020019081526020016000206000820151816000019080519060200190611a54929190612dc1565b506020828101518051611a6d9260018501920190612dc1565b5060408201518051611a89916002840191602090910190612dc1565b5060608201518051611aa5916003840191602090910190612dc1565b5060808201518051611ac1916004840191602090910190612dc1565b5060a08201518051611add916005840191602090910190612dc1565b505061012e8054600101905550611af48a8a61238d565b887f27201f19e2a284a0ddc5b13bb865386f850f040a07ebeb082286ffa24f2c1925888888888887604051611b2e96959493929190613100565b60405180910390a25050600160c9555050505050505050565b611b4f6120b6565b6040514790339082156108fc029083906000818181858888f19350505050158015611647573d6000803e3d6000fd5b611b883383611dda565b611ba45760405162461bcd60e51b81526004016106279061335d565b611bb0848484846124c7565b50505050565b6000818152606760205260409020546060906001600160a01b0316611c115760405162461bcd60e51b81526020600482015260116024820152702737b732bc34b9ba32b73a103a37b5b2b760791b6044820152606401610627565b61012f611c1d836124fa565b604051602001611c2e92919061369f565b6040516020818303038152906040529050919050565b611c4c6120b6565b6001600160a01b038116611cb15760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610627565b611cba816123a7565b50565b611cc56120b6565b61012d80546001600160a01b0319166001600160a01b0392909216919091179055565b60006001600160e01b0319821663780e9d6360e01b14806104f457506104f4826125fb565b6000818152606760205260409020546001600160a01b0316611cba5760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610627565b600081815260696020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611da18261107a565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600080611de68361107a565b9050806001600160a01b0316846001600160a01b03161480611e2d57506001600160a01b038082166000908152606a602090815260408083209388168352929052205460ff165b80611e515750836001600160a01b0316611e468461058c565b6001600160a01b0316145b949350505050565b826001600160a01b0316611e6c8261107a565b6001600160a01b031614611ed05760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608401610627565b6001600160a01b038216611f325760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610627565b611f3d83838361264b565b611f48600082611d6c565b6001600160a01b0383166000908152606860205260408120805460019290611f71908490613745565b90915550506001600160a01b0382166000908152606860205260408120805460019290611f9f90849061375c565b909155505060008181526067602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600054610100900460ff166120275760405162461bcd60e51b815260040161062790613774565b611647828261272c565b600054610100900460ff166111725760405162461bcd60e51b815260040161062790613774565b600054610100900460ff1661207f5760405162461bcd60e51b815260040161062790613774565b61117261277a565b600054610100900460ff166120ae5760405162461bcd60e51b815260040161062790613774565b6111726127a8565b60fb546001600160a01b031633146111725760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610627565b60606000612146876121218a6124fa565b6040516020016121329291906137bf565b6040516020818303038152906040526127d8565b90506000868751836121589190613804565b81518110612168576121686133ab565b602002602001015190506000605e836121819190613804565b9050605c8111156121df578485518461219a9190613804565b815181106121aa576121aa6133ab565b6020026020010151826040516020016121c4929190613818565b60408051601f1981840301815291905293506122a492505050565b605381111561224757868751846121f69190613804565b81518110612206576122066133ab565b6020026020010151828788518661221d9190613804565b8151811061222d5761222d6133ab565b60200260200101516040516020016121c493929190613854565b604a81111561228857818687518561225f9190613804565b8151811061226f5761226f6133ab565b60200260200101516040516020016121c4929190613818565b604181111561229f578687518461219a9190613804565b509150505b9695505050505050565b606060006122bf85612121886124fa565b90506000848551836122d19190613804565b815181106122e1576122e16133ab565b6020026020010151905060006033836122fa9190613804565b9050602d81111561234f57848551846123139190613804565b81518110612323576123236133ab565b60200260200101518260405160200161233d929190613818565b60405160208183030381529060405291505b509695505050505050565b600080606561236c84612121876124fa565b6123769190613804565b9050605f81111561238657600191505b5092915050565b611647828260405180602001604052806000815250612823565b60fb80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b03160361245a5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610627565b6001600160a01b038381166000818152606a6020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6124d2848484611e59565b6124de84848484612856565b611bb05760405162461bcd60e51b8152600401610627906138ae565b6060816000036125215750506040805180820190915260018152600360fc1b602082015290565b8160005b811561254b57806125358161366a565b91506125449050600a83613900565b9150612525565b60008167ffffffffffffffff811115612566576125666131b5565b6040519080825280601f01601f191660200182016040528015612590576020820181803683370190505b5090505b8415611e51576125a5600183613745565b91506125b2600a86613804565b6125bd90603061375c565b60f81b8183815181106125d2576125d26133ab565b60200101906001600160f81b031916908160001a9053506125f4600a86613900565b9450612594565b60006001600160e01b031982166380ac58cd60e01b148061262c57506001600160e01b03198216635b5e139f60e01b145b806104f457506301ffc9a760e01b6001600160e01b03198316146104f4565b6101335460405163e303033f60e01b81523060048201526024810183905260009161010090046001600160a01b03169063e303033f90604401602060405180830381865afa1580156126a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126c59190613914565b9050436126d382600461375c565b11156127215760405162461bcd60e51b815260206004820152601e60248201527f4e6f207472616e7366657220726967687420616674657220616374696f6e00006044820152606401610627565b611bb0848484612954565b600054610100900460ff166127535760405162461bcd60e51b815260040161062790613774565b8151612766906065906020850190612dc1565b5080516106c8906066906020840190612dc1565b600054610100900460ff166127a15760405162461bcd60e51b815260040161062790613774565b600160c955565b600054610100900460ff166127cf5760405162461bcd60e51b815260040161062790613774565b611172336123a7565b6000813a3342486127ea600143613745565b4061013154604051602001612805979695949392919061392d565b60408051601f19818403018152919052805160209091012092915050565b61282d8383612a0c565b61283a6000848484612856565b6106c85760405162461bcd60e51b8152600401610627906138ae565b60006001600160a01b0384163b1561294c57604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061289a90339089908890889060040161397b565b6020604051808303816000875af19250505080156128d5575060408051601f3d908101601f191682019092526128d2918101906139ae565b60015b612932573d808015612903576040519150601f19603f3d011682016040523d82523d6000602084013e612908565b606091505b50805160000361292a5760405162461bcd60e51b8152600401610627906138ae565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611e51565b506001611e51565b6001600160a01b0383166129af576129aa81609980546000838152609a60205260408120829055600182018355919091527f72a152ddfb8e864297c917af52ea6c1c68aead0fee1a62673fcc7e0c94979d000155565b6129d2565b816001600160a01b0316836001600160a01b0316146129d2576129d28382612b5a565b6001600160a01b0382166129e9576106c881612bf7565b826001600160a01b0316826001600160a01b0316146106c8576106c88282612ca6565b6001600160a01b038216612a625760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610627565b6000818152606760205260409020546001600160a01b031615612ac75760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610627565b612ad36000838361264b565b6001600160a01b0382166000908152606860205260408120805460019290612afc90849061375c565b909155505060008181526067602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60006001612b67846110da565b612b719190613745565b600083815260986020526040902054909150808214612bc4576001600160a01b03841660009081526097602090815260408083208584528252808320548484528184208190558352609890915290208190555b5060009182526098602090815260408084208490556001600160a01b039094168352609781528383209183525290812055565b609954600090612c0990600190613745565b6000838152609a602052604081205460998054939450909284908110612c3157612c316133ab565b906000526020600020015490508060998381548110612c5257612c526133ab565b6000918252602080832090910192909255828152609a90915260408082208490558582528120556099805480612c8a57612c8a6139cb565b6001900381819060005260206000200160009055905550505050565b6000612cb1836110da565b6001600160a01b039093166000908152609760209081526040808320868452825280832085905593825260989052919091209190915550565b828054612cf690613323565b90600052602060002090601f016020900481019282612d185760008555612d5e565b82601f10612d315782800160ff19823516178555612d5e565b82800160010185558215612d5e579182015b82811115612d5e578235825591602001919060010190612d43565b50612d6a929150612e35565b5090565b604051806101400160405280606081526020016060815260200160608152602001606081526020016060815260200160608152602001606081526020016060815260200160608152602001606081525090565b828054612dcd90613323565b90600052602060002090601f016020900481019282612def5760008555612d5e565b82601f10612e0857805160ff1916838001178555612d5e565b82800160010185558215612d5e579182015b82811115612d5e578251825591602001919060010190612e1a565b5b80821115612d6a5760008155600101612e36565b6001600160e01b031981168114611cba57600080fd5b600060208284031215612e7257600080fd5b8135612e7d81612e4a565b9392505050565b60005b83811015612e9f578181015183820152602001612e87565b83811115611bb05750506000910152565b60008151808452612ec8816020860160208601612e84565b601f01601f19169290920160200192915050565b602081526000612e7d6020830184612eb0565b600060208284031215612f0157600080fd5b5035919050565b80356001600160a01b0381168114612f1f57600080fd5b919050565b60008060408385031215612f3757600080fd5b612f4083612f08565b946020939093013593505050565b600080600060608486031215612f6357600080fd5b612f6c84612f08565b9250612f7a60208501612f08565b9150604084013590509250925092565b60008083601f840112612f9c57600080fd5b50813567ffffffffffffffff811115612fb457600080fd5b602083019150836020828501011115612fcc57600080fd5b9250929050565b60008060008060608587031215612fe957600080fd5b612ff285612f08565b935061300060208601612f08565b9250604085013567ffffffffffffffff81111561301c57600080fd5b61302887828801612f8a565b95989497509550505050565b60006020828403121561304657600080fd5b612e7d82612f08565b6000806020838503121561306257600080fd5b823567ffffffffffffffff81111561307957600080fd5b61308585828601612f8a565b90969095509350505050565b6020808252825182820181905260009190848201906040850190845b818110156130c9578351835292840192918401916001016130ad565b50909695505050505050565b80358015158114612f1f57600080fd5b6000602082840312156130f757600080fd5b612e7d826130d5565b60c08152600061311360c0830189612eb0565b82810360208401526131258189612eb0565b905082810360408401526131398188612eb0565b9050828103606084015261314d8187612eb0565b905082810360808401526131618186612eb0565b905082810360a08401526131758185612eb0565b9998505050505050505050565b6000806040838503121561319557600080fd5b61319e83612f08565b91506131ac602084016130d5565b90509250929050565b634e487b7160e01b600052604160045260246000fd5b604051610140810167ffffffffffffffff811182821017156131ef576131ef6131b5565b60405290565b604051601f8201601f1916810167ffffffffffffffff8111828210171561321e5761321e6131b5565b604052919050565b600067ffffffffffffffff821115613240576132406131b5565b50601f01601f191660200190565b6000806000806080858703121561326457600080fd5b61326d85612f08565b935061327b60208601612f08565b925060408501359150606085013567ffffffffffffffff81111561329e57600080fd5b8501601f810187136132af57600080fd5b80356132c26132bd82613226565b6131f5565b8181528860208385010111156132d757600080fd5b8160208401602083013760006020838301015280935050505092959194509250565b6000806040838503121561330c57600080fd5b61331583612f08565b91506131ac60208401612f08565b600181811c9082168061333757607f821691505b60208210810361335757634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252602e908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526d1c881b9bdc88185c1c1c9bdd995960921b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b600082601f8301126133d257600080fd5b8151602067ffffffffffffffff808311156133ef576133ef6131b5565b8260051b6133fe8382016131f5565b938452858101830193838101908886111561341857600080fd5b84880192505b85831015613490578251848111156134365760008081fd5b8801603f81018a136134485760008081fd5b85810151604061345a6132bd83613226565b8281528c8284860101111561346f5760008081fd5b61347e838a8301848701612e84565b8552505050918401919084019061341e565b98975050505050505050565b6000602082840312156134ae57600080fd5b815167ffffffffffffffff808211156134c657600080fd5b9083019061014082860312156134db57600080fd5b6134e36131cb565b8251828111156134f257600080fd5b6134fe878286016133c1565b82525060208301518281111561351357600080fd5b61351f878286016133c1565b60208301525060408301518281111561353757600080fd5b613543878286016133c1565b60408301525060608301518281111561355b57600080fd5b613567878286016133c1565b60608301525060808301518281111561357f57600080fd5b61358b878286016133c1565b60808301525060a0830151828111156135a357600080fd5b6135af878286016133c1565b60a08301525060c0830151828111156135c757600080fd5b6135d3878286016133c1565b60c08301525060e0830151828111156135eb57600080fd5b6135f7878286016133c1565b60e083015250610100808401518381111561361157600080fd5b61361d888287016133c1565b828401525050610120808401518381111561363757600080fd5b613643888287016133c1565b918301919091525095945050505050565b634e487b7160e01b600052601160045260246000fd5b60006001820161367c5761367c613654565b5060010190565b60008151613695818560208601612e84565b9290920192915050565b600080845481600182811c9150808316806136bb57607f831692505b602080841082036136da57634e487b7160e01b86526022600452602486fd5b8180156136ee57600181146136ff5761372c565b60ff1986168952848901965061372c565b60008b81526020902060005b868110156137245781548b82015290850190830161370b565b505084890196505b50505050505061373c8185613683565b95945050505050565b60008282101561375757613757613654565b500390565b6000821982111561376f5761376f613654565b500190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b600083516137d1818460208801612e84565b8351908301906137e5818360208801612e84565b01949350505050565b634e487b7160e01b600052601260045260246000fd5b600082613813576138136137ee565b500690565b6000835161382a818460208801612e84565b600160fd1b9083019081528351613848816001840160208801612e84565b01600101949350505050565b60008451613866818460208901612e84565b8083019050600160fd1b8082528551613886816001850160208a01612e84565b600192019182015283516138a1816002840160208801612e84565b0160020195945050505050565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60008261390f5761390f6137ee565b500490565b60006020828403121561392657600080fd5b5051919050565b6000885161393f818460208d01612e84565b919091019687525060609490941b6001600160601b0319166020860152603485019290925260548401526074830152609482015260b401919050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906122a490830184612eb0565b6000602082840312156139c057600080fd5b8151612e7d81612e4a565b634e487b7160e01b600052603160045260246000fdfea2646970667358221220eb196d371f690ffd6f236f378e9ee41d59d74becfaa431b5530f8f45c390b88764736f6c634300080d0033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106102065760003560e01c80638697897e1161011a578063b1111359116100ad578063c87b56dd1161007c578063c87b56dd1461045b578063d148433f1461046e578063e985e9c514610487578063f2fde38b146104c3578063fd01179d146104d657600080fd5b8063b11113591461041e578063b187bd2614610426578063b3b446e214610434578063b88d4fde1461044857600080fd5b806395d89b41116100e957806395d89b41146103cb57806399708b4f146103d3578063a22cb465146103f8578063a84df8b51461040b57600080fd5b80638697897e14610380578063882796f1146103935780638da5cb5b146103a657806395854efb146103b757600080fd5b80634571e3a61161019d57806357dd845b1161016c57806357dd845b1461031f5780636352211e1461033257806370a0823114610345578063715018a6146103585780638462151c1461036057600080fd5b80634571e3a6146102d35780634cab291d146102e65780634f6ccce7146102f957806355f804b31461030c57600080fd5b806318160ddd116101d957806318160ddd1461028857806323b872dd1461029a5780632f745c59146102ad57806342842e0e146102c057600080fd5b806301ffc9a71461020b57806306fdde0314610233578063081812fc14610248578063095ea7b314610273575b600080fd5b61021e610219366004612e60565b6104e9565b60405190151581526020015b60405180910390f35b61023b6104fa565b60405161022a9190612edc565b61025b610256366004612eef565b61058c565b6040516001600160a01b03909116815260200161022a565b610286610281366004612f24565b6105b3565b005b6099545b60405190815260200161022a565b6102866102a8366004612f4e565b6106cd565b61028c6102bb366004612f24565b6106fe565b6102866102ce366004612f4e565b610794565b6102866102e1366004612fd3565b6107af565b6102866102f4366004613034565b610a55565b61028c610307366004612eef565b610a86565b61028661031a36600461304f565b610b19565b61028c61032d366004613034565b610b2e565b61025b610340366004612eef565b61107a565b61028c610353366004613034565b6110da565b610286611160565b61037361036e366004613034565b611174565b60405161022a9190613091565b61028661038e366004613034565b611216565b6102866103a13660046130e5565b611279565b60fb546001600160a01b031661025b565b6101305461025b906001600160a01b031681565b61023b6112c8565b6103e66103e1366004612eef565b6112d7565b60405161022a96959493929190613100565b610286610406366004613182565b61163c565b610286610419366004613034565b61164b565b610286611b47565b6101335461021e9060ff1681565b61012d5461025b906001600160a01b031681565b61028661045636600461324e565b611b7e565b61023b610469366004612eef565b611bb6565b6101335461025b9061010090046001600160a01b031681565b61021e6104953660046132f9565b6001600160a01b039182166000908152606a6020908152604080832093909416825291909152205460ff1690565b6102866104d1366004613034565b611c44565b6102866104e4366004613034565b611cbd565b60006104f482611ce8565b92915050565b60606065805461050990613323565b80601f016020809104026020016040519081016040528092919081815260200182805461053590613323565b80156105825780601f1061055757610100808354040283529160200191610582565b820191906000526020600020905b81548152906001019060200180831161056557829003601f168201915b5050505050905090565b600061059782611d0d565b506000908152606960205260409020546001600160a01b031690565b60006105be8261107a565b9050806001600160a01b0316836001600160a01b0316036106305760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b038216148061064c575061064c8133610495565b6106be5760405162461bcd60e51b815260206004820152603e60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206e6f7220617070726f76656420666f7220616c6c00006064820152608401610627565b6106c88383611d6c565b505050565b6106d73382611dda565b6106f35760405162461bcd60e51b81526004016106279061335d565b6106c8838383611e59565b6000610709836110da565b821061076b5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610627565b506001600160a01b03919091166000908152609760209081526040808320938352929052205490565b6106c883838360405180602001604052806000815250611b7e565b600054610100900460ff16158080156107cf5750600054600160ff909116105b806107e95750303b1580156107e9575060005460ff166001145b61084c5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610627565b6000805460ff19166001179055801561086f576000805461ff0019166101001790555b6001600160a01b0385166108c55760405162461bcd60e51b815260206004820152601a60248201527f426f776c20636f6e7472616374206164647265737320697320300000000000006044820152606401610627565b6001600160a01b03841661091b5760405162461bcd60e51b815260206004820152601960248201527f416e6f6d757261204461746120616464726573732069732030000000000000006044820152606401610627565b61096360405180604001604052806007815260200166416e6f6d75726160c81b81525060405180604001604052806007815260200166414e4f4d55524160c81b815250612000565b61096b612031565b610973612058565b61097b612087565b61098861012f8484612cea565b5061013080546001600160a01b038088166001600160a01b03199283161790925561012d805492871692909116919091179055610133805460ff191690556109d561012e80546001019055565b6040513381527f8ffcdc15a283d706d38281f500270d8b5a656918f555de0913d7455e3e6bc1bf9060200160405180910390a18015610a4e576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050565b610a5d6120b6565b61013380546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b6000610a9160995490565b8210610af45760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610627565b60998281548110610b0757610b076133ab565b90600052602060002001549050919050565b610b216120b6565b6106c861012f8383612cea565b6101335460009060ff1615610b7a5760405162461bcd60e51b815260206004820152601260248201527110dbdb9d1c9858dd081a5cc81c185d5cd95960721b6044820152606401610627565b600260c95403610bcc5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610627565b600260c955610130546001600160a01b03163314610c2c5760405162461bcd60e51b815260206004820152601a60248201527f43616e206f6e6c792062652063616c6c656420627920426f776c0000000000006044820152606401610627565b61012d546001600160a01b0316610c815760405162461bcd60e51b81526020600482015260196024820152780416e6f6d75726120646174612061646472657373206973203603c1b6044820152606401610627565b6040516001600160601b0319606084811b8216602084015241901b16603482015260480160408051808303601f1901815291905280516020909101206101315561012e549050610ccf612d6e565b61012d60009054906101000a90046001600160a01b03166001600160a01b03166366030e486040518163ffffffff1660e01b8152600401600060405180830381865afa158015610d23573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610d4b919081019061349c565b90506000610d8a8360405180604001604052806004815260200163434c415760e01b81525084602001518560c001518660e00151876101000151612110565b90506000610dc884604051806040016040528060038152602001624c454760e81b81525085604001518660c001518760e00151886101000151612110565b90506000610e078560405180604001604052806004815260200163424f445960e01b81525086600001518760c001518860e00151896101000151612110565b90506000610e47866040518060400160405280600581526020016414d211531360da1b81525087606001518860c001518960e001518a6101000151612110565b90506000610e82876040518060400160405280600a815260200169109050d2d1d493d5539160b21b8152508860a001518961012001516122ae565b90506000610eb6886040518060400160405280600e81526020016d484156455f48454144504945434560901b81525061235a565b90506000600182151514610ee657604051806040016040528060048152602001634e6f6e6560e01b815250610f26565b610f26896040518060400160405280600981526020016848454144504945434560b81b8152508a608001518b60c001518c60e001518d6101000151612110565b90506040518060c001604052808681526020018881526020018781526020018581526020018281526020018481525061013260008b81526020019081526020016000206000820151816000019080519060200190610f85929190612dc1565b506020828101518051610f9e9260018501920190612dc1565b5060408201518051610fba916002840191602090910190612dc1565b5060608201518051610fd6916003840191602090910190612dc1565b5060808201518051610ff2916004840191602090910190612dc1565b5060a0820151805161100e916005840191602090910190612dc1565b505061012e80546001019055506110258a8a61238d565b887f27201f19e2a284a0ddc5b13bb865386f850f040a07ebeb082286ffa24f2c192588888888888760405161105f96959493929190613100565b60405180910390a25050600160c95550949695505050505050565b6000818152606760205260408120546001600160a01b0316806104f45760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610627565b60006001600160a01b0382166111445760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610627565b506001600160a01b031660009081526068602052604090205490565b6111686120b6565b61117260006123a7565b565b60606000611181836110da565b905060008167ffffffffffffffff81111561119e5761119e6131b5565b6040519080825280602002602001820160405280156111c7578160200160208202803683370190505b50905060005b8281101561120e576111df85826106fe565b8282815181106111f1576111f16133ab565b6020908102919091010152806112068161366a565b9150506111cd565b509392505050565b61121e6120b6565b61013080546001600160a01b0319166001600160a01b038316908117909155604080519182523360208301527f1fc93c6e1b3d3cbdf21cb6110d2bd30ce9c831461f83aab2c2cce8f2a30d4c6f91015b60405180910390a150565b6112816120b6565b610133805460ff1916821515908117909155604080519182523360208301527fa06b5a80dcb0a794bdf9b8683ec488cb83588c4e69e0945b2f87afa8a8448ce0910161126e565b60606066805461050990613323565b610132602052600090815260409020805481906112f390613323565b80601f016020809104026020016040519081016040528092919081815260200182805461131f90613323565b801561136c5780601f106113415761010080835404028352916020019161136c565b820191906000526020600020905b81548152906001019060200180831161134f57829003601f168201915b50505050509080600101805461138190613323565b80601f01602080910402602001604051908101604052809291908181526020018280546113ad90613323565b80156113fa5780601f106113cf576101008083540402835291602001916113fa565b820191906000526020600020905b8154815290600101906020018083116113dd57829003601f168201915b50505050509080600201805461140f90613323565b80601f016020809104026020016040519081016040528092919081815260200182805461143b90613323565b80156114885780601f1061145d57610100808354040283529160200191611488565b820191906000526020600020905b81548152906001019060200180831161146b57829003601f168201915b50505050509080600301805461149d90613323565b80601f01602080910402602001604051908101604052809291908181526020018280546114c990613323565b80156115165780601f106114eb57610100808354040283529160200191611516565b820191906000526020600020905b8154815290600101906020018083116114f957829003601f168201915b50505050509080600401805461152b90613323565b80601f016020809104026020016040519081016040528092919081815260200182805461155790613323565b80156115a45780601f10611579576101008083540402835291602001916115a4565b820191906000526020600020905b81548152906001019060200180831161158757829003601f168201915b5050505050908060050180546115b990613323565b80601f01602080910402602001604051908101604052809291908181526020018280546115e590613323565b80156116325780601f1061160757610100808354040283529160200191611632565b820191906000526020600020905b81548152906001019060200180831161161557829003601f168201915b5050505050905086565b6116473383836123f9565b5050565b6101335460ff16156116945760405162461bcd60e51b815260206004820152601260248201527110dbdb9d1c9858dd081a5cc81c185d5cd95960721b6044820152606401610627565b600260c954036116e65760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610627565b600260c9556116f36120b6565b61012d546001600160a01b03166117485760405162461bcd60e51b81526020600482015260196024820152780416e6f6d75726120646174612061646472657373206973203603c1b6044820152606401610627565b6040516001600160601b0319606083811b8216602084015241901b16603482015260480160408051601f19818403018152919052805160209091012061013155600061179461012e5490565b905061179e612d6e565b61012d60009054906101000a90046001600160a01b03166001600160a01b03166366030e486040518163ffffffff1660e01b8152600401600060405180830381865afa1580156117f2573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261181a919081019061349c565b905060006118598360405180604001604052806004815260200163434c415760e01b81525084602001518560c001518660e00151876101000151612110565b9050600061189784604051806040016040528060038152602001624c454760e81b81525085604001518660c001518760e00151886101000151612110565b905060006118d68560405180604001604052806004815260200163424f445960e01b81525086600001518760c001518860e00151896101000151612110565b90506000611916866040518060400160405280600581526020016414d211531360da1b81525087606001518860c001518960e001518a6101000151612110565b90506000611951876040518060400160405280600a815260200169109050d2d1d493d5539160b21b8152508860a001518961012001516122ae565b90506000611985886040518060400160405280600e81526020016d484156455f48454144504945434560901b81525061235a565b905060006001821515146119b557604051806040016040528060048152602001634e6f6e6560e01b8152506119f5565b6119f5896040518060400160405280600981526020016848454144504945434560b81b8152508a608001518b60c001518c60e001518d6101000151612110565b90506040518060c001604052808681526020018881526020018781526020018581526020018281526020018481525061013260008b81526020019081526020016000206000820151816000019080519060200190611a54929190612dc1565b506020828101518051611a6d9260018501920190612dc1565b5060408201518051611a89916002840191602090910190612dc1565b5060608201518051611aa5916003840191602090910190612dc1565b5060808201518051611ac1916004840191602090910190612dc1565b5060a08201518051611add916005840191602090910190612dc1565b505061012e8054600101905550611af48a8a61238d565b887f27201f19e2a284a0ddc5b13bb865386f850f040a07ebeb082286ffa24f2c1925888888888887604051611b2e96959493929190613100565b60405180910390a25050600160c9555050505050505050565b611b4f6120b6565b6040514790339082156108fc029083906000818181858888f19350505050158015611647573d6000803e3d6000fd5b611b883383611dda565b611ba45760405162461bcd60e51b81526004016106279061335d565b611bb0848484846124c7565b50505050565b6000818152606760205260409020546060906001600160a01b0316611c115760405162461bcd60e51b81526020600482015260116024820152702737b732bc34b9ba32b73a103a37b5b2b760791b6044820152606401610627565b61012f611c1d836124fa565b604051602001611c2e92919061369f565b6040516020818303038152906040529050919050565b611c4c6120b6565b6001600160a01b038116611cb15760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610627565b611cba816123a7565b50565b611cc56120b6565b61012d80546001600160a01b0319166001600160a01b0392909216919091179055565b60006001600160e01b0319821663780e9d6360e01b14806104f457506104f4826125fb565b6000818152606760205260409020546001600160a01b0316611cba5760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610627565b600081815260696020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611da18261107a565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600080611de68361107a565b9050806001600160a01b0316846001600160a01b03161480611e2d57506001600160a01b038082166000908152606a602090815260408083209388168352929052205460ff165b80611e515750836001600160a01b0316611e468461058c565b6001600160a01b0316145b949350505050565b826001600160a01b0316611e6c8261107a565b6001600160a01b031614611ed05760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608401610627565b6001600160a01b038216611f325760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610627565b611f3d83838361264b565b611f48600082611d6c565b6001600160a01b0383166000908152606860205260408120805460019290611f71908490613745565b90915550506001600160a01b0382166000908152606860205260408120805460019290611f9f90849061375c565b909155505060008181526067602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600054610100900460ff166120275760405162461bcd60e51b815260040161062790613774565b611647828261272c565b600054610100900460ff166111725760405162461bcd60e51b815260040161062790613774565b600054610100900460ff1661207f5760405162461bcd60e51b815260040161062790613774565b61117261277a565b600054610100900460ff166120ae5760405162461bcd60e51b815260040161062790613774565b6111726127a8565b60fb546001600160a01b031633146111725760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610627565b60606000612146876121218a6124fa565b6040516020016121329291906137bf565b6040516020818303038152906040526127d8565b90506000868751836121589190613804565b81518110612168576121686133ab565b602002602001015190506000605e836121819190613804565b9050605c8111156121df578485518461219a9190613804565b815181106121aa576121aa6133ab565b6020026020010151826040516020016121c4929190613818565b60408051601f1981840301815291905293506122a492505050565b605381111561224757868751846121f69190613804565b81518110612206576122066133ab565b6020026020010151828788518661221d9190613804565b8151811061222d5761222d6133ab565b60200260200101516040516020016121c493929190613854565b604a81111561228857818687518561225f9190613804565b8151811061226f5761226f6133ab565b60200260200101516040516020016121c4929190613818565b604181111561229f578687518461219a9190613804565b509150505b9695505050505050565b606060006122bf85612121886124fa565b90506000848551836122d19190613804565b815181106122e1576122e16133ab565b6020026020010151905060006033836122fa9190613804565b9050602d81111561234f57848551846123139190613804565b81518110612323576123236133ab565b60200260200101518260405160200161233d929190613818565b60405160208183030381529060405291505b509695505050505050565b600080606561236c84612121876124fa565b6123769190613804565b9050605f81111561238657600191505b5092915050565b611647828260405180602001604052806000815250612823565b60fb80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b03160361245a5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610627565b6001600160a01b038381166000818152606a6020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6124d2848484611e59565b6124de84848484612856565b611bb05760405162461bcd60e51b8152600401610627906138ae565b6060816000036125215750506040805180820190915260018152600360fc1b602082015290565b8160005b811561254b57806125358161366a565b91506125449050600a83613900565b9150612525565b60008167ffffffffffffffff811115612566576125666131b5565b6040519080825280601f01601f191660200182016040528015612590576020820181803683370190505b5090505b8415611e51576125a5600183613745565b91506125b2600a86613804565b6125bd90603061375c565b60f81b8183815181106125d2576125d26133ab565b60200101906001600160f81b031916908160001a9053506125f4600a86613900565b9450612594565b60006001600160e01b031982166380ac58cd60e01b148061262c57506001600160e01b03198216635b5e139f60e01b145b806104f457506301ffc9a760e01b6001600160e01b03198316146104f4565b6101335460405163e303033f60e01b81523060048201526024810183905260009161010090046001600160a01b03169063e303033f90604401602060405180830381865afa1580156126a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126c59190613914565b9050436126d382600461375c565b11156127215760405162461bcd60e51b815260206004820152601e60248201527f4e6f207472616e7366657220726967687420616674657220616374696f6e00006044820152606401610627565b611bb0848484612954565b600054610100900460ff166127535760405162461bcd60e51b815260040161062790613774565b8151612766906065906020850190612dc1565b5080516106c8906066906020840190612dc1565b600054610100900460ff166127a15760405162461bcd60e51b815260040161062790613774565b600160c955565b600054610100900460ff166127cf5760405162461bcd60e51b815260040161062790613774565b611172336123a7565b6000813a3342486127ea600143613745565b4061013154604051602001612805979695949392919061392d565b60408051601f19818403018152919052805160209091012092915050565b61282d8383612a0c565b61283a6000848484612856565b6106c85760405162461bcd60e51b8152600401610627906138ae565b60006001600160a01b0384163b1561294c57604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061289a90339089908890889060040161397b565b6020604051808303816000875af19250505080156128d5575060408051601f3d908101601f191682019092526128d2918101906139ae565b60015b612932573d808015612903576040519150601f19603f3d011682016040523d82523d6000602084013e612908565b606091505b50805160000361292a5760405162461bcd60e51b8152600401610627906138ae565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611e51565b506001611e51565b6001600160a01b0383166129af576129aa81609980546000838152609a60205260408120829055600182018355919091527f72a152ddfb8e864297c917af52ea6c1c68aead0fee1a62673fcc7e0c94979d000155565b6129d2565b816001600160a01b0316836001600160a01b0316146129d2576129d28382612b5a565b6001600160a01b0382166129e9576106c881612bf7565b826001600160a01b0316826001600160a01b0316146106c8576106c88282612ca6565b6001600160a01b038216612a625760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610627565b6000818152606760205260409020546001600160a01b031615612ac75760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610627565b612ad36000838361264b565b6001600160a01b0382166000908152606860205260408120805460019290612afc90849061375c565b909155505060008181526067602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60006001612b67846110da565b612b719190613745565b600083815260986020526040902054909150808214612bc4576001600160a01b03841660009081526097602090815260408083208584528252808320548484528184208190558352609890915290208190555b5060009182526098602090815260408084208490556001600160a01b039094168352609781528383209183525290812055565b609954600090612c0990600190613745565b6000838152609a602052604081205460998054939450909284908110612c3157612c316133ab565b906000526020600020015490508060998381548110612c5257612c526133ab565b6000918252602080832090910192909255828152609a90915260408082208490558582528120556099805480612c8a57612c8a6139cb565b6001900381819060005260206000200160009055905550505050565b6000612cb1836110da565b6001600160a01b039093166000908152609760209081526040808320868452825280832085905593825260989052919091209190915550565b828054612cf690613323565b90600052602060002090601f016020900481019282612d185760008555612d5e565b82601f10612d315782800160ff19823516178555612d5e565b82800160010185558215612d5e579182015b82811115612d5e578235825591602001919060010190612d43565b50612d6a929150612e35565b5090565b604051806101400160405280606081526020016060815260200160608152602001606081526020016060815260200160608152602001606081526020016060815260200160608152602001606081525090565b828054612dcd90613323565b90600052602060002090601f016020900481019282612def5760008555612d5e565b82601f10612e0857805160ff1916838001178555612d5e565b82800160010185558215612d5e579182015b82811115612d5e578251825591602001919060010190612e1a565b5b80821115612d6a5760008155600101612e36565b6001600160e01b031981168114611cba57600080fd5b600060208284031215612e7257600080fd5b8135612e7d81612e4a565b9392505050565b60005b83811015612e9f578181015183820152602001612e87565b83811115611bb05750506000910152565b60008151808452612ec8816020860160208601612e84565b601f01601f19169290920160200192915050565b602081526000612e7d6020830184612eb0565b600060208284031215612f0157600080fd5b5035919050565b80356001600160a01b0381168114612f1f57600080fd5b919050565b60008060408385031215612f3757600080fd5b612f4083612f08565b946020939093013593505050565b600080600060608486031215612f6357600080fd5b612f6c84612f08565b9250612f7a60208501612f08565b9150604084013590509250925092565b60008083601f840112612f9c57600080fd5b50813567ffffffffffffffff811115612fb457600080fd5b602083019150836020828501011115612fcc57600080fd5b9250929050565b60008060008060608587031215612fe957600080fd5b612ff285612f08565b935061300060208601612f08565b9250604085013567ffffffffffffffff81111561301c57600080fd5b61302887828801612f8a565b95989497509550505050565b60006020828403121561304657600080fd5b612e7d82612f08565b6000806020838503121561306257600080fd5b823567ffffffffffffffff81111561307957600080fd5b61308585828601612f8a565b90969095509350505050565b6020808252825182820181905260009190848201906040850190845b818110156130c9578351835292840192918401916001016130ad565b50909695505050505050565b80358015158114612f1f57600080fd5b6000602082840312156130f757600080fd5b612e7d826130d5565b60c08152600061311360c0830189612eb0565b82810360208401526131258189612eb0565b905082810360408401526131398188612eb0565b9050828103606084015261314d8187612eb0565b905082810360808401526131618186612eb0565b905082810360a08401526131758185612eb0565b9998505050505050505050565b6000806040838503121561319557600080fd5b61319e83612f08565b91506131ac602084016130d5565b90509250929050565b634e487b7160e01b600052604160045260246000fd5b604051610140810167ffffffffffffffff811182821017156131ef576131ef6131b5565b60405290565b604051601f8201601f1916810167ffffffffffffffff8111828210171561321e5761321e6131b5565b604052919050565b600067ffffffffffffffff821115613240576132406131b5565b50601f01601f191660200190565b6000806000806080858703121561326457600080fd5b61326d85612f08565b935061327b60208601612f08565b925060408501359150606085013567ffffffffffffffff81111561329e57600080fd5b8501601f810187136132af57600080fd5b80356132c26132bd82613226565b6131f5565b8181528860208385010111156132d757600080fd5b8160208401602083013760006020838301015280935050505092959194509250565b6000806040838503121561330c57600080fd5b61331583612f08565b91506131ac60208401612f08565b600181811c9082168061333757607f821691505b60208210810361335757634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252602e908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526d1c881b9bdc88185c1c1c9bdd995960921b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b600082601f8301126133d257600080fd5b8151602067ffffffffffffffff808311156133ef576133ef6131b5565b8260051b6133fe8382016131f5565b938452858101830193838101908886111561341857600080fd5b84880192505b85831015613490578251848111156134365760008081fd5b8801603f81018a136134485760008081fd5b85810151604061345a6132bd83613226565b8281528c8284860101111561346f5760008081fd5b61347e838a8301848701612e84565b8552505050918401919084019061341e565b98975050505050505050565b6000602082840312156134ae57600080fd5b815167ffffffffffffffff808211156134c657600080fd5b9083019061014082860312156134db57600080fd5b6134e36131cb565b8251828111156134f257600080fd5b6134fe878286016133c1565b82525060208301518281111561351357600080fd5b61351f878286016133c1565b60208301525060408301518281111561353757600080fd5b613543878286016133c1565b60408301525060608301518281111561355b57600080fd5b613567878286016133c1565b60608301525060808301518281111561357f57600080fd5b61358b878286016133c1565b60808301525060a0830151828111156135a357600080fd5b6135af878286016133c1565b60a08301525060c0830151828111156135c757600080fd5b6135d3878286016133c1565b60c08301525060e0830151828111156135eb57600080fd5b6135f7878286016133c1565b60e083015250610100808401518381111561361157600080fd5b61361d888287016133c1565b828401525050610120808401518381111561363757600080fd5b613643888287016133c1565b918301919091525095945050505050565b634e487b7160e01b600052601160045260246000fd5b60006001820161367c5761367c613654565b5060010190565b60008151613695818560208601612e84565b9290920192915050565b600080845481600182811c9150808316806136bb57607f831692505b602080841082036136da57634e487b7160e01b86526022600452602486fd5b8180156136ee57600181146136ff5761372c565b60ff1986168952848901965061372c565b60008b81526020902060005b868110156137245781548b82015290850190830161370b565b505084890196505b50505050505061373c8185613683565b95945050505050565b60008282101561375757613757613654565b500390565b6000821982111561376f5761376f613654565b500190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b600083516137d1818460208801612e84565b8351908301906137e5818360208801612e84565b01949350505050565b634e487b7160e01b600052601260045260246000fd5b600082613813576138136137ee565b500690565b6000835161382a818460208801612e84565b600160fd1b9083019081528351613848816001840160208801612e84565b01600101949350505050565b60008451613866818460208901612e84565b8083019050600160fd1b8082528551613886816001850160208a01612e84565b600192019182015283516138a1816002840160208801612e84565b0160020195945050505050565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60008261390f5761390f6137ee565b500490565b60006020828403121561392657600080fd5b5051919050565b6000885161393f818460208d01612e84565b919091019687525060609490941b6001600160601b0319166020860152603485019290925260548401526074830152609482015260b401919050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906122a490830184612eb0565b6000602082840312156139c057600080fd5b8151612e7d81612e4a565b634e487b7160e01b600052603160045260246000fdfea2646970667358221220eb196d371f690ffd6f236f378e9ee41d59d74becfaa431b5530f8f45c390b88764736f6c634300080d0033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 26 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.