From 189835762e908a646f88ef74e176b875c32943da Mon Sep 17 00:00:00 2001 From: Lucas Manuel Date: Fri, 26 Nov 2021 09:07:29 -0500 Subject: [PATCH] chore: Remove erc20 dependency (SC-4209) (#6) * chore: use IERC20Like instead of IERC20 * dapp uninstall erc20 --- .gitmodules | 3 --- lib/erc20 | 1 - src/ERC20Helper.sol | 8 ++++---- src/interfaces/IERC20Like.sol | 13 +++++++++++++ 4 files changed, 17 insertions(+), 8 deletions(-) delete mode 160000 lib/erc20 create mode 100644 src/interfaces/IERC20Like.sol diff --git a/.gitmodules b/.gitmodules index a5d3e70..2e9401e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "lib/erc20"] - path = lib/erc20 - url = https://github.com/maple-labs/erc20.git [submodule "lib/ds-test"] path = lib/ds-test url = https://github.com/dapphub/ds-test.git diff --git a/lib/erc20 b/lib/erc20 deleted file mode 160000 index de7fc2c..0000000 --- a/lib/erc20 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit de7fc2cda0f847c4e8fa087bdc5dc04018bdb49a diff --git a/src/ERC20Helper.sol b/src/ERC20Helper.sol index f0edff5..e23d134 100644 --- a/src/ERC20Helper.sol +++ b/src/ERC20Helper.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only pragma solidity ^0.8.7; -import { IERC20 } from "../lib/erc20/src/interfaces/IERC20.sol"; +import { IERC20Like } from "./interfaces/IERC20Like.sol"; /** * @title Small Library to standardize erc20 token interactions. @@ -15,15 +15,15 @@ library ERC20Helper { /**************************/ function transfer(address token, address to, uint256 amount) internal returns (bool) { - return _call(token, abi.encodeWithSelector(IERC20.transfer.selector, to, amount)); + return _call(token, abi.encodeWithSelector(IERC20Like.transfer.selector, to, amount)); } function transferFrom(address token, address from, address to, uint256 amount) internal returns (bool) { - return _call(token, abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, amount)); + return _call(token, abi.encodeWithSelector(IERC20Like.transferFrom.selector, from, to, amount)); } function approve(address token, address spender, uint256 amount) internal returns (bool) { - return _call(token, abi.encodeWithSelector(IERC20.approve.selector, spender, amount)); + return _call(token, abi.encodeWithSelector(IERC20Like.approve.selector, spender, amount)); } function _call(address token, bytes memory data) private returns (bool success) { diff --git a/src/interfaces/IERC20Like.sol b/src/interfaces/IERC20Like.sol new file mode 100644 index 0000000..b66a4be --- /dev/null +++ b/src/interfaces/IERC20Like.sol @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: AGPL-3.0-only +pragma solidity ^0.8.7; + +/// @title Interface of the ERC20 standard as needed by ERC20Helper +interface IERC20Like { + + function approve(address spender, uint256 amount) external returns (bool); + + function transfer(address recipient, uint256 amount) external returns (bool); + + function transferFrom(address owner, address recipient, uint256 amount) external returns (bool); + +}