@hashgraphonline/standards-sdk 0.0.75 → 0.0.76
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/standards-sdk.es100.js +31 -3
- package/dist/es/standards-sdk.es100.js.map +1 -1
- package/dist/es/standards-sdk.es101.js +14 -3
- package/dist/es/standards-sdk.es101.js.map +1 -1
- package/dist/es/standards-sdk.es102.js +4 -13
- package/dist/es/standards-sdk.es102.js.map +1 -1
- package/dist/es/standards-sdk.es103.js +4 -13
- package/dist/es/standards-sdk.es103.js.map +1 -1
- package/dist/es/standards-sdk.es110.js +1 -1
- package/dist/es/standards-sdk.es12.js +3 -3
- package/dist/es/standards-sdk.es14.js +1 -1
- package/dist/es/standards-sdk.es17.js +2 -2
- package/dist/es/standards-sdk.es18.js +3 -3
- package/dist/es/standards-sdk.es21.js +1692 -966
- package/dist/es/standards-sdk.es21.js.map +1 -1
- package/dist/es/standards-sdk.es22.js +3 -5
- package/dist/es/standards-sdk.es22.js.map +1 -1
- package/dist/es/standards-sdk.es23.js +4103 -1703
- package/dist/es/standards-sdk.es23.js.map +1 -1
- package/dist/es/standards-sdk.es24.js +941 -7090
- package/dist/es/standards-sdk.es24.js.map +1 -1
- package/dist/es/standards-sdk.es25.js +5 -36
- package/dist/es/standards-sdk.es25.js.map +1 -1
- package/dist/es/standards-sdk.es26.js +36 -48
- package/dist/es/standards-sdk.es26.js.map +1 -1
- package/dist/es/standards-sdk.es27.js +48 -3
- package/dist/es/standards-sdk.es27.js.map +1 -1
- package/dist/es/standards-sdk.es28.js +7190 -2
- package/dist/es/standards-sdk.es28.js.map +1 -1
- package/dist/es/standards-sdk.es29.js +2 -4167
- package/dist/es/standards-sdk.es29.js.map +1 -1
- package/dist/es/standards-sdk.es35.js +96 -79
- package/dist/es/standards-sdk.es35.js.map +1 -1
- package/dist/es/standards-sdk.es36.js +2 -23
- package/dist/es/standards-sdk.es36.js.map +1 -1
- package/dist/es/standards-sdk.es37.js +15 -147
- package/dist/es/standards-sdk.es37.js.map +1 -1
- package/dist/es/standards-sdk.es38.js +403 -85
- package/dist/es/standards-sdk.es38.js.map +1 -1
- package/dist/es/standards-sdk.es39.js +79 -7131
- 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 +18 -190
- package/dist/es/standards-sdk.es40.js.map +1 -1
- package/dist/es/standards-sdk.es41.js +127 -417
- package/dist/es/standards-sdk.es41.js.map +1 -1
- package/dist/es/standards-sdk.es42.js +87 -21
- package/dist/es/standards-sdk.es42.js.map +1 -1
- package/dist/es/standards-sdk.es43.js +161 -126
- package/dist/es/standards-sdk.es43.js.map +1 -1
- package/dist/es/standards-sdk.es44.js +5 -17
- package/dist/es/standards-sdk.es44.js.map +1 -1
- package/dist/es/standards-sdk.es45.js +136 -22
- package/dist/es/standards-sdk.es45.js.map +1 -1
- package/dist/es/standards-sdk.es46.js +191 -25
- package/dist/es/standards-sdk.es46.js.map +1 -1
- package/dist/es/standards-sdk.es47.js +432 -15
- package/dist/es/standards-sdk.es47.js.map +1 -1
- package/dist/es/standards-sdk.es48.js +15 -34
- package/dist/es/standards-sdk.es48.js.map +1 -1
- package/dist/es/standards-sdk.es49.js +131 -10
- package/dist/es/standards-sdk.es49.js.map +1 -1
- package/dist/es/standards-sdk.es5.js +3 -3
- package/dist/es/standards-sdk.es50.js +10 -53
- package/dist/es/standards-sdk.es50.js.map +1 -1
- package/dist/es/standards-sdk.es51.js +21 -1281
- package/dist/es/standards-sdk.es51.js.map +1 -1
- package/dist/es/standards-sdk.es52.js +25 -28
- package/dist/es/standards-sdk.es52.js.map +1 -1
- package/dist/es/standards-sdk.es53.js +20 -5
- package/dist/es/standards-sdk.es53.js.map +1 -1
- package/dist/es/standards-sdk.es54.js +36 -151
- package/dist/es/standards-sdk.es54.js.map +1 -1
- package/dist/es/standards-sdk.es55.js +13 -788
- package/dist/es/standards-sdk.es55.js.map +1 -1
- package/dist/es/standards-sdk.es56.js +55 -168
- package/dist/es/standards-sdk.es56.js.map +1 -1
- package/dist/es/standards-sdk.es57.js +1262 -116
- package/dist/es/standards-sdk.es57.js.map +1 -1
- package/dist/es/standards-sdk.es58.js +32 -3
- package/dist/es/standards-sdk.es58.js.map +1 -1
- package/dist/es/standards-sdk.es59.js +154 -16
- package/dist/es/standards-sdk.es59.js.map +1 -1
- package/dist/es/standards-sdk.es60.js +790 -24
- package/dist/es/standards-sdk.es60.js.map +1 -1
- package/dist/es/standards-sdk.es61.js +2282 -26
- package/dist/es/standards-sdk.es61.js.map +1 -1
- package/dist/es/standards-sdk.es62.js +163 -37
- package/dist/es/standards-sdk.es62.js.map +1 -1
- package/dist/es/standards-sdk.es63.js +26 -100
- package/dist/es/standards-sdk.es63.js.map +1 -1
- package/dist/es/standards-sdk.es64.js +26 -2
- package/dist/es/standards-sdk.es64.js.map +1 -1
- package/dist/es/standards-sdk.es65.js +37 -15
- package/dist/es/standards-sdk.es65.js.map +1 -1
- package/dist/es/standards-sdk.es66.js +17 -405
- package/dist/es/standards-sdk.es66.js.map +1 -1
- package/dist/es/standards-sdk.es67.js +2 -2
- package/dist/es/standards-sdk.es7.js +3 -3
- package/dist/es/standards-sdk.es77.js +1 -1
- package/dist/es/standards-sdk.es8.js +3 -3
- package/dist/es/standards-sdk.es84.js +3 -2282
- package/dist/es/standards-sdk.es84.js.map +1 -1
- package/dist/es/standards-sdk.es85.js +7102 -130
- package/dist/es/standards-sdk.es85.js.map +1 -1
- package/dist/es/standards-sdk.es86.js +1 -1
- package/dist/es/standards-sdk.es88.js +1 -1
- package/dist/es/standards-sdk.es89.js +2 -2
- package/dist/es/standards-sdk.es9.js +1 -1
- package/dist/es/standards-sdk.es93.js +2 -2
- package/dist/es/standards-sdk.es98.js +12 -31
- package/dist/es/standards-sdk.es98.js.map +1 -1
- package/dist/es/standards-sdk.es99.js +13 -15
- package/dist/es/standards-sdk.es99.js.map +1 -1
- package/dist/umd/standards-sdk.umd.js +5 -5
- package/dist/umd/standards-sdk.umd.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,1044 +1,1770 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
import { isHexString, dataSlice, concat, getBytesCopy, hexlify, getBytes, zeroPadBytes, zeroPadValue } from "./standards-sdk.es38.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
|
-
});
|
|
1
|
+
var buffer = {};
|
|
2
|
+
var base64Js = {};
|
|
3
|
+
base64Js.byteLength = byteLength;
|
|
4
|
+
base64Js.toByteArray = toByteArray;
|
|
5
|
+
base64Js.fromByteArray = fromByteArray;
|
|
6
|
+
var lookup = [];
|
|
7
|
+
var revLookup = [];
|
|
8
|
+
var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
|
|
9
|
+
var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
10
|
+
for (var i = 0, len = code.length; i < len; ++i) {
|
|
11
|
+
lookup[i] = code[i];
|
|
12
|
+
revLookup[code.charCodeAt(i)] = i;
|
|
13
|
+
}
|
|
14
|
+
revLookup["-".charCodeAt(0)] = 62;
|
|
15
|
+
revLookup["_".charCodeAt(0)] = 63;
|
|
16
|
+
function getLens(b64) {
|
|
17
|
+
var len = b64.length;
|
|
18
|
+
if (len % 4 > 0) {
|
|
19
|
+
throw new Error("Invalid string. Length must be a multiple of 4");
|
|
56
20
|
}
|
|
21
|
+
var validLen = b64.indexOf("=");
|
|
22
|
+
if (validLen === -1) validLen = len;
|
|
23
|
+
var placeHoldersLen = validLen === len ? 0 : 4 - validLen % 4;
|
|
24
|
+
return [validLen, placeHoldersLen];
|
|
57
25
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
});
|
|
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
|
+
}
|
|
32
|
+
function _byteLength(b64, validLen, placeHoldersLen) {
|
|
33
|
+
return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
|
|
34
|
+
}
|
|
35
|
+
function toByteArray(b64) {
|
|
36
|
+
var tmp;
|
|
37
|
+
var lens = getLens(b64);
|
|
38
|
+
var validLen = lens[0];
|
|
39
|
+
var placeHoldersLen = lens[1];
|
|
40
|
+
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
|
|
41
|
+
var curByte = 0;
|
|
42
|
+
var len = placeHoldersLen > 0 ? validLen - 4 : validLen;
|
|
43
|
+
var i;
|
|
44
|
+
for (i = 0; i < len; i += 4) {
|
|
45
|
+
tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)];
|
|
46
|
+
arr[curByte++] = tmp >> 16 & 255;
|
|
47
|
+
arr[curByte++] = tmp >> 8 & 255;
|
|
48
|
+
arr[curByte++] = tmp & 255;
|
|
96
49
|
}
|
|
50
|
+
if (placeHoldersLen === 2) {
|
|
51
|
+
tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4;
|
|
52
|
+
arr[curByte++] = tmp & 255;
|
|
53
|
+
}
|
|
54
|
+
if (placeHoldersLen === 1) {
|
|
55
|
+
tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2;
|
|
56
|
+
arr[curByte++] = tmp >> 8 & 255;
|
|
57
|
+
arr[curByte++] = tmp & 255;
|
|
58
|
+
}
|
|
59
|
+
return arr;
|
|
97
60
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
});
|
|
61
|
+
function tripletToBase64(num) {
|
|
62
|
+
return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
|
|
63
|
+
}
|
|
64
|
+
function encodeChunk(uint8, start, end) {
|
|
65
|
+
var tmp;
|
|
66
|
+
var output = [];
|
|
67
|
+
for (var i = start; i < end; i += 3) {
|
|
68
|
+
tmp = (uint8[i] << 16 & 16711680) + (uint8[i + 1] << 8 & 65280) + (uint8[i + 2] & 255);
|
|
69
|
+
output.push(tripletToBase64(tmp));
|
|
131
70
|
}
|
|
71
|
+
return output.join("");
|
|
132
72
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
*/
|
|
153
|
-
static isIndexed(value) {
|
|
154
|
-
return !!(value && value._isIndexed);
|
|
73
|
+
function fromByteArray(uint8) {
|
|
74
|
+
var tmp;
|
|
75
|
+
var len = uint8.length;
|
|
76
|
+
var extraBytes = len % 3;
|
|
77
|
+
var parts = [];
|
|
78
|
+
var maxChunkLength = 16383;
|
|
79
|
+
for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
|
|
80
|
+
parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength));
|
|
81
|
+
}
|
|
82
|
+
if (extraBytes === 1) {
|
|
83
|
+
tmp = uint8[len - 1];
|
|
84
|
+
parts.push(
|
|
85
|
+
lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "=="
|
|
86
|
+
);
|
|
87
|
+
} else if (extraBytes === 2) {
|
|
88
|
+
tmp = (uint8[len - 2] << 8) + uint8[len - 1];
|
|
89
|
+
parts.push(
|
|
90
|
+
lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "="
|
|
91
|
+
);
|
|
155
92
|
}
|
|
93
|
+
return parts.join("");
|
|
156
94
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
95
|
+
var ieee754 = {};
|
|
96
|
+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
97
|
+
ieee754.read = function(buffer2, offset, isLE, mLen, nBytes) {
|
|
98
|
+
var e, m;
|
|
99
|
+
var eLen = nBytes * 8 - mLen - 1;
|
|
100
|
+
var eMax = (1 << eLen) - 1;
|
|
101
|
+
var eBias = eMax >> 1;
|
|
102
|
+
var nBits = -7;
|
|
103
|
+
var i = isLE ? nBytes - 1 : 0;
|
|
104
|
+
var d = isLE ? -1 : 1;
|
|
105
|
+
var s = buffer2[offset + i];
|
|
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);
|
|
168
126
|
};
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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;
|
|
188
164
|
}
|
|
189
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;
|
|
190
173
|
};
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
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);
|
|
233
|
-
}
|
|
174
|
+
/*!
|
|
175
|
+
* The buffer module from node.js, for the browser.
|
|
176
|
+
*
|
|
177
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
178
|
+
* @license MIT
|
|
179
|
+
*/
|
|
180
|
+
(function(exports) {
|
|
181
|
+
const base64 = base64Js;
|
|
182
|
+
const ieee754$1 = ieee754;
|
|
183
|
+
const customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null;
|
|
184
|
+
exports.Buffer = Buffer2;
|
|
185
|
+
exports.SlowBuffer = SlowBuffer;
|
|
186
|
+
exports.INSPECT_MAX_BYTES = 50;
|
|
187
|
+
const K_MAX_LENGTH = 2147483647;
|
|
188
|
+
exports.kMaxLength = K_MAX_LENGTH;
|
|
189
|
+
const { Uint8Array: GlobalUint8Array, ArrayBuffer: GlobalArrayBuffer, SharedArrayBuffer: GlobalSharedArrayBuffer } = globalThis;
|
|
190
|
+
Buffer2.TYPED_ARRAY_SUPPORT = typedArraySupport();
|
|
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;
|
|
234
207
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
bucket = __privateGet(this, _events);
|
|
265
|
-
break;
|
|
266
|
-
case "error":
|
|
267
|
-
bucket = __privateGet(this, _errors);
|
|
268
|
-
break;
|
|
269
|
-
default:
|
|
270
|
-
return;
|
|
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
|
+
);
|
|
271
237
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
238
|
+
return allocUnsafe(arg);
|
|
239
|
+
}
|
|
240
|
+
return from(arg, encodingOrOffset, length);
|
|
241
|
+
}
|
|
242
|
+
Buffer2.poolSize = 8192;
|
|
243
|
+
function from(value, encodingOrOffset, length) {
|
|
244
|
+
if (typeof value === "string") {
|
|
245
|
+
return fromString(value, encodingOrOffset);
|
|
246
|
+
}
|
|
247
|
+
if (GlobalArrayBuffer.isView(value)) {
|
|
248
|
+
return fromArrayView(value);
|
|
249
|
+
}
|
|
250
|
+
if (value == null) {
|
|
251
|
+
throw new TypeError(
|
|
252
|
+
"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
if (isInstance(value, GlobalArrayBuffer) || value && isInstance(value.buffer, GlobalArrayBuffer)) {
|
|
256
|
+
return fromArrayBuffer(value, encodingOrOffset, length);
|
|
257
|
+
}
|
|
258
|
+
if (typeof GlobalSharedArrayBuffer !== "undefined" && (isInstance(value, GlobalSharedArrayBuffer) || value && isInstance(value.buffer, GlobalSharedArrayBuffer))) {
|
|
259
|
+
return fromArrayBuffer(value, encodingOrOffset, length);
|
|
260
|
+
}
|
|
261
|
+
if (typeof value === "number") {
|
|
262
|
+
throw new TypeError(
|
|
263
|
+
'The "value" argument must not be of type number. Received type number'
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
const valueOf = value.valueOf && value.valueOf();
|
|
267
|
+
if (valueOf != null && valueOf !== value) {
|
|
268
|
+
return Buffer2.from(valueOf, encodingOrOffset, length);
|
|
269
|
+
}
|
|
270
|
+
const b = fromObject(value);
|
|
271
|
+
if (b) return b;
|
|
272
|
+
if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") {
|
|
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);
|
|
356
|
+
} else {
|
|
357
|
+
buf = new GlobalUint8Array(array, byteOffset, length);
|
|
358
|
+
}
|
|
359
|
+
Object.setPrototypeOf(buf, Buffer2.prototype);
|
|
360
|
+
return buf;
|
|
361
|
+
}
|
|
362
|
+
function fromObject(obj) {
|
|
363
|
+
if (Buffer2.isBuffer(obj)) {
|
|
364
|
+
const len = checked(obj.length) | 0;
|
|
365
|
+
const buf = createBuffer(len);
|
|
366
|
+
if (buf.length === 0) {
|
|
367
|
+
return buf;
|
|
275
368
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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);
|
|
369
|
+
obj.copy(buf, 0, 0, len);
|
|
370
|
+
return buf;
|
|
371
|
+
}
|
|
372
|
+
if (obj.length !== void 0) {
|
|
373
|
+
if (typeof obj.length !== "number" || numberIsNaN(obj.length)) {
|
|
374
|
+
return createBuffer(0);
|
|
411
375
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
376
|
+
return fromArrayLike(obj);
|
|
377
|
+
}
|
|
378
|
+
if (obj.type === "Buffer" && Array.isArray(obj.data)) {
|
|
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;
|
|
416
413
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
if (
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
414
|
+
}
|
|
415
|
+
if (x < y) return -1;
|
|
416
|
+
if (y < x) return 1;
|
|
417
|
+
return 0;
|
|
418
|
+
};
|
|
419
|
+
Buffer2.isEncoding = function isEncoding(encoding) {
|
|
420
|
+
switch (String(encoding).toLowerCase()) {
|
|
421
|
+
case "hex":
|
|
422
|
+
case "utf8":
|
|
423
|
+
case "utf-8":
|
|
424
|
+
case "ascii":
|
|
425
|
+
case "latin1":
|
|
426
|
+
case "binary":
|
|
427
|
+
case "base64":
|
|
428
|
+
case "ucs2":
|
|
429
|
+
case "ucs-2":
|
|
430
|
+
case "utf16le":
|
|
431
|
+
case "utf-16le":
|
|
432
|
+
return true;
|
|
433
|
+
default:
|
|
434
|
+
return false;
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
Buffer2.concat = function concat(list, length) {
|
|
438
|
+
if (!Array.isArray(list)) {
|
|
439
|
+
throw new TypeError('"list" argument must be an Array of Buffers');
|
|
440
|
+
}
|
|
441
|
+
if (list.length === 0) {
|
|
442
|
+
return Buffer2.alloc(0);
|
|
443
|
+
}
|
|
444
|
+
let i;
|
|
445
|
+
if (length === void 0) {
|
|
446
|
+
length = 0;
|
|
447
|
+
for (i = 0; i < list.length; ++i) {
|
|
448
|
+
length += list[i].length;
|
|
428
449
|
}
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
450
|
+
}
|
|
451
|
+
const buffer2 = Buffer2.allocUnsafe(length);
|
|
452
|
+
let pos = 0;
|
|
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
|
+
);
|
|
435
465
|
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
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);
|
|
440
470
|
}
|
|
441
|
-
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
471
|
+
pos += buf.length;
|
|
472
|
+
}
|
|
473
|
+
return buffer2;
|
|
474
|
+
};
|
|
475
|
+
function byteLength2(string, encoding) {
|
|
476
|
+
if (Buffer2.isBuffer(string)) {
|
|
477
|
+
return string.length;
|
|
478
|
+
}
|
|
479
|
+
if (GlobalArrayBuffer.isView(string) || isInstance(string, GlobalArrayBuffer)) {
|
|
480
|
+
return string.byteLength;
|
|
481
|
+
}
|
|
482
|
+
if (typeof string !== "string") {
|
|
483
|
+
throw new TypeError(
|
|
484
|
+
'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof string
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
const len = string.length;
|
|
488
|
+
const mustMatch = arguments.length > 2 && arguments[2] === true;
|
|
489
|
+
if (!mustMatch && len === 0) return 0;
|
|
490
|
+
let loweredCase = false;
|
|
491
|
+
for (; ; ) {
|
|
492
|
+
switch (encoding) {
|
|
493
|
+
case "ascii":
|
|
494
|
+
case "latin1":
|
|
495
|
+
case "binary":
|
|
496
|
+
return len;
|
|
497
|
+
case "utf8":
|
|
498
|
+
case "utf-8":
|
|
499
|
+
return utf8ToBytes(string).length;
|
|
500
|
+
case "ucs2":
|
|
501
|
+
case "ucs-2":
|
|
502
|
+
case "utf16le":
|
|
503
|
+
case "utf-16le":
|
|
504
|
+
return len * 2;
|
|
505
|
+
case "hex":
|
|
506
|
+
return len >>> 1;
|
|
507
|
+
case "base64":
|
|
508
|
+
return base64ToBytes(string).length;
|
|
509
|
+
default:
|
|
510
|
+
if (loweredCase) {
|
|
511
|
+
return mustMatch ? -1 : utf8ToBytes(string).length;
|
|
480
512
|
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
}
|
|
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";
|
|
513
|
+
encoding = ("" + encoding).toLowerCase();
|
|
514
|
+
loweredCase = true;
|
|
600
515
|
}
|
|
601
516
|
}
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
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
|
-
}
|
|
627
|
-
}
|
|
517
|
+
}
|
|
518
|
+
Buffer2.byteLength = byteLength2;
|
|
519
|
+
function slowToString(encoding, start, end) {
|
|
520
|
+
let loweredCase = false;
|
|
521
|
+
if (start === void 0 || start < 0) {
|
|
522
|
+
start = 0;
|
|
628
523
|
}
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
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]);
|
|
524
|
+
if (start > this.length) {
|
|
525
|
+
return "";
|
|
526
|
+
}
|
|
527
|
+
if (end === void 0 || end > this.length) {
|
|
528
|
+
end = this.length;
|
|
529
|
+
}
|
|
530
|
+
if (end <= 0) {
|
|
531
|
+
return "";
|
|
532
|
+
}
|
|
533
|
+
end >>>= 0;
|
|
534
|
+
start >>>= 0;
|
|
535
|
+
if (end <= start) {
|
|
536
|
+
return "";
|
|
537
|
+
}
|
|
538
|
+
if (!encoding) encoding = "utf8";
|
|
539
|
+
while (true) {
|
|
540
|
+
switch (encoding) {
|
|
541
|
+
case "hex":
|
|
542
|
+
return hexSlice(this, start, end);
|
|
543
|
+
case "utf8":
|
|
544
|
+
case "utf-8":
|
|
545
|
+
return utf8Slice(this, start, end);
|
|
546
|
+
case "ascii":
|
|
547
|
+
return asciiSlice(this, start, end);
|
|
548
|
+
case "latin1":
|
|
549
|
+
case "binary":
|
|
550
|
+
return latin1Slice(this, start, end);
|
|
551
|
+
case "base64":
|
|
552
|
+
return base64Slice(this, start, end);
|
|
553
|
+
case "ucs2":
|
|
554
|
+
case "ucs-2":
|
|
555
|
+
case "utf16le":
|
|
556
|
+
case "utf-16le":
|
|
557
|
+
return utf16leSlice(this, start, end);
|
|
558
|
+
default:
|
|
559
|
+
if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
|
|
560
|
+
encoding = (encoding + "").toLowerCase();
|
|
561
|
+
loweredCase = true;
|
|
711
562
|
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
Buffer2.prototype._isBuffer = true;
|
|
566
|
+
function swap(b, n, m) {
|
|
567
|
+
const i = b[n];
|
|
568
|
+
b[n] = b[m];
|
|
569
|
+
b[m] = i;
|
|
570
|
+
}
|
|
571
|
+
Buffer2.prototype.swap16 = function swap16() {
|
|
572
|
+
const len = this.length;
|
|
573
|
+
if (len % 2 !== 0) {
|
|
574
|
+
throw new RangeError("Buffer size must be a multiple of 16-bits");
|
|
575
|
+
}
|
|
576
|
+
for (let i = 0; i < len; i += 2) {
|
|
577
|
+
swap(this, i, i + 1);
|
|
578
|
+
}
|
|
579
|
+
return this;
|
|
580
|
+
};
|
|
581
|
+
Buffer2.prototype.swap32 = function swap32() {
|
|
582
|
+
const len = this.length;
|
|
583
|
+
if (len % 4 !== 0) {
|
|
584
|
+
throw new RangeError("Buffer size must be a multiple of 32-bits");
|
|
585
|
+
}
|
|
586
|
+
for (let i = 0; i < len; i += 4) {
|
|
587
|
+
swap(this, i, i + 3);
|
|
588
|
+
swap(this, i + 1, i + 2);
|
|
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;
|
|
719
675
|
}
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
676
|
+
}
|
|
677
|
+
if (x < y) return -1;
|
|
678
|
+
if (y < x) return 1;
|
|
679
|
+
return 0;
|
|
680
|
+
};
|
|
681
|
+
function bidirectionalIndexOf(buffer2, val, byteOffset, encoding, dir) {
|
|
682
|
+
if (buffer2.length === 0) return -1;
|
|
683
|
+
if (typeof byteOffset === "string") {
|
|
684
|
+
encoding = byteOffset;
|
|
685
|
+
byteOffset = 0;
|
|
686
|
+
} else if (byteOffset > 2147483647) {
|
|
687
|
+
byteOffset = 2147483647;
|
|
688
|
+
} else if (byteOffset < -2147483648) {
|
|
689
|
+
byteOffset = -2147483648;
|
|
690
|
+
}
|
|
691
|
+
byteOffset = +byteOffset;
|
|
692
|
+
if (numberIsNaN(byteOffset)) {
|
|
693
|
+
byteOffset = dir ? 0 : buffer2.length - 1;
|
|
694
|
+
}
|
|
695
|
+
if (byteOffset < 0) byteOffset = buffer2.length + byteOffset;
|
|
696
|
+
if (byteOffset >= buffer2.length) {
|
|
697
|
+
if (dir) return -1;
|
|
698
|
+
else byteOffset = buffer2.length - 1;
|
|
699
|
+
} else if (byteOffset < 0) {
|
|
700
|
+
if (dir) byteOffset = 0;
|
|
701
|
+
else return -1;
|
|
702
|
+
}
|
|
703
|
+
if (typeof val === "string") {
|
|
704
|
+
val = Buffer2.from(val, encoding);
|
|
705
|
+
}
|
|
706
|
+
if (Buffer2.isBuffer(val)) {
|
|
707
|
+
if (val.length === 0) {
|
|
708
|
+
return -1;
|
|
728
709
|
}
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
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");
|
|
710
|
+
return arrayIndexOf(buffer2, val, byteOffset, encoding, dir);
|
|
711
|
+
} else if (typeof val === "number") {
|
|
712
|
+
val = val & 255;
|
|
713
|
+
if (typeof GlobalUint8Array.prototype.indexOf === "function") {
|
|
714
|
+
if (dir) {
|
|
715
|
+
return GlobalUint8Array.prototype.indexOf.call(buffer2, val, byteOffset);
|
|
757
716
|
} else {
|
|
758
|
-
|
|
717
|
+
return GlobalUint8Array.prototype.lastIndexOf.call(buffer2, val, byteOffset);
|
|
759
718
|
}
|
|
760
|
-
} else {
|
|
761
|
-
dataTypes.push(param);
|
|
762
|
-
dataValues.push(value);
|
|
763
719
|
}
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
topics
|
|
768
|
-
};
|
|
720
|
+
return arrayIndexOf(buffer2, [val], byteOffset, encoding, dir);
|
|
721
|
+
}
|
|
722
|
+
throw new TypeError("val must be string, number or Buffer");
|
|
769
723
|
}
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
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);
|
|
724
|
+
function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
|
|
725
|
+
let indexSize = 1;
|
|
726
|
+
let arrLength = arr.length;
|
|
727
|
+
let valLength = val.length;
|
|
728
|
+
if (encoding !== void 0) {
|
|
729
|
+
encoding = String(encoding).toLowerCase();
|
|
730
|
+
if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
|
|
731
|
+
if (arr.length < 2 || val.length < 2) {
|
|
732
|
+
return -1;
|
|
793
733
|
}
|
|
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];
|
|
794
743
|
} else {
|
|
795
|
-
|
|
796
|
-
dynamic.push(false);
|
|
744
|
+
return buf.readUInt16BE(i2 * indexSize);
|
|
797
745
|
}
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
if (param.indexed) {
|
|
807
|
-
if (resultIndexed == null) {
|
|
808
|
-
value = new Indexed(null);
|
|
809
|
-
} else if (dynamic[index]) {
|
|
810
|
-
value = new Indexed(resultIndexed[indexedIndex++]);
|
|
746
|
+
}
|
|
747
|
+
let i;
|
|
748
|
+
if (dir) {
|
|
749
|
+
let foundIndex = -1;
|
|
750
|
+
for (i = byteOffset; i < arrLength; i++) {
|
|
751
|
+
if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
|
|
752
|
+
if (foundIndex === -1) foundIndex = i;
|
|
753
|
+
if (i - foundIndex + 1 === valLength) return foundIndex * indexSize;
|
|
811
754
|
} else {
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
} catch (error) {
|
|
815
|
-
value = error;
|
|
816
|
-
}
|
|
755
|
+
if (foundIndex !== -1) i -= i - foundIndex;
|
|
756
|
+
foundIndex = -1;
|
|
817
757
|
}
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
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;
|
|
767
|
+
}
|
|
823
768
|
}
|
|
769
|
+
if (found) return i;
|
|
824
770
|
}
|
|
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;
|
|
886
771
|
}
|
|
887
|
-
|
|
888
|
-
|
|
772
|
+
return -1;
|
|
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
|
+
}
|
|
889
793
|
}
|
|
890
|
-
|
|
891
|
-
|
|
794
|
+
const strLen = string.length;
|
|
795
|
+
if (length > strLen / 2) {
|
|
796
|
+
length = strLen / 2;
|
|
892
797
|
}
|
|
893
|
-
|
|
894
|
-
|
|
798
|
+
let i;
|
|
799
|
+
for (i = 0; i < length; ++i) {
|
|
800
|
+
const parsed = parseInt(string.substr(i * 2, 2), 16);
|
|
801
|
+
if (numberIsNaN(parsed)) return i;
|
|
802
|
+
buf[offset + i] = parsed;
|
|
895
803
|
}
|
|
896
|
-
return
|
|
804
|
+
return i;
|
|
897
805
|
}
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
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;
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
return null;
|
|
806
|
+
function utf8Write(buf, string, offset, length) {
|
|
807
|
+
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
|
|
808
|
+
}
|
|
809
|
+
function asciiWrite(buf, string, offset, length) {
|
|
810
|
+
return blitBuffer(asciiToBytes(string), buf, offset, length);
|
|
811
|
+
}
|
|
812
|
+
function base64Write(buf, string, offset, length) {
|
|
813
|
+
return blitBuffer(base64ToBytes(string), buf, offset, length);
|
|
914
814
|
}
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
815
|
+
function ucs2Write(buf, string, offset, length) {
|
|
816
|
+
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
|
|
817
|
+
}
|
|
818
|
+
Buffer2.prototype.write = function write(string, offset, length, encoding) {
|
|
819
|
+
if (offset === void 0) {
|
|
820
|
+
encoding = "utf8";
|
|
821
|
+
length = this.length;
|
|
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;
|
|
923
835
|
}
|
|
836
|
+
} else {
|
|
837
|
+
throw new Error(
|
|
838
|
+
"Buffer.write(string, encoding, offset[, length]) is no longer supported"
|
|
839
|
+
);
|
|
924
840
|
}
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
841
|
+
const remaining = this.length - offset;
|
|
842
|
+
if (length === void 0 || length > remaining) length = remaining;
|
|
843
|
+
if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) {
|
|
844
|
+
throw new RangeError("Attempt to write outside buffer bounds");
|
|
845
|
+
}
|
|
846
|
+
if (!encoding) encoding = "utf8";
|
|
847
|
+
let loweredCase = false;
|
|
848
|
+
for (; ; ) {
|
|
849
|
+
switch (encoding) {
|
|
850
|
+
case "hex":
|
|
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;
|
|
938
870
|
}
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
871
|
+
}
|
|
872
|
+
};
|
|
873
|
+
Buffer2.prototype.toJSON = function toJSON() {
|
|
874
|
+
return {
|
|
875
|
+
type: "Buffer",
|
|
876
|
+
data: Array.prototype.slice.call(this._arr || this, 0)
|
|
877
|
+
};
|
|
878
|
+
};
|
|
879
|
+
function base64Slice(buf, start, end) {
|
|
880
|
+
if (start === 0 && end === buf.length) {
|
|
881
|
+
return base64.fromByteArray(buf);
|
|
882
|
+
} else {
|
|
883
|
+
return base64.fromByteArray(buf.slice(start, end));
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
function utf8Slice(buf, start, end) {
|
|
887
|
+
end = Math.min(buf.length, end);
|
|
888
|
+
const res = [];
|
|
889
|
+
let i = start;
|
|
890
|
+
while (i < end) {
|
|
891
|
+
const firstByte = buf[i];
|
|
892
|
+
let codePoint = null;
|
|
893
|
+
let bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
|
|
894
|
+
if (i + bytesPerSequence <= end) {
|
|
895
|
+
let secondByte, thirdByte, fourthByte, tempCodePoint;
|
|
896
|
+
switch (bytesPerSequence) {
|
|
897
|
+
case 1:
|
|
898
|
+
if (firstByte < 128) {
|
|
899
|
+
codePoint = firstByte;
|
|
948
900
|
}
|
|
949
|
-
matching.splice(i, 1);
|
|
950
901
|
break;
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
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
|
+
}
|
|
909
|
+
}
|
|
954
910
|
break;
|
|
955
|
-
|
|
911
|
+
case 3:
|
|
912
|
+
secondByte = buf[i + 1];
|
|
913
|
+
thirdByte = buf[i + 2];
|
|
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
|
+
}
|
|
920
|
+
break;
|
|
921
|
+
case 4:
|
|
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
|
+
}
|
|
956
931
|
}
|
|
957
932
|
}
|
|
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);
|
|
958
1169
|
}
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
1170
|
+
const val = (first << 24) + // Overflow
|
|
1171
|
+
this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
|
|
1172
|
+
return (BigInt(val) << BigInt(32)) + BigInt(this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last);
|
|
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;
|
|
963
1334
|
}
|
|
1335
|
+
this[offset + i] = (value / mul >> 0) - sub & 255;
|
|
964
1336
|
}
|
|
965
|
-
|
|
966
|
-
|
|
1337
|
+
return offset + byteLength3;
|
|
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);
|
|
967
1345
|
}
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
1346
|
+
let i = byteLength3 - 1;
|
|
1347
|
+
let mul = 1;
|
|
1348
|
+
let sub = 0;
|
|
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;
|
|
971
1355
|
}
|
|
972
|
-
return
|
|
1356
|
+
return offset + byteLength3;
|
|
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");
|
|
973
1412
|
}
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
1413
|
+
function writeFloat(buf, value, offset, littleEndian, noAssert) {
|
|
1414
|
+
value = +value;
|
|
1415
|
+
offset = offset >>> 0;
|
|
1416
|
+
if (!noAssert) {
|
|
1417
|
+
checkIEEE754(buf, value, offset, 4);
|
|
1418
|
+
}
|
|
1419
|
+
ieee754$1.write(buf, value, offset, littleEndian, 23, 4);
|
|
1420
|
+
return offset + 4;
|
|
977
1421
|
}
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
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;
|
|
1436
|
+
}
|
|
1437
|
+
Buffer2.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
|
|
1438
|
+
return writeDouble(this, value, offset, true, noAssert);
|
|
1439
|
+
};
|
|
1440
|
+
Buffer2.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
|
|
1441
|
+
return writeDouble(this, value, offset, false, noAssert);
|
|
1442
|
+
};
|
|
1443
|
+
Buffer2.prototype.copy = function copy(target, targetStart, start, end) {
|
|
1444
|
+
if (!Buffer2.isBuffer(target)) throw new TypeError("argument should be a Buffer");
|
|
1445
|
+
if (!start) start = 0;
|
|
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];
|
|
987
1522
|
}
|
|
988
1523
|
}
|
|
989
|
-
return
|
|
1524
|
+
return this;
|
|
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
|
+
};
|
|
990
1555
|
}
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
if (name
|
|
995
|
-
|
|
996
|
-
/* fix:) */
|
|
997
|
-
)[0] === key) {
|
|
998
|
-
matching.push(fragment);
|
|
1556
|
+
E(
|
|
1557
|
+
"ERR_BUFFER_OUT_OF_BOUNDS",
|
|
1558
|
+
function(name) {
|
|
1559
|
+
if (name) {
|
|
1560
|
+
return `${name} is outside of buffer bounds`;
|
|
999
1561
|
}
|
|
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}`;
|
|
1000
1598
|
}
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1599
|
+
return `${val.slice(0, i)}${res}`;
|
|
1600
|
+
}
|
|
1601
|
+
function checkBounds(buf, offset, byteLength3) {
|
|
1602
|
+
validateNumber(offset, "offset");
|
|
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}`;
|
|
1005
1616
|
}
|
|
1006
1617
|
}
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1618
|
+
throw new errors.ERR_OUT_OF_RANGE("value", range, value);
|
|
1619
|
+
}
|
|
1620
|
+
checkBounds(buf, offset, byteLength3);
|
|
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);
|
|
1011
1666
|
continue;
|
|
1012
1667
|
}
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
break;
|
|
1016
|
-
}
|
|
1668
|
+
leadSurrogate = codePoint;
|
|
1669
|
+
continue;
|
|
1017
1670
|
}
|
|
1671
|
+
if (codePoint < 56320) {
|
|
1672
|
+
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
1673
|
+
leadSurrogate = codePoint;
|
|
1674
|
+
continue;
|
|
1675
|
+
}
|
|
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");
|
|
1018
1707
|
}
|
|
1019
1708
|
}
|
|
1020
|
-
|
|
1021
|
-
|
|
1709
|
+
return bytes;
|
|
1710
|
+
}
|
|
1711
|
+
function asciiToBytes(str) {
|
|
1712
|
+
const byteArray = [];
|
|
1713
|
+
for (let i = 0; i < str.length; ++i) {
|
|
1714
|
+
byteArray.push(str.charCodeAt(i) & 255);
|
|
1022
1715
|
}
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
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);
|
|
1026
1728
|
}
|
|
1027
|
-
return
|
|
1729
|
+
return byteArray;
|
|
1028
1730
|
}
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
return result;
|
|
1731
|
+
function base64ToBytes(str) {
|
|
1732
|
+
return base64.toByteArray(base64clean(str));
|
|
1032
1733
|
}
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
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];
|
|
1739
|
+
}
|
|
1740
|
+
return i;
|
|
1741
|
+
}
|
|
1742
|
+
function isInstance(obj, type) {
|
|
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
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
return table;
|
|
1758
|
+
}();
|
|
1759
|
+
function defineBigIntMethod(fn) {
|
|
1760
|
+
return typeof BigInt === "undefined" ? BufferBigIntNotDefined : fn;
|
|
1761
|
+
}
|
|
1762
|
+
function BufferBigIntNotDefined() {
|
|
1763
|
+
throw new Error("BigInt not supported");
|
|
1764
|
+
}
|
|
1765
|
+
})(buffer);
|
|
1766
|
+
const Buffer = buffer.Buffer;
|
|
1036
1767
|
export {
|
|
1037
|
-
|
|
1038
|
-
Indexed,
|
|
1039
|
-
Interface,
|
|
1040
|
-
LogDescription,
|
|
1041
|
-
Result,
|
|
1042
|
-
TransactionDescription
|
|
1768
|
+
Buffer as default
|
|
1043
1769
|
};
|
|
1044
1770
|
//# sourceMappingURL=standards-sdk.es21.js.map
|