You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're currently exposing _addTokenTo and _removeTokenFrom due to language limitations, despite them not being useful due to incomplete behavior (e.g. no events are emitted). We do have a comment describing this and discouraging their usage, which IMO is enough to not consider them part of the API. We should get rid of these functions soon.
Once #1539 is merged, they won't be necessary anymore, since they can be inlined in _mint and _burn (which are the actual API functions).
In #839@frangio and I discussed not being sure of why setting a field to 0 in _removeTokenFrom wasn't making the whole transaction cheaper.
I finally understood this: we were measuring the gas cost of transfer, which calls _remove followed by _add. That last call sets _ownedTokensIndex again, which prevents the refund from being issued (which wouldn't make any sense - otherwise all SSTORE calls would be cheaper if preceded by another SSTORE clearing that slot).
So if this assignment is removed, transfer will be cheaper, but burn more expensive. Given this, I'd still advocate for getting rid of _removeTokenFrom, and clearing the storage slot in _burn.
We're currently exposing
_addTokenTo
and_removeTokenFrom
due to language limitations, despite them not being useful due to incomplete behavior (e.g. no events are emitted). We do have a comment describing this and discouraging their usage, which IMO is enough to not consider them part of the API. We should get rid of these functions soon.Once #1539 is merged, they won't be necessary anymore, since they can be inlined in
_mint
and_burn
(which are the actual API functions).Additionally, I advocate for removing some of the cleanup done in
_removeTokenFrom
, since it doesn't really help to prevent bugs.This may be a last minute inclusion for 2.1, if there's enough time.
The text was updated successfully, but these errors were encountered: