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

changing type of subscriptionId from uint64 to uint256 (chainlink VRF) in written lessons #333

Merged
merged 4 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ function testRevertsIfCollateralZero() public {
vm.startPrank(USER);
ERC20Mock(weth).approve(address(dsce), AMOUNT_COLLATERAL);

vm.expectRevert(DSCEngine__NeedsMoreThanZero.selector);
vm.expectRevert(DSCEngine.DSCEngine__NeedsMoreThanZero.selector);
dsce.depositCollateral(weth, 0);
vm.stopPrank();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function run() external returns (Raffle, HelperConfig) {
uint256 interval;
address vrfCoordinator;
bytes32 gasLane;
uint64 subscriptionId;
uint256 subscriptionId;
uint32 callbackGasLimit;

) = helperConfig.activeNetworkConfig();
Expand Down Expand Up @@ -90,7 +90,7 @@ function run() external returns (Raffle, HelperConfig) {
uint256 interval,
address vrfCoordinator,
bytes32 gasLane,
uint64 subscriptionId,
uint256 subscriptionId,
uint32 callbackGasLimit
) = helperConfig.activeNetworkConfig();

Expand Down Expand Up @@ -122,7 +122,7 @@ contract RaffleTest is Test {
uint256 interval;
address vrfCoordinator;
bytes32 gasLane;
uint64 subscriptionId;
uint256 subscriptionId;
uint32 callbackGasLimit;

address public PLAYER = makeAddr("player");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ contract HelperConfig is Script {
uint256 interval;
address vrfCoordinator;
bytes32 gasLane;
uint64 subscriptionId;
uint256 subscriptionId;
uint32 callbackGasLimit;
}

Expand All @@ -69,7 +69,7 @@ contract HelperConfig is Script {

We start with the `SPDX `and `pragma solidity` declarations. Then, we import `Script` from Foundry, name the contract and make it inherit `Script`. Cool! Now what do we need to deploy the `Raffle` contract? That information can be easily found in the `Raffle` contract's constructor:

`constructor(uint256 entranceFee, uint256 interval, address vrfCoordinator, bytes32 gasLane, uint64 subscriptionId, uint32 callbackGasLimit)`
`constructor(uint256 entranceFee, uint256 interval, address vrfCoordinator, bytes32 gasLane, uint256 subscriptionId, uint32 callbackGasLimit)`

We created a new struct called `NetworkConfig` and we matched its contents with the Raffle's constructor input.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ contract DeployRaffle is Script {
uint256 interval,
address vrfCoordinator,
bytes32 gasLane,
uint64 subscriptionId,
uint256 subscriptionId,
uint32 callbackGasLimit
) = helperConfig.activeNetworkConfig();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Let's start modifying our `HelperConfig.s.sol`:
uint256 interval;
address vrfCoordinator;
bytes32 gasLane;
uint64 subscriptionId;
uint256 subscriptionId;
uint32 callbackGasLimit;
address linkToken;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ And right about now, everything should feel extremely familiar. Let's define `ad
```solidity
contract AddConsumer is Script {

function addConsumer(address raffle, address vrfCoordinator, uint64 subscriptionId) public {
function addConsumer(address raffle, address vrfCoordinator, uint256 subscriptionId) public {
console.log("Adding consumer contract: ", raffle);
console.log("Using VRFCoordinator: ", vrfCoordinator);
console.log("On chain id: ", block.chainid);
Expand All @@ -59,7 +59,7 @@ contract AddConsumer is Script {
,
address vrfCoordinator,
,
uint64 subscriptionId,
uint256 subscriptionId,
,
) = helperConfig.activeNetworkConfig();
addConsumer(raffle, vrfCoordinator, subscriptionId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ Let's add the above-mentioned variables inside the VRF state variables block:
// Chainlink VRF related variables
VRFCoordinatorV2Interface private immutable i_vrfCoordinator;
bytes32 private immutable i_gasLane;
uint64 private immutable i_subscriptionId;
uint256 private immutable i_subscriptionId;
uint16 private constant REQUEST_CONFIRMATIONS = 3;
uint32 private immutable i_callbackGasLimit;
uint32 private constant NUM_WORDS = 1;
Expand All @@ -188,7 +188,7 @@ For simplicity we request only 1 word, thus we make that variable constant. The
The next step is to attribute values inside the constructor:

```solidity
constructor(uint256 entranceFee, uint256 interval, address vrfCoordinator, bytes32 gasLane, uint64 subscriptionId, uint32 callbackGasLimit) VRFConsumerBaseV2(vrfCoordinator) {
constructor(uint256 entranceFee, uint256 interval, address vrfCoordinator, bytes32 gasLane, uint256 subscriptionId, uint32 callbackGasLimit) VRFConsumerBaseV2(vrfCoordinator) {
i_entranceFee = entranceFee;
i_interval = interval;
s_lastTimeStamp = block.timestamp;
Expand Down