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
feat(RNGChainlinkV2): add Chainlink VRF V2 #22
Conversation
5e1682e
to
086757a
Compare
086757a
to
1c0e920
Compare
contracts/RNGBlockhash.sol
Outdated
|
||
import "./RNGInterface.sol"; | ||
import "./interfaces/RNGInterface.sol"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep in mind that this is a breaking change for any dependencies. Keep the same, even if it makes you twitch!
Try to touch as little as possible!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done: 701badd
contracts/RNGChainlinkV2.sol
Outdated
RequestConfig public sRequestConfig; | ||
|
||
/// @notice Chainlink VRF subscription request id | ||
uint256 public sRequestId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We store the most recent Chainlink VRF request id to compare it with the request id passed to the fulfillRandomWords
fallback function.
If it doesn't match, the transaction will revert.
require(_requestId == sRequestId, "RNGChainLink/requestId-incorrect"); |
contracts/RNGChainlinkV2.sol
Outdated
_requestConfig.numWords | ||
); | ||
|
||
sRequestId = _vrfRequestId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
sRequestConfig.keyHash = _keyhash; | ||
|
||
emit KeyHashSet(_keyhash); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to setting the keyhash, you'll want to add setters for each of the fields in RequestConfig.
Or you could just add a setRequestConfig
function. It's prob easiest, even if info gets repeated. You already have a RequestConfigSet
event too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done: 21e2671
21e2671
to
c1a3331
Compare
c1a3331
to
35cdaf9
Compare
No description provided.