Skip to content

Commit 6e260f2

Browse files
authored
Remove DefaultOperatorFilterer (#508)
* Remove DefaultOperatorFilterer removed from all contracts except dynamic contracts. * Remove DefaultOperatorFilterer - dynamic contracts * lint * remove DefaultOperatorFilterer extension * Clean natspec * natspec updates --------- Signed-off-by: WhiteOakKong <[email protected]>
1 parent 6b6e567 commit 6e260f2

23 files changed

+219
-956
lines changed

contracts/base/ERC1155Base.sol

Lines changed: 17 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import "../extension/Multicall.sol";
1010
import "../extension/Ownable.sol";
1111
import "../extension/Royalty.sol";
1212
import "../extension/BatchMintMetadata.sol";
13-
import "../extension/DefaultOperatorFilterer.sol";
1413

1514
import "../lib/TWStrings.sol";
1615

@@ -31,15 +30,7 @@ import "../lib/TWStrings.sol";
3130
* - EIP 2981 compliance for royalty support on NFT marketplaces.
3231
*/
3332

34-
contract ERC1155Base is
35-
ERC1155,
36-
ContractMetadata,
37-
Ownable,
38-
Royalty,
39-
Multicall,
40-
BatchMintMetadata,
41-
DefaultOperatorFilterer
42-
{
33+
contract ERC1155Base is ERC1155, ContractMetadata, Ownable, Royalty, Multicall, BatchMintMetadata {
4334
using TWStrings for uint256;
4435

4536
/*//////////////////////////////////////////////////////////////
@@ -72,14 +63,15 @@ contract ERC1155Base is
7263
) ERC1155(_name, _symbol) {
7364
_setupOwner(_defaultAdmin);
7465
_setupDefaultRoyaltyInfo(_royaltyRecipient, _royaltyBps);
75-
_setOperatorRestriction(true);
7666
}
7767

7868
/*//////////////////////////////////////////////////////////////
7969
Overriden metadata logic
8070
//////////////////////////////////////////////////////////////*/
8171

8272
/// @notice Returns the metadata URI for the given tokenId.
73+
/// @param _tokenId The tokenId of the token for which a URI should be returned.
74+
/// @return The metadata URI for the given tokenId.
8375
function uri(uint256 _tokenId) public view virtual override returns (string memory) {
8476
string memory uriForToken = _uri[_tokenId];
8577
if (bytes(uriForToken).length > 0) {
@@ -222,7 +214,10 @@ contract ERC1155Base is
222214
ERC165 Logic
223215
//////////////////////////////////////////////////////////////*/
224216

225-
/// @notice Returns whether this contract supports the given interface.
217+
/**
218+
* @dev See ERC165: https://eips.ethereum.org/EIPS/eip-165
219+
* @inheritdoc IERC165
220+
*/
226221
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC1155, IERC165) returns (bool) {
227222
return
228223
interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
@@ -240,76 +235,41 @@ contract ERC1155Base is
240235
return nextTokenIdToMint_;
241236
}
242237

243-
/*//////////////////////////////////////////////////////////////
244-
ERC-1155 overrides
245-
//////////////////////////////////////////////////////////////*/
246-
247-
/// @dev See {ERC1155-setApprovalForAll}
248-
function setApprovalForAll(address operator, bool approved)
249-
public
250-
virtual
251-
override(ERC1155)
252-
onlyAllowedOperatorApproval(operator)
253-
{
254-
super.setApprovalForAll(operator, approved);
255-
}
256-
257-
/**
258-
* @dev See {IERC1155-safeTransferFrom}.
259-
*/
260-
function safeTransferFrom(
261-
address from,
262-
address to,
263-
uint256 id,
264-
uint256 amount,
265-
bytes memory data
266-
) public virtual override(ERC1155) onlyAllowedOperator(from) {
267-
super.safeTransferFrom(from, to, id, amount, data);
268-
}
269-
270-
/**
271-
* @dev See {IERC1155-safeBatchTransferFrom}.
272-
*/
273-
function safeBatchTransferFrom(
274-
address from,
275-
address to,
276-
uint256[] memory ids,
277-
uint256[] memory amounts,
278-
bytes memory data
279-
) public virtual override(ERC1155) onlyAllowedOperator(from) {
280-
super.safeBatchTransferFrom(from, to, ids, amounts, data);
281-
}
282-
283238
/*//////////////////////////////////////////////////////////////
284239
Internal (overrideable) functions
285240
//////////////////////////////////////////////////////////////*/
286241

287242
/// @dev Returns whether contract metadata can be set in the given execution context.
243+
/// @return Whether contract metadata can be set in the given execution context.
288244
function _canSetContractURI() internal view virtual override returns (bool) {
289245
return msg.sender == owner();
290246
}
291247

292248
/// @dev Returns whether a token can be minted in the given execution context.
249+
/// @return Whether a token can be minted in the given execution context.
293250
function _canMint() internal view virtual returns (bool) {
294251
return msg.sender == owner();
295252
}
296253

297254
/// @dev Returns whether owner can be set in the given execution context.
255+
/// @return Whether owner can be set in the given execution context.
298256
function _canSetOwner() internal view virtual override returns (bool) {
299257
return msg.sender == owner();
300258
}
301259

302260
/// @dev Returns whether royalty info can be set in the given execution context.
261+
/// @return Whether royalty info can be set in the given execution context.
303262
function _canSetRoyaltyInfo() internal view virtual override returns (bool) {
304263
return msg.sender == owner();
305264
}
306265

307-
/// @dev Returns whether operator restriction can be set in the given execution context.
308-
function _canSetOperatorRestriction() internal virtual override returns (bool) {
309-
return msg.sender == owner();
310-
}
311-
312266
/// @dev Runs before every token transfer / mint / burn.
267+
/// @param operator The address of the caller.
268+
/// @param from The address of the sender.
269+
/// @param to The address of the recipient.
270+
/// @param ids The tokenIds of the tokens being transferred.
271+
/// @param amounts The amounts of the tokens being transferred.
272+
/// @param data Additional data with no specified format.
313273
function _beforeTokenTransfer(
314274
address operator,
315275
address from,

contracts/base/ERC1155Drop.sol

Lines changed: 53 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import "../extension/PrimarySale.sol";
1414
import "../extension/DropSinglePhase1155.sol";
1515
import "../extension/LazyMint.sol";
1616
import "../extension/DelayedReveal.sol";
17-
import "../extension/DefaultOperatorFilterer.sol";
1817

1918
import "../lib/CurrencyTransferLib.sol";
2019
import "../lib/TWStrings.sol";
@@ -52,8 +51,7 @@ contract ERC1155Drop is
5251
PrimarySale,
5352
LazyMint,
5453
DelayedReveal,
55-
DropSinglePhase1155,
56-
DefaultOperatorFilterer
54+
DropSinglePhase1155
5755
{
5856
using TWStrings for uint256;
5957

@@ -71,6 +69,16 @@ contract ERC1155Drop is
7169
Constructor
7270
//////////////////////////////////////////////////////////////*/
7371

72+
/**
73+
* @notice Initializes the contract with the given parameters.
74+
*
75+
* @param _defaultAdmin The default admin for the contract.
76+
* @param _name The name of the contract.
77+
* @param _symbol The symbol of the contract.
78+
* @param _royaltyRecipient The address to which royalties should be sent.
79+
* @param _royaltyBps The royalty basis points to be charged. Max = 10000 (10000 = 100%, 1000 = 10%)
80+
* @param _primarySaleRecipient The address to which primary sale revenue should be sent.
81+
*/
7482
constructor(
7583
address _defaultAdmin,
7684
string memory _name,
@@ -82,14 +90,16 @@ contract ERC1155Drop is
8290
_setupOwner(_defaultAdmin);
8391
_setupDefaultRoyaltyInfo(_royaltyRecipient, _royaltyBps);
8492
_setupPrimarySaleRecipient(_primarySaleRecipient);
85-
_setOperatorRestriction(true);
8693
}
8794

8895
/*//////////////////////////////////////////////////////////////
8996
ERC165 Logic
9097
//////////////////////////////////////////////////////////////*/
9198

92-
/// @notice Returns whether this contract supports the given interface.
99+
/**
100+
* @dev See ERC165: https://eips.ethereum.org/EIPS/eip-165
101+
* @inheritdoc IERC165
102+
*/
93103
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC1155, IERC165) returns (bool) {
94104
return
95105
interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
@@ -151,10 +161,11 @@ contract ERC1155Drop is
151161
//////////////////////////////////////////////////////////////*/
152162

153163
/**
154-
* @notice Returns the metadata URI for an NFT.
155-
* @dev See `BatchMintMetadata` for handling of metadata in this contract.
164+
* @notice Returns the metadata URI for an NFT.
165+
* @dev See `BatchMintMetadata` for handling of metadata in this contract.
156166
*
157-
* @param _tokenId The tokenId of an NFT.
167+
* @param _tokenId The tokenId of an NFT.
168+
* @return The metadata URI for the given NFT.
158169
*/
159170
function uri(uint256 _tokenId) public view virtual override returns (string memory) {
160171
(uint256 batchId, ) = _getBatchId(_tokenId);
@@ -174,8 +185,9 @@ contract ERC1155Drop is
174185
/**
175186
* @notice Lets an authorized address reveal a batch of delayed reveal NFTs.
176187
*
177-
* @param _index The ID for the batch of delayed-reveal NFTs to reveal.
178-
* @param _key The key with which the base URI for the relevant batch of NFTs was encrypted.
188+
* @param _index The ID for the batch of delayed-reveal NFTs to reveal.
189+
* @param _key The key with which the base URI for the relevant batch of NFTs was encrypted.
190+
* @return revealedURI The revealed URI for the batch of NFTs.
179191
*/
180192
function reveal(uint256 _index, bytes calldata _key) public virtual override returns (string memory revealedURI) {
181193
require(_canReveal(), "Not authorized");
@@ -222,51 +234,15 @@ contract ERC1155Drop is
222234
return nextTokenIdToLazyMint;
223235
}
224236

225-
/*//////////////////////////////////////////////////////////////
226-
ERC-1155 overrides
227-
//////////////////////////////////////////////////////////////*/
228-
229-
/// @dev See {ERC1155-setApprovalForAll}
230-
function setApprovalForAll(address operator, bool approved)
231-
public
232-
virtual
233-
override(ERC1155)
234-
onlyAllowedOperatorApproval(operator)
235-
{
236-
super.setApprovalForAll(operator, approved);
237-
}
238-
239-
/**
240-
* @dev See {IERC1155-safeTransferFrom}.
241-
*/
242-
function safeTransferFrom(
243-
address from,
244-
address to,
245-
uint256 id,
246-
uint256 amount,
247-
bytes memory data
248-
) public virtual override(ERC1155) onlyAllowedOperator(from) {
249-
super.safeTransferFrom(from, to, id, amount, data);
250-
}
251-
252-
/**
253-
* @dev See {IERC1155-safeBatchTransferFrom}.
254-
*/
255-
function safeBatchTransferFrom(
256-
address from,
257-
address to,
258-
uint256[] memory ids,
259-
uint256[] memory amounts,
260-
bytes memory data
261-
) public virtual override(ERC1155) onlyAllowedOperator(from) {
262-
super.safeBatchTransferFrom(from, to, ids, amounts, data);
263-
}
264-
265237
/*///////////////////////////////////////////////////////////////
266238
Internal functions
267239
//////////////////////////////////////////////////////////////*/
268240

269-
/// @dev Runs before every `claim` function call.
241+
/**
242+
* @dev Runs before every `claim` function call.
243+
*
244+
* @param _tokenId The tokenId of the NFT being claimed.
245+
*/
270246
function _beforeClaim(
271247
uint256 _tokenId,
272248
address,
@@ -281,7 +257,15 @@ contract ERC1155Drop is
281257
}
282258
}
283259

284-
/// @dev Collects and distributes the primary sale value of NFTs being claimed.
260+
/**
261+
* @dev Collects and distributes the primary sale value of NFTs being claimed.
262+
*
263+
* @param _primarySaleRecipient The address to which primary sale revenue should be sent.
264+
* @param _quantityToClaim The quantity of NFTs being claimed.
265+
* @param _currency The currency in which the NFTs are being sold.
266+
* @param _pricePerToken The price per NFT being claimed.
267+
*/
268+
285269
function _collectPriceOnClaim(
286270
address _primarySaleRecipient,
287271
uint256 _quantityToClaim,
@@ -307,7 +291,13 @@ contract ERC1155Drop is
307291
CurrencyTransferLib.transferCurrency(_currency, msg.sender, saleRecipient, totalPrice);
308292
}
309293

310-
/// @dev Transfers the NFTs being claimed.
294+
/**
295+
* @dev Transfers the NFTs being claimed.
296+
*
297+
* @param _to The address to which the NFTs are being transferred.
298+
* @param _tokenId The tokenId of the NFTs being claimed.
299+
* @param _quantityBeingClaimed The quantity of NFTs being claimed.
300+
*/
311301
function _transferTokensOnClaim(
312302
address _to,
313303
uint256 _tokenId,
@@ -316,7 +306,16 @@ contract ERC1155Drop is
316306
_mint(_to, _tokenId, _quantityBeingClaimed, "");
317307
}
318308

319-
/// @dev Runs before every token transfer / mint / burn.
309+
/**
310+
* @dev Runs before every token transfer / mint / burn.
311+
*
312+
* @param operator The address performing the token transfer.
313+
* @param from The address from which the token is being transferred.
314+
* @param to The address to which the token is being transferred.
315+
* @param ids The tokenIds of the tokens being transferred.
316+
* @param amounts The amounts of the tokens being transferred.
317+
* @param data Any additional data being passed in the token transfer.
318+
*/
320319
function _beforeTokenTransfer(
321320
address operator,
322321
address from,
@@ -370,11 +369,6 @@ contract ERC1155Drop is
370369
return msg.sender == owner();
371370
}
372371

373-
/// @dev Returns whether operator restriction can be set in the given execution context.
374-
function _canSetOperatorRestriction() internal virtual override returns (bool) {
375-
return msg.sender == owner();
376-
}
377-
378372
/// @dev Checks whether NFTs can be revealed in the given execution context.
379373
function _canReveal() internal view virtual returns (bool) {
380374
return msg.sender == owner();

0 commit comments

Comments
 (0)