@1inch/solidity-utils 2.0.16 → 2.0.19
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.
- package/contracts/libraries/AddressArray.sol +1 -1
- package/contracts/libraries/AddressSet.sol +1 -1
- package/contracts/libraries/RevertReasonForwarder.sol +5 -3
- package/contracts/libraries/RevertReasonParser.sol +13 -9
- package/contracts/libraries/SafeERC20.sol +4 -3
- package/contracts/libraries/StringUtil.sol +2 -2
- package/contracts/libraries/UniERC20.sol +1 -1
- package/dist/src/prelude.d.ts +1 -1
- package/dist/src/prelude.js +3 -0
- package/dist/src/prelude.js.map +1 -1
- package/dist/src/profileEVM.d.ts +1 -0
- package/package.json +21 -21
|
@@ -6,9 +6,11 @@ pragma abicoder v1;
|
|
|
6
6
|
library RevertReasonForwarder {
|
|
7
7
|
function reRevert() internal pure {
|
|
8
8
|
// bubble up revert reason from latest external call
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
/// @solidity memory-safe-assembly
|
|
10
|
+
assembly { // solhint-disable-line no-inline-assembly
|
|
11
|
+
let ptr := mload(0x40)
|
|
12
|
+
returndatacopy(ptr, 0, returndatasize())
|
|
13
|
+
revert(ptr, returndatasize())
|
|
12
14
|
}
|
|
13
15
|
}
|
|
14
16
|
}
|
|
@@ -25,15 +25,18 @@ library RevertReasonParser {
|
|
|
25
25
|
// https://solidity.readthedocs.io/en/latest/control-structures.html#revert
|
|
26
26
|
// We assume that revert reason is abi-encoded as Error(string)
|
|
27
27
|
bytes4 selector;
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
if (data.length >= 4) {
|
|
29
|
+
/// @solidity memory-safe-assembly
|
|
30
|
+
assembly { // solhint-disable-line no-inline-assembly
|
|
31
|
+
selector := mload(add(data, 0x20))
|
|
32
|
+
}
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
// 68 = 4-byte selector + 32 bytes offset + 32 bytes length
|
|
33
36
|
if (selector == _ERROR_SELECTOR && data.length >= 68) {
|
|
34
37
|
string memory reason;
|
|
35
|
-
|
|
36
|
-
assembly {
|
|
38
|
+
/// @solidity memory-safe-assembly
|
|
39
|
+
assembly { // solhint-disable-line no-inline-assembly
|
|
37
40
|
// 68 = 32 bytes data length + 4-byte selector + 32 bytes offset
|
|
38
41
|
reason := add(data, 68)
|
|
39
42
|
}
|
|
@@ -42,16 +45,17 @@ library RevertReasonParser {
|
|
|
42
45
|
also sometimes there is extra 32 bytes of zeros padded in the end:
|
|
43
46
|
https://github.com/ethereum/solidity/issues/10170
|
|
44
47
|
because of that we can't check for equality and instead check
|
|
45
|
-
that string length + extra 68 bytes is
|
|
48
|
+
that string length + extra 68 bytes is equal or greater than overall data length
|
|
46
49
|
*/
|
|
47
|
-
if (data.length
|
|
48
|
-
|
|
50
|
+
if (data.length >= 68 + bytes(reason).length) {
|
|
51
|
+
return string.concat(prefix, "Error(", reason, ")");
|
|
52
|
+
}
|
|
49
53
|
}
|
|
50
54
|
// 36 = 4-byte selector + 32 bytes integer
|
|
51
55
|
else if (selector == _PANIC_SELECTOR && data.length == 36) {
|
|
52
56
|
uint256 code;
|
|
53
|
-
|
|
54
|
-
assembly {
|
|
57
|
+
/// @solidity memory-safe-assembly
|
|
58
|
+
assembly { // solhint-disable-line no-inline-assembly
|
|
55
59
|
// 36 = 32 bytes data length + 4-byte selector
|
|
56
60
|
code := mload(add(data, 36))
|
|
57
61
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
|
|
3
3
|
pragma solidity ^0.8.0;
|
|
4
|
+
pragma abicoder v1;
|
|
4
5
|
|
|
5
6
|
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
6
7
|
import "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol";
|
|
@@ -19,9 +20,9 @@ library SafeERC20 {
|
|
|
19
20
|
function safeTransferFrom(IERC20 token, address from, address to, uint256 amount) internal {
|
|
20
21
|
bytes4 selector = token.transferFrom.selector;
|
|
21
22
|
bool success;
|
|
23
|
+
/// @solidity memory-safe-assembly
|
|
22
24
|
assembly { // solhint-disable-line no-inline-assembly
|
|
23
25
|
let data := mload(0x40)
|
|
24
|
-
mstore(0x40, add(data, 100))
|
|
25
26
|
|
|
26
27
|
mstore(data, selector)
|
|
27
28
|
mstore(add(data, 0x04), from)
|
|
@@ -83,9 +84,9 @@ library SafeERC20 {
|
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
function _makeCall(IERC20 token, bytes4 selector, address to, uint256 amount) private returns(bool done) {
|
|
87
|
+
/// @solidity memory-safe-assembly
|
|
86
88
|
assembly { // solhint-disable-line no-inline-assembly
|
|
87
89
|
let data := mload(0x40)
|
|
88
|
-
mstore(0x40, add(data, 68))
|
|
89
90
|
|
|
90
91
|
mstore(data, selector)
|
|
91
92
|
mstore(add(data, 0x04), to)
|
|
@@ -102,10 +103,10 @@ library SafeERC20 {
|
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
function _makeCalldataCall(IERC20 token, bytes4 selector, bytes calldata args) private returns(bool done) {
|
|
106
|
+
/// @solidity memory-safe-assembly
|
|
105
107
|
assembly { // solhint-disable-line no-inline-assembly
|
|
106
108
|
let len := add(4, args.length)
|
|
107
109
|
let data := mload(0x40)
|
|
108
|
-
mstore(0x40, add(data, len))
|
|
109
110
|
|
|
110
111
|
mstore(data, selector)
|
|
111
112
|
calldatacopy(add(data, 0x04), args.offset, args.length)
|
|
@@ -14,8 +14,8 @@ library StringUtil {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
function toHex(bytes memory data) internal pure returns (string memory result) {
|
|
17
|
-
|
|
18
|
-
assembly {
|
|
17
|
+
/// @solidity memory-safe-assembly
|
|
18
|
+
assembly { // solhint-disable-line no-inline-assembly
|
|
19
19
|
function _toHex16(input) -> output {
|
|
20
20
|
output := or(
|
|
21
21
|
and(input, 0xFFFFFFFFFFFFFFFF000000000000000000000000000000000000000000000000),
|
|
@@ -4,8 +4,8 @@ pragma solidity ^0.8.0;
|
|
|
4
4
|
pragma abicoder v1;
|
|
5
5
|
|
|
6
6
|
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
7
|
-
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
|
8
7
|
import "./RevertReasonForwarder.sol";
|
|
8
|
+
import "./SafeERC20.sol";
|
|
9
9
|
import "./StringUtil.sol";
|
|
10
10
|
|
|
11
11
|
library UniERC20 {
|
package/dist/src/prelude.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare const constants: {
|
|
|
10
10
|
readonly MAX_INT256: string;
|
|
11
11
|
readonly MIN_INT256: string;
|
|
12
12
|
};
|
|
13
|
-
export { BN };
|
|
13
|
+
export { BN, };
|
|
14
14
|
export declare type Time = {
|
|
15
15
|
increaseTo: (target: string | number | BN) => Promise<BN>;
|
|
16
16
|
latest: () => Promise<BN>;
|
package/dist/src/prelude.js
CHANGED
|
@@ -18,6 +18,9 @@ chai_1.default.use(chai_as_promised_1.default);
|
|
|
18
18
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
19
19
|
const { time: timeImpl } = require('@openzeppelin/test-helpers');
|
|
20
20
|
function toBN(num, base) {
|
|
21
|
+
if (typeof (num) === 'string' && num.startsWith('0x')) {
|
|
22
|
+
return new bn_js_1.default(num.substring(2), 16);
|
|
23
|
+
}
|
|
21
24
|
return new bn_js_1.default(num, base);
|
|
22
25
|
}
|
|
23
26
|
exports.toBN = toBN;
|
package/dist/src/prelude.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prelude.js","sourceRoot":"","sources":["../../src/prelude.ts"],"names":[],"mappings":";;;;AAAA,qDAAuF;
|
|
1
|
+
{"version":3,"file":"prelude.js","sourceRoot":"","sources":["../../src/prelude.ts"],"names":[],"mappings":";;;;AAAA,qDAAuF;AA4CnF,0FA5CW,gBAAS,OA4CX;AACT,+FA7CsB,qBA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AAI,CAAC,CAAC,CAAC,QAAQ,EAAE;CAC3D,CAAC;AAaE,QAAA,IAAI,GAAS,QAAQ,CAAC;AAEnC,SAAgB,KAAK,CAAE,CAAS;IAC5B,OAAO,IAAI,CAAC,IAAA,kBAAK,EAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;AACnC,CAAC;AAFD,sBAEC"}
|
package/dist/src/profileEVM.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1inch/solidity-utils",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.19",
|
|
4
4
|
"main": "dist/src/index.js",
|
|
5
5
|
"types": "dist/src/index.d.ts",
|
|
6
6
|
"repository": {
|
|
@@ -26,50 +26,50 @@
|
|
|
26
26
|
"typechain": "hardhat typechain"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@metamask/eth-sig-util": "4.0.
|
|
30
|
-
"@openzeppelin/contracts": "4.
|
|
29
|
+
"@metamask/eth-sig-util": "4.0.1",
|
|
30
|
+
"@openzeppelin/contracts": "4.6.0",
|
|
31
31
|
"@openzeppelin/test-helpers": "0.5.15",
|
|
32
|
-
"bn.js": "5.2.
|
|
32
|
+
"bn.js": "5.2.1",
|
|
33
33
|
"chai": "4.3.6",
|
|
34
34
|
"chai-as-promised": "7.1.1",
|
|
35
35
|
"chai-bn": "0.3.1",
|
|
36
|
-
"ethereumjs-util": "7.1.
|
|
37
|
-
"web3-utils": "1.7.
|
|
36
|
+
"ethereumjs-util": "7.1.5",
|
|
37
|
+
"web3-utils": "1.7.4"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@nomiclabs/hardhat-truffle5": "2.0.
|
|
40
|
+
"@nomiclabs/hardhat-truffle5": "2.0.6",
|
|
41
41
|
"@nomiclabs/hardhat-web3": "2.0.0",
|
|
42
|
-
"@typechain/hardhat": "
|
|
42
|
+
"@typechain/hardhat": "4.0.0",
|
|
43
43
|
"@typechain/truffle-v5": "7.0.0",
|
|
44
|
-
"@types/chai": "4.3.
|
|
44
|
+
"@types/chai": "4.3.1",
|
|
45
45
|
"@types/chai-as-promised": "7.1.5",
|
|
46
46
|
"@types/eth-sig-util": "2.1.1",
|
|
47
47
|
"@types/ethereumjs-util": "6.1.0",
|
|
48
|
-
"@types/mocha": "9.1.
|
|
49
|
-
"@types/node": "
|
|
50
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
51
|
-
"@typescript-eslint/parser": "5.
|
|
48
|
+
"@types/mocha": "9.1.1",
|
|
49
|
+
"@types/node": "18.0.0",
|
|
50
|
+
"@typescript-eslint/eslint-plugin": "5.30.0",
|
|
51
|
+
"@typescript-eslint/parser": "5.30.0",
|
|
52
52
|
"acquit": "1.2.1",
|
|
53
53
|
"commander": "9.3.0",
|
|
54
54
|
"create-ts-index": "1.14.0",
|
|
55
55
|
"cross-spawn": "7.0.3",
|
|
56
|
-
"dotenv": "16.0.
|
|
57
|
-
"eslint": "8.
|
|
58
|
-
"eslint-config-standard": "
|
|
56
|
+
"dotenv": "16.0.1",
|
|
57
|
+
"eslint": "8.18.0",
|
|
58
|
+
"eslint-config-standard": "17.0.0",
|
|
59
59
|
"eslint-plugin-import": "2.26.0",
|
|
60
|
-
"eslint-plugin-
|
|
60
|
+
"eslint-plugin-n": "15.2.3",
|
|
61
61
|
"eslint-plugin-promise": "6.0.0",
|
|
62
62
|
"eslint-plugin-standard": "5.0.0",
|
|
63
63
|
"ethereumjs-wallet": "1.0.2",
|
|
64
|
-
"hardhat": "2.9.
|
|
64
|
+
"hardhat": "2.9.9",
|
|
65
65
|
"hardhat-gas-reporter": "1.0.8",
|
|
66
66
|
"rimraf": "3.0.2",
|
|
67
67
|
"shx": "0.3.4",
|
|
68
68
|
"solhint": "3.3.7",
|
|
69
|
-
"solidity-coverage": "0.7.
|
|
70
|
-
"ts-node": "10.
|
|
69
|
+
"solidity-coverage": "0.7.21",
|
|
70
|
+
"ts-node": "10.8.1",
|
|
71
71
|
"typechain": "7.0.0",
|
|
72
|
-
"typescript": "4.
|
|
72
|
+
"typescript": "4.7.4"
|
|
73
73
|
},
|
|
74
74
|
"bin": {
|
|
75
75
|
"solidity-utils-docify": "utils/docify.utils.js",
|