@ocap/merkle-tree 1.28.6 → 1.28.8
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/README.md +1 -1
- package/lib/abi.js +12 -18
- package/package.json +10 -11
- package/LICENSE +0 -13
package/README.md
CHANGED
package/lib/abi.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/* eslint-disable no-param-reassign */
|
|
2
|
-
/* eslint-disable func-names */
|
|
3
|
-
/* eslint-disable no-prototype-builtins */
|
|
4
|
-
/* eslint-disable prefer-rest-params */
|
|
5
1
|
// Ported from: https://github.com/ChainSafe/web3.js/blob/1.x/packages/web3-utils/src/soliditySha3.js
|
|
6
2
|
|
|
7
3
|
const Mcrypto = require('@ocap/mcrypto');
|
|
@@ -24,8 +20,8 @@ const checkAddressChecksum = (address) => {
|
|
|
24
20
|
const addressHash = keccak256(origin.toLowerCase()).replace(/^0x/i, '');
|
|
25
21
|
for (let i = 0; i < 40; i++) {
|
|
26
22
|
if (
|
|
27
|
-
(parseInt(addressHash[i], 16) > 7 && origin[i].toUpperCase() !== origin[i]) ||
|
|
28
|
-
(parseInt(addressHash[i], 16) <= 7 && origin[i].toLowerCase() !== origin[i])
|
|
23
|
+
(Number.parseInt(addressHash[i], 16) > 7 && origin[i].toUpperCase() !== origin[i]) ||
|
|
24
|
+
(Number.parseInt(addressHash[i], 16) <= 7 && origin[i].toLowerCase() !== origin[i])
|
|
29
25
|
) {
|
|
30
26
|
return false;
|
|
31
27
|
}
|
|
@@ -33,7 +29,7 @@ const checkAddressChecksum = (address) => {
|
|
|
33
29
|
return true;
|
|
34
30
|
};
|
|
35
31
|
|
|
36
|
-
const _elementaryName =
|
|
32
|
+
const _elementaryName = (name) => {
|
|
37
33
|
if (name.startsWith('int[')) {
|
|
38
34
|
return `int256${name.slice(3)}`;
|
|
39
35
|
}
|
|
@@ -62,18 +58,18 @@ const _elementaryName = function (name) {
|
|
|
62
58
|
};
|
|
63
59
|
|
|
64
60
|
// Parse N from type<N>
|
|
65
|
-
const _parseTypeN =
|
|
61
|
+
const _parseTypeN = (type) => {
|
|
66
62
|
const size = /^\D+(\d+).*$/.exec(type);
|
|
67
|
-
return size ? parseInt(size[1], 10) : null;
|
|
63
|
+
return size ? Number.parseInt(size[1], 10) : null;
|
|
68
64
|
};
|
|
69
65
|
|
|
70
66
|
// Parse N from type[<N>]
|
|
71
|
-
const _parseTypeNArray =
|
|
67
|
+
const _parseTypeNArray = (type) => {
|
|
72
68
|
const arraySize = /^\D+\d*\[(\d+)\]$/.exec(type);
|
|
73
|
-
return arraySize ? parseInt(arraySize[1], 10) : null;
|
|
69
|
+
return arraySize ? Number.parseInt(arraySize[1], 10) : null;
|
|
74
70
|
};
|
|
75
71
|
|
|
76
|
-
const _parseNumber =
|
|
72
|
+
const _parseNumber = (arg) => {
|
|
77
73
|
const type = typeof arg;
|
|
78
74
|
if (type === 'string') {
|
|
79
75
|
if (isHexStrict(arg)) {
|
|
@@ -93,7 +89,7 @@ const _parseNumber = function (arg) {
|
|
|
93
89
|
throw new Error(`${arg} is not a number`);
|
|
94
90
|
};
|
|
95
91
|
|
|
96
|
-
const _solidityPack =
|
|
92
|
+
const _solidityPack = (type, value, arraySize) => {
|
|
97
93
|
let size;
|
|
98
94
|
let num;
|
|
99
95
|
type = _elementaryName(type);
|
|
@@ -179,7 +175,7 @@ const _solidityPack = function (type, value, arraySize) {
|
|
|
179
175
|
throw new Error(`Unsupported or invalid type: ${type}`);
|
|
180
176
|
};
|
|
181
177
|
|
|
182
|
-
const _processSolidityEncodePackedArgs =
|
|
178
|
+
const _processSolidityEncodePackedArgs = (arg) => {
|
|
183
179
|
if (!arg || typeof arg !== 'object') {
|
|
184
180
|
throw new Error('arg must be an object');
|
|
185
181
|
}
|
|
@@ -198,9 +194,8 @@ const _processSolidityEncodePackedArgs = function (arg) {
|
|
|
198
194
|
arraySize = _parseTypeNArray(type);
|
|
199
195
|
if (arraySize && value.length !== arraySize) {
|
|
200
196
|
throw new Error(`${type} is not matching the given array ${JSON.stringify(value)}`);
|
|
201
|
-
} else {
|
|
202
|
-
arraySize = value.length;
|
|
203
197
|
}
|
|
198
|
+
arraySize = value.length;
|
|
204
199
|
}
|
|
205
200
|
|
|
206
201
|
if (Array.isArray(value)) {
|
|
@@ -216,8 +211,7 @@ const _processSolidityEncodePackedArgs = function (arg) {
|
|
|
216
211
|
* @method encodePacked
|
|
217
212
|
* @return {String} the hex encoded arguments
|
|
218
213
|
*/
|
|
219
|
-
const encodePacked =
|
|
220
|
-
const args = Array.prototype.slice.call(arguments);
|
|
214
|
+
const encodePacked = (...args) => {
|
|
221
215
|
const hexArgs = args.map(_processSolidityEncodePackedArgs);
|
|
222
216
|
return `0x${hexArgs.join('').toLowerCase()}`;
|
|
223
217
|
};
|
package/package.json
CHANGED
|
@@ -3,27 +3,26 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.28.
|
|
6
|
+
"version": "1.28.8",
|
|
7
7
|
"description": "Merkle tree implementation that powers DID Rollup",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
10
10
|
"lib"
|
|
11
11
|
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"lint": "biome check",
|
|
14
|
+
"lint:fix": "biome check --write",
|
|
15
|
+
"test": "bun test",
|
|
16
|
+
"coverage": "npm run test -- --coverage"
|
|
17
|
+
},
|
|
12
18
|
"keywords": [],
|
|
13
19
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
14
20
|
"license": "MIT",
|
|
15
21
|
"devDependencies": {
|
|
16
|
-
"jest": "^29.7.0",
|
|
17
22
|
"web3-utils": "^1.8.0"
|
|
18
23
|
},
|
|
19
24
|
"dependencies": {
|
|
20
|
-
"@ocap/mcrypto": "1.28.
|
|
21
|
-
"@ocap/util": "1.28.
|
|
22
|
-
},
|
|
23
|
-
"scripts": {
|
|
24
|
-
"lint": "eslint tests lib",
|
|
25
|
-
"lint:fix": "eslint --fix tests lib",
|
|
26
|
-
"test": "jest --forceExit --detectOpenHandles",
|
|
27
|
-
"coverage": "npm run test -- --coverage"
|
|
25
|
+
"@ocap/mcrypto": "1.28.8",
|
|
26
|
+
"@ocap/util": "1.28.8"
|
|
28
27
|
}
|
|
29
|
-
}
|
|
28
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
Copyright 2018-2025 ArcBlock
|
|
2
|
-
|
|
3
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
you may not use this file except in compliance with the License.
|
|
5
|
-
You may obtain a copy of the License at
|
|
6
|
-
|
|
7
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
|
|
9
|
-
Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
See the License for the specific language governing permissions and
|
|
13
|
-
limitations under the License.
|