-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #510 from morpho-labs/build/remove-oz
build(deps): remove oz
- Loading branch information
Showing
8 changed files
with
75 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
[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 |
Submodule openzeppelin-contracts
deleted from
fd81a9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
ds-test/=lib/forge-std/lib/ds-test/src/ | ||
forge-std/=lib/forge-std/src/ | ||
openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,52 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity ^0.8.0; | ||
|
||
import {ERC20} from "openzeppelin-contracts/token/ERC20/ERC20.sol"; | ||
import {IERC20} from "./interfaces/IERC20.sol"; | ||
|
||
contract ERC20Mock is ERC20 { | ||
constructor(string memory name, string memory symbol) ERC20(name, symbol) {} | ||
contract ERC20Mock is IERC20 { | ||
uint256 public totalSupply; | ||
|
||
function setBalance(address account, uint256 amount) external { | ||
_burn(account, balanceOf(account)); | ||
_mint(account, amount); | ||
mapping(address account => uint256) public balanceOf; | ||
mapping(address account => mapping(address spender => uint256)) public allowance; | ||
|
||
function setBalance(address account, uint256 amount) public virtual { | ||
if (amount > balanceOf[account]) totalSupply += amount - balanceOf[account]; | ||
else totalSupply -= balanceOf[account] - amount; | ||
|
||
balanceOf[account] = amount; | ||
} | ||
|
||
function approve(address spender, uint256 amount) public virtual returns (bool) { | ||
allowance[msg.sender][spender] = amount; | ||
|
||
emit Approval(msg.sender, spender, amount); | ||
|
||
return true; | ||
} | ||
|
||
function transfer(address to, uint256 amount) public virtual returns (bool) { | ||
require(balanceOf[msg.sender] >= amount, "insufficient balance"); | ||
|
||
balanceOf[msg.sender] -= amount; | ||
balanceOf[to] += amount; | ||
|
||
emit Transfer(msg.sender, to, amount); | ||
|
||
return true; | ||
} | ||
|
||
function transferFrom(address from, address to, uint256 amount) public virtual returns (bool) { | ||
require(allowance[from][msg.sender] >= amount, "insufficient allowance"); | ||
|
||
allowance[from][msg.sender] -= amount; | ||
|
||
require(balanceOf[from] >= amount, "insufficient balance"); | ||
|
||
balanceOf[from] -= amount; | ||
balanceOf[to] += amount; | ||
|
||
emit Transfer(from, to, amount); | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity ^0.8.0; | ||
|
||
interface IERC20 { | ||
/* EVENTS */ | ||
|
||
event Transfer(address indexed from, address indexed to, uint256 value); | ||
|
||
event Approval(address indexed owner, address indexed spender, uint256 value); | ||
|
||
/* FUNCTIONS */ | ||
|
||
function totalSupply() external view returns (uint256); | ||
|
||
function balanceOf(address account) external view returns (uint256); | ||
|
||
function transfer(address to, uint256 value) external returns (bool); | ||
|
||
function allowance(address owner, address spender) external view returns (uint256); | ||
|
||
function approve(address spender, uint256 value) external returns (bool); | ||
|
||
function transferFrom(address from, address to, uint256 value) external returns (bool); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters