Skip to content

Commit

Permalink
v1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
beshup committed Jun 4, 2024
1 parent 9263994 commit cbddc6d
Show file tree
Hide file tree
Showing 75 changed files with 6,712 additions and 15,504 deletions.
3 changes: 2 additions & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"avoid-throw": "off",
"avoid-suicide": "error",
"avoid-sha3": "warn",
"no-global-import": "off"
"no-global-import": "off",
"quotes": "warn"
}
}
44 changes: 39 additions & 5 deletions contracts/auction/AuctionManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { IAuctionManager } from "./interfaces/IAuctionManager.sol";
import { IOwnable } from "./interfaces/IOwnable.sol";
import { IERC721GeneralMint } from "../erc721/interfaces/IERC721GeneralMint.sol";
import { IERC721EditionMint } from "../erc721/interfaces/IERC721EditionMint.sol";
import { IERC721EditionsStartId } from "../erc721/interfaces/IERC721EditionsStartId.sol";
import "../utils/EIP712Upgradeable.sol";
import { SafeMath } from "@openzeppelin/contracts/utils/math/SafeMath.sol";
import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
Expand Down Expand Up @@ -285,10 +286,7 @@ contract AuctionManager is

IAuctionManager.EditionAuction memory editionAuction = _auctionEditions[claim.auctionId];
if (editionAuction.used == true) {
auction.tokenId = IERC721EditionMint(auction.collection).mintOneToRecipient(
editionAuction.editionId,
address(this)
);
IERC721EditionMint(auction.collection).mintOneToRecipient(editionAuction.editionId, address(this));
} else {
auction.tokenId = IERC721GeneralMint(auction.collection).mintOneToOneRecipient(address(this));
}
Expand Down Expand Up @@ -319,14 +317,22 @@ contract AuctionManager is
function fulfillAuction(bytes32 auctionId) external override auctionIsLiveOnChain(auctionId) nonReentrant {
IAuctionManager.EnglishAuction memory auction = _auctions[auctionId];
IAuctionManager.HighestBidderData memory highestBidderData = _highestBidders[auctionId];
IAuctionManager.EditionAuction memory editionData = _auctionEditions[auctionId];
require(block.timestamp > auction.endTime && auction.endTime != 0, "Auction hasn't ended");

// send nft to recipient as preferred by winning bidder

// use edition to transfer (calculate tokenId on the fly)
uint256 tokenId = auction.tokenId;
if (editionData.used) {
tokenId = IERC721EditionsStartId(auction.collection).editionStartId(editionData.editionId);
}

try
IERC721(auction.collection).safeTransferFrom(
address(this),
highestBidderData.preferredNFTRecipient,
auction.tokenId
tokenId
)
{} catch {
// encourage fulfiller to urge highest bidder to update their preferred nft recipient
Expand Down Expand Up @@ -371,6 +377,34 @@ contract AuctionManager is
_auctions[auctionId].state = AuctionState.FULFILLED;
}

function cleanup() external {
bytes32 auc6Id = 0x3635643538626564343763383530306366376633383630310000000000000000;
bytes32 auc1Id = 0x3635643537656362626539653766323466383839393738340000000000000000;

// handle sending of money of auc1
IAuctionManager.EnglishAuction memory auction = _auctions[auc1Id];
require(auction.state != AuctionState.FULFILLED, "a");
IAuctionManager.HighestBidderData memory highestBidderData = _highestBidders[auc1Id];
uint256 platformCut = highestBidderData.amount;
require(platformCut == 30000000000000000, "a.5");
(bool sentToPlatform, bytes memory dataPlatform) = _platform.call{ value: platformCut }("");
require(sentToPlatform, "Failed to send native gas token to platform");

// handle sending nft of auc6
IAuctionManager.EnglishAuction memory auctionAuc6 = _auctions[auc6Id];
require(auctionAuc6.state == AuctionState.FULFILLED, "b");
IAuctionManager.HighestBidderData memory highestBidderDataAuc6 = _highestBidders[auc6Id];
IAuctionManager.EditionAuction memory editionData = _auctionEditions[auc6Id];
require(editionData.editionId == 6, "c");
uint256 tokenId = IERC721EditionsStartId(auction.collection).editionStartId(editionData.editionId);
require(tokenId == 7, "d");
IERC721(auction.collection).safeTransferFrom(
address(this),
highestBidderDataAuc6.preferredNFTRecipient,
tokenId
);
}

/**
* @notice See {IAuctionManager-cancelAuctionOnChain}
*/
Expand Down
8 changes: 4 additions & 4 deletions contracts/erc721/ERC721Editions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ contract ERC721Editions is
uint48 tokenLimitPerTx,
uint48 maxTotalClaimableViaVector,
uint48 maxUserClaimableViaVector,
bytes32 allowlistRoot
address currency
) = abi.decode(
mintVectorData,
(address, address, uint48, uint48, uint192, uint48, uint48, uint48, bytes32)
(address, address, uint48, uint48, uint192, uint48, uint48, uint48, address)
);

