From 0ee7d79fa66514a3142eda5cba319ced5aec1466 Mon Sep 17 00:00:00 2001 From: Meet Mangukiya Date: Thu, 26 Sep 2024 11:39:29 +0530 Subject: [PATCH] chore: move non standard erc20 contracts to the test file --- test/e2e/NonStandardErc20.t.sol | 50 ++++++++++++++++++++++++++++- test/src/NonStandardERC20.sol | 56 --------------------------------- 2 files changed, 49 insertions(+), 57 deletions(-) delete mode 100644 test/src/NonStandardERC20.sol diff --git a/test/e2e/NonStandardErc20.t.sol b/test/e2e/NonStandardErc20.t.sol index 2d58af26..1445d1d9 100644 --- a/test/e2e/NonStandardErc20.t.sol +++ b/test/e2e/NonStandardErc20.t.sol @@ -3,13 +3,61 @@ pragma solidity ^0.8; import {Vm} from "forge-std/Vm.sol"; -import {ERC20NoReturn, ERC20ReturningUint} from "../src/NonStandardERC20.sol"; import {Helper} from "./Helper.sol"; import {IERC20} from "src/contracts/interfaces/IERC20.sol"; import {GPv2Order, GPv2Signing, SettlementEncoder} from "../libraries/encoders/SettlementEncoder.sol"; import {Registry, TokenRegistry} from "../libraries/encoders/TokenRegistry.sol"; +abstract contract NonStandardERC20 { + mapping(address => uint256) public balanceOf; + mapping(address => mapping(address => uint256)) public allowance; + + function mint(address to, uint256 amount) external { + balanceOf[to] += amount; + } + + function approve(address spender, uint256 amount) external { + allowance[msg.sender][spender] = amount; + } + + function transfer_(address to, uint256 amount) internal { + balanceOf[msg.sender] -= amount; + balanceOf[to] += amount; + } + + function transferFrom_(address from, address to, uint256 amount) internal { + allowance[from][msg.sender] -= amount; + balanceOf[from] -= amount; + balanceOf[to] += amount; + } +} + +contract ERC20NoReturn is NonStandardERC20 { + function transfer(address to, uint256 amount) external { + transfer_(to, amount); + } + + function transferFrom(address from, address to, uint256 amount) external { + transferFrom_(from, to, amount); + } +} + +contract ERC20ReturningUint is NonStandardERC20 { + // Largest 256-bit prime :) + uint256 private constant OK = 115792089237316195423570985008687907853269984665640564039457584007913129639747; + + function transfer(address to, uint256 amount) external returns (uint256) { + transfer_(to, amount); + return OK; + } + + function transferFrom(address from, address to, uint256 amount) external returns (uint256) { + transferFrom_(from, to, amount); + return OK; + } +} + using SettlementEncoder for SettlementEncoder.State; using TokenRegistry for TokenRegistry.State; using TokenRegistry for Registry; diff --git a/test/src/NonStandardERC20.sol b/test/src/NonStandardERC20.sol deleted file mode 100644 index c91f8843..00000000 --- a/test/src/NonStandardERC20.sol +++ /dev/null @@ -1,56 +0,0 @@ -// SPDX-License-Identifier: LGPL-3.0-or-later -// solhint-disable-next-line compiler-version -pragma solidity >=0.7.6 <0.9.0; - -import "src/contracts/libraries/SafeMath.sol"; - -abstract contract NonStandardERC20 { - using SafeMath for uint256; - - mapping(address => uint256) public balanceOf; - mapping(address => mapping(address => uint256)) public allowance; - - function mint(address to, uint256 amount) external { - balanceOf[to] = balanceOf[to].add(amount); - } - - function approve(address spender, uint256 amount) external { - allowance[msg.sender][spender] = amount; - } - - function transfer_(address to, uint256 amount) internal { - balanceOf[msg.sender] = balanceOf[msg.sender].sub(amount); - balanceOf[to] = balanceOf[to].add(amount); - } - - function transferFrom_(address from, address to, uint256 amount) internal { - allowance[from][msg.sender] = allowance[from][msg.sender].sub(amount); - balanceOf[from] = balanceOf[from].sub(amount); - balanceOf[to] = balanceOf[to].add(amount); - } -} - -contract ERC20NoReturn is NonStandardERC20 { - function transfer(address to, uint256 amount) external { - transfer_(to, amount); - } - - function transferFrom(address from, address to, uint256 amount) external { - transferFrom_(from, to, amount); - } -} - -contract ERC20ReturningUint is NonStandardERC20 { - // Largest 256-bit prime :) - uint256 private constant OK = 115792089237316195423570985008687907853269984665640564039457584007913129639747; - - function transfer(address to, uint256 amount) external returns (uint256) { - transfer_(to, amount); - return OK; - } - - function transferFrom(address from, address to, uint256 amount) external returns (uint256) { - transferFrom_(from, to, amount); - return OK; - } -}