Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add collection plus and merkle minters #116

Merged
merged 7 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions .storage-layout
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,20 @@
➡ Auction
=======================

| Name | Type | Slot | Offset | Bytes | Contract |
|---------------|--------------------------------|------|--------|-------|---------------------------------|
| _initialized | uint8 | 0 | 0 | 1 | src/auction/Auction.sol:Auction |
| _initializing | bool | 0 | 1 | 1 | src/auction/Auction.sol:Auction |
| _owner | address | 0 | 2 | 20 | src/auction/Auction.sol:Auction |
| _pendingOwner | address | 1 | 0 | 20 | src/auction/Auction.sol:Auction |
| _status | uint256 | 2 | 0 | 32 | src/auction/Auction.sol:Auction |
| _paused | bool | 3 | 0 | 1 | src/auction/Auction.sol:Auction |
| settings | struct AuctionTypesV1.Settings | 4 | 0 | 64 | src/auction/Auction.sol:Auction |
| token | contract IBaseToken | 6 | 0 | 20 | src/auction/Auction.sol:Auction |
| auction | struct AuctionTypesV1.Auction | 7 | 0 | 96 | src/auction/Auction.sol:Auction |
| Name | Type | Slot | Offset | Bytes | Contract |
|------------------------|--------------------------------|------|--------|-------|---------------------------------|
| _initialized | uint8 | 0 | 0 | 1 | src/auction/Auction.sol:Auction |
| _initializing | bool | 0 | 1 | 1 | src/auction/Auction.sol:Auction |
| _owner | address | 0 | 2 | 20 | src/auction/Auction.sol:Auction |
| _pendingOwner | address | 1 | 0 | 20 | src/auction/Auction.sol:Auction |
| _status | uint256 | 2 | 0 | 32 | src/auction/Auction.sol:Auction |
| _paused | bool | 3 | 0 | 1 | src/auction/Auction.sol:Auction |
| settings | struct AuctionTypesV1.Settings | 4 | 0 | 64 | src/auction/Auction.sol:Auction |
| token | contract IBaseToken | 6 | 0 | 20 | src/auction/Auction.sol:Auction |
| auction | struct AuctionTypesV1.Auction | 7 | 0 | 96 | src/auction/Auction.sol:Auction |
| currentBidReferral | address | 10 | 0 | 20 | src/auction/Auction.sol:Auction |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be careful when adding slots, looks fine here.

| founderRewardsRecipent | address | 11 | 0 | 20 | src/auction/Auction.sol:Auction |
| founderRewardBPS | uint256 | 12 | 0 | 32 | src/auction/Auction.sol:Auction |

=======================
➡ Governor
Expand Down
50 changes: 50 additions & 0 deletions src/lib/interfaces/IERC6551Registry.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IERC6551Registry {
/**
* @dev The registry SHALL emit the AccountCreated event upon successful account creation
*/
event AccountCreated(
address account,
address indexed implementation,
uint256 chainId,
address indexed tokenContract,
uint256 indexed tokenId,
uint256 salt
);

/**
* @dev Creates a token bound account for a non-fungible token
*
* If account has already been created, returns the account address without calling create2
*
* If initData is not empty and account has not yet been created, calls account with
* provided initData after creation
*
* Emits AccountCreated event
*
* @return the address of the account
*/
function createAccount(
address implementation,
uint256 chainId,
address tokenContract,
uint256 tokenId,
uint256 seed,
bytes calldata initData
) external returns (address);

/**
* @dev Returns the computed token bound account address for a non-fungible token
*
* @return The computed address of the token bound account
*/
function account(
address implementation,
uint256 chainId,
address tokenContract,
uint256 tokenId,
uint256 salt
) external view returns (address);
}
7 changes: 7 additions & 0 deletions src/lib/interfaces/IERC721Votes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,11 @@ interface IERC721Votes is IERC721, IEIP712 {
bytes32 r,
bytes32 s
) external;

function batchDelegateBySigERC1271(
address[] calldata _fromAddresses,
address _toAddress,
uint256 _deadline,
bytes memory _signature
) external;
}
32 changes: 16 additions & 16 deletions src/lib/token/ERC721Votes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ abstract contract ERC721Votes is IERC721Votes, EIP712, ERC721 {
bytes32 internal constant DELEGATION_TYPEHASH = keccak256("Delegation(address from,address to,uint256 nonce,uint256 deadline)");

/// @dev The EIP-712 typehash to batch delegate with a signature
bytes32 internal constant BATCH_DELEGATION_TYPEHASH = keccak256("Delegation(address[] from,address[] to,uint256[] nonce,uint256[] deadline)");
bytes32 internal constant BATCH_DELEGATION_TYPEHASH = keccak256("Delegation(address[] from,address to,uint256[] nonce,uint256 deadline)");

/// ///
/// STORAGE ///
Expand Down Expand Up @@ -59,20 +59,20 @@ abstract contract ERC721Votes is IERC721Votes, EIP712, ERC721 {

function getBatchDelegateBySigTypedDataHash(
address[] calldata _fromAddresses,
address[] calldata _toAddresses,
uint256[] calldata _deadlines
address _toAddress,
uint256 _deadline
) public view returns (bytes32) {
uint256 length = _fromAddresses.length;

// Ensure the signature has not expired
if (block.timestamp > _deadline) revert EXPIRED_SIGNATURE();

// Cannot realistically overflow
unchecked {
// Store nonces for each from address
uint256[] memory currentNonces = new uint256[](length);

for (uint256 i = 0; i < length; ++i) {
// Ensure the signature has not expired
if (block.timestamp > _deadlines[i]) revert EXPIRED_SIGNATURE();

// Add the addresses current nonce to the list of nonces
currentNonces[i] = nonces[_fromAddresses[i]];
}
Expand All @@ -87,9 +87,9 @@ abstract contract ERC721Votes is IERC721Votes, EIP712, ERC721 {
abi.encode(
BATCH_DELEGATION_TYPEHASH,
keccak256(abi.encodePacked(_fromAddresses)),
keccak256(abi.encodePacked(_toAddresses)),
keccak256(abi.encodePacked(_toAddress)),
keccak256(abi.encodePacked(currentNonces)),
keccak256(abi.encodePacked(_deadlines))
keccak256(abi.encodePacked(_deadline))
)
)
)
Expand Down Expand Up @@ -219,24 +219,24 @@ abstract contract ERC721Votes is IERC721Votes, EIP712, ERC721 {

function batchDelegateBySigERC1271(
address[] calldata _fromAddresses,
address[] calldata _toAddresses,
uint256[] calldata _deadlines,
address _toAddress,
uint256 _deadline,
bytes memory _signature
) external {
uint256 length = _fromAddresses.length;

// Used to store the digest
bytes32 digest;

// Ensure the signature has not expired
if (block.timestamp > _deadline) revert EXPIRED_SIGNATURE();

// Cannot realistically overflow
unchecked {
// Store nonces for each from address
uint256[] memory currentNonces = new uint256[](length);

for (uint256 i = 0; i < length; ++i) {
// Ensure the signature has not expired
if (block.timestamp > _deadlines[i]) revert EXPIRED_SIGNATURE();

// Add the addresses current nonce to the list of nonces
currentNonces[i] = nonces[_fromAddresses[i]]++;
}
Expand All @@ -250,9 +250,9 @@ abstract contract ERC721Votes is IERC721Votes, EIP712, ERC721 {
abi.encode(
BATCH_DELEGATION_TYPEHASH,
keccak256(abi.encodePacked(_fromAddresses)),
keccak256(abi.encodePacked(_toAddresses)),
keccak256(abi.encodePacked(_toAddress)),
keccak256(abi.encodePacked(currentNonces)),
keccak256(abi.encodePacked(_deadlines))
keccak256(abi.encodePacked(_deadline))
)
)
)
Expand All @@ -269,7 +269,7 @@ abstract contract ERC721Votes is IERC721Votes, EIP712, ERC721 {
// Ensure the signature is valid
if (success && result.length >= 32 && abi.decode(result, (bytes32)) == bytes32(IERC1271.isValidSignature.selector)) {
// Update the delegate
_delegate(cachedFromAddress, _toAddresses[i]);
_delegate(cachedFromAddress, _toAddress);
} else {
revert INVALID_SIGNATURE();
}
Expand Down
Loading
Loading