sablier-labs / v2-core

⏳ Core smart contracts of the Sablier V2 token distribution protocol
https://sablier.com
Other
311 stars 47 forks source link

Emit ERC-4906 metadata updates in "transferFrom" #670

Closed PaulRBerg closed 1 year ago

PaulRBerg commented 1 year ago

The goal is to refresh the NFT SVG on platforms like OpenSea whenever the NFT is transferred around.

andreivladbrg commented 1 year ago

How should the implementation look like?

  1. emit an event only when transfer or transferFrom are called
  2. emit an event on transfer and also when burn and mint functions are called

Both versions require the implementation of _afterTokenTransfer hook. However, for the first version we would need to do similar as we did for _beforeTokenTransfer (checking for address(0)):

https://github.com/sablier-labs/v2-core/blob/d1ca26db69a92f174fe372a9643431efd1dcec1e/src/abstracts/SablierV2Lockup.sol#L332

PaulRBerg commented 1 year ago

Option 2, but note that transfer does not exist in ERC-721. Only transferFrom. I think you meant to say _transfer (notice the underscore)?

Yes, the implementation would go in _afterTokenTransfer. No need to check for the zero address in this case.