Skip to content

Commit

Permalink
Switch DefaultOperatorFilterer to UpdatableOperatorFilterer (#100)
Browse files Browse the repository at this point in the history
* Switch DefaultOperatorFilterer to UpdatableOperatorFilterer

* update ME_SUBSCRIPTION
  • Loading branch information
channing-magiceden authored Dec 21, 2023
1 parent 16137be commit ef57c3f
Show file tree
Hide file tree
Showing 29 changed files with 784 additions and 367 deletions.
22 changes: 20 additions & 2 deletions contracts/BucketAuctionOperatorFilterer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
pragma solidity ^0.8.4;

import "./BucketAuction.sol";
import "./OperatorFilter/DefaultOperatorFilterer.sol";
import {UpdatableOperatorFilterer} from "operator-filter-registry/src/UpdatableOperatorFilterer.sol";
import {CANONICAL_OPERATOR_FILTER_REGISTRY_ADDRESS, ME_SUBSCRIPTION} from "./utils/Constants.sol";

contract BucketAuctionOperatorFilterer is BucketAuction, DefaultOperatorFilterer {
contract BucketAuctionOperatorFilterer is
BucketAuction,
UpdatableOperatorFilterer
{
constructor(
string memory collectionName,
string memory collectionSymbol,
Expand All @@ -17,6 +21,11 @@ contract BucketAuctionOperatorFilterer is BucketAuction, DefaultOperatorFilterer
uint64 startTimeUnixSeconds,
uint64 endTimeUnixSeconds
)
UpdatableOperatorFilterer(
CANONICAL_OPERATOR_FILTER_REGISTRY_ADDRESS,
ME_SUBSCRIPTION,
true
)
BucketAuction(
collectionName,
collectionSymbol,
Expand All @@ -30,6 +39,15 @@ contract BucketAuctionOperatorFilterer is BucketAuction, DefaultOperatorFilterer
)
{}

function owner()
public
view
override(Ownable, UpdatableOperatorFilterer)
returns (address)
{
return Ownable.owner();
}

function transferFrom(
address from,
address to,
Expand Down
16 changes: 11 additions & 5 deletions contracts/ERC721M.sol
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ contract ERC721M is IERC721M, ERC721AQueryable, Ownable, ReentrancyGuard {
if (i >= 1) {
if (
newStages[i].startTimeUnixSeconds <
newStages[i - 1].endTimeUnixSeconds + _timestampExpirySeconds
newStages[i - 1].endTimeUnixSeconds +
_timestampExpirySeconds
) {
revert InsufficientStageTimeGap();
}
Expand Down Expand Up @@ -361,7 +362,7 @@ contract ERC721M is IERC721M, ERC721AQueryable, Ownable, ReentrancyGuard {
bytes32[] calldata proof,
uint64 timestamp,
bytes calldata signature
) virtual external payable nonReentrant {
) external payable virtual nonReentrant {
_mintInternal(qty, msg.sender, proof, timestamp, signature);
}

Expand Down Expand Up @@ -413,7 +414,8 @@ contract ERC721M is IERC721M, ERC721AQueryable, Ownable, ReentrancyGuard {
stage = _mintStages[activeStage];

// Check value if minting with ETH
if (_mintCurrency == address(0) && msg.value < stage.price * qty) revert NotEnoughValue();
if (_mintCurrency == address(0) && msg.value < stage.price * qty)
revert NotEnoughValue();

// Check stage supply if applicable
if (stage.maxStageSupply > 0) {
Expand Down Expand Up @@ -446,7 +448,11 @@ contract ERC721M is IERC721M, ERC721AQueryable, Ownable, ReentrancyGuard {
}

if (_mintCurrency != address(0)) {
IERC20(_mintCurrency).safeTransferFrom(msg.sender, address(this), stage.price * qty);
IERC20(_mintCurrency).safeTransferFrom(
msg.sender,
address(this),
stage.price * qty
);
}

_stageMintedCountsPerWallet[activeStage][to] += qty;
Expand Down Expand Up @@ -624,4 +630,4 @@ contract ERC721M is IERC721M, ERC721AQueryable, Ownable, ReentrancyGuard {
}
return chainID;
}
}
}
9 changes: 5 additions & 4 deletions contracts/ERC721MAutoApprover.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "./ERC721M.sol";

contract ERC721MAutoApprover is ERC721M {
address private _autoApproveAddress;

event SetAutoApproveAddress(address autoApproveAddress);

constructor(
Expand Down Expand Up @@ -56,9 +56,10 @@ contract ERC721MAutoApprover is ERC721M {
return _autoApproveAddress;
}

function setAutoApproveAddress(
address autoApproveAddress
) external onlyOwner {
function setAutoApproveAddress(address autoApproveAddress)
external
onlyOwner
{
_autoApproveAddress = autoApproveAddress;
emit SetAutoApproveAddress(autoApproveAddress);
}
Expand Down
22 changes: 20 additions & 2 deletions contracts/ERC721MIncreasableOperatorFilterer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ pragma solidity ^0.8.4;

import "./ERC721M.sol";
import "./ERC721MIncreasableSupply.sol";
import "./OperatorFilter/DefaultOperatorFilterer.sol";
import {UpdatableOperatorFilterer} from "operator-filter-registry/src/UpdatableOperatorFilterer.sol";
import {CANONICAL_OPERATOR_FILTER_REGISTRY_ADDRESS, ME_SUBSCRIPTION} from "./utils/Constants.sol";

contract ERC721MIncreasableOperatorFilterer is ERC721MIncreasableSupply, DefaultOperatorFilterer {
contract ERC721MIncreasableOperatorFilterer is
ERC721MIncreasableSupply,
UpdatableOperatorFilterer
{
constructor(
string memory collectionName,
string memory collectionSymbol,
Expand All @@ -17,6 +21,11 @@ contract ERC721MIncreasableOperatorFilterer is ERC721MIncreasableSupply, Default
uint64 timestampExpirySeconds,
address mintCurrency
)
UpdatableOperatorFilterer(
CANONICAL_OPERATOR_FILTER_REGISTRY_ADDRESS,
ME_SUBSCRIPTION,
true
)
ERC721MIncreasableSupply(
collectionName,
collectionSymbol,
Expand All @@ -29,6 +38,15 @@ contract ERC721MIncreasableOperatorFilterer is ERC721MIncreasableSupply, Default
)
{}

function owner()
public
view
override(Ownable, UpdatableOperatorFilterer)
returns (address)
{
return Ownable.owner();
}

function transferFrom(
address from,
address to,
Expand Down
89 changes: 63 additions & 26 deletions contracts/ERC721MLite.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {MerkleProof} from "@openzeppelin/contracts/utils/cryptography/MerkleProo
import {SignatureChecker} from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
import {ERC721A, ERC721AQueryable, ERC721A__IERC721Receiver} from "erc721a/contracts/extensions/ERC721AQueryable.sol";
import {IERC721A, IERC721M} from "./IERC721M.sol";
import {DefaultOperatorFilterer} from "./OperatorFilter/DefaultOperatorFilterer.sol";
import {UpdatableOperatorFilterer} from "operator-filter-registry/src/UpdatableOperatorFilterer.sol";
import {CANONICAL_OPERATOR_FILTER_REGISTRY_ADDRESS, ME_SUBSCRIPTION} from "./utils/Constants.sol";

/**
* @title ERC721MLite
Expand All @@ -21,7 +22,7 @@ import {DefaultOperatorFilterer} from "./OperatorFilter/DefaultOperatorFilterer.
contract ERC721MLite is
IERC721M,
ERC721AQueryable,
DefaultOperatorFilterer,
UpdatableOperatorFilterer,
Ownable,
ReentrancyGuard
{
Expand Down Expand Up @@ -66,7 +67,14 @@ contract ERC721MLite is
uint256 globalWalletLimit,
address cosigner,
uint64 timestampExpirySeconds
) ERC721A(collectionName, collectionSymbol) {
)
UpdatableOperatorFilterer(
CANONICAL_OPERATOR_FILTER_REGISTRY_ADDRESS,
ME_SUBSCRIPTION,
true
)
ERC721A(collectionName, collectionSymbol)
{
if (globalWalletLimit > maxMintableSupply)
revert GlobalWalletLimitOverflow();
_mintable = false;
Expand Down Expand Up @@ -190,9 +198,11 @@ contract ERC721MLite is
/**
* @dev Sets maximum mintable supply.
*/
function setMaxMintableSupply(
uint256 maxMintableSupply
) external virtual onlyOwner {
function setMaxMintableSupply(uint256 maxMintableSupply)
external
virtual
onlyOwner
{
if (maxMintableSupply > _maxMintableSupply) {
revert CannotIncreaseMaxMintableSupply();
}
Expand All @@ -211,18 +221,29 @@ contract ERC721MLite is
/**
* @dev Returns number of minted token for a given address.
*/
function totalMintedByAddress(
address a
) external view virtual override returns (uint256) {
function totalMintedByAddress(address a)
external
view
virtual
override
returns (uint256)
{
return _numberMinted(a);
}

/**
* @dev Returns info for one stage specified by index (starting from 0).
*/
function getStageInfo(
uint256 index
) external view override returns (MintStageInfo memory, uint32, uint256) {
function getStageInfo(uint256 index)
external
view
override
returns (
MintStageInfo memory,
uint32,
uint256
)
{
if (index >= _mintStages.length) {
revert("InvalidStage");
}
Expand Down Expand Up @@ -302,10 +323,11 @@ contract ERC721MLite is
* NOTE: This function bypasses validations thus only available for owner.
* This is typically used for owner to pre-mint or mint the remaining of the supply.
*/
function ownerMint(
uint32 qty,
address to
) external onlyOwner hasSupply(qty) {
function ownerMint(uint32 qty, address to)
external
onlyOwner
hasSupply(qty)
{
_safeMint(to, qty);
}

Expand All @@ -330,9 +352,12 @@ contract ERC721MLite is
/**
* @dev Returns token URI for a given token id.
*/
function tokenURI(
uint256 tokenId
) public view override(ERC721A, IERC721A) returns (string memory) {
function tokenURI(uint256 tokenId)
public
view
override(ERC721A, IERC721A)
returns (string memory)
{
if (!_exists(tokenId)) revert URIQueryForNonexistentToken();

string memory baseURI = _currentBaseURI;
Expand Down Expand Up @@ -392,9 +417,11 @@ contract ERC721MLite is
/**
* @dev Returns the current active stage based on timestamp.
*/
function getActiveStageFromTimestamp(
uint64 timestamp
) public view returns (uint256) {
function getActiveStageFromTimestamp(uint64 timestamp)
public
view
returns (uint256)
{
for (uint256 i = 0; i < _mintStages.length; i++) {
if (
timestamp >= _mintStages[i].startTimeUnixSeconds &&
Expand All @@ -417,10 +444,10 @@ contract ERC721MLite is
/**
* @dev Validates the start timestamp is before end timestamp. Used when updating stages.
*/
function _assertValidStartAndEndTimestamp(
uint64 start,
uint64 end
) internal pure {
function _assertValidStartAndEndTimestamp(uint64 start, uint64 end)
internal
pure
{
if (start >= end) revert InvalidStartAndEndTimestamp();
}

Expand All @@ -435,6 +462,16 @@ contract ERC721MLite is
return chainID;
}

function owner()
public
view
virtual
override(Ownable, UpdatableOperatorFilterer)
returns (address)
{
return Ownable.owner();
}

function transferFrom(
address from,
address to,
Expand Down
Loading

0 comments on commit ef57c3f

Please sign in to comment.