Skip to content

Instantly share code, notes, and snippets.

@prajwolrg
Last active November 1, 2022 08:52
Show Gist options
  • Save prajwolrg/bf2431b0b7e122ba8aaca9271ab3966a to your computer and use it in GitHub Desktop.
Save prajwolrg/bf2431b0b7e122ba8aaca9271ab3966a to your computer and use it in GitHub Desktop.
RMRK nestTransfer function
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