Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- Pack
- Optimization enabled
- true
- Compiler version
- v0.8.23+commit.f704f362
- Optimization runs
- 20
- EVM Version
- london
- Verified at
- 2024-05-14T17:14:49.310596Z
Constructor Arguments
0x000000000000000000000000d23e77b7e1726577006799b7194b6ae31958a8390000000000000000000000000000000000000000000000000000000000000000
Arg [0] (address) : 0xd23e77b7e1726577006799b7194b6ae31958a839
Arg [1] (address) : 0x0000000000000000000000000000000000000000
contracts/prebuilts/pack/Pack.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.11; /// @author thirdweb // $$\ $$\ $$\ $$\ $$\ // $$ | $$ | \__| $$ | $$ | // $$$$$$\ $$$$$$$\ $$\ $$$$$$\ $$$$$$$ |$$\ $$\ $$\ $$$$$$\ $$$$$$$\ // \_$$ _| $$ __$$\ $$ |$$ __$$\ $$ __$$ |$$ | $$ | $$ |$$ __$$\ $$ __$$\ // $$ | $$ | $$ |$$ |$$ | \__|$$ / $$ |$$ | $$ | $$ |$$$$$$$$ |$$ | $$ | // $$ |$$\ $$ | $$ |$$ |$$ | $$ | $$ |$$ | $$ | $$ |$$ ____|$$ | $$ | // \$$$$ |$$ | $$ |$$ |$$ | \$$$$$$$ |\$$$$$\$$$$ |\$$$$$$$\ $$$$$$$ | // \____/ \__| \__|\__|\__| \_______| \_____\____/ \_______|\_______/ // ========== External imports ========== import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol"; import "@openzeppelin/contracts/interfaces/IERC721Receiver.sol"; import { IERC1155Receiver } from "@openzeppelin/contracts/interfaces/IERC1155Receiver.sol"; // ========== Internal imports ========== import "../interface/IPack.sol"; import "../../extension/Multicall.sol"; import "../../external-deps/openzeppelin/metatx/ERC2771ContextUpgradeable.sol"; // ========== Features ========== import "../../extension/ContractMetadata.sol"; import "../../extension/Royalty.sol"; import "../../extension/Ownable.sol"; import "../../extension/PermissionsEnumerable.sol"; import { TokenStore, ERC1155Receiver } from "../../extension/TokenStore.sol"; contract Pack is Initializable, ContractMetadata, Ownable, Royalty, PermissionsEnumerable, TokenStore, ReentrancyGuardUpgradeable, ERC2771ContextUpgradeable, Multicall, ERC1155Upgradeable, IPack { /*/////////////////////////////////////////////////////////////// State variables //////////////////////////////////////////////////////////////*/ bytes32 private constant MODULE_TYPE = bytes32("Pack"); uint256 private constant VERSION = 2; address private immutable forwarder; // Token name string public name; // Token symbol string public symbol; /// @dev Only transfers to or from TRANSFER_ROLE holders are valid, when transfers are restricted. bytes32 private transferRole; /// @dev Only MINTER_ROLE holders can create packs. bytes32 private minterRole; /// @dev Only assets with ASSET_ROLE can be packed, when packing is restricted to particular assets. bytes32 private assetRole; /// @dev The token Id of the next set of packs to be minted. uint256 public nextTokenIdToMint; /*/////////////////////////////////////////////////////////////// Mappings //////////////////////////////////////////////////////////////*/ /// @dev Mapping from token ID => total circulating supply of token with that ID. mapping(uint256 => uint256) public totalSupply; /// @dev Mapping from pack ID => The state of that set of packs. mapping(uint256 => PackInfo) private packInfo; /// @dev Checks if pack-creator allowed to add more tokens to a packId; set to false after first transfer mapping(uint256 => bool) public canUpdatePack; /*/////////////////////////////////////////////////////////////// Constructor + initializer logic //////////////////////////////////////////////////////////////*/ constructor(address _nativeTokenWrapper, address _trustedForwarder) TokenStore(_nativeTokenWrapper) initializer { forwarder = _trustedForwarder; } /// @dev Initializes the contract, like a constructor. function initialize( address _defaultAdmin, string memory _name, string memory _symbol, string memory _contractURI, address[] memory _trustedForwarders, address _royaltyRecipient, uint256 _royaltyBps ) external initializer { bytes32 _transferRole = keccak256("TRANSFER_ROLE"); bytes32 _minterRole = keccak256("MINTER_ROLE"); bytes32 _assetRole = keccak256("ASSET_ROLE"); /** note: The immutable state-variable `forwarder` is an EOA-only forwarder, * which guards against automated attacks. * * Use other forwarders only if there's a strong reason to bypass this check. */ address[] memory forwarders = new address[](_trustedForwarders.length + 1); uint256 i; for (; i < _trustedForwarders.length; i++) { forwarders[i] = _trustedForwarders[i]; } forwarders[i] = forwarder; __ERC2771Context_init(forwarders); __ERC1155_init(_contractURI); name = _name; symbol = _symbol; _setupContractURI(_contractURI); _setupOwner(_defaultAdmin); _setupRole(DEFAULT_ADMIN_ROLE, _defaultAdmin); _setupRole(_transferRole, _defaultAdmin); _setupRole(_minterRole, _defaultAdmin); _setupRole(_transferRole, address(0)); // note: see `onlyRoleWithSwitch` for ASSET_ROLE behaviour. _setupRole(_assetRole, address(0)); _setupDefaultRoyaltyInfo(_royaltyRecipient, _royaltyBps); transferRole = _transferRole; minterRole = _minterRole; assetRole = _assetRole; } receive() external payable { require(msg.sender == nativeTokenWrapper, "!nativeTokenWrapper."); } /*/////////////////////////////////////////////////////////////// Modifiers //////////////////////////////////////////////////////////////*/ modifier onlyRoleWithSwitch(bytes32 role) { _checkRoleWithSwitch(role, _msgSender()); _; } /*/////////////////////////////////////////////////////////////// Generic contract logic //////////////////////////////////////////////////////////////*/ /// @dev Returns the type of the contract. function contractType() external pure returns (bytes32) { return MODULE_TYPE; } /// @dev Returns the version of the contract. function contractVersion() external pure returns (uint8) { return uint8(VERSION); } /*/////////////////////////////////////////////////////////////// ERC 165 / 1155 / 2981 logic //////////////////////////////////////////////////////////////*/ /// @dev Returns the URI for a given tokenId. function uri(uint256 _tokenId) public view override returns (string memory) { return getUriOfBundle(_tokenId); } /// @dev See ERC 165 function supportsInterface( bytes4 interfaceId ) public view virtual override(ERC1155Receiver, ERC1155Upgradeable, IERC165) returns (bool) { return super.supportsInterface(interfaceId) || type(IERC2981Upgradeable).interfaceId == interfaceId || type(IERC721Receiver).interfaceId == interfaceId || type(IERC1155Receiver).interfaceId == interfaceId; } /*/////////////////////////////////////////////////////////////// Pack logic: create | open packs. //////////////////////////////////////////////////////////////*/ /// @dev Creates a pack with the stated contents. function createPack( Token[] calldata _contents, uint256[] calldata _numOfRewardUnits, string memory _packUri, uint128 _openStartTimestamp, uint128 _amountDistributedPerOpen, address _recipient ) external payable onlyRoleWithSwitch(minterRole) nonReentrant returns (uint256 packId, uint256 packTotalSupply) { require(_contents.length > 0 && _contents.length == _numOfRewardUnits.length, "!Len"); if (!hasRole(assetRole, address(0))) { for (uint256 i = 0; i < _contents.length; i += 1) { _checkRole(assetRole, _contents[i].assetContract); } } packId = nextTokenIdToMint; nextTokenIdToMint += 1; packTotalSupply = escrowPackContents( _contents, _numOfRewardUnits, _packUri, packId, _amountDistributedPerOpen, false ); packInfo[packId].openStartTimestamp = _openStartTimestamp; packInfo[packId].amountDistributedPerOpen = _amountDistributedPerOpen; canUpdatePack[packId] = true; _mint(_recipient, packId, packTotalSupply, ""); emit PackCreated(packId, _recipient, packTotalSupply); } /// @dev Add contents to an existing packId. function addPackContents( uint256 _packId, Token[] calldata _contents, uint256[] calldata _numOfRewardUnits, address _recipient ) external payable onlyRoleWithSwitch(minterRole) nonReentrant returns (uint256 packTotalSupply, uint256 newSupplyAdded) { require(canUpdatePack[_packId], "!Allowed"); require(_contents.length > 0 && _contents.length == _numOfRewardUnits.length, "!Len"); require(balanceOf(_recipient, _packId) != 0, "!Bal"); if (!hasRole(assetRole, address(0))) { for (uint256 i = 0; i < _contents.length; i += 1) { _checkRole(assetRole, _contents[i].assetContract); } } uint256 amountPerOpen = packInfo[_packId].amountDistributedPerOpen; newSupplyAdded = escrowPackContents(_contents, _numOfRewardUnits, "", _packId, amountPerOpen, true); packTotalSupply = totalSupply[_packId] + newSupplyAdded; _mint(_recipient, _packId, newSupplyAdded, ""); emit PackUpdated(_packId, _recipient, newSupplyAdded); } /// @notice Lets a pack owner open packs and receive the packs' reward units. function openPack(uint256 _packId, uint256 _amountToOpen) external returns (Token[] memory) { address opener = _msgSender(); require(isTrustedForwarder(msg.sender) || opener == tx.origin, "!EOA"); require(balanceOf(opener, _packId) >= _amountToOpen, "!Bal"); PackInfo memory pack = packInfo[_packId]; require(pack.openStartTimestamp <= block.timestamp, "cant open"); Token[] memory rewardUnits = getRewardUnits(_packId, _amountToOpen, pack.amountDistributedPerOpen, pack); _burn(opener, _packId, _amountToOpen); _transferTokenBatch(address(this), opener, rewardUnits); emit PackOpened(_packId, opener, _amountToOpen, rewardUnits); return rewardUnits; } /// @dev Stores assets within the contract. function escrowPackContents( Token[] calldata _contents, uint256[] calldata _numOfRewardUnits, string memory _packUri, uint256 packId, uint256 amountPerOpen, bool isUpdate ) internal returns (uint256 supplyToMint) { uint256 sumOfRewardUnits; for (uint256 i = 0; i < _contents.length; i += 1) { require(_contents[i].totalAmount != 0, "0 amt"); require(_contents[i].totalAmount % _numOfRewardUnits[i] == 0, "!R"); require(_contents[i].tokenType != TokenType.ERC721 || _contents[i].totalAmount == 1, "!R"); sumOfRewardUnits += _numOfRewardUnits[i]; packInfo[packId].perUnitAmounts.push(_contents[i].totalAmount / _numOfRewardUnits[i]); } require(sumOfRewardUnits % amountPerOpen == 0, "!Amt"); supplyToMint = sumOfRewardUnits / amountPerOpen; if (isUpdate) { for (uint256 i = 0; i < _contents.length; i += 1) { _addTokenInBundle(_contents[i], packId); } _transferTokenBatch(_msgSender(), address(this), _contents); } else { _storeTokens(_msgSender(), _contents, _packUri, packId); } } /// @dev Returns the reward units to distribute. function getRewardUnits( uint256 _packId, uint256 _numOfPacksToOpen, uint256 _rewardUnitsPerOpen, PackInfo memory pack ) internal returns (Token[] memory rewardUnits) { uint256 numOfRewardUnitsToDistribute = _numOfPacksToOpen * _rewardUnitsPerOpen; rewardUnits = new Token[](numOfRewardUnitsToDistribute); uint256 totalRewardUnits = totalSupply[_packId] * _rewardUnitsPerOpen; uint256 totalRewardKinds = getTokenCountOfBundle(_packId); uint256 random = generateRandomValue(); (Token[] memory _token, ) = getPackContents(_packId); bool[] memory _isUpdated = new bool[](totalRewardKinds); for (uint256 i; i < numOfRewardUnitsToDistribute; ) { uint256 randomVal = uint256(keccak256(abi.encode(random, i))); uint256 target = randomVal % totalRewardUnits; uint256 step; for (uint256 j; j < totalRewardKinds; ) { uint256 perUnitAmount = pack.perUnitAmounts[j]; uint256 totalRewardUnitsOfKind = _token[j].totalAmount / perUnitAmount; if (target < step + totalRewardUnitsOfKind) { _token[j].totalAmount -= perUnitAmount; _isUpdated[j] = true; rewardUnits[i].assetContract = _token[j].assetContract; rewardUnits[i].tokenType = _token[j].tokenType; rewardUnits[i].tokenId = _token[j].tokenId; rewardUnits[i].totalAmount = perUnitAmount; totalRewardUnits -= 1; break; } else { step += totalRewardUnitsOfKind; } unchecked { ++j; } } unchecked { ++i; } } for (uint256 i; i < totalRewardKinds; ) { if (_isUpdated[i]) { _updateTokenInBundle(_token[i], _packId, i); } unchecked { ++i; } } } /*/////////////////////////////////////////////////////////////// Getter functions //////////////////////////////////////////////////////////////*/ /// @dev Returns the underlying contents of a pack. function getPackContents( uint256 _packId ) public view returns (Token[] memory contents, uint256[] memory perUnitAmounts) { PackInfo memory pack = packInfo[_packId]; uint256 total = getTokenCountOfBundle(_packId); contents = new Token[](total); perUnitAmounts = new uint256[](total); for (uint256 i; i < total; ) { contents[i] = getTokenOfBundle(_packId, i); unchecked { ++i; } } perUnitAmounts = pack.perUnitAmounts; } /*/////////////////////////////////////////////////////////////// Internal functions //////////////////////////////////////////////////////////////*/ /// @dev Returns whether owner can be set in the given execution context. function _canSetOwner() internal view override returns (bool) { return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); } /// @dev Returns whether royalty info can be set in the given execution context. function _canSetRoyaltyInfo() internal view override returns (bool) { return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); } /// @dev Returns whether contract metadata can be set in the given execution context. function _canSetContractURI() internal view override returns (bool) { return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); } /*/////////////////////////////////////////////////////////////// Miscellaneous //////////////////////////////////////////////////////////////*/ function generateRandomValue() internal view returns (uint256 random) { random = uint256(keccak256(abi.encodePacked(_msgSender(), blockhash(block.number - 1), block.difficulty))); } /** * @dev See {ERC1155-_beforeTokenTransfer}. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual override { super._beforeTokenTransfer(operator, from, to, ids, amounts, data); // if transfer is restricted on the contract, we still want to allow burning and minting if (!hasRole(transferRole, address(0)) && from != address(0) && to != address(0)) { require(hasRole(transferRole, from) || hasRole(transferRole, to), "!TRANSFER_ROLE"); } if (from == address(0)) { for (uint256 i = 0; i < ids.length; ++i) { totalSupply[ids[i]] += amounts[i]; } } else { for (uint256 i = 0; i < ids.length; ++i) { // pack can no longer be updated after first transfer to non-zero address if (canUpdatePack[ids[i]] && amounts[i] != 0) { canUpdatePack[ids[i]] = false; } } } if (to == address(0)) { for (uint256 i = 0; i < ids.length; ++i) { totalSupply[ids[i]] -= amounts[i]; } } } /// @dev See EIP-2771 function _msgSender() internal view virtual override(ContextUpgradeable, ERC2771ContextUpgradeable, Multicall) returns (address sender) { return ERC2771ContextUpgradeable._msgSender(); } /// @dev See EIP-2771 function _msgData() internal view virtual override(ContextUpgradeable, ERC2771ContextUpgradeable) returns (bytes calldata) { return ERC2771ContextUpgradeable._msgData(); } }
contracts/extension/PermissionsEnumerable.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb import "./interface/IPermissionsEnumerable.sol"; import "./Permissions.sol"; /** * @title PermissionsEnumerable * @dev This contracts provides extending-contracts with role-based access control mechanisms. * Also provides interfaces to view all members with a given role, and total count of members. */ contract PermissionsEnumerable is IPermissionsEnumerable, Permissions { /** * @notice A data structure to store data of members for a given role. * * @param index Current index in the list of accounts that have a role. * @param members map from index => address of account that has a role * @param indexOf map from address => index which the account has. */ struct RoleMembers { uint256 index; mapping(uint256 => address) members; mapping(address => uint256) indexOf; } /// @dev map from keccak256 hash of a role to its members' data. See {RoleMembers}. mapping(bytes32 => RoleMembers) private roleMembers; /** * @notice Returns the role-member from a list of members for a role, * at a given index. * @dev Returns `member` who has `role`, at `index` of role-members list. * See struct {RoleMembers}, and mapping {roleMembers} * * @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") * @param index Index in list of current members for the role. * * @return member Address of account that has `role` */ function getRoleMember(bytes32 role, uint256 index) external view override returns (address member) { uint256 currentIndex = roleMembers[role].index; uint256 check; for (uint256 i = 0; i < currentIndex; i += 1) { if (roleMembers[role].members[i] != address(0)) { if (check == index) { member = roleMembers[role].members[i]; return member; } check += 1; } else if (hasRole(role, address(0)) && i == roleMembers[role].indexOf[address(0)]) { check += 1; } } } /** * @notice Returns total number of accounts that have a role. * @dev Returns `count` of accounts that have `role`. * See struct {RoleMembers}, and mapping {roleMembers} * * @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") * * @return count Total number of accounts that have `role` */ function getRoleMemberCount(bytes32 role) external view override returns (uint256 count) { uint256 currentIndex = roleMembers[role].index; for (uint256 i = 0; i < currentIndex; i += 1) { if (roleMembers[role].members[i] != address(0)) { count += 1; } } if (hasRole(role, address(0))) { count += 1; } } /// @dev Revokes `role` from `account`, and removes `account` from {roleMembers} /// See {_removeMember} function _revokeRole(bytes32 role, address account) internal override { super._revokeRole(role, account); _removeMember(role, account); } /// @dev Grants `role` to `account`, and adds `account` to {roleMembers} /// See {_addMember} function _setupRole(bytes32 role, address account) internal override { super._setupRole(role, account); _addMember(role, account); } /// @dev adds `account` to {roleMembers}, for `role` function _addMember(bytes32 role, address account) internal { uint256 idx = roleMembers[role].index; roleMembers[role].index += 1; roleMembers[role].members[idx] = account; roleMembers[role].indexOf[account] = idx; } /// @dev removes `account` from {roleMembers}, for `role` function _removeMember(bytes32 role, address account) internal { uint256 idx = roleMembers[role].indexOf[account]; delete roleMembers[role].members[idx]; delete roleMembers[role].indexOf[account]; } }
contracts/eip/interface/IERC1155.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /** @title ERC-1155 Multi Token Standard @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1155.md Note: The ERC-165 identifier for this interface is 0xd9b67a26. */ interface IERC1155 { /** @dev Either `TransferSingle` or `TransferBatch` MUST emit when tokens are transferred, including zero value transfers as well as minting or burning (see "Safe Transfer Rules" section of the standard). The `_operator` argument MUST be msg.sender. The `_from` argument MUST be the address of the holder whose balance is decreased. The `_to` argument MUST be the address of the recipient whose balance is increased. The `_id` argument MUST be the token type being transferred. The `_value` argument MUST be the number of tokens the holder balance is decreased by and match what the recipient balance is increased by. When minting/creating tokens, the `_from` argument MUST be set to `0x0` (i.e. zero address). When burning/destroying tokens, the `_to` argument MUST be set to `0x0` (i.e. zero address). */ event TransferSingle( address indexed _operator, address indexed _from, address indexed _to, uint256 _id, uint256 _value ); /** @dev Either `TransferSingle` or `TransferBatch` MUST emit when tokens are transferred, including zero value transfers as well as minting or burning (see "Safe Transfer Rules" section of the standard). The `_operator` argument MUST be msg.sender. The `_from` argument MUST be the address of the holder whose balance is decreased. The `_to` argument MUST be the address of the recipient whose balance is increased. The `_ids` argument MUST be the list of tokens being transferred. The `_values` argument MUST be the list of number of tokens (matching the list and order of tokens specified in _ids) the holder balance is decreased by and match what the recipient balance is increased by. When minting/creating tokens, the `_from` argument MUST be set to `0x0` (i.e. zero address). When burning/destroying tokens, the `_to` argument MUST be set to `0x0` (i.e. zero address). */ event TransferBatch( address indexed _operator, address indexed _from, address indexed _to, uint256[] _ids, uint256[] _values ); /** @dev MUST emit when approval for a second party/operator address to manage all tokens for an owner address is enabled or disabled (absense of an event assumes disabled). */ event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved); /** @dev MUST emit when the URI is updated for a token ID. URIs are defined in RFC 3986. The URI MUST point a JSON file that conforms to the "ERC-1155 Metadata URI JSON Schema". */ event URI(string _value, uint256 indexed _id); /** @notice Transfers `_value` amount of an `_id` from the `_from` address to the `_to` address specified (with safety call). @dev Caller must be approved to manage the tokens being transferred out of the `_from` account (see "Approval" section of the standard). MUST revert if `_to` is the zero address. MUST revert if balance of holder for token `_id` is lower than the `_value` sent. MUST revert on any other error. MUST emit the `TransferSingle` event to reflect the balance change (see "Safe Transfer Rules" section of the standard). After the above conditions are met, this function MUST check if `_to` is a smart contract (e.g. code size > 0). If so, it MUST call `onERC1155Received` on `_to` and act appropriately (see "Safe Transfer Rules" section of the standard). @param _from Source address @param _to Target address @param _id ID of the token type @param _value Transfer amount @param _data Additional data with no specified format, MUST be sent unaltered in call to `onERC1155Received` on `_to` */ function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _value, bytes calldata _data) external; /** @notice Transfers `_values` amount(s) of `_ids` from the `_from` address to the `_to` address specified (with safety call). @dev Caller must be approved to manage the tokens being transferred out of the `_from` account (see "Approval" section of the standard). MUST revert if `_to` is the zero address. MUST revert if length of `_ids` is not the same as length of `_values`. MUST revert if any of the balance(s) of the holder(s) for token(s) in `_ids` is lower than the respective amount(s) in `_values` sent to the recipient. MUST revert on any other error. MUST emit `TransferSingle` or `TransferBatch` event(s) such that all the balance changes are reflected (see "Safe Transfer Rules" section of the standard). Balance changes and events MUST follow the ordering of the arrays (_ids[0]/_values[0] before _ids[1]/_values[1], etc). After the above conditions for the transfer(s) in the batch are met, this function MUST check if `_to` is a smart contract (e.g. code size > 0). If so, it MUST call the relevant `ERC1155TokenReceiver` hook(s) on `_to` and act appropriately (see "Safe Transfer Rules" section of the standard). @param _from Source address @param _to Target address @param _ids IDs of each token type (order and length must match _values array) @param _values Transfer amounts per token type (order and length must match _ids array) @param _data Additional data with no specified format, MUST be sent unaltered in call to the `ERC1155TokenReceiver` hook(s) on `_to` */ function safeBatchTransferFrom( address _from, address _to, uint256[] calldata _ids, uint256[] calldata _values, bytes calldata _data ) external; /** @notice Get the balance of an account's Tokens. @param _owner The address of the token holder @param _id ID of the Token @return The _owner's balance of the Token type requested */ function balanceOf(address _owner, uint256 _id) external view returns (uint256); /** @notice Get the balance of multiple account/token pairs @param _owners The addresses of the token holders @param _ids ID of the Tokens @return The _owner's balance of the Token types requested (i.e. balance for each (owner, id) pair) */ function balanceOfBatch( address[] calldata _owners, uint256[] calldata _ids ) external view returns (uint256[] memory); /** @notice Enable or disable approval for a third party ("operator") to manage all of the caller's tokens. @dev MUST emit the ApprovalForAll event on success. @param _operator Address to add to the set of authorized operators @param _approved True if the operator is approved, false to revoke approval */ function setApprovalForAll(address _operator, bool _approved) external; /** @notice Queries the approval status of an operator for a given owner. @param _owner The owner of the Tokens @param _operator Address of authorized operator @return True if the operator is approved, false if not */ function isApprovedForAll(address _owner, address _operator) external view returns (bool); }
lib/openzeppelin-contracts-upgradeable/contracts/utils/introspection/IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
contracts/eip/interface/IERC1155Receiver.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev _Available since v3.1._ */ interface IERC1155Receiver is IERC165 { /** * @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); }
lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/IERC1155ReceiverUpgradeable.sol
// 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); }
lib/openzeppelin-contracts-upgradeable/contracts/security/PausableUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } /** * @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; }
lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/extensions/ERC1155PausableUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.2) (token/ERC1155/extensions/ERC1155Pausable.sol) pragma solidity ^0.8.0; import "../ERC1155Upgradeable.sol"; import "../../../security/PausableUpgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @dev ERC1155 token with pausable token transfers, minting and burning. * * Useful for scenarios such as preventing trades until the end of an evaluation * period, or having an emergency switch for freezing all token transfers in the * event of a large bug. * * IMPORTANT: This contract does not include public pause and unpause functions. In * addition to inheriting this contract, you must define both functions, invoking the * {Pausable-_pause} and {Pausable-_unpause} internal functions, with appropriate * access control, e.g. using {AccessControl} or {Ownable}. Not doing so will * make the contract unpausable. * * _Available since v3.1._ */ abstract contract ERC1155PausableUpgradeable is Initializable, ERC1155Upgradeable, PausableUpgradeable { function __ERC1155Pausable_init() internal onlyInitializing { __Pausable_init_unchained(); } function __ERC1155Pausable_init_unchained() internal onlyInitializing { } /** * @dev See {ERC1155-_beforeTokenTransfer}. * * Requirements: * * - the contract must not be paused. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual override { super._beforeTokenTransfer(operator, from, to, ids, amounts, data); require(!paused(), "ERC1155Pausable: token transfer while paused"); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
contracts/extension/TokenBundle.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb import "./interface/ITokenBundle.sol"; import { CurrencyTransferLib } from "../lib/CurrencyTransferLib.sol"; interface IERC165 { function supportsInterface(bytes4 interfaceId) external view returns (bool); } /** * @title Token Bundle * @notice `TokenBundle` contract extension allows bundling-up of ERC20/ERC721/ERC1155 and native-tokan assets * in a data structure, and provides logic for setting/getting IDs and URIs for created bundles. * @dev See {ITokenBundle} */ abstract contract TokenBundle is ITokenBundle { /// @dev Mapping from bundle UID => bundle info. mapping(uint256 => BundleInfo) private bundle; /// @dev Returns the total number of assets in a particular bundle. function getTokenCountOfBundle(uint256 _bundleId) public view returns (uint256) { return bundle[_bundleId].count; } /// @dev Returns an asset contained in a particular bundle, at a particular index. function getTokenOfBundle(uint256 _bundleId, uint256 index) public view returns (Token memory) { return bundle[_bundleId].tokens[index]; } /// @dev Returns the uri of a particular bundle. function getUriOfBundle(uint256 _bundleId) public view returns (string memory) { return bundle[_bundleId].uri; } /// @dev Lets the calling contract create a bundle, by passing in a list of tokens and a unique id. function _createBundle(Token[] calldata _tokensToBind, uint256 _bundleId) internal { uint256 targetCount = _tokensToBind.length; require(targetCount > 0, "!Tokens"); require(bundle[_bundleId].count == 0, "id exists"); for (uint256 i = 0; i < targetCount; i += 1) { _checkTokenType(_tokensToBind[i]); bundle[_bundleId].tokens[i] = _tokensToBind[i]; } bundle[_bundleId].count = targetCount; } /// @dev Lets the calling contract update a bundle, by passing in a list of tokens and a unique id. function _updateBundle(Token[] memory _tokensToBind, uint256 _bundleId) internal { require(_tokensToBind.length > 0, "!Tokens"); uint256 currentCount = bundle[_bundleId].count; uint256 targetCount = _tokensToBind.length; uint256 check = currentCount > targetCount ? currentCount : targetCount; for (uint256 i = 0; i < check; i += 1) { if (i < targetCount) { _checkTokenType(_tokensToBind[i]); bundle[_bundleId].tokens[i] = _tokensToBind[i]; } else if (i < currentCount) { delete bundle[_bundleId].tokens[i]; } } bundle[_bundleId].count = targetCount; } /// @dev Lets the calling contract add a token to a bundle for a unique bundle id and index. function _addTokenInBundle(Token memory _tokenToBind, uint256 _bundleId) internal { _checkTokenType(_tokenToBind); uint256 id = bundle[_bundleId].count; bundle[_bundleId].tokens[id] = _tokenToBind; bundle[_bundleId].count += 1; } /// @dev Lets the calling contract update a token in a bundle for a unique bundle id and index. function _updateTokenInBundle(Token memory _tokenToBind, uint256 _bundleId, uint256 _index) internal { require(_index < bundle[_bundleId].count, "index DNE"); _checkTokenType(_tokenToBind); bundle[_bundleId].tokens[_index] = _tokenToBind; } /// @dev Checks if the type of asset-contract is same as the TokenType specified. function _checkTokenType(Token memory _token) internal view { if (_token.tokenType == TokenType.ERC721) { try IERC165(_token.assetContract).supportsInterface(0x80ac58cd) returns (bool supported721) { require(supported721, "!TokenType"); } catch { revert("!TokenType"); } } else if (_token.tokenType == TokenType.ERC1155) { try IERC165(_token.assetContract).supportsInterface(0xd9b67a26) returns (bool supported1155) { require(supported1155, "!TokenType"); } catch { revert("!TokenType"); } } else if (_token.tokenType == TokenType.ERC20) { if (_token.assetContract != CurrencyTransferLib.NATIVE_TOKEN) { // 0x36372b07 try IERC165(_token.assetContract).supportsInterface(0x80ac58cd) returns (bool supported721) { require(!supported721, "!TokenType"); try IERC165(_token.assetContract).supportsInterface(0xd9b67a26) returns (bool supported1155) { require(!supported1155, "!TokenType"); } catch Error(string memory) {} catch {} } catch Error(string memory) {} catch {} } } } /// @dev Lets the calling contract set/update the uri of a particular bundle. function _setUriOfBundle(string memory _uri, uint256 _bundleId) internal { bundle[_bundleId].uri = _uri; } /// @dev Lets the calling contract delete a particular bundle. function _deleteBundle(uint256 _bundleId) internal { for (uint256 i = 0; i < bundle[_bundleId].count; i += 1) { delete bundle[_bundleId].tokens[i]; } bundle[_bundleId].count = 0; } }
contracts/extension/Permissions.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb import "./interface/IPermissions.sol"; import "../lib/Strings.sol"; /** * @title Permissions * @dev This contracts provides extending-contracts with role-based access control mechanisms */ contract Permissions is IPermissions { /// @dev Map from keccak256 hash of a role => a map from address => whether address has role. mapping(bytes32 => mapping(address => bool)) private _hasRole; /// @dev Map from keccak256 hash of a role to role admin. See {getRoleAdmin}. mapping(bytes32 => bytes32) private _getRoleAdmin; /// @dev Default admin role for all roles. Only accounts with this role can grant/revoke other roles. bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /// @dev Modifier that checks if an account has the specified role; reverts otherwise. modifier onlyRole(bytes32 role) { _checkRole(role, msg.sender); _; } /** * @notice Checks whether an account has a particular role. * @dev Returns `true` if `account` has been granted `role`. * * @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") * @param account Address of the account for which the role is being checked. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _hasRole[role][account]; } /** * @notice Checks whether an account has a particular role; * role restrictions can be swtiched on and off. * * @dev Returns `true` if `account` has been granted `role`. * Role restrictions can be swtiched on and off: * - If address(0) has ROLE, then the ROLE restrictions * don't apply. * - If address(0) does not have ROLE, then the ROLE * restrictions will apply. * * @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") * @param account Address of the account for which the role is being checked. */ function hasRoleWithSwitch(bytes32 role, address account) public view returns (bool) { if (!_hasRole[role][address(0)]) { return _hasRole[role][account]; } return true; } /** * @notice Returns the admin role that controls the specified role. * @dev See {grantRole} and {revokeRole}. * To change a role's admin, use {_setRoleAdmin}. * * @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") */ function getRoleAdmin(bytes32 role) external view override returns (bytes32) { return _getRoleAdmin[role]; } /** * @notice Grants a role to an account, if not previously granted. * @dev Caller must have admin role for the `role`. * Emits {RoleGranted Event}. * * @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") * @param account Address of the account to which the role is being granted. */ function grantRole(bytes32 role, address account) public virtual override { _checkRole(_getRoleAdmin[role], msg.sender); if (_hasRole[role][account]) { revert("Can only grant to non holders"); } _setupRole(role, account); } /** * @notice Revokes role from an account. * @dev Caller must have admin role for the `role`. * Emits {RoleRevoked Event}. * * @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") * @param account Address of the account from which the role is being revoked. */ function revokeRole(bytes32 role, address account) public virtual override { _checkRole(_getRoleAdmin[role], msg.sender); _revokeRole(role, account); } /** * @notice Revokes role from the account. * @dev Caller must have the `role`, with caller being the same as `account`. * Emits {RoleRevoked Event}. * * @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") * @param account Address of the account from which the role is being revoked. */ function renounceRole(bytes32 role, address account) public virtual override { if (msg.sender != account) { revert("Can only renounce for self"); } _revokeRole(role, account); } /// @dev Sets `adminRole` as `role`'s admin role. function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = _getRoleAdmin[role]; _getRoleAdmin[role] = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /// @dev Sets up `role` for `account` function _setupRole(bytes32 role, address account) internal virtual { _hasRole[role][account] = true; emit RoleGranted(role, account, msg.sender); } /// @dev Revokes `role` from `account` function _revokeRole(bytes32 role, address account) internal virtual { _checkRole(role, account); delete _hasRole[role][account]; emit RoleRevoked(role, account, msg.sender); } /// @dev Checks `role` for `account`. Reverts with a message including the required role. function _checkRole(bytes32 role, address account) internal view virtual { if (!_hasRole[role][account]) { revert( string( abi.encodePacked( "Permissions: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /// @dev Checks `role` for `account`. Reverts with a message including the required role. function _checkRoleWithSwitch(bytes32 role, address account) internal view virtual { if (!hasRoleWithSwitch(role, account)) { revert( string( abi.encodePacked( "Permissions: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } }
contracts/eip/interface/IERC20.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); }
contracts/extension/interface/IPermissions.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IPermissions { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
contracts/extension/interface/IPermissionsEnumerable.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb import "./IPermissions.sol"; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IPermissionsEnumerable is IPermissions { /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * [forum post](https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296) * for more information. */ function getRoleMember(bytes32 role, uint256 index) external view returns (address); /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) external view returns (uint256); }
lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * 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); }
lib/openzeppelin-contracts/contracts/token/ERC721/IERC721Receiver.sol
// 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 IERC721Receiver { /** * @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); }
lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/IERC1155Upgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC1155/IERC1155.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. * * _Available since v3.1._ */ interface IERC1155Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the amount of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch( address[] calldata accounts, uint256[] calldata ids ) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) external; }
lib/openzeppelin-contracts-upgradeable/contracts/security/ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (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() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return _status == _ENTERED; } /** * @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; }
contracts/extension/ContractMetadata.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb import "./interface/IContractMetadata.sol"; /** * @title Contract Metadata * @notice Thirdweb's `ContractMetadata` is a contract extension for any base contracts. It lets you set a metadata URI * for you contract. * Additionally, `ContractMetadata` is necessary for NFT contracts that want royalties to get distributed on OpenSea. */ abstract contract ContractMetadata is IContractMetadata { /// @notice Returns the contract metadata URI. string public override contractURI; /** * @notice Lets a contract admin set the URI for contract-level metadata. * @dev Caller should be authorized to setup contractURI, e.g. contract admin. * See {_canSetContractURI}. * Emits {ContractURIUpdated Event}. * * @param _uri keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") */ function setContractURI(string memory _uri) external override { if (!_canSetContractURI()) { revert("Not authorized"); } _setupContractURI(_uri); } /// @dev Lets a contract admin set the URI for contract-level metadata. function _setupContractURI(string memory _uri) internal { string memory prevURI = contractURI; contractURI = _uri; emit ContractURIUpdated(prevURI, _uri); } /// @dev Returns whether contract metadata can be set in the given execution context. function _canSetContractURI() internal view virtual returns (bool); }
lib/openzeppelin-contracts-upgradeable/contracts/interfaces/IERC2981Upgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC2981.sol) pragma solidity ^0.8.0; import "../utils/introspection/IERC165Upgradeable.sol"; /** * @dev Interface for the NFT Royalty Standard. * * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal * support for royalty payments across all NFT marketplaces and ecosystem participants. * * _Available since v4.5._ */ interface IERC2981Upgradeable is IERC165Upgradeable { /** * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of * exchange. The royalty amount is denominated and should be paid in that same unit of exchange. */ function royaltyInfo( uint256 tokenId, uint256 salePrice ) external view returns (address receiver, uint256 royaltyAmount); }
contracts/extension/interface/ITokenBundle.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb /** * Group together arbitrary ERC20, ERC721 and ERC1155 tokens into a single bundle. * * The `Token` struct is a generic type that can describe any ERC20, ERC721 or ERC1155 token. * The `Bundle` struct is a data structure to track a group/bundle of multiple assets i.e. ERC20, * ERC721 and ERC1155 tokens, each described as a `Token`. * * Expressing tokens as the `Token` type, and grouping them as a `Bundle` allows for writing generic * logic to handle any ERC20, ERC721 or ERC1155 tokens. */ interface ITokenBundle { /// @notice The type of assets that can be wrapped. enum TokenType { ERC20, ERC721, ERC1155 } /** * @notice A generic interface to describe any ERC20, ERC721 or ERC1155 token. * * @param assetContract The contract address of the asset. * @param tokenType The token type (ERC20 / ERC721 / ERC1155) of the asset. * @param tokenId The token Id of the asset, if the asset is an ERC721 / ERC1155 NFT. * @param totalAmount The amount of the asset, if the asset is an ERC20 / ERC1155 fungible token. */ struct Token { address assetContract; TokenType tokenType; uint256 tokenId; uint256 totalAmount; } /** * @notice An internal data structure to track a group / bundle of multiple assets i.e. `Token`s. * * @param count The total number of assets i.e. `Token` in a bundle. * @param uri The (metadata) URI assigned to the bundle created * @param tokens Mapping from a UID -> to a unique asset i.e. `Token` in the bundle. */ struct BundleInfo { uint256 count; string uri; mapping(uint256 => Token) tokens; } }
lib/openzeppelin-contracts/contracts/token/ERC1155/IERC1155Receiver.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev _Available since v3.1._ */ interface IERC1155Receiver is IERC165 { /** * @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); }
contracts/extension/interface/IRoyalty.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb import "../../eip/interface/IERC2981.sol"; /** * Thirdweb's `Royalty` is a contract extension to be used with any base contract. It exposes functions for setting and reading * the recipient of royalty fee and the royalty fee basis points, and lets the inheriting contract perform conditional logic * that uses information about royalty fees, if desired. * * The `Royalty` contract is ERC2981 compliant. */ interface IRoyalty is IERC2981 { struct RoyaltyInfo { address recipient; uint256 bps; } /// @dev Returns the royalty recipient and fee bps. function getDefaultRoyaltyInfo() external view returns (address, uint16); /// @dev Lets a module admin update the royalty bps and recipient. function setDefaultRoyaltyInfo(address _royaltyRecipient, uint256 _royaltyBps) external; /// @dev Lets a module admin set the royalty recipient for a particular token Id. function setRoyaltyInfoForToken(uint256 tokenId, address recipient, uint256 bps) external; /// @dev Returns the royalty recipient for a particular token Id. function getRoyaltyInfoForToken(uint256 tokenId) external view returns (address, uint16); /// @dev Emitted when royalty info is updated. event DefaultRoyalty(address indexed newRoyaltyRecipient, uint256 newRoyaltyBps); /// @dev Emitted when royalty recipient for tokenId is set event RoyaltyForToken(uint256 indexed tokenId, address indexed royaltyRecipient, uint256 royaltyBps); }
contracts/eip/interface/IERC2981.sol
// SPDX-License-Identifier: Apache 2.0 pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Interface for the NFT Royalty Standard. * * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal * support for royalty payments across all NFT marketplaces and ecosystem participants. * * _Available since v4.5._ */ interface IERC2981 is IERC165 { /** * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of * exchange. The royalty amount is denominated and should be payed in that same unit of exchange. */ function royaltyInfo( uint256 tokenId, uint256 salePrice ) external view returns (address receiver, uint256 royaltyAmount); }
contracts/eip/interface/IERC165.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * [EIP](https://eips.ethereum.org/EIPS/eip-165). * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
contracts/extension/Royalty.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb import "./interface/IRoyalty.sol"; /** * @title Royalty * @notice Thirdweb's `Royalty` is a contract extension to be used with any base contract. It exposes functions for setting and reading * the recipient of royalty fee and the royalty fee basis points, and lets the inheriting contract perform conditional logic * that uses information about royalty fees, if desired. * * @dev The `Royalty` contract is ERC2981 compliant. */ abstract contract Royalty is IRoyalty { /// @dev The (default) address that receives all royalty value. address private royaltyRecipient; /// @dev The (default) % of a sale to take as royalty (in basis points). uint16 private royaltyBps; /// @dev Token ID => royalty recipient and bps for token mapping(uint256 => RoyaltyInfo) private royaltyInfoForToken; /** * @notice View royalty info for a given token and sale price. * @dev Returns royalty amount and recipient for `tokenId` and `salePrice`. * @param tokenId The tokenID of the NFT for which to query royalty info. * @param salePrice Sale price of the token. * * @return receiver Address of royalty recipient account. * @return royaltyAmount Royalty amount calculated at current royaltyBps value. */ function royaltyInfo( uint256 tokenId, uint256 salePrice ) external view virtual override returns (address receiver, uint256 royaltyAmount) { (address recipient, uint256 bps) = getRoyaltyInfoForToken(tokenId); receiver = recipient; royaltyAmount = (salePrice * bps) / 10_000; } /** * @notice View royalty info for a given token. * @dev Returns royalty recipient and bps for `_tokenId`. * @param _tokenId The tokenID of the NFT for which to query royalty info. */ function getRoyaltyInfoForToken(uint256 _tokenId) public view override returns (address, uint16) { RoyaltyInfo memory royaltyForToken = royaltyInfoForToken[_tokenId]; return royaltyForToken.recipient == address(0) ? (royaltyRecipient, uint16(royaltyBps)) : (royaltyForToken.recipient, uint16(royaltyForToken.bps)); } /** * @notice Returns the defualt royalty recipient and BPS for this contract's NFTs. */ function getDefaultRoyaltyInfo() external view override returns (address, uint16) { return (royaltyRecipient, uint16(royaltyBps)); } /** * @notice Updates default royalty recipient and bps. * @dev Caller should be authorized to set royalty info. * See {_canSetRoyaltyInfo}. * Emits {DefaultRoyalty Event}; See {_setupDefaultRoyaltyInfo}. * * @param _royaltyRecipient Address to be set as default royalty recipient. * @param _royaltyBps Updated royalty bps. */ function setDefaultRoyaltyInfo(address _royaltyRecipient, uint256 _royaltyBps) external override { if (!_canSetRoyaltyInfo()) { revert("Not authorized"); } _setupDefaultRoyaltyInfo(_royaltyRecipient, _royaltyBps); } /// @dev Lets a contract admin update the default royalty recipient and bps. function _setupDefaultRoyaltyInfo(address _royaltyRecipient, uint256 _royaltyBps) internal { if (_royaltyBps > 10_000) { revert("Exceeds max bps"); } royaltyRecipient = _royaltyRecipient; royaltyBps = uint16(_royaltyBps); emit DefaultRoyalty(_royaltyRecipient, _royaltyBps); } /** * @notice Updates default royalty recipient and bps for a particular token. * @dev Sets royalty info for `_tokenId`. Caller should be authorized to set royalty info. * See {_canSetRoyaltyInfo}. * Emits {RoyaltyForToken Event}; See {_setupRoyaltyInfoForToken}. * * @param _recipient Address to be set as royalty recipient for given token Id. * @param _bps Updated royalty bps for the token Id. */ function setRoyaltyInfoForToken(uint256 _tokenId, address _recipient, uint256 _bps) external override { if (!_canSetRoyaltyInfo()) { revert("Not authorized"); } _setupRoyaltyInfoForToken(_tokenId, _recipient, _bps); } /// @dev Lets a contract admin set the royalty recipient and bps for a particular token Id. function _setupRoyaltyInfoForToken(uint256 _tokenId, address _recipient, uint256 _bps) internal { if (_bps > 10_000) { revert("Exceeds max bps"); } royaltyInfoForToken[_tokenId] = RoyaltyInfo({ recipient: _recipient, bps: _bps }); emit RoyaltyForToken(_tokenId, _recipient, _bps); } /// @dev Returns whether royalty info can be set in the given execution context. function _canSetRoyaltyInfo() internal view virtual returns (bool); }
contracts/eip/interface/IERC721Receiver.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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 IERC721Receiver { /** * @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 `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/ERC1155Upgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC1155/ERC1155.sol) pragma solidity ^0.8.0; import "./IERC1155Upgradeable.sol"; import "./IERC1155ReceiverUpgradeable.sol"; import "./extensions/IERC1155MetadataURIUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../utils/introspection/ERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the basic standard multi-token. * See https://eips.ethereum.org/EIPS/eip-1155 * Originally based on code by Enjin: https://github.com/enjin/erc-1155 * * _Available since v3.1._ */ contract ERC1155Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC1155Upgradeable, IERC1155MetadataURIUpgradeable { using AddressUpgradeable for address; // Mapping from token ID to account balances mapping(uint256 => mapping(address => uint256)) private _balances; // Mapping from account to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string private _uri; /** * @dev See {_setURI}. */ function __ERC1155_init(string memory uri_) internal onlyInitializing { __ERC1155_init_unchained(uri_); } function __ERC1155_init_unchained(string memory uri_) internal onlyInitializing { _setURI(uri_); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) { return interfaceId == type(IERC1155Upgradeable).interfaceId || interfaceId == type(IERC1155MetadataURIUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC1155MetadataURI-uri}. * * This implementation returns the same URI for *all* token types. It relies * on the token type ID substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * Clients calling this function must replace the `\{id\}` substring with the * actual token type ID. */ function uri(uint256) public view virtual override returns (string memory) { return _uri; } /** * @dev See {IERC1155-balanceOf}. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) public view virtual override returns (uint256) { require(account != address(0), "ERC1155: address zero is not a valid owner"); return _balances[id][account]; } /** * @dev See {IERC1155-balanceOfBatch}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch( address[] memory accounts, uint256[] memory ids ) public view virtual override returns (uint256[] memory) { require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch"); uint256[] memory batchBalances = new uint256[](accounts.length); for (uint256 i = 0; i < accounts.length; ++i) { batchBalances[i] = balanceOf(accounts[i], ids[i]); } return batchBalances; } /** * @dev See {IERC1155-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC1155-isApprovedForAll}. */ function isApprovedForAll(address account, address operator) public view virtual override returns (bool) { return _operatorApprovals[account][operator]; } /** * @dev See {IERC1155-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not token owner or approved" ); _safeTransferFrom(from, to, id, amount, data); } /** * @dev See {IERC1155-safeBatchTransferFrom}. */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not token owner or approved" ); _safeBatchTransferFrom(from, to, ids, amounts, data); } /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, from, to, ids, amounts, data); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; emit TransferSingle(operator, from, to, id, amount); _afterTokenTransfer(operator, from, to, ids, amounts, data); _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, ids, amounts, data); for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; } emit TransferBatch(operator, from, to, ids, amounts); _afterTokenTransfer(operator, from, to, ids, amounts, data); _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data); } /** * @dev Sets a new URI for all token types, by relying on the token type ID * substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * By this mechanism, any occurrence of the `\{id\}` substring in either the * URI or any of the amounts in the JSON file at said URI will be replaced by * clients with the token type ID. * * For example, the `https://token-cdn-domain/\{id\}.json` URI would be * interpreted by clients as * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json` * for token type ID 0x4cce0. * * See {uri}. * * Because these URIs cannot be meaningfully represented by the {URI} event, * this function emits no events. */ function _setURI(string memory newuri) internal virtual { _uri = newuri; } /** * @dev Creates `amount` tokens of token type `id`, and assigns them to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint(address to, uint256 id, uint256 amount, bytes memory data) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); _balances[id][to] += amount; emit TransferSingle(operator, address(0), to, id, amount); _afterTokenTransfer(operator, address(0), to, ids, amounts, data); _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _mintBatch( address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); for (uint256 i = 0; i < ids.length; i++) { _balances[ids[i]][to] += amounts[i]; } emit TransferBatch(operator, address(0), to, ids, amounts); _afterTokenTransfer(operator, address(0), to, ids, amounts, data); _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data); } /** * @dev Destroys `amount` tokens of token type `id` from `from` * * Emits a {TransferSingle} event. * * Requirements: * * - `from` cannot be the zero address. * - `from` must have at least `amount` tokens of token type `id`. */ function _burn(address from, uint256 id, uint256 amount) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } emit TransferSingle(operator, from, address(0), id, amount); _afterTokenTransfer(operator, from, address(0), ids, amounts, ""); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. */ function _burnBatch(address from, uint256[] memory ids, uint256[] memory amounts) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); for (uint256 i = 0; i < ids.length; i++) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } } emit TransferBatch(operator, from, address(0), ids, amounts); _afterTokenTransfer(operator, from, address(0), ids, amounts, ""); } /** * @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, "ERC1155: setting approval status for self"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Hook that is called before any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `ids` and `amounts` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} /** * @dev Hook that is called after any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `id` and `amount` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} function _doSafeTransferAcceptanceCheck( address operator, address from, address to, uint256 id, uint256 amount, bytes memory data ) private { if (to.isContract()) { try IERC1155ReceiverUpgradeable(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) { if (response != IERC1155ReceiverUpgradeable.onERC1155Received.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non-ERC1155Receiver implementer"); } } } function _doSafeBatchTransferAcceptanceCheck( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) private { if (to.isContract()) { try IERC1155ReceiverUpgradeable(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns ( bytes4 response ) { if (response != IERC1155ReceiverUpgradeable.onERC1155BatchReceived.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non-ERC1155Receiver implementer"); } } } function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) { uint256[] memory array = new uint256[](1); array[0] = element; return array; } /** * @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[47] private __gap; }
contracts/external-deps/openzeppelin/utils/ERC721/ERC721Holder.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/utils/ERC721Holder.sol) pragma solidity ^0.8.0; import "../../../../eip/interface/IERC721Receiver.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 ERC721Holder is IERC721Receiver { /** * @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; } }
contracts/extension/TokenStore.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb // ========== External imports ========== import "../eip/interface/IERC1155.sol"; import "../eip/interface/IERC721.sol"; import "../external-deps/openzeppelin/utils/ERC1155/ERC1155Holder.sol"; import "../external-deps/openzeppelin/utils/ERC721/ERC721Holder.sol"; // ========== Internal imports ========== import { TokenBundle, ITokenBundle } from "./TokenBundle.sol"; import { CurrencyTransferLib } from "../lib/CurrencyTransferLib.sol"; /** * @title Token Store * @notice `TokenStore` contract extension allows bundling-up of ERC20/ERC721/ERC1155 and native-tokan assets * and provides logic for storing, releasing, and transferring them from the extending contract. * @dev See {CurrencyTransferLib} */ contract TokenStore is TokenBundle, ERC721Holder, ERC1155Holder { /// @dev The address of the native token wrapper contract. address internal immutable nativeTokenWrapper; constructor(address _nativeTokenWrapper) { nativeTokenWrapper = _nativeTokenWrapper; } /// @dev Store / escrow multiple ERC1155, ERC721, ERC20 tokens. function _storeTokens( address _tokenOwner, Token[] calldata _tokens, string memory _uriForTokens, uint256 _idForTokens ) internal { _createBundle(_tokens, _idForTokens); _setUriOfBundle(_uriForTokens, _idForTokens); _transferTokenBatch(_tokenOwner, address(this), _tokens); } /// @dev Release stored / escrowed ERC1155, ERC721, ERC20 tokens. function _releaseTokens(address _recipient, uint256 _idForContent) internal { uint256 count = getTokenCountOfBundle(_idForContent); Token[] memory tokensToRelease = new Token[](count); for (uint256 i = 0; i < count; i += 1) { tokensToRelease[i] = getTokenOfBundle(_idForContent, i); } _deleteBundle(_idForContent); _transferTokenBatch(address(this), _recipient, tokensToRelease); } /// @dev Transfers an arbitrary ERC20 / ERC721 / ERC1155 token. function _transferToken(address _from, address _to, Token memory _token) internal { if (_token.tokenType == TokenType.ERC20) { CurrencyTransferLib.transferCurrencyWithWrapper( _token.assetContract, _from, _to, _token.totalAmount, nativeTokenWrapper ); } else if (_token.tokenType == TokenType.ERC721) { IERC721(_token.assetContract).safeTransferFrom(_from, _to, _token.tokenId); } else if (_token.tokenType == TokenType.ERC1155) { IERC1155(_token.assetContract).safeTransferFrom(_from, _to, _token.tokenId, _token.totalAmount, ""); } } /// @dev Transfers multiple arbitrary ERC20 / ERC721 / ERC1155 tokens. function _transferTokenBatch(address _from, address _to, Token[] memory _tokens) internal { uint256 nativeTokenValue; for (uint256 i = 0; i < _tokens.length; i += 1) { if (_tokens[i].assetContract == CurrencyTransferLib.NATIVE_TOKEN && _to == address(this)) { nativeTokenValue += _tokens[i].totalAmount; } else { _transferToken(_from, _to, _tokens[i]); } } if (nativeTokenValue != 0) { Token memory _nativeToken = Token({ assetContract: CurrencyTransferLib.NATIVE_TOKEN, tokenType: ITokenBundle.TokenType.ERC20, tokenId: 0, totalAmount: nativeTokenValue }); _transferToken(_from, _to, _nativeToken); } } }
lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/extensions/IERC1155MetadataURIUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol) pragma solidity ^0.8.0; import "../IERC1155Upgradeable.sol"; /** * @dev Interface of the optional ERC1155MetadataExtension interface, as defined * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. * * _Available since v3.1._ */ interface IERC1155MetadataURIUpgradeable is IERC1155Upgradeable { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); }
contracts/lib/Strings.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /// @dev Returns the hexadecimal representation of `value`. /// The output is prefixed with "0x", encoded using 2 hexadecimal digits per byte, /// and the alphabets are capitalized conditionally according to /// https://eips.ethereum.org/EIPS/eip-55 function toHexStringChecksummed(address value) internal pure returns (string memory str) { str = toHexString(value); /// @solidity memory-safe-assembly assembly { let mask := shl(6, div(not(0), 255)) // `0b010000000100000000 ...` let o := add(str, 0x22) let hashed := and(keccak256(o, 40), mul(34, mask)) // `0b10001000 ... ` let t := shl(240, 136) // `0b10001000 << 240` for { let i := 0 } 1 { } { mstore(add(i, i), mul(t, byte(i, hashed))) i := add(i, 1) if eq(i, 20) { break } } mstore(o, xor(mload(o), shr(1, and(mload(0x00), and(mload(o), mask))))) o := add(o, 0x20) mstore(o, xor(mload(o), shr(1, and(mload(0x20), and(mload(o), mask))))) } } /// @dev Returns the hexadecimal representation of `value`. /// The output is prefixed with "0x" and encoded using 2 hexadecimal digits per byte. function toHexString(address value) internal pure returns (string memory str) { str = toHexStringNoPrefix(value); /// @solidity memory-safe-assembly assembly { let strLength := add(mload(str), 2) // Compute the length. mstore(str, 0x3078) // Write the "0x" prefix. str := sub(str, 2) // Move the pointer. mstore(str, strLength) // Write the length. } } /// @dev Returns the hexadecimal representation of `value`. /// The output is encoded using 2 hexadecimal digits per byte. function toHexStringNoPrefix(address value) internal pure returns (string memory str) { /// @solidity memory-safe-assembly assembly { str := mload(0x40) // Allocate the memory. // We need 0x20 bytes for the trailing zeros padding, 0x20 bytes for the length, // 0x02 bytes for the prefix, and 0x28 bytes for the digits. // The next multiple of 0x20 above (0x20 + 0x20 + 0x02 + 0x28) is 0x80. mstore(0x40, add(str, 0x80)) // Store "0123456789abcdef" in scratch space. mstore(0x0f, 0x30313233343536373839616263646566) str := add(str, 2) mstore(str, 40) let o := add(str, 0x20) mstore(add(o, 40), 0) value := shl(96, value) // We write the string from rightmost digit to leftmost digit. // The following is essentially a do-while loop that also handles the zero case. for { let i := 0 } 1 { } { let p := add(o, add(i, i)) let temp := byte(i, value) mstore8(add(p, 1), mload(and(temp, 15))) mstore8(p, mload(shr(4, temp))) i := add(i, 1) if eq(i, 20) { break } } } } /// @dev Returns the hex encoded string from the raw bytes. /// The output is encoded using 2 hexadecimal digits per byte. function toHexString(bytes memory raw) internal pure returns (string memory str) { str = toHexStringNoPrefix(raw); /// @solidity memory-safe-assembly assembly { let strLength := add(mload(str), 2) // Compute the length. mstore(str, 0x3078) // Write the "0x" prefix. str := sub(str, 2) // Move the pointer. mstore(str, strLength) // Write the length. } } /// @dev Returns the hex encoded string from the raw bytes. /// The output is encoded using 2 hexadecimal digits per byte. function toHexStringNoPrefix(bytes memory raw) internal pure returns (string memory str) { /// @solidity memory-safe-assembly assembly { let length := mload(raw) str := add(mload(0x40), 2) // Skip 2 bytes for the optional prefix. mstore(str, add(length, length)) // Store the length of the output. // Store "0123456789abcdef" in scratch space. mstore(0x0f, 0x30313233343536373839616263646566) let o := add(str, 0x20) let end := add(raw, length) for { } iszero(eq(raw, end)) { } { raw := add(raw, 1) mstore8(add(o, 1), mload(and(mload(raw), 15))) mstore8(o, mload(and(shr(4, mload(raw)), 15))) o := add(o, 2) } mstore(o, 0) // Zeroize the slot after the string. mstore(0x40, add(o, 0x20)) // Allocate the memory. } } }
contracts/external-deps/openzeppelin/utils/ERC1155/ERC1155Receiver.sol
// SPDX-License-Identifier: Apache 2.0 // OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol) pragma solidity ^0.8.0; import "../../../../eip/interface/IERC1155Receiver.sol"; import "../../../../eip/ERC165.sol"; /** * @dev _Available since v3.1._ */ abstract contract ERC1155Receiver is ERC165, IERC1155Receiver { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId); } }
contracts/lib/CurrencyTransferLib.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb // Helper interfaces import { IWETH } from "../infra/interface/IWETH.sol"; import { SafeERC20, IERC20 } from "../external-deps/openzeppelin/token/ERC20/utils/SafeERC20.sol"; library CurrencyTransferLib { using SafeERC20 for IERC20; /// @dev The address interpreted as native token of the chain. address public constant NATIVE_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; /// @dev Transfers a given amount of currency. function transferCurrency(address _currency, address _from, address _to, uint256 _amount) internal { if (_amount == 0) { return; } if (_currency == NATIVE_TOKEN) { safeTransferNativeToken(_to, _amount); } else { safeTransferERC20(_currency, _from, _to, _amount); } } /// @dev Transfers a given amount of currency. (With native token wrapping) function transferCurrencyWithWrapper( address _currency, address _from, address _to, uint256 _amount, address _nativeTokenWrapper ) internal { if (_amount == 0) { return; } if (_currency == NATIVE_TOKEN) { if (_from == address(this)) { // withdraw from weth then transfer withdrawn native token to recipient IWETH(_nativeTokenWrapper).withdraw(_amount); safeTransferNativeTokenWithWrapper(_to, _amount, _nativeTokenWrapper); } else if (_to == address(this)) { // store native currency in weth require(_amount == msg.value, "msg.value != amount"); IWETH(_nativeTokenWrapper).deposit{ value: _amount }(); } else { safeTransferNativeTokenWithWrapper(_to, _amount, _nativeTokenWrapper); } } else { safeTransferERC20(_currency, _from, _to, _amount); } } /// @dev Transfer `amount` of ERC20 token from `from` to `to`. function safeTransferERC20(address _currency, address _from, address _to, uint256 _amount) internal { if (_from == _to) { return; } if (_from == address(this)) { IERC20(_currency).safeTransfer(_to, _amount); } else { IERC20(_currency).safeTransferFrom(_from, _to, _amount); } } /// @dev Transfers `amount` of native token to `to`. function safeTransferNativeToken(address to, uint256 value) internal { // solhint-disable avoid-low-level-calls // slither-disable-next-line low-level-calls (bool success, ) = to.call{ value: value }(""); require(success, "native token transfer failed"); } /// @dev Transfers `amount` of native token to `to`. (With native token wrapping) function safeTransferNativeTokenWithWrapper(address to, uint256 value, address _nativeTokenWrapper) internal { // solhint-disable avoid-low-level-calls // slither-disable-next-line low-level-calls (bool success, ) = to.call{ value: value }(""); if (!success) { IWETH(_nativeTokenWrapper).deposit{ value: value }(); IERC20(_nativeTokenWrapper).safeTransfer(to, value); } } }
contracts/external-deps/openzeppelin/utils/ERC1155/ERC1155Holder.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/utils/ERC1155Holder.sol) pragma solidity ^0.8.0; import "./ERC1155Receiver.sol"; /** * Simple implementation of `ERC1155Receiver` that will allow a contract to hold ERC1155 tokens. * * IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be * stuck. * * @dev _Available since v3.1._ */ contract ERC1155Holder is ERC1155Receiver { function onERC1155Received( address, address, uint256, uint256, bytes memory ) public virtual override returns (bytes4) { return this.onERC1155Received.selector; } function onERC1155BatchReceived( address, address, uint256[] memory, uint256[] memory, bytes memory ) public virtual override returns (bytes4) { return this.onERC1155BatchReceived.selector; } }
contracts/external-deps/openzeppelin/token/ERC20/utils/SafeERC20.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../../../../../eip/interface/IERC20.sol"; import { Address } from "@openzeppelin/contracts/utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
contracts/extension/interface/IContractMetadata.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb /** * Thirdweb's `ContractMetadata` is a contract extension for any base contracts. It lets you set a metadata URI * for you contract. * * Additionally, `ContractMetadata` is necessary for NFT contracts that want royalties to get distributed on OpenSea. */ interface IContractMetadata { /// @dev Returns the metadata URI of the contract. function contractURI() external view returns (string memory); /** * @dev Sets contract URI for the storefront-level metadata of the contract. * Only module admin can call this function. */ function setContractURI(string calldata _uri) external; /// @dev Emitted when the contract URI is updated. event ContractURIUpdated(string prevURI, string newURI); }
contracts/extension/interface/IMulticall.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author thirdweb /** * @dev Provides a function to batch together multiple calls in a single external call. * * _Available since v4.1._ */ interface IMulticall { /** * @dev Receives and executes a batch of function calls on this contract. */ function multicall(bytes[] calldata data) external returns (bytes[] memory results); }
contracts/extension/Ownable.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb import "./interface/IOwnable.sol"; /** * @title Ownable * @notice Thirdweb's `Ownable` is a contract extension to be used with any base contract. It exposes functions for setting and reading * who the 'owner' of the inheriting smart contract is, and lets the inheriting contract perform conditional logic that uses * information about who the contract's owner is. */ abstract contract Ownable is IOwnable { /// @dev Owner of the contract (purpose: OpenSea compatibility) address private _owner; /// @dev Reverts if caller is not the owner. modifier onlyOwner() { if (msg.sender != _owner) { revert("Not authorized"); } _; } /** * @notice Returns the owner of the contract. */ function owner() public view override returns (address) { return _owner; } /** * @notice Lets an authorized wallet set a new owner for the contract. * @param _newOwner The address to set as the new owner of the contract. */ function setOwner(address _newOwner) external override { if (!_canSetOwner()) { revert("Not authorized"); } _setupOwner(_newOwner); } /// @dev Lets a contract admin set a new owner for the contract. The new owner must be a contract admin. function _setupOwner(address _newOwner) internal { address _prevOwner = _owner; _owner = _newOwner; emit OwnerUpdated(_prevOwner, _newOwner); } /// @dev Returns whether owner can be set in the given execution context. function _canSetOwner() internal view virtual returns (bool); }
contracts/extension/interface/IOwnable.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb /** * Thirdweb's `Ownable` is a contract extension to be used with any base contract. It exposes functions for setting and reading * who the 'owner' of the inheriting smart contract is, and lets the inheriting contract perform conditional logic that uses * information about who the contract's owner is. */ interface IOwnable { /// @dev Returns the owner of the contract. function owner() external view returns (address); /// @dev Lets a module admin set a new owner for the contract. The new owner must be a module admin. function setOwner(address _newOwner) external; /// @dev Emitted when a new Owner is set. event OwnerUpdated(address indexed prevOwner, address indexed newOwner); }
contracts/eip/ERC165.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./interface/IERC165.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 ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
contracts/external-deps/openzeppelin/metatx/ERC2771ContextUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (metatx/ERC2771Context.sol) pragma solidity ^0.8.11; import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; /** * @dev Context variant with ERC2771 support. */ abstract contract ERC2771ContextUpgradeable is Initializable, ContextUpgradeable { mapping(address => bool) private _trustedForwarder; function __ERC2771Context_init(address[] memory trustedForwarder) internal onlyInitializing { __Context_init_unchained(); __ERC2771Context_init_unchained(trustedForwarder); } function __ERC2771Context_init_unchained(address[] memory trustedForwarder) internal onlyInitializing { for (uint256 i = 0; i < trustedForwarder.length; i++) { _trustedForwarder[trustedForwarder[i]] = true; } } function isTrustedForwarder(address forwarder) public view virtual returns (bool) { return _trustedForwarder[forwarder]; } function _msgSender() internal view virtual override returns (address sender) { if (isTrustedForwarder(msg.sender)) { // The assembly code is more direct than the Solidity version using `abi.decode`. assembly { sender := shr(96, calldataload(sub(calldatasize(), 20))) } } else { return super._msgSender(); } } function _msgData() internal view virtual override returns (bytes calldata) { if (isTrustedForwarder(msg.sender)) { return msg.data[:msg.data.length - 20]; } else { return super._msgData(); } } uint256[49] private __gap; }
contracts/prebuilts/interface/IPack.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.11; import "../../extension/interface/ITokenBundle.sol"; /** * The thirdweb `Pack` contract is a lootbox mechanism. An account can bundle up arbitrary ERC20, ERC721 and ERC1155 tokens into * a set of packs. A pack can then be opened in return for a selection of the tokens in the pack. The selection of tokens distributed * on opening a pack depends on the relative supply of all tokens in the packs. */ interface IPack is ITokenBundle { /** * @notice All info relevant to packs. * * @param perUnitAmounts Mapping from a UID -> to the per-unit amount of that asset i.e. `Token` at that index. * @param openStartTimestamp The timestamp after which packs can be opened. * @param amountDistributedPerOpen The number of reward units distributed per open. */ struct PackInfo { uint256[] perUnitAmounts; uint128 openStartTimestamp; uint128 amountDistributedPerOpen; } /// @notice Emitted when a set of packs is created. event PackCreated(uint256 indexed packId, address recipient, uint256 totalPacksCreated); /// @notice Emitted when more packs are minted for a packId. event PackUpdated(uint256 indexed packId, address recipient, uint256 totalPacksCreated); /// @notice Emitted when a pack is opened. event PackOpened( uint256 indexed packId, address indexed opener, uint256 numOfPacksOpened, Token[] rewardUnitsDistributed ); /** * @notice Creates a pack with the stated contents. * * @param contents The reward units to pack in the packs. * @param numOfRewardUnits The number of reward units to create, for each asset specified in `contents`. * @param packUri The (metadata) URI assigned to the packs created. * @param openStartTimestamp The timestamp after which packs can be opened. * @param amountDistributedPerOpen The number of reward units distributed per open. * @param recipient The recipient of the packs created. * * @return packId The unique identifier of the created set of packs. * @return packTotalSupply The total number of packs created. */ function createPack( Token[] calldata contents, uint256[] calldata numOfRewardUnits, string calldata packUri, uint128 openStartTimestamp, uint128 amountDistributedPerOpen, address recipient ) external payable returns (uint256 packId, uint256 packTotalSupply); /** * @notice Lets a pack owner open a pack and receive the pack's reward unit. * * @param packId The identifier of the pack to open. * @param amountToOpen The number of packs to open at once. */ function openPack(uint256 packId, uint256 amountToOpen) external returns (Token[] memory); }
lib/openzeppelin-contracts/contracts/interfaces/IERC1155Receiver.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1155Receiver.sol) pragma solidity ^0.8.0; import "../token/ERC1155/IERC1155Receiver.sol";
contracts/extension/Multicall.sol
// SPDX-License-Identifier: Apache 2.0 pragma solidity ^0.8.0; /// @author thirdweb import "../lib/Address.sol"; import "./interface/IMulticall.sol"; /** * @dev Provides a function to batch together multiple calls in a single external call. * * _Available since v4.1._ */ contract Multicall is IMulticall { /** * @notice Receives and executes a batch of function calls on this contract. * @dev Receives and executes a batch of function calls on this contract. * * @param data The bytes data that makes up the batch of function calls to execute. * @return results The bytes data that makes up the result of the batch of function calls executed. */ function multicall(bytes[] calldata data) external returns (bytes[] memory results) { results = new bytes[](data.length); address sender = _msgSender(); bool isForwarder = msg.sender != sender; for (uint256 i = 0; i < data.length; i++) { if (isForwarder) { results[i] = Address.functionDelegateCall(address(this), abi.encodePacked(data[i], sender)); } else { results[i] = Address.functionDelegateCall(address(this), data[i]); } } return results; } /// @notice Returns the sender in the given execution context. function _msgSender() internal view virtual returns (address) { return msg.sender; } }
lib/openzeppelin-contracts-upgradeable/contracts/utils/introspection/ERC165Upgradeable.sol
// 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; }
lib/openzeppelin-contracts/contracts/interfaces/IERC721Receiver.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC721Receiver.sol) pragma solidity ^0.8.0; import "../token/ERC721/IERC721Receiver.sol";
contracts/lib/Address.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.1; /// @author thirdweb, OpenZeppelin Contracts (v4.9.0) /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{ value: value }(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
lib/openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
contracts/eip/interface/IERC721.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; }
lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized != type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
contracts/infra/interface/IWETH.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; interface IWETH { function deposit() external payable; function withdraw(uint256 amount) external; function transfer(address to, uint256 value) external returns (bool); }
lib/openzeppelin-contracts/contracts/utils/Address.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
Compiler Settings
{"remappings":["@chainlink/=lib/chainlink/","@ds-test/=lib/ds-test/src/","@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/","@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/","@std/=lib/forge-std/src/","@thirdweb-dev/dynamic-contracts/=lib/dynamic-contracts/","ERC721A-Upgradeable/=lib/ERC721A-Upgradeable/contracts/","ERC721A/=lib/ERC721A/contracts/","chainlink/=lib/chainlink/contracts/","contracts/=contracts/","ds-test/=lib/ds-test/src/","dynamic-contracts/=lib/dynamic-contracts/src/","erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/","erc721a-upgradeable/=lib/ERC721A-Upgradeable/","erc721a/=lib/ERC721A/","forge-std/=lib/forge-std/src/","lib/sstore2/=lib/dynamic-contracts/lib/sstore2/","openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/","openzeppelin-contracts/=lib/openzeppelin-contracts/","openzeppelin/=lib/openzeppelin-contracts-upgradeable/contracts/","sstore2/=lib/dynamic-contracts/lib/sstore2/contracts/"],"outputSelection":{"*":{"*":["*"],"":["*"]}},"optimizer":{"runs":20,"enabled":true},"libraries":{},"evmVersion":"london"}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_nativeTokenWrapper","internalType":"address"},{"type":"address","name":"_trustedForwarder","internalType":"address"}]},{"type":"event","name":"ApprovalForAll","inputs":[{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"operator","internalType":"address","indexed":true},{"type":"bool","name":"approved","internalType":"bool","indexed":false}],"anonymous":false},{"type":"event","name":"ContractURIUpdated","inputs":[{"type":"string","name":"prevURI","internalType":"string","indexed":false},{"type":"string","name":"newURI","internalType":"string","indexed":false}],"anonymous":false},{"type":"event","name":"DefaultRoyalty","inputs":[{"type":"address","name":"newRoyaltyRecipient","internalType":"address","indexed":true},{"type":"uint256","name":"newRoyaltyBps","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"type":"uint8","name":"version","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"OwnerUpdated","inputs":[{"type":"address","name":"prevOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"PackCreated","inputs":[{"type":"uint256","name":"packId","internalType":"uint256","indexed":true},{"type":"address","name":"recipient","internalType":"address","indexed":false},{"type":"uint256","name":"totalPacksCreated","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"PackOpened","inputs":[{"type":"uint256","name":"packId","internalType":"uint256","indexed":true},{"type":"address","name":"opener","internalType":"address","indexed":true},{"type":"uint256","name":"numOfPacksOpened","internalType":"uint256","indexed":false},{"type":"tuple[]","name":"rewardUnitsDistributed","internalType":"struct ITokenBundle.Token[]","indexed":false,"components":[{"type":"address","name":"assetContract","internalType":"address"},{"type":"uint8","name":"tokenType","internalType":"enum ITokenBundle.TokenType"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"uint256","name":"totalAmount","internalType":"uint256"}]}],"anonymous":false},{"type":"event","name":"PackUpdated","inputs":[{"type":"uint256","name":"packId","internalType":"uint256","indexed":true},{"type":"address","name":"recipient","internalType":"address","indexed":false},{"type":"uint256","name":"totalPacksCreated","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RoleAdminChanged","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"previousAdminRole","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"newAdminRole","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"RoleGranted","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RoleRevoked","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RoyaltyForToken","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":true},{"type":"address","name":"royaltyRecipient","internalType":"address","indexed":true},{"type":"uint256","name":"royaltyBps","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"TransferBatch","inputs":[{"type":"address","name":"operator","internalType":"address","indexed":true},{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256[]","name":"ids","internalType":"uint256[]","indexed":false},{"type":"uint256[]","name":"values","internalType":"uint256[]","indexed":false}],"anonymous":false},{"type":"event","name":"TransferSingle","inputs":[{"type":"address","name":"operator","internalType":"address","indexed":true},{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256","name":"id","internalType":"uint256","indexed":false},{"type":"uint256","name":"value","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"URI","inputs":[{"type":"string","name":"value","internalType":"string","indexed":false},{"type":"uint256","name":"id","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"DEFAULT_ADMIN_ROLE","inputs":[]},{"type":"function","stateMutability":"payable","outputs":[{"type":"uint256","name":"packTotalSupply","internalType":"uint256"},{"type":"uint256","name":"newSupplyAdded","internalType":"uint256"}],"name":"addPackContents","inputs":[{"type":"uint256","name":"_packId","internalType":"uint256"},{"type":"tuple[]","name":"_contents","internalType":"struct ITokenBundle.Token[]","components":[{"type":"address","name":"assetContract","internalType":"address"},{"type":"uint8","name":"tokenType","internalType":"enum ITokenBundle.TokenType"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"uint256","name":"totalAmount","internalType":"uint256"}]},{"type":"uint256[]","name":"_numOfRewardUnits","internalType":"uint256[]"},{"type":"address","name":"_recipient","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceOf","inputs":[{"type":"address","name":"account","internalType":"address"},{"type":"uint256","name":"id","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256[]","name":"","internalType":"uint256[]"}],"name":"balanceOfBatch","inputs":[{"type":"address[]","name":"accounts","internalType":"address[]"},{"type":"uint256[]","name":"ids","internalType":"uint256[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"canUpdatePack","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"contractType","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"contractURI","inputs":[]},{"type":"function","stateMutability":"pure","outputs":[{"type":"uint8","name":"","internalType":"uint8"}],"name":"contractVersion","inputs":[]},{"type":"function","stateMutability":"payable","outputs":[{"type":"uint256","name":"packId","internalType":"uint256"},{"type":"uint256","name":"packTotalSupply","internalType":"uint256"}],"name":"createPack","inputs":[{"type":"tuple[]","name":"_contents","internalType":"struct ITokenBundle.Token[]","components":[{"type":"address","name":"assetContract","internalType":"address"},{"type":"uint8","name":"tokenType","internalType":"enum ITokenBundle.TokenType"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"uint256","name":"totalAmount","internalType":"uint256"}]},{"type":"uint256[]","name":"_numOfRewardUnits","internalType":"uint256[]"},{"type":"string","name":"_packUri","internalType":"string"},{"type":"uint128","name":"_openStartTimestamp","internalType":"uint128"},{"type":"uint128","name":"_amountDistributedPerOpen","internalType":"uint128"},{"type":"address","name":"_recipient","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"},{"type":"uint16","name":"","internalType":"uint16"}],"name":"getDefaultRoyaltyInfo","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple[]","name":"contents","internalType":"struct ITokenBundle.Token[]","components":[{"type":"address","name":"assetContract","internalType":"address"},{"type":"uint8","name":"tokenType","internalType":"enum ITokenBundle.TokenType"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"uint256","name":"totalAmount","internalType":"uint256"}]},{"type":"uint256[]","name":"perUnitAmounts","internalType":"uint256[]"}],"name":"getPackContents","inputs":[{"type":"uint256","name":"_packId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getRoleAdmin","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"member","internalType":"address"}],"name":"getRoleMember","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"uint256","name":"index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"count","internalType":"uint256"}],"name":"getRoleMemberCount","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"},{"type":"uint16","name":"","internalType":"uint16"}],"name":"getRoyaltyInfoForToken","inputs":[{"type":"uint256","name":"_tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getTokenCountOfBundle","inputs":[{"type":"uint256","name":"_bundleId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"","internalType":"struct ITokenBundle.Token","components":[{"type":"address","name":"assetContract","internalType":"address"},{"type":"uint8","name":"tokenType","internalType":"enum ITokenBundle.TokenType"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"uint256","name":"totalAmount","internalType":"uint256"}]}],"name":"getTokenOfBundle","inputs":[{"type":"uint256","name":"_bundleId","internalType":"uint256"},{"type":"uint256","name":"index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"getUriOfBundle","inputs":[{"type":"uint256","name":"_bundleId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"grantRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasRoleWithSwitch","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_defaultAdmin","internalType":"address"},{"type":"string","name":"_name","internalType":"string"},{"type":"string","name":"_symbol","internalType":"string"},{"type":"string","name":"_contractURI","internalType":"string"},{"type":"address[]","name":"_trustedForwarders","internalType":"address[]"},{"type":"address","name":"_royaltyRecipient","internalType":"address"},{"type":"uint256","name":"_royaltyBps","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isApprovedForAll","inputs":[{"type":"address","name":"account","internalType":"address"},{"type":"address","name":"operator","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isTrustedForwarder","inputs":[{"type":"address","name":"forwarder","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bytes[]","name":"results","internalType":"bytes[]"}],"name":"multicall","inputs":[{"type":"bytes[]","name":"data","internalType":"bytes[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"name","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"nextTokenIdToMint","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bytes4","name":"","internalType":"bytes4"}],"name":"onERC1155BatchReceived","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"address","name":"","internalType":"address"},{"type":"uint256[]","name":"","internalType":"uint256[]"},{"type":"uint256[]","name":"","internalType":"uint256[]"},{"type":"bytes","name":"","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bytes4","name":"","internalType":"bytes4"}],"name":"onERC1155Received","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"bytes","name":"","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bytes4","name":"","internalType":"bytes4"}],"name":"onERC721Received","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"bytes","name":"","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"tuple[]","name":"","internalType":"struct ITokenBundle.Token[]","components":[{"type":"address","name":"assetContract","internalType":"address"},{"type":"uint8","name":"tokenType","internalType":"enum ITokenBundle.TokenType"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"uint256","name":"totalAmount","internalType":"uint256"}]}],"name":"openPack","inputs":[{"type":"uint256","name":"_packId","internalType":"uint256"},{"type":"uint256","name":"_amountToOpen","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"revokeRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"receiver","internalType":"address"},{"type":"uint256","name":"royaltyAmount","internalType":"uint256"}],"name":"royaltyInfo","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"uint256","name":"salePrice","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"safeBatchTransferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256[]","name":"ids","internalType":"uint256[]"},{"type":"uint256[]","name":"amounts","internalType":"uint256[]"},{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"safeTransferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"id","internalType":"uint256"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setApprovalForAll","inputs":[{"type":"address","name":"operator","internalType":"address"},{"type":"bool","name":"approved","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setContractURI","inputs":[{"type":"string","name":"_uri","internalType":"string"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setDefaultRoyaltyInfo","inputs":[{"type":"address","name":"_royaltyRecipient","internalType":"address"},{"type":"uint256","name":"_royaltyBps","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setOwner","inputs":[{"type":"address","name":"_newOwner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setRoyaltyInfoForToken","inputs":[{"type":"uint256","name":"_tokenId","internalType":"uint256"},{"type":"address","name":"_recipient","internalType":"address"},{"type":"uint256","name":"_bps","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"symbol","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalSupply","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"uri","inputs":[{"type":"uint256","name":"_tokenId","internalType":"uint256"}]},{"type":"receive","stateMutability":"payable"}]
Contract Creation Code
0x60c06040523480156200001157600080fd5b5060405162005cb538038062005cb5833981016040819052620000349162000184565b6001600160a01b038216608052600054610100900460ff1615808015620000625750600054600160ff909116105b806200007e5750303b1580156200007e575060005460ff166001145b620000e65760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840160405180910390fd5b6000805460ff1916600117905580156200010a576000805461ff0019166101001790555b6001600160a01b03821660a05280156200015e576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050620001bc565b80516001600160a01b03811681146200017f57600080fd5b919050565b600080604083850312156200019857600080fd5b620001a38362000167565b9150620001b36020840162000167565b90509250929050565b60805160a051615acc620001e9600039600061134a0152600081816102300152613ca00152615acc6000f3fe6080604052600436106102205760003560e01c8063914e126a1161011f578063914e126a1461063457806391d1485414610661578063938e3d7b1461068157806395d89b41146106a15780639bcf7a15146106b6578063a0a8e460146106d6578063a217fddf146106f2578063a22cb46514610707578063a32fa5b314610727578063a96b143814610747578063ac9650d81461075a578063b0381b0814610787578063b24f2d39146107b8578063bc197c81146107e3578063bd85b0391461080f578063ca15c8731461083d578063cb2ef6f71461085d578063d0d2fe2514610877578063d547741f146108a4578063e8a3d485146108c4578063e985e9c5146108d9578063f23a6e6114610922578063f242432a1461094e57600080fd5b8062fdd58e146102a057806301ffc9a7146102d357806306fdde0314610303578063092e6075146103255780630e89341c1461034d57806313af40351461036d578063150b7a021461038d5780631da799c9146103c6578063248a9ca3146103f35780632a55205a146104205780632eb2c2d61461044e5780632f2ff15d1461046e57806336568abe1461048e5780633b1475a7146104ae5780634cc157df146104c55780634e1273f414610507578063572b6c0514610534578063600dd5ea1461055457806361195e9414610574578063754b8fe7146105945780638d4c446a146105b45780638da5cb5b146105e25780639010d07c1461061457600080fd5b3661029b57336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146102995760405162461bcd60e51b815260206004820152601460248201527310b730ba34bb32aa37b5b2b72bb930b83832b91760611b60448201526064015b60405180910390fd5b005b600080fd5b3480156102ac57600080fd5b506102c06102bb366004614770565b61096e565b6040519081526020015b60405180910390f35b3480156102df57600080fd5b506102f36102ee3660046147b2565b610a04565b60405190151581526020016102ca565b34801561030f57600080fd5b50610318610a62565b6040516102ca919061481f565b61033861033336600461498d565b610af1565b604080519283526020830191909152016102ca565b34801561035957600080fd5b50610318610368366004614a55565b610c84565b34801561037957600080fd5b50610299610388366004614a6e565b610c8f565b34801561039957600080fd5b506103ad6103a8366004614a8b565b610cbf565b6040516001600160e01b031990911681526020016102ca565b3480156103d257600080fd5b506103e66103e1366004614af6565b610cd0565b6040516102ca9190614b78565b3480156103ff57600080fd5b506102c061040e366004614a55565b60009081526007602052604090205490565b34801561042c57600080fd5b5061044061043b366004614af6565b610d5f565b6040516102ca929190614b86565b34801561045a57600080fd5b50610299610469366004614c38565b610d9c565b34801561047a57600080fd5b50610299610489366004614ce5565b610dfa565b34801561049a57600080fd5b506102996104a9366004614ce5565b610e94565b3480156104ba57600080fd5b506102c06101085481565b3480156104d157600080fd5b506104e56104e0366004614a55565b610ef3565b604080516001600160a01b03909316835261ffff9091166020830152016102ca565b34801561051357600080fd5b50610527610522366004614d89565b610f5e565b6040516102ca9190614e28565b34801561054057600080fd5b506102f361054f366004614a6e565b61107f565b34801561056057600080fd5b5061029961056f366004614770565b61109d565b34801561058057600080fd5b5061031861058f366004614a55565b6110cb565b3480156105a057600080fd5b506102996105af366004614e3b565b611170565b3480156105c057600080fd5b506105d46105cf366004614a55565b61147b565b6040516102ca929190614f4d565b3480156105ee57600080fd5b506002546001600160a01b03165b6040516001600160a01b0390911681526020016102ca565b34801561062057600080fd5b506105fc61062f366004614af6565b61160a565b34801561064057600080fd5b5061065461064f366004614af6565b6116f8565b6040516102ca9190614f7b565b34801561066d57600080fd5b506102f361067c366004614ce5565b6118da565b34801561068d57600080fd5b5061029961069c366004614f8e565b611905565b3480156106ad57600080fd5b50610318611932565b3480156106c257600080fd5b506102996106d1366004614fc2565b611940565b3480156106e257600080fd5b50604051600281526020016102ca565b3480156106fe57600080fd5b506102c0600081565b34801561071357600080fd5b50610299610722366004615008565b611974565b34801561073357600080fd5b506102f3610742366004614ce5565b611986565b610338610755366004615036565b6119dc565b34801561076657600080fd5b5061077a6107753660046150c1565b611bc2565b6040516102ca9190615102565b34801561079357600080fd5b506102f36107a2366004614a55565b61010b6020526000908152604090205460ff1681565b3480156107c457600080fd5b506004546001600160a01b03811690600160a01b900461ffff166104e5565b3480156107ef57600080fd5b506103ad6107fe366004614c38565b63bc197c8160e01b95945050505050565b34801561081b57600080fd5b506102c061082a366004614a55565b6101096020526000908152604090205481565b34801561084957600080fd5b506102c0610858366004614a55565b611d35565b34801561086957600080fd5b50635061636b60e01b6102c0565b34801561088357600080fd5b506102c0610892366004614a55565b60009081526003602052604090205490565b3480156108b057600080fd5b506102996108bf366004614ce5565b611dbe565b3480156108d057600080fd5b50610318611dd7565b3480156108e557600080fd5b506102f36108f4366004615166565b6001600160a01b03918216600090815260d26020908152604080832093909416825291909152205460ff1690565b34801561092e57600080fd5b506103ad61093d366004615194565b63f23a6e6160e01b95945050505050565b34801561095a57600080fd5b50610299610969366004615194565b611de4565b60006001600160a01b0383166109d95760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a2061646472657373207a65726f206973206e6f742061207660448201526930b634b21037bbb732b960b11b6064820152608401610290565b50600081815260d1602090815260408083206001600160a01b03861684529091529020545b92915050565b6000610a0f82611e3b565b80610a2a575063152a902d60e11b6001600160e01b03198316145b80610a455750630a85bd0160e11b6001600160e01b03198316145b806109fe5750506001600160e01b031916630271189760e51b1490565b6101038054610a70906151fc565b80601f0160208091040260200160405190810160405280929190818152602001828054610a9c906151fc565b8015610ae95780601f10610abe57610100808354040283529160200191610ae9565b820191906000526020600020905b815481529060010190602001808311610acc57829003601f168201915b505050505081565b60008061010654610b0981610b04611e8b565b611e9a565b610b11611efe565b8915801590610b1f57508988145b610b3b5760405162461bcd60e51b815260040161029090615230565b610b496101075460006118da565b610ba05760005b8a811015610b9e57610b8c610107548d8d84818110610b7157610b7161524e565b610b879260206080909202019081019150614a6e565b611f57565b610b9760018261527a565b9050610b50565b505b610108805493506001906000610bb6838761527a565b90915550610bd690508b8b8b8b8b886001600160801b038c166000611f95565b600084815261010a602090815260408083206001600160801b038a8116600160801b02908c161760019182015561010b8352818420805460ff1916909117905580519182019052908152909250610c329085908590859061229a565b827f529034575398e71312a0b7b951d8ca42dce1529d774f4a255a587f64f649fff88584604051610c64929190614b86565b60405180910390a2610c766001600955565b509850989650505050505050565b60606109fe826110cb565b610c976123b8565b610cb35760405162461bcd60e51b81526004016102909061528d565b610cbc816123c6565b50565b630a85bd0160e11b5b949350505050565b610cd8614722565b6000838152600360209081526040808320858452600290810183529281902081516080810190925280546001600160a01b038116835291939092840191600160a01b900460ff1690811115610d2f57610d2f614b18565b6002811115610d4057610d40614b18565b8152600182015460208201526002909101546040909101529392505050565b600080600080610d6e86610ef3565b90945084925061ffff169050612710610d8782876152b5565b610d9191906152e2565b925050509250929050565b610da4611e8b565b6001600160a01b0316856001600160a01b03161480610dca5750610dca856108f4611e8b565b610de65760405162461bcd60e51b8152600401610290906152f6565b610df38585858585612418565b5050505050565b600082815260076020526040902054610e139033611f57565b60008281526006602090815260408083206001600160a01b038516845290915290205460ff1615610e865760405162461bcd60e51b815260206004820152601d60248201527f43616e206f6e6c79206772616e7420746f206e6f6e20686f6c646572730000006044820152606401610290565b610e90828261260a565b5050565b336001600160a01b03821614610ee95760405162461bcd60e51b815260206004820152601a60248201527921b0b71037b7363c903932b737bab731b2903337b91039b2b63360311b6044820152606401610290565b610e90828261261e565b6000818152600560209081526040808320815180830190925280546001600160a01b031680835260019091015492820192909252829115610f3a5780516020820151610f54565b6004546001600160a01b03811690600160a01b900461ffff165b9250925050915091565b60608151835114610fc35760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604482015268040dad2e6dac2e8c6d60bb1b6064820152608401610290565b600083516001600160401b03811115610fde57610fde6148c1565b604051908082528060200260200182016040528015611007578160200160208202803683370190505b50905060005b84518110156110775761105285828151811061102b5761102b61524e565b60200260200101518583815181106110455761104561524e565b602002602001015161096e565b8282815181106110645761106461524e565b602090810291909101015260010161100d565b509392505050565b6001600160a01b03166000908152606d602052604090205460ff1690565b6110a56123b8565b6110c15760405162461bcd60e51b81526004016102909061528d565b610e908282612675565b60008181526003602052604090206001018054606091906110eb906151fc565b80601f0160208091040260200160405190810160405280929190818152602001828054611117906151fc565b80156111645780601f1061113957610100808354040283529160200191611164565b820191906000526020600020905b81548152906001019060200180831161114757829003601f168201915b50505050509050919050565b600054610100900460ff16158080156111905750600054600160ff909116105b806111b1575061119f306126f9565b1580156111b1575060005460ff166001145b6112145760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610290565b6000805460ff191660011790558015611237576000805461ff0019166101001790555b83517f8502233096d909befbda0999bb8ea2f3a6be3c138b9fbf003752a4c8bce86f6c907f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6907f86d5cf0a6bdc8d859ba3bdc97043337c82a0e609035f378e419298b6a3e00ae6906000906112ad90600161527a565b6001600160401b038111156112c4576112c46148c1565b6040519080825280602002602001820160405280156112ed578160200160208202803683370190505b50905060005b88518110156113485788818151811061130e5761130e61524e565b60200260200101518282815181106113285761132861524e565b6001600160a01b03909216602092830291909101909101526001016112f3565b7f000000000000000000000000000000000000000000000000000000000000000082828151811061137b5761137b61524e565b60200260200101906001600160a01b031690816001600160a01b0316815250506113a482612708565b6113ad8a612740565b6101036113ba8d8261538c565b506101046113c88c8261538c565b506113d28a612770565b6113db8d6123c6565b6113e660008e61260a565b6113f0858e61260a565b6113fa848e61260a565b61140585600061260a565b61141083600061260a565b61141a8888612675565b50506101059290925561010655610107558015611471576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050565b600081815261010a602090815260408083208151815460809481028201850190935260608181018481529095869590949293928492918491908401828280156114e357602002820191906000526020600020905b8154815260200190600101908083116114cf575b5050509183525050600191909101546001600160801b038082166020840152600160801b909104166040909101529050600061152b8560009081526003602052604090205490565b9050806001600160401b03811115611545576115456148c1565b60405190808252806020026020018201604052801561157e57816020015b61156b614722565b8152602001906001900390816115635790505b509350806001600160401b03811115611599576115996148c1565b6040519080825280602002602001820160405280156115c2578160200160208202803683370190505b50925060005b818110156115ff576115da8682610cd0565b8582815181106115ec576115ec61524e565b60209081029190910101526001016115c8565b505051919391925050565b60008281526008602052604081205481805b828110156116ef5760008681526008602090815260408083208484526001019091529020546001600160a01b031615611698578482036116865760008681526008602090815260408083209383526001909301905220546001600160a01b031692506109fe915050565b61169160018361527a565b91506116dd565b6116a38660006118da565b80156116ca5750600086815260086020908152604080832083805260020190915290205481145b156116dd576116da60018361527a565b91505b6116e860018261527a565b905061161c565b50505092915050565b60606000611704611e8b565b905061170f3361107f565b8061172257506001600160a01b03811632145b6117575760405162461bcd60e51b81526004016102909060208082526004908201526321454f4160e01b604082015260600190565b82611762828661096e565b10156117805760405162461bcd60e51b81526004016102909061544b565b600084815261010a6020908152604080832081518154608094810282018501909352606081018381529093919284928491908401828280156117e157602002820191906000526020600020905b8154815260200190600101908083116117cd575b5050509183525050600191909101546001600160801b03808216602080850191909152600160801b9092048116604090930192909252820151919250429116111561185a5760405162461bcd60e51b815260206004820152600960248201526831b0b73a1037b832b760b91b6044820152606401610290565b6000611875868684604001516001600160801b03168561284c565b9050611882838787612bf0565b61188d308483612d7d565b826001600160a01b0316867f58bbfaa763248693d05ac650926341943af86affd998d80e41dbcc9adfdae60787846040516118c9929190615469565b60405180910390a395945050505050565b60009182526006602090815260408084206001600160a01b0393909316845291905290205460ff1690565b61190d6123b8565b6119295760405162461bcd60e51b81526004016102909061528d565b610cbc81612770565b6101048054610a70906151fc565b6119486123b8565b6119645760405162461bcd60e51b81526004016102909061528d565b61196f838383612e9f565b505050565b610e9061197f611e8b565b8383612f47565b600082815260066020908152604080832083805290915281205460ff166119d3575060008281526006602090815260408083206001600160a01b038516845290915290205460ff166109fe565b50600192915050565b600080610106546119ef81610b04611e8b565b6119f7611efe565b600089815261010b602052604090205460ff16611a415760405162461bcd60e51b815260206004820152600860248201526708505b1b1bddd95960c21b6044820152606401610290565b8615801590611a4f57508685145b611a6b5760405162461bcd60e51b815260040161029090615230565b611a75848a61096e565b600003611a945760405162461bcd60e51b81526004016102909061544b565b611aa26101075460006118da565b611ade5760005b87811015611adc57611aca610107548a8a84818110610b7157610b7161524e565b611ad560018261527a565b9050611aa9565b505b600061010a60008b815260200190815260200160002060010160109054906101000a90046001600160801b03166001600160801b03169050611b3689898989604051806020016040528060008152508f876001611f95565b60008b81526101096020526040902054909350611b5490849061527a565b9350611b71858b856040518060200160405280600081525061229a565b897fdf54045461e7fa6cda88afd9b979d29bb9ef67b8271562cec9a7a95ddc3afe728685604051611ba3929190614b86565b60405180910390a250611bb66001600955565b50965096945050505050565b6060816001600160401b03811115611bdc57611bdc6148c1565b604051908082528060200260200182016040528015611c0f57816020015b6060815260200190600190039081611bfa5790505b5090506000611c1c611e8b565b9050336001600160a01b038216141560005b848110156116ef578115611cad57611c8b30878784818110611c5257611c5261524e565b9050602002810190611c649190615482565b86604051602001611c77939291906154c8565b60405160208183030381529060405261301f565b848281518110611c9d57611c9d61524e565b6020026020010181905250611d2d565b611d0f30878784818110611cc357611cc361524e565b9050602002810190611cd59190615482565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061301f92505050565b848281518110611d2157611d2161524e565b60200260200101819052505b600101611c2e565b600081815260086020526040812054815b81811015611d995760008481526008602090815260408083208484526001019091529020546001600160a01b031615611d8757611d8460018461527a565b92505b611d9260018261527a565b9050611d46565b50611da58360006118da565b15611db857611db560018361527a565b91505b50919050565b600082815260076020526040902054610ee99033611f57565b60018054610a70906151fc565b611dec611e8b565b6001600160a01b0316856001600160a01b03161480611e125750611e12856108f4611e8b565b611e2e5760405162461bcd60e51b8152600401610290906152f6565b610df3858585858561304b565b60006001600160e01b03198216636cdb3d1360e11b1480611e6c57506001600160e01b031982166303a24d0760e21b145b806109fe57506301ffc9a760e01b6001600160e01b03198316146109fe565b6000611e95613180565b905090565b611ea48282611986565b610e9057611ebc816001600160a01b031660146131a5565b611ec78360206131a5565b604051602001611ed89291906154e9565b60408051601f198184030181529082905262461bcd60e51b82526102909160040161481f565b600260095403611f505760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610290565b6002600955565b60008281526006602090815260408083206001600160a01b038516845290915290205460ff16610e9057611ebc816001600160a01b031660146131a5565b60008060005b8981101561216e578a8a82818110611fb557611fb561524e565b90506080020160600135600003611ff65760405162461bcd60e51b81526020600482015260056024820152640c08185b5d60da1b6044820152606401610290565b8888828181106120085761200861524e565b905060200201358b8b838181106120215761202161524e565b905060800201606001356120359190615556565b156120525760405162461bcd60e51b81526004016102909061556a565b60018b8b838181106120665761206661524e565b905060800201602001602081019061207e9190615593565b600281111561208f5761208f614b18565b1415806120b757508a8a828181106120a9576120a961524e565b905060800201606001356001145b6120d35760405162461bcd60e51b81526004016102909061556a565b8888828181106120e5576120e561524e565b90506020020135826120f7919061527a565b600087815261010a6020526040902090925089898381811061211b5761211b61524e565b905060200201358c8c848181106121345761213461524e565b9050608002016060013561214891906152e2565b815460018181018455600093845260209093200155612167908261527a565b9050611f9b565b506121798482615556565b156121af5760405162461bcd60e51b81526004016102909060208082526004908201526308505b5d60e21b604082015260600190565b6121b984826152e2565b915082156122795760005b8981101561220f576121fd8b8b838181106121e1576121e161524e565b9050608002018036038101906121f791906155b0565b87613340565b61220860018261527a565b90506121c4565b5061227461221b611e8b565b308c8c808060200260200160405190810160405280939291908181526020016000905b8282101561226a5761225b608083028601368190038101906155b0565b8152602001906001019061223e565b5050505050612d7d565b61228d565b61228d612284611e8b565b8b8b8989613405565b5098975050505050505050565b6001600160a01b0384166122fa5760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b6064820152608401610290565b6000612304611e8b565b905060006123118561346d565b9050600061231e8561346d565b905061232f836000898585896134b8565b600086815260d1602090815260408083206001600160a01b038b1684529091528120805487929061236190849061527a565b909155505060408051878152602081018790526001600160a01b03808a169260009291871691600080516020615a50833981519152910160405180910390a46123af8360008989898961370e565b50505050505050565b6000611e958161067c611e8b565b600280546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d7690600090a35050565b815183511461247a5760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206044820152670dad2e6dac2e8c6d60c31b6064820152608401610290565b6001600160a01b0384166124a05760405162461bcd60e51b815260040161029090615624565b60006124aa611e8b565b90506124ba8187878787876134b8565b60005b845181101561259c5760008582815181106124da576124da61524e565b6020026020010151905060008583815181106124f8576124f861524e565b602090810291909101810151600084815260d1835260408082206001600160a01b038e1683529093529190912054909150818110156125495760405162461bcd60e51b815260040161029090615669565b600083815260d1602090815260408083206001600160a01b038e8116855292528083208585039055908b1682528120805484929061258890849061527a565b9091555050600190930192506124bd915050565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb87876040516125ec9291906156b3565b60405180910390a4612602818787878787613870565b505050505050565b6126148282613932565b610e90828261398d565b61262882826139fa565b60008281526008602090815260408083206001600160a01b03851680855260028201808552838620805487526001909301855292852080546001600160a01b031916905584529152555050565b6127108111156126975760405162461bcd60e51b8152600401610290906156c6565b600480546001600160a01b0384166001600160b01b03199091168117600160a01b61ffff851602179091556040518281527f90d7ec04bcb8978719414f82e52e4cb651db41d0e6f8cea6118c2191e6183adb9060200160405180910390a25050565b6001600160a01b03163b151590565b600054610100900460ff1661272f5760405162461bcd60e51b8152600401610290906156ef565b612737613a5c565b610cbc81613a85565b600054610100900460ff166127675760405162461bcd60e51b8152600401610290906156ef565b610cbc81613b0a565b60006001805461277f906151fc565b80601f01602080910402602001604051908101604052809291908181526020018280546127ab906151fc565b80156127f85780601f106127cd576101008083540402835291602001916127f8565b820191906000526020600020905b8154815290600101906020018083116127db57829003601f168201915b50505050509050816001908161280e919061538c565b507fc9c7c3fe08b88b4df9d4d47ef47d2c43d55c025a0ba88ca442580ed9e7348a16818360405161284092919061573a565b60405180910390a15050565b6060600061285a84866152b5565b9050806001600160401b03811115612874576128746148c1565b6040519080825280602002602001820160405280156128ad57816020015b61289a614722565b8152602001906001900390816128925790505b5060008781526101096020526040812054919350906128cd9086906152b5565b6000888152600360205260408120549192506128e7613b3a565b905060006128f48a61147b565b5090506000836001600160401b03811115612911576129116148c1565b60405190808252806020026020018201604052801561293a578160200160208202803683370190505b50905060005b86811015612b8a5760408051602080820187905281830184905282518083038401815260609092019092528051910120600061297c8883615556565b90506000805b88811015612b7b5760008d6000015182815181106129a2576129a261524e565b602002602001015190506000818984815181106129c1576129c161524e565b6020026020010151606001516129d791906152e2565b90506129e3818561527a565b851015612b6557818984815181106129fd576129fd61524e565b6020026020010151606001818151612a15919061575f565b9052508751600190899085908110612a2f57612a2f61524e565b602002602001019015159081151581525050888381518110612a5357612a5361524e565b6020026020010151600001518e8881518110612a7157612a7161524e565b60209081029190910101516001600160a01b0390911690528851899084908110612a9d57612a9d61524e565b6020026020010151602001518e8881518110612abb57612abb61524e565b6020026020010151602001906002811115612ad857612ad8614b18565b90816002811115612aeb57612aeb614b18565b81525050888381518110612b0157612b0161524e565b6020026020010151604001518e8881518110612b1f57612b1f61524e565b60200260200101516040018181525050818e8881518110612b4257612b4261524e565b602090810291909101015160600152612b5c60018d61575f565b9b505050612b7b565b612b6f818561527a565b93505050600101612982565b50836001019350505050612940565b5060005b84811015612be157818181518110612ba857612ba861524e565b602002602001015115612bd957612bd9838281518110612bca57612bca61524e565b60200260200101518d83613b94565b600101612b8e565b50505050505050949350505050565b6001600160a01b038316612c525760405162461bcd60e51b815260206004820152602360248201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260448201526265737360e81b6064820152608401610290565b6000612c5c611e8b565b90506000612c698461346d565b90506000612c768461346d565b9050612c96838760008585604051806020016040528060008152506134b8565b600085815260d1602090815260408083206001600160a01b038a16845290915290205484811015612d155760405162461bcd60e51b8152602060048201526024808201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604482015263616e636560e01b6064820152608401610290565b600086815260d1602090815260408083206001600160a01b038b81168086529184528285208a8703905582518b81529384018a9052909290881691600080516020615a50833981519152910160405180910390a46040805160208101909152600090526123af565b6000805b8251811015612e4f5773eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b0316838281518110612dba57612dba61524e565b6020026020010151600001516001600160a01b0316148015612de457506001600160a01b03841630145b15612e1957828181518110612dfb57612dfb61524e565b60200260200101516060015182612e12919061527a565b9150612e3d565b612e3d8585858481518110612e3057612e3061524e565b6020026020010151613c72565b612e4860018261527a565b9050612d81565b508015612e99576040805160808101825273eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee81526000602082018190529181019190915260608101829052610df3858583613c72565b50505050565b612710811115612ec15760405162461bcd60e51b8152600401610290906156c6565b6040805180820182526001600160a01b038481168083526020808401868152600089815260058352869020945185546001600160a01b031916941693909317845591516001909301929092559151838152909185917f7365cf4122f072a3365c20d54eff9b38d73c096c28e1892ec8f5b0e403a0f12d91015b60405180910390a3505050565b816001600160a01b0316836001600160a01b031603612fba5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604482015268103337b91039b2b63360b91b6064820152608401610290565b6001600160a01b03838116600081815260d26020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c319101612f3a565b60606130448383604051806060016040528060278152602001615a7060279139613dc3565b9392505050565b6001600160a01b0384166130715760405162461bcd60e51b815260040161029090615624565b600061307b611e8b565b905060006130888561346d565b905060006130958561346d565b90506130a58389898585896134b8565b600086815260d1602090815260408083206001600160a01b038c168452909152902054858110156130e85760405162461bcd60e51b815260040161029090615669565b600087815260d1602090815260408083206001600160a01b038d8116855292528083208985039055908a1682528120805488929061312790849061527a565b909155505060408051888152602081018890526001600160a01b03808b16928c82169291881691600080516020615a50833981519152910160405180910390a4613175848a8a8a8a8a61370e565b505050505050505050565b600061318b3361107f565b1561319d575060131936013560601c90565b503390565b90565b606060006131b48360026152b5565b6131bf90600261527a565b6001600160401b038111156131d6576131d66148c1565b6040519080825280601f01601f191660200182016040528015613200576020820181803683370190505b509050600360fc1b8160008151811061321b5761321b61524e565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061324a5761324a61524e565b60200101906001600160f81b031916908160001a905350600061326e8460026152b5565b61327990600161527a565b90505b60018111156132f1576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106132ad576132ad61524e565b1a60f81b8282815181106132c3576132c361524e565b60200101906001600160f81b031916908160001a90535060049490941c936132ea81615772565b905061327c565b5083156130445760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610290565b61334982613e3b565b600081815260036020908152604080832080548085526002918201845291909320855181546001600160a01b039091166001600160a01b0319821681178355938701519294879492939284926001600160a81b0319161790600160a01b9084908111156133b8576133b8614b18565b0217905550604082015181600101556060820151816002015590505060016003600084815260200190815260200160002060000160008282546133fb919061527a565b9091555050505050565b6134108484836140f6565b61341a828261421f565b610df385308686808060200260200160405190810160405280939291908181526020016000905b8282101561226a5761345e608083028601368190038101906155b0565b81526020019060010190613441565b604080516001808252818301909252606091600091906020808301908036833701905050905082816000815181106134a7576134a761524e565b602090810291909101015292915050565b6134c66101055460006118da565b1580156134db57506001600160a01b03851615155b80156134ef57506001600160a01b03841615155b156135515761350161010554866118da565b80613514575061351461010554856118da565b6135515760405162461bcd60e51b815260206004820152600e60248201526d215452414e534645525f524f4c4560901b6044820152606401610290565b6001600160a01b0385166135d45760005b83518110156135ce5782818151811061357d5761357d61524e565b6020026020010151610109600086848151811061359c5761359c61524e565b6020026020010151815260200190815260200160002060008282546135c1919061527a565b9091555050600101613562565b50613691565b60005b835181101561368f5761010b60008583815181106135f7576135f761524e565b60209081029190910181015182528101919091526040016000205460ff16801561363b575082818151811061362e5761362e61524e565b6020026020010151600014155b1561368757600061010b60008684815181106136595761365961524e565b6020026020010151815260200190815260200160002060006101000a81548160ff0219169083151502179055505b6001016135d7565b505b6001600160a01b0384166126025760005b83518110156123af578281815181106136bd576136bd61524e565b602002602001015161010960008684815181106136dc576136dc61524e565b602002602001015181526020019081526020016000206000828254613701919061575f565b90915550506001016136a2565b613720846001600160a01b03166126f9565b156126025760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e61906137599089908990889088908890600401615789565b6020604051808303816000875af1925050508015613794575060408051601f3d908101601f19168201909252613791918101906157c3565b60015b613840576137a06157e0565b806308c379a0036137d957506137b46157fb565b806137bf57506137db565b8060405162461bcd60e51b8152600401610290919061481f565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e2d455243313135356044820152732932b1b2b4bb32b91034b6b83632b6b2b73a32b960611b6064820152608401610290565b6001600160e01b0319811663f23a6e6160e01b146123af5760405162461bcd60e51b815260040161029090615884565b613882846001600160a01b03166126f9565b156126025760405163bc197c8160e01b81526001600160a01b0385169063bc197c81906138bb90899089908890889088906004016158cc565b6020604051808303816000875af19250505080156138f6575060408051601f3d908101601f191682019092526138f3918101906157c3565b60015b613902576137a06157e0565b6001600160e01b0319811663bc197c8160e01b146123af5760405162461bcd60e51b815260040161029090615884565b60008281526006602090815260408083206001600160a01b0385168085529252808320805460ff1916600117905551339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b6000828152600860205260408120805491600191906139ac838561527a565b9091555050600092835260086020908152604080852083865260018101835281862080546001600160a01b039096166001600160a01b03199096168617905593855260029093019052912055565b613a048282611f57565b60008281526006602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600054610100900460ff16613a835760405162461bcd60e51b8152600401610290906156ef565b565b600054610100900460ff16613aac5760405162461bcd60e51b8152600401610290906156ef565b60005b8151811015610e90576001606d6000848481518110613ad057613ad061524e565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055600101613aaf565b600054610100900460ff16613b315760405162461bcd60e51b8152600401610290906156ef565b610cbc8161423a565b6000613b44611e8b565b613b4f60014361575f565b60405160609290921b6001600160601b03191660208301524060348201524460548201526074016040516020818303038152906040528051906020012060001c905090565b6000828152600360205260409020548110613bdd5760405162461bcd60e51b8152602060048201526009602482015268696e64657820444e4560b81b6044820152606401610290565b613be683613e3b565b6000828152600360209081526040808320848452600290810183529220855181546001600160a01b039091166001600160a01b03198216811783559287015187949293909284926001600160a81b03191690911790600160a01b908490811115613c5257613c52614b18565b021790555060408201516001820155606090910151600290910155505050565b600081602001516002811115613c8a57613c8a614b18565b03613cc45761196f8160000151848484606001517f0000000000000000000000000000000000000000000000000000000000000000614246565b600181602001516002811115613cdc57613cdc614b18565b03613d455780516040808301519051632142170760e11b81526001600160a01b03909216916342842e0e91613d17918791879160040161592a565b600060405180830381600087803b158015613d3157600080fd5b505af11580156123af573d6000803e3d6000fd5b600281602001516002811115613d5d57613d5d614b18565b0361196f57805160408083015160608401519151637921219560e11b81526001600160a01b03878116600483015286811660248301526044820192909252606481019290925260a06084830152600060a48301529091169063f242432a9060c401613d17565b6060600080856001600160a01b031685604051613de0919061594e565b600060405180830381855af49150503d8060008114613e1b576040519150601f19603f3d011682016040523d82523d6000602084013e613e20565b606091505b5091509150613e31868383876143b0565b9695505050505050565b600181602001516002811115613e5357613e53614b18565b03613efd5780516040516301ffc9a760e01b81526001600160a01b03909116906301ffc9a790613e8b906380ac58cd9060040161596a565b602060405180830381865afa925050508015613ec4575060408051601f3d908101601f19168201909252613ec191810190615982565b60015b613ee05760405162461bcd60e51b81526004016102909061599f565b80610e905760405162461bcd60e51b81526004016102909061599f565b600281602001516002811115613f1557613f15614b18565b03613f4d5780516040516301ffc9a760e01b81526001600160a01b03909116906301ffc9a790613e8b9063d9b67a269060040161596a565b600081602001516002811115613f6557613f65614b18565b03610cbc5780516001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14610cbc5780516040516301ffc9a760e01b81526001600160a01b03909116906301ffc9a790613fc2906380ac58cd9060040161596a565b602060405180830381865afa925050508015613ffb575060408051601f3d908101601f19168201909252613ff891810190615982565b60015b614024576140076157e0565b806308c379a003610e90575061401b6157fb565b80610e90575050565b80156140425760405162461bcd60e51b81526004016102909061599f565b81516040516301ffc9a760e01b81526001600160a01b03909116906301ffc9a7906140759063d9b67a269060040161596a565b602060405180830381865afa9250505080156140ae575060408051601f3d908101601f191682019092526140ab91810190615982565b60015b6140d8576140ba6157e0565b806308c379a00361196f57506140ce6157fb565b8061196f57505050565b801561196f5760405162461bcd60e51b81526004016102909061599f565b818061412e5760405162461bcd60e51b815260206004820152600760248201526621546f6b656e7360c81b6044820152606401610290565b600082815260036020526040902054156141765760405162461bcd60e51b815260206004820152600960248201526869642065786973747360b81b6044820152606401610290565b60005b8181101561420a576141b18585838181106141965761419661524e565b9050608002018036038101906141ac91906155b0565b613e3b565b8484828181106141c3576141c361524e565b600086815260036020908152604080832087845260020190915290206080909102929092019190506141f582826159c3565b50614203905060018261527a565b9050614179565b50600091825260036020526040909120555050565b600081815260036020526040902060010161196f838261538c565b60d3610e90828261538c565b8115610df35773eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed196001600160a01b038616016143a457306001600160a01b038516036142eb57604051632e1a7d4d60e01b8152600481018390526001600160a01b03821690632e1a7d4d90602401600060405180830381600087803b1580156142c357600080fd5b505af11580156142d7573d6000803e3d6000fd5b505050506142e6838383614427565b610df3565b306001600160a01b03841603614399573482146143405760405162461bcd60e51b81526020600482015260136024820152721b5cd9cb9d985b1d5948084f48185b5bdd5b9d606a1b6044820152606401610290565b806001600160a01b031663d0e30db0836040518263ffffffff1660e01b81526004016000604051808303818588803b15801561437b57600080fd5b505af115801561438f573d6000803e3d6000fd5b5050505050610df3565b6142e6838383614427565b610df3858585856144ec565b6060831561441d578251600003614416576143ca856126f9565b6144165760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610290565b5081610cc8565b610cc88383614544565b6000836001600160a01b03168360405160006040518083038185875af1925050503d8060008114614474576040519150601f19603f3d011682016040523d82523d6000602084013e614479565b606091505b5050905080612e9957816001600160a01b031663d0e30db0846040518263ffffffff1660e01b81526004016000604051808303818588803b1580156144bd57600080fd5b505af11580156144d1573d6000803e3d6000fd5b50612e99935050506001600160a01b03841690508585614554565b816001600160a01b0316836001600160a01b03160315612e9957306001600160a01b0384160361452f5761452a6001600160a01b0385168383614554565b612e99565b612e996001600160a01b0385168484846145aa565b8151156137bf5781518083602001fd5b61196f8363a9059cbb60e01b8484604051602401614573929190614b86565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526145cb565b612e99846323b872dd60e01b8585856040516024016145739392919061592a565b6000614620826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661469d9092919063ffffffff16565b80519091501561196f578080602001905181019061463e9190615982565b61196f5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610290565b6060610cc8848460008585600080866001600160a01b031685876040516146c4919061594e565b60006040518083038185875af1925050503d8060008114614701576040519150601f19603f3d011682016040523d82523d6000602084013e614706565b606091505b5091509150614717878383876143b0565b979650505050505050565b604080516080810190915260008082526020820190815260200160008152602001600081525090565b6001600160a01b0381168114610cbc57600080fd5b803561476b8161474b565b919050565b6000806040838503121561478357600080fd5b823561478e8161474b565b946020939093013593505050565b6001600160e01b031981168114610cbc57600080fd5b6000602082840312156147c457600080fd5b81356130448161479c565b60005b838110156147ea5781810151838201526020016147d2565b50506000910152565b6000815180845261480b8160208601602086016147cf565b601f01601f19169290920160200192915050565b60208152600061304460208301846147f3565b60008083601f84011261484457600080fd5b5081356001600160401b0381111561485b57600080fd5b6020830191508360208260071b850101111561487657600080fd5b9250929050565b60008083601f84011261488f57600080fd5b5081356001600160401b038111156148a657600080fd5b6020830191508360208260051b850101111561487657600080fd5b634e487b7160e01b600052604160045260246000fd5b601f8201601f191681016001600160401b03811182821017156148fc576148fc6148c1565b6040525050565b600082601f83011261491457600080fd5b81356001600160401b0381111561492d5761492d6148c1565b604051614944601f8301601f1916602001826148d7565b81815284602083860101111561495957600080fd5b816020850160208301376000918101602001919091529392505050565b80356001600160801b038116811461476b57600080fd5b60008060008060008060008060c0898b0312156149a957600080fd5b88356001600160401b03808211156149c057600080fd5b6149cc8c838d01614832565b909a50985060208b01359150808211156149e557600080fd5b6149f18c838d0161487d565b909850965060408b0135915080821115614a0a57600080fd5b50614a178b828c01614903565b945050614a2660608a01614976565b9250614a3460808a01614976565b915060a0890135614a448161474b565b809150509295985092959890939650565b600060208284031215614a6757600080fd5b5035919050565b600060208284031215614a8057600080fd5b81356130448161474b565b60008060008060808587031215614aa157600080fd5b8435614aac8161474b565b93506020850135614abc8161474b565b92506040850135915060608501356001600160401b03811115614ade57600080fd5b614aea87828801614903565b91505092959194509250565b60008060408385031215614b0957600080fd5b50508035926020909101359150565b634e487b7160e01b600052602160045260246000fd5b80516001600160a01b03168252602081015160038110614b5e57634e487b7160e01b600052602160045260246000fd5b602083015260408181015190830152606090810151910152565b608081016109fe8284614b2e565b6001600160a01b03929092168252602082015260400190565b60006001600160401b03821115614bb857614bb86148c1565b5060051b60200190565b600082601f830112614bd357600080fd5b81356020614be082614b9f565b604051614bed82826148d7565b80915083815260208101915060208460051b870101935086841115614c1157600080fd5b602086015b84811015614c2d5780358352918301918301614c16565b509695505050505050565b600080600080600060a08688031215614c5057600080fd5b8535614c5b8161474b565b94506020860135614c6b8161474b565b935060408601356001600160401b0380821115614c8757600080fd5b614c9389838a01614bc2565b94506060880135915080821115614ca957600080fd5b614cb589838a01614bc2565b93506080880135915080821115614ccb57600080fd5b50614cd888828901614903565b9150509295509295909350565b60008060408385031215614cf857600080fd5b823591506020830135614d0a8161474b565b809150509250929050565b600082601f830112614d2657600080fd5b81356020614d3382614b9f565b604051614d4082826148d7565b80915083815260208101915060208460051b870101935086841115614d6457600080fd5b602086015b84811015614c2d578035614d7c8161474b565b8352918301918301614d69565b60008060408385031215614d9c57600080fd5b82356001600160401b0380821115614db357600080fd5b614dbf86838701614d15565b93506020850135915080821115614dd557600080fd5b50614de285828601614bc2565b9150509250929050565b60008151808452602080850194506020840160005b83811015614e1d57815187529582019590820190600101614e01565b509495945050505050565b6020815260006130446020830184614dec565b600080600080600080600060e0888a031215614e5657600080fd5b614e5f88614760565b965060208801356001600160401b0380821115614e7b57600080fd5b614e878b838c01614903565b975060408a0135915080821115614e9d57600080fd5b614ea98b838c01614903565b965060608a0135915080821115614ebf57600080fd5b614ecb8b838c01614903565b955060808a0135915080821115614ee157600080fd5b50614eee8a828b01614d15565b935050614efd60a08901614760565b915060c0880135905092959891949750929550565b60008151808452602080850194506020840160005b83811015614e1d57614f3a878351614b2e565b6080969096019590820190600101614f27565b604081526000614f606040830185614f12565b8281036020840152614f728185614dec565b95945050505050565b6020815260006130446020830184614f12565b600060208284031215614fa057600080fd5b81356001600160401b03811115614fb657600080fd5b610cc884828501614903565b600080600060608486031215614fd757600080fd5b833592506020840135614fe98161474b565b929592945050506040919091013590565b8015158114610cbc57600080fd5b6000806040838503121561501b57600080fd5b82356150268161474b565b91506020830135614d0a81614ffa565b6000806000806000806080878903121561504f57600080fd5b8635955060208701356001600160401b038082111561506d57600080fd5b6150798a838b01614832565b9097509550604089013591508082111561509257600080fd5b5061509f89828a0161487d565b90945092505060608701356150b38161474b565b809150509295509295509295565b600080602083850312156150d457600080fd5b82356001600160401b038111156150ea57600080fd5b6150f68582860161487d565b90969095509350505050565b600060208083016020845280855180835260408601915060408160051b87010192506020870160005b8281101561515957603f198886030184526151478583516147f3565b9450928501929085019060010161512b565b5092979650505050505050565b6000806040838503121561517957600080fd5b82356151848161474b565b91506020830135614d0a8161474b565b600080600080600060a086880312156151ac57600080fd5b85356151b78161474b565b945060208601356151c78161474b565b9350604086013592506060860135915060808601356001600160401b038111156151f057600080fd5b614cd888828901614903565b600181811c9082168061521057607f821691505b602082108103611db857634e487b7160e01b600052602260045260246000fd5b60208082526004908201526310a632b760e11b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b808201808211156109fe576109fe615264565b6020808252600e908201526d139bdd08185d5d1a1bdc9a5e995960921b604082015260600190565b80820281158282048414176109fe576109fe615264565b634e487b7160e01b600052601260045260246000fd5b6000826152f1576152f16152cc565b500490565b6020808252602e908201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60408201526d195c881bdc88185c1c1c9bdd995960921b606082015260800190565b601f82111561196f576000816000526020600020601f850160051c8101602086101561536d5750805b601f850160051c820191505b8181101561260257828155600101615379565b81516001600160401b038111156153a5576153a56148c1565b6153b9816153b384546151fc565b84615344565b602080601f8311600181146153ee57600084156153d65750858301515b600019600386901b1c1916600185901b178555612602565b600085815260208120601f198616915b8281101561541d578886015182559484019460019091019084016153fe565b508582101561543b5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6020808252600490820152630850985b60e21b604082015260600190565b828152604060208201526000610cc86040830184614f12565b6000808335601e1984360301811261549957600080fd5b8301803591506001600160401b038211156154b357600080fd5b60200191503681900382131561487657600080fd5b8284823760609190911b6001600160601b0319169101908152601401919050565b7402832b936b4b9b9b4b7b7399d1030b1b1b7bab73a1605d1b8152600083516155198160158501602088016147cf565b7001034b99036b4b9b9b4b733903937b6329607d1b601591840191820152835161554a8160268401602088016147cf565b01602601949350505050565b600082615565576155656152cc565b500690565b60208082526002908201526110a960f11b604082015260600190565b60038110610cbc57600080fd5b6000602082840312156155a557600080fd5b813561304481615586565b6000608082840312156155c257600080fd5b604051608081018181106001600160401b03821117156155e4576155e46148c1565b60405282356155f28161474b565b8152602083013561560281615586565b6020820152604083810135908201526060928301359281019290925250919050565b60208082526025908201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201526939103a3930b739b332b960b11b606082015260800190565b604081526000614f606040830185614dec565b6020808252600f908201526e45786365656473206d61782062707360881b604082015260600190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60408152600061574d60408301856147f3565b8281036020840152614f7281856147f3565b818103818111156109fe576109fe615264565b60008161578157615781615264565b506000190190565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090614717908301846147f3565b6000602082840312156157d557600080fd5b81516130448161479c565b600060033d11156131a25760046000803e5060005160e01c90565b600060443d10156158095790565b6040516003193d81016004833e81513d6001600160401b03816024840111818411171561583857505050505090565b82850191508151818111156158505750505050505090565b843d870101602082850101111561586a5750505050505090565b615879602082860101876148d7565b509095945050505050565b60208082526028908201527f455243313135353a204552433131353552656365697665722072656a656374656040820152676420746f6b656e7360c01b606082015260800190565b6001600160a01b0386811682528516602082015260a0604082018190526000906158f890830186614dec565b828103606084015261590a8186614dec565b9050828103608084015261591e81856147f3565b98975050505050505050565b6001600160a01b039384168152919092166020820152604081019190915260600190565b600082516159608184602087016147cf565b9190910192915050565b60e09190911b6001600160e01b031916815260200190565b60006020828403121561599457600080fd5b815161304481614ffa565b6020808252600a908201526921546f6b656e5479706560b01b604082015260600190565b81356159ce8161474b565b81546001600160a01b031981166001600160a01b0392909216918217835560208401356159fa81615586565b60038110615a1857634e487b7160e01b600052602160045260246000fd5b6001600160a81b03199190911690911760a09190911b60ff60a01b161781556040820135600182015560609091013560029091015556fec3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220624bfa16497cb79925ddcc3ac7118eeba77c46f910f49c549da187e74fd7cb8e64736f6c63430008170033000000000000000000000000d23e77b7e1726577006799b7194b6ae31958a8390000000000000000000000000000000000000000000000000000000000000000
Deployed ByteCode
0x6080604052600436106102205760003560e01c8063914e126a1161011f578063914e126a1461063457806391d1485414610661578063938e3d7b1461068157806395d89b41146106a15780639bcf7a15146106b6578063a0a8e460146106d6578063a217fddf146106f2578063a22cb46514610707578063a32fa5b314610727578063a96b143814610747578063ac9650d81461075a578063b0381b0814610787578063b24f2d39146107b8578063bc197c81146107e3578063bd85b0391461080f578063ca15c8731461083d578063cb2ef6f71461085d578063d0d2fe2514610877578063d547741f146108a4578063e8a3d485146108c4578063e985e9c5146108d9578063f23a6e6114610922578063f242432a1461094e57600080fd5b8062fdd58e146102a057806301ffc9a7146102d357806306fdde0314610303578063092e6075146103255780630e89341c1461034d57806313af40351461036d578063150b7a021461038d5780631da799c9146103c6578063248a9ca3146103f35780632a55205a146104205780632eb2c2d61461044e5780632f2ff15d1461046e57806336568abe1461048e5780633b1475a7146104ae5780634cc157df146104c55780634e1273f414610507578063572b6c0514610534578063600dd5ea1461055457806361195e9414610574578063754b8fe7146105945780638d4c446a146105b45780638da5cb5b146105e25780639010d07c1461061457600080fd5b3661029b57336001600160a01b037f000000000000000000000000d23e77b7e1726577006799b7194b6ae31958a83916146102995760405162461bcd60e51b815260206004820152601460248201527310b730ba34bb32aa37b5b2b72bb930b83832b91760611b60448201526064015b60405180910390fd5b005b600080fd5b3480156102ac57600080fd5b506102c06102bb366004614770565b61096e565b6040519081526020015b60405180910390f35b3480156102df57600080fd5b506102f36102ee3660046147b2565b610a04565b60405190151581526020016102ca565b34801561030f57600080fd5b50610318610a62565b6040516102ca919061481f565b61033861033336600461498d565b610af1565b604080519283526020830191909152016102ca565b34801561035957600080fd5b50610318610368366004614a55565b610c84565b34801561037957600080fd5b50610299610388366004614a6e565b610c8f565b34801561039957600080fd5b506103ad6103a8366004614a8b565b610cbf565b6040516001600160e01b031990911681526020016102ca565b3480156103d257600080fd5b506103e66103e1366004614af6565b610cd0565b6040516102ca9190614b78565b3480156103ff57600080fd5b506102c061040e366004614a55565b60009081526007602052604090205490565b34801561042c57600080fd5b5061044061043b366004614af6565b610d5f565b6040516102ca929190614b86565b34801561045a57600080fd5b50610299610469366004614c38565b610d9c565b34801561047a57600080fd5b50610299610489366004614ce5565b610dfa565b34801561049a57600080fd5b506102996104a9366004614ce5565b610e94565b3480156104ba57600080fd5b506102c06101085481565b3480156104d157600080fd5b506104e56104e0366004614a55565b610ef3565b604080516001600160a01b03909316835261ffff9091166020830152016102ca565b34801561051357600080fd5b50610527610522366004614d89565b610f5e565b6040516102ca9190614e28565b34801561054057600080fd5b506102f361054f366004614a6e565b61107f565b34801561056057600080fd5b5061029961056f366004614770565b61109d565b34801561058057600080fd5b5061031861058f366004614a55565b6110cb565b3480156105a057600080fd5b506102996105af366004614e3b565b611170565b3480156105c057600080fd5b506105d46105cf366004614a55565b61147b565b6040516102ca929190614f4d565b3480156105ee57600080fd5b506002546001600160a01b03165b6040516001600160a01b0390911681526020016102ca565b34801561062057600080fd5b506105fc61062f366004614af6565b61160a565b34801561064057600080fd5b5061065461064f366004614af6565b6116f8565b6040516102ca9190614f7b565b34801561066d57600080fd5b506102f361067c366004614ce5565b6118da565b34801561068d57600080fd5b5061029961069c366004614f8e565b611905565b3480156106ad57600080fd5b50610318611932565b3480156106c257600080fd5b506102996106d1366004614fc2565b611940565b3480156106e257600080fd5b50604051600281526020016102ca565b3480156106fe57600080fd5b506102c0600081565b34801561071357600080fd5b50610299610722366004615008565b611974565b34801561073357600080fd5b506102f3610742366004614ce5565b611986565b610338610755366004615036565b6119dc565b34801561076657600080fd5b5061077a6107753660046150c1565b611bc2565b6040516102ca9190615102565b34801561079357600080fd5b506102f36107a2366004614a55565b61010b6020526000908152604090205460ff1681565b3480156107c457600080fd5b506004546001600160a01b03811690600160a01b900461ffff166104e5565b3480156107ef57600080fd5b506103ad6107fe366004614c38565b63bc197c8160e01b95945050505050565b34801561081b57600080fd5b506102c061082a366004614a55565b6101096020526000908152604090205481565b34801561084957600080fd5b506102c0610858366004614a55565b611d35565b34801561086957600080fd5b50635061636b60e01b6102c0565b34801561088357600080fd5b506102c0610892366004614a55565b60009081526003602052604090205490565b3480156108b057600080fd5b506102996108bf366004614ce5565b611dbe565b3480156108d057600080fd5b50610318611dd7565b3480156108e557600080fd5b506102f36108f4366004615166565b6001600160a01b03918216600090815260d26020908152604080832093909416825291909152205460ff1690565b34801561092e57600080fd5b506103ad61093d366004615194565b63f23a6e6160e01b95945050505050565b34801561095a57600080fd5b50610299610969366004615194565b611de4565b60006001600160a01b0383166109d95760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a2061646472657373207a65726f206973206e6f742061207660448201526930b634b21037bbb732b960b11b6064820152608401610290565b50600081815260d1602090815260408083206001600160a01b03861684529091529020545b92915050565b6000610a0f82611e3b565b80610a2a575063152a902d60e11b6001600160e01b03198316145b80610a455750630a85bd0160e11b6001600160e01b03198316145b806109fe5750506001600160e01b031916630271189760e51b1490565b6101038054610a70906151fc565b80601f0160208091040260200160405190810160405280929190818152602001828054610a9c906151fc565b8015610ae95780601f10610abe57610100808354040283529160200191610ae9565b820191906000526020600020905b815481529060010190602001808311610acc57829003601f168201915b505050505081565b60008061010654610b0981610b04611e8b565b611e9a565b610b11611efe565b8915801590610b1f57508988145b610b3b5760405162461bcd60e51b815260040161029090615230565b610b496101075460006118da565b610ba05760005b8a811015610b9e57610b8c610107548d8d84818110610b7157610b7161524e565b610b879260206080909202019081019150614a6e565b611f57565b610b9760018261527a565b9050610b50565b505b610108805493506001906000610bb6838761527a565b90915550610bd690508b8b8b8b8b886001600160801b038c166000611f95565b600084815261010a602090815260408083206001600160801b038a8116600160801b02908c161760019182015561010b8352818420805460ff1916909117905580519182019052908152909250610c329085908590859061229a565b827f529034575398e71312a0b7b951d8ca42dce1529d774f4a255a587f64f649fff88584604051610c64929190614b86565b60405180910390a2610c766001600955565b509850989650505050505050565b60606109fe826110cb565b610c976123b8565b610cb35760405162461bcd60e51b81526004016102909061528d565b610cbc816123c6565b50565b630a85bd0160e11b5b949350505050565b610cd8614722565b6000838152600360209081526040808320858452600290810183529281902081516080810190925280546001600160a01b038116835291939092840191600160a01b900460ff1690811115610d2f57610d2f614b18565b6002811115610d4057610d40614b18565b8152600182015460208201526002909101546040909101529392505050565b600080600080610d6e86610ef3565b90945084925061ffff169050612710610d8782876152b5565b610d9191906152e2565b925050509250929050565b610da4611e8b565b6001600160a01b0316856001600160a01b03161480610dca5750610dca856108f4611e8b565b610de65760405162461bcd60e51b8152600401610290906152f6565b610df38585858585612418565b5050505050565b600082815260076020526040902054610e139033611f57565b60008281526006602090815260408083206001600160a01b038516845290915290205460ff1615610e865760405162461bcd60e51b815260206004820152601d60248201527f43616e206f6e6c79206772616e7420746f206e6f6e20686f6c646572730000006044820152606401610290565b610e90828261260a565b5050565b336001600160a01b03821614610ee95760405162461bcd60e51b815260206004820152601a60248201527921b0b71037b7363c903932b737bab731b2903337b91039b2b63360311b6044820152606401610290565b610e90828261261e565b6000818152600560209081526040808320815180830190925280546001600160a01b031680835260019091015492820192909252829115610f3a5780516020820151610f54565b6004546001600160a01b03811690600160a01b900461ffff165b9250925050915091565b60608151835114610fc35760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604482015268040dad2e6dac2e8c6d60bb1b6064820152608401610290565b600083516001600160401b03811115610fde57610fde6148c1565b604051908082528060200260200182016040528015611007578160200160208202803683370190505b50905060005b84518110156110775761105285828151811061102b5761102b61524e565b60200260200101518583815181106110455761104561524e565b602002602001015161096e565b8282815181106110645761106461524e565b602090810291909101015260010161100d565b509392505050565b6001600160a01b03166000908152606d602052604090205460ff1690565b6110a56123b8565b6110c15760405162461bcd60e51b81526004016102909061528d565b610e908282612675565b60008181526003602052604090206001018054606091906110eb906151fc565b80601f0160208091040260200160405190810160405280929190818152602001828054611117906151fc565b80156111645780601f1061113957610100808354040283529160200191611164565b820191906000526020600020905b81548152906001019060200180831161114757829003601f168201915b50505050509050919050565b600054610100900460ff16158080156111905750600054600160ff909116105b806111b1575061119f306126f9565b1580156111b1575060005460ff166001145b6112145760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610290565b6000805460ff191660011790558015611237576000805461ff0019166101001790555b83517f8502233096d909befbda0999bb8ea2f3a6be3c138b9fbf003752a4c8bce86f6c907f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6907f86d5cf0a6bdc8d859ba3bdc97043337c82a0e609035f378e419298b6a3e00ae6906000906112ad90600161527a565b6001600160401b038111156112c4576112c46148c1565b6040519080825280602002602001820160405280156112ed578160200160208202803683370190505b50905060005b88518110156113485788818151811061130e5761130e61524e565b60200260200101518282815181106113285761132861524e565b6001600160a01b03909216602092830291909101909101526001016112f3565b7f000000000000000000000000000000000000000000000000000000000000000082828151811061137b5761137b61524e565b60200260200101906001600160a01b031690816001600160a01b0316815250506113a482612708565b6113ad8a612740565b6101036113ba8d8261538c565b506101046113c88c8261538c565b506113d28a612770565b6113db8d6123c6565b6113e660008e61260a565b6113f0858e61260a565b6113fa848e61260a565b61140585600061260a565b61141083600061260a565b61141a8888612675565b50506101059290925561010655610107558015611471576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050565b600081815261010a602090815260408083208151815460809481028201850190935260608181018481529095869590949293928492918491908401828280156114e357602002820191906000526020600020905b8154815260200190600101908083116114cf575b5050509183525050600191909101546001600160801b038082166020840152600160801b909104166040909101529050600061152b8560009081526003602052604090205490565b9050806001600160401b03811115611545576115456148c1565b60405190808252806020026020018201604052801561157e57816020015b61156b614722565b8152602001906001900390816115635790505b509350806001600160401b03811115611599576115996148c1565b6040519080825280602002602001820160405280156115c2578160200160208202803683370190505b50925060005b818110156115ff576115da8682610cd0565b8582815181106115ec576115ec61524e565b60209081029190910101526001016115c8565b505051919391925050565b60008281526008602052604081205481805b828110156116ef5760008681526008602090815260408083208484526001019091529020546001600160a01b031615611698578482036116865760008681526008602090815260408083209383526001909301905220546001600160a01b031692506109fe915050565b61169160018361527a565b91506116dd565b6116a38660006118da565b80156116ca5750600086815260086020908152604080832083805260020190915290205481145b156116dd576116da60018361527a565b91505b6116e860018261527a565b905061161c565b50505092915050565b60606000611704611e8b565b905061170f3361107f565b8061172257506001600160a01b03811632145b6117575760405162461bcd60e51b81526004016102909060208082526004908201526321454f4160e01b604082015260600190565b82611762828661096e565b10156117805760405162461bcd60e51b81526004016102909061544b565b600084815261010a6020908152604080832081518154608094810282018501909352606081018381529093919284928491908401828280156117e157602002820191906000526020600020905b8154815260200190600101908083116117cd575b5050509183525050600191909101546001600160801b03808216602080850191909152600160801b9092048116604090930192909252820151919250429116111561185a5760405162461bcd60e51b815260206004820152600960248201526831b0b73a1037b832b760b91b6044820152606401610290565b6000611875868684604001516001600160801b03168561284c565b9050611882838787612bf0565b61188d308483612d7d565b826001600160a01b0316867f58bbfaa763248693d05ac650926341943af86affd998d80e41dbcc9adfdae60787846040516118c9929190615469565b60405180910390a395945050505050565b60009182526006602090815260408084206001600160a01b0393909316845291905290205460ff1690565b61190d6123b8565b6119295760405162461bcd60e51b81526004016102909061528d565b610cbc81612770565b6101048054610a70906151fc565b6119486123b8565b6119645760405162461bcd60e51b81526004016102909061528d565b61196f838383612e9f565b505050565b610e9061197f611e8b565b8383612f47565b600082815260066020908152604080832083805290915281205460ff166119d3575060008281526006602090815260408083206001600160a01b038516845290915290205460ff166109fe565b50600192915050565b600080610106546119ef81610b04611e8b565b6119f7611efe565b600089815261010b602052604090205460ff16611a415760405162461bcd60e51b815260206004820152600860248201526708505b1b1bddd95960c21b6044820152606401610290565b8615801590611a4f57508685145b611a6b5760405162461bcd60e51b815260040161029090615230565b611a75848a61096e565b600003611a945760405162461bcd60e51b81526004016102909061544b565b611aa26101075460006118da565b611ade5760005b87811015611adc57611aca610107548a8a84818110610b7157610b7161524e565b611ad560018261527a565b9050611aa9565b505b600061010a60008b815260200190815260200160002060010160109054906101000a90046001600160801b03166001600160801b03169050611b3689898989604051806020016040528060008152508f876001611f95565b60008b81526101096020526040902054909350611b5490849061527a565b9350611b71858b856040518060200160405280600081525061229a565b897fdf54045461e7fa6cda88afd9b979d29bb9ef67b8271562cec9a7a95ddc3afe728685604051611ba3929190614b86565b60405180910390a250611bb66001600955565b50965096945050505050565b6060816001600160401b03811115611bdc57611bdc6148c1565b604051908082528060200260200182016040528015611c0f57816020015b6060815260200190600190039081611bfa5790505b5090506000611c1c611e8b565b9050336001600160a01b038216141560005b848110156116ef578115611cad57611c8b30878784818110611c5257611c5261524e565b9050602002810190611c649190615482565b86604051602001611c77939291906154c8565b60405160208183030381529060405261301f565b848281518110611c9d57611c9d61524e565b6020026020010181905250611d2d565b611d0f30878784818110611cc357611cc361524e565b9050602002810190611cd59190615482565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061301f92505050565b848281518110611d2157611d2161524e565b60200260200101819052505b600101611c2e565b600081815260086020526040812054815b81811015611d995760008481526008602090815260408083208484526001019091529020546001600160a01b031615611d8757611d8460018461527a565b92505b611d9260018261527a565b9050611d46565b50611da58360006118da565b15611db857611db560018361527a565b91505b50919050565b600082815260076020526040902054610ee99033611f57565b60018054610a70906151fc565b611dec611e8b565b6001600160a01b0316856001600160a01b03161480611e125750611e12856108f4611e8b565b611e2e5760405162461bcd60e51b8152600401610290906152f6565b610df3858585858561304b565b60006001600160e01b03198216636cdb3d1360e11b1480611e6c57506001600160e01b031982166303a24d0760e21b145b806109fe57506301ffc9a760e01b6001600160e01b03198316146109fe565b6000611e95613180565b905090565b611ea48282611986565b610e9057611ebc816001600160a01b031660146131a5565b611ec78360206131a5565b604051602001611ed89291906154e9565b60408051601f198184030181529082905262461bcd60e51b82526102909160040161481f565b600260095403611f505760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610290565b6002600955565b60008281526006602090815260408083206001600160a01b038516845290915290205460ff16610e9057611ebc816001600160a01b031660146131a5565b60008060005b8981101561216e578a8a82818110611fb557611fb561524e565b90506080020160600135600003611ff65760405162461bcd60e51b81526020600482015260056024820152640c08185b5d60da1b6044820152606401610290565b8888828181106120085761200861524e565b905060200201358b8b838181106120215761202161524e565b905060800201606001356120359190615556565b156120525760405162461bcd60e51b81526004016102909061556a565b60018b8b838181106120665761206661524e565b905060800201602001602081019061207e9190615593565b600281111561208f5761208f614b18565b1415806120b757508a8a828181106120a9576120a961524e565b905060800201606001356001145b6120d35760405162461bcd60e51b81526004016102909061556a565b8888828181106120e5576120e561524e565b90506020020135826120f7919061527a565b600087815261010a6020526040902090925089898381811061211b5761211b61524e565b905060200201358c8c848181106121345761213461524e565b9050608002016060013561214891906152e2565b815460018181018455600093845260209093200155612167908261527a565b9050611f9b565b506121798482615556565b156121af5760405162461bcd60e51b81526004016102909060208082526004908201526308505b5d60e21b604082015260600190565b6121b984826152e2565b915082156122795760005b8981101561220f576121fd8b8b838181106121e1576121e161524e565b9050608002018036038101906121f791906155b0565b87613340565b61220860018261527a565b90506121c4565b5061227461221b611e8b565b308c8c808060200260200160405190810160405280939291908181526020016000905b8282101561226a5761225b608083028601368190038101906155b0565b8152602001906001019061223e565b5050505050612d7d565b61228d565b61228d612284611e8b565b8b8b8989613405565b5098975050505050505050565b6001600160a01b0384166122fa5760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b6064820152608401610290565b6000612304611e8b565b905060006123118561346d565b9050600061231e8561346d565b905061232f836000898585896134b8565b600086815260d1602090815260408083206001600160a01b038b1684529091528120805487929061236190849061527a565b909155505060408051878152602081018790526001600160a01b03808a169260009291871691600080516020615a50833981519152910160405180910390a46123af8360008989898961370e565b50505050505050565b6000611e958161067c611e8b565b600280546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d7690600090a35050565b815183511461247a5760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206044820152670dad2e6dac2e8c6d60c31b6064820152608401610290565b6001600160a01b0384166124a05760405162461bcd60e51b815260040161029090615624565b60006124aa611e8b565b90506124ba8187878787876134b8565b60005b845181101561259c5760008582815181106124da576124da61524e565b6020026020010151905060008583815181106124f8576124f861524e565b602090810291909101810151600084815260d1835260408082206001600160a01b038e1683529093529190912054909150818110156125495760405162461bcd60e51b815260040161029090615669565b600083815260d1602090815260408083206001600160a01b038e8116855292528083208585039055908b1682528120805484929061258890849061527a565b9091555050600190930192506124bd915050565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb87876040516125ec9291906156b3565b60405180910390a4612602818787878787613870565b505050505050565b6126148282613932565b610e90828261398d565b61262882826139fa565b60008281526008602090815260408083206001600160a01b03851680855260028201808552838620805487526001909301855292852080546001600160a01b031916905584529152555050565b6127108111156126975760405162461bcd60e51b8152600401610290906156c6565b600480546001600160a01b0384166001600160b01b03199091168117600160a01b61ffff851602179091556040518281527f90d7ec04bcb8978719414f82e52e4cb651db41d0e6f8cea6118c2191e6183adb9060200160405180910390a25050565b6001600160a01b03163b151590565b600054610100900460ff1661272f5760405162461bcd60e51b8152600401610290906156ef565b612737613a5c565b610cbc81613a85565b600054610100900460ff166127675760405162461bcd60e51b8152600401610290906156ef565b610cbc81613b0a565b60006001805461277f906151fc565b80601f01602080910402602001604051908101604052809291908181526020018280546127ab906151fc565b80156127f85780601f106127cd576101008083540402835291602001916127f8565b820191906000526020600020905b8154815290600101906020018083116127db57829003601f168201915b50505050509050816001908161280e919061538c565b507fc9c7c3fe08b88b4df9d4d47ef47d2c43d55c025a0ba88ca442580ed9e7348a16818360405161284092919061573a565b60405180910390a15050565b6060600061285a84866152b5565b9050806001600160401b03811115612874576128746148c1565b6040519080825280602002602001820160405280156128ad57816020015b61289a614722565b8152602001906001900390816128925790505b5060008781526101096020526040812054919350906128cd9086906152b5565b6000888152600360205260408120549192506128e7613b3a565b905060006128f48a61147b565b5090506000836001600160401b03811115612911576129116148c1565b60405190808252806020026020018201604052801561293a578160200160208202803683370190505b50905060005b86811015612b8a5760408051602080820187905281830184905282518083038401815260609092019092528051910120600061297c8883615556565b90506000805b88811015612b7b5760008d6000015182815181106129a2576129a261524e565b602002602001015190506000818984815181106129c1576129c161524e565b6020026020010151606001516129d791906152e2565b90506129e3818561527a565b851015612b6557818984815181106129fd576129fd61524e565b6020026020010151606001818151612a15919061575f565b9052508751600190899085908110612a2f57612a2f61524e565b602002602001019015159081151581525050888381518110612a5357612a5361524e565b6020026020010151600001518e8881518110612a7157612a7161524e565b60209081029190910101516001600160a01b0390911690528851899084908110612a9d57612a9d61524e565b6020026020010151602001518e8881518110612abb57612abb61524e565b6020026020010151602001906002811115612ad857612ad8614b18565b90816002811115612aeb57612aeb614b18565b81525050888381518110612b0157612b0161524e565b6020026020010151604001518e8881518110612b1f57612b1f61524e565b60200260200101516040018181525050818e8881518110612b4257612b4261524e565b602090810291909101015160600152612b5c60018d61575f565b9b505050612b7b565b612b6f818561527a565b93505050600101612982565b50836001019350505050612940565b5060005b84811015612be157818181518110612ba857612ba861524e565b602002602001015115612bd957612bd9838281518110612bca57612bca61524e565b60200260200101518d83613b94565b600101612b8e565b50505050505050949350505050565b6001600160a01b038316612c525760405162461bcd60e51b815260206004820152602360248201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260448201526265737360e81b6064820152608401610290565b6000612c5c611e8b565b90506000612c698461346d565b90506000612c768461346d565b9050612c96838760008585604051806020016040528060008152506134b8565b600085815260d1602090815260408083206001600160a01b038a16845290915290205484811015612d155760405162461bcd60e51b8152602060048201526024808201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604482015263616e636560e01b6064820152608401610290565b600086815260d1602090815260408083206001600160a01b038b81168086529184528285208a8703905582518b81529384018a9052909290881691600080516020615a50833981519152910160405180910390a46040805160208101909152600090526123af565b6000805b8251811015612e4f5773eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b0316838281518110612dba57612dba61524e565b6020026020010151600001516001600160a01b0316148015612de457506001600160a01b03841630145b15612e1957828181518110612dfb57612dfb61524e565b60200260200101516060015182612e12919061527a565b9150612e3d565b612e3d8585858481518110612e3057612e3061524e565b6020026020010151613c72565b612e4860018261527a565b9050612d81565b508015612e99576040805160808101825273eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee81526000602082018190529181019190915260608101829052610df3858583613c72565b50505050565b612710811115612ec15760405162461bcd60e51b8152600401610290906156c6565b6040805180820182526001600160a01b038481168083526020808401868152600089815260058352869020945185546001600160a01b031916941693909317845591516001909301929092559151838152909185917f7365cf4122f072a3365c20d54eff9b38d73c096c28e1892ec8f5b0e403a0f12d91015b60405180910390a3505050565b816001600160a01b0316836001600160a01b031603612fba5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604482015268103337b91039b2b63360b91b6064820152608401610290565b6001600160a01b03838116600081815260d26020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c319101612f3a565b60606130448383604051806060016040528060278152602001615a7060279139613dc3565b9392505050565b6001600160a01b0384166130715760405162461bcd60e51b815260040161029090615624565b600061307b611e8b565b905060006130888561346d565b905060006130958561346d565b90506130a58389898585896134b8565b600086815260d1602090815260408083206001600160a01b038c168452909152902054858110156130e85760405162461bcd60e51b815260040161029090615669565b600087815260d1602090815260408083206001600160a01b038d8116855292528083208985039055908a1682528120805488929061312790849061527a565b909155505060408051888152602081018890526001600160a01b03808b16928c82169291881691600080516020615a50833981519152910160405180910390a4613175848a8a8a8a8a61370e565b505050505050505050565b600061318b3361107f565b1561319d575060131936013560601c90565b503390565b90565b606060006131b48360026152b5565b6131bf90600261527a565b6001600160401b038111156131d6576131d66148c1565b6040519080825280601f01601f191660200182016040528015613200576020820181803683370190505b509050600360fc1b8160008151811061321b5761321b61524e565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061324a5761324a61524e565b60200101906001600160f81b031916908160001a905350600061326e8460026152b5565b61327990600161527a565b90505b60018111156132f1576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106132ad576132ad61524e565b1a60f81b8282815181106132c3576132c361524e565b60200101906001600160f81b031916908160001a90535060049490941c936132ea81615772565b905061327c565b5083156130445760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610290565b61334982613e3b565b600081815260036020908152604080832080548085526002918201845291909320855181546001600160a01b039091166001600160a01b0319821681178355938701519294879492939284926001600160a81b0319161790600160a01b9084908111156133b8576133b8614b18565b0217905550604082015181600101556060820151816002015590505060016003600084815260200190815260200160002060000160008282546133fb919061527a565b9091555050505050565b6134108484836140f6565b61341a828261421f565b610df385308686808060200260200160405190810160405280939291908181526020016000905b8282101561226a5761345e608083028601368190038101906155b0565b81526020019060010190613441565b604080516001808252818301909252606091600091906020808301908036833701905050905082816000815181106134a7576134a761524e565b602090810291909101015292915050565b6134c66101055460006118da565b1580156134db57506001600160a01b03851615155b80156134ef57506001600160a01b03841615155b156135515761350161010554866118da565b80613514575061351461010554856118da565b6135515760405162461bcd60e51b815260206004820152600e60248201526d215452414e534645525f524f4c4560901b6044820152606401610290565b6001600160a01b0385166135d45760005b83518110156135ce5782818151811061357d5761357d61524e565b6020026020010151610109600086848151811061359c5761359c61524e565b6020026020010151815260200190815260200160002060008282546135c1919061527a565b9091555050600101613562565b50613691565b60005b835181101561368f5761010b60008583815181106135f7576135f761524e565b60209081029190910181015182528101919091526040016000205460ff16801561363b575082818151811061362e5761362e61524e565b6020026020010151600014155b1561368757600061010b60008684815181106136595761365961524e565b6020026020010151815260200190815260200160002060006101000a81548160ff0219169083151502179055505b6001016135d7565b505b6001600160a01b0384166126025760005b83518110156123af578281815181106136bd576136bd61524e565b602002602001015161010960008684815181106136dc576136dc61524e565b602002602001015181526020019081526020016000206000828254613701919061575f565b90915550506001016136a2565b613720846001600160a01b03166126f9565b156126025760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e61906137599089908990889088908890600401615789565b6020604051808303816000875af1925050508015613794575060408051601f3d908101601f19168201909252613791918101906157c3565b60015b613840576137a06157e0565b806308c379a0036137d957506137b46157fb565b806137bf57506137db565b8060405162461bcd60e51b8152600401610290919061481f565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e2d455243313135356044820152732932b1b2b4bb32b91034b6b83632b6b2b73a32b960611b6064820152608401610290565b6001600160e01b0319811663f23a6e6160e01b146123af5760405162461bcd60e51b815260040161029090615884565b613882846001600160a01b03166126f9565b156126025760405163bc197c8160e01b81526001600160a01b0385169063bc197c81906138bb90899089908890889088906004016158cc565b6020604051808303816000875af19250505080156138f6575060408051601f3d908101601f191682019092526138f3918101906157c3565b60015b613902576137a06157e0565b6001600160e01b0319811663bc197c8160e01b146123af5760405162461bcd60e51b815260040161029090615884565b60008281526006602090815260408083206001600160a01b0385168085529252808320805460ff1916600117905551339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b6000828152600860205260408120805491600191906139ac838561527a565b9091555050600092835260086020908152604080852083865260018101835281862080546001600160a01b039096166001600160a01b03199096168617905593855260029093019052912055565b613a048282611f57565b60008281526006602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600054610100900460ff16613a835760405162461bcd60e51b8152600401610290906156ef565b565b600054610100900460ff16613aac5760405162461bcd60e51b8152600401610290906156ef565b60005b8151811015610e90576001606d6000848481518110613ad057613ad061524e565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055600101613aaf565b600054610100900460ff16613b315760405162461bcd60e51b8152600401610290906156ef565b610cbc8161423a565b6000613b44611e8b565b613b4f60014361575f565b60405160609290921b6001600160601b03191660208301524060348201524460548201526074016040516020818303038152906040528051906020012060001c905090565b6000828152600360205260409020548110613bdd5760405162461bcd60e51b8152602060048201526009602482015268696e64657820444e4560b81b6044820152606401610290565b613be683613e3b565b6000828152600360209081526040808320848452600290810183529220855181546001600160a01b039091166001600160a01b03198216811783559287015187949293909284926001600160a81b03191690911790600160a01b908490811115613c5257613c52614b18565b021790555060408201516001820155606090910151600290910155505050565b600081602001516002811115613c8a57613c8a614b18565b03613cc45761196f8160000151848484606001517f000000000000000000000000d23e77b7e1726577006799b7194b6ae31958a839614246565b600181602001516002811115613cdc57613cdc614b18565b03613d455780516040808301519051632142170760e11b81526001600160a01b03909216916342842e0e91613d17918791879160040161592a565b600060405180830381600087803b158015613d3157600080fd5b505af11580156123af573d6000803e3d6000fd5b600281602001516002811115613d5d57613d5d614b18565b0361196f57805160408083015160608401519151637921219560e11b81526001600160a01b03878116600483015286811660248301526044820192909252606481019290925260a06084830152600060a48301529091169063f242432a9060c401613d17565b6060600080856001600160a01b031685604051613de0919061594e565b600060405180830381855af49150503d8060008114613e1b576040519150601f19603f3d011682016040523d82523d6000602084013e613e20565b606091505b5091509150613e31868383876143b0565b9695505050505050565b600181602001516002811115613e5357613e53614b18565b03613efd5780516040516301ffc9a760e01b81526001600160a01b03909116906301ffc9a790613e8b906380ac58cd9060040161596a565b602060405180830381865afa925050508015613ec4575060408051601f3d908101601f19168201909252613ec191810190615982565b60015b613ee05760405162461bcd60e51b81526004016102909061599f565b80610e905760405162461bcd60e51b81526004016102909061599f565b600281602001516002811115613f1557613f15614b18565b03613f4d5780516040516301ffc9a760e01b81526001600160a01b03909116906301ffc9a790613e8b9063d9b67a269060040161596a565b600081602001516002811115613f6557613f65614b18565b03610cbc5780516001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14610cbc5780516040516301ffc9a760e01b81526001600160a01b03909116906301ffc9a790613fc2906380ac58cd9060040161596a565b602060405180830381865afa925050508015613ffb575060408051601f3d908101601f19168201909252613ff891810190615982565b60015b614024576140076157e0565b806308c379a003610e90575061401b6157fb565b80610e90575050565b80156140425760405162461bcd60e51b81526004016102909061599f565b81516040516301ffc9a760e01b81526001600160a01b03909116906301ffc9a7906140759063d9b67a269060040161596a565b602060405180830381865afa9250505080156140ae575060408051601f3d908101601f191682019092526140ab91810190615982565b60015b6140d8576140ba6157e0565b806308c379a00361196f57506140ce6157fb565b8061196f57505050565b801561196f5760405162461bcd60e51b81526004016102909061599f565b818061412e5760405162461bcd60e51b815260206004820152600760248201526621546f6b656e7360c81b6044820152606401610290565b600082815260036020526040902054156141765760405162461bcd60e51b815260206004820152600960248201526869642065786973747360b81b6044820152606401610290565b60005b8181101561420a576141b18585838181106141965761419661524e565b9050608002018036038101906141ac91906155b0565b613e3b565b8484828181106141c3576141c361524e565b600086815260036020908152604080832087845260020190915290206080909102929092019190506141f582826159c3565b50614203905060018261527a565b9050614179565b50600091825260036020526040909120555050565b600081815260036020526040902060010161196f838261538c565b60d3610e90828261538c565b8115610df35773eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed196001600160a01b038616016143a457306001600160a01b038516036142eb57604051632e1a7d4d60e01b8152600481018390526001600160a01b03821690632e1a7d4d90602401600060405180830381600087803b1580156142c357600080fd5b505af11580156142d7573d6000803e3d6000fd5b505050506142e6838383614427565b610df3565b306001600160a01b03841603614399573482146143405760405162461bcd60e51b81526020600482015260136024820152721b5cd9cb9d985b1d5948084f48185b5bdd5b9d606a1b6044820152606401610290565b806001600160a01b031663d0e30db0836040518263ffffffff1660e01b81526004016000604051808303818588803b15801561437b57600080fd5b505af115801561438f573d6000803e3d6000fd5b5050505050610df3565b6142e6838383614427565b610df3858585856144ec565b6060831561441d578251600003614416576143ca856126f9565b6144165760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610290565b5081610cc8565b610cc88383614544565b6000836001600160a01b03168360405160006040518083038185875af1925050503d8060008114614474576040519150601f19603f3d011682016040523d82523d6000602084013e614479565b606091505b5050905080612e9957816001600160a01b031663d0e30db0846040518263ffffffff1660e01b81526004016000604051808303818588803b1580156144bd57600080fd5b505af11580156144d1573d6000803e3d6000fd5b50612e99935050506001600160a01b03841690508585614554565b816001600160a01b0316836001600160a01b03160315612e9957306001600160a01b0384160361452f5761452a6001600160a01b0385168383614554565b612e99565b612e996001600160a01b0385168484846145aa565b8151156137bf5781518083602001fd5b61196f8363a9059cbb60e01b8484604051602401614573929190614b86565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526145cb565b612e99846323b872dd60e01b8585856040516024016145739392919061592a565b6000614620826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661469d9092919063ffffffff16565b80519091501561196f578080602001905181019061463e9190615982565b61196f5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610290565b6060610cc8848460008585600080866001600160a01b031685876040516146c4919061594e565b60006040518083038185875af1925050503d8060008114614701576040519150601f19603f3d011682016040523d82523d6000602084013e614706565b606091505b5091509150614717878383876143b0565b979650505050505050565b604080516080810190915260008082526020820190815260200160008152602001600081525090565b6001600160a01b0381168114610cbc57600080fd5b803561476b8161474b565b919050565b6000806040838503121561478357600080fd5b823561478e8161474b565b946020939093013593505050565b6001600160e01b031981168114610cbc57600080fd5b6000602082840312156147c457600080fd5b81356130448161479c565b60005b838110156147ea5781810151838201526020016147d2565b50506000910152565b6000815180845261480b8160208601602086016147cf565b601f01601f19169290920160200192915050565b60208152600061304460208301846147f3565b60008083601f84011261484457600080fd5b5081356001600160401b0381111561485b57600080fd5b6020830191508360208260071b850101111561487657600080fd5b9250929050565b60008083601f84011261488f57600080fd5b5081356001600160401b038111156148a657600080fd5b6020830191508360208260051b850101111561487657600080fd5b634e487b7160e01b600052604160045260246000fd5b601f8201601f191681016001600160401b03811182821017156148fc576148fc6148c1565b6040525050565b600082601f83011261491457600080fd5b81356001600160401b0381111561492d5761492d6148c1565b604051614944601f8301601f1916602001826148d7565b81815284602083860101111561495957600080fd5b816020850160208301376000918101602001919091529392505050565b80356001600160801b038116811461476b57600080fd5b60008060008060008060008060c0898b0312156149a957600080fd5b88356001600160401b03808211156149c057600080fd5b6149cc8c838d01614832565b909a50985060208b01359150808211156149e557600080fd5b6149f18c838d0161487d565b909850965060408b0135915080821115614a0a57600080fd5b50614a178b828c01614903565b945050614a2660608a01614976565b9250614a3460808a01614976565b915060a0890135614a448161474b565b809150509295985092959890939650565b600060208284031215614a6757600080fd5b5035919050565b600060208284031215614a8057600080fd5b81356130448161474b565b60008060008060808587031215614aa157600080fd5b8435614aac8161474b565b93506020850135614abc8161474b565b92506040850135915060608501356001600160401b03811115614ade57600080fd5b614aea87828801614903565b91505092959194509250565b60008060408385031215614b0957600080fd5b50508035926020909101359150565b634e487b7160e01b600052602160045260246000fd5b80516001600160a01b03168252602081015160038110614b5e57634e487b7160e01b600052602160045260246000fd5b602083015260408181015190830152606090810151910152565b608081016109fe8284614b2e565b6001600160a01b03929092168252602082015260400190565b60006001600160401b03821115614bb857614bb86148c1565b5060051b60200190565b600082601f830112614bd357600080fd5b81356020614be082614b9f565b604051614bed82826148d7565b80915083815260208101915060208460051b870101935086841115614c1157600080fd5b602086015b84811015614c2d5780358352918301918301614c16565b509695505050505050565b600080600080600060a08688031215614c5057600080fd5b8535614c5b8161474b565b94506020860135614c6b8161474b565b935060408601356001600160401b0380821115614c8757600080fd5b614c9389838a01614bc2565b94506060880135915080821115614ca957600080fd5b614cb589838a01614bc2565b93506080880135915080821115614ccb57600080fd5b50614cd888828901614903565b9150509295509295909350565b60008060408385031215614cf857600080fd5b823591506020830135614d0a8161474b565b809150509250929050565b600082601f830112614d2657600080fd5b81356020614d3382614b9f565b604051614d4082826148d7565b80915083815260208101915060208460051b870101935086841115614d6457600080fd5b602086015b84811015614c2d578035614d7c8161474b565b8352918301918301614d69565b60008060408385031215614d9c57600080fd5b82356001600160401b0380821115614db357600080fd5b614dbf86838701614d15565b93506020850135915080821115614dd557600080fd5b50614de285828601614bc2565b9150509250929050565b60008151808452602080850194506020840160005b83811015614e1d57815187529582019590820190600101614e01565b509495945050505050565b6020815260006130446020830184614dec565b600080600080600080600060e0888a031215614e5657600080fd5b614e5f88614760565b965060208801356001600160401b0380821115614e7b57600080fd5b614e878b838c01614903565b975060408a0135915080821115614e9d57600080fd5b614ea98b838c01614903565b965060608a0135915080821115614ebf57600080fd5b614ecb8b838c01614903565b955060808a0135915080821115614ee157600080fd5b50614eee8a828b01614d15565b935050614efd60a08901614760565b915060c0880135905092959891949750929550565b60008151808452602080850194506020840160005b83811015614e1d57614f3a878351614b2e565b6080969096019590820190600101614f27565b604081526000614f606040830185614f12565b8281036020840152614f728185614dec565b95945050505050565b6020815260006130446020830184614f12565b600060208284031215614fa057600080fd5b81356001600160401b03811115614fb657600080fd5b610cc884828501614903565b600080600060608486031215614fd757600080fd5b833592506020840135614fe98161474b565b929592945050506040919091013590565b8015158114610cbc57600080fd5b6000806040838503121561501b57600080fd5b82356150268161474b565b91506020830135614d0a81614ffa565b6000806000806000806080878903121561504f57600080fd5b8635955060208701356001600160401b038082111561506d57600080fd5b6150798a838b01614832565b9097509550604089013591508082111561509257600080fd5b5061509f89828a0161487d565b90945092505060608701356150b38161474b565b809150509295509295509295565b600080602083850312156150d457600080fd5b82356001600160401b038111156150ea57600080fd5b6150f68582860161487d565b90969095509350505050565b600060208083016020845280855180835260408601915060408160051b87010192506020870160005b8281101561515957603f198886030184526151478583516147f3565b9450928501929085019060010161512b565b5092979650505050505050565b6000806040838503121561517957600080fd5b82356151848161474b565b91506020830135614d0a8161474b565b600080600080600060a086880312156151ac57600080fd5b85356151b78161474b565b945060208601356151c78161474b565b9350604086013592506060860135915060808601356001600160401b038111156151f057600080fd5b614cd888828901614903565b600181811c9082168061521057607f821691505b602082108103611db857634e487b7160e01b600052602260045260246000fd5b60208082526004908201526310a632b760e11b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b808201808211156109fe576109fe615264565b6020808252600e908201526d139bdd08185d5d1a1bdc9a5e995960921b604082015260600190565b80820281158282048414176109fe576109fe615264565b634e487b7160e01b600052601260045260246000fd5b6000826152f1576152f16152cc565b500490565b6020808252602e908201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60408201526d195c881bdc88185c1c1c9bdd995960921b606082015260800190565b601f82111561196f576000816000526020600020601f850160051c8101602086101561536d5750805b601f850160051c820191505b8181101561260257828155600101615379565b81516001600160401b038111156153a5576153a56148c1565b6153b9816153b384546151fc565b84615344565b602080601f8311600181146153ee57600084156153d65750858301515b600019600386901b1c1916600185901b178555612602565b600085815260208120601f198616915b8281101561541d578886015182559484019460019091019084016153fe565b508582101561543b5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6020808252600490820152630850985b60e21b604082015260600190565b828152604060208201526000610cc86040830184614f12565b6000808335601e1984360301811261549957600080fd5b8301803591506001600160401b038211156154b357600080fd5b60200191503681900382131561487657600080fd5b8284823760609190911b6001600160601b0319169101908152601401919050565b7402832b936b4b9b9b4b7b7399d1030b1b1b7bab73a1605d1b8152600083516155198160158501602088016147cf565b7001034b99036b4b9b9b4b733903937b6329607d1b601591840191820152835161554a8160268401602088016147cf565b01602601949350505050565b600082615565576155656152cc565b500690565b60208082526002908201526110a960f11b604082015260600190565b60038110610cbc57600080fd5b6000602082840312156155a557600080fd5b813561304481615586565b6000608082840312156155c257600080fd5b604051608081018181106001600160401b03821117156155e4576155e46148c1565b60405282356155f28161474b565b8152602083013561560281615586565b6020820152604083810135908201526060928301359281019290925250919050565b60208082526025908201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201526939103a3930b739b332b960b11b606082015260800190565b604081526000614f606040830185614dec565b6020808252600f908201526e45786365656473206d61782062707360881b604082015260600190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60408152600061574d60408301856147f3565b8281036020840152614f7281856147f3565b818103818111156109fe576109fe615264565b60008161578157615781615264565b506000190190565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090614717908301846147f3565b6000602082840312156157d557600080fd5b81516130448161479c565b600060033d11156131a25760046000803e5060005160e01c90565b600060443d10156158095790565b6040516003193d81016004833e81513d6001600160401b03816024840111818411171561583857505050505090565b82850191508151818111156158505750505050505090565b843d870101602082850101111561586a5750505050505090565b615879602082860101876148d7565b509095945050505050565b60208082526028908201527f455243313135353a204552433131353552656365697665722072656a656374656040820152676420746f6b656e7360c01b606082015260800190565b6001600160a01b0386811682528516602082015260a0604082018190526000906158f890830186614dec565b828103606084015261590a8186614dec565b9050828103608084015261591e81856147f3565b98975050505050505050565b6001600160a01b039384168152919092166020820152604081019190915260600190565b600082516159608184602087016147cf565b9190910192915050565b60e09190911b6001600160e01b031916815260200190565b60006020828403121561599457600080fd5b815161304481614ffa565b6020808252600a908201526921546f6b656e5479706560b01b604082015260600190565b81356159ce8161474b565b81546001600160a01b031981166001600160a01b0392909216918217835560208401356159fa81615586565b60038110615a1857634e487b7160e01b600052602160045260246000fd5b6001600160a81b03199190911690911760a09190911b60ff60a01b161781556040820135600182015560609091013560029091015556fec3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220624bfa16497cb79925ddcc3ac7118eeba77c46f910f49c549da187e74fd7cb8e64736f6c63430008170033