-
Notifications
You must be signed in to change notification settings - Fork 842
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
Add function to directly set extra data #336
Add function to directly set extra data #336
Conversation
/** | ||
* @dev Directly sets the extra data for the ownership data `index`. | ||
*/ | ||
function _setExtraDataAt(uint256 index, uint24 extraData) internal { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessarily specific to this PR, but we use index
and tokenId
to access _packedOwnerships. We should probably make these consistent in a a future PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
index
refers to something that may not be initialized, and will expose the user to the underlying logic.
tokenId
refers to something that is initialized.
assembly { | ||
extraDataCasted := extraData | ||
} | ||
packed = (packed & BITMASK_EXTRA_DATA_COMPLEMENT) | (extraDataCasted << BITPOS_EXTRA_DATA); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, is this cheaper to do in assembly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. That's why I removed it.
In case people want to use the extra data to store the type of token.
Changes:
_setAux
function body to be consistent with the function body of_setExtraDataAt
._nextExtraData
private. Forgot to make it private previously.previousExtraData
toextraData
.Cuz there is another variable called
prevPackedOwnership
, and this triggers OCD.