Last active
November 1, 2022 08:52
-
-
Save prajwolrg/bf2431b0b7e122ba8aaca9271ab3966a to your computer and use it in GitHub Desktop.
RMRK nestTransfer function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.8.15; | |
function _nestTransfer( | |
address from, | |
address to, | |
uint256 tokenId, | |
uint256 destinationId | |
) internal virtual { | |
(address immediateOwner, , ) = rmrkOwnerOf(tokenId); | |
if (immediateOwner != from) revert ERC721TransferFromIncorrectOwner(); | |
if (to == address(0)) revert ERC721TransferToTheZeroAddress(); | |
if (to == address(this) && tokenId == destinationId) | |
revert RMRKNestingTransferToSelf(); | |
// Destination contract checks: | |
if (!to.isContract()) revert RMRKIsNotContract(); | |
if (!IERC165(to).supportsInterface(type(IRMRKNesting).interfaceId)) | |
revert RMRKNestingTransferToNonRMRKNestingImplementer(); | |
_checkForInheritanceLoop(tokenId, to, destinationId); | |
_beforeTokenTransfer(from, to, tokenId); | |
_balances[from] -= 1; | |
_updateOwnerAndClearApprovals(tokenId, destinationId, to, true); | |
_balances[to] += 1; | |
// Sending to NFT: | |
_sendToNFT(tokenId, destinationId, from, to); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment