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

Small improvements (see the comment below) #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
21 changes: 14 additions & 7 deletions src/MultiRaffle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ contract MultiRaffle is Ownable, ERC721, VRFConsumerBase {
uint256 public immutable MAX_PER_ADDRESS;

/// ============ Mutable storage ============

/// @notice LINK fee paid to oracles
uint256 public linkFee = 2e18;
/// @notice Entropy from Chainlink VRF
uint256 public entropy;
/// @notice Number of NFTs minted
Expand Down Expand Up @@ -140,7 +141,7 @@ contract MultiRaffle is Ownable, ERC721, VRFConsumerBase {
// Ensure number of tickets to acquire <= max per address
require(
entriesPerAddress[msg.sender] + numTickets <= MAX_PER_ADDRESS,
"Max mints for address reached"
"Max entries for address reached"
);
// Ensure sufficient raffle ticket payment
require(msg.value == numTickets * MINT_COST, "Incorrect payment");
Expand Down Expand Up @@ -246,14 +247,14 @@ contract MultiRaffle is Ownable, ERC721, VRFConsumerBase {
// Ensure raffle has ended
require(block.timestamp > RAFFLE_END_TIME, "Raffle still active");
// Ensure contract has sufficient LINK balance
require(LINK_TOKEN.balanceOf(address(this)) >= 2e18, "Insufficient LINK");
require(LINK_TOKEN.balanceOf(address(this)) >= linkFee, "Insufficient LINK");
// Ensure raffle requires entropy (entries !< supply)
require(raffleEntries.length > AVAILABLE_SUPPLY, "Raffle does not need entropy");
// Ensure raffle requires entropy (entropy not already set)
require(!clearingEntropySet, "Clearing entropy already set");

// Request randomness from Chainlink VRF
return requestRandomness(KEY_HASH, 2e18);
return requestRandomness(KEY_HASH, linkFee);
}

/// @notice Reveals metadata for all NFTs with reveals pending (batch reveal)
Expand All @@ -263,10 +264,10 @@ contract MultiRaffle is Ownable, ERC721, VRFConsumerBase {
// Ensure at least 1 minted NFT requires metadata
require(nftCount - nftRevealedCount > 0, "No NFTs pending metadata reveal");
// Ensure contract has sufficient LINK balance
require(LINK_TOKEN.balanceOf(address(this)) >= 2e18, "Insufficient LINK");
require(LINK_TOKEN.balanceOf(address(this)) >= linkFee, "Insufficient LINK");

// Request randomness from Chainlink VRF
return requestRandomness(KEY_HASH, 2e18);
return requestRandomness(KEY_HASH, linkFee);
}

/// @notice Fulfills randomness from Chainlink VRF
Expand Down Expand Up @@ -319,6 +320,11 @@ contract MultiRaffle is Ownable, ERC721, VRFConsumerBase {
emit RaffleProceedsClaimed(msg.sender, proceeds);
}

/// @notice Allows contract owner to change LINK fee paid to oracles
function changeLinkFee(uint256 _linkFee) external onlyOwner {
linkFee = _linkFee;
}

/// ============ Developer-defined functions ============

/// @notice Returns metadata about a token (depending on randomness reveal status)
Expand All @@ -332,6 +338,7 @@ contract MultiRaffle is Ownable, ERC721, VRFConsumerBase {
if (tokenId >= metadatas[i].startIndex && tokenId < metadatas[i].endIndex) {
randomness = metadatas[i].entropy;
metadataCleared = true;
break;
}
}

Expand Down Expand Up @@ -369,4 +376,4 @@ contract MultiRaffle is Ownable, ERC721, VRFConsumerBase {
}
return string(buffer);
}
}
}