UNPKG

@animoca/ethereum-contracts-assets

Version:
76 lines 13.7 MB
{ "id": "87bce0d3ce9ebfb35c038831fa5913c8", "_format": "hh-sol-build-info-1", "solcVersion": "0.7.6", "solcLongVersion": "0.7.6+commit.7338295f", "input": { "language": "Solidity", "sources": { "contracts/metadata/NFTBaseMetadataURI.sol": { "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.7.6 <0.8.0;\n\nimport {UInt256ToDecimalString} from \"@animoca/ethereum-contracts-core/contracts/utils/types/UInt256ToDecimalString.sol\";\nimport {ManagedIdentity} from \"@animoca/ethereum-contracts-core/contracts/metatx/ManagedIdentity.sol\";\nimport {Ownable} from \"@animoca/ethereum-contracts-core/contracts/access/Ownable.sol\";\n\nabstract contract NFTBaseMetadataURI is ManagedIdentity, Ownable {\n using UInt256ToDecimalString for uint256;\n\n event BaseMetadataURISet(string baseMetadataURI);\n\n string public baseMetadataURI;\n\n function setBaseMetadataURI(string calldata baseMetadataURI_) external {\n _requireOwnership(_msgSender());\n baseMetadataURI = baseMetadataURI_;\n emit BaseMetadataURISet(baseMetadataURI_);\n }\n\n function _uri(uint256 id) internal view virtual returns (string memory) {\n return string(abi.encodePacked(baseMetadataURI, id.toDecimalString()));\n }\n}\n" }, "@animoca/ethereum-contracts-core/contracts/utils/types/UInt256ToDecimalString.sol": { "content": "// SPDX-License-Identifier: MIT\n\n// Partially derived from OpenZeppelin:\n// https://github.com/OpenZeppelin/openzeppelin-contracts/blob/8b10cb38d8fedf34f2d89b0ed604f2dceb76d6a9/contracts/utils/Strings.sol\n\npragma solidity >=0.7.6 <0.8.0;\n\nlibrary UInt256ToDecimalString {\n function toDecimalString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n uint256 index = digits - 1;\n temp = value;\n while (temp != 0) {\n buffer[index--] = bytes1(uint8(48 + (temp % 10)));\n temp /= 10;\n }\n return string(buffer);\n }\n}\n" }, "@animoca/ethereum-contracts-core/contracts/metatx/ManagedIdentity.sol": { "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.7.6 <0.8.0;\n\n/*\n * 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.\n */\nabstract contract ManagedIdentity {\n function _msgSender() internal view virtual returns (address payable) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes memory) {\n return msg.data;\n }\n}\n" }, "@animoca/ethereum-contracts-core/contracts/access/Ownable.sol": { "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.7.6 <0.8.0;\n\nimport {ManagedIdentity} from \"../metatx/ManagedIdentity.sol\";\nimport {IERC173} from \"./IERC173.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 ManagedIdentity, IERC173 {\n address internal _owner;\n\n /**\n * Initializes the contract, setting the deployer as the initial owner.\n * @dev Emits an {IERC173-OwnershipTransferred(address,address)} event.\n */\n constructor(address owner_) {\n _owner = owner_;\n emit OwnershipTransferred(address(0), owner_);\n }\n\n /**\n * Gets the address of the current contract owner.\n */\n function owner() public view virtual override returns (address) {\n return _owner;\n }\n\n /**\n * See {IERC173-transferOwnership(address)}\n * @dev Reverts if the sender is not the current contract owner.\n * @param newOwner the address of the new owner. Use the zero address to renounce the ownership.\n */\n function transferOwnership(address newOwner) public virtual override {\n _requireOwnership(_msgSender());\n _owner = newOwner;\n emit OwnershipTransferred(_owner, newOwner);\n }\n\n /**\n * @dev Reverts if `account` is not the contract owner.\n * @param account the account to test.\n */\n function _requireOwnership(address account) internal virtual {\n require(account == this.owner(), \"Ownable: not the owner\");\n }\n}\n" }, "@animoca/ethereum-contracts-core/contracts/access/IERC173.sol": { "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.7.6 <0.8.0;\n\n/**\n * @title ERC-173 Contract Ownership Standard\n * Note: the ERC-165 identifier for this interface is 0x7f5828d0\n */\ninterface IERC173 {\n /**\n * Event emited when ownership of a contract changes.\n * @param previousOwner the previous owner.\n * @param newOwner the new owner.\n */\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * Get the address of the owner\n * @return The address of the owner.\n */\n function owner() external view returns (address);\n\n /**\n * Set the address of the new owner of the contract\n * Set newOwner to address(0) to renounce any ownership.\n * @dev Emits an {OwnershipTransferred} event.\n * @param newOwner The address of the new owner of the contract. Using the zero address means renouncing ownership.\n */\n function transferOwnership(address newOwner) external;\n}\n" }, "contracts/token/ERC721/mocks/ERC721Mock.sol": { "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.7.6 <0.8.0;\n\nimport {IForwarderRegistry} from \"ethereum-universal-forwarder/src/solc_0.7/ERC2771/IForwarderRegistry.sol\";\nimport {IERC721Metadata} from \"./../interfaces/IERC721Metadata.sol\";\nimport {IERC721Mintable} from \"./../interfaces/IERC721Mintable.sol\";\nimport {ManagedIdentity} from \"@animoca/ethereum-contracts-core/contracts/metatx/ManagedIdentity.sol\";\nimport {Recoverable} from \"@animoca/ethereum-contracts-core/contracts/utils/Recoverable.sol\";\nimport {UsingUniversalForwarding} from \"ethereum-universal-forwarder/src/solc_0.7/ERC2771/UsingUniversalForwarding.sol\";\nimport {MinterRole} from \"@animoca/ethereum-contracts-core/contracts/access/MinterRole.sol\";\nimport {ERC721} from \"./../ERC721.sol\";\nimport {NFTBaseMetadataURI} from \"./../../../metadata/NFTBaseMetadataURI.sol\";\n\n/**\n * @title ERC721 Mock.\n */\ncontract ERC721Mock is Recoverable, UsingUniversalForwarding, ERC721, NFTBaseMetadataURI, IERC721Mintable, MinterRole {\n constructor(IForwarderRegistry forwarderRegistry, address universalForwarder)\n ERC721(\"ERC721Mock\", \"E721\")\n UsingUniversalForwarding(forwarderRegistry, universalForwarder)\n MinterRole(msg.sender)\n {}\n\n //=================================================== ERC721Metadata ====================================================//\n\n /// @inheritdoc IERC721Metadata\n function tokenURI(uint256 tokenId) external view virtual override returns (string memory) {\n require(address(uint160(_owners[tokenId])) != address(0), \"ERC721: non-existing NFT\");\n return _uri(tokenId);\n }\n\n //=================================================== ERC721Mintable ====================================================//\n\n /// @inheritdoc IERC721Mintable\n /// @dev Reverts if the sender is not a minter.\n function mint(address to, uint256 tokenId) external virtual override {\n _requireMinter(_msgSender());\n _mint(to, tokenId, \"\", false);\n }\n\n /// @inheritdoc IERC721Mintable\n /// @dev Reverts if the sender is not a minter.\n function batchMint(address to, uint256[] calldata tokenIds) external virtual override {\n _requireMinter(_msgSender());\n _batchMint(to, tokenIds);\n }\n\n /// @inheritdoc IERC721Mintable\n /// @dev Reverts if the sender is not a minter.\n function safeMint(\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external virtual override {\n _requireMinter(_msgSender());\n _mint(to, tokenId, data, true);\n }\n\n //======================================== Meta Transactions Internal Functions =========================================//\n\n function _msgSender() internal view virtual override(ManagedIdentity, UsingUniversalForwarding) returns (address payable) {\n return UsingUniversalForwarding._msgSender();\n }\n\n function _msgData() internal view virtual override(ManagedIdentity, UsingUniversalForwarding) returns (bytes memory ret) {\n return UsingUniversalForwarding._msgData();\n }\n\n //=============================================== Mock Coverage Functions ===============================================//\n\n function msgData() external view returns (bytes memory ret) {\n return _msgData();\n }\n}\n" }, "ethereum-universal-forwarder/src/solc_0.7/ERC2771/IForwarderRegistry.sol": { "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.7.0;\n\ninterface IForwarderRegistry {\n function isForwarderFor(address, address) external view returns (bool);\n}\n" }, "contracts/token/ERC721/interfaces/IERC721Metadata.sol": { "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.7.6 <0.8.0;\n\n/**\n * @title ERC721 Non-Fungible Token Standard, optional extension: Metadata.\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n * @dev Note: The ERC-165 identifier for this interface is 0x5b5e139f.\n */\ninterface IERC721Metadata {\n /**\n * @dev Gets the token name\n * @return string representing the token name\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Gets the token symbol\n * @return string representing the token symbol\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns an URI for a given token ID\n * Throws if the token ID does not exist. May return an empty string.\n * @param tokenId uint256 ID of the token to query\n * @return string URI of given token ID\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n" }, "contracts/token/ERC721/interfaces/IERC721Mintable.sol": { "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.7.6 <0.8.0;\n\n/**\n * @title ERC721 Non-Fungible Token Standard, optional extension: Mintable.\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Mintable {\n /**\n * Unsafely mints a token.\n * @dev Reverts if `to` is the zero address.\n * @dev Reverts if `tokenId` has already been minted.\n * @dev Emits an {IERC721-Transfer} event from the zero address.\n * @param to Address of the new token owner.\n * @param tokenId Identifier of the token to mint.\n */\n function mint(address to, uint256 tokenId) external;\n\n /**\n * Unsafely mints a batch of tokens.\n * @dev Reverts if `to` is the zero address.\n * @dev Reverts if one of `tokenIds` has already been minted.\n * @dev Emits an {IERC721-Transfer} event from the zero address for each of `tokenIds`.\n * @param to Address of the new tokens owner.\n * @param tokenIds Identifiers of the tokens to mint.\n */\n function batchMint(address to, uint256[] calldata tokenIds) external;\n\n /**\n * Safely mints a token.\n * @dev Reverts if `to` is the zero address.\n * @dev Reverts if `tokenId` has already ben minted.\n * @dev Reverts if `to` is a contract and the call to {IERC721Receiver-onERC721Received} fails or is refused.\n * @dev Emits an {IERC721-Transfer} event from the zero address.\n * @param to Address of the new token owner.\n * @param tokenId Identifier of the token to mint.\n * @param data Optional data to pass along to the receiver call.\n */\n function safeMint(\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n}\n" }, "@animoca/ethereum-contracts-core/contracts/utils/Recoverable.sol": { "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.7.6 <0.8.0;\n\nimport {ManagedIdentity} from \"../metatx/ManagedIdentity.sol\";\nimport {Ownable} from \"../access/Ownable.sol\";\nimport {IWrappedERC20, ERC20Wrapper} from \"./ERC20Wrapper.sol\";\n\nabstract contract Recoverable is ManagedIdentity, Ownable {\n using ERC20Wrapper for IWrappedERC20;\n\n /**\n * Extract ERC20 tokens which were accidentally sent to the contract to a list of accounts.\n * Warning: this function should be overriden for contracts which are supposed to hold ERC20 tokens\n * so that the extraction is limited to only amounts sent accidentally.\n * @dev Reverts if the sender is not the contract owner.\n * @dev Reverts if `accounts`, `tokens` and `amounts` do not have the same length.\n * @dev Reverts if one of `tokens` is does not implement the ERC20 transfer function.\n * @dev Reverts if one of the ERC20 transfers fail for any reason.\n * @param accounts the list of accounts to transfer the tokens to.\n * @param tokens the list of ERC20 token addresses.\n * @param amounts the list of token amounts to transfer.\n */\n function recoverERC20s(\n address[] calldata accounts,\n address[] calldata tokens,\n uint256[] calldata amounts\n ) external virtual {\n _requireOwnership(_msgSender());\n uint256 length = accounts.length;\n require(length == tokens.length && length == amounts.length, \"Recov: inconsistent arrays\");\n for (uint256 i = 0; i != length; ++i) {\n IWrappedERC20(tokens[i]).wrappedTransfer(accounts[i], amounts[i]);\n }\n }\n\n /**\n * Extract ERC721 tokens which were accidentally sent to the contract to a list of accounts.\n * Warning: this function should be overriden for contracts which are supposed to hold ERC721 tokens\n * so that the extraction is limited to only tokens sent accidentally.\n * @dev Reverts if the sender is not the contract owner.\n * @dev Reverts if `accounts`, `contracts` and `amounts` do not have the same length.\n * @dev Reverts if one of `contracts` is does not implement the ERC721 transferFrom function.\n * @dev Reverts if one of the ERC721 transfers fail for any reason.\n * @param accounts the list of accounts to transfer the tokens to.\n * @param contracts the list of ERC721 contract addresses.\n * @param tokenIds the list of token ids to transfer.\n */\n function recoverERC721s(\n address[] calldata accounts,\n address[] calldata contracts,\n uint256[] calldata tokenIds\n ) external virtual {\n _requireOwnership(_msgSender());\n uint256 length = accounts.length;\n require(length == contracts.length && length == tokenIds.length, \"Recov: inconsistent arrays\");\n for (uint256 i = 0; i != length; ++i) {\n IRecoverableERC721(contracts[i]).transferFrom(address(this), accounts[i], tokenIds[i]);\n }\n }\n}\n\ninterface IRecoverableERC721 {\n /// See {IERC721-transferFrom(address,address,uint256)}\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n}\n" }, "ethereum-universal-forwarder/src/solc_0.7/ERC2771/UsingUniversalForwarding.sol": { "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.7.0;\n\nimport \"./UsingAppendedCallData.sol\";\nimport \"./IERC2771.sol\";\nimport \"./IForwarderRegistry.sol\";\n\nabstract contract UsingUniversalForwarding is UsingAppendedCallData, IERC2771 {\n IForwarderRegistry internal immutable _forwarderRegistry;\n address internal immutable _universalForwarder;\n\n constructor(IForwarderRegistry forwarderRegistry, address universalForwarder) {\n _universalForwarder = universalForwarder;\n _forwarderRegistry = forwarderRegistry;\n }\n\n function isTrustedForwarder(address forwarder) external view virtual override returns (bool) {\n return forwarder == _universalForwarder || forwarder == address(_forwarderRegistry);\n }\n\n function _msgSender() internal view virtual returns (address payable) {\n address payable msgSender = msg.sender;\n address payable sender = _lastAppendedDataAsSender();\n if (msgSender == address(_forwarderRegistry) || msgSender == _universalForwarder) {\n // if forwarder use appended data\n return sender;\n }\n\n // if msg.sender is neither the registry nor the universal forwarder,\n // we have to check the last 20bytes of the call data intepreted as an address\n // and check if the msg.sender was registered as forewarder for that address\n // we check tx.origin to save gas in case where msg.sender == tx.origin\n // solhint-disable-next-line avoid-tx-origin\n if (msgSender != tx.origin && _forwarderRegistry.isForwarderFor(sender, msgSender)) {\n return sender;\n }\n\n return msgSender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n address payable msgSender = msg.sender;\n if (msgSender == address(_forwarderRegistry) || msgSender == _universalForwarder) {\n // if forwarder use appended data\n return _msgDataAssuming20BytesAppendedData();\n }\n\n // we check tx.origin to save gas in case where msg.sender == tx.origin\n // solhint-disable-next-line avoid-tx-origin\n if (msgSender != tx.origin && _forwarderRegistry.isForwarderFor(_lastAppendedDataAsSender(), msgSender)) {\n return _msgDataAssuming20BytesAppendedData();\n }\n return msg.data;\n }\n}\n" }, "@animoca/ethereum-contracts-core/contracts/access/MinterRole.sol": { "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.7.6 <0.8.0;\n\nimport {Ownable} from \"./Ownable.sol\";\n\n/**\n * Contract which allows derived contracts access control over token minting operations.\n */\ncontract MinterRole is Ownable {\n event MinterAdded(address indexed account);\n event MinterRemoved(address indexed account);\n\n mapping(address => bool) public isMinter;\n\n /**\n * Constructor.\n */\n constructor(address owner_) Ownable(owner_) {\n _addMinter(owner_);\n }\n\n /**\n * Grants the minter role to a non-minter.\n * @dev reverts if the sender is not the contract owner.\n * @param account The account to grant the minter role to.\n */\n function addMinter(address account) public {\n _requireOwnership(_msgSender());\n _addMinter(account);\n }\n\n /**\n * Renounces the granted minter role.\n * @dev reverts if the sender is not a minter.\n */\n function renounceMinter() public {\n address account = _msgSender();\n _requireMinter(account);\n isMinter[account] = false;\n emit MinterRemoved(account);\n }\n\n function _requireMinter(address account) internal view {\n require(isMinter[account], \"MinterRole: not a Minter\");\n }\n\n function _addMinter(address account) internal {\n isMinter[account] = true;\n emit MinterAdded(account);\n }\n}\n" }, "contracts/token/ERC721/ERC721.sol": { "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.7.6 <0.8.0;\n\nimport {AddressIsContract} from \"@animoca/ethereum-contracts-core/contracts/utils/types/AddressIsContract.sol\";\nimport {IERC165} from \"@animoca/ethereum-contracts-core/contracts/introspection/IERC165.sol\";\nimport {IERC721} from \"./interfaces/IERC721.sol\";\nimport {IERC721Events} from \"./interfaces/IERC721Events.sol\";\nimport {IERC721Receiver} from \"./interfaces/IERC721Receiver.sol\";\nimport {IERC721Metadata} from \"./interfaces/IERC721Metadata.sol\";\nimport {IERC721BatchTransfer} from \"./interfaces/IERC721BatchTransfer.sol\";\nimport {ManagedIdentity} from \"@animoca/ethereum-contracts-core/contracts/metatx/ManagedIdentity.sol\";\nimport {ERC721Simple} from \"./ERC721Simple.sol\";\n\n/**\n * @title ERC721 Non Fungible Token Contract.\n * @dev The function `tokenURI(uint256)` needs to be implemented by a child contract, for example with the help of `NFTBaseMetadataURI`.\n */\nabstract contract ERC721 is ManagedIdentity, IERC165, IERC721, IERC721Events, IERC721Metadata, IERC721BatchTransfer {\n using AddressIsContract for address;\n\n bytes4 internal constant _ERC721_RECEIVED = type(IERC721Receiver).interfaceId;\n\n uint256 internal constant _APPROVAL_BIT_TOKEN_OWNER_ = 1 << 160;\n\n // Burnt Non-Fungible Token owner's magic value\n uint256 internal constant _BURNT_NFT_OWNER = 0xdead000000000000000000000000000000000000000000000000000000000000;\n\n string internal _name;\n string internal _symbol;\n\n /* owner => operator => approved */\n mapping(address => mapping(address => bool)) internal _operators;\n\n /* NFT ID => owner */\n mapping(uint256 => uint256) internal _owners;\n\n /* owner => NFT balance */\n mapping(address => uint256) internal _nftBalances;\n\n /* NFT ID => operator */\n mapping(uint256 => address) internal _nftApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n // todo\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n //======================================================= ERC165 ========================================================//\n\n /// @inheritdoc IERC165\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return\n interfaceId == type(IERC165).interfaceId ||\n interfaceId == type(IERC721).interfaceId ||\n interfaceId == type(IERC721Metadata).interfaceId ||\n interfaceId == type(IERC721BatchTransfer).interfaceId;\n }\n\n //=================================================== ERC721Metadata ====================================================//\n\n /// @inheritdoc IERC721Metadata\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /// @inheritdoc IERC721Metadata\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n //======================================================= ERC721 ========================================================//\n\n /// @inheritdoc IERC721\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: zero address\");\n return _nftBalances[owner];\n }\n\n /// @inheritdoc IERC721\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = address(uint160(_owners[tokenId]));\n require(owner != address(0), \"ERC721: non-existing NFT\");\n return owner;\n }\n\n /// @inheritdoc IERC721\n function approve(address to, uint256 tokenId) public virtual override {\n uint256 owner = _owners[tokenId];\n require(owner != 0, \"ERC721: non-existing NFT\");\n address ownerAddress = address(uint160(owner));\n require(to != ownerAddress, \"ERC721: self-approval\");\n require(_isOperatable(ownerAddress, _msgSender()), \"ERC721: non-approved sender\");\n if (to == address(0)) {\n if (owner & _APPROVAL_BIT_TOKEN_OWNER_ != 0) {\n // remove the approval bit if it is present\n _owners[tokenId] = uint256(ownerAddress);\n }\n } else {\n uint256 ownerWithApprovalBit = owner | _APPROVAL_BIT_TOKEN_OWNER_;\n if (owner != ownerWithApprovalBit) {\n // add the approval bit if it is not present\n _owners[tokenId] = ownerWithApprovalBit;\n }\n _nftApprovals[tokenId] = to;\n }\n emit Approval(ownerAddress, to, tokenId);\n }\n\n /// @inheritdoc IERC721\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n uint256 owner = _owners[tokenId];\n require(address(uint160(owner)) != address(0), \"ERC721: non-existing NFT\");\n if (owner & _APPROVAL_BIT_TOKEN_OWNER_ != 0) {\n return _nftApprovals[tokenId];\n } else {\n return address(0);\n }\n }\n\n /// @inheritdoc IERC721\n function setApprovalForAll(address operator, bool approved) public virtual override {\n address sender = _msgSender();\n require(operator != sender, \"ERC721: self-approval\");\n _operators[sender][operator] = approved;\n emit ApprovalForAll(sender, operator, approved);\n }\n\n /// @inheritdoc IERC721\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operators[owner][operator];\n }\n\n /// @inheritdoc IERC721\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n _transferFrom(\n from,\n to,\n tokenId,\n \"\",\n /* safe */\n false\n );\n }\n\n /// @inheritdoc IERC721\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n _transferFrom(\n from,\n to,\n tokenId,\n \"\",\n /* safe */\n true\n );\n }\n\n /// @inheritdoc IERC721\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public virtual override {\n _transferFrom(\n from,\n to,\n tokenId,\n data,\n /* safe */\n true\n );\n }\n\n //================================================= ERC721BatchTransfer =================================================//\n\n /// @inheritdoc IERC721BatchTransfer\n function batchTransferFrom(\n address from,\n address to,\n uint256[] memory tokenIds\n ) public virtual override {\n require(to != address(0), \"ERC721: transfer to zero\");\n address sender = _msgSender();\n bool operatable = _isOperatable(from, sender);\n\n uint256 length = tokenIds.length;\n\n for (uint256 i; i != length; ++i) {\n uint256 tokenId = tokenIds[i];\n _transferNFT(from, to, tokenId, operatable, true);\n emit Transfer(from, to, tokenId);\n }\n\n if (length != 0) {\n _transferNFTUpdateBalances(from, to, length);\n }\n }\n\n //============================================ High-level Internal Functions ============================================//\n\n function _mint(\n address to,\n uint256 tokenId,\n bytes memory data,\n bool safe\n ) internal {\n require(to != address(0), \"ERC721: mint to zero\");\n\n _mintNFT(to, tokenId, false);\n\n emit Transfer(address(0), to, tokenId);\n if (safe && to.isContract()) {\n _callOnERC721Received(address(0), to, tokenId, data);\n }\n }\n\n function _batchMint(address to, uint256[] memory tokenIds) internal {\n require(to != address(0), \"ERC721: mint to zero\");\n\n uint256 length = tokenIds.length;\n for (uint256 i; i != length; ++i) {\n uint256 tokenId = tokenIds[i];\n _mintNFT(to, tokenId, true);\n emit Transfer(address(0), to, tokenId);\n }\n\n _nftBalances[to] += length;\n }\n\n function _transferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data,\n bool safe\n ) internal {\n require(to != address(0), \"ERC721: transfer to zero\");\n address sender = _msgSender();\n bool operatable = _isOperatable(from, sender);\n\n _transferNFT(from, to, tokenId, operatable, false);\n\n emit Transfer(from, to, tokenId);\n if (safe && to.isContract()) {\n _callOnERC721Received(from, to, tokenId, data);\n }\n }\n\n //============================================== Helper Internal Functions ==============================================//\n\n function _transferNFT(\n address from,\n address to,\n uint256 id,\n bool operatable,\n bool isBatch\n ) internal virtual {\n uint256 owner = _owners[id];\n require(from == address(uint160(owner)), \"ERC721: non-owned NFT\");\n if (!operatable) {\n require((owner & _APPROVAL_BIT_TOKEN_OWNER_ != 0) && _msgSender() == _nftApprovals[id], \"ERC721: non-approved sender\");\n }\n _owners[id] = uint256(uint160(to));\n if (!isBatch) {\n _transferNFTUpdateBalances(from, to, 1);\n }\n }\n\n function _transferNFTUpdateBalances(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n if (from != to) {\n // cannot underflow as balance is verified through ownership\n _nftBalances[from] -= amount;\n // cannot overflow as supply cannot overflow\n _nftBalances[to] += amount;\n }\n }\n\n function _mintNFT(\n address to,\n uint256 id,\n bool isBatch\n ) internal {\n require(_owners[id] == 0, \"ERC721: existing/burnt NFT\");\n\n _owners[id] = uint256(uint160(to));\n\n if (!isBatch) {\n // cannot overflow due to the cost of minting individual tokens\n ++_nftBalances[to];\n }\n }\n\n /**\n * Calls {IERC721Receiver-onERC721Received} on a target contract.\n * @dev Reverts if `to` is not a contract.\n * @dev Reverts if the call to the target fails or is refused.\n * @param from Previous token owner.\n * @param to New token owner.\n * @param tokenId Identifier of the token transferred.\n * @param data Optional data to send along with the receiver contract call.\n */\n function _callOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal {\n require(IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) == _ERC721_RECEIVED, \"ERC721: transfer refused\");\n }\n\n /**\n * Returns whether `sender` is authorised to make a transfer on behalf of `from`.\n * @param from The address to check operatibility upon.\n * @param sender The sender address.\n * @return True if sender is `from` or an operator for `from`, false otherwise.\n */\n function _isOperatable(address from, address sender) internal view virtual returns (bool) {\n return (from == sender) || _operators[from][sender];\n }\n}\n" }, "@animoca/ethereum-contracts-core/contracts/utils/ERC20Wrapper.sol": { "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.7.6 <0.8.0;\n\nimport {AddressIsContract} from \"./types/AddressIsContract.sol\";\n\n/**\n * @title ERC20Wrapper\n * Wraps ERC20 functions to support non-standard implementations which do not return a bool value.\n * Calls to the wrapped functions revert only if they throw or if they return false.\n */\nlibrary ERC20Wrapper {\n using AddressIsContract for address;\n\n function wrappedTransfer(\n IWrappedERC20 token,\n address to,\n uint256 value\n ) internal {\n _callWithOptionalReturnData(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function wrappedTransferFrom(\n IWrappedERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callWithOptionalReturnData(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n function wrappedApprove(\n IWrappedERC20 token,\n address spender,\n uint256 value\n ) internal {\n _callWithOptionalReturnData(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function _callWithOptionalReturnData(IWrappedERC20 token, bytes memory callData) internal {\n address target = address(token);\n require(target.isContract(), \"ERC20Wrapper: non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory data) = target.call(callData);\n if (success) {\n if (data.length != 0) {\n require(abi.decode(data, (bool)), \"ERC20Wrapper: operation failed\");\n }\n } else {\n // revert using a standard revert message\n if (data.length == 0) {\n revert(\"ERC20Wrapper: operation failed\");\n }\n\n // revert using the revert message coming from the call\n assembly {\n let size := mload(data)\n revert(add(32, data), size)\n }\n }\n }\n}\n\ninterface IWrappedERC20 {\n function transfer(address to, uint256 value) external returns (bool);\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) external returns (bool);\n\n function approve(address spender, uint256 value) external returns (bool);\n}\n" }, "@animoca/ethereum-contracts-core/contracts/utils/types/AddressIsContract.sol": { "content": "// SPDX-License-Identifier: MIT\n\n// Partially derived from OpenZeppelin:\n// https://github.com/OpenZeppelin/openzeppelin-contracts/blob/406c83649bd6169fc1b578e08506d78f0873b276/contracts/utils/Address.sol\n\npragma solidity >=0.7.6 <0.8.0;\n\n/**\n * @dev Upgrades the address type to check if it is a contract.\n */\nlibrary AddressIsContract {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize, which returns 0 for contracts in\n // construction, since the code is only stored at the end of the\n // constructor execution.\n\n uint256 size;\n assembly {\n size := extcodesize(account)\n }\n return size > 0;\n }\n}\n" }, "ethereum-universal-forwarder/src/solc_0.7/ERC2771/UsingAppendedCallData.sol": { "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.7.0;\n\nabstract contract UsingAppendedCallData {\n function _lastAppendedDataAsSender() internal pure virtual returns (address payable sender) {\n // Copied from openzeppelin : https://github.com/OpenZeppelin/openzeppelin-contracts/blob/9d5f77db9da0604ce0b25148898a94ae2c20d70f/contracts/metatx/ERC2771Context.sol1\n // The assembly code is more direct than the Solidity version using `abi.decode`.\n // solhint-disable-next-line no-inline-assembly\n assembly {\n sender := shr(96, calldataload(sub(calldatasize(), 20)))\n }\n }\n\n function _msgDataAssuming20BytesAppendedData() internal pure virtual returns (bytes calldata) {\n return msg.data[:msg.data.length - 20];\n }\n}\n" }, "ethereum-universal-forwarder/src/solc_0.7/ERC2771/IERC2771.sol": { "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.7.0;\n\ninterface IERC2771 {\n function isTrustedForwarder(address forwarder) external view returns (bool);\n}\n" }, "@animoca/ethereum-contracts-core/contracts/introspection/IERC165.sol": { "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.7.6 <0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165.\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" }, "contracts/token/ERC721/interfaces/IERC721.sol": { "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.7.6 <0.8.0;\n\n/**\n * @title ERC721 Non-Fungible Token Standard, basic interface (functions).\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n * @dev This interface only contains the standard functions. See IERC721Events for the events.\n * @dev Note: The ERC-165 identifier for this interface is 0x80ac58cd.\n */\ninterface IERC721 {\n /**\n * Gets the balance of the specified address\n * @param owner address to query the balance of\n * @return balance uint256 representing the amount owned by the passed address\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * Gets the owner of the specified ID\n * @param tokenId uint256 ID to query the owner of\n * @return owner address currently marked as the owner of the given ID\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * Approves another address to transfer the given token ID\n * @dev The zero address indicates there is no approved address.\n * @dev There can only be one approved address per token at a given time.\n * @dev Can only be called by the token owner or an approved operator.\n * @param to address to be approved for the given token ID\n * @param tokenId uint256 ID of the token to be approved\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * Gets the approved address for a token ID, or zero if no address set\n * @dev Reverts if the token ID does not exist.\n * @param tokenId uint256 ID of the token to query the approval of\n * @return operator address currently approved for the given token ID\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * Sets or unsets the approval of a given operator\n * @dev An operator is allowed to transfer all tokens of the sender on their behalf\n * @param operator operator address to set the approval\n * @param approved representing the status of the approval to be set\n */\n function setApprovalForAll(address operator, bool approved) external;\n\n /**\n * Tells whether an operator is approved by a given owner\n * @param owner owner address which you want to query the approval of\n * @param operator operator address which you want to query the approval of\n * @return bool whether the given operator is approved by the given owner\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n /**\n * Transfers the ownership of a given token ID to another address\n * @dev Usage of this method is discouraged, use `safeTransferFrom` whenever possible\n * @dev Requires the msg sender to be the owner, approved, or operator\n * @param from current owner of the token\n * @param to address to receive the ownership of the given token ID\n * @param tokenId uint256 ID of the token to be transferred\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * Safely transfers the ownership of a given token ID to another address\n *\n * If the target address is a contract, it must implement `onERC721Received`,\n * which is called upon a safe transfer, and return the magic value\n * `bytes4(keccak256(\"onERC721Received(address,address,uint256,bytes)\"))`; otherwise,\n * the transfer is reverted.\n *\n * @dev Requires the msg sender to be the owner, approved, or operator\n * @param from current owner of the token\n * @param to address to receive the ownership of the given token ID\n * @param tokenId uint256 ID of the token to be transferred\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * Safely transfers the ownership of a given token ID to another address\n *\n * If the target address is a contract, it must implement `onERC721Received`,\n * which is called upon a safe transfer, and return the magic value\n * `bytes4(keccak256(\"onERC721Received(address,address,uint256,bytes)\"))`; otherwise,\n * the transfer is reverted.\n *\n * @dev Requires the msg sender to be the owner, approved, or operator\n * @param from current owner of the token\n * @param to address to receive the ownership of the given token ID\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes data to send along with a safe transfer check\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n}\n" }, "contracts/token/ERC721/interfaces/IERC721Events.sol": { "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.7.6 <0.8.0;\n\n/**\n * @title ERC721 Non-Fungible Token Standard, basic interface (events).\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n * @dev This interface only contains the standard events, see IERC721 for the functions.\n * @dev Note: The ERC-165 identifier for this interface is 0x80ac58cd.\n */\ninterface IERC721Events {\n event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);\n\n event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId);\n\n event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);\n}\n" }, "contracts/token/ERC721/interfaces/IERC721Receiver.sol": { "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.7.6 <0.8.0;\n\n/**\n * @title ERC721 Non-Fungible Token Standard, Tokens Receiver.\n * Interface for any contract that wants to support safeTransfers from ERC721 asset contracts.\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n * @dev Note: The ERC-165 identifier for this interface is 0x150b7a02.\n */\ninterface IERC721Receiver {\n /**\n * Handles the receipt of an NFT.\n * @dev The ERC721 smart contract calls this function on the recipient\n * after a {IERC721-safeTransferFrom}. This function MUST return the function selector,\n * otherwise the caller will revert the transaction. The selector to be\n * returned can be obtained as `this.onERC721Received.selector`. This\n * function MAY throw to revert and reject the transfer.\n * @dev Note: the ERC721 contract address is always the message sender.\n * @param operator The address which called `safeTransferFrom` function\n * @param from The address which previously owned the token\n * @param tokenId The NFT identifier which is being transferred\n * @param data Additional data with no specified format\n * @return bytes4 `bytes4(keccak256(\"onERC721Received(address,address,uint256,bytes)\"))`\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" }, "contracts/token/ERC721/interfaces/IERC721BatchTransfer.sol": { "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.7.6 <0.8.0;\n\n/**\n * @title ERC721 Non-Fungible Token Standard, optional extension: Batch Transfer.\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n * @dev Note: The ERC-165 identifier for this interface is 0xf3993d11.\n */\ninterface IERC721BatchTransfer {\n /**\n * Unsafely transfers a batch of tokens.\n * @dev Reverts if `to` is the zero address.\n * @dev Reverts if the sender is not approved.\n * @dev Reverts if one of `tokenIds` is not owned by `from`.\n * @dev Resets the token approval for each of `tokenIds`.\n * @dev Emits an {IERC721-Transfer} event for each of `tokenIds`.\n * @param from Current tokens owner.\n * @param to Address of the new token owner.\n * @param tokenIds Identifiers of the tokens to transfer.\n */\n function batchTransferFrom(\n address from,\n address to,\n uint256[] calldata tokenIds\n ) external;\n}\n" }, "contracts/token/ERC721/ERC721Simple.sol": { "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.7.6 <0.8.0;\n\nimport {AddressIsContract} from \"@animoca/ethereum-contracts-core/contracts/utils/types/AddressIsContract.sol\";\nimport {IERC165} from \"@animoca/ethereum-contracts-core/contracts/introspection/IERC165.sol\";\nimport {IERC721} from \"./interfaces/IERC721.sol\";\nimport {IERC721Events} from \"./interfaces/IERC721Events.sol\";\nimport {IERC721Receiver} from \"./interfaces/IERC721Receiver.sol\";\nimport {ManagedIdentity} from \"@animoca/ethereum-contracts-core/contracts/metatx/ManagedIdentity.sol\";\n\n/**\n * @title ERC721 Non Fungible Token Contract, simple implementation.\n */\ncontract ERC721Simple is ManagedIdentity, IERC165, IERC721, IERC721Events {\n using AddressIsContract for address;\n\n bytes4 internal constant _ERC721_RECEIVED = type(IERC721Receiver).interfaceId;\n\n uint256 internal constant _APPROVAL_BIT_TOKEN_OWNER_ = 1 << 160;\n\n /* owner => operator => approved */\n mapping(address => mapping(address => bool)) internal _operators;\n\n /* NFT ID => owner */\n mapping(uint256 => uint256) internal _owners;\n\n /* owner => NFT balance */\n mapping(address => uint256) internal _nftBalances;\n\n /* NFT ID => operator */\n mapping(uint256 => address) internal _nftApprovals;\n\n //======================================================= ERC165 ========================================================//\n\n /// @inheritdoc IERC165\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId || interfaceId == type(IERC721).interfaceId;\n }\n\n //======================================================= ERC721 ========================================================//\n\n /// @inheritdoc IERC721\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: zero address\");\n return _nftBalances[owner];\n }\n\n /// @inheritdoc IERC721\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = address(uint160(_owners[tokenId]));\n require(owner != address(0), \"ERC721: non-existing NFT\");\n return owner;\n }\n\n /// @inheritdoc IERC721\n function approve(address to, uint256 tokenId) public virtual override {\n uint256 owner = _owners[tokenId];\n require(owner != 0, \"ERC721: non-existing NFT\");\n address ownerAddress = address(uint160(owner));\n require(to != ownerAddress, \"ERC721: self-approval\");\n require(_isOperatable(ownerAddress, _msgSender()), \"ERC721: non-approved sender\");\n if (to == address(0)) {\n if (owner & _APPROVAL_BIT_TOKEN_OWNER_ != 0) {\n // remove the approval bit if it is present\n _owners[tokenId] = uint256(ownerAddress);\n }\n } else {\n uint256 ownerWithApprovalBit = owner | _APPROVAL_BIT_TOKEN_OWNER_;\n if (owner != ownerWithApprovalBit) {\n // add the approval bit if it is not present\n _owners[tokenId] = ownerWithApprovalBit;\n }\n _nftApprovals[tokenId] = to;\n }\n emit Approval(ownerAddress, to, tokenId);\n }\n\n /// @inheritdoc IERC721\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n uint256 owner = _owners[tokenId];\n require(address(uint160(owner)) != address(0), \"ERC721: non-existing