remove Counter contract and add basic Raffle contract
This commit is contained in:
parent
6ec32143b7
commit
938ea14d44
@ -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();
|
||||
}
|
||||
}
|
||||
@ -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++;
|
||||
}
|
||||
}
|
||||
48
lottery/src/Raffle.sol
Normal file
48
lottery/src/Raffle.sol
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user