Skip to content

Commit 0ee7d79

Browse files
committed
chore: move non standard erc20 contracts to the test file
1 parent 323c79d commit 0ee7d79

File tree

2 files changed

+49
-57
lines changed

2 files changed

+49
-57
lines changed

test/e2e/NonStandardErc20.t.sol

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,61 @@ pragma solidity ^0.8;
33

44
import {Vm} from "forge-std/Vm.sol";
55

6-
import {ERC20NoReturn, ERC20ReturningUint} from "../src/NonStandardERC20.sol";
76
import {Helper} from "./Helper.sol";
87
import {IERC20} from "src/contracts/interfaces/IERC20.sol";
98

109
import {GPv2Order, GPv2Signing, SettlementEncoder} from "../libraries/encoders/SettlementEncoder.sol";
1110
import {Registry, TokenRegistry} from "../libraries/encoders/TokenRegistry.sol";
1211

12+
abstract contract NonStandardERC20 {
13+
mapping(address => uint256) public balanceOf;
14+
mapping(address => mapping(address => uint256)) public allowance;
15+
16+
function mint(address to, uint256 amount) external {
17+
balanceOf[to] += amount;
18+
}
19+
20+
function approve(address spender, uint256 amount) external {
21+
allowance[msg.sender][spender] = amount;
22+
}
23+
24+
function transfer_(address to, uint256 amount) internal {
25+
balanceOf[msg.sender] -= amount;
26+
balanceOf[to] += amount;
27+
}
28+
29+
function transferFrom_(address from, address to, uint256 amount) internal {
30+
allowance[from][msg.sender] -= amount;
31+
balanceOf[from] -= amount;
32+
balanceOf[to] += amount;
33+
}
34+
}
35+
36+
contract ERC20NoReturn is NonStandardERC20 {
37+
function transfer(address to, uint256 amount) external {
38+
transfer_(to, amount);
39+
}
40+
41+
function transferFrom(address from, address to, uint256 amount) external {
42+
transferFrom_(from, to, amount);
43+
}
44+
}
45+
46+
contract ERC20ReturningUint is NonStandardERC20 {
47+
// Largest 256-bit prime :)
48+
uint256 private constant OK = 115792089237316195423570985008687907853269984665640564039457584007913129639747;
49+
50+
function transfer(address to, uint256 amount) external returns (uint256) {
51+
transfer_(to, amount);
52+
return OK;
53+
}
54+
55+
function transferFrom(address from, address to, uint256 amount) external returns (uint256) {
56+
transferFrom_(from, to, amount);
57+
return OK;
58+
}
59+
}
60+
1361
using SettlementEncoder for SettlementEncoder.State;
1462
using TokenRegistry for TokenRegistry.State;
1563
using TokenRegistry for Registry;

test/src/NonStandardERC20.sol

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)