Skip to content

Commit

Permalink
refactored code and added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ABFX15 committed Nov 28, 2024
1 parent 3232879 commit 9114eb9
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 238 deletions.
17 changes: 9 additions & 8 deletions script/DeployLottery.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ import {HelperConfig} from "./HelperConfig.s.sol";
import {SmartLottery} from "../src/Lottery.sol";

contract DeployLottery is Script {
function run() public returns (SmartLottery, HelperConfig) {
return deployContract();
}

function deployContract() public returns (SmartLottery, HelperConfig) {
function run() external returns (SmartLottery, HelperConfig) {
HelperConfig helperConfig = new HelperConfig();
HelperConfig.NetworkConfig memory config = helperConfig.getConfig();

vm.startBroadcast();
SmartLottery smartLottery =
new SmartLottery(config.vrfCoordinatorV2, config.subscriptionId, config.keyHash, config.callbackGasLimit);
SmartLottery lottery = new SmartLottery(
config.vrfCoordinatorV2,
config.subscriptionId,
config.keyHash,
config.callbackGasLimit,
config.minimumTicketPrice
);
vm.stopBroadcast();
return (smartLottery, helperConfig);
return (lottery, helperConfig);
}
}
13 changes: 8 additions & 5 deletions script/HelperConfig.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ contract HelperConfig is Script {
error HelperConfig__InvalidChainId();

struct NetworkConfig {
uint64 subscriptionId;
address vrfCoordinatorV2;
uint64 subscriptionId;
bytes32 keyHash;
uint32 callbackGasLimit;
uint256 minimumTicketPrice;
}

NetworkConfig public localNetworkConfig;
Expand Down Expand Up @@ -42,10 +43,11 @@ contract HelperConfig is Script {

function getSepoliaEthConfig() public pure returns (NetworkConfig memory) {
return NetworkConfig({
vrfCoordinatorV2: 0x8103B0A8A00be2DDC778e6e7eaa21791Cd364625,
subscriptionId: 0,
vrfCoordinatorV2: 0x9DdfaCa8183c41ad55329BdeeD9F6A8d53168B1B,
keyHash: 0x787d74caea10b2b357790d5b5247c2f63d1d91572a9846f780606e4d953677ae,
callbackGasLimit: 500000
keyHash: 0x474e34a077df58807dbe9c96d3c009b23b3c6d0cce433e59bbf5b34f823bc56c,
callbackGasLimit: 500000,
minimumTicketPrice: 1 ether
});
}

Expand All @@ -61,7 +63,8 @@ contract HelperConfig is Script {
subscriptionId: 0,
vrfCoordinatorV2: address(vrfCoordinatorMock),
keyHash: 0x787d74caea10b2b357790d5b5247c2f63d1d91572a9846f780606e4d953677ae,
callbackGasLimit: 500000
callbackGasLimit: 500000,
minimumTicketPrice: 1 ether
});
return localNetworkConfig;
}
Expand Down
Loading

0 comments on commit 9114eb9

Please sign in to comment.