IAbridgedMintVector(mintManager).createAbridgedVector(
Expand All @@ -191,14 +191,14 @@ contract ERC721Editions is
uint160(paymentRecipient),
maxTotalClaimableViaVector,
0,
0,
uint160(currency),
tokenLimitPerTx,
maxUserClaimableViaVector,
pricePerToken,
uint48(editionId), // cast down
true,
false,
allowlistRoot
0
)
);
}
Expand Down
8 changes: 4 additions & 4 deletions contracts/erc721/ERC721EditionsDFS.sol
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ contract ERC721EditionsDFS is
uint48 tokenLimitPerTx,
uint48 maxTotalClaimableViaVector,
uint48 maxUserClaimableViaVector,
bytes32 allowlistRoot
address currency
) = abi.decode(
mintVectorData,
(address, address, uint48, uint48, uint192, uint48, uint48, uint48, bytes32)
(address, address, uint48, uint48, uint192, uint48, uint48, uint48, address)
);

IAbridgedMintVector(mintManager).createAbridgedVector(
Expand All @@ -186,14 +186,14 @@ contract ERC721EditionsDFS is
uint160(paymentRecipient),
maxTotalClaimableViaVector,
0,
0,
uint160(currency),
tokenLimitPerTx,
maxUserClaimableViaVector,
pricePerToken,
uint48(editionId), // cast down
true,
false,
allowlistRoot
0
)
);
}
Expand Down
39 changes: 38 additions & 1 deletion contracts/erc721/ERC721GeneralSequence.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import "../tokenManager/interfaces/IPostTransfer.sol";
import "../tokenManager/interfaces/IPostBurn.sol";
import "./interfaces/IERC721GeneralMint.sol";
import "./ERC721GeneralSequenceBase.sol";
import "./onchain/OnchainFileStorage.sol";

