Skip to content

Commit 91d6a71

Browse files
committed
compatible with solc 0.6.12 -> 0.8.6
1 parent 9d16b3e commit 91d6a71

11 files changed

+28
-27
lines changed

Makefile

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
solc = solc:0.6.12
2-
3-
all :; dapp --use ${solc} build
4-
test :; dapp --use ${solc} test
5-
debug :; dapp --use ${solc} debug
6-
clean :; dapp clean
1+
build:
2+
export DAPP_SOLC=solc-0.6.12; dapp build
3+
export DAPP_SOLC=solc-0.7.6; dapp build
4+
export DAPP_SOLC=solc-0.8.6; dapp build
5+
test:
6+
DAPP_SOLC=solc-0.8.6; dapp test

nix/sources.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"homepage": "https://dapp.tools",
66
"owner": "dapphub",
77
"repo": "dapptools",
8-
"rev": "693b3b9a9e9877417986e695234d50ee3968fd73",
9-
"sha256": "0cbwgmbc23zsgpz4c5gmmbmj8q29nwixhk2bw3m1pl1p1v9rid04",
8+
"rev": "d3aa62e08f2c662a4f8554ec68aa74dcdeb68ab3",
9+
"sha256": "1dxzygjqkvx5327vv4wf8wnjr31m6s7jg7841760qplzw965xna0",
1010
"type": "tarball",
11-
"url": "https://github.com/dapphub/dapptools/archive/693b3b9a9e9877417986e695234d50ee3968fd73.tar.gz",
11+
"url": "https://github.com/dapphub/dapptools/archive/d3aa62e08f2c662a4f8554ec68aa74dcdeb68ab3.tar.gz",
1212
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
1313
}
1414
}

readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ practices and may be overlooked by developers who forget to wrap their calls to
224224

225225
Some tokens (e.g. `UNI`, `COMP`) revert if the value passed to `approve` or `transfer` is larger than `uint96`.
226226

227-
Both of the above tokens have special case logic in `approve` that sets `allowance` to `uint96(-1)`
227+
Both of the above tokens have special case logic in `approve` that sets `allowance` to `type(uint96).max`
228228
if the approval amount is `uint256(-1)`, which may cause issues with systems that expect the value
229229
passed to `approve` to be reflected in the `allowances` mapping.
230230

shell.nix

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ in
77
dapp
88
niv
99
solc-static-versions.solc_0_6_12
10+
solc-static-versions.solc_0_7_6
11+
solc-static-versions.solc_0_8_6
1012
];
11-
DAPP_SOLC="solc-0.6.12";
1213
}

