Right now, the code assumes that the slot after a burnt slot will always be initialized.
These code changes allow for efficient bulk burning by allowing the slots after a burnt slot to remain uninitialized:
simply set the burn bit of the starting slot to true, and the rest of the uninitialized slots will be considered burnt.
For now, the batch burning logic is not included due to it's complexity.
It is left to the developer to implement their batch burning logic.
This does not affect how the storage slots are written, and will not cause a breaking change.
It simply makes the ownership reading logic able to handle lazy batch burning, which is a superset of what the current code can do.
Changes:
ERC721A
New internal _ownershipIsInitialized function. This is for the ERC721AQueryable extension to easily find the previous initialized slot.
The _packedOwnershipOf function will now revert if the slot before an uninitialized slot is burned. Also, reordered the checks for to keep runtime gas costs the same.
ERC721AQueryable
Changed tokensOfOwner to use the tokensOfOwnerIn logic. This is for smaller bytecode and reduced code duplication -- we don't need best runtime gas for these external query functions. Also, the tokensOfOwnerIn logic requires less modifications to make it capable of handling the uninitialized slots after a burn slot.
Right now, the code assumes that the slot after a burnt slot will always be initialized.
These code changes allow for efficient bulk burning by allowing the slots after a burnt slot to remain uninitialized: simply set the burn bit of the starting slot to true, and the rest of the uninitialized slots will be considered burnt.
For now, the batch burning logic is not included due to it's complexity. It is left to the developer to implement their batch burning logic.
This does not affect how the storage slots are written, and will not cause a breaking change. It simply makes the ownership reading logic able to handle lazy batch burning, which is a superset of what the current code can do.
Changes:
_ownershipIsInitialized
function. This is for the ERC721AQueryable extension to easily find the previous initialized slot._packedOwnershipOf
function will now revert if the slot before an uninitialized slot is burned. Also, reordered the checks for to keep runtime gas costs the same.tokensOfOwner
to use thetokensOfOwnerIn
logic. This is for smaller bytecode and reduced code duplication -- we don't need best runtime gas for these external query functions. Also, thetokensOfOwnerIn
logic requires less modifications to make it capable of handling the uninitialized slots after a burn slot.