Skip to content

Commit

Permalink
Merge pull request #82 from gelatodigital/update-comments
Browse files Browse the repository at this point in the history
chore: update comments and types
  • Loading branch information
Louis Bettens authored Sep 27, 2023
2 parents 1b9e061 + 9f2fe05 commit 5160529
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
18 changes: 9 additions & 9 deletions contracts/GelatoVRFConsumerBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,35 @@ abstract contract GelatoVRFConsumerBase is GelatoVRFConsumer {
}

/// @notice User logic to handle the random value received.
/// @dev The seed is derived from the hash of the randomness
/// provided by the drand network and the request ID.
/// @param seed The derived seed.
/// @param randomness The random number generated by Gelato VRF.
/// @param requestId The ID for the randomness request.
/// @param extraData Additional data from the randomness request.
function _fulfillRandomness(
bytes32 seed,
uint256 randomness,
uint64 requestId,
bytes memory extraData
) internal virtual;

/// @notice Callback function used by Gelato VRF to return the random number.
/// The seed is derived by hashing the provided randomness with the request ID.
/// The randomness is derived by hashing the provided randomness with the request ID.
/// @param randomness The random number generated by Gelato VRF.
/// @param data Additional data provided by Gelato VRF, typically containing request details.
function fulfillRandomness(
uint256 randomness,
bytes calldata data
) external {
require(msg.sender == _operator());
require(msg.sender == _operator(), "only operator");
(uint64 requestId, bytes memory extraData) = abi.decode(
data,
(uint64, bytes)
);
bytes32 seed = keccak256(
abi.encode(randomness, address(this), block.chainid, requestId)
randomness = uint(
keccak256(
abi.encode(randomness, address(this), block.chainid, requestId)
)
);
if (requestPending[requestId]) {
_fulfillRandomness(seed, requestId, extraData);
_fulfillRandomness(randomness, requestId, extraData);
requestPending[requestId] = false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/MockVRFConsumerBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.8.18;
import {GelatoVRFConsumerBase} from "./GelatoVRFConsumerBase.sol";

contract MockVRFConsumerBase is GelatoVRFConsumerBase {
bytes32 public latestRandomness;
uint256 public latestRandomness;
uint64 public latestRequestId;
address private immutable _operatorAddr;

Expand All @@ -21,7 +21,7 @@ contract MockVRFConsumerBase is GelatoVRFConsumerBase {
}

function _fulfillRandomness(
bytes32 randomness,
uint256 randomness,
uint64 requestId,
bytes memory
) internal override {
Expand Down
6 changes: 3 additions & 3 deletions contracts/chainlink_compatible/VRFCoordinatorV2Adapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ contract VRFCoordinatorV2Adapter is
}

/// @notice Callback function used by Gelato VRF to return the random number.
/// @param seed The random number generated by Gelato VRF.
/// @param randomness The random number generated by Gelato VRF.
/// @param data Additional data provided by Gelato VRF, typically containing request details.
function _fulfillRandomness(
bytes32 seed,
uint256 randomness,
uint64 requestId,
bytes memory data
) internal override {
Expand All @@ -102,7 +102,7 @@ contract VRFCoordinatorV2Adapter is
);
uint[] memory words = new uint[](numWords);
for (uint32 i = 0; i < numWords; i++) {
words[i] = uint(keccak256(abi.encode(seed, i)));
words[i] = uint(keccak256(abi.encode(randomness, i)));
}
consumer.rawFulfillRandomWords(requestId, words);
}
Expand Down

0 comments on commit 5160529

Please sign in to comment.