mattlockyer / composables-998

An implementation and documentation repo for developing the ERC-998 standard for Ethereum.
MIT License
103 stars 64 forks source link

Improvements and Consolidated Code and Ideas Between Bottom-Up and Top-Down #18

Closed mudgen closed 6 years ago

mudgen commented 6 years ago

Major changes:

  1. Removed OpenZeppelin's implementation of ERC721 from the top-down composable implementation and added my own implementation. I needed to do this because the ownerOf function from ERC721 needed to work differently and authentication works differently.
  2. In both top-down and bottom-up implementations the ownerOf(uint256 _tokenId) function returns the owner address at the top of the tree of composables (rootOwner), not the immediate owner of the supplied token.
  3. In both top-down and bottom-up implementations the tokenOwnerOf(uint256 _tokenId) function returns the parent token contract and parent tokenId.
  4. The onERC998RemovedChild(address _operator, address _toContract, uint256 _tokenId, bytes _data) callback function was added. Contracts that are composable aware must call onERC998RemovedChild in safeTransferFrom functions on the _from address if it is a contract.
  5. In both top-down and bottom-up implementations authentication is done by finding the rootOwner with ownerOf(uint256 _tokenId) and comparing that to msg.sender and getApproved and isApprovedForAll and also comparing these to the immediate owner.