-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeployRaffle.s.sol
65 lines (56 loc) · 1.88 KB
/
DeployRaffle.s.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import {Script} from "forge-std/Script.sol";
import {Raffle} from "../src/Raffle.sol";
import {HelperConfig} from "./HelperConfig.s.sol";
import {CreateSubscription, FundSubscription, AddConsumer} from "./Interactions.s.sol";
contract DeployRaffle is Script {
function run() external returns (Raffle, HelperConfig) {
HelperConfig helperConfig = new HelperConfig();
(
uint256 subscriptionId,
bytes32 gasLane,
uint256 automationUpdateInterval,
uint256 entranceFee,
uint32 callbackGasLimit,
address vrfCoordinator,
address link,
uint256 deployerKey
) = helperConfig.activeNetworkConfig();
if (subscriptionId == 0) {
// 1. Create a subscription
CreateSubscription createSubscription = new CreateSubscription();
subscriptionId = createSubscription.createSubscription(
vrfCoordinator,
deployerKey
);
// 2. Fund the subscription with LINK
FundSubscription fundSubscription = new FundSubscription();
fundSubscription.fundSubscription(
vrfCoordinator,
subscriptionId,
link,
deployerKey
);
}
vm.startBroadcast();
Raffle raffle;
raffle = new Raffle(
subscriptionId,
gasLane,
automationUpdateInterval,
entranceFee,
callbackGasLimit,
vrfCoordinator
);
vm.stopBroadcast();
AddConsumer addConsumer = new AddConsumer();
addConsumer.addConsumer(
address(raffle),
vrfCoordinator,
subscriptionId,
deployerKey
);
return (raffle, helperConfig);
}
}