Skip to content

Commit

Permalink
chore: Remove erc20 dependency (SC-4209) (#6)
Browse files Browse the repository at this point in the history
* chore: use IERC20Like instead of IERC20

* dapp uninstall erc20
  • Loading branch information
Lucas Manuel authored Nov 26, 2021
1 parent 6034525 commit 1898357
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion lib/erc20
Submodule erc20 deleted from de7fc2
8 changes: 4 additions & 4 deletions src/ERC20Helper.sol
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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) {
Expand Down
13 changes: 13 additions & 0 deletions src/interfaces/IERC20Like.sol
Original file line number Diff line number Diff line change
@@ -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);

}

0 comments on commit 1898357

Please sign in to comment.