From cfed8272e60b1b26e72760e035af5eeab07d4b0b Mon Sep 17 00:00:00 2001 From: Ryan Ghods Date: Wed, 3 Jan 2024 15:56:46 -0800 Subject: [PATCH] add conduit preapproved --- src/ERC721ContractMetadata.sol | 6 +++-- src/lib/ERC721AConduitPreapproved.sol | 39 +++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 src/lib/ERC721AConduitPreapproved.sol diff --git a/src/ERC721ContractMetadata.sol b/src/ERC721ContractMetadata.sol index 559f4726..a8a25838 100644 --- a/src/ERC721ContractMetadata.sol +++ b/src/ERC721ContractMetadata.sol @@ -7,6 +7,8 @@ import { import { ERC721A } from "ERC721A/ERC721A.sol"; +import { ERC721AConduitPreapproved } from "./lib/ERC721AConduitPreapproved.sol"; + import { TwoStepOwnable } from "utility-contracts/TwoStepOwnable.sol"; import { IERC2981 } from "openzeppelin-contracts/interfaces/IERC2981.sol"; @@ -24,7 +26,7 @@ import { * with additional metadata and ownership capabilities. */ contract ERC721ContractMetadata is - ERC721A, + ERC721AConduitPreapproved, TwoStepOwnable, ISeaDropTokenContractMetadata { @@ -63,7 +65,7 @@ contract ERC721ContractMetadata is * @notice Deploy the token contract with its name and symbol. */ constructor(string memory name, string memory symbol) - ERC721A(name, symbol) + ERC721AConduitPreapproved(name, symbol) {} /** diff --git a/src/lib/ERC721AConduitPreapproved.sol b/src/lib/ERC721AConduitPreapproved.sol new file mode 100644 index 00000000..fdcd8288 --- /dev/null +++ b/src/lib/ERC721AConduitPreapproved.sol @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +import { ERC721A } from "ERC721A/ERC721A.sol"; + +/** + * @title ERC721AConduitPreapproved + * @notice ERC721A with the OpenSea conduit preapproved. + */ +abstract contract ERC721AConduitPreapproved is ERC721A { + /// @dev The canonical OpenSea conduit. + address internal constant _CONDUIT = + 0x1E0049783F008A0085193E00003D00cd54003c71; + + /** + * @notice Deploy the token contract. + * + * @param name The name of the token. + * @param symbol The symbol of the token. + */ + constructor( + string memory name, + string memory symbol + ) ERC721A(name, symbol) {} + + /** + * @dev Returns if the `operator` is allowed to manage all of the + * assets of `owner`. Always returns true for the conduit. + */ + function isApprovedForAll( + address owner, + address operator + ) public view virtual override returns (bool) { + if (operator == _CONDUIT) { + return true; + } + return ERC721A.isApprovedForAll(owner, operator); + } +} \ No newline at end of file