From 938ea14d44482ac863543b487944a1720c375b65 Mon Sep 17 00:00:00 2001 From: han Date: Fri, 3 Jan 2025 10:34:36 +0700 Subject: [PATCH] remove Counter contract and add basic Raffle contract --- lottery/script/Counter.s.sol | 19 -------------- lottery/src/Counter.sol | 14 ----------- lottery/src/Raffle.sol | 48 ++++++++++++++++++++++++++++++++++++ lottery/test/Counter.t.sol | 24 ------------------ 4 files changed, 48 insertions(+), 57 deletions(-) delete mode 100644 lottery/script/Counter.s.sol delete mode 100644 lottery/src/Counter.sol create mode 100644 lottery/src/Raffle.sol delete mode 100644 lottery/test/Counter.t.sol diff --git a/lottery/script/Counter.s.sol b/lottery/script/Counter.s.sol deleted file mode 100644 index cdc1fe9..0000000 --- a/lottery/script/Counter.s.sol +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import {Script, console} from "forge-std/Script.sol"; -import {Counter} from "../src/Counter.sol"; - -contract CounterScript is Script { - Counter public counter; - - function setUp() public {} - - function run() public { - vm.startBroadcast(); - - counter = new Counter(); - - vm.stopBroadcast(); - } -} diff --git a/lottery/src/Counter.sol b/lottery/src/Counter.sol deleted file mode 100644 index aded799..0000000 --- a/lottery/src/Counter.sol +++ /dev/null @@ -1,14 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -contract Counter { - uint256 public number; - - function setNumber(uint256 newNumber) public { - number = newNumber; - } - - function increment() public { - number++; - } -} diff --git a/lottery/src/Raffle.sol b/lottery/src/Raffle.sol new file mode 100644 index 0000000..5b379dd --- /dev/null +++ b/lottery/src/Raffle.sol @@ -0,0 +1,48 @@ +// Layout of Contract: +// version +// imports +// errors +// interfaces, libraries, contracts +// Type declarations +// State variables +// Events +// Modifiers +// Functions + +// Layout of Functions: +// constructor +// receive function (if exists) +// fallback function (if exists) +// external +// public +// internal +// private +// view & pure functions + +// SPDX-License-Identifier: SEE LICENSE IN LICENSE +pragma solidity 0.8.19; + +/** + * @title A sample Raffle contract + * @author hirugohan + * @notice This contract is for creating a sample raffle + * @dev Implements Chainlink VRFv2.5 + */ +contract Raffle { + uint256 private immutable i_entranceFee; + + constructor (uint256 entranceFee) { + i_entranceFee = entranceFee; + } + + function enterRaffle() public payable { + require(msg.value >= i_entranceFee, "Not enough ETH sent!"); + } + + function pickWinner() public {} + + /** Getter Functions */ + function getEntranceFee() external view returns (uint256) { + return i_entranceFee; + } +} diff --git a/lottery/test/Counter.t.sol b/lottery/test/Counter.t.sol deleted file mode 100644 index 54b724f..0000000 --- a/lottery/test/Counter.t.sol +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import {Test, console} from "forge-std/Test.sol"; -import {Counter} from "../src/Counter.sol"; - -contract CounterTest is Test { - Counter public counter; - - function setUp() public { - counter = new Counter(); - counter.setNumber(0); - } - - function test_Increment() public { - counter.increment(); - assertEq(counter.number(), 1); - } - - function testFuzz_SetNumber(uint256 x) public { - counter.setNumber(x); - assertEq(counter.number(), x); - } -}