File size: 10,591 Bytes
f998fcd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
{
"language": "Solidity",
"sources": {
"contracts/ivy-pets/DistributorV2.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\n\ncontract DistributorV2 {\n address public IVY_BOYS_ADDRESS =\n 0x809D8f2B12454FC07408d2479cf6DC701ecD5a9f;\n address public SERUM_ADDRESS = 0x59BDB74d66bDdBF32f632B6bD9B3a2b35477D7A5;\n address public owner;\n address public UPGRADED_PET_ADDRESS;\n bool public isUpgradingActive;\n mapping(uint256 => bool)[3] public superUpgrades;\n mapping(uint256 => bool)[3] public megaUpgrades;\n\n constructor() {\n owner = msg.sender;\n }\n\n address[3] public petContracts = [\n 0xf4f5fbF9ecc85F457aA4468F20Fa88169970c44D,\n 0x51061aA713BF11889Ea01183633ABb3c2f62cADF,\n 0xd6F047bC6E5c0e39E4Ca97E6706221D4C47D1D56\n ];\n\n function upgradePets(uint256[][3] calldata _tokenIds, uint8 _serumCount)\n external\n {\n require(isUpgradingActive, \"Upgrading not active\");\n require(\n IIvyBoys(IVY_BOYS_ADDRESS).balanceOf(msg.sender) > 0,\n \"Need at least one ivy boy\"\n );\n for (uint256 i = 0; i < _tokenIds.length; i++) {\n for (uint256 j; j < _tokenIds[i].length; j++) {\n uint256 selectedTokenId = _tokenIds[i][j];\n if (_serumCount == 1) {\n require(\n !superUpgrades[i][selectedTokenId],\n \"Token already upgraded\"\n );\n superUpgrades[i][selectedTokenId] = true;\n }\n if (_serumCount == 5) {\n require(\n !megaUpgrades[i][selectedTokenId],\n \"Token already upgraded\"\n );\n megaUpgrades[i][selectedTokenId] = true;\n }\n }\n IIvyPet(petContracts[i]).upgrade(_tokenIds[i], _serumCount);\n }\n uint256 mintCount = _tokenIds[0].length +\n _tokenIds[1].length +\n _tokenIds[2].length;\n ISerum(SERUM_ADDRESS).burnExternal(_serumCount * mintCount, msg.sender);\n IUpgradedPets(UPGRADED_PET_ADDRESS).mint(\n _tokenIds,\n msg.sender,\n _serumCount\n );\n }\n\n // ==== SETTERS ====\n\n function setPetContracts(\n address _dog,\n address _cat,\n address _bear\n ) external onlyOwner {\n petContracts = [_dog, _cat, _bear];\n }\n\n function setUpgradedPets(address _address) external onlyOwner {\n UPGRADED_PET_ADDRESS = _address;\n }\n\n function setIvyBoysContract(address _address) external onlyOwner {\n IVY_BOYS_ADDRESS = _address;\n }\n\n function setSerum(address _address) public onlyOwner {\n SERUM_ADDRESS = _address;\n }\n\n function setSwitches(bool _upgrade) public onlyOwner {\n isUpgradingActive = _upgrade;\n }\n\n // ==== UTIL ====\n\n function getPetTokens(address _address)\n public\n view\n returns (uint256[][3] memory)\n {\n uint256[][3] memory output;\n for (uint256 i = 0; i < 3; i++) {\n output[i] = IIvyPet(petContracts[i]).tokensOfOwner(_address);\n }\n return output;\n }\n\n modifier onlyOwner() {\n require(msg.sender == owner, \"Can only be called by owner\");\n _;\n }\n}\n\ninterface IIvyPet {\n function mint(uint256 _quantity, address _minter) external;\n\n function upgrade(uint256[] calldata _tokenIds, uint8 _serumCount) external;\n\n function tokensOfOwner(address owner)\n external\n view\n returns (uint256[] memory);\n}\n\ninterface IIvyBoys {\n function ownerOf(uint256 token_id) external returns (address);\n\n function balanceOf(address _owner) external view returns (uint256);\n}\n\ninterface ISerum {\n function burnExternal(uint256 _amount, address _caller) external;\n}\n\ninterface IUpgradedPets {\n function mint(\n uint256[][3] calldata _tokenIds,\n address _minter,\n uint256 _serumCount\n ) external;\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": false,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}
} |