{ "language": "Solidity", "sources": { "diamond/VoviWallets.sol": { "content": "// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.8.13;\r\n\r\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\r\nimport \"@openzeppelin/contracts/utils/Counters.sol\";\r\nimport \"./interfaces/IVoviWallets.sol\";\r\n\r\ncontract VoviWallets is IVoviWallets {\r\n using Counters for Counters.Counter;\r\n\r\n Counters.Counter private _pointer;\r\n mapping(address => uint256) private _pointers;\r\n mapping(uint256 => address[]) private _linkedWallets;\r\n mapping(address => bool) private _hasLink;\r\n mapping(address => mapping(address => bool)) private _pendingLinks;\r\n\r\n constructor () {\r\n\r\n }\r\n\r\n function isOwnerOf(Link[] calldata links, address token, uint256 tokenId) external view returns (bool) {\r\n require(this.confirmLinks(links), \"VOVI Wallets: Cannot confirm wallet linking\");\r\n IERC721 tokenContract = IERC721(token);\r\n address owner = tokenContract.ownerOf(tokenId);\r\n for (uint256 i = 0; i < links.length; i++) {\r\n if (links[i].signer == owner) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n function balanceOf(Link[] calldata links, address token) external view returns (uint256) {\r\n require(this.confirmLinks(links), \"VOVI Wallets: Cannot confirm wallet linking\");\r\n uint256 balance = 0;\r\n IERC721 tokenContract = IERC721(token);\r\n for (uint256 i = 0; i < links.length; i++) {\r\n balance += tokenContract.balanceOf(links[i].signer);\r\n }\r\n return balance;\r\n }\r\n\r\n function confirmLinks(Link[] calldata links) external pure returns (bool) {\r\n if (links.length == 0) {\r\n return false;\r\n }\r\n for (uint256 i = 0; i < links.length; i++) {\r\n if (recoverSigner(getEthSignedHash(getMessageHash(\"VOVI Linked Wallet\")), links[i].signature) != links[i].signer) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n function getMessageHash(string memory message) internal pure returns (bytes32) {\r\n return keccak256(abi.encodePacked(message));\r\n }\r\n\r\n function getEthSignedHash(bytes32 messageHash) internal pure returns (bytes32) {\r\n return keccak256(abi.encodePacked(\r\n \"\\x19Ethereum Signed Message:\\n32\",\r\n messageHash\r\n ));\r\n }\r\n\r\n function recoverSigner(bytes32 ethSignedMessageHash, bytes memory sig) internal pure returns (address) {\r\n (bytes32 r, bytes32 s, uint8 v) = _split(sig);\r\n return ecrecover(ethSignedMessageHash, v, r, s);\r\n }\r\n\r\n function _split(bytes memory _sig) internal pure returns (bytes32 r, bytes32 s, uint8 v) {\r\n require(_sig.length == 65, \"Invalid Signature Length\");\r\n assembly {\r\n r := mload(add(_sig, 32))\r\n s := mload(add(_sig, 64))\r\n v := byte(0, mload(add(_sig, 96)))\r\n }\r\n }\r\n}" }, "diamond/interfaces/IVoviWallets.sol": { "content": "// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.8.13;\r\n\r\ninterface IVoviWallets {\r\n struct Link {\r\n address signer;\r\n bytes signature;\r\n } \r\n function isOwnerOf(Link[] calldata links, address token, uint256 tokenId) external view returns (bool);\r\n function balanceOf(Link[] calldata links, address token) external view returns (uint256);\r\n function confirmLinks(Link[] calldata links) external pure returns (bool);\r\n}" }, "@openzeppelin/contracts/utils/Counters.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary Counters {\n struct Counter {\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n // this feature: see https://github.com/ethereum/solidity/issues/4637\n uint256 _value; // default: 0\n }\n\n function current(Counter storage counter) internal view returns (uint256) {\n return counter._value;\n }\n\n function increment(Counter storage counter) internal {\n unchecked {\n counter._value += 1;\n }\n }\n\n function decrement(Counter storage counter) internal {\n uint256 value = counter._value;\n require(value > 0, \"Counter: decrement overflow\");\n unchecked {\n counter._value = value - 1;\n }\n }\n\n function reset(Counter storage counter) internal {\n counter._value = 0;\n }\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" ] } } } }