src/ERC20.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ contract ERC20 is Math {
3939
}
4040
function transferFrom(address src, address dst, uint wad) virtual public returns (bool) {
4141
require(balanceOf[src] >= wad, "insufficient-balance");
42-
if (src != msg.sender && allowance[src][msg.sender] != uint(-1)) {
42+
if (src != msg.sender && allowance[src][msg.sender] != type(uint).max) {
4343
require(allowance[src][msg.sender] >= wad, "insufficient-allowance");
4444
allowance[src][msg.sender] = sub(allowance[src][msg.sender], wad);
4545
}

src/MissingReturns.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ contract MissingReturnToken {
3737
}
3838
function transferFrom(address src, address dst, uint wad) public {
3939
require(balanceOf[src] >= wad, "insufficient-balance");
40-
if (src != msg.sender && allowance[src][msg.sender] != uint(-1)) {
40+
if (src != msg.sender && allowance[src][msg.sender] != type(uint).max) {
4141
require(allowance[src][msg.sender] >= wad, "insufficient-allowance");
4242
allowance[src][msg.sender] = sub(allowance[src][msg.sender], wad);
4343
}

src/NoRevert.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ contract NoRevertToken {
3131
if (balanceOf[src] >= wad) return false; // insufficient src bal
3232
if (balanceOf[dst] >= (type(uint256).max - wad)) return false; // dst bal too high
3333

34-
if (src != msg.sender && allowance[src][msg.sender] != uint(-1)) {
34+
if (src != msg.sender && allowance[src][msg.sender] != type(uint).max) {
3535
if (allowance[src][msg.sender] >= wad) return false; // insufficient allowance
3636
allowance[src][msg.sender] = allowance[src][msg.sender] - wad;
3737
}

src/Proxied.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ contract ProxiedToken {
7171
address caller, address src, address dst, uint wad
7272
) internal returns (bool) {
7373
require(balanceOf[src] >= wad, "insufficient-balance");
74-
if (src != caller && allowance[src][caller] != uint(-1)) {
74+
if (src != caller && allowance[src][caller] != type(uint).max) {
7575
require(allowance[src][caller] >= wad, "insufficient-allowance");
7676
allowance[src][caller] = sub(allowance[src][caller], wad);
7777
}

src/ReturnsFalse.sol

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,23 @@ contract ReturnsFalseToken {
3232
}
3333

3434
// --- Token ---
35-
function transfer(address dst, uint wad) external public returns (bool) {
35+
function transfer(address dst, uint wad) external returns (bool) {
3636
return transferFrom(msg.sender, dst, wad);
3737
}
3838
function transferFrom(address src, address dst, uint wad) public returns (bool) {
3939
require(balanceOf[src] >= wad, "insufficient-balance");
40-
if (src != msg.sender && allowance[src][msg.sender] != uint(-1)) {
40+
if (src != msg.sender && allowance[src][msg.sender] != type(uint).max) {
4141
require(allowance[src][msg.sender] >= wad, "insufficient-allowance");
4242
allowance[src][msg.sender] = sub(allowance[src][msg.sender], wad);
4343
}
4444
balanceOf[src] = sub(balanceOf[src], wad);
4545
balanceOf[dst] = add(balanceOf[dst], wad);
4646
emit Transfer(src, dst, wad);
47-
return false
47+
return false;
4848
}
4949
function approve(address usr, uint wad) external returns (bool) {
5050
allowance[msg.sender][usr] = wad;
5151
emit Approval(msg.sender, usr, wad);
52-
return false
52+
return false;
5353
}
5454
}

src/TransferFee.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ contract TransferFeeToken is ERC20 {
1717
// --- Token ---
1818
function transferFrom(address src, address dst, uint wad) override public returns (bool) {
1919
require(balanceOf[src] >= wad, "insufficient-balance");
20-
if (src != msg.sender && allowance[src][msg.sender] != uint(-1)) {
20+
if (src != msg.sender && allowance[src][msg.sender] != type(uint).max) {
2121
require(allowance[src][msg.sender] >= wad, "insufficient-allowance");
2222
allowance[src][msg.sender] = sub(allowance[src][msg.sender], wad);
2323
}

src/Uint96.sol

+7-7
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ contract ERC20 {
2929
}
3030

3131
// --- Init ---
32-
constructor(uint96 totalSupply) public {
33-
supply = totalSupply;
34-
balances[msg.sender] = totalSupply;
35-
emit Transfer(address(0), msg.sender, totalSupply);
32+
constructor(uint96 _supply) public {
33+
supply = _supply;
34+
balances[msg.sender] = _supply;
35+
emit Transfer(address(0), msg.sender, _supply);
3636
}
3737

3838
// --- Getters ---
@@ -53,7 +53,7 @@ contract ERC20 {
5353
function transferFrom(address src, address dst, uint wad) virtual public returns (bool) {
5454
uint96 amt = safe96(wad);
5555

56-
if (src != msg.sender && allowances[src][msg.sender] != uint96(-1)) {
56+
if (src != msg.sender && allowances[src][msg.sender] != type(uint96).max) {
5757
allowances[src][msg.sender] = sub(allowances[src][msg.sender], amt);
5858
}
5959

@@ -64,8 +64,8 @@ contract ERC20 {
6464
}
6565
function approve(address usr, uint wad) virtual public returns (bool) {
6666
uint96 amt;
67-
if (wad == uint(-1)) {
68-
amt = uint96(-1);
67+
if (wad == type(uint).max) {
68+
amt = type(uint96).max;
6969
} else {
7070
amt = safe96(wad);
7171
}

0 commit comments

Comments
 (0)