-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add transfer hook extension back into erc721a
- Loading branch information
Showing
3 changed files
with
65 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.10; | ||
|
||
interface ITransferHookExtension { | ||
function beforeTokenTransfers(address from, address to, uint256 startTokenId, uint256 quantity) external; | ||
function supportsInterface(bytes4 interfaceId) external returns (bool); | ||
} |
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,29 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.10; | ||
|
||
import {IERC721Drop} from "../interfaces/IERC721Drop.sol"; | ||
|
||
/// @custom:storage-location erc7201:zora.erc721drop.transferhook | ||
struct TransferHookStorage { | ||
address transferHookExtension; | ||
} | ||
|
||
contract ERC721TransferHookStorageV1 { | ||
error InvalidTransferHook(); | ||
event SetNewTransferHook(address _newTransferHook); | ||
|
||
// keccak256(abi.encode(uint256(keccak256("zora.erc721drop.transferhook")) - 1)) & ~bytes32(uint256(0xff)); | ||
bytes32 private constant TRANSFER_HOOK_STORAGE_LOCATION = | ||
0x7dd1076582dd9e0dc6a5073ed536c067f2e92ed46866d3076f6f2d9a5e36b400; | ||
|
||
function _getTransferHookStorage() internal pure returns (TransferHookStorage storage $) { | ||
assembly { | ||
$.slot := TRANSFER_HOOK_STORAGE_LOCATION | ||
} | ||
} | ||
|
||
function _setTransferHook(address _newTransferHook) internal { | ||
_getTransferHookStorage().transferHookExtension = _newTransferHook; | ||
emit SetNewTransferHook(_newTransferHook); | ||
} | ||
} |