Created
November 1, 2022 11:04
-
-
Save prajwolrg/5145eb6b7f934783c92efb07016c6833 to your computer and use it in GitHub Desktop.
Add child
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 addChild(uint256 parentTokenId, uint256 childTokenId) | |
public | |
virtual | |
{ | |
_requireMinted(parentTokenId); | |
if (!_msgSender().isContract()) revert RMRKIsNotContract(); | |
Child memory child = Child({ | |
contractAddress: _msgSender(), | |
tokenId: childTokenId | |
}); | |
uint256 length = pendingChildrenOf(parentTokenId).length; | |
if (length < 128) { | |
_childIsInPending[child.contractAddress][child.tokenId] = 1; // We use 1 as true | |
_pendingChildren[parentTokenId].push(child); | |
} else { | |
revert RMRKMaxPendingChildrenReached(); | |
} | |
// Previous length matches the index for the new child | |
emit ChildProposed(parentTokenId, _msgSender(), childTokenId, length); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment