@1inch/solidity-utils 2.0.20 → 2.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,7 @@ abstract contract OnlyWethReceiver {
7
7
  error EthDepositRejected();
8
8
 
9
9
  // solhint-disable-next-line var-name-mixedcase
10
- address internal immutable _WETH;
10
+ address private immutable _WETH;
11
11
 
12
12
  constructor(address weth) {
13
13
  _WETH = weth;
@@ -69,13 +69,7 @@ library UniERC20 {
69
69
  function uniApprove(IERC20 token, address to, uint256 amount) internal {
70
70
  if (isETH(token)) revert ApproveCalledOnETH();
71
71
 
72
- // solhint-disable-next-line avoid-low-level-calls
73
- (bool success, bytes memory returndata) = address(token).call(abi.encodeWithSelector(token.approve.selector, to, amount));
74
-
75
- if (!success || (returndata.length > 0 && !abi.decode(returndata, (bool)))) {
76
- _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, to, 0));
77
- _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, to, amount));
78
- }
72
+ token.forceApprove(to, amount);
79
73
  }
80
74
 
81
75
  function _uniDecode(IERC20 token, string memory lowerCaseSignature, string memory upperCaseSignature) private view returns(string memory) {
@@ -100,34 +94,19 @@ library UniERC20 {
100
94
  }
101
95
 
102
96
  if (success && data.length == 32) {
103
- uint len = 0;
97
+ uint256 len = 0;
104
98
  while (len < data.length && data[len] >= 0x20 && data[len] <= 0x7E) {
105
99
  len++;
106
100
  }
107
101
 
108
102
  if (len > 0) {
109
- bytes memory result = new bytes(len);
110
- unchecked {
111
- for (uint i = 0; i < len; i++) {
112
- result[i] = data[i];
113
- }
103
+ assembly { // solhint-disable-line no-inline-assembly
104
+ mstore(data, len)
114
105
  }
115
- return string(result);
106
+ return string(data);
116
107
  }
117
108
  }
118
109
 
119
110
  return StringUtil.toHex(address(token));
120
111
  }
121
-
122
- function _callOptionalReturn(IERC20 token, bytes memory data) private {
123
- // solhint-disable-next-line avoid-low-level-calls
124
- (bool success, bytes memory result) = address(token).call(data);
125
- if (!success) {
126
- RevertReasonForwarder.reRevert();
127
- }
128
-
129
- if (result.length > 0) { // Return data is optional
130
- if (!abi.decode(result, (bool))) revert ERC20OperationFailed();
131
- }
132
- }
133
112
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1inch/solidity-utils",
3
- "version": "2.0.20",
3
+ "version": "2.0.21",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "repository": {