Skip to content

Add custom error in revert #9885

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

Closed
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
8 changes: 6 additions & 2 deletions contracts/src/v0.8/KeepersVRFConsumer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import "./interfaces/VRFCoordinatorV2Interface.sol";
* is called in a cadence provided by the upkeep interval.
*/
contract KeepersVRFConsumer is KeeperCompatibleInterface, VRFConsumerBaseV2 {

// error
error RequestIdNotFoundInMap();

// Upkeep interval in seconds. This contract's performUpkeep method will
// be called by the Keepers network roughly every UPKEEP_INTERVAL seconds.
uint256 public immutable UPKEEP_INTERVAL;
Expand Down Expand Up @@ -84,8 +88,8 @@ contract KeepersVRFConsumer is KeeperCompatibleInterface, VRFConsumerBaseV2 {
*/
function fulfillRandomWords(uint256 requestId, uint256[] memory randomWords) internal override {
// Check that the request exists. If not, revert.
RequestRecord memory record = s_requests[requestId];
require(record.requestId == requestId, "request ID not found in map");
RequestRecord memory record = s_requests[requested];
if(record.requestId != requested) revert RequestIdNotFoundInMap();

// Update the randomness in the record, and increment the response counter.
s_requests[requestId].randomness = randomWords[0];
Expand Down