zellic-audit
Initial commit
f998fcd
raw
history blame
41.1 kB
{
"language": "Solidity",
"sources": {
"hardhat/contracts/BequestWillV1.sol": {
"content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport \"@openzeppelin/contracts/token/ERC1155/IERC1155.sol\";\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\n\n/**\n * @title BequestWillV1\n * @author Bequest Finance Inc.\n * @notice Bequest uses a Dead Man's switch to distribute tokens and NFTs to\n * selected recipients. Bequest allows decentralized, trustless and\n * anonymous crypto wills and asset recovery backed by the blockchain.\n */\ncontract BequestWillV1 is Ownable, ReentrancyGuard {\n /*\n * @dev: Stores all details about a Bequest\n */\n struct Bequest {\n address owner;\n address[] recipients;\n address[] nftRecipients;\n address executor;\n IERC20[] tokens;\n IERC165[] nfts;\n uint256 timestamp;\n uint256 renewalRate;\n uint256[] percentages;\n uint256[] nftIds;\n uint256[] nftAmounts;\n }\n\n /*\n * @dev: Stores all details about a referral\n */\n struct Referral {\n uint256 usesLeft;\n uint256 profit;\n uint8 discount;\n uint8 profitShare;\n address profitAddress;\n }\n\n /*\n * @dev: Event emitted when Bequest is created\n * @param owner: The owner of the Bequest\n * @param referral: Referral code used\n */\n event CreatedBequest(address indexed owner, string indexed referral);\n\n /*\n * @dev: Event emitted when Bequest is renewed\n * @param owner: The owner of the Bequest\n * @param executor: The executor of the renewal\n */\n event RenewedBequest(address indexed owner, address executor);\n\n /*\n * @dev: Event emitted when Bequest recipient distributes a Bequest\n * @param owner: The owner of the Bequest\n * @param executor: The recipient of the Bequest\n */\n event DistributedBequest(address indexed owner, address indexed recipient);\n\n /*\n * @dev: Event emitted when Bequest owner sets a recipient,\n * used for gas-efficent storage.\n * @param recipient: The recipient added to a Bequest\n * @param owner: The owner of the Bequest\n */\n event AddedRecipient(address indexed recipient, address owner);\n\n /*\n * @dev: Event emitted when Bequest owner sets an executor,\n * used for gas-efficent storage.\n * @param executor: The executor added to a Bequest\n * @param owner: The owner of the Bequest\n */\n event SetExecutor(address indexed executor, address owner);\n\n /*\n * @dev: Event emitted when referral code is created\n * @param code: Referral code\n */\n event CreatedReferral(string code);\n\n /*\n * @dev: Event emitted when yearly fee is edited\n * @param code: New yearly fee\n */\n event ChangedYearlyFee(uint256 newYearlyFee);\n\n // Stores all Bequests\n mapping(address => Bequest) private addressToBequest;\n // Stores if a Bequest owner has paid their distribution fee\n mapping(address => bool) private paidDistributionFee;\n // Stores the last\n mapping(address => uint256) private lastPaidYearlyFee;\n\n // Stores all referral codes\n mapping(string => Referral) public referralCodes;\n // Current profit to be withdrawn for referrers\n uint256 public referralProfit;\n\n uint256 private constant ONE_YEAR = 365 days;\n uint256 public bequestYearlyFee;\n uint256 private constant BEQUEST_FEE_DIVISOR = 100; // CONSTANT 1%\n\n constructor(uint256 _bequestYearlyFee) {\n bequestYearlyFee = _bequestYearlyFee;\n }\n\n /*\n * @dev: Ensures called is a Bequest owner\n */\n modifier onlyBequestOwner() {\n require(isOwner(msg.sender), \"Not Bequest owner\");\n _;\n }\n\n /*\n * @dev: Ensures Bequest is up to date on renewal payments\n */\n modifier notClaimable() {\n require(!isClaimable(msg.sender), \"Renew Bequest\");\n _;\n }\n\n modifier onlyExecutor(address _owner) {\n require(\n msg.sender == addressToBequest[_owner].executor ||\n msg.sender == addressToBequest[_owner].owner,\n \"Not executor\"\n );\n _;\n }\n\n /*\n * @notice: Creates a Bequest\n * @param _owner: To be owner of Bequest\n * @param _referral: Referral code, if any\n */\n function createBequest(address _owner, string memory _referral)\n external\n payable\n {\n require(!isOwner(_owner), \"Already owner\");\n\n uint256 creationFee = getCreationFee(_referral);\n require(msg.value == creationFee, \"Invalid fee\");\n\n if (bytes(_referral).length != 0) {\n Referral storage referralDetails = referralCodes[_referral];\n\n if (referralDetails.profitShare > 0) {\n uint256 profit = (creationFee * referralDetails.profitShare) / 100;\n\n referralDetails.profit += profit;\n referralProfit += profit;\n }\n\n referralDetails.usesLeft--;\n }\n\n Bequest storage bequest = addressToBequest[_owner];\n bequest.owner = _owner;\n bequest.timestamp = block.timestamp;\n bequest.renewalRate = ONE_YEAR;\n\n emit CreatedBequest(_owner, _referral);\n }\n\n /*\n * @notice: Lets Bequest owners renew their Bequest\n * @dev: Similar to Dead Man's Switch\n */\n function renewBequest(address _owner) external payable onlyExecutor(_owner) {\n (uint256 renewalFee, uint256 yearsPassed) = getRenewalFee(_owner);\n require(msg.value == renewalFee, \"Invalid fee\");\n\n if (yearsPassed > 0) {\n if (lastPaidYearlyFee[_owner] == 0) {\n lastPaidYearlyFee[_owner] =\n addressToBequest[_owner].timestamp +\n ONE_YEAR *\n yearsPassed;\n } else {\n lastPaidYearlyFee[_owner] += ONE_YEAR * yearsPassed;\n }\n }\n\n addressToBequest[_owner].timestamp = block.timestamp;\n emit RenewedBequest(_owner, msg.sender);\n }\n\n /*\n * @notice: Transfers all assets in _owner's Bequest to _recipient\n * @param _owner: Owner of Bequest\n * @param _recipient: Recipient of assets\n * @dev: Nonreentrant to avoid malicious code when calling external contracts\n */\n function distribute(address _owner, address _recipient)\n external\n nonReentrant\n {\n require(isRecipient(_owner, _recipient), \"Not recipient\");\n require(isClaimable(_owner), \"Cannot distribute now\");\n\n Bequest storage bequest = addressToBequest[_owner];\n\n if (bequest.recipients.length != 0) {\n if (!paidDistributionFee[_owner]) {\n safeSendERC20s(_owner, owner(), 1, BEQUEST_FEE_DIVISOR);\n paidDistributionFee[_owner] = true;\n }\n\n uint256 recipientPercentage;\n uint256 index;\n\n for (uint256 i; i < bequest.recipients.length; i++) {\n if (bequest.recipients[i] == _recipient) {\n recipientPercentage = bequest.percentages[i];\n index = i;\n break;\n }\n }\n\n uint256 cumulativePercentage;\n\n for (uint256 i; i < bequest.percentages.length; i++) {\n cumulativePercentage += bequest.percentages[i];\n }\n\n safeSendERC20s(\n _owner,\n _recipient,\n recipientPercentage,\n cumulativePercentage\n );\n\n delete bequest.recipients[index];\n delete bequest.percentages[index];\n }\n\n for (uint256 i; i < bequest.nftRecipients.length; i++) {\n if (bequest.nftRecipients[i] == _recipient) {\n safeSendNFT(\n _owner,\n _recipient,\n bequest.nfts[i],\n bequest.nftIds[i],\n bequest.nftAmounts[i]\n );\n delete bequest.nftRecipients[i];\n }\n }\n\n emit DistributedBequest(_owner, _recipient);\n\n for (uint256 i; i < bequest.recipients.length; i++) {\n if (bequest.recipients[i] != address(0)) {\n return;\n }\n }\n\n for (uint256 i; i < bequest.nftRecipients.length; i++) {\n if (bequest.nftRecipients[i] != address(0)) {\n return;\n }\n }\n\n delete addressToBequest[_owner];\n delete paidDistributionFee[_owner];\n delete lastPaidYearlyFee[_owner];\n }\n\n /*\n * @notice sets recipients, tokens, and renewal rate for a will\n * @param _recipients: Address of token recipients\n * @param _percentages: Percentage alloted to each recipient by index match\n * @param _tokens: ERC20 contract addresses\n * @param _renewal_rate: New renewal rate\n */\n function setBequest(\n address[] memory _recipients,\n uint256[] memory _percentages,\n IERC20[] memory _tokens,\n uint256 _renewalRate\n ) external notClaimable {\n setRecipients(_recipients, _percentages);\n setTokens(_tokens);\n setRenewalRate(_renewalRate);\n }\n\n /*\n * @notice: Lets Bequest owner set tokens in Bequest\n * @param _nfts: NFT contract addresses\n * @param _nftIds: NFT tokenIds, index-matched\n * @param _nftRecipients: NFT recipient address, index-matched\n */\n function setNFTs(\n IERC165[] memory _nfts,\n uint256[] memory _nftIds,\n address[] memory _nftRecipients,\n uint256[] memory _nftAmounts\n ) external onlyBequestOwner notClaimable {\n require(_nfts.length == _nftIds.length, \"Invalid input\");\n require(_nfts.length == _nftRecipients.length, \"Invalid input\");\n require(_nfts.length == _nftAmounts.length, \"Invalid input\");\n\n for (uint256 i; i < _nfts.length; i++) {\n require(isERC721(_nfts[i]) || isERC1155(_nfts[i]), \"Not ERC721/ERC1155\");\n require(_nftAmounts[i] > 0, \"Invalid input\");\n }\n\n addressToBequest[msg.sender].nfts = _nfts;\n addressToBequest[msg.sender].nftIds = _nftIds;\n addressToBequest[msg.sender].nftRecipients = _nftRecipients;\n addressToBequest[msg.sender].nftAmounts = _nftAmounts;\n }\n\n /*\n * @notice: Lets Executor or Bequest owner set executor to renew will on owner's behalf\n * @param _owner: Bequest owner's address\n * @param _executor: Exeuctor's address\n */\n function setExecutor(address _owner, address _executor)\n external\n onlyExecutor(_owner)\n {\n require(!isClaimable(_owner), \"Renew Bequest\");\n addressToBequest[_owner].executor = _executor;\n emit SetExecutor(_executor, _owner);\n }\n\n /*\n * @notice: Creates a referral code\n * @param _code: Referral code name\n * @param _usesLeft: The amount of uses of the referral code\n * @param _discount: The percent of discount\n * @param _profitShare: The percent of profit to give to _profitAddress\n * @param _profitAddress: Address to send profit to\n * @dev: Possible to edit referral code\n */\n function createReferral(\n string memory _code,\n uint256 _usesLeft,\n uint8 _discount,\n uint8 _profitShare,\n address _profitAddress\n ) external onlyOwner {\n require(bytes(_code).length > 0, \"Invalid code\");\n require(_discount <= 100, \"Invalid discount\");\n require(_profitShare <= 100, \"Invalid profit share\");\n if (_profitShare != 0) {\n require(_profitAddress != address(0), \"Invalid address\");\n }\n\n referralCodes[_code].usesLeft = _usesLeft;\n referralCodes[_code].discount = _discount;\n referralCodes[_code].profitShare = _profitShare;\n referralCodes[_code].profitAddress = _profitAddress;\n\n emit CreatedReferral(_code);\n }\n\n /*\n * @notice: Transfers all profit, if any, to the profit address\n * @param _code: Referrer code name\n * @dev: Profit set to 0 before transfer to prevent re-entrancy\n */\n function withdrawReferralProfits(string memory _code) external {\n Referral storage referralDetails = referralCodes[_code];\n uint256 profit = referralDetails.profit;\n require(profit > 0, \"No profit\");\n\n referralProfit -= profit;\n referralDetails.profit = 0;\n (bool success, ) = referralDetails.profitAddress.call{ value: profit }(\"\");\n require(success, \"Transaction failed\");\n }\n\n /*\n * @notice: Deletes caller's Bequest\n */\n function deleteBequest() external onlyBequestOwner {\n delete addressToBequest[msg.sender];\n delete paidDistributionFee[msg.sender];\n delete lastPaidYearlyFee[msg.sender];\n }\n\n /*\n * @notice: Lets contract admin extract fees paid by users\n * @dev: Does not let referral profit be withdrawn\n */\n function extractFees() external onlyOwner {\n uint256 amount = address(this).balance - referralProfit;\n (bool success, ) = owner().call{ value: amount }(\"\");\n require(success, \"Transaction failed\");\n }\n\n /*\n * @notice: Sets Bequest yearly fee, admin function\n * @param _fee: New yearly fee\n */\n function setYearlyFee(uint256 _fee) external onlyOwner {\n bequestYearlyFee = _fee;\n emit ChangedYearlyFee(_fee);\n }\n\n /*\n * @param _owner: Address\n * @returns: _owner's Bequest details\n */\n function getBequest(address _owner) external view returns (Bequest memory) {\n return addressToBequest[_owner];\n }\n\n /*\n * @notice: Lets Bequest owner set renewal rate\n * @param _rate: New renewal rate\n */\n function setRenewalRate(uint256 _rate) public onlyBequestOwner notClaimable {\n require(_rate >= 1 days, \"Invalid input\");\n addressToBequest[msg.sender].renewalRate = _rate;\n }\n\n /*\n * @notice: Lets Bequest owner set token's recipients\n * @param _recipients: Address of token recipients\n * @param _percentages: Percentage alloted to each recipient by index match\n */\n function setRecipients(\n address[] memory _recipients,\n uint256[] memory _percentages\n ) public onlyBequestOwner notClaimable {\n for (uint256 i; i < _recipients.length; i++) {\n for (uint256 j = i + 1; j < _recipients.length; j++) {\n if (_recipients[i] == _recipients[j]) {\n revert(\"Duplicate recipient\");\n }\n }\n }\n\n require(_recipients.length == _percentages.length, \"Invalid input\");\n\n uint256 sum;\n for (uint256 i; i < _recipients.length; i++) {\n sum += _percentages[i];\n require(_recipients[i] != address(0), \"Invalid recipient\");\n }\n require(sum == 100, \"Must sum to 100%\");\n\n for (uint256 i; i < _recipients.length; i++) {\n emit AddedRecipient(_recipients[i], msg.sender);\n }\n\n addressToBequest[msg.sender].recipients = _recipients;\n addressToBequest[msg.sender].percentages = _percentages;\n }\n\n /*\n * @notice: Lets Bequest owner set tokens in Bequest\n * @param _tokens: ERC20 contract addresses\n * @dev: Tokens are pre-approved in frontend\n */\n function setTokens(IERC20[] memory _tokens)\n public\n onlyBequestOwner\n notClaimable\n {\n addressToBequest[msg.sender].tokens = _tokens;\n }\n\n /*\n * @param _owner: Bequest owner\n * @returns: True if _owner's Bequest is claimable\n */\n function isClaimable(address _owner) public view returns (bool) {\n Bequest memory bequest = addressToBequest[_owner];\n return block.timestamp >= bequest.renewalRate + bequest.timestamp;\n }\n\n /*\n * @param _referral: Address\n * @returns: The current creation fee with a possible\n * referral discount\n */\n function getCreationFee(string memory _referral)\n public\n view\n returns (uint256)\n {\n uint256 creationFee = bequestYearlyFee;\n if (bytes(_referral).length != 0) {\n Referral memory referralDetails = referralCodes[_referral];\n\n require(referralDetails.usesLeft > 0, \"Referral code expired\");\n creationFee = (bequestYearlyFee * (100 - referralDetails.discount)) / 100;\n }\n return creationFee;\n }\n\n /*\n * @param _owner: Address\n * @returns: The current renewal fee for _owner and the number\n * of years passed since last renewal\n */\n function getRenewalFee(address _owner)\n public\n view\n returns (uint256, uint256)\n {\n uint256 timePassed;\n if (lastPaidYearlyFee[_owner] == 0) {\n timePassed = block.timestamp - addressToBequest[_owner].timestamp;\n } else {\n timePassed = block.timestamp - lastPaidYearlyFee[_owner];\n }\n\n uint256 yearsPassed = timePassed / ONE_YEAR;\n uint256 renewalFee = yearsPassed * bequestYearlyFee;\n\n return (renewalFee, yearsPassed);\n }\n\n /*\n * @param _owner: Address\n * @returns A boolean indicatting whether the _owner owns a Bequest\n */\n function isOwner(address _owner) public view returns (bool) {\n return addressToBequest[_owner].owner == _owner;\n }\n\n /*\n * @param _owner: Bequest owner address\n * @param _recipient: Recipient address\n * @returns A boolean indicatting whether the _recipent is a recipient\n * of the _owner's Bequest\n */\n function isRecipient(address _owner, address _recipient)\n public\n view\n returns (bool)\n {\n if (_recipient == address(0)) return false;\n\n Bequest memory bequest = addressToBequest[_owner];\n\n for (uint256 i; i < bequest.recipients.length; i++) {\n if (bequest.recipients[i] == _recipient) {\n return true;\n }\n }\n\n for (uint256 i; i < bequest.nftRecipients.length; i++) {\n if (bequest.nftRecipients[i] == _recipient) {\n return true;\n }\n }\n\n return false;\n }\n\n /*\n * @notice Distributes all ERC20s\n * @param _owner: Owner of Bequest\n * @param _recipient: Recipient address\n * @param _percentage: Percentage alloted to _recipient\n * @param _percentageSum: Sum of percentages alloted to all\n * recipients in _owner's Bequest\n */\n function safeSendERC20s(\n address _owner,\n address _recipient,\n uint256 _percentage,\n uint256 _percentageSum\n ) internal {\n Bequest memory bequest = addressToBequest[_owner];\n\n for (uint256 i; i < bequest.tokens.length; i++) {\n uint256 amount = min(\n getTokenAllowance(bequest.owner, bequest.tokens[i]),\n getBalance(bequest.owner, bequest.tokens[i])\n );\n\n uint256 share = (_percentage * amount) / _percentageSum;\n\n if (share != 0) {\n try bequest.tokens[i].transferFrom(_owner, _recipient, share) {} catch (\n bytes memory\n ) {}\n }\n }\n }\n\n /*\n * @notice Sends an NFT\n * @param _owner: Owner of Bequest\n * @param _recipient: Recipient address\n * @param _nft: Address of NFT Contract\n * @param _nft: NFT token ID\n * @dev Only supports ERC721 and ERC1155\n */\n function safeSendNFT(\n address _owner,\n address _recipient,\n IERC165 _nft,\n uint256 _nftId,\n uint256 _amount\n ) internal {\n if (isERC721(_nft)) {\n IERC721 nft = IERC721(address(_nft));\n try nft.safeTransferFrom(_owner, _recipient, _nftId) {} catch (\n bytes memory\n ) {}\n } else if (isERC1155(_nft)) {\n IERC1155 nft = IERC1155(address(_nft));\n uint256 nftBalance;\n\n try nft.balanceOf(_owner, _nftId) returns (uint256 balance) {\n nftBalance = balance;\n } catch (bytes memory) {}\n\n nftBalance = min(nftBalance, _amount);\n\n if (nftBalance > 0) {\n try\n nft.safeTransferFrom(_owner, _recipient, _nftId, nftBalance, \"\")\n {} catch (bytes memory) {}\n }\n }\n }\n\n /*\n * @param _nft: NFT address\n * @returns Whether _nft is ERC721\n */\n function isERC721(IERC165 _nft) internal view returns (bool) {\n try _nft.supportsInterface(0x80ac58cd) returns (bool erc721) {\n return erc721;\n } catch (bytes memory) {\n return false;\n }\n }\n\n /*\n * @param _nft: NFT address\n * @returns Whether _nft is ERC1155\n */\n function isERC1155(IERC165 _nft) internal view returns (bool) {\n try _nft.supportsInterface(0xd9b67a26) returns (bool erc1155) {\n return erc1155;\n } catch (bytes memory) {\n return false;\n }\n }\n\n /*\n * @param _owner: Bequest owner\n * @param _token: Token contract address\n * @returns: Token allowance\n */\n function getTokenAllowance(address _owner, IERC20 _token)\n internal\n view\n returns (uint256)\n {\n try _token.allowance(_owner, address(this)) returns (uint256 allowance) {\n return allowance;\n } catch (bytes memory) {\n return 0;\n }\n }\n\n /*\n * @param _owner: Bequest owner\n * @param _token: Token contract address\n * @returns: Token balance\n */\n function getBalance(address _owner, IERC20 _token)\n internal\n view\n returns (uint256)\n {\n try _token.balanceOf(_owner) returns (uint256 balance) {\n return balance;\n } catch (bytes memory) {\n return 0;\n }\n }\n\n /*\n * @param a: First integer\n * @param b: Second integer\n * @returns Smaller integer\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a <= b ? a : b;\n }\n}\n"
},
"@openzeppelin/contracts/token/ERC20/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n"
},
"@openzeppelin/contracts/access/Ownable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\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"
},
"@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/token/ERC1155/IERC1155.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC1155 compliant contract, as defined in the\n * https://eips.ethereum.org/EIPS/eip-1155[EIP].\n *\n * _Available since v3.1._\n */\ninterface IERC1155 is IERC165 {\n /**\n * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.\n */\n event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);\n\n /**\n * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all\n * transfers.\n */\n event TransferBatch(\n address indexed operator,\n address indexed from,\n address indexed to,\n uint256[] ids,\n uint256[] values\n );\n\n /**\n * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to\n * `approved`.\n */\n event ApprovalForAll(address indexed account, address indexed operator, bool approved);\n\n /**\n * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.\n *\n * If an {URI} event was emitted for `id`, the standard\n * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value\n * returned by {IERC1155MetadataURI-uri}.\n */\n event URI(string value, uint256 indexed id);\n\n /**\n * @dev Returns the amount of tokens of token type `id` owned by `account`.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function balanceOf(address account, uint256 id) external view returns (uint256);\n\n /**\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.\n *\n * Requirements:\n *\n * - `accounts` and `ids` must have the same length.\n */\n function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)\n external\n view\n returns (uint256[] memory);\n\n /**\n * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,\n *\n * Emits an {ApprovalForAll} event.\n *\n * Requirements:\n *\n * - `operator` cannot be the caller.\n */\n function setApprovalForAll(address operator, bool approved) external;\n\n /**\n * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.\n *\n * See {setApprovalForAll}.\n */\n function isApprovedForAll(address account, address operator) external view returns (bool);\n\n /**\n * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.\n *\n * Emits a {TransferSingle} event.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.\n * - `from` must have a balance of tokens of type `id` of at least `amount`.\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the\n * acceptance magic value.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes calldata data\n ) external;\n\n /**\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.\n *\n * Emits a {TransferBatch} event.\n *\n * Requirements:\n *\n * - `ids` and `amounts` must have the same length.\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the\n * acceptance magic value.\n */\n function safeBatchTransferFrom(\n address from,\n address to,\n uint256[] calldata ids,\n uint256[] calldata amounts,\n bytes calldata data\n ) external;\n}\n"
},
"@openzeppelin/contracts/security/ReentrancyGuard.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n constructor() {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n // On the first call to nonReentrant, _notEntered will be true\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n\n _;\n\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 1000000
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}
}