Skip to content

Commit

Permalink
refactor: remove OZ dependency in dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
QGarchery committed Oct 12, 2023
1 parent 1dc07bd commit 0783ddb
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 7 deletions.
40 changes: 37 additions & 3 deletions certora/dispatch/ERC20Standard.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,42 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

import {ERC20} from "../../lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol";
contract ERC20Standard {
address public owner;
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;

contract ERC20Standard is ERC20 {
constructor(string memory name, string memory symbol) ERC20(name, symbol) {}
constructor() {
owner = msg.sender;
}

modifier onlyOwner() {
require(msg.sender == owner);
_;
}

function _transfer(address _from, address _to, uint256 _amount) internal returns (bool) {
balanceOf[_from] -= _amount;
balanceOf[_to] += _amount;
return true;
}

function transfer(address _to, uint256 _amount) public returns (bool) {
return _transfer(msg.sender, _to, _amount);
}

function transferFrom(address _from, address _to, uint256 _amount) public returns (bool) {
allowance[_from][msg.sender] -= _amount;
return _transfer(_from, _to, _amount);
}

function approve(address _spender, uint256 _amount) public {
allowance[msg.sender][_spender] = _amount;
}

function mint(address _receiver, uint256 _amount) public onlyOwner {
balanceOf[_receiver] += _amount;
totalSupply += _amount;
}
}
6 changes: 2 additions & 4 deletions certora/dispatch/ERC20USDT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
pragma solidity ^0.8.0;

contract ERC20USDT {
uint256 public constant MAX_UINT = 2 ** 256 - 1;

uint256 public totalSupply;
address public owner;
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;

Expand All @@ -28,7 +26,7 @@ contract ERC20USDT {
}

function transferFrom(address _from, address _to, uint256 _amount) public {
if (allowance[_from][msg.sender] < MAX_UINT) {
if (allowance[_from][msg.sender] < type(uint256).max) {
allowance[_from][msg.sender] -= _amount;
}
_transfer(_from, _to, _amount);
Expand Down

0 comments on commit 0783ddb

Please sign in to comment.