Skip to content

Commit 08962a8

Browse files
committed
use openzeppelin/contracts
1 parent 77c940d commit 08962a8

File tree

4 files changed

+25
-3388
lines changed

4 files changed

+25
-3388
lines changed

basic/26-quadratic-vote&gitcoin/contracts/FinancingTool.sol

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
// SPDX-License-Identifier: MIT
12
pragma solidity ^0.8.0;
23

4+
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
5+
36
interface IERC20 {
47

58
function balanceOf(address account) external view returns (uint256);
@@ -14,51 +17,6 @@ interface IERC20 {
1417

1518
}
1619

17-
library SafeMath {
18-
function add(uint256 a, uint256 b) internal pure returns (uint256) {
19-
uint256 c = a + b;
20-
require(c >= a, "SafeMath: addition overflow");
21-
22-
return c;
23-
}
24-
25-
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
26-
require(b <= a, "SafeMath: subtraction overflow");
27-
uint256 c = a - b;
28-
29-
return c;
30-
}
31-
32-
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
33-
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
34-
// benefit is lost if 'b' is also tested.
35-
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
36-
if (a == 0) {
37-
return 0;
38-
}
39-
40-
uint256 c = a * b;
41-
require(c / a == b, "SafeMath: multiplication overflow");
42-
43-
return c;
44-
}
45-
46-
function div(uint256 a, uint256 b) internal pure returns (uint256) {
47-
// Solidity only automatically asserts when dividing by 0
48-
require(b > 0, "SafeMath: division by zero");
49-
uint256 c = a / b;
50-
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
51-
52-
return c;
53-
}
54-
55-
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
56-
require(b != 0, "SafeMath: modulo by zero");
57-
return a % b;
58-
}
59-
60-
}
61-
6220
contract FinancingTool {
6321
function safeTransfer(address token, address to, uint256 value) internal {
6422
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));

0 commit comments

Comments
 (0)