From c630e106ffd3879dc723d82aef114d4ac8782cba Mon Sep 17 00:00:00 2001 From: panditdhamdhere Date: Thu, 5 Sep 2024 21:55:37 +0530 Subject: [PATCH] erc20 contract ready next on --- .gitmodules | 3 +++ foundry.toml | 19 +++++++++++++++++++ lib/openzeppelin-contracts | 1 + script/Counter.s.sol | 19 ------------------- src/Counter.sol | 14 -------------- src/MerkleAirdrop.sol | 8 ++++++++ src/MisalToken.sol | 13 +++++++++++++ test/Counter.t.sol | 24 ------------------------ 8 files changed, 44 insertions(+), 57 deletions(-) create mode 160000 lib/openzeppelin-contracts delete mode 100644 script/Counter.s.sol delete mode 100644 src/Counter.sol create mode 100644 src/MerkleAirdrop.sol create mode 100644 src/MisalToken.sol delete mode 100644 test/Counter.t.sol diff --git a/.gitmodules b/.gitmodules index 888d42d..690924b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "lib/forge-std"] path = lib/forge-std url = https://github.com/foundry-rs/forge-std +[submodule "lib/openzeppelin-contracts"] + path = lib/openzeppelin-contracts + url = https://github.com/OpenZeppelin/openzeppelin-contracts diff --git a/foundry.toml b/foundry.toml index 25b918f..3040468 100644 --- a/foundry.toml +++ b/foundry.toml @@ -2,5 +2,24 @@ src = "src" out = "out" libs = ["lib"] +ffi = true +solc = "0.8.24" +fs_permissions = [{ access = "read-write", path = "./" }] +remappings = [ + 'murky/=lib/murky/', + '@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/', + 'foundry-devops/=lib/foundry-devops', + 'forge-std/=lib/forge-std/src/', +] + +[fmt] +bracket_spacing = true +int_types = "long" +line_length = 120 +multiline_func_header = "all" +number_underscore = "thousands" +quote_style = "double" +tab_width = 4 +wrap_comments = true # See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options diff --git a/lib/openzeppelin-contracts b/lib/openzeppelin-contracts new file mode 160000 index 0000000..dbb6104 --- /dev/null +++ b/lib/openzeppelin-contracts @@ -0,0 +1 @@ +Subproject commit dbb6104ce834628e473d2173bbc9d47f81a9eec3 diff --git a/script/Counter.s.sol b/script/Counter.s.sol deleted file mode 100644 index cdc1fe9..0000000 --- a/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/src/Counter.sol b/src/Counter.sol deleted file mode 100644 index aded799..0000000 --- a/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/src/MerkleAirdrop.sol b/src/MerkleAirdrop.sol new file mode 100644 index 0000000..322d16d --- /dev/null +++ b/src/MerkleAirdrop.sol @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.24; + +contract MerkleAirdrop { + // some list of addresses + + // Allow someone in the list to claim ERC 20 the token. +} \ No newline at end of file diff --git a/src/MisalToken.sol b/src/MisalToken.sol new file mode 100644 index 0000000..eb11388 --- /dev/null +++ b/src/MisalToken.sol @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.25; + +import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; +import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; + +contract MisalToken is ERC20, Ownable { + constructor() ERC20("Misal", "MISAL") Ownable(msg.sender) {} + + function mint(address to, uint256 amount) external onlyOwner { + _mint(to, amount); + } +} diff --git a/test/Counter.t.sol b/test/Counter.t.sol deleted file mode 100644 index 54b724f..0000000 --- a/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); - } -}