-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
01044bd
commit 872eddc
Showing
7 changed files
with
107 additions
and
39 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
check: | ||
git apply "bugs/$(bug).patch" && forge test | ||
|
||
clean: | ||
git checkout src/WETH9.sol |
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,13 @@ | ||
diff --git a/src/WETH9.sol b/src/WETH9.sol | ||
index cd55b98..ccb40cb 100644 | ||
--- a/src/WETH9.sol | ||
+++ b/src/WETH9.sol | ||
@@ -33,7 +33,7 @@ contract WETH9 { | ||
} | ||
|
||
function deposit() public payable { | ||
- balanceOf[msg.sender] += msg.value; | ||
+ balanceOf[msg.sender] += 1; | ||
emit Deposit(msg.sender, msg.value); | ||
} | ||
|
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,13 @@ | ||
diff --git a/src/WETH9.sol b/src/WETH9.sol | ||
index cd55b98..961f03b 100644 | ||
--- a/src/WETH9.sol | ||
+++ b/src/WETH9.sol | ||
@@ -40,7 +40,7 @@ contract WETH9 { | ||
function withdraw(uint256 wad) public { | ||
require(balanceOf[msg.sender] >= wad); | ||
balanceOf[msg.sender] -= wad; | ||
- payable(msg.sender).transfer(wad); | ||
+ payable(msg.sender).transfer(1); | ||
emit Withdrawal(msg.sender, wad); | ||
} | ||
|
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,12 @@ | ||
diff --git a/src/WETH9.sol b/src/WETH9.sol | ||
index cd55b98..6e74bd5 100644 | ||
--- a/src/WETH9.sol | ||
+++ b/src/WETH9.sol | ||
@@ -29,7 +29,6 @@ contract WETH9 { | ||
mapping(address => mapping(address => uint256)) public allowance; | ||
|
||
fallback() external payable { | ||
- deposit(); | ||
} | ||
|
||
function deposit() public payable { |
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,22 @@ | ||
diff --git a/src/WETH9.sol b/src/WETH9.sol | ||
index cd55b98..26cec99 100644 | ||
--- a/src/WETH9.sol | ||
+++ b/src/WETH9.sol | ||
@@ -59,15 +59,8 @@ contract WETH9 { | ||
} | ||
|
||
function transferFrom(address src, address dst, uint256 wad) public returns (bool) { | ||
- require(balanceOf[src] >= wad); | ||
- | ||
- if (src != msg.sender && allowance[src][msg.sender] != type(uint256).max) { | ||
- require(allowance[src][msg.sender] >= wad); | ||
- allowance[src][msg.sender] -= wad; | ||
- } | ||
- | ||
- balanceOf[src] -= wad; | ||
- balanceOf[dst] += wad; | ||
+ balanceOf[src] -= wad; | ||
+ balanceOf[dst] += 1; | ||
|
||
emit Transfer(src, dst, wad); | ||
|
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,40 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.13; | ||
|
||
struct AddressSet { | ||
address[] addrs; | ||
mapping(address => bool) saved; | ||
} | ||
|
||
library LibAddressSet { | ||
function add(AddressSet storage s, address addr) internal { | ||
if (!s.saved[addr]) { | ||
s.addrs.push(addr); | ||
s.saved[addr] = true; | ||
} | ||
} | ||
|
||
function contains(AddressSet storage s, address addr) internal view returns (bool) { | ||
return s.saved[addr]; | ||
} | ||
|
||
function count(AddressSet storage s) internal view returns (uint256) { | ||
return s.addrs.length; | ||
} | ||
|
||
function forEach(AddressSet storage s, function(address) external func) internal { | ||
for (uint256 i; i < s.addrs.length; ++i) { | ||
func(s.addrs[i]); | ||
} | ||
} | ||
|
||
function reduce(AddressSet storage s, uint256 acc, function(uint256,address) external returns (uint256) func) | ||
internal | ||
returns (uint256) | ||
{ | ||
for (uint256 i; i < s.addrs.length; ++i) { | ||
acc = func(acc, s.addrs[i]); | ||
} | ||
return acc; | ||
} | ||
} |