-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Add ERC1155URIStorage #3210
Add ERC1155URIStorage #3210
Conversation
Add ERC721URIStorage-like extension for ERC1155
Hello @takahser You are depending on |
This is because this extension depends on the ' |
I'd personnally remove the @frangio any opinion on that ? |
This has come up before. Perhaps For now I'm ok with dropping the exists check in this PR. |
I don't think it's right to use So, someone could set global URI as I think the base URI mechanism we have in ERC721 makes less sense here because there is already a built in base URI-like mechanism built into the ERC. So just the global URI plus a storage-based override sounds like enough. |
@frangio In that case, the following scenario wouldn't be supported:
|
If we want that behavior, I think we need a separate You may as well just set uri to |
Well, don't we already have a // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
string private _uri;
While I agree that this should be sufficient in most cases, there might be some edge cases where you'd want to have this extra flexibility, e.g. because you have to support a legacy system. Or maybe you want to have different locations on the same base uri for different categories of NFTs. I'm sure there will be more edge cases. |
ERC1155 includes a "base" variable ( IMO, for naming consistency, the setter in ERC155URIStorage should probably be |
The problem I see with that approach is that it'd make it impossible to change the base /**
* @dev See {_setURI}.
*/
constructor(string memory uri_) {
_setURI(uri_);
} |
Why would it make impossible to change the base URI ?
|
@Amxx Apologies, for some reason, I ignored the fact that the two methods have different signatures. Ofc you're right, I updated the PR. 👍 |
We could possibly write this override mechanism as
IMO that would fit most usecases I see, and would make it simpler to have a default uri. @takahser what do you think? |
@Amxx tbh I'd prefer the current implementation since it supports combining the |
Well, technically, if you wanted to concatenate both you could do that.
@frangio might say this is terrible, and I would agree, but its technically possible. This point is that, if the "override" is concatenated to the base, that has a strong restriction on the base, and it basically kills the possibility of having a usefull base, that would have a real meaning even when it is not overridden with token specific info. |
Not that ERC721 is designed differently, because the super call (if In ERC1155, this is achieved through the use of |
Sorry, you lost me there. Would you mind elaborating on that using an example? |
If we want concatenation, we need a separate @takahser Feel free to implement either of these options but please do not use |
@frangio that actually sounds logical to me. I'm going to implement the 2nd suggestion you made (separate base URI). 👍 |
The super call on line 42 should be done on line 50, in the return. We don't want to have to pay for it if it turns out it's not needed. @frangio do you like this baseUri mechanism, considering it is not used by the core erc1155 ? |
Thx guys! |
Thanks for your work and your patience |
Fixes #3206
ERC1155
calledERC1155URIStorage
that implements aERC721
-style_setTokenURI
andtokenURI
behaviors.PR Checklist