Added support to band, added formBand and disbandBand #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi there,
this is just a proposal to experiment with the concept of building blocks and how we could interact with core blocks to create new ones.
When I say "block" I mean
band
,artist
,venue
and so on.Proposal
A band should be formed by 5 members of different types.
You can form a band only when you own an artist of each type. After forming a band you can disband it.
Tests
I've created a
/test/band-test.js
where I'm testing only the "success" cases. I'll add more tests as soon as possible.Code implementation
Types.sol
I've added a
Role
enum, changing the Musicianrole
from string toRole
type. I need aRole
type to enforce check when you form a band. You can't (at least in this implementation) form a band of only singers. @Shpigford this is just a proposal, so feel free to suggest how a band should be formed, I only needed some type of hard limit for implementation/testI've added 5 new
uint
tokenId to theBand
type because I need to trace which artists are part of a BandI've updated the
MusicianRenderer
to properly render the newrole
type and I've updated themetadata-test.js
to correctly pass the test.I've added two methods to the main contract
formBand
anddisbandBand
. Maybe all this implementations could be exported inside an external contract that is inherited byRockburgNFT
to not have everything inside of it.formBand
When you form a
Band
you need to specify thename
,bandType
(like Blues, Jazz, Rock&Roll), and the tokenId of 5 artists that will perform in a band. Those artists must be owned by thesender
and need to be from each of the required types.If all the checks pass the contract is going to
transfer
the ownership of those artists to the Contract itself andmint
a newBand
associating the artistIds to the band members.At this point the
User
is not the owner of the artists anymore, this is needed to prevent him to transfer them (sell) to others while he still owns the band. If he wants he can transfer the wholeBand
.disbandBand
This is the inverse process of forming a band. I check if the user owners the band and if so I'm going to transfer all the artists back to his account (he could not be the original owner of the band, maybe he has sold that band to someone else).
After doing that we need to decide what to do with the band and I think that we have two options here @Shpigford @m1guelpf
disbanded
totrue
only for metadata/frontend display purposes. Maybe adding aformDate
anddisbandDate
just for fun.burn
the band deleting the NFT token and removing it from the_bands
mapping.ERC721Holder
I needed to add it in order to implement the
Implementation of the IERC721Receiver interface
. @m1guelpf I'm not a super expert here, just used it for another project I was implementing ("Unloot the Loot bags").This is needed to allow our own contract to accept transfers. Maybe we could skip this if we use the internal
_transfer
instead of thesafeTransferFrom
?Why have I used
_transfer
instead ofsafeTransferFrom
indisbandBand
?the
safeTransferFrom
implementation is checking that themsg.sender
(the user) is the owner of the token or has the approval to transfer it. In this case, thefrom
part of thesafeTransferFrom
is the contract itself. It seems that this function was not meant to be used internally when the NFT Contract is also the sender so I used the_transfer
directly.I don't know if this is the best implementation but I've already asked around about it so I'll wait for an answer on this topic.
Feedback?
What do you think?