@hashgraphonline/standards-sdk 0.0.93 → 0.0.95
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/dist/es/hcs-10/base-client.d.ts +14 -2
- package/dist/es/hcs-10/base-client.d.ts.map +1 -1
- package/dist/es/inscribe/inscriber.d.ts +2 -0
- package/dist/es/inscribe/inscriber.d.ts.map +1 -1
- package/dist/es/standards-sdk.es.js +8 -5
- package/dist/es/standards-sdk.es.js.map +1 -1
- package/dist/es/standards-sdk.es100.js +13 -16
- package/dist/es/standards-sdk.es100.js.map +1 -1
- package/dist/es/standards-sdk.es101.js +13 -5
- package/dist/es/standards-sdk.es101.js.map +1 -1
- package/dist/es/standards-sdk.es102.js +30 -37
- package/dist/es/standards-sdk.es102.js.map +1 -1
- package/dist/es/standards-sdk.es103.js +15 -40
- package/dist/es/standards-sdk.es103.js.map +1 -1
- package/dist/es/standards-sdk.es104.js +4 -37
- package/dist/es/standards-sdk.es104.js.map +1 -1
- package/dist/es/standards-sdk.es105.js +4 -78
- package/dist/es/standards-sdk.es105.js.map +1 -1
- package/dist/es/standards-sdk.es106.js +13 -7133
- package/dist/es/standards-sdk.es106.js.map +1 -1
- package/dist/es/standards-sdk.es107.js +5 -3
- package/dist/es/standards-sdk.es107.js.map +1 -1
- package/dist/es/standards-sdk.es108.js +39 -2
- package/dist/es/standards-sdk.es108.js.map +1 -1
- package/dist/es/standards-sdk.es109.js +40 -2
- package/dist/es/standards-sdk.es109.js.map +1 -1
- package/dist/es/standards-sdk.es110.js +37 -34
- package/dist/es/standards-sdk.es110.js.map +1 -1
- package/dist/es/standards-sdk.es111.js +74 -29
- package/dist/es/standards-sdk.es111.js.map +1 -1
- package/dist/es/standards-sdk.es112.js +3 -9
- package/dist/es/standards-sdk.es112.js.map +1 -1
- package/dist/es/standards-sdk.es113.js +2 -34
- package/dist/es/standards-sdk.es113.js.map +1 -1
- package/dist/es/standards-sdk.es114.js +2 -419
- package/dist/es/standards-sdk.es114.js.map +1 -1
- package/dist/es/standards-sdk.es115.js +34 -2
- package/dist/es/standards-sdk.es115.js.map +1 -1
- package/dist/es/standards-sdk.es116.js +29 -116
- package/dist/es/standards-sdk.es116.js.map +1 -1
- package/dist/es/standards-sdk.es117.js +9 -4
- package/dist/es/standards-sdk.es117.js.map +1 -1
- package/dist/es/standards-sdk.es118.js +37 -0
- package/dist/es/standards-sdk.es118.js.map +1 -0
- package/dist/es/standards-sdk.es13.js +5 -5
- package/dist/es/standards-sdk.es15.js +1 -1
- package/dist/es/standards-sdk.es16.js +1 -1
- package/dist/es/standards-sdk.es18.js +134 -384
- package/dist/es/standards-sdk.es18.js.map +1 -1
- package/dist/es/standards-sdk.es19.js +386 -315
- package/dist/es/standards-sdk.es19.js.map +1 -1
- package/dist/es/standards-sdk.es20.js +310 -128
- package/dist/es/standards-sdk.es20.js.map +1 -1
- package/dist/es/standards-sdk.es21.js +155 -7
- package/dist/es/standards-sdk.es21.js.map +1 -1
- package/dist/es/standards-sdk.es22.js +7 -1041
- package/dist/es/standards-sdk.es22.js.map +1 -1
- package/dist/es/standards-sdk.es23.js +966 -1692
- package/dist/es/standards-sdk.es23.js.map +1 -1
- package/dist/es/standards-sdk.es24.js +1767 -36
- package/dist/es/standards-sdk.es24.js.map +1 -1
- package/dist/es/standards-sdk.es25.js +7163 -21
- package/dist/es/standards-sdk.es25.js.map +1 -1
- package/dist/es/standards-sdk.es26.js +3 -7190
- package/dist/es/standards-sdk.es26.js.map +1 -1
- package/dist/es/standards-sdk.es27.js +2 -3
- package/dist/es/standards-sdk.es27.js.map +1 -1
- package/dist/es/standards-sdk.es28.js +4167 -2
- package/dist/es/standards-sdk.es28.js.map +1 -1
- package/dist/es/standards-sdk.es29.js +36 -4167
- package/dist/es/standards-sdk.es29.js.map +1 -1
- package/dist/es/standards-sdk.es30.js +48 -5
- package/dist/es/standards-sdk.es30.js.map +1 -1
- package/dist/es/standards-sdk.es31.js +5 -2
- package/dist/es/standards-sdk.es31.js.map +1 -1
- package/dist/es/standards-sdk.es32.js +2 -364
- package/dist/es/standards-sdk.es32.js.map +1 -1
- package/dist/es/standards-sdk.es33.js +100 -5
- package/dist/es/standards-sdk.es33.js.map +1 -1
- package/dist/es/standards-sdk.es34.js +2 -179
- package/dist/es/standards-sdk.es34.js.map +1 -1
- package/dist/es/standards-sdk.es35.js +15 -80
- package/dist/es/standards-sdk.es35.js.map +1 -1
- package/dist/es/standards-sdk.es36.js +400 -105
- package/dist/es/standards-sdk.es36.js.map +1 -1
- package/dist/es/standards-sdk.es37.js +190 -47
- package/dist/es/standards-sdk.es37.js.map +1 -1
- package/dist/es/standards-sdk.es38.js +438 -10
- package/dist/es/standards-sdk.es38.js.map +1 -1
- package/dist/es/standards-sdk.es39.js +19 -91
- package/dist/es/standards-sdk.es39.js.map +1 -1
- package/dist/es/standards-sdk.es4.js +1 -1
- package/dist/es/standards-sdk.es40.js +138 -3
- package/dist/es/standards-sdk.es40.js.map +1 -1
- package/dist/es/standards-sdk.es41.js +18 -2
- package/dist/es/standards-sdk.es41.js.map +1 -1
- package/dist/es/standards-sdk.es42.js +22 -106
- package/dist/es/standards-sdk.es42.js.map +1 -1
- package/dist/es/standards-sdk.es43.js +26 -71
- package/dist/es/standards-sdk.es43.js.map +1 -1
- package/dist/es/standards-sdk.es44.js +20 -5
- package/dist/es/standards-sdk.es44.js.map +1 -1
- package/dist/es/standards-sdk.es45.js +43 -4
- package/dist/es/standards-sdk.es45.js.map +1 -1
- package/dist/es/standards-sdk.es46.js +13 -216
- package/dist/es/standards-sdk.es46.js.map +1 -1
- package/dist/es/standards-sdk.es47.js +57 -54
- package/dist/es/standards-sdk.es47.js.map +1 -1
- package/dist/es/standards-sdk.es48.js +1287 -67
- package/dist/es/standards-sdk.es48.js.map +1 -1
- package/dist/es/standards-sdk.es49.js +131 -67
- package/dist/es/standards-sdk.es49.js.map +1 -1
- package/dist/es/standards-sdk.es5.js +42 -18
- package/dist/es/standards-sdk.es5.js.map +1 -1
- package/dist/es/standards-sdk.es50.js +90 -22
- package/dist/es/standards-sdk.es50.js.map +1 -1
- package/dist/es/standards-sdk.es51.js +67 -131
- package/dist/es/standards-sdk.es51.js.map +1 -1
- package/dist/es/standards-sdk.es52.js +27 -86
- package/dist/es/standards-sdk.es52.js.map +1 -1
- package/dist/es/standards-sdk.es53.js +5 -194
- package/dist/es/standards-sdk.es53.js.map +1 -1
- package/dist/es/standards-sdk.es54.js +140 -419
- package/dist/es/standards-sdk.es54.js.map +1 -1
- package/dist/es/standards-sdk.es55.js +22 -24
- package/dist/es/standards-sdk.es55.js.map +1 -1
- package/dist/es/standards-sdk.es56.js +777 -123
- package/dist/es/standards-sdk.es56.js.map +1 -1
- package/dist/es/standards-sdk.es57.js +169 -13
- package/dist/es/standards-sdk.es57.js.map +1 -1
- package/dist/es/standards-sdk.es58.js +2282 -29
- package/dist/es/standards-sdk.es58.js.map +1 -1
- package/dist/es/standards-sdk.es59.js +160 -25
- package/dist/es/standards-sdk.es59.js.map +1 -1
- package/dist/es/standards-sdk.es60.js +137 -15
- package/dist/es/standards-sdk.es60.js.map +1 -1
- package/dist/es/standards-sdk.es61.js +7128 -36
- package/dist/es/standards-sdk.es61.js.map +1 -1
- package/dist/es/standards-sdk.es62.js +14 -11
- package/dist/es/standards-sdk.es62.js.map +1 -1
- package/dist/es/standards-sdk.es63.js +25 -59
- package/dist/es/standards-sdk.es63.js.map +1 -1
- package/dist/es/standards-sdk.es64.js +26 -1289
- package/dist/es/standards-sdk.es64.js.map +1 -1
- package/dist/es/standards-sdk.es65.js +35 -29
- package/dist/es/standards-sdk.es65.js.map +1 -1
- package/dist/es/standards-sdk.es66.js +418 -5
- package/dist/es/standards-sdk.es66.js.map +1 -1
- package/dist/es/standards-sdk.es67.js +2 -159
- package/dist/es/standards-sdk.es67.js.map +1 -1
- package/dist/es/standards-sdk.es68.js +113 -786
- package/dist/es/standards-sdk.es68.js.map +1 -1
- package/dist/es/standards-sdk.es69.js +3 -143
- package/dist/es/standards-sdk.es69.js.map +1 -1
- package/dist/es/standards-sdk.es7.js +4 -4
- package/dist/es/standards-sdk.es70.js +3 -173
- package/dist/es/standards-sdk.es70.js.map +1 -1
- package/dist/es/standards-sdk.es71.js +364 -3
- package/dist/es/standards-sdk.es71.js.map +1 -1
- package/dist/es/standards-sdk.es72.js +5 -163
- package/dist/es/standards-sdk.es72.js.map +1 -1
- package/dist/es/standards-sdk.es73.js +173 -26
- package/dist/es/standards-sdk.es73.js.map +1 -1
- package/dist/es/standards-sdk.es74.js +73 -55
- package/dist/es/standards-sdk.es74.js.map +1 -1
- package/dist/es/standards-sdk.es75.js +109 -45
- package/dist/es/standards-sdk.es75.js.map +1 -1
- package/dist/es/standards-sdk.es76.js +50 -8
- package/dist/es/standards-sdk.es76.js.map +1 -1
- package/dist/es/standards-sdk.es77.js +9 -64
- package/dist/es/standards-sdk.es77.js.map +1 -1
- package/dist/es/standards-sdk.es78.js +97 -6
- package/dist/es/standards-sdk.es78.js.map +1 -1
- package/dist/es/standards-sdk.es79.js +3 -14
- package/dist/es/standards-sdk.es79.js.map +1 -1
- package/dist/es/standards-sdk.es8.js +4 -4
- package/dist/es/standards-sdk.es80.js +2 -7
- package/dist/es/standards-sdk.es80.js.map +1 -1
- package/dist/es/standards-sdk.es81.js +109 -41
- package/dist/es/standards-sdk.es81.js.map +1 -1
- package/dist/es/standards-sdk.es82.js +74 -2
- package/dist/es/standards-sdk.es82.js.map +1 -1
- package/dist/es/standards-sdk.es83.js +6 -136
- package/dist/es/standards-sdk.es83.js.map +1 -1
- package/dist/es/standards-sdk.es84.js +5 -172
- package/dist/es/standards-sdk.es84.js.map +1 -1
- package/dist/es/standards-sdk.es85.js +208 -88
- package/dist/es/standards-sdk.es85.js.map +1 -1
- package/dist/es/standards-sdk.es86.js +58 -2
- package/dist/es/standards-sdk.es86.js.map +1 -1
- package/dist/es/standards-sdk.es87.js +69 -16
- package/dist/es/standards-sdk.es87.js.map +1 -1
- package/dist/es/standards-sdk.es88.js +27 -404
- package/dist/es/standards-sdk.es88.js.map +1 -1
- package/dist/es/standards-sdk.es89.js +58 -16
- package/dist/es/standards-sdk.es89.js.map +1 -1
- package/dist/es/standards-sdk.es9.js +1 -1
- package/dist/es/standards-sdk.es90.js +47 -24
- package/dist/es/standards-sdk.es90.js.map +1 -1
- package/dist/es/standards-sdk.es91.js +8 -24
- package/dist/es/standards-sdk.es91.js.map +1 -1
- package/dist/es/standards-sdk.es92.js +63 -36
- package/dist/es/standards-sdk.es92.js.map +1 -1
- package/dist/es/standards-sdk.es93.js +5 -12
- package/dist/es/standards-sdk.es93.js.map +1 -1
- package/dist/es/standards-sdk.es94.js +15 -13
- package/dist/es/standards-sdk.es94.js.map +1 -1
- package/dist/es/standards-sdk.es95.js +6 -31
- package/dist/es/standards-sdk.es95.js.map +1 -1
- package/dist/es/standards-sdk.es96.js +44 -14
- package/dist/es/standards-sdk.es96.js.map +1 -1
- package/dist/es/standards-sdk.es97.js +2 -4
- package/dist/es/standards-sdk.es97.js.map +1 -1
- package/dist/es/standards-sdk.es98.js +136 -4
- package/dist/es/standards-sdk.es98.js.map +1 -1
- package/dist/es/standards-sdk.es99.js +171 -2281
- package/dist/es/standards-sdk.es99.js.map +1 -1
- package/dist/es/utils/hrl-resolver.d.ts +53 -0
- package/dist/es/utils/hrl-resolver.d.ts.map +1 -0
- package/dist/es/utils/index.d.ts +1 -0
- package/dist/es/utils/index.d.ts.map +1 -1
- package/dist/umd/hcs-10/base-client.d.ts +14 -2
- package/dist/umd/hcs-10/base-client.d.ts.map +1 -1
- package/dist/umd/inscribe/inscriber.d.ts +2 -0
- package/dist/umd/inscribe/inscriber.d.ts.map +1 -1
- package/dist/umd/standards-sdk.umd.js +2 -2
- package/dist/umd/standards-sdk.umd.js.map +1 -1
- package/dist/umd/utils/hrl-resolver.d.ts +53 -0
- package/dist/umd/utils/hrl-resolver.d.ts.map +1 -0
- package/dist/umd/utils/index.d.ts +1 -0
- package/dist/umd/utils/index.d.ts.map +1 -1
- package/package.json +2 -1
|
@@ -1,1770 +1,1044 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __typeError = (msg) => {
|
|
3
|
+
throw TypeError(msg);
|
|
4
|
+
};
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
8
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
9
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
10
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
11
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
12
|
+
var _errors, _events, _functions, _abiCoder, _Interface_instances, getFunction_fn, getEvent_fn;
|
|
13
|
+
import { keccak256 } from "./standards-sdk.es55.js";
|
|
14
|
+
import { AbiCoder } from "./standards-sdk.es37.js";
|
|
15
|
+
import { Result } from "./standards-sdk.es38.js";
|
|
16
|
+
import { Fragment, ConstructorFragment, FunctionFragment, EventFragment, ErrorFragment, ParamType } from "./standards-sdk.es48.js";
|
|
17
|
+
import { Typed } from "./standards-sdk.es56.js";
|
|
18
|
+
import { defineProperties } from "./standards-sdk.es52.js";
|
|
19
|
+
import { assertArgument, assert } from "./standards-sdk.es49.js";
|
|
20
|
+
import { isHexString, dataSlice, concat, getBytesCopy, hexlify, getBytes, zeroPadBytes, zeroPadValue } from "./standards-sdk.es50.js";
|
|
21
|
+
import { id } from "./standards-sdk.es53.js";
|
|
22
|
+
import { getBigInt, toBeHex } from "./standards-sdk.es54.js";
|
|
23
|
+
class LogDescription {
|
|
24
|
+
/**
|
|
25
|
+
* @_ignore:
|
|
26
|
+
*/
|
|
27
|
+
constructor(fragment, topic, args) {
|
|
28
|
+
/**
|
|
29
|
+
* The matching fragment for the ``topic0``.
|
|
30
|
+
*/
|
|
31
|
+
__publicField(this, "fragment");
|
|
32
|
+
/**
|
|
33
|
+
* The name of the Event.
|
|
34
|
+
*/
|
|
35
|
+
__publicField(this, "name");
|
|
36
|
+
/**
|
|
37
|
+
* The full Event signature.
|
|
38
|
+
*/
|
|
39
|
+
__publicField(this, "signature");
|
|
40
|
+
/**
|
|
41
|
+
* The topic hash for the Event.
|
|
42
|
+
*/
|
|
43
|
+
__publicField(this, "topic");
|
|
44
|
+
/**
|
|
45
|
+
* The arguments passed into the Event with ``emit``.
|
|
46
|
+
*/
|
|
47
|
+
__publicField(this, "args");
|
|
48
|
+
const name = fragment.name, signature = fragment.format();
|
|
49
|
+
defineProperties(this, {
|
|
50
|
+
fragment,
|
|
51
|
+
name,
|
|
52
|
+
signature,
|
|
53
|
+
topic,
|
|
54
|
+
args
|
|
55
|
+
});
|
|
20
56
|
}
|
|
21
|
-
var validLen = b64.indexOf("=");
|
|
22
|
-
if (validLen === -1) validLen = len;
|
|
23
|
-
var placeHoldersLen = validLen === len ? 0 : 4 - validLen % 4;
|
|
24
|
-
return [validLen, placeHoldersLen];
|
|
25
|
-
}
|
|
26
|
-
function byteLength(b64) {
|
|
27
|
-
var lens = getLens(b64);
|
|
28
|
-
var validLen = lens[0];
|
|
29
|
-
var placeHoldersLen = lens[1];
|
|
30
|
-
return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
|
|
31
57
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
class TransactionDescription {
|
|
59
|
+
/**
|
|
60
|
+
* @_ignore:
|
|
61
|
+
*/
|
|
62
|
+
constructor(fragment, selector, args, value) {
|
|
63
|
+
/**
|
|
64
|
+
* The matching fragment from the transaction ``data``.
|
|
65
|
+
*/
|
|
66
|
+
__publicField(this, "fragment");
|
|
67
|
+
/**
|
|
68
|
+
* The name of the Function from the transaction ``data``.
|
|
69
|
+
*/
|
|
70
|
+
__publicField(this, "name");
|
|
71
|
+
/**
|
|
72
|
+
* The arguments passed to the Function from the transaction ``data``.
|
|
73
|
+
*/
|
|
74
|
+
__publicField(this, "args");
|
|
75
|
+
/**
|
|
76
|
+
* The full Function signature from the transaction ``data``.
|
|
77
|
+
*/
|
|
78
|
+
__publicField(this, "signature");
|
|
79
|
+
/**
|
|
80
|
+
* The selector for the Function from the transaction ``data``.
|
|
81
|
+
*/
|
|
82
|
+
__publicField(this, "selector");
|
|
83
|
+
/**
|
|
84
|
+
* The ``value`` (in wei) from the transaction.
|
|
85
|
+
*/
|
|
86
|
+
__publicField(this, "value");
|
|
87
|
+
const name = fragment.name, signature = fragment.format();
|
|
88
|
+
defineProperties(this, {
|
|
89
|
+
fragment,
|
|
90
|
+
name,
|
|
91
|
+
args,
|
|
92
|
+
signature,
|
|
93
|
+
selector,
|
|
94
|
+
value
|
|
95
|
+
});
|
|
58
96
|
}
|
|
59
|
-
return arr;
|
|
60
97
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
98
|
+
class ErrorDescription {
|
|
99
|
+
/**
|
|
100
|
+
* @_ignore:
|
|
101
|
+
*/
|
|
102
|
+
constructor(fragment, selector, args) {
|
|
103
|
+
/**
|
|
104
|
+
* The matching fragment.
|
|
105
|
+
*/
|
|
106
|
+
__publicField(this, "fragment");
|
|
107
|
+
/**
|
|
108
|
+
* The name of the Error.
|
|
109
|
+
*/
|
|
110
|
+
__publicField(this, "name");
|
|
111
|
+
/**
|
|
112
|
+
* The arguments passed to the Error with ``revert``.
|
|
113
|
+
*/
|
|
114
|
+
__publicField(this, "args");
|
|
115
|
+
/**
|
|
116
|
+
* The full Error signature.
|
|
117
|
+
*/
|
|
118
|
+
__publicField(this, "signature");
|
|
119
|
+
/**
|
|
120
|
+
* The selector for the Error.
|
|
121
|
+
*/
|
|
122
|
+
__publicField(this, "selector");
|
|
123
|
+
const name = fragment.name, signature = fragment.format();
|
|
124
|
+
defineProperties(this, {
|
|
125
|
+
fragment,
|
|
126
|
+
name,
|
|
127
|
+
args,
|
|
128
|
+
signature,
|
|
129
|
+
selector
|
|
130
|
+
});
|
|
70
131
|
}
|
|
71
|
-
return output.join("");
|
|
72
132
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
133
|
+
class Indexed {
|
|
134
|
+
/**
|
|
135
|
+
* @_ignore:
|
|
136
|
+
*/
|
|
137
|
+
constructor(hash) {
|
|
138
|
+
/**
|
|
139
|
+
* The ``keccak256`` of the value logged.
|
|
140
|
+
*/
|
|
141
|
+
__publicField(this, "hash");
|
|
142
|
+
/**
|
|
143
|
+
* @_ignore:
|
|
144
|
+
*/
|
|
145
|
+
__publicField(this, "_isIndexed");
|
|
146
|
+
defineProperties(this, { hash, _isIndexed: true });
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Returns ``true`` if %%value%% is an **Indexed**.
|
|
150
|
+
*
|
|
151
|
+
* This provides a Type Guard for property access.
|
|
152
|
+
*/
|
|
153
|
+
static isIndexed(value) {
|
|
154
|
+
return !!(value && value._isIndexed);
|
|
92
155
|
}
|
|
93
|
-
return parts.join("");
|
|
94
156
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
i += d;
|
|
107
|
-
e = s & (1 << -nBits) - 1;
|
|
108
|
-
s >>= -nBits;
|
|
109
|
-
nBits += eLen;
|
|
110
|
-
for (; nBits > 0; e = e * 256 + buffer2[offset + i], i += d, nBits -= 8) {
|
|
111
|
-
}
|
|
112
|
-
m = e & (1 << -nBits) - 1;
|
|
113
|
-
e >>= -nBits;
|
|
114
|
-
nBits += mLen;
|
|
115
|
-
for (; nBits > 0; m = m * 256 + buffer2[offset + i], i += d, nBits -= 8) {
|
|
116
|
-
}
|
|
117
|
-
if (e === 0) {
|
|
118
|
-
e = 1 - eBias;
|
|
119
|
-
} else if (e === eMax) {
|
|
120
|
-
return m ? NaN : (s ? -1 : 1) * Infinity;
|
|
121
|
-
} else {
|
|
122
|
-
m = m + Math.pow(2, mLen);
|
|
123
|
-
e = e - eBias;
|
|
124
|
-
}
|
|
125
|
-
return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
|
|
126
|
-
};
|
|
127
|
-
ieee754.write = function(buffer2, value, offset, isLE, mLen, nBytes) {
|
|
128
|
-
var e, m, c;
|
|
129
|
-
var eLen = nBytes * 8 - mLen - 1;
|
|
130
|
-
var eMax = (1 << eLen) - 1;
|
|
131
|
-
var eBias = eMax >> 1;
|
|
132
|
-
var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
|
|
133
|
-
var i = isLE ? 0 : nBytes - 1;
|
|
134
|
-
var d = isLE ? 1 : -1;
|
|
135
|
-
var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
|
|
136
|
-
value = Math.abs(value);
|
|
137
|
-
if (isNaN(value) || value === Infinity) {
|
|
138
|
-
m = isNaN(value) ? 1 : 0;
|
|
139
|
-
e = eMax;
|
|
140
|
-
} else {
|
|
141
|
-
e = Math.floor(Math.log(value) / Math.LN2);
|
|
142
|
-
if (value * (c = Math.pow(2, -e)) < 1) {
|
|
143
|
-
e--;
|
|
144
|
-
c *= 2;
|
|
145
|
-
}
|
|
146
|
-
if (e + eBias >= 1) {
|
|
147
|
-
value += rt / c;
|
|
148
|
-
} else {
|
|
149
|
-
value += rt * Math.pow(2, 1 - eBias);
|
|
150
|
-
}
|
|
151
|
-
if (value * c >= 2) {
|
|
152
|
-
e++;
|
|
153
|
-
c /= 2;
|
|
154
|
-
}
|
|
155
|
-
if (e + eBias >= eMax) {
|
|
156
|
-
m = 0;
|
|
157
|
-
e = eMax;
|
|
158
|
-
} else if (e + eBias >= 1) {
|
|
159
|
-
m = (value * c - 1) * Math.pow(2, mLen);
|
|
160
|
-
e = e + eBias;
|
|
161
|
-
} else {
|
|
162
|
-
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
|
|
163
|
-
e = 0;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
for (; mLen >= 8; buffer2[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
|
|
167
|
-
}
|
|
168
|
-
e = e << mLen | m;
|
|
169
|
-
eLen += mLen;
|
|
170
|
-
for (; eLen > 0; buffer2[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
|
|
171
|
-
}
|
|
172
|
-
buffer2[offset + i - d] |= s * 128;
|
|
157
|
+
const PanicReasons = {
|
|
158
|
+
"0": "generic panic",
|
|
159
|
+
"1": "assert(false)",
|
|
160
|
+
"17": "arithmetic overflow",
|
|
161
|
+
"18": "division or modulo by zero",
|
|
162
|
+
"33": "enum overflow",
|
|
163
|
+
"34": "invalid encoded storage byte array accessed",
|
|
164
|
+
"49": "out-of-bounds array access; popping on an empty array",
|
|
165
|
+
"50": "out-of-bounds access of an array or bytesN",
|
|
166
|
+
"65": "out of memory",
|
|
167
|
+
"81": "uninitialized function"
|
|
173
168
|
};
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
(
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
if (!Buffer2.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") {
|
|
192
|
-
console.error(
|
|
193
|
-
"This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
function typedArraySupport() {
|
|
197
|
-
try {
|
|
198
|
-
const arr = new GlobalUint8Array(1);
|
|
199
|
-
const proto = { foo: function() {
|
|
200
|
-
return 42;
|
|
201
|
-
} };
|
|
202
|
-
Object.setPrototypeOf(proto, GlobalUint8Array.prototype);
|
|
203
|
-
Object.setPrototypeOf(arr, proto);
|
|
204
|
-
return arr.foo() === 42;
|
|
205
|
-
} catch (e) {
|
|
206
|
-
return false;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
Object.defineProperty(Buffer2.prototype, "parent", {
|
|
210
|
-
enumerable: true,
|
|
211
|
-
get: function() {
|
|
212
|
-
if (!Buffer2.isBuffer(this)) return void 0;
|
|
213
|
-
return this.buffer;
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
Object.defineProperty(Buffer2.prototype, "offset", {
|
|
217
|
-
enumerable: true,
|
|
218
|
-
get: function() {
|
|
219
|
-
if (!Buffer2.isBuffer(this)) return void 0;
|
|
220
|
-
return this.byteOffset;
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
function createBuffer(length) {
|
|
224
|
-
if (length > K_MAX_LENGTH) {
|
|
225
|
-
throw new RangeError('The value "' + length + '" is invalid for option "size"');
|
|
226
|
-
}
|
|
227
|
-
const buf = new GlobalUint8Array(length);
|
|
228
|
-
Object.setPrototypeOf(buf, Buffer2.prototype);
|
|
229
|
-
return buf;
|
|
230
|
-
}
|
|
231
|
-
function Buffer2(arg, encodingOrOffset, length) {
|
|
232
|
-
if (typeof arg === "number") {
|
|
233
|
-
if (typeof encodingOrOffset === "string") {
|
|
234
|
-
throw new TypeError(
|
|
235
|
-
'The "string" argument must be of type string. Received type number'
|
|
236
|
-
);
|
|
169
|
+
const BuiltinErrors = {
|
|
170
|
+
"0x08c379a0": {
|
|
171
|
+
signature: "Error(string)",
|
|
172
|
+
name: "Error",
|
|
173
|
+
inputs: ["string"],
|
|
174
|
+
reason: (message) => {
|
|
175
|
+
return `reverted with reason string ${JSON.stringify(message)}`;
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
"0x4e487b71": {
|
|
179
|
+
signature: "Panic(uint256)",
|
|
180
|
+
name: "Panic",
|
|
181
|
+
inputs: ["uint256"],
|
|
182
|
+
reason: (code) => {
|
|
183
|
+
let reason = "unknown panic code";
|
|
184
|
+
if (code >= 0 && code <= 255 && PanicReasons[code.toString()]) {
|
|
185
|
+
reason = PanicReasons[code.toString()];
|
|
237
186
|
}
|
|
238
|
-
return
|
|
187
|
+
return `reverted with panic code 0x${code.toString(16)} (${reason})`;
|
|
239
188
|
}
|
|
240
|
-
return from(arg, encodingOrOffset, length);
|
|
241
189
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
if (
|
|
272
|
-
|
|
273
|
-
return Buffer2.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length);
|
|
274
|
-
}
|
|
275
|
-
throw new TypeError(
|
|
276
|
-
"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value
|
|
277
|
-
);
|
|
278
|
-
}
|
|
279
|
-
Buffer2.from = function(value, encodingOrOffset, length) {
|
|
280
|
-
return from(value, encodingOrOffset, length);
|
|
281
|
-
};
|
|
282
|
-
Object.setPrototypeOf(Buffer2.prototype, GlobalUint8Array.prototype);
|
|
283
|
-
Object.setPrototypeOf(Buffer2, GlobalUint8Array);
|
|
284
|
-
function assertSize(size) {
|
|
285
|
-
if (typeof size !== "number") {
|
|
286
|
-
throw new TypeError('"size" argument must be of type number');
|
|
287
|
-
} else if (size < 0) {
|
|
288
|
-
throw new RangeError('The value "' + size + '" is invalid for option "size"');
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
function alloc(size, fill, encoding) {
|
|
292
|
-
assertSize(size);
|
|
293
|
-
if (size <= 0) {
|
|
294
|
-
return createBuffer(size);
|
|
295
|
-
}
|
|
296
|
-
if (fill !== void 0) {
|
|
297
|
-
return typeof encoding === "string" ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill);
|
|
298
|
-
}
|
|
299
|
-
return createBuffer(size);
|
|
300
|
-
}
|
|
301
|
-
Buffer2.alloc = function(size, fill, encoding) {
|
|
302
|
-
return alloc(size, fill, encoding);
|
|
303
|
-
};
|
|
304
|
-
function allocUnsafe(size) {
|
|
305
|
-
assertSize(size);
|
|
306
|
-
return createBuffer(size < 0 ? 0 : checked(size) | 0);
|
|
307
|
-
}
|
|
308
|
-
Buffer2.allocUnsafe = function(size) {
|
|
309
|
-
return allocUnsafe(size);
|
|
310
|
-
};
|
|
311
|
-
Buffer2.allocUnsafeSlow = function(size) {
|
|
312
|
-
return allocUnsafe(size);
|
|
313
|
-
};
|
|
314
|
-
function fromString(string, encoding) {
|
|
315
|
-
if (typeof encoding !== "string" || encoding === "") {
|
|
316
|
-
encoding = "utf8";
|
|
317
|
-
}
|
|
318
|
-
if (!Buffer2.isEncoding(encoding)) {
|
|
319
|
-
throw new TypeError("Unknown encoding: " + encoding);
|
|
320
|
-
}
|
|
321
|
-
const length = byteLength2(string, encoding) | 0;
|
|
322
|
-
let buf = createBuffer(length);
|
|
323
|
-
const actual = buf.write(string, encoding);
|
|
324
|
-
if (actual !== length) {
|
|
325
|
-
buf = buf.slice(0, actual);
|
|
326
|
-
}
|
|
327
|
-
return buf;
|
|
328
|
-
}
|
|
329
|
-
function fromArrayLike(array) {
|
|
330
|
-
const length = array.length < 0 ? 0 : checked(array.length) | 0;
|
|
331
|
-
const buf = createBuffer(length);
|
|
332
|
-
for (let i = 0; i < length; i += 1) {
|
|
333
|
-
buf[i] = array[i] & 255;
|
|
334
|
-
}
|
|
335
|
-
return buf;
|
|
336
|
-
}
|
|
337
|
-
function fromArrayView(arrayView) {
|
|
338
|
-
if (isInstance(arrayView, GlobalUint8Array)) {
|
|
339
|
-
const copy = new GlobalUint8Array(arrayView);
|
|
340
|
-
return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength);
|
|
341
|
-
}
|
|
342
|
-
return fromArrayLike(arrayView);
|
|
343
|
-
}
|
|
344
|
-
function fromArrayBuffer(array, byteOffset, length) {
|
|
345
|
-
if (byteOffset < 0 || array.byteLength < byteOffset) {
|
|
346
|
-
throw new RangeError('"offset" is outside of buffer bounds');
|
|
347
|
-
}
|
|
348
|
-
if (array.byteLength < byteOffset + (length || 0)) {
|
|
349
|
-
throw new RangeError('"length" is outside of buffer bounds');
|
|
350
|
-
}
|
|
351
|
-
let buf;
|
|
352
|
-
if (byteOffset === void 0 && length === void 0) {
|
|
353
|
-
buf = new GlobalUint8Array(array);
|
|
354
|
-
} else if (length === void 0) {
|
|
355
|
-
buf = new GlobalUint8Array(array, byteOffset);
|
|
190
|
+
};
|
|
191
|
+
const _Interface = class _Interface {
|
|
192
|
+
/**
|
|
193
|
+
* Create a new Interface for the %%fragments%%.
|
|
194
|
+
*/
|
|
195
|
+
constructor(fragments) {
|
|
196
|
+
__privateAdd(this, _Interface_instances);
|
|
197
|
+
/**
|
|
198
|
+
* All the Contract ABI members (i.e. methods, events, errors, etc).
|
|
199
|
+
*/
|
|
200
|
+
__publicField(this, "fragments");
|
|
201
|
+
/**
|
|
202
|
+
* The Contract constructor.
|
|
203
|
+
*/
|
|
204
|
+
__publicField(this, "deploy");
|
|
205
|
+
/**
|
|
206
|
+
* The Fallback method, if any.
|
|
207
|
+
*/
|
|
208
|
+
__publicField(this, "fallback");
|
|
209
|
+
/**
|
|
210
|
+
* If receiving ether is supported.
|
|
211
|
+
*/
|
|
212
|
+
__publicField(this, "receive");
|
|
213
|
+
__privateAdd(this, _errors);
|
|
214
|
+
__privateAdd(this, _events);
|
|
215
|
+
__privateAdd(this, _functions);
|
|
216
|
+
// #structs: Map<string, StructFragment>;
|
|
217
|
+
__privateAdd(this, _abiCoder);
|
|
218
|
+
let abi = [];
|
|
219
|
+
if (typeof fragments === "string") {
|
|
220
|
+
abi = JSON.parse(fragments);
|
|
356
221
|
} else {
|
|
357
|
-
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
222
|
+
abi = fragments;
|
|
223
|
+
}
|
|
224
|
+
__privateSet(this, _functions, /* @__PURE__ */ new Map());
|
|
225
|
+
__privateSet(this, _errors, /* @__PURE__ */ new Map());
|
|
226
|
+
__privateSet(this, _events, /* @__PURE__ */ new Map());
|
|
227
|
+
const frags = [];
|
|
228
|
+
for (const a of abi) {
|
|
229
|
+
try {
|
|
230
|
+
frags.push(Fragment.from(a));
|
|
231
|
+
} catch (error) {
|
|
232
|
+
console.log(`[Warning] Invalid Fragment ${JSON.stringify(a)}:`, error.message);
|
|
368
233
|
}
|
|
369
|
-
obj.copy(buf, 0, 0, len);
|
|
370
|
-
return buf;
|
|
371
234
|
}
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
235
|
+
defineProperties(this, {
|
|
236
|
+
fragments: Object.freeze(frags)
|
|
237
|
+
});
|
|
238
|
+
let fallback = null;
|
|
239
|
+
let receive = false;
|
|
240
|
+
__privateSet(this, _abiCoder, this.getAbiCoder());
|
|
241
|
+
this.fragments.forEach((fragment, index) => {
|
|
242
|
+
let bucket;
|
|
243
|
+
switch (fragment.type) {
|
|
244
|
+
case "constructor":
|
|
245
|
+
if (this.deploy) {
|
|
246
|
+
console.log("duplicate definition - constructor");
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
defineProperties(this, { deploy: fragment });
|
|
250
|
+
return;
|
|
251
|
+
case "fallback":
|
|
252
|
+
if (fragment.inputs.length === 0) {
|
|
253
|
+
receive = true;
|
|
254
|
+
} else {
|
|
255
|
+
assertArgument(!fallback || fragment.payable !== fallback.payable, "conflicting fallback fragments", `fragments[${index}]`, fragment);
|
|
256
|
+
fallback = fragment;
|
|
257
|
+
receive = fallback.payable;
|
|
258
|
+
}
|
|
259
|
+
return;
|
|
260
|
+
case "function":
|
|
261
|
+
bucket = __privateGet(this, _functions);
|
|
262
|
+
break;
|
|
263
|
+
case "event":
|
|
264
|
+
bucket = __privateGet(this, _events);
|
|
265
|
+
break;
|
|
266
|
+
case "error":
|
|
267
|
+
bucket = __privateGet(this, _errors);
|
|
268
|
+
break;
|
|
269
|
+
default:
|
|
270
|
+
return;
|
|
375
271
|
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
return fromArrayLike(obj.data);
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
function checked(length) {
|
|
383
|
-
if (length >= K_MAX_LENGTH) {
|
|
384
|
-
throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + K_MAX_LENGTH.toString(16) + " bytes");
|
|
385
|
-
}
|
|
386
|
-
return length | 0;
|
|
387
|
-
}
|
|
388
|
-
function SlowBuffer(length) {
|
|
389
|
-
if (+length != length) {
|
|
390
|
-
length = 0;
|
|
391
|
-
}
|
|
392
|
-
return Buffer2.alloc(+length);
|
|
393
|
-
}
|
|
394
|
-
Buffer2.isBuffer = function isBuffer(b) {
|
|
395
|
-
return b != null && b._isBuffer === true && b !== Buffer2.prototype;
|
|
396
|
-
};
|
|
397
|
-
Buffer2.compare = function compare(a, b) {
|
|
398
|
-
if (isInstance(a, GlobalUint8Array)) a = Buffer2.from(a, a.offset, a.byteLength);
|
|
399
|
-
if (isInstance(b, GlobalUint8Array)) b = Buffer2.from(b, b.offset, b.byteLength);
|
|
400
|
-
if (!Buffer2.isBuffer(a) || !Buffer2.isBuffer(b)) {
|
|
401
|
-
throw new TypeError(
|
|
402
|
-
'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
|
|
403
|
-
);
|
|
404
|
-
}
|
|
405
|
-
if (a === b) return 0;
|
|
406
|
-
let x = a.length;
|
|
407
|
-
let y = b.length;
|
|
408
|
-
for (let i = 0, len = Math.min(x, y); i < len; ++i) {
|
|
409
|
-
if (a[i] !== b[i]) {
|
|
410
|
-
x = a[i];
|
|
411
|
-
y = b[i];
|
|
412
|
-
break;
|
|
272
|
+
const signature = fragment.format();
|
|
273
|
+
if (bucket.has(signature)) {
|
|
274
|
+
return;
|
|
413
275
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
if (
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
276
|
+
bucket.set(signature, fragment);
|
|
277
|
+
});
|
|
278
|
+
if (!this.deploy) {
|
|
279
|
+
defineProperties(this, {
|
|
280
|
+
deploy: ConstructorFragment.from("constructor()")
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
defineProperties(this, { fallback, receive });
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Returns the entire Human-Readable ABI, as an array of
|
|
287
|
+
* signatures, optionally as %%minimal%% strings, which
|
|
288
|
+
* removes parameter names and unneceesary spaces.
|
|
289
|
+
*/
|
|
290
|
+
format(minimal) {
|
|
291
|
+
const format = minimal ? "minimal" : "full";
|
|
292
|
+
const abi = this.fragments.map((f) => f.format(format));
|
|
293
|
+
return abi;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Return the JSON-encoded ABI. This is the format Solidiy
|
|
297
|
+
* returns.
|
|
298
|
+
*/
|
|
299
|
+
formatJson() {
|
|
300
|
+
const abi = this.fragments.map((f) => f.format("json"));
|
|
301
|
+
return JSON.stringify(abi.map((j) => JSON.parse(j)));
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* The ABI coder that will be used to encode and decode binary
|
|
305
|
+
* data.
|
|
306
|
+
*/
|
|
307
|
+
getAbiCoder() {
|
|
308
|
+
return AbiCoder.defaultAbiCoder();
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Get the function name for %%key%%, which may be a function selector,
|
|
312
|
+
* function name or function signature that belongs to the ABI.
|
|
313
|
+
*/
|
|
314
|
+
getFunctionName(key) {
|
|
315
|
+
const fragment = __privateMethod(this, _Interface_instances, getFunction_fn).call(this, key, null, false);
|
|
316
|
+
assertArgument(fragment, "no matching function", "key", key);
|
|
317
|
+
return fragment.name;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Returns true if %%key%% (a function selector, function name or
|
|
321
|
+
* function signature) is present in the ABI.
|
|
322
|
+
*
|
|
323
|
+
* In the case of a function name, the name may be ambiguous, so
|
|
324
|
+
* accessing the [[FunctionFragment]] may require refinement.
|
|
325
|
+
*/
|
|
326
|
+
hasFunction(key) {
|
|
327
|
+
return !!__privateMethod(this, _Interface_instances, getFunction_fn).call(this, key, null, false);
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Get the [[FunctionFragment]] for %%key%%, which may be a function
|
|
331
|
+
* selector, function name or function signature that belongs to the ABI.
|
|
332
|
+
*
|
|
333
|
+
* If %%values%% is provided, it will use the Typed API to handle
|
|
334
|
+
* ambiguous cases where multiple functions match by name.
|
|
335
|
+
*
|
|
336
|
+
* If the %%key%% and %%values%% do not refine to a single function in
|
|
337
|
+
* the ABI, this will throw.
|
|
338
|
+
*/
|
|
339
|
+
getFunction(key, values) {
|
|
340
|
+
return __privateMethod(this, _Interface_instances, getFunction_fn).call(this, key, values || null, true);
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Iterate over all functions, calling %%callback%%, sorted by their name.
|
|
344
|
+
*/
|
|
345
|
+
forEachFunction(callback) {
|
|
346
|
+
const names = Array.from(__privateGet(this, _functions).keys());
|
|
347
|
+
names.sort((a, b) => a.localeCompare(b));
|
|
348
|
+
for (let i = 0; i < names.length; i++) {
|
|
349
|
+
const name = names[i];
|
|
350
|
+
callback(__privateGet(this, _functions).get(name), i);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Get the event name for %%key%%, which may be a topic hash,
|
|
355
|
+
* event name or event signature that belongs to the ABI.
|
|
356
|
+
*/
|
|
357
|
+
getEventName(key) {
|
|
358
|
+
const fragment = __privateMethod(this, _Interface_instances, getEvent_fn).call(this, key, null, false);
|
|
359
|
+
assertArgument(fragment, "no matching event", "key", key);
|
|
360
|
+
return fragment.name;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Returns true if %%key%% (an event topic hash, event name or
|
|
364
|
+
* event signature) is present in the ABI.
|
|
365
|
+
*
|
|
366
|
+
* In the case of an event name, the name may be ambiguous, so
|
|
367
|
+
* accessing the [[EventFragment]] may require refinement.
|
|
368
|
+
*/
|
|
369
|
+
hasEvent(key) {
|
|
370
|
+
return !!__privateMethod(this, _Interface_instances, getEvent_fn).call(this, key, null, false);
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Get the [[EventFragment]] for %%key%%, which may be a topic hash,
|
|
374
|
+
* event name or event signature that belongs to the ABI.
|
|
375
|
+
*
|
|
376
|
+
* If %%values%% is provided, it will use the Typed API to handle
|
|
377
|
+
* ambiguous cases where multiple events match by name.
|
|
378
|
+
*
|
|
379
|
+
* If the %%key%% and %%values%% do not refine to a single event in
|
|
380
|
+
* the ABI, this will throw.
|
|
381
|
+
*/
|
|
382
|
+
getEvent(key, values) {
|
|
383
|
+
return __privateMethod(this, _Interface_instances, getEvent_fn).call(this, key, values || null, true);
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Iterate over all events, calling %%callback%%, sorted by their name.
|
|
387
|
+
*/
|
|
388
|
+
forEachEvent(callback) {
|
|
389
|
+
const names = Array.from(__privateGet(this, _events).keys());
|
|
390
|
+
names.sort((a, b) => a.localeCompare(b));
|
|
391
|
+
for (let i = 0; i < names.length; i++) {
|
|
392
|
+
const name = names[i];
|
|
393
|
+
callback(__privateGet(this, _events).get(name), i);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Get the [[ErrorFragment]] for %%key%%, which may be an error
|
|
398
|
+
* selector, error name or error signature that belongs to the ABI.
|
|
399
|
+
*
|
|
400
|
+
* If %%values%% is provided, it will use the Typed API to handle
|
|
401
|
+
* ambiguous cases where multiple errors match by name.
|
|
402
|
+
*
|
|
403
|
+
* If the %%key%% and %%values%% do not refine to a single error in
|
|
404
|
+
* the ABI, this will throw.
|
|
405
|
+
*/
|
|
406
|
+
getError(key, values) {
|
|
407
|
+
if (isHexString(key)) {
|
|
408
|
+
const selector = key.toLowerCase();
|
|
409
|
+
if (BuiltinErrors[selector]) {
|
|
410
|
+
return ErrorFragment.from(BuiltinErrors[selector].signature);
|
|
449
411
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
for (i = 0; i < list.length; ++i) {
|
|
454
|
-
let buf = list[i];
|
|
455
|
-
if (isInstance(buf, GlobalUint8Array)) {
|
|
456
|
-
if (pos + buf.length > buffer2.length) {
|
|
457
|
-
if (!Buffer2.isBuffer(buf)) buf = Buffer2.from(buf);
|
|
458
|
-
buf.copy(buffer2, pos);
|
|
459
|
-
} else {
|
|
460
|
-
GlobalUint8Array.prototype.set.call(
|
|
461
|
-
buffer2,
|
|
462
|
-
buf,
|
|
463
|
-
pos
|
|
464
|
-
);
|
|
412
|
+
for (const fragment of __privateGet(this, _errors).values()) {
|
|
413
|
+
if (selector === fragment.selector) {
|
|
414
|
+
return fragment;
|
|
465
415
|
}
|
|
466
|
-
} else if (!Buffer2.isBuffer(buf)) {
|
|
467
|
-
throw new TypeError('"list" argument must be an Array of Buffers');
|
|
468
|
-
} else {
|
|
469
|
-
buf.copy(buffer2, pos);
|
|
470
416
|
}
|
|
471
|
-
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
417
|
+
return null;
|
|
418
|
+
}
|
|
419
|
+
if (key.indexOf("(") === -1) {
|
|
420
|
+
const matching = [];
|
|
421
|
+
for (const [name, fragment] of __privateGet(this, _errors)) {
|
|
422
|
+
if (name.split(
|
|
423
|
+
"("
|
|
424
|
+
/* fix:) */
|
|
425
|
+
)[0] === key) {
|
|
426
|
+
matching.push(fragment);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
if (matching.length === 0) {
|
|
430
|
+
if (key === "Error") {
|
|
431
|
+
return ErrorFragment.from("error Error(string)");
|
|
432
|
+
}
|
|
433
|
+
if (key === "Panic") {
|
|
434
|
+
return ErrorFragment.from("error Panic(uint256)");
|
|
435
|
+
}
|
|
436
|
+
return null;
|
|
437
|
+
} else if (matching.length > 1) {
|
|
438
|
+
const matchStr = matching.map((m) => JSON.stringify(m.format())).join(", ");
|
|
439
|
+
assertArgument(false, `ambiguous error description (i.e. ${matchStr})`, "name", key);
|
|
440
|
+
}
|
|
441
|
+
return matching[0];
|
|
442
|
+
}
|
|
443
|
+
key = ErrorFragment.from(key).format();
|
|
444
|
+
if (key === "Error(string)") {
|
|
445
|
+
return ErrorFragment.from("error Error(string)");
|
|
446
|
+
}
|
|
447
|
+
if (key === "Panic(uint256)") {
|
|
448
|
+
return ErrorFragment.from("error Panic(uint256)");
|
|
449
|
+
}
|
|
450
|
+
const result = __privateGet(this, _errors).get(key);
|
|
451
|
+
if (result) {
|
|
452
|
+
return result;
|
|
453
|
+
}
|
|
454
|
+
return null;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Iterate over all errors, calling %%callback%%, sorted by their name.
|
|
458
|
+
*/
|
|
459
|
+
forEachError(callback) {
|
|
460
|
+
const names = Array.from(__privateGet(this, _errors).keys());
|
|
461
|
+
names.sort((a, b) => a.localeCompare(b));
|
|
462
|
+
for (let i = 0; i < names.length; i++) {
|
|
463
|
+
const name = names[i];
|
|
464
|
+
callback(__privateGet(this, _errors).get(name), i);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
// Get the 4-byte selector used by Solidity to identify a function
|
|
468
|
+
/*
|
|
469
|
+
getSelector(fragment: ErrorFragment | FunctionFragment): string {
|
|
470
|
+
if (typeof(fragment) === "string") {
|
|
471
|
+
const matches: Array<Fragment> = [ ];
|
|
472
|
+
|
|
473
|
+
try { matches.push(this.getFunction(fragment)); } catch (error) { }
|
|
474
|
+
try { matches.push(this.getError(<string>fragment)); } catch (_) { }
|
|
475
|
+
|
|
476
|
+
if (matches.length === 0) {
|
|
477
|
+
logger.throwArgumentError("unknown fragment", "key", fragment);
|
|
478
|
+
} else if (matches.length > 1) {
|
|
479
|
+
logger.throwArgumentError("ambiguous fragment matches function and error", "key", fragment);
|
|
512
480
|
}
|
|
513
|
-
|
|
514
|
-
|
|
481
|
+
|
|
482
|
+
fragment = matches[0];
|
|
515
483
|
}
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
484
|
+
|
|
485
|
+
return dataSlice(id(fragment.format()), 0, 4);
|
|
486
|
+
}
|
|
487
|
+
*/
|
|
488
|
+
// Get the 32-byte topic hash used by Solidity to identify an event
|
|
489
|
+
/*
|
|
490
|
+
getEventTopic(fragment: EventFragment): string {
|
|
491
|
+
//if (typeof(fragment) === "string") { fragment = this.getEvent(eventFragment); }
|
|
492
|
+
return id(fragment.format());
|
|
493
|
+
}
|
|
494
|
+
*/
|
|
495
|
+
_decodeParams(params, data) {
|
|
496
|
+
return __privateGet(this, _abiCoder).decode(params, data);
|
|
497
|
+
}
|
|
498
|
+
_encodeParams(params, values) {
|
|
499
|
+
return __privateGet(this, _abiCoder).encode(params, values);
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Encodes a ``tx.data`` object for deploying the Contract with
|
|
503
|
+
* the %%values%% as the constructor arguments.
|
|
504
|
+
*/
|
|
505
|
+
encodeDeploy(values) {
|
|
506
|
+
return this._encodeParams(this.deploy.inputs, values || []);
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Decodes the result %%data%% (e.g. from an ``eth_call``) for the
|
|
510
|
+
* specified error (see [[getError]] for valid values for
|
|
511
|
+
* %%key%%).
|
|
512
|
+
*
|
|
513
|
+
* Most developers should prefer the [[parseCallResult]] method instead,
|
|
514
|
+
* which will automatically detect a ``CALL_EXCEPTION`` and throw the
|
|
515
|
+
* corresponding error.
|
|
516
|
+
*/
|
|
517
|
+
decodeErrorResult(fragment, data) {
|
|
518
|
+
if (typeof fragment === "string") {
|
|
519
|
+
const f = this.getError(fragment);
|
|
520
|
+
assertArgument(f, "unknown error", "fragment", fragment);
|
|
521
|
+
fragment = f;
|
|
522
|
+
}
|
|
523
|
+
assertArgument(dataSlice(data, 0, 4) === fragment.selector, `data signature does not match error ${fragment.name}.`, "data", data);
|
|
524
|
+
return this._decodeParams(fragment.inputs, dataSlice(data, 4));
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Encodes the transaction revert data for a call result that
|
|
528
|
+
* reverted from the the Contract with the sepcified %%error%%
|
|
529
|
+
* (see [[getError]] for valid values for %%fragment%%) with the %%values%%.
|
|
530
|
+
*
|
|
531
|
+
* This is generally not used by most developers, unless trying to mock
|
|
532
|
+
* a result from a Contract.
|
|
533
|
+
*/
|
|
534
|
+
encodeErrorResult(fragment, values) {
|
|
535
|
+
if (typeof fragment === "string") {
|
|
536
|
+
const f = this.getError(fragment);
|
|
537
|
+
assertArgument(f, "unknown error", "fragment", fragment);
|
|
538
|
+
fragment = f;
|
|
539
|
+
}
|
|
540
|
+
return concat([
|
|
541
|
+
fragment.selector,
|
|
542
|
+
this._encodeParams(fragment.inputs, values || [])
|
|
543
|
+
]);
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Decodes the %%data%% from a transaction ``tx.data`` for
|
|
547
|
+
* the function specified (see [[getFunction]] for valid values
|
|
548
|
+
* for %%fragment%%).
|
|
549
|
+
*
|
|
550
|
+
* Most developers should prefer the [[parseTransaction]] method
|
|
551
|
+
* instead, which will automatically detect the fragment.
|
|
552
|
+
*/
|
|
553
|
+
decodeFunctionData(fragment, data) {
|
|
554
|
+
if (typeof fragment === "string") {
|
|
555
|
+
const f = this.getFunction(fragment);
|
|
556
|
+
assertArgument(f, "unknown function", "fragment", fragment);
|
|
557
|
+
fragment = f;
|
|
558
|
+
}
|
|
559
|
+
assertArgument(dataSlice(data, 0, 4) === fragment.selector, `data signature does not match function ${fragment.name}.`, "data", data);
|
|
560
|
+
return this._decodeParams(fragment.inputs, dataSlice(data, 4));
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Encodes the ``tx.data`` for a transaction that calls the function
|
|
564
|
+
* specified (see [[getFunction]] for valid values for %%fragment%%) with
|
|
565
|
+
* the %%values%%.
|
|
566
|
+
*/
|
|
567
|
+
encodeFunctionData(fragment, values) {
|
|
568
|
+
if (typeof fragment === "string") {
|
|
569
|
+
const f = this.getFunction(fragment);
|
|
570
|
+
assertArgument(f, "unknown function", "fragment", fragment);
|
|
571
|
+
fragment = f;
|
|
572
|
+
}
|
|
573
|
+
return concat([
|
|
574
|
+
fragment.selector,
|
|
575
|
+
this._encodeParams(fragment.inputs, values || [])
|
|
576
|
+
]);
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Decodes the result %%data%% (e.g. from an ``eth_call``) for the
|
|
580
|
+
* specified function (see [[getFunction]] for valid values for
|
|
581
|
+
* %%key%%).
|
|
582
|
+
*
|
|
583
|
+
* Most developers should prefer the [[parseCallResult]] method instead,
|
|
584
|
+
* which will automatically detect a ``CALL_EXCEPTION`` and throw the
|
|
585
|
+
* corresponding error.
|
|
586
|
+
*/
|
|
587
|
+
decodeFunctionResult(fragment, data) {
|
|
588
|
+
if (typeof fragment === "string") {
|
|
589
|
+
const f = this.getFunction(fragment);
|
|
590
|
+
assertArgument(f, "unknown function", "fragment", fragment);
|
|
591
|
+
fragment = f;
|
|
592
|
+
}
|
|
593
|
+
let message = "invalid length for result data";
|
|
594
|
+
const bytes = getBytesCopy(data);
|
|
595
|
+
if (bytes.length % 32 === 0) {
|
|
596
|
+
try {
|
|
597
|
+
return __privateGet(this, _abiCoder).decode(fragment.outputs, bytes);
|
|
598
|
+
} catch (error) {
|
|
599
|
+
message = "could not decode result data";
|
|
562
600
|
}
|
|
563
601
|
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
const
|
|
573
|
-
if (
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
}
|
|
590
|
-
return this;
|
|
591
|
-
};
|
|
592
|
-
Buffer2.prototype.swap64 = function swap64() {
|
|
593
|
-
const len = this.length;
|
|
594
|
-
if (len % 8 !== 0) {
|
|
595
|
-
throw new RangeError("Buffer size must be a multiple of 64-bits");
|
|
596
|
-
}
|
|
597
|
-
for (let i = 0; i < len; i += 8) {
|
|
598
|
-
swap(this, i, i + 7);
|
|
599
|
-
swap(this, i + 1, i + 6);
|
|
600
|
-
swap(this, i + 2, i + 5);
|
|
601
|
-
swap(this, i + 3, i + 4);
|
|
602
|
-
}
|
|
603
|
-
return this;
|
|
604
|
-
};
|
|
605
|
-
Buffer2.prototype.toString = function toString() {
|
|
606
|
-
const length = this.length;
|
|
607
|
-
if (length === 0) return "";
|
|
608
|
-
if (arguments.length === 0) return utf8Slice(this, 0, length);
|
|
609
|
-
return slowToString.apply(this, arguments);
|
|
610
|
-
};
|
|
611
|
-
Buffer2.prototype.toLocaleString = Buffer2.prototype.toString;
|
|
612
|
-
Buffer2.prototype.equals = function equals(b) {
|
|
613
|
-
if (!Buffer2.isBuffer(b)) throw new TypeError("Argument must be a Buffer");
|
|
614
|
-
if (this === b) return true;
|
|
615
|
-
return Buffer2.compare(this, b) === 0;
|
|
616
|
-
};
|
|
617
|
-
Buffer2.prototype.inspect = function inspect() {
|
|
618
|
-
let str = "";
|
|
619
|
-
const max = exports.INSPECT_MAX_BYTES;
|
|
620
|
-
str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim();
|
|
621
|
-
if (this.length > max) str += " ... ";
|
|
622
|
-
return "<Buffer " + str + ">";
|
|
623
|
-
};
|
|
624
|
-
if (customInspectSymbol) {
|
|
625
|
-
Buffer2.prototype[customInspectSymbol] = Buffer2.prototype.inspect;
|
|
626
|
-
}
|
|
627
|
-
Buffer2.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
|
|
628
|
-
if (isInstance(target, GlobalUint8Array)) {
|
|
629
|
-
target = Buffer2.from(target, target.offset, target.byteLength);
|
|
630
|
-
}
|
|
631
|
-
if (!Buffer2.isBuffer(target)) {
|
|
632
|
-
throw new TypeError(
|
|
633
|
-
'The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target
|
|
634
|
-
);
|
|
635
|
-
}
|
|
636
|
-
if (start === void 0) {
|
|
637
|
-
start = 0;
|
|
638
|
-
}
|
|
639
|
-
if (end === void 0) {
|
|
640
|
-
end = target ? target.length : 0;
|
|
641
|
-
}
|
|
642
|
-
if (thisStart === void 0) {
|
|
643
|
-
thisStart = 0;
|
|
644
|
-
}
|
|
645
|
-
if (thisEnd === void 0) {
|
|
646
|
-
thisEnd = this.length;
|
|
647
|
-
}
|
|
648
|
-
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
|
|
649
|
-
throw new RangeError("out of range index");
|
|
650
|
-
}
|
|
651
|
-
if (thisStart >= thisEnd && start >= end) {
|
|
652
|
-
return 0;
|
|
653
|
-
}
|
|
654
|
-
if (thisStart >= thisEnd) {
|
|
655
|
-
return -1;
|
|
656
|
-
}
|
|
657
|
-
if (start >= end) {
|
|
658
|
-
return 1;
|
|
659
|
-
}
|
|
660
|
-
start >>>= 0;
|
|
661
|
-
end >>>= 0;
|
|
662
|
-
thisStart >>>= 0;
|
|
663
|
-
thisEnd >>>= 0;
|
|
664
|
-
if (this === target) return 0;
|
|
665
|
-
let x = thisEnd - thisStart;
|
|
666
|
-
let y = end - start;
|
|
667
|
-
const len = Math.min(x, y);
|
|
668
|
-
const thisCopy = this.slice(thisStart, thisEnd);
|
|
669
|
-
const targetCopy = target.slice(start, end);
|
|
670
|
-
for (let i = 0; i < len; ++i) {
|
|
671
|
-
if (thisCopy[i] !== targetCopy[i]) {
|
|
672
|
-
x = thisCopy[i];
|
|
673
|
-
y = targetCopy[i];
|
|
674
|
-
break;
|
|
602
|
+
assert(false, message, "BAD_DATA", {
|
|
603
|
+
value: hexlify(bytes),
|
|
604
|
+
info: { method: fragment.name, signature: fragment.format() }
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
makeError(_data, tx) {
|
|
608
|
+
const data = getBytes(_data, "data");
|
|
609
|
+
const error = AbiCoder.getBuiltinCallException("call", tx, data);
|
|
610
|
+
const customPrefix = "execution reverted (unknown custom error)";
|
|
611
|
+
if (error.message.startsWith(customPrefix)) {
|
|
612
|
+
const selector = hexlify(data.slice(0, 4));
|
|
613
|
+
const ef = this.getError(selector);
|
|
614
|
+
if (ef) {
|
|
615
|
+
try {
|
|
616
|
+
const args = __privateGet(this, _abiCoder).decode(ef.inputs, data.slice(4));
|
|
617
|
+
error.revert = {
|
|
618
|
+
name: ef.name,
|
|
619
|
+
signature: ef.format(),
|
|
620
|
+
args
|
|
621
|
+
};
|
|
622
|
+
error.reason = error.revert.signature;
|
|
623
|
+
error.message = `execution reverted: ${error.reason}`;
|
|
624
|
+
} catch (e) {
|
|
625
|
+
error.message = `execution reverted (coult not decode custom error)`;
|
|
626
|
+
}
|
|
675
627
|
}
|
|
676
628
|
}
|
|
677
|
-
|
|
678
|
-
if (
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
if (
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
629
|
+
const parsed = this.parseTransaction(tx);
|
|
630
|
+
if (parsed) {
|
|
631
|
+
error.invocation = {
|
|
632
|
+
method: parsed.name,
|
|
633
|
+
signature: parsed.signature,
|
|
634
|
+
args: parsed.args
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
return error;
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Encodes the result data (e.g. from an ``eth_call``) for the
|
|
641
|
+
* specified function (see [[getFunction]] for valid values
|
|
642
|
+
* for %%fragment%%) with %%values%%.
|
|
643
|
+
*
|
|
644
|
+
* This is generally not used by most developers, unless trying to mock
|
|
645
|
+
* a result from a Contract.
|
|
646
|
+
*/
|
|
647
|
+
encodeFunctionResult(fragment, values) {
|
|
648
|
+
if (typeof fragment === "string") {
|
|
649
|
+
const f = this.getFunction(fragment);
|
|
650
|
+
assertArgument(f, "unknown function", "fragment", fragment);
|
|
651
|
+
fragment = f;
|
|
652
|
+
}
|
|
653
|
+
return hexlify(__privateGet(this, _abiCoder).encode(fragment.outputs, values || []));
|
|
654
|
+
}
|
|
655
|
+
/*
|
|
656
|
+
spelunk(inputs: Array<ParamType>, values: ReadonlyArray<any>, processfunc: (type: string, value: any) => Promise<any>): Promise<Array<any>> {
|
|
657
|
+
const promises: Array<Promise<>> = [ ];
|
|
658
|
+
const process = function(type: ParamType, value: any): any {
|
|
659
|
+
if (type.baseType === "array") {
|
|
660
|
+
return descend(type.child
|
|
661
|
+
}
|
|
662
|
+
if (type. === "address") {
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
const descend = function (inputs: Array<ParamType>, values: ReadonlyArray<any>) {
|
|
667
|
+
if (inputs.length !== values.length) { throw new Error("length mismatch"); }
|
|
668
|
+
|
|
669
|
+
};
|
|
670
|
+
|
|
671
|
+
const result: Array<any> = [ ];
|
|
672
|
+
values.forEach((value, index) => {
|
|
673
|
+
if (value == null) {
|
|
674
|
+
topics.push(null);
|
|
675
|
+
} else if (param.baseType === "array" || param.baseType === "tuple") {
|
|
676
|
+
logger.throwArgumentError("filtering with tuples or arrays not supported", ("contract." + param.name), value);
|
|
677
|
+
} else if (Array.isArray(value)) {
|
|
678
|
+
topics.push(value.map((value) => encodeTopic(param, value)));
|
|
679
|
+
} else {
|
|
680
|
+
topics.push(encodeTopic(param, value));
|
|
681
|
+
}
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
*/
|
|
685
|
+
// Create the filter for the event with search criteria (e.g. for eth_filterLog)
|
|
686
|
+
encodeFilterTopics(fragment, values) {
|
|
687
|
+
if (typeof fragment === "string") {
|
|
688
|
+
const f = this.getEvent(fragment);
|
|
689
|
+
assertArgument(f, "unknown event", "eventFragment", fragment);
|
|
690
|
+
fragment = f;
|
|
691
|
+
}
|
|
692
|
+
assert(values.length <= fragment.inputs.length, `too many arguments for ${fragment.format()}`, "UNEXPECTED_ARGUMENT", { count: values.length, expectedCount: fragment.inputs.length });
|
|
693
|
+
const topics = [];
|
|
694
|
+
if (!fragment.anonymous) {
|
|
695
|
+
topics.push(fragment.topicHash);
|
|
696
|
+
}
|
|
697
|
+
const encodeTopic = (param, value) => {
|
|
698
|
+
if (param.type === "string") {
|
|
699
|
+
return id(value);
|
|
700
|
+
} else if (param.type === "bytes") {
|
|
701
|
+
return keccak256(hexlify(value));
|
|
702
|
+
}
|
|
703
|
+
if (param.type === "bool" && typeof value === "boolean") {
|
|
704
|
+
value = value ? "0x01" : "0x00";
|
|
705
|
+
} else if (param.type.match(/^u?int/)) {
|
|
706
|
+
value = toBeHex(value);
|
|
707
|
+
} else if (param.type.match(/^bytes/)) {
|
|
708
|
+
value = zeroPadBytes(value, 32);
|
|
709
|
+
} else if (param.type === "address") {
|
|
710
|
+
__privateGet(this, _abiCoder).encode(["address"], [value]);
|
|
711
|
+
}
|
|
712
|
+
return zeroPadValue(hexlify(value), 32);
|
|
713
|
+
};
|
|
714
|
+
values.forEach((value, index) => {
|
|
715
|
+
const param = fragment.inputs[index];
|
|
716
|
+
if (!param.indexed) {
|
|
717
|
+
assertArgument(value == null, "cannot filter non-indexed parameters; must be null", "contract." + param.name, value);
|
|
718
|
+
return;
|
|
709
719
|
}
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
720
|
+
if (value == null) {
|
|
721
|
+
topics.push(null);
|
|
722
|
+
} else if (param.baseType === "array" || param.baseType === "tuple") {
|
|
723
|
+
assertArgument(false, "filtering with tuples or arrays not supported", "contract." + param.name, value);
|
|
724
|
+
} else if (Array.isArray(value)) {
|
|
725
|
+
topics.push(value.map((value2) => encodeTopic(param, value2)));
|
|
726
|
+
} else {
|
|
727
|
+
topics.push(encodeTopic(param, value));
|
|
728
|
+
}
|
|
729
|
+
});
|
|
730
|
+
while (topics.length && topics[topics.length - 1] === null) {
|
|
731
|
+
topics.pop();
|
|
732
|
+
}
|
|
733
|
+
return topics;
|
|
734
|
+
}
|
|
735
|
+
encodeEventLog(fragment, values) {
|
|
736
|
+
if (typeof fragment === "string") {
|
|
737
|
+
const f = this.getEvent(fragment);
|
|
738
|
+
assertArgument(f, "unknown event", "eventFragment", fragment);
|
|
739
|
+
fragment = f;
|
|
740
|
+
}
|
|
741
|
+
const topics = [];
|
|
742
|
+
const dataTypes = [];
|
|
743
|
+
const dataValues = [];
|
|
744
|
+
if (!fragment.anonymous) {
|
|
745
|
+
topics.push(fragment.topicHash);
|
|
746
|
+
}
|
|
747
|
+
assertArgument(values.length === fragment.inputs.length, "event arguments/values mismatch", "values", values);
|
|
748
|
+
fragment.inputs.forEach((param, index) => {
|
|
749
|
+
const value = values[index];
|
|
750
|
+
if (param.indexed) {
|
|
751
|
+
if (param.type === "string") {
|
|
752
|
+
topics.push(id(value));
|
|
753
|
+
} else if (param.type === "bytes") {
|
|
754
|
+
topics.push(keccak256(value));
|
|
755
|
+
} else if (param.baseType === "tuple" || param.baseType === "array") {
|
|
756
|
+
throw new Error("not implemented");
|
|
716
757
|
} else {
|
|
717
|
-
|
|
758
|
+
topics.push(__privateGet(this, _abiCoder).encode([param.type], [value]));
|
|
718
759
|
}
|
|
760
|
+
} else {
|
|
761
|
+
dataTypes.push(param);
|
|
762
|
+
dataValues.push(value);
|
|
719
763
|
}
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
764
|
+
});
|
|
765
|
+
return {
|
|
766
|
+
data: __privateGet(this, _abiCoder).encode(dataTypes, dataValues),
|
|
767
|
+
topics
|
|
768
|
+
};
|
|
723
769
|
}
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
770
|
+
// Decode a filter for the event and the search criteria
|
|
771
|
+
decodeEventLog(fragment, data, topics) {
|
|
772
|
+
if (typeof fragment === "string") {
|
|
773
|
+
const f = this.getEvent(fragment);
|
|
774
|
+
assertArgument(f, "unknown event", "eventFragment", fragment);
|
|
775
|
+
fragment = f;
|
|
776
|
+
}
|
|
777
|
+
if (topics != null && !fragment.anonymous) {
|
|
778
|
+
const eventTopic = fragment.topicHash;
|
|
779
|
+
assertArgument(isHexString(topics[0], 32) && topics[0].toLowerCase() === eventTopic, "fragment/topic mismatch", "topics[0]", topics[0]);
|
|
780
|
+
topics = topics.slice(1);
|
|
781
|
+
}
|
|
782
|
+
const indexed = [];
|
|
783
|
+
const nonIndexed = [];
|
|
784
|
+
const dynamic = [];
|
|
785
|
+
fragment.inputs.forEach((param, index) => {
|
|
786
|
+
if (param.indexed) {
|
|
787
|
+
if (param.type === "string" || param.type === "bytes" || param.baseType === "tuple" || param.baseType === "array") {
|
|
788
|
+
indexed.push(ParamType.from({ type: "bytes32", name: param.name }));
|
|
789
|
+
dynamic.push(true);
|
|
790
|
+
} else {
|
|
791
|
+
indexed.push(param);
|
|
792
|
+
dynamic.push(false);
|
|
733
793
|
}
|
|
734
|
-
indexSize = 2;
|
|
735
|
-
arrLength /= 2;
|
|
736
|
-
valLength /= 2;
|
|
737
|
-
byteOffset /= 2;
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
function read(buf, i2) {
|
|
741
|
-
if (indexSize === 1) {
|
|
742
|
-
return buf[i2];
|
|
743
794
|
} else {
|
|
744
|
-
|
|
795
|
+
nonIndexed.push(param);
|
|
796
|
+
dynamic.push(false);
|
|
745
797
|
}
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
798
|
+
});
|
|
799
|
+
const resultIndexed = topics != null ? __privateGet(this, _abiCoder).decode(indexed, concat(topics)) : null;
|
|
800
|
+
const resultNonIndexed = __privateGet(this, _abiCoder).decode(nonIndexed, data, true);
|
|
801
|
+
const values = [];
|
|
802
|
+
const keys = [];
|
|
803
|
+
let nonIndexedIndex = 0, indexedIndex = 0;
|
|
804
|
+
fragment.inputs.forEach((param, index) => {
|
|
805
|
+
let value = null;
|
|
806
|
+
if (param.indexed) {
|
|
807
|
+
if (resultIndexed == null) {
|
|
808
|
+
value = new Indexed(null);
|
|
809
|
+
} else if (dynamic[index]) {
|
|
810
|
+
value = new Indexed(resultIndexed[indexedIndex++]);
|
|
754
811
|
} else {
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
} else {
|
|
760
|
-
if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
|
|
761
|
-
for (i = byteOffset; i >= 0; i--) {
|
|
762
|
-
let found = true;
|
|
763
|
-
for (let j = 0; j < valLength; j++) {
|
|
764
|
-
if (read(arr, i + j) !== read(val, j)) {
|
|
765
|
-
found = false;
|
|
766
|
-
break;
|
|
812
|
+
try {
|
|
813
|
+
value = resultIndexed[indexedIndex++];
|
|
814
|
+
} catch (error) {
|
|
815
|
+
value = error;
|
|
767
816
|
}
|
|
768
817
|
}
|
|
769
|
-
|
|
818
|
+
} else {
|
|
819
|
+
try {
|
|
820
|
+
value = resultNonIndexed[nonIndexedIndex++];
|
|
821
|
+
} catch (error) {
|
|
822
|
+
value = error;
|
|
823
|
+
}
|
|
770
824
|
}
|
|
825
|
+
values.push(value);
|
|
826
|
+
keys.push(param.name || null);
|
|
827
|
+
});
|
|
828
|
+
return Result.fromItems(values, keys);
|
|
829
|
+
}
|
|
830
|
+
/**
|
|
831
|
+
* Parses a transaction, finding the matching function and extracts
|
|
832
|
+
* the parameter values along with other useful function details.
|
|
833
|
+
*
|
|
834
|
+
* If the matching function cannot be found, return null.
|
|
835
|
+
*/
|
|
836
|
+
parseTransaction(tx) {
|
|
837
|
+
const data = getBytes(tx.data, "tx.data");
|
|
838
|
+
const value = getBigInt(tx.value != null ? tx.value : 0, "tx.value");
|
|
839
|
+
const fragment = this.getFunction(hexlify(data.slice(0, 4)));
|
|
840
|
+
if (!fragment) {
|
|
841
|
+
return null;
|
|
842
|
+
}
|
|
843
|
+
const args = __privateGet(this, _abiCoder).decode(fragment.inputs, data.slice(4));
|
|
844
|
+
return new TransactionDescription(fragment, fragment.selector, args, value);
|
|
845
|
+
}
|
|
846
|
+
parseCallResult(data) {
|
|
847
|
+
throw new Error("@TODO");
|
|
848
|
+
}
|
|
849
|
+
/**
|
|
850
|
+
* Parses a receipt log, finding the matching event and extracts
|
|
851
|
+
* the parameter values along with other useful event details.
|
|
852
|
+
*
|
|
853
|
+
* If the matching event cannot be found, returns null.
|
|
854
|
+
*/
|
|
855
|
+
parseLog(log) {
|
|
856
|
+
const fragment = this.getEvent(log.topics[0]);
|
|
857
|
+
if (!fragment || fragment.anonymous) {
|
|
858
|
+
return null;
|
|
859
|
+
}
|
|
860
|
+
return new LogDescription(fragment, fragment.topicHash, this.decodeEventLog(fragment, log.data, log.topics));
|
|
861
|
+
}
|
|
862
|
+
/**
|
|
863
|
+
* Parses a revert data, finding the matching error and extracts
|
|
864
|
+
* the parameter values along with other useful error details.
|
|
865
|
+
*
|
|
866
|
+
* If the matching error cannot be found, returns null.
|
|
867
|
+
*/
|
|
868
|
+
parseError(data) {
|
|
869
|
+
const hexData = hexlify(data);
|
|
870
|
+
const fragment = this.getError(dataSlice(hexData, 0, 4));
|
|
871
|
+
if (!fragment) {
|
|
872
|
+
return null;
|
|
873
|
+
}
|
|
874
|
+
const args = __privateGet(this, _abiCoder).decode(fragment.inputs, dataSlice(hexData, 4));
|
|
875
|
+
return new ErrorDescription(fragment, fragment.selector, args);
|
|
876
|
+
}
|
|
877
|
+
/**
|
|
878
|
+
* Creates a new [[Interface]] from the ABI %%value%%.
|
|
879
|
+
*
|
|
880
|
+
* The %%value%% may be provided as an existing [[Interface]] object,
|
|
881
|
+
* a JSON-encoded ABI or any Human-Readable ABI format.
|
|
882
|
+
*/
|
|
883
|
+
static from(value) {
|
|
884
|
+
if (value instanceof _Interface) {
|
|
885
|
+
return value;
|
|
771
886
|
}
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
Buffer2.prototype.includes = function includes(val, byteOffset, encoding) {
|
|
775
|
-
return this.indexOf(val, byteOffset, encoding) !== -1;
|
|
776
|
-
};
|
|
777
|
-
Buffer2.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
|
|
778
|
-
return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
|
|
779
|
-
};
|
|
780
|
-
Buffer2.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
|
|
781
|
-
return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
|
|
782
|
-
};
|
|
783
|
-
function hexWrite(buf, string, offset, length) {
|
|
784
|
-
offset = Number(offset) || 0;
|
|
785
|
-
const remaining = buf.length - offset;
|
|
786
|
-
if (!length) {
|
|
787
|
-
length = remaining;
|
|
788
|
-
} else {
|
|
789
|
-
length = Number(length);
|
|
790
|
-
if (length > remaining) {
|
|
791
|
-
length = remaining;
|
|
792
|
-
}
|
|
887
|
+
if (typeof value === "string") {
|
|
888
|
+
return new _Interface(JSON.parse(value));
|
|
793
889
|
}
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
length = strLen / 2;
|
|
890
|
+
if (typeof value.formatJson === "function") {
|
|
891
|
+
return new _Interface(value.formatJson());
|
|
797
892
|
}
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
const parsed = parseInt(string.substr(i * 2, 2), 16);
|
|
801
|
-
if (numberIsNaN(parsed)) return i;
|
|
802
|
-
buf[offset + i] = parsed;
|
|
893
|
+
if (typeof value.format === "function") {
|
|
894
|
+
return new _Interface(value.format("json"));
|
|
803
895
|
}
|
|
804
|
-
return
|
|
805
|
-
}
|
|
806
|
-
function utf8Write(buf, string, offset, length) {
|
|
807
|
-
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
|
|
896
|
+
return new _Interface(value);
|
|
808
897
|
}
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
offset = 0;
|
|
823
|
-
} else if (length === void 0 && typeof offset === "string") {
|
|
824
|
-
encoding = offset;
|
|
825
|
-
length = this.length;
|
|
826
|
-
offset = 0;
|
|
827
|
-
} else if (isFinite(offset)) {
|
|
828
|
-
offset = offset >>> 0;
|
|
829
|
-
if (isFinite(length)) {
|
|
830
|
-
length = length >>> 0;
|
|
831
|
-
if (encoding === void 0) encoding = "utf8";
|
|
832
|
-
} else {
|
|
833
|
-
encoding = length;
|
|
834
|
-
length = void 0;
|
|
898
|
+
};
|
|
899
|
+
_errors = new WeakMap();
|
|
900
|
+
_events = new WeakMap();
|
|
901
|
+
_functions = new WeakMap();
|
|
902
|
+
_abiCoder = new WeakMap();
|
|
903
|
+
_Interface_instances = new WeakSet();
|
|
904
|
+
// Find a function definition by any means necessary (unless it is ambiguous)
|
|
905
|
+
getFunction_fn = function(key, values, forceUnique) {
|
|
906
|
+
if (isHexString(key)) {
|
|
907
|
+
const selector = key.toLowerCase();
|
|
908
|
+
for (const fragment of __privateGet(this, _functions).values()) {
|
|
909
|
+
if (selector === fragment.selector) {
|
|
910
|
+
return fragment;
|
|
835
911
|
}
|
|
836
|
-
} else {
|
|
837
|
-
throw new Error(
|
|
838
|
-
"Buffer.write(string, encoding, offset[, length]) is no longer supported"
|
|
839
|
-
);
|
|
840
912
|
}
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
return hexWrite(this, string, offset, length);
|
|
852
|
-
case "utf8":
|
|
853
|
-
case "utf-8":
|
|
854
|
-
return utf8Write(this, string, offset, length);
|
|
855
|
-
case "ascii":
|
|
856
|
-
case "latin1":
|
|
857
|
-
case "binary":
|
|
858
|
-
return asciiWrite(this, string, offset, length);
|
|
859
|
-
case "base64":
|
|
860
|
-
return base64Write(this, string, offset, length);
|
|
861
|
-
case "ucs2":
|
|
862
|
-
case "ucs-2":
|
|
863
|
-
case "utf16le":
|
|
864
|
-
case "utf-16le":
|
|
865
|
-
return ucs2Write(this, string, offset, length);
|
|
866
|
-
default:
|
|
867
|
-
if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
|
|
868
|
-
encoding = ("" + encoding).toLowerCase();
|
|
869
|
-
loweredCase = true;
|
|
913
|
+
return null;
|
|
914
|
+
}
|
|
915
|
+
if (key.indexOf("(") === -1) {
|
|
916
|
+
const matching = [];
|
|
917
|
+
for (const [name, fragment] of __privateGet(this, _functions)) {
|
|
918
|
+
if (name.split(
|
|
919
|
+
"("
|
|
920
|
+
/* fix:) */
|
|
921
|
+
)[0] === key) {
|
|
922
|
+
matching.push(fragment);
|
|
870
923
|
}
|
|
871
924
|
}
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
let secondByte, thirdByte, fourthByte, tempCodePoint;
|
|
896
|
-
switch (bytesPerSequence) {
|
|
897
|
-
case 1:
|
|
898
|
-
if (firstByte < 128) {
|
|
899
|
-
codePoint = firstByte;
|
|
900
|
-
}
|
|
901
|
-
break;
|
|
902
|
-
case 2:
|
|
903
|
-
secondByte = buf[i + 1];
|
|
904
|
-
if ((secondByte & 192) === 128) {
|
|
905
|
-
tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
|
|
906
|
-
if (tempCodePoint > 127) {
|
|
907
|
-
codePoint = tempCodePoint;
|
|
908
|
-
}
|
|
925
|
+
if (values) {
|
|
926
|
+
const lastValue = values.length > 0 ? values[values.length - 1] : null;
|
|
927
|
+
let valueLength = values.length;
|
|
928
|
+
let allowOptions = true;
|
|
929
|
+
if (Typed.isTyped(lastValue) && lastValue.type === "overrides") {
|
|
930
|
+
allowOptions = false;
|
|
931
|
+
valueLength--;
|
|
932
|
+
}
|
|
933
|
+
for (let i = matching.length - 1; i >= 0; i--) {
|
|
934
|
+
const inputs = matching[i].inputs.length;
|
|
935
|
+
if (inputs !== valueLength && (!allowOptions || inputs !== valueLength - 1)) {
|
|
936
|
+
matching.splice(i, 1);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
for (let i = matching.length - 1; i >= 0; i--) {
|
|
940
|
+
const inputs = matching[i].inputs;
|
|
941
|
+
for (let j = 0; j < values.length; j++) {
|
|
942
|
+
if (!Typed.isTyped(values[j])) {
|
|
943
|
+
continue;
|
|
944
|
+
}
|
|
945
|
+
if (j >= inputs.length) {
|
|
946
|
+
if (values[j].type === "overrides") {
|
|
947
|
+
continue;
|
|
909
948
|
}
|
|
949
|
+
matching.splice(i, 1);
|
|
910
950
|
break;
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
|
|
915
|
-
tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
|
|
916
|
-
if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) {
|
|
917
|
-
codePoint = tempCodePoint;
|
|
918
|
-
}
|
|
919
|
-
}
|
|
951
|
+
}
|
|
952
|
+
if (values[j].type !== inputs[j].baseType) {
|
|
953
|
+
matching.splice(i, 1);
|
|
920
954
|
break;
|
|
921
|
-
|
|
922
|
-
secondByte = buf[i + 1];
|
|
923
|
-
thirdByte = buf[i + 2];
|
|
924
|
-
fourthByte = buf[i + 3];
|
|
925
|
-
if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
|
|
926
|
-
tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
|
|
927
|
-
if (tempCodePoint > 65535 && tempCodePoint < 1114112) {
|
|
928
|
-
codePoint = tempCodePoint;
|
|
929
|
-
}
|
|
930
|
-
}
|
|
955
|
+
}
|
|
931
956
|
}
|
|
932
957
|
}
|
|
933
|
-
if (codePoint === null) {
|
|
934
|
-
codePoint = 65533;
|
|
935
|
-
bytesPerSequence = 1;
|
|
936
|
-
} else if (codePoint > 65535) {
|
|
937
|
-
codePoint -= 65536;
|
|
938
|
-
res.push(codePoint >>> 10 & 1023 | 55296);
|
|
939
|
-
codePoint = 56320 | codePoint & 1023;
|
|
940
|
-
}
|
|
941
|
-
res.push(codePoint);
|
|
942
|
-
i += bytesPerSequence;
|
|
943
|
-
}
|
|
944
|
-
return decodeCodePointsArray(res);
|
|
945
|
-
}
|
|
946
|
-
const MAX_ARGUMENTS_LENGTH = 4096;
|
|
947
|
-
function decodeCodePointsArray(codePoints) {
|
|
948
|
-
const len = codePoints.length;
|
|
949
|
-
if (len <= MAX_ARGUMENTS_LENGTH) {
|
|
950
|
-
return String.fromCharCode.apply(String, codePoints);
|
|
951
|
-
}
|
|
952
|
-
let res = "";
|
|
953
|
-
let i = 0;
|
|
954
|
-
while (i < len) {
|
|
955
|
-
res += String.fromCharCode.apply(
|
|
956
|
-
String,
|
|
957
|
-
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
|
|
958
|
-
);
|
|
959
|
-
}
|
|
960
|
-
return res;
|
|
961
|
-
}
|
|
962
|
-
function asciiSlice(buf, start, end) {
|
|
963
|
-
let ret = "";
|
|
964
|
-
end = Math.min(buf.length, end);
|
|
965
|
-
for (let i = start; i < end; ++i) {
|
|
966
|
-
ret += String.fromCharCode(buf[i] & 127);
|
|
967
|
-
}
|
|
968
|
-
return ret;
|
|
969
|
-
}
|
|
970
|
-
function latin1Slice(buf, start, end) {
|
|
971
|
-
let ret = "";
|
|
972
|
-
end = Math.min(buf.length, end);
|
|
973
|
-
for (let i = start; i < end; ++i) {
|
|
974
|
-
ret += String.fromCharCode(buf[i]);
|
|
975
|
-
}
|
|
976
|
-
return ret;
|
|
977
|
-
}
|
|
978
|
-
function hexSlice(buf, start, end) {
|
|
979
|
-
const len = buf.length;
|
|
980
|
-
if (!start || start < 0) start = 0;
|
|
981
|
-
if (!end || end < 0 || end > len) end = len;
|
|
982
|
-
let out = "";
|
|
983
|
-
for (let i = start; i < end; ++i) {
|
|
984
|
-
out += hexSliceLookupTable[buf[i]];
|
|
985
|
-
}
|
|
986
|
-
return out;
|
|
987
|
-
}
|
|
988
|
-
function utf16leSlice(buf, start, end) {
|
|
989
|
-
const bytes = buf.slice(start, end);
|
|
990
|
-
let res = "";
|
|
991
|
-
for (let i = 0; i < bytes.length - 1; i += 2) {
|
|
992
|
-
res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
|
|
993
|
-
}
|
|
994
|
-
return res;
|
|
995
|
-
}
|
|
996
|
-
Buffer2.prototype.slice = function slice(start, end) {
|
|
997
|
-
const len = this.length;
|
|
998
|
-
start = ~~start;
|
|
999
|
-
end = end === void 0 ? len : ~~end;
|
|
1000
|
-
if (start < 0) {
|
|
1001
|
-
start += len;
|
|
1002
|
-
if (start < 0) start = 0;
|
|
1003
|
-
} else if (start > len) {
|
|
1004
|
-
start = len;
|
|
1005
|
-
}
|
|
1006
|
-
if (end < 0) {
|
|
1007
|
-
end += len;
|
|
1008
|
-
if (end < 0) end = 0;
|
|
1009
|
-
} else if (end > len) {
|
|
1010
|
-
end = len;
|
|
1011
|
-
}
|
|
1012
|
-
if (end < start) end = start;
|
|
1013
|
-
const newBuf = this.subarray(start, end);
|
|
1014
|
-
Object.setPrototypeOf(newBuf, Buffer2.prototype);
|
|
1015
|
-
return newBuf;
|
|
1016
|
-
};
|
|
1017
|
-
function checkOffset(offset, ext, length) {
|
|
1018
|
-
if (offset % 1 !== 0 || offset < 0) throw new RangeError("offset is not uint");
|
|
1019
|
-
if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length");
|
|
1020
|
-
}
|
|
1021
|
-
Buffer2.prototype.readUintLE = Buffer2.prototype.readUIntLE = function readUIntLE(offset, byteLength3, noAssert) {
|
|
1022
|
-
offset = offset >>> 0;
|
|
1023
|
-
byteLength3 = byteLength3 >>> 0;
|
|
1024
|
-
if (!noAssert) checkOffset(offset, byteLength3, this.length);
|
|
1025
|
-
let val = this[offset];
|
|
1026
|
-
let mul = 1;
|
|
1027
|
-
let i = 0;
|
|
1028
|
-
while (++i < byteLength3 && (mul *= 256)) {
|
|
1029
|
-
val += this[offset + i] * mul;
|
|
1030
|
-
}
|
|
1031
|
-
return val;
|
|
1032
|
-
};
|
|
1033
|
-
Buffer2.prototype.readUintBE = Buffer2.prototype.readUIntBE = function readUIntBE(offset, byteLength3, noAssert) {
|
|
1034
|
-
offset = offset >>> 0;
|
|
1035
|
-
byteLength3 = byteLength3 >>> 0;
|
|
1036
|
-
if (!noAssert) {
|
|
1037
|
-
checkOffset(offset, byteLength3, this.length);
|
|
1038
|
-
}
|
|
1039
|
-
let val = this[offset + --byteLength3];
|
|
1040
|
-
let mul = 1;
|
|
1041
|
-
while (byteLength3 > 0 && (mul *= 256)) {
|
|
1042
|
-
val += this[offset + --byteLength3] * mul;
|
|
1043
|
-
}
|
|
1044
|
-
return val;
|
|
1045
|
-
};
|
|
1046
|
-
Buffer2.prototype.readUint8 = Buffer2.prototype.readUInt8 = function readUInt8(offset, noAssert) {
|
|
1047
|
-
offset = offset >>> 0;
|
|
1048
|
-
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
1049
|
-
return this[offset];
|
|
1050
|
-
};
|
|
1051
|
-
Buffer2.prototype.readUint16LE = Buffer2.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
|
|
1052
|
-
offset = offset >>> 0;
|
|
1053
|
-
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1054
|
-
return this[offset] | this[offset + 1] << 8;
|
|
1055
|
-
};
|
|
1056
|
-
Buffer2.prototype.readUint16BE = Buffer2.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
|
|
1057
|
-
offset = offset >>> 0;
|
|
1058
|
-
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1059
|
-
return this[offset] << 8 | this[offset + 1];
|
|
1060
|
-
};
|
|
1061
|
-
Buffer2.prototype.readUint32LE = Buffer2.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
|
|
1062
|
-
offset = offset >>> 0;
|
|
1063
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1064
|
-
return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
|
|
1065
|
-
};
|
|
1066
|
-
Buffer2.prototype.readUint32BE = Buffer2.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
|
|
1067
|
-
offset = offset >>> 0;
|
|
1068
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1069
|
-
return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
|
|
1070
|
-
};
|
|
1071
|
-
Buffer2.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE(offset) {
|
|
1072
|
-
offset = offset >>> 0;
|
|
1073
|
-
validateNumber(offset, "offset");
|
|
1074
|
-
const first = this[offset];
|
|
1075
|
-
const last = this[offset + 7];
|
|
1076
|
-
if (first === void 0 || last === void 0) {
|
|
1077
|
-
boundsError(offset, this.length - 8);
|
|
1078
|
-
}
|
|
1079
|
-
const lo = first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24;
|
|
1080
|
-
const hi = this[++offset] + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + last * 2 ** 24;
|
|
1081
|
-
return BigInt(lo) + (BigInt(hi) << BigInt(32));
|
|
1082
|
-
});
|
|
1083
|
-
Buffer2.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE(offset) {
|
|
1084
|
-
offset = offset >>> 0;
|
|
1085
|
-
validateNumber(offset, "offset");
|
|
1086
|
-
const first = this[offset];
|
|
1087
|
-
const last = this[offset + 7];
|
|
1088
|
-
if (first === void 0 || last === void 0) {
|
|
1089
|
-
boundsError(offset, this.length - 8);
|
|
1090
|
-
}
|
|
1091
|
-
const hi = first * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
|
|
1092
|
-
const lo = this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last;
|
|
1093
|
-
return (BigInt(hi) << BigInt(32)) + BigInt(lo);
|
|
1094
|
-
});
|
|
1095
|
-
Buffer2.prototype.readIntLE = function readIntLE(offset, byteLength3, noAssert) {
|
|
1096
|
-
offset = offset >>> 0;
|
|
1097
|
-
byteLength3 = byteLength3 >>> 0;
|
|
1098
|
-
if (!noAssert) checkOffset(offset, byteLength3, this.length);
|
|
1099
|
-
let val = this[offset];
|
|
1100
|
-
let mul = 1;
|
|
1101
|
-
let i = 0;
|
|
1102
|
-
while (++i < byteLength3 && (mul *= 256)) {
|
|
1103
|
-
val += this[offset + i] * mul;
|
|
1104
|
-
}
|
|
1105
|
-
mul *= 128;
|
|
1106
|
-
if (val >= mul) val -= Math.pow(2, 8 * byteLength3);
|
|
1107
|
-
return val;
|
|
1108
|
-
};
|
|
1109
|
-
Buffer2.prototype.readIntBE = function readIntBE(offset, byteLength3, noAssert) {
|
|
1110
|
-
offset = offset >>> 0;
|
|
1111
|
-
byteLength3 = byteLength3 >>> 0;
|
|
1112
|
-
if (!noAssert) checkOffset(offset, byteLength3, this.length);
|
|
1113
|
-
let i = byteLength3;
|
|
1114
|
-
let mul = 1;
|
|
1115
|
-
let val = this[offset + --i];
|
|
1116
|
-
while (i > 0 && (mul *= 256)) {
|
|
1117
|
-
val += this[offset + --i] * mul;
|
|
1118
|
-
}
|
|
1119
|
-
mul *= 128;
|
|
1120
|
-
if (val >= mul) val -= Math.pow(2, 8 * byteLength3);
|
|
1121
|
-
return val;
|
|
1122
|
-
};
|
|
1123
|
-
Buffer2.prototype.readInt8 = function readInt8(offset, noAssert) {
|
|
1124
|
-
offset = offset >>> 0;
|
|
1125
|
-
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
1126
|
-
if (!(this[offset] & 128)) return this[offset];
|
|
1127
|
-
return (255 - this[offset] + 1) * -1;
|
|
1128
|
-
};
|
|
1129
|
-
Buffer2.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
|
|
1130
|
-
offset = offset >>> 0;
|
|
1131
|
-
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1132
|
-
const val = this[offset] | this[offset + 1] << 8;
|
|
1133
|
-
return val & 32768 ? val | 4294901760 : val;
|
|
1134
|
-
};
|
|
1135
|
-
Buffer2.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
|
|
1136
|
-
offset = offset >>> 0;
|
|
1137
|
-
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1138
|
-
const val = this[offset + 1] | this[offset] << 8;
|
|
1139
|
-
return val & 32768 ? val | 4294901760 : val;
|
|
1140
|
-
};
|
|
1141
|
-
Buffer2.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
|
|
1142
|
-
offset = offset >>> 0;
|
|
1143
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1144
|
-
return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
|
|
1145
|
-
};
|
|
1146
|
-
Buffer2.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
|
|
1147
|
-
offset = offset >>> 0;
|
|
1148
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1149
|
-
return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
|
|
1150
|
-
};
|
|
1151
|
-
Buffer2.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE(offset) {
|
|
1152
|
-
offset = offset >>> 0;
|
|
1153
|
-
validateNumber(offset, "offset");
|
|
1154
|
-
const first = this[offset];
|
|
1155
|
-
const last = this[offset + 7];
|
|
1156
|
-
if (first === void 0 || last === void 0) {
|
|
1157
|
-
boundsError(offset, this.length - 8);
|
|
1158
|
-
}
|
|
1159
|
-
const val = this[offset + 4] + this[offset + 5] * 2 ** 8 + this[offset + 6] * 2 ** 16 + (last << 24);
|
|
1160
|
-
return (BigInt(val) << BigInt(32)) + BigInt(first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24);
|
|
1161
|
-
});
|
|
1162
|
-
Buffer2.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE(offset) {
|
|
1163
|
-
offset = offset >>> 0;
|
|
1164
|
-
validateNumber(offset, "offset");
|
|
1165
|
-
const first = this[offset];
|
|
1166
|
-
const last = this[offset + 7];
|
|
1167
|
-
if (first === void 0 || last === void 0) {
|
|
1168
|
-
boundsError(offset, this.length - 8);
|
|
1169
958
|
}
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
Buffer2.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
|
|
1175
|
-
offset = offset >>> 0;
|
|
1176
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1177
|
-
return ieee754$1.read(this, offset, true, 23, 4);
|
|
1178
|
-
};
|
|
1179
|
-
Buffer2.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
|
|
1180
|
-
offset = offset >>> 0;
|
|
1181
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1182
|
-
return ieee754$1.read(this, offset, false, 23, 4);
|
|
1183
|
-
};
|
|
1184
|
-
Buffer2.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
|
|
1185
|
-
offset = offset >>> 0;
|
|
1186
|
-
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
1187
|
-
return ieee754$1.read(this, offset, true, 52, 8);
|
|
1188
|
-
};
|
|
1189
|
-
Buffer2.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
|
|
1190
|
-
offset = offset >>> 0;
|
|
1191
|
-
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
1192
|
-
return ieee754$1.read(this, offset, false, 52, 8);
|
|
1193
|
-
};
|
|
1194
|
-
function checkInt(buf, value, offset, ext, max, min) {
|
|
1195
|
-
if (!Buffer2.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance');
|
|
1196
|
-
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds');
|
|
1197
|
-
if (offset + ext > buf.length) throw new RangeError("Index out of range");
|
|
1198
|
-
}
|
|
1199
|
-
Buffer2.prototype.writeUintLE = Buffer2.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength3, noAssert) {
|
|
1200
|
-
value = +value;
|
|
1201
|
-
offset = offset >>> 0;
|
|
1202
|
-
byteLength3 = byteLength3 >>> 0;
|
|
1203
|
-
if (!noAssert) {
|
|
1204
|
-
const maxBytes = Math.pow(2, 8 * byteLength3) - 1;
|
|
1205
|
-
checkInt(this, value, offset, byteLength3, maxBytes, 0);
|
|
1206
|
-
}
|
|
1207
|
-
let mul = 1;
|
|
1208
|
-
let i = 0;
|
|
1209
|
-
this[offset] = value & 255;
|
|
1210
|
-
while (++i < byteLength3 && (mul *= 256)) {
|
|
1211
|
-
this[offset + i] = value / mul & 255;
|
|
1212
|
-
}
|
|
1213
|
-
return offset + byteLength3;
|
|
1214
|
-
};
|
|
1215
|
-
Buffer2.prototype.writeUintBE = Buffer2.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength3, noAssert) {
|
|
1216
|
-
value = +value;
|
|
1217
|
-
offset = offset >>> 0;
|
|
1218
|
-
byteLength3 = byteLength3 >>> 0;
|
|
1219
|
-
if (!noAssert) {
|
|
1220
|
-
const maxBytes = Math.pow(2, 8 * byteLength3) - 1;
|
|
1221
|
-
checkInt(this, value, offset, byteLength3, maxBytes, 0);
|
|
1222
|
-
}
|
|
1223
|
-
let i = byteLength3 - 1;
|
|
1224
|
-
let mul = 1;
|
|
1225
|
-
this[offset + i] = value & 255;
|
|
1226
|
-
while (--i >= 0 && (mul *= 256)) {
|
|
1227
|
-
this[offset + i] = value / mul & 255;
|
|
1228
|
-
}
|
|
1229
|
-
return offset + byteLength3;
|
|
1230
|
-
};
|
|
1231
|
-
Buffer2.prototype.writeUint8 = Buffer2.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
|
|
1232
|
-
value = +value;
|
|
1233
|
-
offset = offset >>> 0;
|
|
1234
|
-
if (!noAssert) checkInt(this, value, offset, 1, 255, 0);
|
|
1235
|
-
this[offset] = value & 255;
|
|
1236
|
-
return offset + 1;
|
|
1237
|
-
};
|
|
1238
|
-
Buffer2.prototype.writeUint16LE = Buffer2.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
|
|
1239
|
-
value = +value;
|
|
1240
|
-
offset = offset >>> 0;
|
|
1241
|
-
if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
|
|
1242
|
-
this[offset] = value & 255;
|
|
1243
|
-
this[offset + 1] = value >>> 8;
|
|
1244
|
-
return offset + 2;
|
|
1245
|
-
};
|
|
1246
|
-
Buffer2.prototype.writeUint16BE = Buffer2.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
|
|
1247
|
-
value = +value;
|
|
1248
|
-
offset = offset >>> 0;
|
|
1249
|
-
if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
|
|
1250
|
-
this[offset] = value >>> 8;
|
|
1251
|
-
this[offset + 1] = value & 255;
|
|
1252
|
-
return offset + 2;
|
|
1253
|
-
};
|
|
1254
|
-
Buffer2.prototype.writeUint32LE = Buffer2.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
|
|
1255
|
-
value = +value;
|
|
1256
|
-
offset = offset >>> 0;
|
|
1257
|
-
if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
|
|
1258
|
-
this[offset + 3] = value >>> 24;
|
|
1259
|
-
this[offset + 2] = value >>> 16;
|
|
1260
|
-
this[offset + 1] = value >>> 8;
|
|
1261
|
-
this[offset] = value & 255;
|
|
1262
|
-
return offset + 4;
|
|
1263
|
-
};
|
|
1264
|
-
Buffer2.prototype.writeUint32BE = Buffer2.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
|
|
1265
|
-
value = +value;
|
|
1266
|
-
offset = offset >>> 0;
|
|
1267
|
-
if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
|
|
1268
|
-
this[offset] = value >>> 24;
|
|
1269
|
-
this[offset + 1] = value >>> 16;
|
|
1270
|
-
this[offset + 2] = value >>> 8;
|
|
1271
|
-
this[offset + 3] = value & 255;
|
|
1272
|
-
return offset + 4;
|
|
1273
|
-
};
|
|
1274
|
-
function wrtBigUInt64LE(buf, value, offset, min, max) {
|
|
1275
|
-
checkIntBI(value, min, max, buf, offset, 7);
|
|
1276
|
-
let lo = Number(value & BigInt(4294967295));
|
|
1277
|
-
buf[offset++] = lo;
|
|
1278
|
-
lo = lo >> 8;
|
|
1279
|
-
buf[offset++] = lo;
|
|
1280
|
-
lo = lo >> 8;
|
|
1281
|
-
buf[offset++] = lo;
|
|
1282
|
-
lo = lo >> 8;
|
|
1283
|
-
buf[offset++] = lo;
|
|
1284
|
-
let hi = Number(value >> BigInt(32) & BigInt(4294967295));
|
|
1285
|
-
buf[offset++] = hi;
|
|
1286
|
-
hi = hi >> 8;
|
|
1287
|
-
buf[offset++] = hi;
|
|
1288
|
-
hi = hi >> 8;
|
|
1289
|
-
buf[offset++] = hi;
|
|
1290
|
-
hi = hi >> 8;
|
|
1291
|
-
buf[offset++] = hi;
|
|
1292
|
-
return offset;
|
|
1293
|
-
}
|
|
1294
|
-
function wrtBigUInt64BE(buf, value, offset, min, max) {
|
|
1295
|
-
checkIntBI(value, min, max, buf, offset, 7);
|
|
1296
|
-
let lo = Number(value & BigInt(4294967295));
|
|
1297
|
-
buf[offset + 7] = lo;
|
|
1298
|
-
lo = lo >> 8;
|
|
1299
|
-
buf[offset + 6] = lo;
|
|
1300
|
-
lo = lo >> 8;
|
|
1301
|
-
buf[offset + 5] = lo;
|
|
1302
|
-
lo = lo >> 8;
|
|
1303
|
-
buf[offset + 4] = lo;
|
|
1304
|
-
let hi = Number(value >> BigInt(32) & BigInt(4294967295));
|
|
1305
|
-
buf[offset + 3] = hi;
|
|
1306
|
-
hi = hi >> 8;
|
|
1307
|
-
buf[offset + 2] = hi;
|
|
1308
|
-
hi = hi >> 8;
|
|
1309
|
-
buf[offset + 1] = hi;
|
|
1310
|
-
hi = hi >> 8;
|
|
1311
|
-
buf[offset] = hi;
|
|
1312
|
-
return offset + 8;
|
|
1313
|
-
}
|
|
1314
|
-
Buffer2.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) {
|
|
1315
|
-
return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
|
|
1316
|
-
});
|
|
1317
|
-
Buffer2.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) {
|
|
1318
|
-
return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
|
|
1319
|
-
});
|
|
1320
|
-
Buffer2.prototype.writeIntLE = function writeIntLE(value, offset, byteLength3, noAssert) {
|
|
1321
|
-
value = +value;
|
|
1322
|
-
offset = offset >>> 0;
|
|
1323
|
-
if (!noAssert) {
|
|
1324
|
-
const limit = Math.pow(2, 8 * byteLength3 - 1);
|
|
1325
|
-
checkInt(this, value, offset, byteLength3, limit - 1, -limit);
|
|
1326
|
-
}
|
|
1327
|
-
let i = 0;
|
|
1328
|
-
let mul = 1;
|
|
1329
|
-
let sub = 0;
|
|
1330
|
-
this[offset] = value & 255;
|
|
1331
|
-
while (++i < byteLength3 && (mul *= 256)) {
|
|
1332
|
-
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
|
|
1333
|
-
sub = 1;
|
|
959
|
+
if (matching.length === 1 && values && values.length !== matching[0].inputs.length) {
|
|
960
|
+
const lastArg = values[values.length - 1];
|
|
961
|
+
if (lastArg == null || Array.isArray(lastArg) || typeof lastArg !== "object") {
|
|
962
|
+
matching.splice(0, 1);
|
|
1334
963
|
}
|
|
1335
|
-
this[offset + i] = (value / mul >> 0) - sub & 255;
|
|
1336
964
|
}
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
Buffer2.prototype.writeIntBE = function writeIntBE(value, offset, byteLength3, noAssert) {
|
|
1340
|
-
value = +value;
|
|
1341
|
-
offset = offset >>> 0;
|
|
1342
|
-
if (!noAssert) {
|
|
1343
|
-
const limit = Math.pow(2, 8 * byteLength3 - 1);
|
|
1344
|
-
checkInt(this, value, offset, byteLength3, limit - 1, -limit);
|
|
965
|
+
if (matching.length === 0) {
|
|
966
|
+
return null;
|
|
1345
967
|
}
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
this[offset + i] = value & 255;
|
|
1350
|
-
while (--i >= 0 && (mul *= 256)) {
|
|
1351
|
-
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
|
|
1352
|
-
sub = 1;
|
|
1353
|
-
}
|
|
1354
|
-
this[offset + i] = (value / mul >> 0) - sub & 255;
|
|
968
|
+
if (matching.length > 1 && forceUnique) {
|
|
969
|
+
const matchStr = matching.map((m) => JSON.stringify(m.format())).join(", ");
|
|
970
|
+
assertArgument(false, `ambiguous function description (i.e. matches ${matchStr})`, "key", key);
|
|
1355
971
|
}
|
|
1356
|
-
return
|
|
1357
|
-
};
|
|
1358
|
-
Buffer2.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
|
|
1359
|
-
value = +value;
|
|
1360
|
-
offset = offset >>> 0;
|
|
1361
|
-
if (!noAssert) checkInt(this, value, offset, 1, 127, -128);
|
|
1362
|
-
if (value < 0) value = 255 + value + 1;
|
|
1363
|
-
this[offset] = value & 255;
|
|
1364
|
-
return offset + 1;
|
|
1365
|
-
};
|
|
1366
|
-
Buffer2.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
|
|
1367
|
-
value = +value;
|
|
1368
|
-
offset = offset >>> 0;
|
|
1369
|
-
if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
|
|
1370
|
-
this[offset] = value & 255;
|
|
1371
|
-
this[offset + 1] = value >>> 8;
|
|
1372
|
-
return offset + 2;
|
|
1373
|
-
};
|
|
1374
|
-
Buffer2.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
|
|
1375
|
-
value = +value;
|
|
1376
|
-
offset = offset >>> 0;
|
|
1377
|
-
if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
|
|
1378
|
-
this[offset] = value >>> 8;
|
|
1379
|
-
this[offset + 1] = value & 255;
|
|
1380
|
-
return offset + 2;
|
|
1381
|
-
};
|
|
1382
|
-
Buffer2.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
|
|
1383
|
-
value = +value;
|
|
1384
|
-
offset = offset >>> 0;
|
|
1385
|
-
if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
|
|
1386
|
-
this[offset] = value & 255;
|
|
1387
|
-
this[offset + 1] = value >>> 8;
|
|
1388
|
-
this[offset + 2] = value >>> 16;
|
|
1389
|
-
this[offset + 3] = value >>> 24;
|
|
1390
|
-
return offset + 4;
|
|
1391
|
-
};
|
|
1392
|
-
Buffer2.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
|
|
1393
|
-
value = +value;
|
|
1394
|
-
offset = offset >>> 0;
|
|
1395
|
-
if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
|
|
1396
|
-
if (value < 0) value = 4294967295 + value + 1;
|
|
1397
|
-
this[offset] = value >>> 24;
|
|
1398
|
-
this[offset + 1] = value >>> 16;
|
|
1399
|
-
this[offset + 2] = value >>> 8;
|
|
1400
|
-
this[offset + 3] = value & 255;
|
|
1401
|
-
return offset + 4;
|
|
1402
|
-
};
|
|
1403
|
-
Buffer2.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) {
|
|
1404
|
-
return wrtBigUInt64LE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
|
|
1405
|
-
});
|
|
1406
|
-
Buffer2.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset = 0) {
|
|
1407
|
-
return wrtBigUInt64BE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
|
|
1408
|
-
});
|
|
1409
|
-
function checkIEEE754(buf, value, offset, ext, max, min) {
|
|
1410
|
-
if (offset + ext > buf.length) throw new RangeError("Index out of range");
|
|
1411
|
-
if (offset < 0) throw new RangeError("Index out of range");
|
|
972
|
+
return matching[0];
|
|
1412
973
|
}
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
if (!noAssert) {
|
|
1417
|
-
checkIEEE754(buf, value, offset, 4);
|
|
1418
|
-
}
|
|
1419
|
-
ieee754$1.write(buf, value, offset, littleEndian, 23, 4);
|
|
1420
|
-
return offset + 4;
|
|
1421
|
-
}
|
|
1422
|
-
Buffer2.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
|
|
1423
|
-
return writeFloat(this, value, offset, true, noAssert);
|
|
1424
|
-
};
|
|
1425
|
-
Buffer2.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
|
|
1426
|
-
return writeFloat(this, value, offset, false, noAssert);
|
|
1427
|
-
};
|
|
1428
|
-
function writeDouble(buf, value, offset, littleEndian, noAssert) {
|
|
1429
|
-
value = +value;
|
|
1430
|
-
offset = offset >>> 0;
|
|
1431
|
-
if (!noAssert) {
|
|
1432
|
-
checkIEEE754(buf, value, offset, 8);
|
|
1433
|
-
}
|
|
1434
|
-
ieee754$1.write(buf, value, offset, littleEndian, 52, 8);
|
|
1435
|
-
return offset + 8;
|
|
974
|
+
const result = __privateGet(this, _functions).get(FunctionFragment.from(key).format());
|
|
975
|
+
if (result) {
|
|
976
|
+
return result;
|
|
1436
977
|
}
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
if (!end && end !== 0) end = this.length;
|
|
1447
|
-
if (targetStart >= target.length) targetStart = target.length;
|
|
1448
|
-
if (!targetStart) targetStart = 0;
|
|
1449
|
-
if (end > 0 && end < start) end = start;
|
|
1450
|
-
if (end === start) return 0;
|
|
1451
|
-
if (target.length === 0 || this.length === 0) return 0;
|
|
1452
|
-
if (targetStart < 0) {
|
|
1453
|
-
throw new RangeError("targetStart out of bounds");
|
|
1454
|
-
}
|
|
1455
|
-
if (start < 0 || start >= this.length) throw new RangeError("Index out of range");
|
|
1456
|
-
if (end < 0) throw new RangeError("sourceEnd out of bounds");
|
|
1457
|
-
if (end > this.length) end = this.length;
|
|
1458
|
-
if (target.length - targetStart < end - start) {
|
|
1459
|
-
end = target.length - targetStart + start;
|
|
1460
|
-
}
|
|
1461
|
-
const len = end - start;
|
|
1462
|
-
if (this === target && typeof GlobalUint8Array.prototype.copyWithin === "function") {
|
|
1463
|
-
this.copyWithin(targetStart, start, end);
|
|
1464
|
-
} else {
|
|
1465
|
-
GlobalUint8Array.prototype.set.call(
|
|
1466
|
-
target,
|
|
1467
|
-
this.subarray(start, end),
|
|
1468
|
-
targetStart
|
|
1469
|
-
);
|
|
1470
|
-
}
|
|
1471
|
-
return len;
|
|
1472
|
-
};
|
|
1473
|
-
Buffer2.prototype.fill = function fill(val, start, end, encoding) {
|
|
1474
|
-
if (typeof val === "string") {
|
|
1475
|
-
if (typeof start === "string") {
|
|
1476
|
-
encoding = start;
|
|
1477
|
-
start = 0;
|
|
1478
|
-
end = this.length;
|
|
1479
|
-
} else if (typeof end === "string") {
|
|
1480
|
-
encoding = end;
|
|
1481
|
-
end = this.length;
|
|
1482
|
-
}
|
|
1483
|
-
if (encoding !== void 0 && typeof encoding !== "string") {
|
|
1484
|
-
throw new TypeError("encoding must be a string");
|
|
1485
|
-
}
|
|
1486
|
-
if (typeof encoding === "string" && !Buffer2.isEncoding(encoding)) {
|
|
1487
|
-
throw new TypeError("Unknown encoding: " + encoding);
|
|
1488
|
-
}
|
|
1489
|
-
if (val.length === 1) {
|
|
1490
|
-
const code2 = val.charCodeAt(0);
|
|
1491
|
-
if (encoding === "utf8" && code2 < 128 || encoding === "latin1") {
|
|
1492
|
-
val = code2;
|
|
1493
|
-
}
|
|
1494
|
-
}
|
|
1495
|
-
} else if (typeof val === "number") {
|
|
1496
|
-
val = val & 255;
|
|
1497
|
-
} else if (typeof val === "boolean") {
|
|
1498
|
-
val = Number(val);
|
|
1499
|
-
}
|
|
1500
|
-
if (start < 0 || this.length < start || this.length < end) {
|
|
1501
|
-
throw new RangeError("Out of range index");
|
|
1502
|
-
}
|
|
1503
|
-
if (end <= start) {
|
|
1504
|
-
return this;
|
|
1505
|
-
}
|
|
1506
|
-
start = start >>> 0;
|
|
1507
|
-
end = end === void 0 ? this.length : end >>> 0;
|
|
1508
|
-
if (!val) val = 0;
|
|
1509
|
-
let i;
|
|
1510
|
-
if (typeof val === "number") {
|
|
1511
|
-
for (i = start; i < end; ++i) {
|
|
1512
|
-
this[i] = val;
|
|
1513
|
-
}
|
|
1514
|
-
} else {
|
|
1515
|
-
const bytes = Buffer2.isBuffer(val) ? val : Buffer2.from(val, encoding);
|
|
1516
|
-
const len = bytes.length;
|
|
1517
|
-
if (len === 0) {
|
|
1518
|
-
throw new TypeError('The value "' + val + '" is invalid for argument "value"');
|
|
1519
|
-
}
|
|
1520
|
-
for (i = 0; i < end - start; ++i) {
|
|
1521
|
-
this[i + start] = bytes[i % len];
|
|
978
|
+
return null;
|
|
979
|
+
};
|
|
980
|
+
// Find an event definition by any means necessary (unless it is ambiguous)
|
|
981
|
+
getEvent_fn = function(key, values, forceUnique) {
|
|
982
|
+
if (isHexString(key)) {
|
|
983
|
+
const eventTopic = key.toLowerCase();
|
|
984
|
+
for (const fragment of __privateGet(this, _events).values()) {
|
|
985
|
+
if (eventTopic === fragment.topicHash) {
|
|
986
|
+
return fragment;
|
|
1522
987
|
}
|
|
1523
988
|
}
|
|
1524
|
-
return
|
|
1525
|
-
};
|
|
1526
|
-
const errors = {};
|
|
1527
|
-
function E(sym, getMessage, Base) {
|
|
1528
|
-
errors[sym] = class NodeError extends Base {
|
|
1529
|
-
constructor() {
|
|
1530
|
-
super();
|
|
1531
|
-
Object.defineProperty(this, "message", {
|
|
1532
|
-
value: getMessage.apply(this, arguments),
|
|
1533
|
-
writable: true,
|
|
1534
|
-
configurable: true
|
|
1535
|
-
});
|
|
1536
|
-
this.name = `${this.name} [${sym}]`;
|
|
1537
|
-
this.stack;
|
|
1538
|
-
delete this.name;
|
|
1539
|
-
}
|
|
1540
|
-
get code() {
|
|
1541
|
-
return sym;
|
|
1542
|
-
}
|
|
1543
|
-
set code(value) {
|
|
1544
|
-
Object.defineProperty(this, "code", {
|
|
1545
|
-
configurable: true,
|
|
1546
|
-
enumerable: true,
|
|
1547
|
-
value,
|
|
1548
|
-
writable: true
|
|
1549
|
-
});
|
|
1550
|
-
}
|
|
1551
|
-
toString() {
|
|
1552
|
-
return `${this.name} [${sym}]: ${this.message}`;
|
|
1553
|
-
}
|
|
1554
|
-
};
|
|
989
|
+
return null;
|
|
1555
990
|
}
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
if (name
|
|
1560
|
-
|
|
991
|
+
if (key.indexOf("(") === -1) {
|
|
992
|
+
const matching = [];
|
|
993
|
+
for (const [name, fragment] of __privateGet(this, _events)) {
|
|
994
|
+
if (name.split(
|
|
995
|
+
"("
|
|
996
|
+
/* fix:) */
|
|
997
|
+
)[0] === key) {
|
|
998
|
+
matching.push(fragment);
|
|
1561
999
|
}
|
|
1562
|
-
return "Attempt to access memory outside buffer bounds";
|
|
1563
|
-
},
|
|
1564
|
-
RangeError
|
|
1565
|
-
);
|
|
1566
|
-
E(
|
|
1567
|
-
"ERR_INVALID_ARG_TYPE",
|
|
1568
|
-
function(name, actual) {
|
|
1569
|
-
return `The "${name}" argument must be of type number. Received type ${typeof actual}`;
|
|
1570
|
-
},
|
|
1571
|
-
TypeError
|
|
1572
|
-
);
|
|
1573
|
-
E(
|
|
1574
|
-
"ERR_OUT_OF_RANGE",
|
|
1575
|
-
function(str, range, input) {
|
|
1576
|
-
let msg = `The value of "${str}" is out of range.`;
|
|
1577
|
-
let received = input;
|
|
1578
|
-
if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
|
|
1579
|
-
received = addNumericalSeparator(String(input));
|
|
1580
|
-
} else if (typeof input === "bigint") {
|
|
1581
|
-
received = String(input);
|
|
1582
|
-
if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
|
|
1583
|
-
received = addNumericalSeparator(received);
|
|
1584
|
-
}
|
|
1585
|
-
received += "n";
|
|
1586
|
-
}
|
|
1587
|
-
msg += ` It must be ${range}. Received ${received}`;
|
|
1588
|
-
return msg;
|
|
1589
|
-
},
|
|
1590
|
-
RangeError
|
|
1591
|
-
);
|
|
1592
|
-
function addNumericalSeparator(val) {
|
|
1593
|
-
let res = "";
|
|
1594
|
-
let i = val.length;
|
|
1595
|
-
const start = val[0] === "-" ? 1 : 0;
|
|
1596
|
-
for (; i >= start + 4; i -= 3) {
|
|
1597
|
-
res = `_${val.slice(i - 3, i)}${res}`;
|
|
1598
1000
|
}
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
if (buf[offset] === void 0 || buf[offset + byteLength3] === void 0) {
|
|
1604
|
-
boundsError(offset, buf.length - (byteLength3 + 1));
|
|
1605
|
-
}
|
|
1606
|
-
}
|
|
1607
|
-
function checkIntBI(value, min, max, buf, offset, byteLength3) {
|
|
1608
|
-
if (value > max || value < min) {
|
|
1609
|
-
const n = typeof min === "bigint" ? "n" : "";
|
|
1610
|
-
let range;
|
|
1611
|
-
{
|
|
1612
|
-
if (min === 0 || min === BigInt(0)) {
|
|
1613
|
-
range = `>= 0${n} and < 2${n} ** ${(byteLength3 + 1) * 8}${n}`;
|
|
1614
|
-
} else {
|
|
1615
|
-
range = `>= -(2${n} ** ${(byteLength3 + 1) * 8 - 1}${n}) and < 2 ** ${(byteLength3 + 1) * 8 - 1}${n}`;
|
|
1001
|
+
if (values) {
|
|
1002
|
+
for (let i = matching.length - 1; i >= 0; i--) {
|
|
1003
|
+
if (matching[i].inputs.length < values.length) {
|
|
1004
|
+
matching.splice(i, 1);
|
|
1616
1005
|
}
|
|
1617
1006
|
}
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
function validateNumber(value, name) {
|
|
1623
|
-
if (typeof value !== "number") {
|
|
1624
|
-
throw new errors.ERR_INVALID_ARG_TYPE(name, "number", value);
|
|
1625
|
-
}
|
|
1626
|
-
}
|
|
1627
|
-
function boundsError(value, length, type) {
|
|
1628
|
-
if (Math.floor(value) !== value) {
|
|
1629
|
-
validateNumber(value, type);
|
|
1630
|
-
throw new errors.ERR_OUT_OF_RANGE("offset", "an integer", value);
|
|
1631
|
-
}
|
|
1632
|
-
if (length < 0) {
|
|
1633
|
-
throw new errors.ERR_BUFFER_OUT_OF_BOUNDS();
|
|
1634
|
-
}
|
|
1635
|
-
throw new errors.ERR_OUT_OF_RANGE(
|
|
1636
|
-
"offset",
|
|
1637
|
-
`>= ${0} and <= ${length}`,
|
|
1638
|
-
value
|
|
1639
|
-
);
|
|
1640
|
-
}
|
|
1641
|
-
const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
|
|
1642
|
-
function base64clean(str) {
|
|
1643
|
-
str = str.split("=")[0];
|
|
1644
|
-
str = str.trim().replace(INVALID_BASE64_RE, "");
|
|
1645
|
-
if (str.length < 2) return "";
|
|
1646
|
-
while (str.length % 4 !== 0) {
|
|
1647
|
-
str = str + "=";
|
|
1648
|
-
}
|
|
1649
|
-
return str;
|
|
1650
|
-
}
|
|
1651
|
-
function utf8ToBytes(string, units) {
|
|
1652
|
-
units = units || Infinity;
|
|
1653
|
-
let codePoint;
|
|
1654
|
-
const length = string.length;
|
|
1655
|
-
let leadSurrogate = null;
|
|
1656
|
-
const bytes = [];
|
|
1657
|
-
for (let i = 0; i < length; ++i) {
|
|
1658
|
-
codePoint = string.charCodeAt(i);
|
|
1659
|
-
if (codePoint > 55295 && codePoint < 57344) {
|
|
1660
|
-
if (!leadSurrogate) {
|
|
1661
|
-
if (codePoint > 56319) {
|
|
1662
|
-
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
1663
|
-
continue;
|
|
1664
|
-
} else if (i + 1 === length) {
|
|
1665
|
-
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
1007
|
+
for (let i = matching.length - 1; i >= 0; i--) {
|
|
1008
|
+
const inputs = matching[i].inputs;
|
|
1009
|
+
for (let j = 0; j < values.length; j++) {
|
|
1010
|
+
if (!Typed.isTyped(values[j])) {
|
|
1666
1011
|
continue;
|
|
1667
1012
|
}
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
1673
|
-
leadSurrogate = codePoint;
|
|
1674
|
-
continue;
|
|
1013
|
+
if (values[j].type !== inputs[j].baseType) {
|
|
1014
|
+
matching.splice(i, 1);
|
|
1015
|
+
break;
|
|
1016
|
+
}
|
|
1675
1017
|
}
|
|
1676
|
-
codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
|
|
1677
|
-
} else if (leadSurrogate) {
|
|
1678
|
-
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
1679
|
-
}
|
|
1680
|
-
leadSurrogate = null;
|
|
1681
|
-
if (codePoint < 128) {
|
|
1682
|
-
if ((units -= 1) < 0) break;
|
|
1683
|
-
bytes.push(codePoint);
|
|
1684
|
-
} else if (codePoint < 2048) {
|
|
1685
|
-
if ((units -= 2) < 0) break;
|
|
1686
|
-
bytes.push(
|
|
1687
|
-
codePoint >> 6 | 192,
|
|
1688
|
-
codePoint & 63 | 128
|
|
1689
|
-
);
|
|
1690
|
-
} else if (codePoint < 65536) {
|
|
1691
|
-
if ((units -= 3) < 0) break;
|
|
1692
|
-
bytes.push(
|
|
1693
|
-
codePoint >> 12 | 224,
|
|
1694
|
-
codePoint >> 6 & 63 | 128,
|
|
1695
|
-
codePoint & 63 | 128
|
|
1696
|
-
);
|
|
1697
|
-
} else if (codePoint < 1114112) {
|
|
1698
|
-
if ((units -= 4) < 0) break;
|
|
1699
|
-
bytes.push(
|
|
1700
|
-
codePoint >> 18 | 240,
|
|
1701
|
-
codePoint >> 12 & 63 | 128,
|
|
1702
|
-
codePoint >> 6 & 63 | 128,
|
|
1703
|
-
codePoint & 63 | 128
|
|
1704
|
-
);
|
|
1705
|
-
} else {
|
|
1706
|
-
throw new Error("Invalid code point");
|
|
1707
1018
|
}
|
|
1708
1019
|
}
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
function asciiToBytes(str) {
|
|
1712
|
-
const byteArray = [];
|
|
1713
|
-
for (let i = 0; i < str.length; ++i) {
|
|
1714
|
-
byteArray.push(str.charCodeAt(i) & 255);
|
|
1715
|
-
}
|
|
1716
|
-
return byteArray;
|
|
1717
|
-
}
|
|
1718
|
-
function utf16leToBytes(str, units) {
|
|
1719
|
-
let c, hi, lo;
|
|
1720
|
-
const byteArray = [];
|
|
1721
|
-
for (let i = 0; i < str.length; ++i) {
|
|
1722
|
-
if ((units -= 2) < 0) break;
|
|
1723
|
-
c = str.charCodeAt(i);
|
|
1724
|
-
hi = c >> 8;
|
|
1725
|
-
lo = c % 256;
|
|
1726
|
-
byteArray.push(lo);
|
|
1727
|
-
byteArray.push(hi);
|
|
1728
|
-
}
|
|
1729
|
-
return byteArray;
|
|
1730
|
-
}
|
|
1731
|
-
function base64ToBytes(str) {
|
|
1732
|
-
return base64.toByteArray(base64clean(str));
|
|
1733
|
-
}
|
|
1734
|
-
function blitBuffer(src, dst, offset, length) {
|
|
1735
|
-
let i;
|
|
1736
|
-
for (i = 0; i < length; ++i) {
|
|
1737
|
-
if (i + offset >= dst.length || i >= src.length) break;
|
|
1738
|
-
dst[i + offset] = src[i];
|
|
1020
|
+
if (matching.length === 0) {
|
|
1021
|
+
return null;
|
|
1739
1022
|
}
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name;
|
|
1744
|
-
}
|
|
1745
|
-
function numberIsNaN(obj) {
|
|
1746
|
-
return obj !== obj;
|
|
1747
|
-
}
|
|
1748
|
-
const hexSliceLookupTable = function() {
|
|
1749
|
-
const alphabet = "0123456789abcdef";
|
|
1750
|
-
const table = new Array(256);
|
|
1751
|
-
for (let i = 0; i < 16; ++i) {
|
|
1752
|
-
const i16 = i * 16;
|
|
1753
|
-
for (let j = 0; j < 16; ++j) {
|
|
1754
|
-
table[i16 + j] = alphabet[i] + alphabet[j];
|
|
1755
|
-
}
|
|
1023
|
+
if (matching.length > 1 && forceUnique) {
|
|
1024
|
+
const matchStr = matching.map((m) => JSON.stringify(m.format())).join(", ");
|
|
1025
|
+
assertArgument(false, `ambiguous event description (i.e. matches ${matchStr})`, "key", key);
|
|
1756
1026
|
}
|
|
1757
|
-
return
|
|
1758
|
-
}();
|
|
1759
|
-
function defineBigIntMethod(fn) {
|
|
1760
|
-
return typeof BigInt === "undefined" ? BufferBigIntNotDefined : fn;
|
|
1027
|
+
return matching[0];
|
|
1761
1028
|
}
|
|
1762
|
-
|
|
1763
|
-
|
|
1029
|
+
const result = __privateGet(this, _events).get(EventFragment.from(key).format());
|
|
1030
|
+
if (result) {
|
|
1031
|
+
return result;
|
|
1764
1032
|
}
|
|
1765
|
-
|
|
1766
|
-
|
|
1033
|
+
return null;
|
|
1034
|
+
};
|
|
1035
|
+
let Interface = _Interface;
|
|
1767
1036
|
export {
|
|
1768
|
-
|
|
1037
|
+
ErrorDescription,
|
|
1038
|
+
Indexed,
|
|
1039
|
+
Interface,
|
|
1040
|
+
LogDescription,
|
|
1041
|
+
Result,
|
|
1042
|
+
TransactionDescription
|
|
1769
1043
|
};
|
|
1770
1044
|
//# sourceMappingURL=standards-sdk.es23.js.map
|