/**
* @title Generalized ERC721 that expects tokenIds to increment in a monotonically increasing sequence
* @author highlight.xyz
* @notice Generalized NFT smart contract
*/
contract ERC721GeneralSequence is MetadataEncryption, ERC721GeneralSequenceBase {
contract ERC721GeneralSequence is MetadataEncryption, ERC721GeneralSequenceBase, OnchainFileStorage {
using EnumerableSet for EnumerableSet.AddressSet;

/**
Expand Down Expand Up @@ -125,6 +126,42 @@ contract ERC721GeneralSequence is MetadataEncryption, ERC721GeneralSequenceBase
);
}

/**
* @notice Used for meta-transactions
*/
function _msgSender()
internal
view
virtual
override(ERC721GeneralSequenceBase, ContextUpgradeable)
returns (address sender)
{
return ERC721GeneralSequenceBase._msgSender();
}

/**
* @notice Used for meta-transactions
*/
function _msgData()
internal
view
virtual
override(ERC721GeneralSequenceBase, ContextUpgradeable)
returns (bytes calldata)
{
return ERC721GeneralSequenceBase._msgData();
}

/**
* @dev For more efficient reverts.
*/
function _revert(bytes4 errorSelector) internal pure override(ERC721GeneralSequenceBase, OnchainFileStorage) {
assembly {
mstore(0x00, errorSelector)
revert(0x00, 0x04)
}
}

/**
* @notice Initialize the contract
* @param creator Creator/owner of contract
Expand Down
20 changes: 6 additions & 14 deletions contracts/erc721/ERC721GeneralSequenceBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "../tokenManager/interfaces/IPostTransfer.sol";
import "../tokenManager/interfaces/IPostBurn.sol";
import "./interfaces/IERC721GeneralSequenceMint.sol";
import "./erc721a/ERC721AURIStorageUpgradeable.sol";
import "./custom/interfaces/IHighlightRenderer.sol";
import "./inchain-rendering/interfaces/IHLRenderer.sol";

/**
* @title Generalized Base ERC721
Expand Down Expand Up @@ -96,7 +96,7 @@ abstract contract ERC721GeneralSequenceBase is ERC721Base, ERC721AURIStorageUpgr
// process mint on custom renderer if present
CustomRendererConfig memory _customRendererConfig = customRendererConfig;
if (_customRendererConfig.processMintDataOnRenderer) {
IHighlightRenderer(_customRendererConfig.renderer).processOneRecipientMint(tempSupply, 1, recipient);
IHLRenderer(_customRendererConfig.renderer).processOneRecipientMint(tempSupply, 1, recipient);
}

return tempSupply;
Expand All @@ -118,11 +118,7 @@ abstract contract ERC721GeneralSequenceBase is ERC721Base, ERC721AURIStorageUpgr
// process mint on custom renderer if present
CustomRendererConfig memory _customRendererConfig = customRendererConfig;
if (_customRendererConfig.processMintDataOnRenderer) {
IHighlightRenderer(_customRendererConfig.renderer).processOneRecipientMint(
tempSupply + 1,
amount,
recipient
);
IHLRenderer(_customRendererConfig.renderer).processOneRecipientMint(tempSupply + 1, amount, recipient);
}
}

Expand All @@ -145,11 +141,7 @@ abstract contract ERC721GeneralSequenceBase is ERC721Base, ERC721AURIStorageUpgr
// process mint on custom renderer if present
CustomRendererConfig memory _customRendererConfig = customRendererConfig;
if (_customRendererConfig.processMintDataOnRenderer) {
IHighlightRenderer(_customRendererConfig.renderer).processMultipleRecipientMint(
tempSupply + 1,
1,
recipients
);
IHLRenderer(_customRendererConfig.renderer).processMultipleRecipientMint(tempSupply + 1, 1, recipients);
}
}

Expand All @@ -175,7 +167,7 @@ abstract contract ERC721GeneralSequenceBase is ERC721Base, ERC721AURIStorageUpgr
// process mint on custom renderer if present
CustomRendererConfig memory _customRendererConfig = customRendererConfig;
if (_customRendererConfig.processMintDataOnRenderer) {
IHighlightRenderer(_customRendererConfig.renderer).processMultipleRecipientMint(
IHLRenderer(_customRendererConfig.renderer).processMultipleRecipientMint(
tempSupply + 1,
amount,
recipients
Expand Down Expand Up @@ -300,7 +292,7 @@ abstract contract ERC721GeneralSequenceBase is ERC721Base, ERC721AURIStorageUpgr
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
if (customRendererConfig.renderer != address(0)) {
return IHighlightRenderer(customRendererConfig.renderer).tokenURI(tokenId);
return IHLRenderer(customRendererConfig.renderer).tokenURI(tokenId);
}
return ERC721AURIStorageUpgradeable.tokenURI(tokenId);
}
Expand Down
Loading

0 comments on commit cbddc6d

Please sign in to comment.