@hashgraphonline/standards-sdk 0.0.108-canary.1 → 0.0.108-canary.3
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 +56 -27
- package/dist/es/standards-sdk.es100.js.map +1 -1
- package/dist/es/standards-sdk.es101.js +69 -21
- package/dist/es/standards-sdk.es101.js.map +1 -1
- package/dist/es/standards-sdk.es102.js +3 -43
- package/dist/es/standards-sdk.es102.js.map +1 -1
- package/dist/es/standards-sdk.es103.js +27 -13
- package/dist/es/standards-sdk.es103.js.map +1 -1
- package/dist/es/standards-sdk.es104.js +57 -55
- package/dist/es/standards-sdk.es104.js.map +1 -1
- package/dist/es/standards-sdk.es105.js +49 -1288
- package/dist/es/standards-sdk.es105.js.map +1 -1
- package/dist/es/standards-sdk.es106.js +8 -30
- package/dist/es/standards-sdk.es106.js.map +1 -1
- package/dist/es/standards-sdk.es107.js +64 -5
- package/dist/es/standards-sdk.es107.js.map +1 -1
- package/dist/es/standards-sdk.es108.js +6 -159
- package/dist/es/standards-sdk.es108.js.map +1 -1
- package/dist/es/standards-sdk.es109.js +13 -791
- package/dist/es/standards-sdk.es109.js.map +1 -1
- package/dist/es/standards-sdk.es110.js +7 -174
- package/dist/es/standards-sdk.es110.js.map +1 -1
- package/dist/es/standards-sdk.es111.js +41 -139
- package/dist/es/standards-sdk.es111.js.map +1 -1
- package/dist/es/standards-sdk.es112.js +2 -3
- package/dist/es/standards-sdk.es112.js.map +1 -1
- package/dist/es/standards-sdk.es113.js +136 -2
- package/dist/es/standards-sdk.es113.js.map +1 -1
- package/dist/es/standards-sdk.es114.js +172 -2
- package/dist/es/standards-sdk.es114.js.map +1 -1
- package/dist/es/standards-sdk.es115.js +13 -34
- package/dist/es/standards-sdk.es115.js.map +1 -1
- package/dist/es/standards-sdk.es116.js +13 -33
- package/dist/es/standards-sdk.es116.js.map +1 -1
- package/dist/es/standards-sdk.es117.js +32 -9
- package/dist/es/standards-sdk.es117.js.map +1 -1
- package/dist/es/standards-sdk.es118.js +15 -34
- package/dist/es/standards-sdk.es118.js.map +1 -1
- package/dist/es/standards-sdk.es119.js +3 -20
- package/dist/es/standards-sdk.es119.js.map +1 -1
- package/dist/es/standards-sdk.es120.js +3 -26
- package/dist/es/standards-sdk.es120.js.map +1 -1
- package/dist/es/standards-sdk.es121.js +14 -24
- package/dist/es/standards-sdk.es121.js.map +1 -1
- package/dist/es/standards-sdk.es122.js +4 -37
- package/dist/es/standards-sdk.es122.js.map +1 -1
- package/dist/es/standards-sdk.es123.js +39 -101
- package/dist/es/standards-sdk.es123.js.map +1 -1
- package/dist/es/standards-sdk.es124.js +40 -2
- package/dist/es/standards-sdk.es124.js.map +1 -1
- package/dist/es/standards-sdk.es125.js +37 -16
- package/dist/es/standards-sdk.es125.js.map +1 -1
- package/dist/es/standards-sdk.es126.js +70 -401
- package/dist/es/standards-sdk.es126.js.map +1 -1
- package/dist/es/standards-sdk.es127.js +3 -2282
- package/dist/es/standards-sdk.es127.js.map +1 -1
- package/dist/es/standards-sdk.es128.js +2 -7136
- package/dist/es/standards-sdk.es128.js.map +1 -1
- package/dist/es/standards-sdk.es129.js +2 -10
- package/dist/es/standards-sdk.es129.js.map +1 -1
- package/dist/es/standards-sdk.es13.js +2 -2
- package/dist/es/standards-sdk.es130.js +33 -10
- package/dist/es/standards-sdk.es130.js.map +1 -1
- package/dist/es/standards-sdk.es131.js +31 -16
- package/dist/es/standards-sdk.es131.js.map +1 -1
- package/dist/es/standards-sdk.es132.js +9 -6
- package/dist/es/standards-sdk.es132.js.map +1 -1
- package/dist/es/standards-sdk.es133.js +34 -9
- package/dist/es/standards-sdk.es133.js.map +1 -1
- package/dist/es/standards-sdk.es15.js +1 -1
- package/dist/es/standards-sdk.es18.js +2 -2
- package/dist/es/standards-sdk.es19.js +76 -8
- package/dist/es/standards-sdk.es19.js.map +1 -1
- package/dist/es/standards-sdk.es20.js +2 -2
- package/dist/es/standards-sdk.es21.js +3 -3
- package/dist/es/standards-sdk.es24.js +10 -10
- package/dist/es/standards-sdk.es25.js +1769 -5
- package/dist/es/standards-sdk.es25.js.map +1 -1
- package/dist/es/standards-sdk.es26.js +7190 -36
- package/dist/es/standards-sdk.es26.js.map +1 -1
- package/dist/es/standards-sdk.es27.js +3 -48
- package/dist/es/standards-sdk.es27.js.map +1 -1
- package/dist/es/standards-sdk.es28.js +8 -1768
- package/dist/es/standards-sdk.es28.js.map +1 -1
- package/dist/es/standards-sdk.es29.js +2 -501
- package/dist/es/standards-sdk.es29.js.map +1 -1
- package/dist/es/standards-sdk.es30.js +5 -109
- package/dist/es/standards-sdk.es30.js.map +1 -1
- package/dist/es/standards-sdk.es31.js +36 -66
- package/dist/es/standards-sdk.es31.js.map +1 -1
- package/dist/es/standards-sdk.es32.js +47 -63
- package/dist/es/standards-sdk.es32.js.map +1 -1
- package/dist/es/standards-sdk.es33.js +492 -18
- package/dist/es/standards-sdk.es33.js.map +1 -1
- package/dist/es/standards-sdk.es34.js +103 -5
- package/dist/es/standards-sdk.es34.js.map +1 -1
- package/dist/es/standards-sdk.es35.js +65 -9
- package/dist/es/standards-sdk.es35.js.map +1 -1
- package/dist/es/standards-sdk.es36.js +225 -7158
- package/dist/es/standards-sdk.es36.js.map +1 -1
- package/dist/es/standards-sdk.es37.js +173 -3
- package/dist/es/standards-sdk.es37.js.map +1 -1
- package/dist/es/standards-sdk.es38.js +10 -8
- package/dist/es/standards-sdk.es38.js.map +1 -1
- package/dist/es/standards-sdk.es39.js +10 -2
- package/dist/es/standards-sdk.es39.js.map +1 -1
- package/dist/es/standards-sdk.es41.js +7092 -375
- package/dist/es/standards-sdk.es41.js.map +1 -1
- package/dist/es/standards-sdk.es42.js +2 -2
- package/dist/es/standards-sdk.es42.js.map +1 -1
- package/dist/es/standards-sdk.es43.js +3 -120
- package/dist/es/standards-sdk.es43.js.map +1 -1
- package/dist/es/standards-sdk.es44.js +93 -356
- package/dist/es/standards-sdk.es44.js.map +1 -1
- package/dist/es/standards-sdk.es45.js +2 -6
- package/dist/es/standards-sdk.es45.js.map +1 -1
- package/dist/es/standards-sdk.es46.js +15 -178
- package/dist/es/standards-sdk.es46.js.map +1 -1
- package/dist/es/standards-sdk.es47.js +400 -72
- package/dist/es/standards-sdk.es47.js.map +1 -1
- package/dist/es/standards-sdk.es48.js +87 -110
- package/dist/es/standards-sdk.es48.js.map +1 -1
- package/dist/es/standards-sdk.es49.js +138 -42
- package/dist/es/standards-sdk.es49.js.map +1 -1
- package/dist/es/standards-sdk.es5.js +1 -1
- package/dist/es/standards-sdk.es50.js +31 -9
- package/dist/es/standards-sdk.es50.js.map +1 -1
- package/dist/es/standards-sdk.es51.js +146 -84
- package/dist/es/standards-sdk.es51.js.map +1 -1
- package/dist/es/standards-sdk.es52.js +142 -3
- package/dist/es/standards-sdk.es52.js.map +1 -1
- package/dist/es/standards-sdk.es53.js +195 -2
- package/dist/es/standards-sdk.es53.js.map +1 -1
- package/dist/es/standards-sdk.es54.js +423 -98
- package/dist/es/standards-sdk.es54.js.map +1 -1
- package/dist/es/standards-sdk.es55.js +22 -71
- package/dist/es/standards-sdk.es55.js.map +1 -1
- package/dist/es/standards-sdk.es56.js +138 -5
- package/dist/es/standards-sdk.es56.js.map +1 -1
- package/dist/es/standards-sdk.es57.js +17 -4
- package/dist/es/standards-sdk.es57.js.map +1 -1
- package/dist/es/standards-sdk.es58.js +21 -213
- package/dist/es/standards-sdk.es58.js.map +1 -1
- package/dist/es/standards-sdk.es59.js +27 -56
- package/dist/es/standards-sdk.es59.js.map +1 -1
- package/dist/es/standards-sdk.es60.js +21 -69
- package/dist/es/standards-sdk.es60.js.map +1 -1
- package/dist/es/standards-sdk.es61.js +43 -3
- package/dist/es/standards-sdk.es61.js.map +1 -1
- package/dist/es/standards-sdk.es62.js +13 -37
- package/dist/es/standards-sdk.es62.js.map +1 -1
- package/dist/es/standards-sdk.es63.js +61 -3
- package/dist/es/standards-sdk.es63.js.map +1 -1
- package/dist/es/standards-sdk.es64.js +1260 -135
- package/dist/es/standards-sdk.es64.js.map +1 -1
- package/dist/es/standards-sdk.es65.js +80 -28
- package/dist/es/standards-sdk.es65.js.map +1 -1
- package/dist/es/standards-sdk.es66.js +5 -62
- package/dist/es/standards-sdk.es66.js.map +1 -1
- package/dist/es/standards-sdk.es67.js +21 -48
- package/dist/es/standards-sdk.es67.js.map +1 -1
- package/dist/es/standards-sdk.es68.js +792 -9
- package/dist/es/standards-sdk.es68.js.map +1 -1
- package/dist/es/standards-sdk.es69.js +166 -57
- package/dist/es/standards-sdk.es69.js.map +1 -1
- package/dist/es/standards-sdk.es7.js +4 -4
- package/dist/es/standards-sdk.es70.js +2281 -5
- package/dist/es/standards-sdk.es70.js.map +1 -1
- package/dist/es/standards-sdk.es71.js +161 -12
- package/dist/es/standards-sdk.es71.js.map +1 -1
- package/dist/es/standards-sdk.es72.js +10 -7
- package/dist/es/standards-sdk.es72.js.map +1 -1
- package/dist/es/standards-sdk.es73.js +11 -45
- package/dist/es/standards-sdk.es73.js.map +1 -1
- package/dist/es/standards-sdk.es74.js +18 -2
- package/dist/es/standards-sdk.es74.js.map +1 -1
- package/dist/es/standards-sdk.es75.js +6 -136
- package/dist/es/standards-sdk.es75.js.map +1 -1
- package/dist/es/standards-sdk.es76.js +9 -172
- package/dist/es/standards-sdk.es76.js.map +1 -1
- package/dist/es/standards-sdk.es77.js +21 -2
- package/dist/es/standards-sdk.es77.js.map +1 -1
- package/dist/es/standards-sdk.es78.js +27 -13
- package/dist/es/standards-sdk.es78.js.map +1 -1
- package/dist/es/standards-sdk.es79.js +26 -13
- package/dist/es/standards-sdk.es79.js.map +1 -1
- package/dist/es/standards-sdk.es8.js +3 -3
- package/dist/es/standards-sdk.es80.js +36 -30
- package/dist/es/standards-sdk.es80.js.map +1 -1
- package/dist/es/standards-sdk.es81.js +418 -14
- package/dist/es/standards-sdk.es81.js.map +1 -1
- package/dist/es/standards-sdk.es82.js +2 -4
- package/dist/es/standards-sdk.es82.js.map +1 -1
- package/dist/es/standards-sdk.es83.js +119 -3
- package/dist/es/standards-sdk.es83.js.map +1 -1
- package/dist/es/standards-sdk.es84.js +40 -14
- package/dist/es/standards-sdk.es84.js.map +1 -1
- package/dist/es/standards-sdk.es85.js +363 -4
- package/dist/es/standards-sdk.es85.js.map +1 -1
- package/dist/es/standards-sdk.es86.js +6 -39
- package/dist/es/standards-sdk.es86.js.map +1 -1
- package/dist/es/standards-sdk.es87.js +173 -34
- package/dist/es/standards-sdk.es87.js.map +1 -1
- package/dist/es/standards-sdk.es88.js +80 -36
- package/dist/es/standards-sdk.es88.js.map +1 -1
- package/dist/es/standards-sdk.es89.js +105 -69
- package/dist/es/standards-sdk.es89.js.map +1 -1
- package/dist/es/standards-sdk.es9.js +1 -1
- package/dist/es/standards-sdk.es90.js +46 -78
- package/dist/es/standards-sdk.es90.js.map +1 -1
- package/dist/es/standards-sdk.es91.js +9 -22
- package/dist/es/standards-sdk.es91.js.map +1 -1
- package/dist/es/standards-sdk.es92.js +83 -134
- package/dist/es/standards-sdk.es92.js.map +1 -1
- package/dist/es/standards-sdk.es93.js +3 -90
- package/dist/es/standards-sdk.es93.js.map +1 -1
- package/dist/es/standards-sdk.es94.js +2 -195
- package/dist/es/standards-sdk.es94.js.map +1 -1
- package/dist/es/standards-sdk.es95.js +98 -423
- package/dist/es/standards-sdk.es95.js.map +1 -1
- package/dist/es/standards-sdk.es96.js +71 -22
- package/dist/es/standards-sdk.es96.js.map +1 -1
- package/dist/es/standards-sdk.es97.js +5 -138
- package/dist/es/standards-sdk.es97.js.map +1 -1
- package/dist/es/standards-sdk.es98.js +4 -17
- package/dist/es/standards-sdk.es98.js.map +1 -1
- package/dist/es/standards-sdk.es99.js +213 -21
- package/dist/es/standards-sdk.es99.js.map +1 -1
- package/dist/es/utils/parsers/crypto-parser.d.ts +5 -1
- package/dist/es/utils/parsers/crypto-parser.d.ts.map +1 -1
- package/dist/es/utils/parsers/scs-parser.d.ts +4 -1
- package/dist/es/utils/parsers/scs-parser.d.ts.map +1 -1
- package/dist/es/utils/parsers/util-parser.d.ts.map +1 -1
- package/dist/es/utils/transaction-parser-types.d.ts +91 -0
- package/dist/es/utils/transaction-parser-types.d.ts.map +1 -1
- package/dist/es/utils/transaction-parser.d.ts.map +1 -1
- package/dist/umd/standards-sdk.umd.js +11 -11
- package/dist/umd/standards-sdk.umd.js.map +1 -1
- package/dist/umd/utils/parsers/crypto-parser.d.ts +5 -1
- package/dist/umd/utils/parsers/crypto-parser.d.ts.map +1 -1
- package/dist/umd/utils/parsers/scs-parser.d.ts +4 -1
- package/dist/umd/utils/parsers/scs-parser.d.ts.map +1 -1
- package/dist/umd/utils/parsers/util-parser.d.ts.map +1 -1
- package/dist/umd/utils/transaction-parser-types.d.ts +91 -0
- package/dist/umd/utils/transaction-parser-types.d.ts.map +1 -1
- package/dist/umd/utils/transaction-parser.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,100 +1,162 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { assertArgument, assert } from "./standards-sdk.es49.js";
|
|
2
|
+
const BN_0 = BigInt(0);
|
|
3
|
+
const BN_1 = BigInt(1);
|
|
4
|
+
const maxValue = 9007199254740991;
|
|
5
|
+
function fromTwos(_value, _width) {
|
|
6
|
+
const value = getUint(_value, "value");
|
|
7
|
+
const width = BigInt(getNumber(_width, "width"));
|
|
8
|
+
assert(value >> width === BN_0, "overflow", "NUMERIC_FAULT", {
|
|
9
|
+
operation: "fromTwos",
|
|
10
|
+
fault: "overflow",
|
|
11
|
+
value: _value
|
|
12
|
+
});
|
|
13
|
+
if (value >> width - BN_1) {
|
|
14
|
+
const mask2 = (BN_1 << width) - BN_1;
|
|
15
|
+
return -((~value & mask2) + BN_1);
|
|
16
|
+
}
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
function toTwos(_value, _width) {
|
|
20
|
+
let value = getBigInt(_value, "value");
|
|
21
|
+
const width = BigInt(getNumber(_width, "width"));
|
|
22
|
+
const limit = BN_1 << width - BN_1;
|
|
23
|
+
if (value < BN_0) {
|
|
24
|
+
value = -value;
|
|
25
|
+
assert(value <= limit, "too low", "NUMERIC_FAULT", {
|
|
26
|
+
operation: "toTwos",
|
|
27
|
+
fault: "overflow",
|
|
28
|
+
value: _value
|
|
10
29
|
});
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
token._listeners = null;
|
|
30
|
+
const mask2 = (BN_1 << width) - BN_1;
|
|
31
|
+
return (~value & mask2) + BN_1;
|
|
32
|
+
} else {
|
|
33
|
+
assert(value < limit, "too high", "NUMERIC_FAULT", {
|
|
34
|
+
operation: "toTwos",
|
|
35
|
+
fault: "overflow",
|
|
36
|
+
value: _value
|
|
19
37
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
}
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
function mask(_value, _bits) {
|
|
42
|
+
const value = getUint(_value, "value");
|
|
43
|
+
const bits = BigInt(getNumber(_bits, "bits"));
|
|
44
|
+
return value & (BN_1 << bits) - BN_1;
|
|
45
|
+
}
|
|
46
|
+
function getBigInt(value, name) {
|
|
47
|
+
switch (typeof value) {
|
|
48
|
+
case "bigint":
|
|
49
|
+
return value;
|
|
50
|
+
case "number":
|
|
51
|
+
assertArgument(Number.isInteger(value), "underflow", name || "value", value);
|
|
52
|
+
assertArgument(value >= -9007199254740991 && value <= maxValue, "overflow", name || "value", value);
|
|
53
|
+
return BigInt(value);
|
|
54
|
+
case "string":
|
|
55
|
+
try {
|
|
56
|
+
if (value === "") {
|
|
57
|
+
throw new Error("empty string");
|
|
58
|
+
}
|
|
59
|
+
if (value[0] === "-" && value[1] !== "-") {
|
|
60
|
+
return -BigInt(value.substring(1));
|
|
61
|
+
}
|
|
62
|
+
return BigInt(value);
|
|
63
|
+
} catch (e) {
|
|
64
|
+
assertArgument(false, `invalid BigNumberish string: ${e.message}`, name || "value", value);
|
|
34
65
|
}
|
|
35
|
-
token.reason = new CanceledError(message, config, request);
|
|
36
|
-
resolvePromise(token.reason);
|
|
37
|
-
});
|
|
38
66
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
67
|
+
assertArgument(false, "invalid BigNumberish value", name || "value", value);
|
|
68
|
+
}
|
|
69
|
+
function getUint(value, name) {
|
|
70
|
+
const result = getBigInt(value, name);
|
|
71
|
+
assert(result >= BN_0, "unsigned value cannot be negative", "NUMERIC_FAULT", {
|
|
72
|
+
fault: "overflow",
|
|
73
|
+
operation: "getUint",
|
|
74
|
+
value
|
|
75
|
+
});
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
const Nibbles = "0123456789abcdef";
|
|
79
|
+
function toBigInt(value) {
|
|
80
|
+
if (value instanceof Uint8Array) {
|
|
81
|
+
let result = "0x0";
|
|
82
|
+
for (const v of value) {
|
|
83
|
+
result += Nibbles[v >> 4];
|
|
84
|
+
result += Nibbles[v & 15];
|
|
45
85
|
}
|
|
86
|
+
return BigInt(result);
|
|
46
87
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
88
|
+
return getBigInt(value);
|
|
89
|
+
}
|
|
90
|
+
function getNumber(value, name) {
|
|
91
|
+
switch (typeof value) {
|
|
92
|
+
case "bigint":
|
|
93
|
+
assertArgument(value >= -9007199254740991 && value <= maxValue, "overflow", name || "value", value);
|
|
94
|
+
return Number(value);
|
|
95
|
+
case "number":
|
|
96
|
+
assertArgument(Number.isInteger(value), "underflow", name || "value", value);
|
|
97
|
+
assertArgument(value >= -9007199254740991 && value <= maxValue, "overflow", name || "value", value);
|
|
98
|
+
return value;
|
|
99
|
+
case "string":
|
|
100
|
+
try {
|
|
101
|
+
if (value === "") {
|
|
102
|
+
throw new Error("empty string");
|
|
103
|
+
}
|
|
104
|
+
return getNumber(BigInt(value), name);
|
|
105
|
+
} catch (e) {
|
|
106
|
+
assertArgument(false, `invalid numeric string: ${e.message}`, name || "value", value);
|
|
107
|
+
}
|
|
60
108
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
109
|
+
assertArgument(false, "invalid numeric value", name || "value", value);
|
|
110
|
+
}
|
|
111
|
+
function toNumber(value) {
|
|
112
|
+
return getNumber(toBigInt(value));
|
|
113
|
+
}
|
|
114
|
+
function toBeHex(_value, _width) {
|
|
115
|
+
const value = getUint(_value, "value");
|
|
116
|
+
let result = value.toString(16);
|
|
117
|
+
if (_width == null) {
|
|
118
|
+
if (result.length % 2) {
|
|
119
|
+
result = "0" + result;
|
|
67
120
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
121
|
+
} else {
|
|
122
|
+
const width = getNumber(_width, "width");
|
|
123
|
+
assert(width * 2 >= result.length, `value exceeds width (${width} bytes)`, "NUMERIC_FAULT", {
|
|
124
|
+
operation: "toBeHex",
|
|
125
|
+
fault: "overflow",
|
|
126
|
+
value: _value
|
|
127
|
+
});
|
|
128
|
+
while (result.length < width * 2) {
|
|
129
|
+
result = "0" + result;
|
|
71
130
|
}
|
|
72
131
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
controller.signal.unsubscribe = () => this.unsubscribe(abort);
|
|
80
|
-
return controller.signal;
|
|
132
|
+
return "0x" + result;
|
|
133
|
+
}
|
|
134
|
+
function toBeArray(_value) {
|
|
135
|
+
const value = getUint(_value, "value");
|
|
136
|
+
if (value === BN_0) {
|
|
137
|
+
return new Uint8Array([]);
|
|
81
138
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
});
|
|
91
|
-
return {
|
|
92
|
-
token,
|
|
93
|
-
cancel
|
|
94
|
-
};
|
|
139
|
+
let hex = value.toString(16);
|
|
140
|
+
if (hex.length % 2) {
|
|
141
|
+
hex = "0" + hex;
|
|
142
|
+
}
|
|
143
|
+
const result = new Uint8Array(hex.length / 2);
|
|
144
|
+
for (let i = 0; i < result.length; i++) {
|
|
145
|
+
const offset = i * 2;
|
|
146
|
+
result[i] = parseInt(hex.substring(offset, offset + 2), 16);
|
|
95
147
|
}
|
|
148
|
+
return result;
|
|
96
149
|
}
|
|
97
150
|
export {
|
|
98
|
-
|
|
151
|
+
fromTwos,
|
|
152
|
+
getBigInt,
|
|
153
|
+
getNumber,
|
|
154
|
+
getUint,
|
|
155
|
+
mask,
|
|
156
|
+
toBeArray,
|
|
157
|
+
toBeHex,
|
|
158
|
+
toBigInt,
|
|
159
|
+
toNumber,
|
|
160
|
+
toTwos
|
|
99
161
|
};
|
|
100
162
|
//# sourceMappingURL=standards-sdk.es51.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es51.js","sources":["../../node_modules/axios/lib/cancel/CancelToken.js"],"sourcesContent":["'use strict';\n\nimport CanceledError from './CanceledError.js';\n\n/**\n * A `CancelToken` is an object that can be used to request cancellation of an operation.\n *\n * @param {Function} executor The executor function.\n *\n * @returns {CancelToken}\n */\nclass CancelToken {\n constructor(executor) {\n if (typeof executor !== 'function') {\n throw new TypeError('executor must be a function.');\n }\n\n let resolvePromise;\n\n this.promise = new Promise(function promiseExecutor(resolve) {\n resolvePromise = resolve;\n });\n\n const token = this;\n\n // eslint-disable-next-line func-names\n this.promise.then(cancel => {\n if (!token._listeners) return;\n\n let i = token._listeners.length;\n\n while (i-- > 0) {\n token._listeners[i](cancel);\n }\n token._listeners = null;\n });\n\n // eslint-disable-next-line func-names\n this.promise.then = onfulfilled => {\n let _resolve;\n // eslint-disable-next-line func-names\n const promise = new Promise(resolve => {\n token.subscribe(resolve);\n _resolve = resolve;\n }).then(onfulfilled);\n\n promise.cancel = function reject() {\n token.unsubscribe(_resolve);\n };\n\n return promise;\n };\n\n executor(function cancel(message, config, request) {\n if (token.reason) {\n // Cancellation has already been requested\n return;\n }\n\n token.reason = new CanceledError(message, config, request);\n resolvePromise(token.reason);\n });\n }\n\n /**\n * Throws a `CanceledError` if cancellation has been requested.\n */\n throwIfRequested() {\n if (this.reason) {\n throw this.reason;\n }\n }\n\n /**\n * Subscribe to the cancel signal\n */\n\n subscribe(listener) {\n if (this.reason) {\n listener(this.reason);\n return;\n }\n\n if (this._listeners) {\n this._listeners.push(listener);\n } else {\n this._listeners = [listener];\n }\n }\n\n /**\n * Unsubscribe from the cancel signal\n */\n\n unsubscribe(listener) {\n if (!this._listeners) {\n return;\n }\n const index = this._listeners.indexOf(listener);\n if (index !== -1) {\n this._listeners.splice(index, 1);\n }\n }\n\n toAbortSignal() {\n const controller = new AbortController();\n\n const abort = (err) => {\n controller.abort(err);\n };\n\n this.subscribe(abort);\n\n controller.signal.unsubscribe = () => this.unsubscribe(abort);\n\n return controller.signal;\n }\n\n /**\n * Returns an object that contains a new `CancelToken` and a function that, when called,\n * cancels the `CancelToken`.\n */\n static source() {\n let cancel;\n const token = new CancelToken(function executor(c) {\n cancel = c;\n });\n return {\n token,\n cancel\n };\n }\n}\n\nexport default CancelToken;\n"],"names":[],"mappings":";AAWA,MAAM,YAAY;AAAA,EAChB,YAAY,UAAU;AACpB,QAAI,OAAO,aAAa,YAAY;AAClC,YAAM,IAAI,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AW,QAAQ,QAAQ;AAC9C,QAAI,UAAU,IAAI;AAChB,WAAK,WAAW,OAAO,OAAO,CAAC;AAAA,IACrC;AAAA,EACA;AAAA,EAEE,gBAAgB;AACd,UAAM,aAAa,IAAI,gBAAiB;AAExC,UAAM,QAAQ,CAAC,QAAQ;AACrB,iBAAW,MAAM,GAAG;AAAA,IACrB;AAED,SAAK,UAAU,KAAK;AAEpB,eAAW,OAAO,cAAc,MAAM,KAAK,YAAY,KAAK;AAE5D,WAAO,WAAW;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA;AAAA,EAME,OAAO,SAAS;AACd,QAAI;AACJ,UAAM,QAAQ,IAAI,YAAY,SAAS,SAAS,GAAG;AACjD,eAAS;AAAA,IACf,CAAK;AACD,WAAO;AAAA,MACL;AAAA,MACA;AAAA,IACD;AAAA,EACL;AACA;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"standards-sdk.es51.js","sources":["../../node_modules/ethers/lib.esm/utils/maths.js"],"sourcesContent":["/**\n * Some mathematic operations.\n *\n * @_subsection: api/utils:Math Helpers [about-maths]\n */\nimport { hexlify, isBytesLike } from \"./data.js\";\nimport { assert, assertArgument } from \"./errors.js\";\nconst BN_0 = BigInt(0);\nconst BN_1 = BigInt(1);\n//const BN_Max256 = (BN_1 << BigInt(256)) - BN_1;\n// IEEE 754 support 53-bits of mantissa\nconst maxValue = 0x1fffffffffffff;\n/**\n * Convert %%value%% from a twos-compliment representation of %%width%%\n * bits to its value.\n *\n * If the highest bit is ``1``, the result will be negative.\n */\nexport function fromTwos(_value, _width) {\n const value = getUint(_value, \"value\");\n const width = BigInt(getNumber(_width, \"width\"));\n assert((value >> width) === BN_0, \"overflow\", \"NUMERIC_FAULT\", {\n operation: \"fromTwos\", fault: \"overflow\", value: _value\n });\n // Top bit set; treat as a negative value\n if (value >> (width - BN_1)) {\n const mask = (BN_1 << width) - BN_1;\n return -(((~value) & mask) + BN_1);\n }\n return value;\n}\n/**\n * Convert %%value%% to a twos-compliment representation of\n * %%width%% bits.\n *\n * The result will always be positive.\n */\nexport function toTwos(_value, _width) {\n let value = getBigInt(_value, \"value\");\n const width = BigInt(getNumber(_width, \"width\"));\n const limit = (BN_1 << (width - BN_1));\n if (value < BN_0) {\n value = -value;\n assert(value <= limit, \"too low\", \"NUMERIC_FAULT\", {\n operation: \"toTwos\", fault: \"overflow\", value: _value\n });\n const mask = (BN_1 << width) - BN_1;\n return ((~value) & mask) + BN_1;\n }\n else {\n assert(value < limit, \"too high\", \"NUMERIC_FAULT\", {\n operation: \"toTwos\", fault: \"overflow\", value: _value\n });\n }\n return value;\n}\n/**\n * Mask %%value%% with a bitmask of %%bits%% ones.\n */\nexport function mask(_value, _bits) {\n const value = getUint(_value, \"value\");\n const bits = BigInt(getNumber(_bits, \"bits\"));\n return value & ((BN_1 << bits) - BN_1);\n}\n/**\n * Gets a BigInt from %%value%%. If it is an invalid value for\n * a BigInt, then an ArgumentError will be thrown for %%name%%.\n */\nexport function getBigInt(value, name) {\n switch (typeof (value)) {\n case \"bigint\": return value;\n case \"number\":\n assertArgument(Number.isInteger(value), \"underflow\", name || \"value\", value);\n assertArgument(value >= -maxValue && value <= maxValue, \"overflow\", name || \"value\", value);\n return BigInt(value);\n case \"string\":\n try {\n if (value === \"\") {\n throw new Error(\"empty string\");\n }\n if (value[0] === \"-\" && value[1] !== \"-\") {\n return -BigInt(value.substring(1));\n }\n return BigInt(value);\n }\n catch (e) {\n assertArgument(false, `invalid BigNumberish string: ${e.message}`, name || \"value\", value);\n }\n }\n assertArgument(false, \"invalid BigNumberish value\", name || \"value\", value);\n}\n/**\n * Returns %%value%% as a bigint, validating it is valid as a bigint\n * value and that it is positive.\n */\nexport function getUint(value, name) {\n const result = getBigInt(value, name);\n assert(result >= BN_0, \"unsigned value cannot be negative\", \"NUMERIC_FAULT\", {\n fault: \"overflow\", operation: \"getUint\", value\n });\n return result;\n}\nconst Nibbles = \"0123456789abcdef\";\n/*\n * Converts %%value%% to a BigInt. If %%value%% is a Uint8Array, it\n * is treated as Big Endian data.\n */\nexport function toBigInt(value) {\n if (value instanceof Uint8Array) {\n let result = \"0x0\";\n for (const v of value) {\n result += Nibbles[v >> 4];\n result += Nibbles[v & 0x0f];\n }\n return BigInt(result);\n }\n return getBigInt(value);\n}\n/**\n * Gets a //number// from %%value%%. If it is an invalid value for\n * a //number//, then an ArgumentError will be thrown for %%name%%.\n */\nexport function getNumber(value, name) {\n switch (typeof (value)) {\n case \"bigint\":\n assertArgument(value >= -maxValue && value <= maxValue, \"overflow\", name || \"value\", value);\n return Number(value);\n case \"number\":\n assertArgument(Number.isInteger(value), \"underflow\", name || \"value\", value);\n assertArgument(value >= -maxValue && value <= maxValue, \"overflow\", name || \"value\", value);\n return value;\n case \"string\":\n try {\n if (value === \"\") {\n throw new Error(\"empty string\");\n }\n return getNumber(BigInt(value), name);\n }\n catch (e) {\n assertArgument(false, `invalid numeric string: ${e.message}`, name || \"value\", value);\n }\n }\n assertArgument(false, \"invalid numeric value\", name || \"value\", value);\n}\n/**\n * Converts %%value%% to a number. If %%value%% is a Uint8Array, it\n * is treated as Big Endian data. Throws if the value is not safe.\n */\nexport function toNumber(value) {\n return getNumber(toBigInt(value));\n}\n/**\n * Converts %%value%% to a Big Endian hexstring, optionally padded to\n * %%width%% bytes.\n */\nexport function toBeHex(_value, _width) {\n const value = getUint(_value, \"value\");\n let result = value.toString(16);\n if (_width == null) {\n // Ensure the value is of even length\n if (result.length % 2) {\n result = \"0\" + result;\n }\n }\n else {\n const width = getNumber(_width, \"width\");\n assert(width * 2 >= result.length, `value exceeds width (${width} bytes)`, \"NUMERIC_FAULT\", {\n operation: \"toBeHex\",\n fault: \"overflow\",\n value: _value\n });\n // Pad the value to the required width\n while (result.length < (width * 2)) {\n result = \"0\" + result;\n }\n }\n return \"0x\" + result;\n}\n/**\n * Converts %%value%% to a Big Endian Uint8Array.\n */\nexport function toBeArray(_value) {\n const value = getUint(_value, \"value\");\n if (value === BN_0) {\n return new Uint8Array([]);\n }\n let hex = value.toString(16);\n if (hex.length % 2) {\n hex = \"0\" + hex;\n }\n const result = new Uint8Array(hex.length / 2);\n for (let i = 0; i < result.length; i++) {\n const offset = i * 2;\n result[i] = parseInt(hex.substring(offset, offset + 2), 16);\n }\n return result;\n}\n/**\n * Returns a [[HexString]] for %%value%% safe to use as a //Quantity//.\n *\n * A //Quantity// does not have and leading 0 values unless the value is\n * the literal value `0x0`. This is most commonly used for JSSON-RPC\n * numeric values.\n */\nexport function toQuantity(value) {\n let result = hexlify(isBytesLike(value) ? value : toBeArray(value)).substring(2);\n while (result.startsWith(\"0\")) {\n result = result.substring(1);\n }\n if (result === \"\") {\n result = \"0\";\n }\n return \"0x\" + result;\n}\n//# sourceMappingURL=maths.js.map"],"names":["mask"],"mappings":";AAOA,MAAM,OAAO,OAAO,CAAC;AACrB,MAAM,OAAO,OAAO,CAAC;AAGrB,MAAM,WAAW;AAOV,SAAS,SAAS,QAAQ,QAAQ;AACrC,QAAM,QAAQ,QAAQ,QAAQ,OAAO;AACrC,QAAM,QAAQ,OAAO,UAAU,QAAQ,OAAO,CAAC;AAC/C,SAAQ,SAAS,UAAW,MAAM,YAAY,iBAAiB;AAAA,IAC3D,WAAW;AAAA,IAAY,OAAO;AAAA,IAAY,OAAO;AAAA,EACzD,CAAK;AAED,MAAI,SAAU,QAAQ,MAAO;AACzB,UAAMA,SAAQ,QAAQ,SAAS;AAC/B,WAAO,GAAI,CAAC,QAASA,SAAQ;AAAA,EACrC;AACI,SAAO;AACX;AAOO,SAAS,OAAO,QAAQ,QAAQ;AACnC,MAAI,QAAQ,UAAU,QAAQ,OAAO;AACrC,QAAM,QAAQ,OAAO,UAAU,QAAQ,OAAO,CAAC;AAC/C,QAAM,QAAS,QAAS,QAAQ;AAChC,MAAI,QAAQ,MAAM;AACd,YAAQ,CAAC;AACT,WAAO,SAAS,OAAO,WAAW,iBAAiB;AAAA,MAC/C,WAAW;AAAA,MAAU,OAAO;AAAA,MAAY,OAAO;AAAA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,QAAQ,wBAAwB,KAAK,WAAW,iBAAiB;AAAA,MACxF,WAAW;AAAA,MACX,OAAO;AAAA,MACP,OAAO;AAAA,IACnB,CAAS;AAED,WAAO,OAAO,SAAU,QAAQ,GAAI;AAChC,eAAS,MAAM;AAAA,IAC3B;AAAA,EACA;AACI,SAAO,OAAO;AAClB;AAIO,SAAS,UAAU,QAAQ;AAC9B,QAAM,QAAQ,QAAQ,QAAQ,OAAO;AACrC,MAAI,UAAU,MAAM;AAChB,WAAO,IAAI,WAAW,EAAE;AAAA,EAChC;AACI,MAAI,MAAM,MAAM,SAAS,EAAE;AAC3B,MAAI,IAAI,SAAS,GAAG;AAChB,UAAM,MAAM;AAAA,EACpB;AACI,QAAM,SAAS,IAAI,WAAW,IAAI,SAAS,CAAC;AAC5C,WAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACpC,UAAM,SAAS,IAAI;AACnB,WAAO,CAAC,IAAI,SAAS,IAAI,UAAU,QAAQ,SAAS,CAAC,GAAG,EAAE;AAAA,EAClE;AACI,SAAO;AACX;","x_google_ignoreList":[0]}
|
|
@@ -1,7 +1,146 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { getBytes } from "./standards-sdk.es48.js";
|
|
2
|
+
import { assertArgument } from "./standards-sdk.es49.js";
|
|
3
|
+
function errorFunc(reason, offset, bytes, output, badCodepoint) {
|
|
4
|
+
assertArgument(false, `invalid codepoint at offset ${offset}; ${reason}`, "bytes", bytes);
|
|
5
|
+
}
|
|
6
|
+
function ignoreFunc(reason, offset, bytes, output, badCodepoint) {
|
|
7
|
+
if (reason === "BAD_PREFIX" || reason === "UNEXPECTED_CONTINUE") {
|
|
8
|
+
let i = 0;
|
|
9
|
+
for (let o = offset + 1; o < bytes.length; o++) {
|
|
10
|
+
if (bytes[o] >> 6 !== 2) {
|
|
11
|
+
break;
|
|
12
|
+
}
|
|
13
|
+
i++;
|
|
14
|
+
}
|
|
15
|
+
return i;
|
|
16
|
+
}
|
|
17
|
+
if (reason === "OVERRUN") {
|
|
18
|
+
return bytes.length - offset - 1;
|
|
19
|
+
}
|
|
20
|
+
return 0;
|
|
21
|
+
}
|
|
22
|
+
function replaceFunc(reason, offset, bytes, output, badCodepoint) {
|
|
23
|
+
if (reason === "OVERLONG") {
|
|
24
|
+
assertArgument(typeof badCodepoint === "number", "invalid bad code point for replacement", "badCodepoint", badCodepoint);
|
|
25
|
+
output.push(badCodepoint);
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
output.push(65533);
|
|
29
|
+
return ignoreFunc(reason, offset, bytes);
|
|
30
|
+
}
|
|
31
|
+
const Utf8ErrorFuncs = Object.freeze({
|
|
32
|
+
error: errorFunc,
|
|
33
|
+
ignore: ignoreFunc,
|
|
34
|
+
replace: replaceFunc
|
|
35
|
+
});
|
|
36
|
+
function getUtf8CodePoints(_bytes, onError) {
|
|
37
|
+
if (onError == null) {
|
|
38
|
+
onError = Utf8ErrorFuncs.error;
|
|
39
|
+
}
|
|
40
|
+
const bytes = getBytes(_bytes, "bytes");
|
|
41
|
+
const result = [];
|
|
42
|
+
let i = 0;
|
|
43
|
+
while (i < bytes.length) {
|
|
44
|
+
const c = bytes[i++];
|
|
45
|
+
if (c >> 7 === 0) {
|
|
46
|
+
result.push(c);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
let extraLength = null;
|
|
50
|
+
let overlongMask = null;
|
|
51
|
+
if ((c & 224) === 192) {
|
|
52
|
+
extraLength = 1;
|
|
53
|
+
overlongMask = 127;
|
|
54
|
+
} else if ((c & 240) === 224) {
|
|
55
|
+
extraLength = 2;
|
|
56
|
+
overlongMask = 2047;
|
|
57
|
+
} else if ((c & 248) === 240) {
|
|
58
|
+
extraLength = 3;
|
|
59
|
+
overlongMask = 65535;
|
|
60
|
+
} else {
|
|
61
|
+
if ((c & 192) === 128) {
|
|
62
|
+
i += onError("UNEXPECTED_CONTINUE", i - 1, bytes, result);
|
|
63
|
+
} else {
|
|
64
|
+
i += onError("BAD_PREFIX", i - 1, bytes, result);
|
|
65
|
+
}
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (i - 1 + extraLength >= bytes.length) {
|
|
69
|
+
i += onError("OVERRUN", i - 1, bytes, result);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
let res = c & (1 << 8 - extraLength - 1) - 1;
|
|
73
|
+
for (let j = 0; j < extraLength; j++) {
|
|
74
|
+
let nextChar = bytes[i];
|
|
75
|
+
if ((nextChar & 192) != 128) {
|
|
76
|
+
i += onError("MISSING_CONTINUE", i, bytes, result);
|
|
77
|
+
res = null;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
res = res << 6 | nextChar & 63;
|
|
81
|
+
i++;
|
|
82
|
+
}
|
|
83
|
+
if (res === null) {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (res > 1114111) {
|
|
87
|
+
i += onError("OUT_OF_RANGE", i - 1 - extraLength, bytes, result, res);
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (res >= 55296 && res <= 57343) {
|
|
91
|
+
i += onError("UTF16_SURROGATE", i - 1 - extraLength, bytes, result, res);
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (res <= overlongMask) {
|
|
95
|
+
i += onError("OVERLONG", i - 1 - extraLength, bytes, result, res);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
result.push(res);
|
|
99
|
+
}
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
function toUtf8Bytes(str, form) {
|
|
103
|
+
assertArgument(typeof str === "string", "invalid string value", "str", str);
|
|
104
|
+
let result = [];
|
|
105
|
+
for (let i = 0; i < str.length; i++) {
|
|
106
|
+
const c = str.charCodeAt(i);
|
|
107
|
+
if (c < 128) {
|
|
108
|
+
result.push(c);
|
|
109
|
+
} else if (c < 2048) {
|
|
110
|
+
result.push(c >> 6 | 192);
|
|
111
|
+
result.push(c & 63 | 128);
|
|
112
|
+
} else if ((c & 64512) == 55296) {
|
|
113
|
+
i++;
|
|
114
|
+
const c2 = str.charCodeAt(i);
|
|
115
|
+
assertArgument(i < str.length && (c2 & 64512) === 56320, "invalid surrogate pair", "str", str);
|
|
116
|
+
const pair = 65536 + ((c & 1023) << 10) + (c2 & 1023);
|
|
117
|
+
result.push(pair >> 18 | 240);
|
|
118
|
+
result.push(pair >> 12 & 63 | 128);
|
|
119
|
+
result.push(pair >> 6 & 63 | 128);
|
|
120
|
+
result.push(pair & 63 | 128);
|
|
121
|
+
} else {
|
|
122
|
+
result.push(c >> 12 | 224);
|
|
123
|
+
result.push(c >> 6 & 63 | 128);
|
|
124
|
+
result.push(c & 63 | 128);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return new Uint8Array(result);
|
|
128
|
+
}
|
|
129
|
+
function _toUtf8String(codePoints) {
|
|
130
|
+
return codePoints.map((codePoint) => {
|
|
131
|
+
if (codePoint <= 65535) {
|
|
132
|
+
return String.fromCharCode(codePoint);
|
|
133
|
+
}
|
|
134
|
+
codePoint -= 65536;
|
|
135
|
+
return String.fromCharCode((codePoint >> 10 & 1023) + 55296, (codePoint & 1023) + 56320);
|
|
136
|
+
}).join("");
|
|
137
|
+
}
|
|
138
|
+
function toUtf8String(bytes, onError) {
|
|
139
|
+
return _toUtf8String(getUtf8CodePoints(bytes, onError));
|
|
3
140
|
}
|
|
4
141
|
export {
|
|
5
|
-
|
|
142
|
+
Utf8ErrorFuncs,
|
|
143
|
+
toUtf8Bytes,
|
|
144
|
+
toUtf8String
|
|
6
145
|
};
|
|
7
146
|
//# sourceMappingURL=standards-sdk.es52.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es52.js","sources":["../../node_modules/axios/lib/cancel/isCancel.js"],"sourcesContent":["'use strict';\n\nexport default function isCancel(value) {\n return !!(value && value.__CANCEL__);\n}\n"],"names":[],"mappings":"AAEe,SAAS,SAAS,OAAO;AACtC,SAAO,CAAC,EAAE,SAAS,MAAM;AAC3B;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"standards-sdk.es52.js","sources":["../../node_modules/ethers/lib.esm/utils/utf8.js"],"sourcesContent":["/**\n * Using strings in Ethereum (or any security-basd system) requires\n * additional care. These utilities attempt to mitigate some of the\n * safety issues as well as provide the ability to recover and analyse\n * strings.\n *\n * @_subsection api/utils:Strings and UTF-8 [about-strings]\n */\nimport { getBytes } from \"./data.js\";\nimport { assertArgument, assertNormalize } from \"./errors.js\";\nfunction errorFunc(reason, offset, bytes, output, badCodepoint) {\n assertArgument(false, `invalid codepoint at offset ${offset}; ${reason}`, \"bytes\", bytes);\n}\nfunction ignoreFunc(reason, offset, bytes, output, badCodepoint) {\n // If there is an invalid prefix (including stray continuation), skip any additional continuation bytes\n if (reason === \"BAD_PREFIX\" || reason === \"UNEXPECTED_CONTINUE\") {\n let i = 0;\n for (let o = offset + 1; o < bytes.length; o++) {\n if (bytes[o] >> 6 !== 0x02) {\n break;\n }\n i++;\n }\n return i;\n }\n // This byte runs us past the end of the string, so just jump to the end\n // (but the first byte was read already read and therefore skipped)\n if (reason === \"OVERRUN\") {\n return bytes.length - offset - 1;\n }\n // Nothing to skip\n return 0;\n}\nfunction replaceFunc(reason, offset, bytes, output, badCodepoint) {\n // Overlong representations are otherwise \"valid\" code points; just non-deistingtished\n if (reason === \"OVERLONG\") {\n assertArgument(typeof (badCodepoint) === \"number\", \"invalid bad code point for replacement\", \"badCodepoint\", badCodepoint);\n output.push(badCodepoint);\n return 0;\n }\n // Put the replacement character into the output\n output.push(0xfffd);\n // Otherwise, process as if ignoring errors\n return ignoreFunc(reason, offset, bytes, output, badCodepoint);\n}\n/**\n * A handful of popular, built-in UTF-8 error handling strategies.\n *\n * **``\"error\"``** - throws on ANY illegal UTF-8 sequence or\n * non-canonical (overlong) codepoints (this is the default)\n *\n * **``\"ignore\"``** - silently drops any illegal UTF-8 sequence\n * and accepts non-canonical (overlong) codepoints\n *\n * **``\"replace\"``** - replace any illegal UTF-8 sequence with the\n * UTF-8 replacement character (i.e. ``\"\\\\ufffd\"``) and accepts\n * non-canonical (overlong) codepoints\n *\n * @returns: Record<\"error\" | \"ignore\" | \"replace\", Utf8ErrorFunc>\n */\nexport const Utf8ErrorFuncs = Object.freeze({\n error: errorFunc,\n ignore: ignoreFunc,\n replace: replaceFunc\n});\n// http://stackoverflow.com/questions/13356493/decode-utf-8-with-javascript#13691499\nfunction getUtf8CodePoints(_bytes, onError) {\n if (onError == null) {\n onError = Utf8ErrorFuncs.error;\n }\n const bytes = getBytes(_bytes, \"bytes\");\n const result = [];\n let i = 0;\n // Invalid bytes are ignored\n while (i < bytes.length) {\n const c = bytes[i++];\n // 0xxx xxxx\n if (c >> 7 === 0) {\n result.push(c);\n continue;\n }\n // Multibyte; how many bytes left for this character?\n let extraLength = null;\n let overlongMask = null;\n // 110x xxxx 10xx xxxx\n if ((c & 0xe0) === 0xc0) {\n extraLength = 1;\n overlongMask = 0x7f;\n // 1110 xxxx 10xx xxxx 10xx xxxx\n }\n else if ((c & 0xf0) === 0xe0) {\n extraLength = 2;\n overlongMask = 0x7ff;\n // 1111 0xxx 10xx xxxx 10xx xxxx 10xx xxxx\n }\n else if ((c & 0xf8) === 0xf0) {\n extraLength = 3;\n overlongMask = 0xffff;\n }\n else {\n if ((c & 0xc0) === 0x80) {\n i += onError(\"UNEXPECTED_CONTINUE\", i - 1, bytes, result);\n }\n else {\n i += onError(\"BAD_PREFIX\", i - 1, bytes, result);\n }\n continue;\n }\n // Do we have enough bytes in our data?\n if (i - 1 + extraLength >= bytes.length) {\n i += onError(\"OVERRUN\", i - 1, bytes, result);\n continue;\n }\n // Remove the length prefix from the char\n let res = c & ((1 << (8 - extraLength - 1)) - 1);\n for (let j = 0; j < extraLength; j++) {\n let nextChar = bytes[i];\n // Invalid continuation byte\n if ((nextChar & 0xc0) != 0x80) {\n i += onError(\"MISSING_CONTINUE\", i, bytes, result);\n res = null;\n break;\n }\n ;\n res = (res << 6) | (nextChar & 0x3f);\n i++;\n }\n // See above loop for invalid continuation byte\n if (res === null) {\n continue;\n }\n // Maximum code point\n if (res > 0x10ffff) {\n i += onError(\"OUT_OF_RANGE\", i - 1 - extraLength, bytes, result, res);\n continue;\n }\n // Reserved for UTF-16 surrogate halves\n if (res >= 0xd800 && res <= 0xdfff) {\n i += onError(\"UTF16_SURROGATE\", i - 1 - extraLength, bytes, result, res);\n continue;\n }\n // Check for overlong sequences (more bytes than needed)\n if (res <= overlongMask) {\n i += onError(\"OVERLONG\", i - 1 - extraLength, bytes, result, res);\n continue;\n }\n result.push(res);\n }\n return result;\n}\n// http://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array\n/**\n * Returns the UTF-8 byte representation of %%str%%.\n *\n * If %%form%% is specified, the string is normalized.\n */\nexport function toUtf8Bytes(str, form) {\n assertArgument(typeof (str) === \"string\", \"invalid string value\", \"str\", str);\n if (form != null) {\n assertNormalize(form);\n str = str.normalize(form);\n }\n let result = [];\n for (let i = 0; i < str.length; i++) {\n const c = str.charCodeAt(i);\n if (c < 0x80) {\n result.push(c);\n }\n else if (c < 0x800) {\n result.push((c >> 6) | 0xc0);\n result.push((c & 0x3f) | 0x80);\n }\n else if ((c & 0xfc00) == 0xd800) {\n i++;\n const c2 = str.charCodeAt(i);\n assertArgument(i < str.length && ((c2 & 0xfc00) === 0xdc00), \"invalid surrogate pair\", \"str\", str);\n // Surrogate Pair\n const pair = 0x10000 + ((c & 0x03ff) << 10) + (c2 & 0x03ff);\n result.push((pair >> 18) | 0xf0);\n result.push(((pair >> 12) & 0x3f) | 0x80);\n result.push(((pair >> 6) & 0x3f) | 0x80);\n result.push((pair & 0x3f) | 0x80);\n }\n else {\n result.push((c >> 12) | 0xe0);\n result.push(((c >> 6) & 0x3f) | 0x80);\n result.push((c & 0x3f) | 0x80);\n }\n }\n return new Uint8Array(result);\n}\n;\n//export \nfunction _toUtf8String(codePoints) {\n return codePoints.map((codePoint) => {\n if (codePoint <= 0xffff) {\n return String.fromCharCode(codePoint);\n }\n codePoint -= 0x10000;\n return String.fromCharCode((((codePoint >> 10) & 0x3ff) + 0xd800), ((codePoint & 0x3ff) + 0xdc00));\n }).join(\"\");\n}\n/**\n * Returns the string represented by the UTF-8 data %%bytes%%.\n *\n * When %%onError%% function is specified, it is called on UTF-8\n * errors allowing recovery using the [[Utf8ErrorFunc]] API.\n * (default: [error](Utf8ErrorFuncs))\n */\nexport function toUtf8String(bytes, onError) {\n return _toUtf8String(getUtf8CodePoints(bytes, onError));\n}\n/**\n * Returns the UTF-8 code-points for %%str%%.\n *\n * If %%form%% is specified, the string is normalized.\n */\nexport function toUtf8CodePoints(str, form) {\n return getUtf8CodePoints(toUtf8Bytes(str, form));\n}\n//# sourceMappingURL=utf8.js.map"],"names":[],"mappings":";;AAUA,SAAS,UAAU,QAAQ,QAAQ,OAAO,QAAQ,cAAc;AAC5D,iBAAe,OAAO,+BAA+B,MAAM,KAAK,MAAM,IAAI,SAAS,KAAK;AAC5F;AACA,SAAS,WAAW,QAAQ,QAAQ,OAAO,QAAQ,cAAc;AAE7D,MAAI,WAAW,gBAAgB,WAAW,uBAAuB;AAC7D,QAAI,IAAI;AACR,aAAS,IAAI,SAAS,GAAG,IAAI,MAAM,QAAQ,KAAK;AAC5C,UAAI,MAAM,CAAC,KAAK,MAAM,GAAM;AACxB;AAAA,MAChB;AACY;AAAA,IACZ;AACQ,WAAO;AAAA,EACf;AAGI,MAAI,WAAW,WAAW;AACtB,WAAO,MAAM,SAAS,SAAS;AAAA,EACvC;AAEI,SAAO;AACX;AACA,SAAS,YAAY,QAAQ,QAAQ,OAAO,QAAQ,cAAc;AAE9D,MAAI,WAAW,YAAY;AACvB,mBAAe,OAAQ,iBAAkB,UAAU,0CAA0C,gBAAgB,YAAY;AACzH,WAAO,KAAK,YAAY;AACxB,WAAO;AAAA,EACf;AAEI,SAAO,KAAK,KAAM;AAElB,SAAO,WAAW,QAAQ,QAAQ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AO,KAAM,IAAI,KAAQ,GAAI;AAAA,IACzC;AAAA,EACA;AACI,SAAO,IAAI,WAAW,MAAM;AAChC;AAGA,SAAS,cAAc,YAAY;AAC/B,SAAO,WAAW,IAAI,CAAC,cAAc;AACjC,QAAI,aAAa,OAAQ;AACrB,aAAO,OAAO,aAAa,SAAS;AAAA,IAChD;AACQ,iBAAa;AACb,WAAO,OAAO,cAAgB,aAAa,KAAM,QAAS,QAAW,YAAY,QAAS,KAAQ;AAAA,EAC1G,CAAK,EAAE,KAAK,EAAE;AACd;AAQO,SAAS,aAAa,OAAO,SAAS;AACzC,SAAO,cAAc,kBAAkB,OAAO,OAAO,CAAC;AAC1D;","x_google_ignoreList":[0]}
|
|
@@ -1,5 +1,198 @@
|
|
|
1
|
-
|
|
1
|
+
var __typeError = (msg) => {
|
|
2
|
+
throw TypeError(msg);
|
|
3
|
+
};
|
|
4
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
5
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
6
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
7
|
+
var _AbiCoder_instances, getCoder_fn;
|
|
8
|
+
import { Writer, Reader } from "./standards-sdk.es54.js";
|
|
9
|
+
import { AddressCoder } from "./standards-sdk.es55.js";
|
|
10
|
+
import { ArrayCoder } from "./standards-sdk.es56.js";
|
|
11
|
+
import { BooleanCoder } from "./standards-sdk.es57.js";
|
|
12
|
+
import { BytesCoder } from "./standards-sdk.es58.js";
|
|
13
|
+
import { FixedBytesCoder } from "./standards-sdk.es59.js";
|
|
14
|
+
import { NullCoder } from "./standards-sdk.es60.js";
|
|
15
|
+
import { NumberCoder } from "./standards-sdk.es61.js";
|
|
16
|
+
import { StringCoder } from "./standards-sdk.es62.js";
|
|
17
|
+
import { TupleCoder } from "./standards-sdk.es63.js";
|
|
18
|
+
import { ParamType } from "./standards-sdk.es64.js";
|
|
19
|
+
import { assertArgument, assertArgumentCount, makeError } from "./standards-sdk.es49.js";
|
|
20
|
+
import { getBytes, hexlify } from "./standards-sdk.es48.js";
|
|
21
|
+
import { getAddress } from "./standards-sdk.es65.js";
|
|
22
|
+
const PanicReasons = /* @__PURE__ */ new Map();
|
|
23
|
+
PanicReasons.set(0, "GENERIC_PANIC");
|
|
24
|
+
PanicReasons.set(1, "ASSERT_FALSE");
|
|
25
|
+
PanicReasons.set(17, "OVERFLOW");
|
|
26
|
+
PanicReasons.set(18, "DIVIDE_BY_ZERO");
|
|
27
|
+
PanicReasons.set(33, "ENUM_RANGE_ERROR");
|
|
28
|
+
PanicReasons.set(34, "BAD_STORAGE_DATA");
|
|
29
|
+
PanicReasons.set(49, "STACK_UNDERFLOW");
|
|
30
|
+
PanicReasons.set(50, "ARRAY_RANGE_ERROR");
|
|
31
|
+
PanicReasons.set(65, "OUT_OF_MEMORY");
|
|
32
|
+
PanicReasons.set(81, "UNINITIALIZED_FUNCTION_CALL");
|
|
33
|
+
const paramTypeBytes = new RegExp(/^bytes([0-9]*)$/);
|
|
34
|
+
const paramTypeNumber = new RegExp(/^(u?int)([0-9]*)$/);
|
|
35
|
+
let defaultCoder = null;
|
|
36
|
+
let defaultMaxInflation = 1024;
|
|
37
|
+
function getBuiltinCallException(action, tx, data, abiCoder) {
|
|
38
|
+
let message = "missing revert data";
|
|
39
|
+
let reason = null;
|
|
40
|
+
const invocation = null;
|
|
41
|
+
let revert = null;
|
|
42
|
+
if (data) {
|
|
43
|
+
message = "execution reverted";
|
|
44
|
+
const bytes = getBytes(data);
|
|
45
|
+
data = hexlify(data);
|
|
46
|
+
if (bytes.length === 0) {
|
|
47
|
+
message += " (no data present; likely require(false) occurred";
|
|
48
|
+
reason = "require(false)";
|
|
49
|
+
} else if (bytes.length % 32 !== 4) {
|
|
50
|
+
message += " (could not decode reason; invalid data length)";
|
|
51
|
+
} else if (hexlify(bytes.slice(0, 4)) === "0x08c379a0") {
|
|
52
|
+
try {
|
|
53
|
+
reason = abiCoder.decode(["string"], bytes.slice(4))[0];
|
|
54
|
+
revert = {
|
|
55
|
+
signature: "Error(string)",
|
|
56
|
+
name: "Error",
|
|
57
|
+
args: [reason]
|
|
58
|
+
};
|
|
59
|
+
message += `: ${JSON.stringify(reason)}`;
|
|
60
|
+
} catch (error) {
|
|
61
|
+
message += " (could not decode reason; invalid string data)";
|
|
62
|
+
}
|
|
63
|
+
} else if (hexlify(bytes.slice(0, 4)) === "0x4e487b71") {
|
|
64
|
+
try {
|
|
65
|
+
const code = Number(abiCoder.decode(["uint256"], bytes.slice(4))[0]);
|
|
66
|
+
revert = {
|
|
67
|
+
signature: "Panic(uint256)",
|
|
68
|
+
name: "Panic",
|
|
69
|
+
args: [code]
|
|
70
|
+
};
|
|
71
|
+
reason = `Panic due to ${PanicReasons.get(code) || "UNKNOWN"}(${code})`;
|
|
72
|
+
message += `: ${reason}`;
|
|
73
|
+
} catch (error) {
|
|
74
|
+
message += " (could not decode panic code)";
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
message += " (unknown custom error)";
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const transaction = {
|
|
81
|
+
to: tx.to ? getAddress(tx.to) : null,
|
|
82
|
+
data: tx.data || "0x"
|
|
83
|
+
};
|
|
84
|
+
if (tx.from) {
|
|
85
|
+
transaction.from = getAddress(tx.from);
|
|
86
|
+
}
|
|
87
|
+
return makeError(message, "CALL_EXCEPTION", {
|
|
88
|
+
action,
|
|
89
|
+
data,
|
|
90
|
+
reason,
|
|
91
|
+
transaction,
|
|
92
|
+
invocation,
|
|
93
|
+
revert
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
const _AbiCoder = class _AbiCoder {
|
|
97
|
+
constructor() {
|
|
98
|
+
__privateAdd(this, _AbiCoder_instances);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get the default values for the given %%types%%.
|
|
102
|
+
*
|
|
103
|
+
* For example, a ``uint`` is by default ``0`` and ``bool``
|
|
104
|
+
* is by default ``false``.
|
|
105
|
+
*/
|
|
106
|
+
getDefaultValue(types) {
|
|
107
|
+
const coders = types.map((type) => __privateMethod(this, _AbiCoder_instances, getCoder_fn).call(this, ParamType.from(type)));
|
|
108
|
+
const coder = new TupleCoder(coders, "_");
|
|
109
|
+
return coder.defaultValue();
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Encode the %%values%% as the %%types%% into ABI data.
|
|
113
|
+
*
|
|
114
|
+
* @returns DataHexstring
|
|
115
|
+
*/
|
|
116
|
+
encode(types, values) {
|
|
117
|
+
assertArgumentCount(values.length, types.length, "types/values length mismatch");
|
|
118
|
+
const coders = types.map((type) => __privateMethod(this, _AbiCoder_instances, getCoder_fn).call(this, ParamType.from(type)));
|
|
119
|
+
const coder = new TupleCoder(coders, "_");
|
|
120
|
+
const writer = new Writer();
|
|
121
|
+
coder.encode(writer, values);
|
|
122
|
+
return writer.data;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Decode the ABI %%data%% as the %%types%% into values.
|
|
126
|
+
*
|
|
127
|
+
* If %%loose%% decoding is enabled, then strict padding is
|
|
128
|
+
* not enforced. Some older versions of Solidity incorrectly
|
|
129
|
+
* padded event data emitted from ``external`` functions.
|
|
130
|
+
*/
|
|
131
|
+
decode(types, data, loose) {
|
|
132
|
+
const coders = types.map((type) => __privateMethod(this, _AbiCoder_instances, getCoder_fn).call(this, ParamType.from(type)));
|
|
133
|
+
const coder = new TupleCoder(coders, "_");
|
|
134
|
+
return coder.decode(new Reader(data, loose, defaultMaxInflation));
|
|
135
|
+
}
|
|
136
|
+
static _setDefaultMaxInflation(value) {
|
|
137
|
+
assertArgument(typeof value === "number" && Number.isInteger(value), "invalid defaultMaxInflation factor", "value", value);
|
|
138
|
+
defaultMaxInflation = value;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Returns the shared singleton instance of a default [[AbiCoder]].
|
|
142
|
+
*
|
|
143
|
+
* On the first call, the instance is created internally.
|
|
144
|
+
*/
|
|
145
|
+
static defaultAbiCoder() {
|
|
146
|
+
if (defaultCoder == null) {
|
|
147
|
+
defaultCoder = new _AbiCoder();
|
|
148
|
+
}
|
|
149
|
+
return defaultCoder;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Returns an ethers-compatible [[CallExceptionError]] Error for the given
|
|
153
|
+
* result %%data%% for the [[CallExceptionAction]] %%action%% against
|
|
154
|
+
* the Transaction %%tx%%.
|
|
155
|
+
*/
|
|
156
|
+
static getBuiltinCallException(action, tx, data) {
|
|
157
|
+
return getBuiltinCallException(action, tx, data, _AbiCoder.defaultAbiCoder());
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
_AbiCoder_instances = new WeakSet();
|
|
161
|
+
getCoder_fn = function(param) {
|
|
162
|
+
if (param.isArray()) {
|
|
163
|
+
return new ArrayCoder(__privateMethod(this, _AbiCoder_instances, getCoder_fn).call(this, param.arrayChildren), param.arrayLength, param.name);
|
|
164
|
+
}
|
|
165
|
+
if (param.isTuple()) {
|
|
166
|
+
return new TupleCoder(param.components.map((c) => __privateMethod(this, _AbiCoder_instances, getCoder_fn).call(this, c)), param.name);
|
|
167
|
+
}
|
|
168
|
+
switch (param.baseType) {
|
|
169
|
+
case "address":
|
|
170
|
+
return new AddressCoder(param.name);
|
|
171
|
+
case "bool":
|
|
172
|
+
return new BooleanCoder(param.name);
|
|
173
|
+
case "string":
|
|
174
|
+
return new StringCoder(param.name);
|
|
175
|
+
case "bytes":
|
|
176
|
+
return new BytesCoder(param.name);
|
|
177
|
+
case "":
|
|
178
|
+
return new NullCoder(param.name);
|
|
179
|
+
}
|
|
180
|
+
let match = param.type.match(paramTypeNumber);
|
|
181
|
+
if (match) {
|
|
182
|
+
let size = parseInt(match[2] || "256");
|
|
183
|
+
assertArgument(size !== 0 && size <= 256 && size % 8 === 0, "invalid " + match[1] + " bit length", "param", param);
|
|
184
|
+
return new NumberCoder(size / 8, match[1] === "int", param.name);
|
|
185
|
+
}
|
|
186
|
+
match = param.type.match(paramTypeBytes);
|
|
187
|
+
if (match) {
|
|
188
|
+
let size = parseInt(match[1]);
|
|
189
|
+
assertArgument(size !== 0 && size <= 32, "invalid bytes length", "param", param);
|
|
190
|
+
return new FixedBytesCoder(size, param.name);
|
|
191
|
+
}
|
|
192
|
+
assertArgument(false, "invalid type", "type", param.type);
|
|
193
|
+
};
|
|
194
|
+
let AbiCoder = _AbiCoder;
|
|
2
195
|
export {
|
|
3
|
-
|
|
196
|
+
AbiCoder
|
|
4
197
|
};
|
|
5
198
|
//# sourceMappingURL=standards-sdk.es53.js.map
|