-
Notifications
You must be signed in to change notification settings - Fork 11.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial ERC1155 implementation with some tests #1803
Initial ERC1155 implementation with some tests #1803
Conversation
Hello @cag, thank you very much for this! Reviewing this PR will probably take a while, since there's quite a bit of code, and we need to figure out a reasonable API to provide. I noticed the implementation by enjin is licensed under Apache v2, whereas we use MIT. We may want to check with them that it is fine to re-license their work to distribute under OpenZeppelin, though I'm not sure to what extent that applies to something like this, where the specification is quite clear-cut regarding what needs to be done. |
Hi all! |
Hey there. It's taking a while for me to get some free time to look at this, but I'll come back to it. |
Hi all! |
Okay, the tests should be complete for the basic setup now. Cheers! |
Any update on this PR? I would like to leverage OpenZepplin in my build, but can't stay on hold indefinitely. |
We're in the process of reviewing this. 🙂 Expect a review from @andresbach from the OpenZeppelin team in a few days! |
Awesome! Thanks!
…On Wed, Aug 7, 2019, 11:41 AM Francisco Giordano ***@***.***> wrote:
We're in the process of reviewing this. 🙂 Expect a review from
@andresbach <https://github.com/andresbach> from the OpenZeppelin team in
a few days!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1803?email_source=notifications&email_token=AAUDVIMLQA6MFRRH2OKSSKLQDMJOZA5CNFSM4HZENLO2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3ZK4SI#issuecomment-519220809>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAUDVIL6DWN2Z75EY2QUTCTQDMJOZANCNFSM4HZENLOQ>
.
|
Hi all! |
Hi folks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* See https://eips.ethereum.org/EIPS/eip-1155 | ||
* Originally based on code by Enjin: https://github.com/enjin/erc-1155 | ||
*/ | ||
contract ERC1155 is ERC165, IERC1155 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of the contracts are missing, such as the one for the metadata and the one for the URI functions. Are those going to be implemented in another stage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not seek to implement those contracts, since we don't know how these features really should work because we don't use them, and didn't plan on using them. These should be added by somebody with more knowledge/use for those features.
Hi all! |
I’ve reached out to the authors of ERC1155 as would be great to get their assistance. |
SafeMath.sub with custom error message is not yet released AFAIK, not in 2.3 at least. |
Hi all! |
Hi everyone. We haven't had the time to do a second review of the code in this PR, which is something we have to do for such a big feature before releasing it. However, we don't want to delay merging this PR any longer so we're merging it into a feature branch. If you're interested in getting this feature released as soon as possible, please help us by reviewing the code and posting your results in an issue or in the forum. We will also be doing our own review and may create an issue with a list of things that need work, where help will also be appreciated. Sorry for taking so long with this and thank you for the great work @cag! |
We're completely fine with re-licensing your implementation with the MIT license. |
I'm trying to use the contracts for a project right now, and I just realized that - compared to other OpenZeppelin token implementations - there is no internal _transferFrom() function (or similar) in those, which makes it harder for us to override something so we can intercept a transfer and e.g. maintain a "totalSupply"-like counter when something is transferred to/from 0x0, or put some restrictions on transfers via custom logic or similar side-effects - and the external public unctions do not allow overrides that call the inherited code via super.safeTransferFrom(), for example. |
@KaiRo-at Agree! Would you like to open a PR making the functions |
I think it would be even better to abstract the actual transfer into an internal function like e.g. ERC20 and ERC721 OpenZeppelin implementations do. They also have the beauty of having a single internal function for all variants of transfers, which is harder here as single and batch emit different events, so I'm not 100% sure yet how to do this in the best way. |
Another thing I just noticed is that this PR contains a URI() event in the interface, but nothing using it or anything else related to URIs, so either the event should be removed or the implementation using it some way. Though actually, this may be a bug in the ERC itself, as that even should belong to the "interface ERC1155Metadata_URI" definition in there, I guess... See ethereum/EIPs#1155 (comment) |
* Initial ERC1155 implementation with some tests * Remove mocked isERC1155TokenReceiver * Revert reason edit nit * Remove parameters associated with isERC1155TokenReceiver call * Add tests for approvals and single transfers * Add tests for transferring to contracts * Add tests for batch transfers * Make expectEvent.inTransaction tests async * Renamed "owner" to "account" and "holder" * Document unspecified balanceOfBatch reversion on zero behavior * Ensure accounts can't set their own operator status * Specify descriptive messages for underflow errors * Bring SafeMath.add calls in line with OZ style * Explicitly prevent _burn on the zero account * Implement batch minting/burning * Refactored operator approval check into isApprovedForAll calls * Renamed ERC1155TokenReceiver to ERC1155Receiver * Added ERC1155Holder * Fix lint issues
* Initial ERC1155 implementation with some tests * Remove mocked isERC1155TokenReceiver * Revert reason edit nit * Remove parameters associated with isERC1155TokenReceiver call * Add tests for approvals and single transfers * Add tests for transferring to contracts * Add tests for batch transfers * Make expectEvent.inTransaction tests async * Renamed "owner" to "account" and "holder" * Document unspecified balanceOfBatch reversion on zero behavior * Ensure accounts can't set their own operator status * Specify descriptive messages for underflow errors * Bring SafeMath.add calls in line with OZ style * Explicitly prevent _burn on the zero account * Implement batch minting/burning * Refactored operator approval check into isApprovedForAll calls * Renamed ERC1155TokenReceiver to ERC1155Receiver * Added ERC1155Holder * Fix lint issues
* Initial ERC1155 implementation with some tests (#1803) * Initial ERC1155 implementation with some tests * Remove mocked isERC1155TokenReceiver * Revert reason edit nit * Remove parameters associated with isERC1155TokenReceiver call * Add tests for approvals and single transfers * Add tests for transferring to contracts * Add tests for batch transfers * Make expectEvent.inTransaction tests async * Renamed "owner" to "account" and "holder" * Document unspecified balanceOfBatch reversion on zero behavior * Ensure accounts can't set their own operator status * Specify descriptive messages for underflow errors * Bring SafeMath.add calls in line with OZ style * Explicitly prevent _burn on the zero account * Implement batch minting/burning * Refactored operator approval check into isApprovedForAll calls * Renamed ERC1155TokenReceiver to ERC1155Receiver * Added ERC1155Holder * Fix lint issues * Migrate tests to @openzeppelin/test-environment * Port ERC 1155 branch to Solidity 0.6 (and current master) (#2130) * port ERC1155 to Solidity 0.6 * make ERC1155 constructor more similar to ERC721 one * also migrate mock contracts to Solidity 0.6 * mark all non-view functions as virtual Co-authored-by: Alan Lu <[email protected]> Co-authored-by: Nicolás Venturo <[email protected]> Co-authored-by: Robert Kaiser <[email protected]>
…2029) * Initial ERC1155 implementation with some tests (#1803) * Initial ERC1155 implementation with some tests * Remove mocked isERC1155TokenReceiver * Revert reason edit nit * Remove parameters associated with isERC1155TokenReceiver call * Add tests for approvals and single transfers * Add tests for transferring to contracts * Add tests for batch transfers * Make expectEvent.inTransaction tests async * Renamed "owner" to "account" and "holder" * Document unspecified balanceOfBatch reversion on zero behavior * Ensure accounts can't set their own operator status * Specify descriptive messages for underflow errors * Bring SafeMath.add calls in line with OZ style * Explicitly prevent _burn on the zero account * Implement batch minting/burning * Refactored operator approval check into isApprovedForAll calls * Renamed ERC1155TokenReceiver to ERC1155Receiver * Added ERC1155Holder * Fix lint issues * Migrate tests to @openzeppelin/test-environment * port ERC1155 to Solidity 0.6 * make ERC1155 constructor more similar to ERC721 one * also migrate mock contracts to Solidity 0.6 * mark all non-view functions as virtual * add simple catch-all implementation for the metadata URI interface * include an internal function to set the URI so users can implement functionality to switch URIs * add tests for ERC1155 metadata URI * fix nits, mostly pointed out by linter * convert ERC1155 metadata URI work to Solidity 0.6 * mark all non-view functions as virtual * Port ERC 1155 branch to Solidity 0.6 (and current master) (#2130) * port ERC1155 to Solidity 0.6 * make ERC1155 constructor more similar to ERC721 one * also migrate mock contracts to Solidity 0.6 * mark all non-view functions as virtual * Update contracts/token/ERC1155/IERC1155MetadataURI.sol Starting on Solidity v0.6.2, interfaces can now inherit. \o/ Co-authored-by: Nicolás Venturo <[email protected]> * Fix compile errors * Remove URI event * Merge MetadataCatchAll into ERC1155 * Improve documentation. * Simplify tests * Move tests into ERC1155 tests * Update documentation * Bump minimum compiler version for inteface inheritance * Fix holder tests * Improve setUri docs * Fix docs generation Co-authored-by: Alan Lu <[email protected]> Co-authored-by: Nicolás Venturo <[email protected]> Co-authored-by: Francisco Giordano <[email protected]>
Fixes #1728
Implements ERC-1155.