Skip to content
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

Attachments #357

Closed
alxocity opened this issue Aug 28, 2020 · 7 comments
Closed

Attachments #357

alxocity opened this issue Aug 28, 2020 · 7 comments

Comments

@alxocity
Copy link

Issue To Be Solved

Ability to extend a resource without updating the resource contract.

Suggest A Solution

Essentially this, but in Cadence/Flow:
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/extension-methods

Context

This would allow adding Autographs to NBA TopShot moments, and generically adding resources to other resources without editing the parent resource contract. This would open up full personalization for anyone's NFTs. https://discord.gg/mCtsWyS

@bjartek
Copy link
Contributor

bjartek commented Aug 29, 2020

There are lots of interesting use cases that could emerge here.

  • Signing (like moment i guess)?
  • Original Artist
  • Suggested Original Artist resell cut (a marketplace could use this to send a small amount of cash to the oringal artist on resale)
  • Ownership trail

@alxocity
Copy link
Author

alxocity commented Aug 30, 2020

Here's an example of modifying the Top Shot contract to support autographs that would be preferably done via extensions instead of editing the original contract:
https://github.com/Flow-Moment-Company/flow-moment-contracts/blob/master/contracts/nba/TopShot.cdc (find "autograph" in file to see extension points)

@alxocity
Copy link
Author

This commit in particular highlights the autographs extensibility that could instead be done outside of the Top Shot contract
Flow-Moment-Company/flow-moment-contracts@5924d24

@bjartek
Copy link
Contributor

bjartek commented Aug 30, 2020

Could mixins be used to model this? If a mixin is stored in another account? And you could say i want

Topshot.NFT with Moment.Autograph

There has to be some guidelines to what could be done in a mixin then i guess. Maybe you should only get a reference to the parent.

@rheaplex
Copy link
Contributor

rheaplex commented Oct 5, 2020

An important issue with smart contract code rather than application code is that extending it can be used to introduce attacks. While extension methods cannot replace existing methods and perform a person-in-the-middle attack, they can add new functions that use existing code and member variables in ways that lead to undesirable results for the user. IMO it's important to look at what any proposal takes from the security of the system as well as what it adds to its expressiveness.

@turbolent
Copy link
Member

Thank you @alxocity and everyone else for starting this discussion! Extensions have been on our roadmap since the beginning, and we're excited to work on this.

I had a call with @alxocity last Friday, and started a new topic in the forum to discuss this further: https://forum.onflow.org/t/extensibility/622

Please have a look and please share your thoughts! Hopefully we can discuss this together, come up with a proposal, and get it implemented 🚀

I'm also very happy to set up another call with more people who are interested to answer the open questions and work out a proposal. Please let me know!

@dsainati1
Copy link
Contributor

The core attachments proposal has been implemented and merged into a feature branch, hopefully to come to master soon.

The portion of the proposal that originally included iteration will be handled separately in the future, tracked in the issue here: #2193

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants