From 239627735954348c099e12a6f1a9499b20b86a03 Mon Sep 17 00:00:00 2001 From: Paulius Date: Thu, 28 Oct 2021 12:30:00 -0700 Subject: [PATCH 1/3] Break when token index is found --- src/MultiRaffle.sol | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/MultiRaffle.sol b/src/MultiRaffle.sol index a611a5b..03d72dc 100644 --- a/src/MultiRaffle.sol +++ b/src/MultiRaffle.sol @@ -332,6 +332,7 @@ contract MultiRaffle is Ownable, ERC721, VRFConsumerBase { if (tokenId >= metadatas[i].startIndex && tokenId < metadatas[i].endIndex) { randomness = metadatas[i].entropy; metadataCleared = true; + break; } } @@ -369,4 +370,4 @@ contract MultiRaffle is Ownable, ERC721, VRFConsumerBase { } return string(buffer); } -} \ No newline at end of file +} From 10492a3758d6beb049e8448bf0e8127981d618b0 Mon Sep 17 00:00:00 2001 From: Paulius Date: Thu, 28 Oct 2021 13:19:43 -0700 Subject: [PATCH 2/3] Ability to change LINK fee --- src/MultiRaffle.sol | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/MultiRaffle.sol b/src/MultiRaffle.sol index 03d72dc..b64c9f2 100644 --- a/src/MultiRaffle.sol +++ b/src/MultiRaffle.sol @@ -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 @@ -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) @@ -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 @@ -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) From b4c4ab4aedae51bba4fd021de3fc6e4131626be0 Mon Sep 17 00:00:00 2001 From: Paulius Date: Thu, 28 Oct 2021 13:36:14 -0700 Subject: [PATCH 3/3] Correct misleading revert message --- src/MultiRaffle.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MultiRaffle.sol b/src/MultiRaffle.sol index b64c9f2..75fea29 100644 --- a/src/MultiRaffle.sol +++ b/src/MultiRaffle.sol @@ -141,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");