Skip to content

Commit

Permalink
feat: add erc20 testnet contract
Browse files Browse the repository at this point in the history
  • Loading branch information
aon committed Nov 27, 2024
1 parent 9141212 commit 02c98de
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 34 deletions.
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# Compiler files
broadcast/
cache/
out/

# Ignores development broadcast logs
!/broadcast
/broadcast/*/31337/
/broadcast/**/dry-run/
zkout/

# Docs
docs/
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ src = "src"
out = "out"
libs = ["lib"]

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
[profile.default.zksync]
zksolc = "1.5.6"
1 change: 1 addition & 0 deletions lib/openzeppelin-contracts
Submodule openzeppelin-contracts added at 69c8de
1 change: 1 addition & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/
28 changes: 28 additions & 0 deletions script/ERC20.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Script, console} from "forge-std/Script.sol";
import {TestnetERC20Token} from "../src/TestnetERC20Token.sol";

contract ERC20Script is Script {
TestnetERC20Token public dai;
TestnetERC20Token public wbtc;

function setUp() public {}

function run() public {
vm.startBroadcast();

dai = new TestnetERC20Token("DAI", "DAI", 18);
dai.mint(msg.sender, 10_000_000 * 10**18);
console.log("DAI address", address(dai));
console.log("DAI minted", dai.balanceOf(msg.sender));

wbtc = new TestnetERC20Token("WBTC", "WBTC", 18);
wbtc.mint(msg.sender, 10_000_000 * 10**18);
console.log("WBTC address", address(wbtc));
console.log("WBTC minted", wbtc.balanceOf(msg.sender));

vm.stopBroadcast();
}
}
18 changes: 14 additions & 4 deletions src/Counter.sol
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

contract Counter {
uint256 public number;
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

function setNumber(uint256 newNumber) public {
contract Counter is Ownable {
uint256 private number;

constructor() Ownable(msg.sender) {}

function getNumber() public view returns (uint256) {
return number;
}

function setNumber(uint256 newNumber) public onlyOwner {
number = newNumber;
}

function increment() public {
function increment() public onlyOwner {
number++;
}

receive() external payable {}
}
25 changes: 25 additions & 0 deletions src/TestnetERC20Token.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: MIT

pragma solidity 0.8.24;

import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract TestnetERC20Token is ERC20 {
// add this to be excluded from coverage report
function test() internal virtual {}

uint8 private _decimals;

constructor(string memory name_, string memory symbol_, uint8 decimals_) ERC20(name_, symbol_) {
_decimals = decimals_;
}

function mint(address _to, uint256 _amount) public returns (bool) {
_mint(_to, _amount);
return true;
}

function decimals() public view override returns (uint8) {
return _decimals;
}
}
24 changes: 0 additions & 24 deletions test/Counter.t.sol

This file was deleted.

0 comments on commit 02c98de

Please sign in to comment.