Skip to content

Commit

Permalink
chore: Update solmate to openzeppelin
Browse files Browse the repository at this point in the history
  • Loading branch information
stonehengeLR committed Jul 4, 2024
1 parent 591cf53 commit 0ba5d3a
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 19 deletions.
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,14 @@
"hardhat-gas-reporter": "^1.0.8",
"husky": "^7.0.4",
"merkletreejs": "^0.2.31",
"@openzeppelin/contracts": "^5.0.2",
"prettier": "^2.3.2",
"prettier-plugin-solidity": "^1.3.0",
"release-it": "^15.0.0",
"solhint": "^3.3.7",
"solidity-coverage": "^0.7.21",
"solmate": "^6.6.1",
"ts-node": "^10.1.0",
"typechain": "^5.1.2",
"typescript": "^4.5.2"
},
"dependencies": {
"@openzeppelin/contracts": "^5.0.2"
}
}
10 changes: 5 additions & 5 deletions test/foundry/LowLevelWETH.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import {WETH} from "solmate/src/tokens/WETH.sol";
import {MockWETH} from "../mock/MockWETH.sol";
import {LowLevelWETH} from "../../contracts/lowLevelCallers/LowLevelWETH.sol";
import {TestHelpers} from "./utils/TestHelpers.sol";

Expand Down Expand Up @@ -30,18 +30,18 @@ contract RecipientFallback {
contract LowLevelWETHTest is TestParameters, TestHelpers {
ImplementedLowLevelWETH public lowLevelWETH;
RecipientFallback public recipientFallback;
WETH public weth;
MockWETH public mockWeth;

function setUp() external {
lowLevelWETH = new ImplementedLowLevelWETH();
recipientFallback = new RecipientFallback();
weth = new WETH();
mockWeth = new MockWETH();
}

function testTransferETHAndRevertsinWETH(uint256 amount) external payable asPrankedUser(_sender) {
vm.deal(_sender, amount);
lowLevelWETH.transferETH{value: amount}(address(weth), address(recipientFallback), _GAS_LIMIT);
lowLevelWETH.transferETH{value: amount}(address(mockWeth), address(recipientFallback), _GAS_LIMIT);
assertEq(address(recipientFallback).balance, 0);
assertEq(weth.balanceOf(address(recipientFallback)), amount);
assertEq(mockWeth.balanceOf(address(recipientFallback)), amount);
}
}
4 changes: 2 additions & 2 deletions test/mock/MockERC1155.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.7;

import {ERC1155} from "solmate/src/tokens/ERC1155.sol";
import {ERC1155} from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";

contract MockERC1155 is ERC1155 {
contract MockERC1155 is ERC1155("MockURI") {
function uri(uint256) public pure override returns (string memory) {
return "uri";
}
Expand Down
4 changes: 2 additions & 2 deletions test/mock/MockERC20.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.7;

import {ERC20} from "solmate/src/tokens/ERC20.sol";
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract MockERC20 is ERC20("MockERC20", "MockERC20", 18) {
contract MockERC20 is ERC20("MockERC20", "MockERC20") {
function mint(address to, uint256 amount) public {
_mint(to, amount);
}
Expand Down
2 changes: 1 addition & 1 deletion test/mock/MockERC721.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.7;

import {ERC721} from "solmate/src/tokens/ERC721.sol";
import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import {IERC165} from "../../contracts/interfaces/generic/IERC165.sol";

contract MockERC721 is ERC721("MockERC721", "MockERC721") {
Expand Down
62 changes: 62 additions & 0 deletions test/mock/MockWETH.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

contract MockWETH {
string public name = "Wrapped Ether";
string public symbol = "WETH";
uint8 public decimals = 18;

event Approval(address indexed src, address indexed guy, uint256 wad);
event Transfer(address indexed src, address indexed dst, uint256 wad);
event Deposit(address indexed dst, uint256 wad);
event Withdrawal(address indexed src, uint256 wad);

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

receive() external payable {
deposit();
}

function deposit() public payable {
balanceOf[msg.sender] += msg.value;
emit Deposit(msg.sender, msg.value);
}

function withdraw(uint256 wad) public {
require(balanceOf[msg.sender] >= wad);
balanceOf[msg.sender] -= wad;
payable(msg.sender).transfer(wad);
emit Withdrawal(msg.sender, wad);
}

function totalSupply() public view returns (uint256) {
return address(this).balance;
}

function approve(address guy, uint256 wad) public returns (bool) {
allowance[msg.sender][guy] = wad;
emit Approval(msg.sender, guy, wad);
return true;
}

function transfer(address dst, uint256 wad) public returns (bool) {
return transferFrom(msg.sender, dst, wad);
}

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;

emit Transfer(src, dst, wad);

return true;
}
}
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10331,11 +10331,6 @@ solidity-coverage@^0.7.21:
shelljs "^0.8.3"
web3-utils "^1.3.0"

solmate@^6.6.1:
version "6.6.1"
resolved "https://registry.yarnpkg.com/solmate/-/solmate-6.6.1.tgz#f0907e1cdada6dd5fbfe11811ab545162b713197"
integrity sha512-WHvRXQvGtgR6R9nmkDTz/d+oULMqf/D33rlzQyadTX2SbuTmaW7ToEjGjGtWUVCQwZsZ/JP3vbOEVv7fB50btg==

source-map-resolve@^0.5.0:
version "0.5.3"
resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.3.tgz#190866bece7553e1f8f267a2ee82c606b5509a1a"
Expand Down

0 comments on commit 0ba5d3a

Please sign in to comment.