-
Notifications
You must be signed in to change notification settings - Fork 842
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preparation for efficient consecutive burns (#447)
- Loading branch information
1 parent
eb4fad6
commit b97b199
Showing
11 changed files
with
185 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SPDX-License-Identifier: MIT | ||
// ERC721A Contracts v4.2.3 | ||
// Creators: Chiru Labs | ||
|
||
pragma solidity ^0.8.4; | ||
|
||
contract DirectBurnBitSetterHelper { | ||
function directSetBurnBit(uint256 index) public virtual { | ||
bytes32 erc721aDiamondStorageSlot = keccak256('openzepplin.contracts.storage.ERC721A'); | ||
|
||
// This is `_BITMASK_BURNED` from ERC721A. | ||
uint256 bitmaskBurned = 1 << 224; | ||
// We use assembly to directly access the private mapping. | ||
assembly { | ||
// The `_packedOwnerships` mapping is at slot 4. | ||
mstore(0x20, 4) | ||
mstore(0x00, index) | ||
let ownershipStorageSlot := keccak256(0x00, 0x40) | ||
sstore(ownershipStorageSlot, or(sload(ownershipStorageSlot), bitmaskBurned)) | ||
|
||
// For diamond storage, we'll simply add the offset of the layout struct. | ||
mstore(0x20, add(erc721aDiamondStorageSlot, 4)) | ||
mstore(0x00, index) | ||
ownershipStorageSlot := keccak256(0x00, 0x40) | ||
sstore(ownershipStorageSlot, or(sload(ownershipStorageSlot), bitmaskBurned)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters