Skip to content

Multiwrap: using thirdweb-dev/contracts/feature/ #160

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

Merged
merged 29 commits into from
May 20, 2022
Merged

Conversation

kumaryash90
Copy link
Member

No description provided.

@kumaryash90 kumaryash90 requested a review from nkrishang May 4, 2022 18:36
@kumaryash90 kumaryash90 self-assigned this May 4, 2022
@@ -4,5 +4,47 @@ pragma solidity ^0.8.0;
import "./interface/ITokenBundle.sol";

abstract contract TokenBundle is ITokenBundle {
uint256 public nextTokenIdToMint;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to have opinionated handling of token IDs in our sdk features. We leave the handling of tokenIds to the top level contract that will be inheriting this TokenBundle feature e.g. Multiwrap in this case.

The reason for the above:

  • Folks have product level preferences of how token IDs should be handled. We shouldn't make the assumption for the end user that token Ids will be assigned serially.
  • The TokenBundle contract should not have special / privileged status as the base contract that's going to specify how token IDs will work.


function _getNextTokenId() internal returns (uint256 nextTokenId) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the comments for token ID handling w.r.t nextTokenIdToMint.

Since we want to hand off token Id handling to the derived contract e.g. Multiwrap, a function like _getNextTokenId() should be exposed as a virtual function, so that the derived contract can override it and supply the right values to this function. What do you think about that?

One question is -- conceptually, does TokenBundle have anything to do with "token IDs"? Why can't _getNextTokenId be _getIdForNewBundle? That is, let the user choose whether the identifier of a bundle is a token Id or not.

Think of the potential use cases for TokenBundle. I don't think it's limited to contracts like Multiwrap that issue NFTs (i.e. token IDs) for a token bundle.

I can see TokenBundle being used in a simple escrow contract, or even in a DeFi contract, since the main utility that i see TokenBundle providing is a generic + compressed way of describing a list of tokens. This has a wide range of uses.

Copy link
Member Author

@kumaryash90 kumaryash90 May 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, makes sense. I like the virtual function idea.

I have added a bundleId variable and removed any tokenId association; leaving it to the top-level contract to map their tokenId with bundleId. Modified related functions accordingly, in both TempMultiwrap and TokenBundle contracts.

For now, I've added some sanity checks while creating/updating/deleting bundles. These can be removed if we assume that the top-level contract will take care of these.

I was wondering if it would be logical to bring any token transfer functions inside TokenBundle contract, since creation/deletion of a bundle would almost always require transfer of underlying tokens.

For now, I've kept the getNextTokenId() virtual function as a comment inside TokenBundle.

@nkrishang nkrishang changed the title Yash/multiwrap Multiwrap: using thirdweb-dev/contracts/features/ May 20, 2022
@nkrishang nkrishang changed the title Multiwrap: using thirdweb-dev/contracts/features/ Multiwrap: using thirdweb-dev/contracts/feature/ May 20, 2022
@nkrishang nkrishang merged commit c886fd4 into main May 20, 2022
@nkrishang nkrishang deleted the yash/multiwrap branch May 24, 2022 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants