@hashgraphonline/standards-sdk 0.0.101 → 0.0.102
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/services/mirror-node.d.ts +102 -1
- package/dist/es/services/mirror-node.d.ts.map +1 -1
- package/dist/es/services/types.d.ts +53 -0
- package/dist/es/services/types.d.ts.map +1 -1
- package/dist/es/standards-sdk.es100.js +8 -62
- package/dist/es/standards-sdk.es100.js.map +1 -1
- package/dist/es/standards-sdk.es101.js +18 -6
- package/dist/es/standards-sdk.es101.js.map +1 -1
- package/dist/es/standards-sdk.es102.js +5 -14
- package/dist/es/standards-sdk.es102.js.map +1 -1
- package/dist/es/standards-sdk.es103.js +9 -7
- package/dist/es/standards-sdk.es103.js.map +1 -1
- package/dist/es/standards-sdk.es104.js +12 -44
- package/dist/es/standards-sdk.es104.js.map +1 -1
- package/dist/es/standards-sdk.es105.js +13 -2
- package/dist/es/standards-sdk.es105.js.map +1 -1
- package/dist/es/standards-sdk.es106.js +30 -134
- package/dist/es/standards-sdk.es106.js.map +1 -1
- package/dist/es/standards-sdk.es107.js +14 -171
- package/dist/es/standards-sdk.es107.js.map +1 -1
- package/dist/es/standards-sdk.es108.js +4 -13
- package/dist/es/standards-sdk.es108.js.map +1 -1
- package/dist/es/standards-sdk.es109.js +4 -13
- package/dist/es/standards-sdk.es109.js.map +1 -1
- package/dist/es/standards-sdk.es110.js +15 -31
- package/dist/es/standards-sdk.es110.js.map +1 -1
- package/dist/es/standards-sdk.es111.js +4 -14
- package/dist/es/standards-sdk.es111.js.map +1 -1
- package/dist/es/standards-sdk.es112.js +39 -4
- package/dist/es/standards-sdk.es112.js.map +1 -1
- package/dist/es/standards-sdk.es113.js +40 -4
- package/dist/es/standards-sdk.es113.js.map +1 -1
- package/dist/es/standards-sdk.es114.js +36 -15
- package/dist/es/standards-sdk.es114.js.map +1 -1
- package/dist/es/standards-sdk.es115.js +78 -5
- package/dist/es/standards-sdk.es115.js.map +1 -1
- package/dist/es/standards-sdk.es116.js +418 -38
- package/dist/es/standards-sdk.es116.js.map +1 -1
- package/dist/es/standards-sdk.es117.js +2 -40
- package/dist/es/standards-sdk.es117.js.map +1 -1
- package/dist/es/standards-sdk.es118.js +117 -34
- package/dist/es/standards-sdk.es118.js.map +1 -1
- package/dist/es/standards-sdk.es119.js +3 -78
- package/dist/es/standards-sdk.es119.js.map +1 -1
- package/dist/es/standards-sdk.es120.js +2 -3
- package/dist/es/standards-sdk.es120.js.map +1 -1
- package/dist/es/standards-sdk.es121.js +2 -2
- package/dist/es/standards-sdk.es121.js.map +1 -1
- package/dist/es/standards-sdk.es122.js +34 -2
- package/dist/es/standards-sdk.es122.js.map +1 -1
- package/dist/es/standards-sdk.es123.js +29 -30
- package/dist/es/standards-sdk.es123.js.map +1 -1
- package/dist/es/standards-sdk.es124.js +9 -33
- package/dist/es/standards-sdk.es124.js.map +1 -1
- package/dist/es/standards-sdk.es125.js +34 -9
- package/dist/es/standards-sdk.es125.js.map +1 -1
- package/dist/es/standards-sdk.es126.js +4 -34
- package/dist/es/standards-sdk.es126.js.map +1 -1
- package/dist/es/standards-sdk.es13.js +2 -2
- package/dist/es/standards-sdk.es18.js +2 -2
- package/dist/es/standards-sdk.es19.js.map +1 -1
- package/dist/es/standards-sdk.es21.js +505 -48
- package/dist/es/standards-sdk.es21.js.map +1 -1
- package/dist/es/standards-sdk.es24.js +10 -10
- package/dist/es/standards-sdk.es26.js +36 -3
- package/dist/es/standards-sdk.es26.js.map +1 -1
- package/dist/es/standards-sdk.es27.js +48 -4168
- package/dist/es/standards-sdk.es27.js.map +1 -1
- package/dist/es/standards-sdk.es28.js +1 -1
- package/dist/es/standards-sdk.es29.js +3 -9
- package/dist/es/standards-sdk.es29.js.map +1 -1
- package/dist/es/standards-sdk.es30.js +9 -2
- package/dist/es/standards-sdk.es30.js.map +1 -1
- package/dist/es/standards-sdk.es31.js +2 -36
- package/dist/es/standards-sdk.es31.js.map +1 -1
- package/dist/es/standards-sdk.es32.js +4168 -48
- package/dist/es/standards-sdk.es32.js.map +1 -1
- package/dist/es/standards-sdk.es33.js +2 -2
- package/dist/es/standards-sdk.es34.js +1 -1
- package/dist/es/standards-sdk.es35.js +2 -101
- package/dist/es/standards-sdk.es35.js.map +1 -1
- package/dist/es/standards-sdk.es36.js +84 -2
- package/dist/es/standards-sdk.es36.js.map +1 -1
- package/dist/es/standards-sdk.es37.js +22 -15
- package/dist/es/standards-sdk.es37.js.map +1 -1
- package/dist/es/standards-sdk.es38.js +138 -399
- package/dist/es/standards-sdk.es38.js.map +1 -1
- package/dist/es/standards-sdk.es39.js +91 -2
- package/dist/es/standards-sdk.es39.js.map +1 -1
- package/dist/es/standards-sdk.es40.js +174 -2282
- package/dist/es/standards-sdk.es40.js.map +1 -1
- package/dist/es/standards-sdk.es41.js +5 -163
- package/dist/es/standards-sdk.es41.js.map +1 -1
- package/dist/es/standards-sdk.es42.js +130 -71
- package/dist/es/standards-sdk.es42.js.map +1 -1
- package/dist/es/standards-sdk.es43.js +190 -18
- package/dist/es/standards-sdk.es43.js.map +1 -1
- package/dist/es/standards-sdk.es44.js +417 -127
- package/dist/es/standards-sdk.es44.js.map +1 -1
- package/dist/es/standards-sdk.es45.js +21 -87
- package/dist/es/standards-sdk.es45.js.map +1 -1
- package/dist/es/standards-sdk.es46.js +125 -181
- package/dist/es/standards-sdk.es46.js.map +1 -1
- package/dist/es/standards-sdk.es47.js +13 -433
- package/dist/es/standards-sdk.es47.js.map +1 -1
- package/dist/es/standards-sdk.es48.js +22 -18
- package/dist/es/standards-sdk.es48.js.map +1 -1
- package/dist/es/standards-sdk.es49.js +17 -127
- package/dist/es/standards-sdk.es49.js.map +1 -1
- package/dist/es/standards-sdk.es50.js +13 -10
- package/dist/es/standards-sdk.es50.js.map +1 -1
- package/dist/es/standards-sdk.es51.js +37 -22
- package/dist/es/standards-sdk.es51.js.map +1 -1
- package/dist/es/standards-sdk.es52.js +10 -21
- package/dist/es/standards-sdk.es52.js.map +1 -1
- package/dist/es/standards-sdk.es53.js +54 -14
- package/dist/es/standards-sdk.es53.js.map +1 -1
- package/dist/es/standards-sdk.es54.js +1284 -39
- package/dist/es/standards-sdk.es54.js.map +1 -1
- package/dist/es/standards-sdk.es55.js +29 -15
- package/dist/es/standards-sdk.es55.js.map +1 -1
- package/dist/es/standards-sdk.es56.js +149 -51
- package/dist/es/standards-sdk.es56.js.map +1 -1
- package/dist/es/standards-sdk.es57.js +629 -1125
- package/dist/es/standards-sdk.es57.js.map +1 -1
- package/dist/es/standards-sdk.es58.js +360 -28
- package/dist/es/standards-sdk.es58.js.map +1 -1
- package/dist/es/standards-sdk.es59.js +5 -5
- package/dist/es/standards-sdk.es59.js.map +1 -1
- package/dist/es/standards-sdk.es60.js +167 -147
- package/dist/es/standards-sdk.es60.js.map +1 -1
- package/dist/es/standards-sdk.es61.js +71 -783
- package/dist/es/standards-sdk.es61.js.map +1 -1
- package/dist/es/standards-sdk.es62.js +105 -165
- package/dist/es/standards-sdk.es62.js.map +1 -1
- package/dist/es/standards-sdk.es63.js +41 -132
- package/dist/es/standards-sdk.es63.js.map +1 -1
- package/dist/es/standards-sdk.es64.js +9 -20
- package/dist/es/standards-sdk.es64.js.map +1 -1
- package/dist/es/standards-sdk.es65.js +95 -25
- package/dist/es/standards-sdk.es65.js.map +1 -1
- package/dist/es/standards-sdk.es66.js +3 -25
- package/dist/es/standards-sdk.es66.js.map +1 -1
- package/dist/es/standards-sdk.es67.js +2 -38
- package/dist/es/standards-sdk.es67.js.map +1 -1
- package/dist/es/standards-sdk.es68.js +113 -3
- package/dist/es/standards-sdk.es68.js.map +1 -1
- package/dist/es/standards-sdk.es69.js +73 -3
- package/dist/es/standards-sdk.es69.js.map +1 -1
- package/dist/es/standards-sdk.es7.js +2 -2
- package/dist/es/standards-sdk.es70.js +4 -7134
- package/dist/es/standards-sdk.es70.js.map +1 -1
- package/dist/es/standards-sdk.es71.js +4 -9
- package/dist/es/standards-sdk.es71.js.map +1 -1
- package/dist/es/standards-sdk.es72.js +218 -8
- package/dist/es/standards-sdk.es72.js.map +1 -1
- package/dist/es/standards-sdk.es73.js +56 -16
- package/dist/es/standards-sdk.es73.js.map +1 -1
- package/dist/es/standards-sdk.es74.js +69 -6
- package/dist/es/standards-sdk.es74.js.map +1 -1
- package/dist/es/standards-sdk.es75.js +100 -8
- package/dist/es/standards-sdk.es75.js.map +1 -1
- package/dist/es/standards-sdk.es76.js +2 -419
- package/dist/es/standards-sdk.es76.js.map +1 -1
- package/dist/es/standards-sdk.es77.js +16 -2
- package/dist/es/standards-sdk.es77.js.map +1 -1
- package/dist/es/standards-sdk.es78.js +395 -106
- package/dist/es/standards-sdk.es78.js.map +1 -1
- package/dist/es/standards-sdk.es79.js +22 -359
- package/dist/es/standards-sdk.es79.js.map +1 -1
- package/dist/es/standards-sdk.es8.js +1 -1
- package/dist/es/standards-sdk.es80.js +25 -5
- package/dist/es/standards-sdk.es80.js.map +1 -1
- package/dist/es/standards-sdk.es81.js +36 -177
- package/dist/es/standards-sdk.es81.js.map +1 -1
- package/dist/es/standards-sdk.es82.js +16 -76
- package/dist/es/standards-sdk.es82.js.map +1 -1
- package/dist/es/standards-sdk.es83.js +2281 -113
- package/dist/es/standards-sdk.es83.js.map +1 -1
- package/dist/es/standards-sdk.es84.js +158 -46
- package/dist/es/standards-sdk.es84.js.map +1 -1
- package/dist/es/standards-sdk.es85.js +3 -10
- package/dist/es/standards-sdk.es85.js.map +1 -1
- package/dist/es/standards-sdk.es86.js +26 -91
- package/dist/es/standards-sdk.es86.js.map +1 -1
- package/dist/es/standards-sdk.es87.js +62 -3
- package/dist/es/standards-sdk.es87.js.map +1 -1
- package/dist/es/standards-sdk.es88.js +50 -2
- package/dist/es/standards-sdk.es88.js.map +1 -1
- package/dist/es/standards-sdk.es89.js +8 -111
- 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 +61 -70
- package/dist/es/standards-sdk.es90.js.map +1 -1
- package/dist/es/standards-sdk.es91.js +6 -6
- package/dist/es/standards-sdk.es91.js.map +1 -1
- package/dist/es/standards-sdk.es92.js +14 -4
- package/dist/es/standards-sdk.es92.js.map +1 -1
- package/dist/es/standards-sdk.es93.js +7 -221
- package/dist/es/standards-sdk.es93.js.map +1 -1
- package/dist/es/standards-sdk.es94.js +41 -54
- package/dist/es/standards-sdk.es94.js.map +1 -1
- package/dist/es/standards-sdk.es95.js +2 -69
- package/dist/es/standards-sdk.es95.js.map +1 -1
- package/dist/es/standards-sdk.es96.js +135 -31
- package/dist/es/standards-sdk.es96.js.map +1 -1
- package/dist/es/standards-sdk.es97.js +164 -55
- package/dist/es/standards-sdk.es97.js.map +1 -1
- package/dist/es/standards-sdk.es98.js +7131 -45
- package/dist/es/standards-sdk.es98.js.map +1 -1
- package/dist/es/standards-sdk.es99.js +9 -9
- package/dist/es/standards-sdk.es99.js.map +1 -1
- package/dist/umd/services/mirror-node.d.ts +102 -1
- package/dist/umd/services/mirror-node.d.ts.map +1 -1
- package/dist/umd/services/types.d.ts +53 -0
- package/dist/umd/services/types.d.ts.map +1 -1
- package/dist/umd/standards-sdk.umd.js +12 -12
- package/dist/umd/standards-sdk.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -8,1285 +8,789 @@ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot
|
|
|
8
8
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
9
9
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
10
10
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
import { defineProperties } from "./standards-sdk.es58.js";
|
|
23
|
-
import { id } from "./standards-sdk.es59.js";
|
|
24
|
-
import { getNumber, getBigInt } from "./standards-sdk.es60.js";
|
|
25
|
-
function setify(items) {
|
|
26
|
-
const result = /* @__PURE__ */ new Set();
|
|
27
|
-
items.forEach((k) => result.add(k));
|
|
28
|
-
return Object.freeze(result);
|
|
11
|
+
var _options;
|
|
12
|
+
import { assertPrivate } from "./standards-sdk.es38.js";
|
|
13
|
+
import { defineProperties } from "./standards-sdk.es55.js";
|
|
14
|
+
const _gaurd = {};
|
|
15
|
+
function n(value, width) {
|
|
16
|
+
let signed = false;
|
|
17
|
+
if (width < 0) {
|
|
18
|
+
signed = true;
|
|
19
|
+
width *= -1;
|
|
20
|
+
}
|
|
21
|
+
return new Typed(_gaurd, `${signed ? "" : "u"}int${width}`, value, { signed, width });
|
|
29
22
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const _TokenString = class _TokenString {
|
|
55
|
-
constructor(tokens) {
|
|
56
|
-
__privateAdd(this, _TokenString_instances);
|
|
57
|
-
__privateAdd(this, _offset);
|
|
58
|
-
__privateAdd(this, _tokens);
|
|
59
|
-
__privateSet(this, _offset, 0);
|
|
60
|
-
__privateSet(this, _tokens, tokens.slice());
|
|
61
|
-
}
|
|
62
|
-
get offset() {
|
|
63
|
-
return __privateGet(this, _offset);
|
|
64
|
-
}
|
|
65
|
-
get length() {
|
|
66
|
-
return __privateGet(this, _tokens).length - __privateGet(this, _offset);
|
|
67
|
-
}
|
|
68
|
-
clone() {
|
|
69
|
-
return new _TokenString(__privateGet(this, _tokens));
|
|
70
|
-
}
|
|
71
|
-
reset() {
|
|
72
|
-
__privateSet(this, _offset, 0);
|
|
73
|
-
}
|
|
74
|
-
// Pops and returns the value of the next token, if it is a keyword in allowed; throws if out of tokens
|
|
75
|
-
popKeyword(allowed) {
|
|
76
|
-
const top = this.peek();
|
|
77
|
-
if (top.type !== "KEYWORD" || !allowed.has(top.text)) {
|
|
78
|
-
throw new Error(`expected keyword ${top.text}`);
|
|
23
|
+
function b(value, size) {
|
|
24
|
+
return new Typed(_gaurd, `bytes${size ? size : ""}`, value, { size });
|
|
25
|
+
}
|
|
26
|
+
const _typedSymbol = Symbol.for("_ethers_typed");
|
|
27
|
+
const _Typed = class _Typed {
|
|
28
|
+
/**
|
|
29
|
+
* @_ignore:
|
|
30
|
+
*/
|
|
31
|
+
constructor(gaurd, type, value, options) {
|
|
32
|
+
/**
|
|
33
|
+
* The type, as a Solidity-compatible type.
|
|
34
|
+
*/
|
|
35
|
+
__publicField(this, "type");
|
|
36
|
+
/**
|
|
37
|
+
* The actual value.
|
|
38
|
+
*/
|
|
39
|
+
__publicField(this, "value");
|
|
40
|
+
__privateAdd(this, _options);
|
|
41
|
+
/**
|
|
42
|
+
* @_ignore:
|
|
43
|
+
*/
|
|
44
|
+
__publicField(this, "_typedSymbol");
|
|
45
|
+
if (options == null) {
|
|
46
|
+
options = null;
|
|
79
47
|
}
|
|
80
|
-
|
|
48
|
+
assertPrivate(_gaurd, gaurd, "Typed");
|
|
49
|
+
defineProperties(this, { _typedSymbol, type, value });
|
|
50
|
+
__privateSet(this, _options, options);
|
|
51
|
+
this.format();
|
|
81
52
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Format the type as a Human-Readable type.
|
|
55
|
+
*/
|
|
56
|
+
format() {
|
|
57
|
+
if (this.type === "array") {
|
|
58
|
+
throw new Error("");
|
|
59
|
+
} else if (this.type === "dynamicArray") {
|
|
60
|
+
throw new Error("");
|
|
61
|
+
} else if (this.type === "tuple") {
|
|
62
|
+
return `tuple(${this.value.map((v) => v.format()).join(",")})`;
|
|
87
63
|
}
|
|
88
|
-
return this.
|
|
64
|
+
return this.type;
|
|
89
65
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
const result = __privateMethod(this, _TokenString_instances, subTokenString_fn).call(this, __privateGet(this, _offset) + 1, top.match + 1);
|
|
97
|
-
__privateSet(this, _offset, top.match + 1);
|
|
98
|
-
return result;
|
|
99
|
-
}
|
|
100
|
-
// Pops and returns the items within "(" ITEM1 "," ITEM2 "," ... ")"
|
|
101
|
-
popParams() {
|
|
102
|
-
const top = this.peek();
|
|
103
|
-
if (top.type !== "OPEN_PAREN") {
|
|
104
|
-
throw new Error("bad start");
|
|
105
|
-
}
|
|
106
|
-
const result = [];
|
|
107
|
-
while (__privateGet(this, _offset) < top.match - 1) {
|
|
108
|
-
const link = this.peek().linkNext;
|
|
109
|
-
result.push(__privateMethod(this, _TokenString_instances, subTokenString_fn).call(this, __privateGet(this, _offset) + 1, link));
|
|
110
|
-
__privateSet(this, _offset, link);
|
|
111
|
-
}
|
|
112
|
-
__privateSet(this, _offset, top.match + 1);
|
|
113
|
-
return result;
|
|
66
|
+
/**
|
|
67
|
+
* The default value returned by this type.
|
|
68
|
+
*/
|
|
69
|
+
defaultValue() {
|
|
70
|
+
return 0;
|
|
114
71
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
72
|
+
/**
|
|
73
|
+
* The minimum value for numeric types.
|
|
74
|
+
*/
|
|
75
|
+
minValue() {
|
|
76
|
+
return 0;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The maximum value for numeric types.
|
|
80
|
+
*/
|
|
81
|
+
maxValue() {
|
|
82
|
+
return 0;
|
|
121
83
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Returns ``true`` and provides a type guard is this is a [[TypedBigInt]].
|
|
86
|
+
*/
|
|
87
|
+
isBigInt() {
|
|
88
|
+
return !!this.type.match(/^u?int[0-9]+$/);
|
|
126
89
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const top = this.peek();
|
|
133
|
-
return top.type === type ? top.text : null;
|
|
134
|
-
}
|
|
135
|
-
// Returns the next token; throws if out of tokens
|
|
136
|
-
pop() {
|
|
137
|
-
const result = this.peek();
|
|
138
|
-
__privateWrapper(this, _offset)._++;
|
|
139
|
-
return result;
|
|
140
|
-
}
|
|
141
|
-
toString() {
|
|
142
|
-
const tokens = [];
|
|
143
|
-
for (let i = __privateGet(this, _offset); i < __privateGet(this, _tokens).length; i++) {
|
|
144
|
-
const token = __privateGet(this, _tokens)[i];
|
|
145
|
-
tokens.push(`${token.type}:${token.text}`);
|
|
146
|
-
}
|
|
147
|
-
return `<TokenString ${tokens.join(" ")}>`;
|
|
90
|
+
/**
|
|
91
|
+
* Returns ``true`` and provides a type guard is this is a [[TypedData]].
|
|
92
|
+
*/
|
|
93
|
+
isData() {
|
|
94
|
+
return this.type.startsWith("bytes");
|
|
148
95
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
};
|
|
162
|
-
let TokenString = _TokenString;
|
|
163
|
-
function lex(text) {
|
|
164
|
-
const tokens = [];
|
|
165
|
-
const throwError = (message) => {
|
|
166
|
-
const token = offset < text.length ? JSON.stringify(text[offset]) : "$EOI";
|
|
167
|
-
throw new Error(`invalid token ${token} at ${offset}: ${message}`);
|
|
168
|
-
};
|
|
169
|
-
let brackets = [];
|
|
170
|
-
let commas = [];
|
|
171
|
-
let offset = 0;
|
|
172
|
-
while (offset < text.length) {
|
|
173
|
-
let cur = text.substring(offset);
|
|
174
|
-
let match = cur.match(regexWhitespacePrefix);
|
|
175
|
-
if (match) {
|
|
176
|
-
offset += match[1].length;
|
|
177
|
-
cur = text.substring(offset);
|
|
96
|
+
/**
|
|
97
|
+
* Returns ``true`` and provides a type guard is this is a [[TypedString]].
|
|
98
|
+
*/
|
|
99
|
+
isString() {
|
|
100
|
+
return this.type === "string";
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Returns the tuple name, if this is a tuple. Throws otherwise.
|
|
104
|
+
*/
|
|
105
|
+
get tupleName() {
|
|
106
|
+
if (this.type !== "tuple") {
|
|
107
|
+
throw TypeError("not a tuple");
|
|
178
108
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
token.match = brackets.pop();
|
|
194
|
-
tokens[token.match].match = tokens.length - 1;
|
|
195
|
-
token.depth--;
|
|
196
|
-
token.linkBack = commas.pop();
|
|
197
|
-
tokens[token.linkBack].linkNext = tokens.length - 1;
|
|
198
|
-
} else if (type === "COMMA") {
|
|
199
|
-
token.linkBack = commas.pop();
|
|
200
|
-
tokens[token.linkBack].linkNext = tokens.length - 1;
|
|
201
|
-
commas.push(tokens.length - 1);
|
|
202
|
-
} else if (type === "OPEN_BRACKET") {
|
|
203
|
-
token.type = "BRACKET";
|
|
204
|
-
} else if (type === "CLOSE_BRACKET") {
|
|
205
|
-
let suffix = tokens.pop().text;
|
|
206
|
-
if (tokens.length > 0 && tokens[tokens.length - 1].type === "NUMBER") {
|
|
207
|
-
const value = tokens.pop().text;
|
|
208
|
-
suffix = value + suffix;
|
|
209
|
-
tokens[tokens.length - 1].value = getNumber(value);
|
|
210
|
-
}
|
|
211
|
-
if (tokens.length === 0 || tokens[tokens.length - 1].type !== "BRACKET") {
|
|
212
|
-
throw new Error("missing opening bracket");
|
|
213
|
-
}
|
|
214
|
-
tokens[tokens.length - 1].text += suffix;
|
|
215
|
-
}
|
|
216
|
-
continue;
|
|
109
|
+
return __privateGet(this, _options);
|
|
110
|
+
}
|
|
111
|
+
// Returns the length of this type as an array
|
|
112
|
+
// - `null` indicates the length is unforced, it could be dynamic
|
|
113
|
+
// - `-1` indicates the length is dynamic
|
|
114
|
+
// - any other value indicates it is a static array and is its length
|
|
115
|
+
/**
|
|
116
|
+
* Returns the length of the array type or ``-1`` if it is dynamic.
|
|
117
|
+
*
|
|
118
|
+
* Throws if the type is not an array.
|
|
119
|
+
*/
|
|
120
|
+
get arrayLength() {
|
|
121
|
+
if (this.type !== "array") {
|
|
122
|
+
throw TypeError("not an array");
|
|
217
123
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
token.text = match[1];
|
|
221
|
-
offset += token.text.length;
|
|
222
|
-
if (Keywords.has(token.text)) {
|
|
223
|
-
token.type = "KEYWORD";
|
|
224
|
-
continue;
|
|
225
|
-
}
|
|
226
|
-
if (token.text.match(regexType)) {
|
|
227
|
-
token.type = "TYPE";
|
|
228
|
-
continue;
|
|
229
|
-
}
|
|
230
|
-
token.type = "ID";
|
|
231
|
-
continue;
|
|
124
|
+
if (__privateGet(this, _options) === true) {
|
|
125
|
+
return -1;
|
|
232
126
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
token.text = match[1];
|
|
236
|
-
token.type = "NUMBER";
|
|
237
|
-
offset += token.text.length;
|
|
238
|
-
continue;
|
|
127
|
+
if (__privateGet(this, _options) === false) {
|
|
128
|
+
return this.value.length;
|
|
239
129
|
}
|
|
240
|
-
|
|
130
|
+
return null;
|
|
241
131
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
if (set.has(key)) {
|
|
248
|
-
included.push(key);
|
|
249
|
-
}
|
|
132
|
+
/**
|
|
133
|
+
* Returns a new **Typed** of %%type%% with the %%value%%.
|
|
134
|
+
*/
|
|
135
|
+
static from(type, value) {
|
|
136
|
+
return new _Typed(_gaurd, type, value);
|
|
250
137
|
}
|
|
251
|
-
|
|
252
|
-
|
|
138
|
+
/**
|
|
139
|
+
* Return a new ``uint8`` type for %%v%%.
|
|
140
|
+
*/
|
|
141
|
+
static uint8(v) {
|
|
142
|
+
return n(v, 8);
|
|
253
143
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
throw new Error(`expected ${type}, got ${keyword}`);
|
|
260
|
-
}
|
|
144
|
+
/**
|
|
145
|
+
* Return a new ``uint16`` type for %%v%%.
|
|
146
|
+
*/
|
|
147
|
+
static uint16(v) {
|
|
148
|
+
return n(v, 16);
|
|
261
149
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
const keyword = tokens.peekType("KEYWORD");
|
|
268
|
-
if (keyword == null || allowed && !allowed.has(keyword)) {
|
|
269
|
-
break;
|
|
270
|
-
}
|
|
271
|
-
tokens.pop();
|
|
272
|
-
if (keywords.has(keyword)) {
|
|
273
|
-
throw new Error(`duplicate keywords: ${JSON.stringify(keyword)}`);
|
|
274
|
-
}
|
|
275
|
-
keywords.add(keyword);
|
|
150
|
+
/**
|
|
151
|
+
* Return a new ``uint24`` type for %%v%%.
|
|
152
|
+
*/
|
|
153
|
+
static uint24(v) {
|
|
154
|
+
return n(v, 24);
|
|
276
155
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
allowSingle(modifiers, setify("pure view payable nonpayable".split(" ")));
|
|
283
|
-
if (modifiers.has("view")) {
|
|
284
|
-
return "view";
|
|
156
|
+
/**
|
|
157
|
+
* Return a new ``uint32`` type for %%v%%.
|
|
158
|
+
*/
|
|
159
|
+
static uint32(v) {
|
|
160
|
+
return n(v, 32);
|
|
285
161
|
}
|
|
286
|
-
|
|
287
|
-
|
|
162
|
+
/**
|
|
163
|
+
* Return a new ``uint40`` type for %%v%%.
|
|
164
|
+
*/
|
|
165
|
+
static uint40(v) {
|
|
166
|
+
return n(v, 40);
|
|
288
167
|
}
|
|
289
|
-
|
|
290
|
-
|
|
168
|
+
/**
|
|
169
|
+
* Return a new ``uint48`` type for %%v%%.
|
|
170
|
+
*/
|
|
171
|
+
static uint48(v) {
|
|
172
|
+
return n(v, 48);
|
|
291
173
|
}
|
|
292
|
-
|
|
293
|
-
|
|
174
|
+
/**
|
|
175
|
+
* Return a new ``uint56`` type for %%v%%.
|
|
176
|
+
*/
|
|
177
|
+
static uint56(v) {
|
|
178
|
+
return n(v, 56);
|
|
294
179
|
}
|
|
295
|
-
|
|
296
|
-
|
|
180
|
+
/**
|
|
181
|
+
* Return a new ``uint64`` type for %%v%%.
|
|
182
|
+
*/
|
|
183
|
+
static uint64(v) {
|
|
184
|
+
return n(v, 64);
|
|
297
185
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
function consumeGas(tokens) {
|
|
304
|
-
if (tokens.peekType("AT")) {
|
|
305
|
-
tokens.pop();
|
|
306
|
-
if (tokens.peekType("NUMBER")) {
|
|
307
|
-
return getBigInt(tokens.pop().text);
|
|
308
|
-
}
|
|
309
|
-
throw new Error("invalid gas");
|
|
186
|
+
/**
|
|
187
|
+
* Return a new ``uint72`` type for %%v%%.
|
|
188
|
+
*/
|
|
189
|
+
static uint72(v) {
|
|
190
|
+
return n(v, 72);
|
|
310
191
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
192
|
+
/**
|
|
193
|
+
* Return a new ``uint80`` type for %%v%%.
|
|
194
|
+
*/
|
|
195
|
+
static uint80(v) {
|
|
196
|
+
return n(v, 80);
|
|
316
197
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
function verifyBasicType(type) {
|
|
320
|
-
const match = type.match(regexType);
|
|
321
|
-
assertArgument(match, "invalid type", "type", type);
|
|
322
|
-
if (type === "uint") {
|
|
323
|
-
return "uint256";
|
|
324
|
-
}
|
|
325
|
-
if (type === "int") {
|
|
326
|
-
return "int256";
|
|
327
|
-
}
|
|
328
|
-
if (match[2]) {
|
|
329
|
-
const length = parseInt(match[2]);
|
|
330
|
-
assertArgument(length !== 0 && length <= 32, "invalid bytes length", "type", type);
|
|
331
|
-
} else if (match[3]) {
|
|
332
|
-
const size = parseInt(match[3]);
|
|
333
|
-
assertArgument(size !== 0 && size <= 256 && size % 8 === 0, "invalid numeric width", "type", type);
|
|
334
|
-
}
|
|
335
|
-
return type;
|
|
336
|
-
}
|
|
337
|
-
const _guard = {};
|
|
338
|
-
const internal = Symbol.for("_ethers_internal");
|
|
339
|
-
const ParamTypeInternal = "_ParamTypeInternal";
|
|
340
|
-
const ErrorFragmentInternal = "_ErrorInternal";
|
|
341
|
-
const EventFragmentInternal = "_EventInternal";
|
|
342
|
-
const ConstructorFragmentInternal = "_ConstructorInternal";
|
|
343
|
-
const FallbackFragmentInternal = "_FallbackInternal";
|
|
344
|
-
const FunctionFragmentInternal = "_FunctionInternal";
|
|
345
|
-
const StructFragmentInternal = "_StructInternal";
|
|
346
|
-
const _ParamType = class _ParamType {
|
|
347
|
-
/**
|
|
348
|
-
* @private
|
|
349
|
-
*/
|
|
350
|
-
constructor(guard, name, type, baseType, indexed, components, arrayLength, arrayChildren) {
|
|
351
|
-
__privateAdd(this, _ParamType_instances);
|
|
352
|
-
/**
|
|
353
|
-
* The local name of the parameter (or ``""`` if unbound)
|
|
354
|
-
*/
|
|
355
|
-
__publicField(this, "name");
|
|
356
|
-
/**
|
|
357
|
-
* The fully qualified type (e.g. ``"address"``, ``"tuple(address)"``,
|
|
358
|
-
* ``"uint256[3][]"``)
|
|
359
|
-
*/
|
|
360
|
-
__publicField(this, "type");
|
|
361
|
-
/**
|
|
362
|
-
* The base type (e.g. ``"address"``, ``"tuple"``, ``"array"``)
|
|
363
|
-
*/
|
|
364
|
-
__publicField(this, "baseType");
|
|
365
|
-
/**
|
|
366
|
-
* True if the parameters is indexed.
|
|
367
|
-
*
|
|
368
|
-
* For non-indexable types this is ``null``.
|
|
369
|
-
*/
|
|
370
|
-
__publicField(this, "indexed");
|
|
371
|
-
/**
|
|
372
|
-
* The components for the tuple.
|
|
373
|
-
*
|
|
374
|
-
* For non-tuple types this is ``null``.
|
|
375
|
-
*/
|
|
376
|
-
__publicField(this, "components");
|
|
377
|
-
/**
|
|
378
|
-
* The array length, or ``-1`` for dynamic-lengthed arrays.
|
|
379
|
-
*
|
|
380
|
-
* For non-array types this is ``null``.
|
|
381
|
-
*/
|
|
382
|
-
__publicField(this, "arrayLength");
|
|
383
|
-
/**
|
|
384
|
-
* The type of each child in the array.
|
|
385
|
-
*
|
|
386
|
-
* For non-array types this is ``null``.
|
|
387
|
-
*/
|
|
388
|
-
__publicField(this, "arrayChildren");
|
|
389
|
-
assertPrivate(guard, _guard, "ParamType");
|
|
390
|
-
Object.defineProperty(this, internal, { value: ParamTypeInternal });
|
|
391
|
-
if (components) {
|
|
392
|
-
components = Object.freeze(components.slice());
|
|
393
|
-
}
|
|
394
|
-
if (baseType === "array") {
|
|
395
|
-
if (arrayLength == null || arrayChildren == null) {
|
|
396
|
-
throw new Error("");
|
|
397
|
-
}
|
|
398
|
-
} else if (arrayLength != null || arrayChildren != null) {
|
|
399
|
-
throw new Error("");
|
|
400
|
-
}
|
|
401
|
-
if (baseType === "tuple") {
|
|
402
|
-
if (components == null) {
|
|
403
|
-
throw new Error("");
|
|
404
|
-
}
|
|
405
|
-
} else if (components != null) {
|
|
406
|
-
throw new Error("");
|
|
407
|
-
}
|
|
408
|
-
defineProperties(this, {
|
|
409
|
-
name,
|
|
410
|
-
type,
|
|
411
|
-
baseType,
|
|
412
|
-
indexed,
|
|
413
|
-
components,
|
|
414
|
-
arrayLength,
|
|
415
|
-
arrayChildren
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
|
-
/**
|
|
419
|
-
* Return a string representation of this type.
|
|
420
|
-
*
|
|
421
|
-
* For example,
|
|
422
|
-
*
|
|
423
|
-
* ``sighash" => "(uint256,address)"``
|
|
424
|
-
*
|
|
425
|
-
* ``"minimal" => "tuple(uint256,address) indexed"``
|
|
426
|
-
*
|
|
427
|
-
* ``"full" => "tuple(uint256 foo, address bar) indexed baz"``
|
|
198
|
+
/**
|
|
199
|
+
* Return a new ``uint88`` type for %%v%%.
|
|
428
200
|
*/
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
format = "sighash";
|
|
432
|
-
}
|
|
433
|
-
if (format === "json") {
|
|
434
|
-
const name = this.name || "";
|
|
435
|
-
if (this.isArray()) {
|
|
436
|
-
const result3 = JSON.parse(this.arrayChildren.format("json"));
|
|
437
|
-
result3.name = name;
|
|
438
|
-
result3.type += `[${this.arrayLength < 0 ? "" : String(this.arrayLength)}]`;
|
|
439
|
-
return JSON.stringify(result3);
|
|
440
|
-
}
|
|
441
|
-
const result2 = {
|
|
442
|
-
type: this.baseType === "tuple" ? "tuple" : this.type,
|
|
443
|
-
name
|
|
444
|
-
};
|
|
445
|
-
if (typeof this.indexed === "boolean") {
|
|
446
|
-
result2.indexed = this.indexed;
|
|
447
|
-
}
|
|
448
|
-
if (this.isTuple()) {
|
|
449
|
-
result2.components = this.components.map((c) => JSON.parse(c.format(format)));
|
|
450
|
-
}
|
|
451
|
-
return JSON.stringify(result2);
|
|
452
|
-
}
|
|
453
|
-
let result = "";
|
|
454
|
-
if (this.isArray()) {
|
|
455
|
-
result += this.arrayChildren.format(format);
|
|
456
|
-
result += `[${this.arrayLength < 0 ? "" : String(this.arrayLength)}]`;
|
|
457
|
-
} else {
|
|
458
|
-
if (this.isTuple()) {
|
|
459
|
-
result += "(" + this.components.map((comp) => comp.format(format)).join(format === "full" ? ", " : ",") + ")";
|
|
460
|
-
} else {
|
|
461
|
-
result += this.type;
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
if (format !== "sighash") {
|
|
465
|
-
if (this.indexed === true) {
|
|
466
|
-
result += " indexed";
|
|
467
|
-
}
|
|
468
|
-
if (format === "full" && this.name) {
|
|
469
|
-
result += " " + this.name;
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
return result;
|
|
201
|
+
static uint88(v) {
|
|
202
|
+
return n(v, 88);
|
|
473
203
|
}
|
|
474
204
|
/**
|
|
475
|
-
*
|
|
476
|
-
*
|
|
477
|
-
* This provides a type gaurd ensuring that [[arrayChildren]]
|
|
478
|
-
* and [[arrayLength]] are non-null.
|
|
205
|
+
* Return a new ``uint96`` type for %%v%%.
|
|
479
206
|
*/
|
|
480
|
-
|
|
481
|
-
return
|
|
207
|
+
static uint96(v) {
|
|
208
|
+
return n(v, 96);
|
|
482
209
|
}
|
|
483
210
|
/**
|
|
484
|
-
*
|
|
485
|
-
*
|
|
486
|
-
* This provides a type gaurd ensuring that [[components]]
|
|
487
|
-
* is non-null.
|
|
211
|
+
* Return a new ``uint104`` type for %%v%%.
|
|
488
212
|
*/
|
|
489
|
-
|
|
490
|
-
return
|
|
213
|
+
static uint104(v) {
|
|
214
|
+
return n(v, 104);
|
|
491
215
|
}
|
|
492
216
|
/**
|
|
493
|
-
*
|
|
494
|
-
*
|
|
495
|
-
* This provides a type gaurd ensuring that [[indexed]]
|
|
496
|
-
* is non-null.
|
|
217
|
+
* Return a new ``uint112`` type for %%v%%.
|
|
497
218
|
*/
|
|
498
|
-
|
|
499
|
-
return
|
|
219
|
+
static uint112(v) {
|
|
220
|
+
return n(v, 112);
|
|
500
221
|
}
|
|
501
222
|
/**
|
|
502
|
-
*
|
|
503
|
-
* on each type, destructing the %%value%% recursively.
|
|
223
|
+
* Return a new ``uint120`` type for %%v%%.
|
|
504
224
|
*/
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
if (!Array.isArray(value)) {
|
|
508
|
-
throw new Error("invalid array value");
|
|
509
|
-
}
|
|
510
|
-
if (this.arrayLength !== -1 && value.length !== this.arrayLength) {
|
|
511
|
-
throw new Error("array is wrong length");
|
|
512
|
-
}
|
|
513
|
-
const _this = this;
|
|
514
|
-
return value.map((v) => _this.arrayChildren.walk(v, process));
|
|
515
|
-
}
|
|
516
|
-
if (this.isTuple()) {
|
|
517
|
-
if (!Array.isArray(value)) {
|
|
518
|
-
throw new Error("invalid tuple value");
|
|
519
|
-
}
|
|
520
|
-
if (value.length !== this.components.length) {
|
|
521
|
-
throw new Error("array is wrong length");
|
|
522
|
-
}
|
|
523
|
-
const _this = this;
|
|
524
|
-
return value.map((v, i) => _this.components[i].walk(v, process));
|
|
525
|
-
}
|
|
526
|
-
return process(this.type, value);
|
|
225
|
+
static uint120(v) {
|
|
226
|
+
return n(v, 120);
|
|
527
227
|
}
|
|
528
228
|
/**
|
|
529
|
-
*
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
* ``"address"`` type.
|
|
534
|
-
*/
|
|
535
|
-
async walkAsync(value, process) {
|
|
536
|
-
const promises = [];
|
|
537
|
-
const result = [value];
|
|
538
|
-
__privateMethod(this, _ParamType_instances, walkAsync_fn).call(this, promises, value, process, (value2) => {
|
|
539
|
-
result[0] = value2;
|
|
540
|
-
});
|
|
541
|
-
if (promises.length) {
|
|
542
|
-
await Promise.all(promises);
|
|
543
|
-
}
|
|
544
|
-
return result[0];
|
|
229
|
+
* Return a new ``uint128`` type for %%v%%.
|
|
230
|
+
*/
|
|
231
|
+
static uint128(v) {
|
|
232
|
+
return n(v, 128);
|
|
545
233
|
}
|
|
546
234
|
/**
|
|
547
|
-
*
|
|
548
|
-
*
|
|
549
|
-
* If %%allowIndexed%% then the ``indexed`` keyword is permitted,
|
|
550
|
-
* otherwise the ``indexed`` keyword will throw an error.
|
|
235
|
+
* Return a new ``uint136`` type for %%v%%.
|
|
551
236
|
*/
|
|
552
|
-
static
|
|
553
|
-
|
|
554
|
-
return obj;
|
|
555
|
-
}
|
|
556
|
-
if (typeof obj === "string") {
|
|
557
|
-
try {
|
|
558
|
-
return _ParamType.from(lex(obj), allowIndexed);
|
|
559
|
-
} catch (error) {
|
|
560
|
-
assertArgument(false, "invalid param type", "obj", obj);
|
|
561
|
-
}
|
|
562
|
-
} else if (obj instanceof TokenString) {
|
|
563
|
-
let type2 = "", baseType = "";
|
|
564
|
-
let comps = null;
|
|
565
|
-
if (consumeKeywords(obj, setify(["tuple"])).has("tuple") || obj.peekType("OPEN_PAREN")) {
|
|
566
|
-
baseType = "tuple";
|
|
567
|
-
comps = obj.popParams().map((t) => _ParamType.from(t));
|
|
568
|
-
type2 = `tuple(${comps.map((c) => c.format()).join(",")})`;
|
|
569
|
-
} else {
|
|
570
|
-
type2 = verifyBasicType(obj.popType("TYPE"));
|
|
571
|
-
baseType = type2;
|
|
572
|
-
}
|
|
573
|
-
let arrayChildren = null;
|
|
574
|
-
let arrayLength = null;
|
|
575
|
-
while (obj.length && obj.peekType("BRACKET")) {
|
|
576
|
-
const bracket = obj.pop();
|
|
577
|
-
arrayChildren = new _ParamType(_guard, "", type2, baseType, null, comps, arrayLength, arrayChildren);
|
|
578
|
-
arrayLength = bracket.value;
|
|
579
|
-
type2 += bracket.text;
|
|
580
|
-
baseType = "array";
|
|
581
|
-
comps = null;
|
|
582
|
-
}
|
|
583
|
-
let indexed2 = null;
|
|
584
|
-
const keywords = consumeKeywords(obj, KwModifiers);
|
|
585
|
-
if (keywords.has("indexed")) {
|
|
586
|
-
if (!allowIndexed) {
|
|
587
|
-
throw new Error("");
|
|
588
|
-
}
|
|
589
|
-
indexed2 = true;
|
|
590
|
-
}
|
|
591
|
-
const name2 = obj.peekType("ID") ? obj.pop().text : "";
|
|
592
|
-
if (obj.length) {
|
|
593
|
-
throw new Error("leftover tokens");
|
|
594
|
-
}
|
|
595
|
-
return new _ParamType(_guard, name2, type2, baseType, indexed2, comps, arrayLength, arrayChildren);
|
|
596
|
-
}
|
|
597
|
-
const name = obj.name;
|
|
598
|
-
assertArgument(!name || typeof name === "string" && name.match(regexId), "invalid name", "obj.name", name);
|
|
599
|
-
let indexed = obj.indexed;
|
|
600
|
-
if (indexed != null) {
|
|
601
|
-
assertArgument(allowIndexed, "parameter cannot be indexed", "obj.indexed", obj.indexed);
|
|
602
|
-
indexed = !!indexed;
|
|
603
|
-
}
|
|
604
|
-
let type = obj.type;
|
|
605
|
-
let arrayMatch = type.match(regexArrayType);
|
|
606
|
-
if (arrayMatch) {
|
|
607
|
-
const arrayLength = parseInt(arrayMatch[2] || "-1");
|
|
608
|
-
const arrayChildren = _ParamType.from({
|
|
609
|
-
type: arrayMatch[1],
|
|
610
|
-
components: obj.components
|
|
611
|
-
});
|
|
612
|
-
return new _ParamType(_guard, name || "", type, "array", indexed, null, arrayLength, arrayChildren);
|
|
613
|
-
}
|
|
614
|
-
if (type === "tuple" || type.startsWith(
|
|
615
|
-
"tuple("
|
|
616
|
-
/* fix: ) */
|
|
617
|
-
) || type.startsWith(
|
|
618
|
-
"("
|
|
619
|
-
/* fix: ) */
|
|
620
|
-
)) {
|
|
621
|
-
const comps = obj.components != null ? obj.components.map((c) => _ParamType.from(c)) : null;
|
|
622
|
-
const tuple = new _ParamType(_guard, name || "", type, "tuple", indexed, comps, null, null);
|
|
623
|
-
return tuple;
|
|
624
|
-
}
|
|
625
|
-
type = verifyBasicType(obj.type);
|
|
626
|
-
return new _ParamType(_guard, name || "", type, type, indexed, null, null, null);
|
|
237
|
+
static uint136(v) {
|
|
238
|
+
return n(v, 136);
|
|
627
239
|
}
|
|
628
240
|
/**
|
|
629
|
-
*
|
|
241
|
+
* Return a new ``uint144`` type for %%v%%.
|
|
630
242
|
*/
|
|
631
|
-
static
|
|
632
|
-
return
|
|
243
|
+
static uint144(v) {
|
|
244
|
+
return n(v, 144);
|
|
633
245
|
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
throw new Error("invalid array value");
|
|
640
|
-
}
|
|
641
|
-
if (this.arrayLength !== -1 && value.length !== this.arrayLength) {
|
|
642
|
-
throw new Error("array is wrong length");
|
|
643
|
-
}
|
|
644
|
-
const childType = this.arrayChildren;
|
|
645
|
-
const result2 = value.slice();
|
|
646
|
-
result2.forEach((value2, index) => {
|
|
647
|
-
var _a;
|
|
648
|
-
__privateMethod(_a = childType, _ParamType_instances, walkAsync_fn).call(_a, promises, value2, process, (value3) => {
|
|
649
|
-
result2[index] = value3;
|
|
650
|
-
});
|
|
651
|
-
});
|
|
652
|
-
setValue(result2);
|
|
653
|
-
return;
|
|
654
|
-
}
|
|
655
|
-
if (this.isTuple()) {
|
|
656
|
-
const components = this.components;
|
|
657
|
-
let result2;
|
|
658
|
-
if (Array.isArray(value)) {
|
|
659
|
-
result2 = value.slice();
|
|
660
|
-
} else {
|
|
661
|
-
if (value == null || typeof value !== "object") {
|
|
662
|
-
throw new Error("invalid tuple value");
|
|
663
|
-
}
|
|
664
|
-
result2 = components.map((param) => {
|
|
665
|
-
if (!param.name) {
|
|
666
|
-
throw new Error("cannot use object value with unnamed components");
|
|
667
|
-
}
|
|
668
|
-
if (!(param.name in value)) {
|
|
669
|
-
throw new Error(`missing value for component ${param.name}`);
|
|
670
|
-
}
|
|
671
|
-
return value[param.name];
|
|
672
|
-
});
|
|
673
|
-
}
|
|
674
|
-
if (result2.length !== this.components.length) {
|
|
675
|
-
throw new Error("array is wrong length");
|
|
676
|
-
}
|
|
677
|
-
result2.forEach((value2, index) => {
|
|
678
|
-
var _a;
|
|
679
|
-
__privateMethod(_a = components[index], _ParamType_instances, walkAsync_fn).call(_a, promises, value2, process, (value3) => {
|
|
680
|
-
result2[index] = value3;
|
|
681
|
-
});
|
|
682
|
-
});
|
|
683
|
-
setValue(result2);
|
|
684
|
-
return;
|
|
685
|
-
}
|
|
686
|
-
const result = process(this.type, value);
|
|
687
|
-
if (result.then) {
|
|
688
|
-
promises.push(async function() {
|
|
689
|
-
setValue(await result);
|
|
690
|
-
}());
|
|
691
|
-
} else {
|
|
692
|
-
setValue(result);
|
|
246
|
+
/**
|
|
247
|
+
* Return a new ``uint152`` type for %%v%%.
|
|
248
|
+
*/
|
|
249
|
+
static uint152(v) {
|
|
250
|
+
return n(v, 152);
|
|
693
251
|
}
|
|
694
|
-
};
|
|
695
|
-
let ParamType = _ParamType;
|
|
696
|
-
class Fragment {
|
|
697
252
|
/**
|
|
698
|
-
*
|
|
253
|
+
* Return a new ``uint160`` type for %%v%%.
|
|
699
254
|
*/
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
* The type of the fragment.
|
|
703
|
-
*/
|
|
704
|
-
__publicField(this, "type");
|
|
705
|
-
/**
|
|
706
|
-
* The inputs for the fragment.
|
|
707
|
-
*/
|
|
708
|
-
__publicField(this, "inputs");
|
|
709
|
-
assertPrivate(guard, _guard, "Fragment");
|
|
710
|
-
inputs = Object.freeze(inputs.slice());
|
|
711
|
-
defineProperties(this, { type, inputs });
|
|
255
|
+
static uint160(v) {
|
|
256
|
+
return n(v, 160);
|
|
712
257
|
}
|
|
713
258
|
/**
|
|
714
|
-
*
|
|
715
|
-
* ABI frgament type.
|
|
259
|
+
* Return a new ``uint168`` type for %%v%%.
|
|
716
260
|
*/
|
|
717
|
-
static
|
|
718
|
-
|
|
719
|
-
try {
|
|
720
|
-
Fragment.from(JSON.parse(obj));
|
|
721
|
-
} catch (e) {
|
|
722
|
-
}
|
|
723
|
-
return Fragment.from(lex(obj));
|
|
724
|
-
}
|
|
725
|
-
if (obj instanceof TokenString) {
|
|
726
|
-
const type = obj.peekKeyword(KwTypes);
|
|
727
|
-
switch (type) {
|
|
728
|
-
case "constructor":
|
|
729
|
-
return ConstructorFragment.from(obj);
|
|
730
|
-
case "error":
|
|
731
|
-
return ErrorFragment.from(obj);
|
|
732
|
-
case "event":
|
|
733
|
-
return EventFragment.from(obj);
|
|
734
|
-
case "fallback":
|
|
735
|
-
case "receive":
|
|
736
|
-
return FallbackFragment.from(obj);
|
|
737
|
-
case "function":
|
|
738
|
-
return FunctionFragment.from(obj);
|
|
739
|
-
case "struct":
|
|
740
|
-
return StructFragment.from(obj);
|
|
741
|
-
}
|
|
742
|
-
} else if (typeof obj === "object") {
|
|
743
|
-
switch (obj.type) {
|
|
744
|
-
case "constructor":
|
|
745
|
-
return ConstructorFragment.from(obj);
|
|
746
|
-
case "error":
|
|
747
|
-
return ErrorFragment.from(obj);
|
|
748
|
-
case "event":
|
|
749
|
-
return EventFragment.from(obj);
|
|
750
|
-
case "fallback":
|
|
751
|
-
case "receive":
|
|
752
|
-
return FallbackFragment.from(obj);
|
|
753
|
-
case "function":
|
|
754
|
-
return FunctionFragment.from(obj);
|
|
755
|
-
case "struct":
|
|
756
|
-
return StructFragment.from(obj);
|
|
757
|
-
}
|
|
758
|
-
assert(false, `unsupported type: ${obj.type}`, "UNSUPPORTED_OPERATION", {
|
|
759
|
-
operation: "Fragment.from"
|
|
760
|
-
});
|
|
761
|
-
}
|
|
762
|
-
assertArgument(false, "unsupported frgament object", "obj", obj);
|
|
261
|
+
static uint168(v) {
|
|
262
|
+
return n(v, 168);
|
|
763
263
|
}
|
|
764
264
|
/**
|
|
765
|
-
*
|
|
265
|
+
* Return a new ``uint176`` type for %%v%%.
|
|
766
266
|
*/
|
|
767
|
-
static
|
|
768
|
-
return
|
|
267
|
+
static uint176(v) {
|
|
268
|
+
return n(v, 176);
|
|
769
269
|
}
|
|
770
270
|
/**
|
|
771
|
-
*
|
|
271
|
+
* Return a new ``uint184`` type for %%v%%.
|
|
772
272
|
*/
|
|
773
|
-
static
|
|
774
|
-
return
|
|
273
|
+
static uint184(v) {
|
|
274
|
+
return n(v, 184);
|
|
775
275
|
}
|
|
776
276
|
/**
|
|
777
|
-
*
|
|
277
|
+
* Return a new ``uint192`` type for %%v%%.
|
|
778
278
|
*/
|
|
779
|
-
static
|
|
780
|
-
return
|
|
279
|
+
static uint192(v) {
|
|
280
|
+
return n(v, 192);
|
|
781
281
|
}
|
|
782
282
|
/**
|
|
783
|
-
*
|
|
283
|
+
* Return a new ``uint200`` type for %%v%%.
|
|
784
284
|
*/
|
|
785
|
-
static
|
|
786
|
-
return
|
|
285
|
+
static uint200(v) {
|
|
286
|
+
return n(v, 200);
|
|
787
287
|
}
|
|
788
288
|
/**
|
|
789
|
-
*
|
|
289
|
+
* Return a new ``uint208`` type for %%v%%.
|
|
790
290
|
*/
|
|
791
|
-
static
|
|
792
|
-
return
|
|
291
|
+
static uint208(v) {
|
|
292
|
+
return n(v, 208);
|
|
793
293
|
}
|
|
794
|
-
}
|
|
795
|
-
class NamedFragment extends Fragment {
|
|
796
294
|
/**
|
|
797
|
-
*
|
|
295
|
+
* Return a new ``uint216`` type for %%v%%.
|
|
798
296
|
*/
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
/**
|
|
802
|
-
* The name of the fragment.
|
|
803
|
-
*/
|
|
804
|
-
__publicField(this, "name");
|
|
805
|
-
assertArgument(typeof name === "string" && name.match(regexId), "invalid identifier", "name", name);
|
|
806
|
-
inputs = Object.freeze(inputs.slice());
|
|
807
|
-
defineProperties(this, { name });
|
|
297
|
+
static uint216(v) {
|
|
298
|
+
return n(v, 216);
|
|
808
299
|
}
|
|
809
|
-
}
|
|
810
|
-
function joinParams(format, params) {
|
|
811
|
-
return "(" + params.map((p) => p.format(format)).join(format === "full" ? ", " : ",") + ")";
|
|
812
|
-
}
|
|
813
|
-
class ErrorFragment extends NamedFragment {
|
|
814
300
|
/**
|
|
815
|
-
*
|
|
301
|
+
* Return a new ``uint224`` type for %%v%%.
|
|
816
302
|
*/
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
Object.defineProperty(this, internal, { value: ErrorFragmentInternal });
|
|
303
|
+
static uint224(v) {
|
|
304
|
+
return n(v, 224);
|
|
820
305
|
}
|
|
821
306
|
/**
|
|
822
|
-
*
|
|
307
|
+
* Return a new ``uint232`` type for %%v%%.
|
|
823
308
|
*/
|
|
824
|
-
|
|
825
|
-
return
|
|
309
|
+
static uint232(v) {
|
|
310
|
+
return n(v, 232);
|
|
826
311
|
}
|
|
827
312
|
/**
|
|
828
|
-
*
|
|
313
|
+
* Return a new ``uint240`` type for %%v%%.
|
|
829
314
|
*/
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
format = "sighash";
|
|
833
|
-
}
|
|
834
|
-
if (format === "json") {
|
|
835
|
-
return JSON.stringify({
|
|
836
|
-
type: "error",
|
|
837
|
-
name: this.name,
|
|
838
|
-
inputs: this.inputs.map((input) => JSON.parse(input.format(format)))
|
|
839
|
-
});
|
|
840
|
-
}
|
|
841
|
-
const result = [];
|
|
842
|
-
if (format !== "sighash") {
|
|
843
|
-
result.push("error");
|
|
844
|
-
}
|
|
845
|
-
result.push(this.name + joinParams(format, this.inputs));
|
|
846
|
-
return result.join(" ");
|
|
315
|
+
static uint240(v) {
|
|
316
|
+
return n(v, 240);
|
|
847
317
|
}
|
|
848
318
|
/**
|
|
849
|
-
*
|
|
319
|
+
* Return a new ``uint248`` type for %%v%%.
|
|
850
320
|
*/
|
|
851
|
-
static
|
|
852
|
-
|
|
853
|
-
return obj;
|
|
854
|
-
}
|
|
855
|
-
if (typeof obj === "string") {
|
|
856
|
-
return ErrorFragment.from(lex(obj));
|
|
857
|
-
} else if (obj instanceof TokenString) {
|
|
858
|
-
const name = consumeName("error", obj);
|
|
859
|
-
const inputs = consumeParams(obj);
|
|
860
|
-
consumeEoi(obj);
|
|
861
|
-
return new ErrorFragment(_guard, name, inputs);
|
|
862
|
-
}
|
|
863
|
-
return new ErrorFragment(_guard, obj.name, obj.inputs ? obj.inputs.map(ParamType.from) : []);
|
|
321
|
+
static uint248(v) {
|
|
322
|
+
return n(v, 248);
|
|
864
323
|
}
|
|
865
324
|
/**
|
|
866
|
-
*
|
|
867
|
-
* **ErrorFragment**.
|
|
325
|
+
* Return a new ``uint256`` type for %%v%%.
|
|
868
326
|
*/
|
|
869
|
-
static
|
|
870
|
-
return
|
|
327
|
+
static uint256(v) {
|
|
328
|
+
return n(v, 256);
|
|
871
329
|
}
|
|
872
|
-
}
|
|
873
|
-
class EventFragment extends NamedFragment {
|
|
874
330
|
/**
|
|
875
|
-
*
|
|
331
|
+
* Return a new ``uint256`` type for %%v%%.
|
|
876
332
|
*/
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
/**
|
|
880
|
-
* Whether this event is anonymous.
|
|
881
|
-
*/
|
|
882
|
-
__publicField(this, "anonymous");
|
|
883
|
-
Object.defineProperty(this, internal, { value: EventFragmentInternal });
|
|
884
|
-
defineProperties(this, { anonymous });
|
|
333
|
+
static uint(v) {
|
|
334
|
+
return n(v, 256);
|
|
885
335
|
}
|
|
886
336
|
/**
|
|
887
|
-
*
|
|
337
|
+
* Return a new ``int8`` type for %%v%%.
|
|
888
338
|
*/
|
|
889
|
-
|
|
890
|
-
return
|
|
339
|
+
static int8(v) {
|
|
340
|
+
return n(v, -8);
|
|
891
341
|
}
|
|
892
342
|
/**
|
|
893
|
-
*
|
|
343
|
+
* Return a new ``int16`` type for %%v%%.
|
|
894
344
|
*/
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
format = "sighash";
|
|
898
|
-
}
|
|
899
|
-
if (format === "json") {
|
|
900
|
-
return JSON.stringify({
|
|
901
|
-
type: "event",
|
|
902
|
-
anonymous: this.anonymous,
|
|
903
|
-
name: this.name,
|
|
904
|
-
inputs: this.inputs.map((i) => JSON.parse(i.format(format)))
|
|
905
|
-
});
|
|
906
|
-
}
|
|
907
|
-
const result = [];
|
|
908
|
-
if (format !== "sighash") {
|
|
909
|
-
result.push("event");
|
|
910
|
-
}
|
|
911
|
-
result.push(this.name + joinParams(format, this.inputs));
|
|
912
|
-
if (format !== "sighash" && this.anonymous) {
|
|
913
|
-
result.push("anonymous");
|
|
914
|
-
}
|
|
915
|
-
return result.join(" ");
|
|
345
|
+
static int16(v) {
|
|
346
|
+
return n(v, -16);
|
|
916
347
|
}
|
|
917
348
|
/**
|
|
918
|
-
* Return
|
|
349
|
+
* Return a new ``int24`` type for %%v%%.
|
|
919
350
|
*/
|
|
920
|
-
static
|
|
921
|
-
|
|
922
|
-
const fragment = new EventFragment(_guard, name, params, false);
|
|
923
|
-
return fragment.topicHash;
|
|
351
|
+
static int24(v) {
|
|
352
|
+
return n(v, -24);
|
|
924
353
|
}
|
|
925
354
|
/**
|
|
926
|
-
*
|
|
355
|
+
* Return a new ``int32`` type for %%v%%.
|
|
927
356
|
*/
|
|
928
|
-
static
|
|
929
|
-
|
|
930
|
-
return obj;
|
|
931
|
-
}
|
|
932
|
-
if (typeof obj === "string") {
|
|
933
|
-
try {
|
|
934
|
-
return EventFragment.from(lex(obj));
|
|
935
|
-
} catch (error) {
|
|
936
|
-
assertArgument(false, "invalid event fragment", "obj", obj);
|
|
937
|
-
}
|
|
938
|
-
} else if (obj instanceof TokenString) {
|
|
939
|
-
const name = consumeName("event", obj);
|
|
940
|
-
const inputs = consumeParams(obj, true);
|
|
941
|
-
const anonymous = !!consumeKeywords(obj, setify(["anonymous"])).has("anonymous");
|
|
942
|
-
consumeEoi(obj);
|
|
943
|
-
return new EventFragment(_guard, name, inputs, anonymous);
|
|
944
|
-
}
|
|
945
|
-
return new EventFragment(_guard, obj.name, obj.inputs ? obj.inputs.map((p) => ParamType.from(p, true)) : [], !!obj.anonymous);
|
|
357
|
+
static int32(v) {
|
|
358
|
+
return n(v, -32);
|
|
946
359
|
}
|
|
947
360
|
/**
|
|
948
|
-
*
|
|
949
|
-
* **EventFragment**.
|
|
361
|
+
* Return a new ``int40`` type for %%v%%.
|
|
950
362
|
*/
|
|
951
|
-
static
|
|
952
|
-
return
|
|
363
|
+
static int40(v) {
|
|
364
|
+
return n(v, -40);
|
|
953
365
|
}
|
|
954
|
-
}
|
|
955
|
-
class ConstructorFragment extends Fragment {
|
|
956
366
|
/**
|
|
957
|
-
*
|
|
367
|
+
* Return a new ``int48`` type for %%v%%.
|
|
958
368
|
*/
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
/**
|
|
962
|
-
* Whether the constructor can receive an endowment.
|
|
963
|
-
*/
|
|
964
|
-
__publicField(this, "payable");
|
|
965
|
-
/**
|
|
966
|
-
* The recommended gas limit for deployment or ``null``.
|
|
967
|
-
*/
|
|
968
|
-
__publicField(this, "gas");
|
|
969
|
-
Object.defineProperty(this, internal, { value: ConstructorFragmentInternal });
|
|
970
|
-
defineProperties(this, { payable, gas });
|
|
971
|
-
}
|
|
972
|
-
/**
|
|
973
|
-
* Returns a string representation of this constructor as %%format%%.
|
|
974
|
-
*/
|
|
975
|
-
format(format) {
|
|
976
|
-
assert(format != null && format !== "sighash", "cannot format a constructor for sighash", "UNSUPPORTED_OPERATION", { operation: "format(sighash)" });
|
|
977
|
-
if (format === "json") {
|
|
978
|
-
return JSON.stringify({
|
|
979
|
-
type: "constructor",
|
|
980
|
-
stateMutability: this.payable ? "payable" : "undefined",
|
|
981
|
-
payable: this.payable,
|
|
982
|
-
gas: this.gas != null ? this.gas : void 0,
|
|
983
|
-
inputs: this.inputs.map((i) => JSON.parse(i.format(format)))
|
|
984
|
-
});
|
|
985
|
-
}
|
|
986
|
-
const result = [`constructor${joinParams(format, this.inputs)}`];
|
|
987
|
-
if (this.payable) {
|
|
988
|
-
result.push("payable");
|
|
989
|
-
}
|
|
990
|
-
if (this.gas != null) {
|
|
991
|
-
result.push(`@${this.gas.toString()}`);
|
|
992
|
-
}
|
|
993
|
-
return result.join(" ");
|
|
369
|
+
static int48(v) {
|
|
370
|
+
return n(v, -48);
|
|
994
371
|
}
|
|
995
372
|
/**
|
|
996
|
-
*
|
|
373
|
+
* Return a new ``int56`` type for %%v%%.
|
|
997
374
|
*/
|
|
998
|
-
static
|
|
999
|
-
|
|
1000
|
-
return obj;
|
|
1001
|
-
}
|
|
1002
|
-
if (typeof obj === "string") {
|
|
1003
|
-
try {
|
|
1004
|
-
return ConstructorFragment.from(lex(obj));
|
|
1005
|
-
} catch (error) {
|
|
1006
|
-
assertArgument(false, "invalid constuctor fragment", "obj", obj);
|
|
1007
|
-
}
|
|
1008
|
-
} else if (obj instanceof TokenString) {
|
|
1009
|
-
consumeKeywords(obj, setify(["constructor"]));
|
|
1010
|
-
const inputs = consumeParams(obj);
|
|
1011
|
-
const payable = !!consumeKeywords(obj, KwVisibDeploy).has("payable");
|
|
1012
|
-
const gas = consumeGas(obj);
|
|
1013
|
-
consumeEoi(obj);
|
|
1014
|
-
return new ConstructorFragment(_guard, "constructor", inputs, payable, gas);
|
|
1015
|
-
}
|
|
1016
|
-
return new ConstructorFragment(_guard, "constructor", obj.inputs ? obj.inputs.map(ParamType.from) : [], !!obj.payable, obj.gas != null ? obj.gas : null);
|
|
375
|
+
static int56(v) {
|
|
376
|
+
return n(v, -56);
|
|
1017
377
|
}
|
|
1018
378
|
/**
|
|
1019
|
-
*
|
|
1020
|
-
* **ConstructorFragment**.
|
|
379
|
+
* Return a new ``int64`` type for %%v%%.
|
|
1021
380
|
*/
|
|
1022
|
-
static
|
|
1023
|
-
return
|
|
381
|
+
static int64(v) {
|
|
382
|
+
return n(v, -64);
|
|
1024
383
|
}
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
* If the function can be sent value during invocation.
|
|
1031
|
-
*/
|
|
1032
|
-
__publicField(this, "payable");
|
|
1033
|
-
Object.defineProperty(this, internal, { value: FallbackFragmentInternal });
|
|
1034
|
-
defineProperties(this, { payable });
|
|
384
|
+
/**
|
|
385
|
+
* Return a new ``int72`` type for %%v%%.
|
|
386
|
+
*/
|
|
387
|
+
static int72(v) {
|
|
388
|
+
return n(v, -72);
|
|
1035
389
|
}
|
|
1036
390
|
/**
|
|
1037
|
-
*
|
|
391
|
+
* Return a new ``int80`` type for %%v%%.
|
|
1038
392
|
*/
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
if (format === "json") {
|
|
1042
|
-
const stateMutability = this.payable ? "payable" : "nonpayable";
|
|
1043
|
-
return JSON.stringify({ type, stateMutability });
|
|
1044
|
-
}
|
|
1045
|
-
return `${type}()${this.payable ? " payable" : ""}`;
|
|
393
|
+
static int80(v) {
|
|
394
|
+
return n(v, -80);
|
|
1046
395
|
}
|
|
1047
396
|
/**
|
|
1048
|
-
*
|
|
397
|
+
* Return a new ``int88`` type for %%v%%.
|
|
1049
398
|
*/
|
|
1050
|
-
static
|
|
1051
|
-
|
|
1052
|
-
return obj;
|
|
1053
|
-
}
|
|
1054
|
-
if (typeof obj === "string") {
|
|
1055
|
-
try {
|
|
1056
|
-
return FallbackFragment.from(lex(obj));
|
|
1057
|
-
} catch (error) {
|
|
1058
|
-
assertArgument(false, "invalid fallback fragment", "obj", obj);
|
|
1059
|
-
}
|
|
1060
|
-
} else if (obj instanceof TokenString) {
|
|
1061
|
-
const errorObj = obj.toString();
|
|
1062
|
-
const topIsValid = obj.peekKeyword(setify(["fallback", "receive"]));
|
|
1063
|
-
assertArgument(topIsValid, "type must be fallback or receive", "obj", errorObj);
|
|
1064
|
-
const type = obj.popKeyword(setify(["fallback", "receive"]));
|
|
1065
|
-
if (type === "receive") {
|
|
1066
|
-
const inputs2 = consumeParams(obj);
|
|
1067
|
-
assertArgument(inputs2.length === 0, `receive cannot have arguments`, "obj.inputs", inputs2);
|
|
1068
|
-
consumeKeywords(obj, setify(["payable"]));
|
|
1069
|
-
consumeEoi(obj);
|
|
1070
|
-
return new FallbackFragment(_guard, [], true);
|
|
1071
|
-
}
|
|
1072
|
-
let inputs = consumeParams(obj);
|
|
1073
|
-
if (inputs.length) {
|
|
1074
|
-
assertArgument(inputs.length === 1 && inputs[0].type === "bytes", "invalid fallback inputs", "obj.inputs", inputs.map((i) => i.format("minimal")).join(", "));
|
|
1075
|
-
} else {
|
|
1076
|
-
inputs = [ParamType.from("bytes")];
|
|
1077
|
-
}
|
|
1078
|
-
const mutability = consumeMutability(obj);
|
|
1079
|
-
assertArgument(mutability === "nonpayable" || mutability === "payable", "fallback cannot be constants", "obj.stateMutability", mutability);
|
|
1080
|
-
if (consumeKeywords(obj, setify(["returns"])).has("returns")) {
|
|
1081
|
-
const outputs = consumeParams(obj);
|
|
1082
|
-
assertArgument(outputs.length === 1 && outputs[0].type === "bytes", "invalid fallback outputs", "obj.outputs", outputs.map((i) => i.format("minimal")).join(", "));
|
|
1083
|
-
}
|
|
1084
|
-
consumeEoi(obj);
|
|
1085
|
-
return new FallbackFragment(_guard, inputs, mutability === "payable");
|
|
1086
|
-
}
|
|
1087
|
-
if (obj.type === "receive") {
|
|
1088
|
-
return new FallbackFragment(_guard, [], true);
|
|
1089
|
-
}
|
|
1090
|
-
if (obj.type === "fallback") {
|
|
1091
|
-
const inputs = [ParamType.from("bytes")];
|
|
1092
|
-
const payable = obj.stateMutability === "payable";
|
|
1093
|
-
return new FallbackFragment(_guard, inputs, payable);
|
|
1094
|
-
}
|
|
1095
|
-
assertArgument(false, "invalid fallback description", "obj", obj);
|
|
399
|
+
static int88(v) {
|
|
400
|
+
return n(v, -88);
|
|
1096
401
|
}
|
|
1097
402
|
/**
|
|
1098
|
-
*
|
|
1099
|
-
* **FallbackFragment**.
|
|
403
|
+
* Return a new ``int96`` type for %%v%%.
|
|
1100
404
|
*/
|
|
1101
|
-
static
|
|
1102
|
-
return
|
|
405
|
+
static int96(v) {
|
|
406
|
+
return n(v, -96);
|
|
1103
407
|
}
|
|
1104
|
-
}
|
|
1105
|
-
class FunctionFragment extends NamedFragment {
|
|
1106
408
|
/**
|
|
1107
|
-
*
|
|
409
|
+
* Return a new ``int104`` type for %%v%%.
|
|
1108
410
|
*/
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
/**
|
|
1112
|
-
* If the function is constant (e.g. ``pure`` or ``view`` functions).
|
|
1113
|
-
*/
|
|
1114
|
-
__publicField(this, "constant");
|
|
1115
|
-
/**
|
|
1116
|
-
* The returned types for the result of calling this function.
|
|
1117
|
-
*/
|
|
1118
|
-
__publicField(this, "outputs");
|
|
1119
|
-
/**
|
|
1120
|
-
* The state mutability (e.g. ``payable``, ``nonpayable``, ``view``
|
|
1121
|
-
* or ``pure``)
|
|
1122
|
-
*/
|
|
1123
|
-
__publicField(this, "stateMutability");
|
|
1124
|
-
/**
|
|
1125
|
-
* If the function can be sent value during invocation.
|
|
1126
|
-
*/
|
|
1127
|
-
__publicField(this, "payable");
|
|
1128
|
-
/**
|
|
1129
|
-
* The recommended gas limit to send when calling this function.
|
|
1130
|
-
*/
|
|
1131
|
-
__publicField(this, "gas");
|
|
1132
|
-
Object.defineProperty(this, internal, { value: FunctionFragmentInternal });
|
|
1133
|
-
outputs = Object.freeze(outputs.slice());
|
|
1134
|
-
const constant = stateMutability === "view" || stateMutability === "pure";
|
|
1135
|
-
const payable = stateMutability === "payable";
|
|
1136
|
-
defineProperties(this, { constant, gas, outputs, payable, stateMutability });
|
|
411
|
+
static int104(v) {
|
|
412
|
+
return n(v, -104);
|
|
1137
413
|
}
|
|
1138
414
|
/**
|
|
1139
|
-
*
|
|
415
|
+
* Return a new ``int112`` type for %%v%%.
|
|
1140
416
|
*/
|
|
1141
|
-
|
|
1142
|
-
return
|
|
417
|
+
static int112(v) {
|
|
418
|
+
return n(v, -112);
|
|
1143
419
|
}
|
|
1144
420
|
/**
|
|
1145
|
-
*
|
|
421
|
+
* Return a new ``int120`` type for %%v%%.
|
|
1146
422
|
*/
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
format = "sighash";
|
|
1150
|
-
}
|
|
1151
|
-
if (format === "json") {
|
|
1152
|
-
return JSON.stringify({
|
|
1153
|
-
type: "function",
|
|
1154
|
-
name: this.name,
|
|
1155
|
-
constant: this.constant,
|
|
1156
|
-
stateMutability: this.stateMutability !== "nonpayable" ? this.stateMutability : void 0,
|
|
1157
|
-
payable: this.payable,
|
|
1158
|
-
gas: this.gas != null ? this.gas : void 0,
|
|
1159
|
-
inputs: this.inputs.map((i) => JSON.parse(i.format(format))),
|
|
1160
|
-
outputs: this.outputs.map((o) => JSON.parse(o.format(format)))
|
|
1161
|
-
});
|
|
1162
|
-
}
|
|
1163
|
-
const result = [];
|
|
1164
|
-
if (format !== "sighash") {
|
|
1165
|
-
result.push("function");
|
|
1166
|
-
}
|
|
1167
|
-
result.push(this.name + joinParams(format, this.inputs));
|
|
1168
|
-
if (format !== "sighash") {
|
|
1169
|
-
if (this.stateMutability !== "nonpayable") {
|
|
1170
|
-
result.push(this.stateMutability);
|
|
1171
|
-
}
|
|
1172
|
-
if (this.outputs && this.outputs.length) {
|
|
1173
|
-
result.push("returns");
|
|
1174
|
-
result.push(joinParams(format, this.outputs));
|
|
1175
|
-
}
|
|
1176
|
-
if (this.gas != null) {
|
|
1177
|
-
result.push(`@${this.gas.toString()}`);
|
|
1178
|
-
}
|
|
1179
|
-
}
|
|
1180
|
-
return result.join(" ");
|
|
423
|
+
static int120(v) {
|
|
424
|
+
return n(v, -120);
|
|
1181
425
|
}
|
|
1182
426
|
/**
|
|
1183
|
-
* Return
|
|
427
|
+
* Return a new ``int128`` type for %%v%%.
|
|
1184
428
|
*/
|
|
1185
|
-
static
|
|
1186
|
-
|
|
1187
|
-
const fragment = new FunctionFragment(_guard, name, "view", params, [], null);
|
|
1188
|
-
return fragment.selector;
|
|
429
|
+
static int128(v) {
|
|
430
|
+
return n(v, -128);
|
|
1189
431
|
}
|
|
1190
432
|
/**
|
|
1191
|
-
*
|
|
433
|
+
* Return a new ``int136`` type for %%v%%.
|
|
1192
434
|
*/
|
|
1193
|
-
static
|
|
1194
|
-
|
|
1195
|
-
return obj;
|
|
1196
|
-
}
|
|
1197
|
-
if (typeof obj === "string") {
|
|
1198
|
-
try {
|
|
1199
|
-
return FunctionFragment.from(lex(obj));
|
|
1200
|
-
} catch (error) {
|
|
1201
|
-
assertArgument(false, "invalid function fragment", "obj", obj);
|
|
1202
|
-
}
|
|
1203
|
-
} else if (obj instanceof TokenString) {
|
|
1204
|
-
const name = consumeName("function", obj);
|
|
1205
|
-
const inputs = consumeParams(obj);
|
|
1206
|
-
const mutability = consumeMutability(obj);
|
|
1207
|
-
let outputs = [];
|
|
1208
|
-
if (consumeKeywords(obj, setify(["returns"])).has("returns")) {
|
|
1209
|
-
outputs = consumeParams(obj);
|
|
1210
|
-
}
|
|
1211
|
-
const gas = consumeGas(obj);
|
|
1212
|
-
consumeEoi(obj);
|
|
1213
|
-
return new FunctionFragment(_guard, name, mutability, inputs, outputs, gas);
|
|
1214
|
-
}
|
|
1215
|
-
let stateMutability = obj.stateMutability;
|
|
1216
|
-
if (stateMutability == null) {
|
|
1217
|
-
stateMutability = "payable";
|
|
1218
|
-
if (typeof obj.constant === "boolean") {
|
|
1219
|
-
stateMutability = "view";
|
|
1220
|
-
if (!obj.constant) {
|
|
1221
|
-
stateMutability = "payable";
|
|
1222
|
-
if (typeof obj.payable === "boolean" && !obj.payable) {
|
|
1223
|
-
stateMutability = "nonpayable";
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
} else if (typeof obj.payable === "boolean" && !obj.payable) {
|
|
1227
|
-
stateMutability = "nonpayable";
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
return new FunctionFragment(_guard, obj.name, stateMutability, obj.inputs ? obj.inputs.map(ParamType.from) : [], obj.outputs ? obj.outputs.map(ParamType.from) : [], obj.gas != null ? obj.gas : null);
|
|
435
|
+
static int136(v) {
|
|
436
|
+
return n(v, -136);
|
|
1231
437
|
}
|
|
1232
438
|
/**
|
|
1233
|
-
*
|
|
1234
|
-
* **FunctionFragment**.
|
|
439
|
+
* Return a new ``int144`` type for %%v%%.
|
|
1235
440
|
*/
|
|
1236
|
-
static
|
|
1237
|
-
return
|
|
441
|
+
static int144(v) {
|
|
442
|
+
return n(v, -144);
|
|
1238
443
|
}
|
|
1239
|
-
}
|
|
1240
|
-
class StructFragment extends NamedFragment {
|
|
1241
444
|
/**
|
|
1242
|
-
*
|
|
445
|
+
* Return a new ``int52`` type for %%v%%.
|
|
1243
446
|
*/
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
Object.defineProperty(this, internal, { value: StructFragmentInternal });
|
|
447
|
+
static int152(v) {
|
|
448
|
+
return n(v, -152);
|
|
1247
449
|
}
|
|
1248
450
|
/**
|
|
1249
|
-
*
|
|
451
|
+
* Return a new ``int160`` type for %%v%%.
|
|
1250
452
|
*/
|
|
1251
|
-
|
|
1252
|
-
|
|
453
|
+
static int160(v) {
|
|
454
|
+
return n(v, -160);
|
|
1253
455
|
}
|
|
1254
456
|
/**
|
|
1255
|
-
*
|
|
457
|
+
* Return a new ``int168`` type for %%v%%.
|
|
1256
458
|
*/
|
|
1257
|
-
static
|
|
1258
|
-
|
|
1259
|
-
try {
|
|
1260
|
-
return StructFragment.from(lex(obj));
|
|
1261
|
-
} catch (error) {
|
|
1262
|
-
assertArgument(false, "invalid struct fragment", "obj", obj);
|
|
1263
|
-
}
|
|
1264
|
-
} else if (obj instanceof TokenString) {
|
|
1265
|
-
const name = consumeName("struct", obj);
|
|
1266
|
-
const inputs = consumeParams(obj);
|
|
1267
|
-
consumeEoi(obj);
|
|
1268
|
-
return new StructFragment(_guard, name, inputs);
|
|
1269
|
-
}
|
|
1270
|
-
return new StructFragment(_guard, obj.name, obj.inputs ? obj.inputs.map(ParamType.from) : []);
|
|
459
|
+
static int168(v) {
|
|
460
|
+
return n(v, -168);
|
|
1271
461
|
}
|
|
1272
|
-
// @TODO: fix this return type
|
|
1273
462
|
/**
|
|
1274
|
-
*
|
|
1275
|
-
* **StructFragment**.
|
|
463
|
+
* Return a new ``int176`` type for %%v%%.
|
|
1276
464
|
*/
|
|
1277
|
-
static
|
|
1278
|
-
return
|
|
465
|
+
static int176(v) {
|
|
466
|
+
return n(v, -176);
|
|
1279
467
|
}
|
|
1280
|
-
|
|
468
|
+
/**
|
|
469
|
+
* Return a new ``int184`` type for %%v%%.
|
|
470
|
+
*/
|
|
471
|
+
static int184(v) {
|
|
472
|
+
return n(v, -184);
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Return a new ``int92`` type for %%v%%.
|
|
476
|
+
*/
|
|
477
|
+
static int192(v) {
|
|
478
|
+
return n(v, -192);
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Return a new ``int200`` type for %%v%%.
|
|
482
|
+
*/
|
|
483
|
+
static int200(v) {
|
|
484
|
+
return n(v, -200);
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Return a new ``int208`` type for %%v%%.
|
|
488
|
+
*/
|
|
489
|
+
static int208(v) {
|
|
490
|
+
return n(v, -208);
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Return a new ``int216`` type for %%v%%.
|
|
494
|
+
*/
|
|
495
|
+
static int216(v) {
|
|
496
|
+
return n(v, -216);
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Return a new ``int224`` type for %%v%%.
|
|
500
|
+
*/
|
|
501
|
+
static int224(v) {
|
|
502
|
+
return n(v, -224);
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Return a new ``int232`` type for %%v%%.
|
|
506
|
+
*/
|
|
507
|
+
static int232(v) {
|
|
508
|
+
return n(v, -232);
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Return a new ``int240`` type for %%v%%.
|
|
512
|
+
*/
|
|
513
|
+
static int240(v) {
|
|
514
|
+
return n(v, -240);
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Return a new ``int248`` type for %%v%%.
|
|
518
|
+
*/
|
|
519
|
+
static int248(v) {
|
|
520
|
+
return n(v, -248);
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Return a new ``int256`` type for %%v%%.
|
|
524
|
+
*/
|
|
525
|
+
static int256(v) {
|
|
526
|
+
return n(v, -256);
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Return a new ``int256`` type for %%v%%.
|
|
530
|
+
*/
|
|
531
|
+
static int(v) {
|
|
532
|
+
return n(v, -256);
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Return a new ``bytes1`` type for %%v%%.
|
|
536
|
+
*/
|
|
537
|
+
static bytes1(v) {
|
|
538
|
+
return b(v, 1);
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Return a new ``bytes2`` type for %%v%%.
|
|
542
|
+
*/
|
|
543
|
+
static bytes2(v) {
|
|
544
|
+
return b(v, 2);
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Return a new ``bytes3`` type for %%v%%.
|
|
548
|
+
*/
|
|
549
|
+
static bytes3(v) {
|
|
550
|
+
return b(v, 3);
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Return a new ``bytes4`` type for %%v%%.
|
|
554
|
+
*/
|
|
555
|
+
static bytes4(v) {
|
|
556
|
+
return b(v, 4);
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* Return a new ``bytes5`` type for %%v%%.
|
|
560
|
+
*/
|
|
561
|
+
static bytes5(v) {
|
|
562
|
+
return b(v, 5);
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Return a new ``bytes6`` type for %%v%%.
|
|
566
|
+
*/
|
|
567
|
+
static bytes6(v) {
|
|
568
|
+
return b(v, 6);
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Return a new ``bytes7`` type for %%v%%.
|
|
572
|
+
*/
|
|
573
|
+
static bytes7(v) {
|
|
574
|
+
return b(v, 7);
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Return a new ``bytes8`` type for %%v%%.
|
|
578
|
+
*/
|
|
579
|
+
static bytes8(v) {
|
|
580
|
+
return b(v, 8);
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Return a new ``bytes9`` type for %%v%%.
|
|
584
|
+
*/
|
|
585
|
+
static bytes9(v) {
|
|
586
|
+
return b(v, 9);
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Return a new ``bytes10`` type for %%v%%.
|
|
590
|
+
*/
|
|
591
|
+
static bytes10(v) {
|
|
592
|
+
return b(v, 10);
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Return a new ``bytes11`` type for %%v%%.
|
|
596
|
+
*/
|
|
597
|
+
static bytes11(v) {
|
|
598
|
+
return b(v, 11);
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* Return a new ``bytes12`` type for %%v%%.
|
|
602
|
+
*/
|
|
603
|
+
static bytes12(v) {
|
|
604
|
+
return b(v, 12);
|
|
605
|
+
}
|
|
606
|
+
/**
|
|
607
|
+
* Return a new ``bytes13`` type for %%v%%.
|
|
608
|
+
*/
|
|
609
|
+
static bytes13(v) {
|
|
610
|
+
return b(v, 13);
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Return a new ``bytes14`` type for %%v%%.
|
|
614
|
+
*/
|
|
615
|
+
static bytes14(v) {
|
|
616
|
+
return b(v, 14);
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* Return a new ``bytes15`` type for %%v%%.
|
|
620
|
+
*/
|
|
621
|
+
static bytes15(v) {
|
|
622
|
+
return b(v, 15);
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Return a new ``bytes16`` type for %%v%%.
|
|
626
|
+
*/
|
|
627
|
+
static bytes16(v) {
|
|
628
|
+
return b(v, 16);
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* Return a new ``bytes17`` type for %%v%%.
|
|
632
|
+
*/
|
|
633
|
+
static bytes17(v) {
|
|
634
|
+
return b(v, 17);
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* Return a new ``bytes18`` type for %%v%%.
|
|
638
|
+
*/
|
|
639
|
+
static bytes18(v) {
|
|
640
|
+
return b(v, 18);
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* Return a new ``bytes19`` type for %%v%%.
|
|
644
|
+
*/
|
|
645
|
+
static bytes19(v) {
|
|
646
|
+
return b(v, 19);
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* Return a new ``bytes20`` type for %%v%%.
|
|
650
|
+
*/
|
|
651
|
+
static bytes20(v) {
|
|
652
|
+
return b(v, 20);
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* Return a new ``bytes21`` type for %%v%%.
|
|
656
|
+
*/
|
|
657
|
+
static bytes21(v) {
|
|
658
|
+
return b(v, 21);
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Return a new ``bytes22`` type for %%v%%.
|
|
662
|
+
*/
|
|
663
|
+
static bytes22(v) {
|
|
664
|
+
return b(v, 22);
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Return a new ``bytes23`` type for %%v%%.
|
|
668
|
+
*/
|
|
669
|
+
static bytes23(v) {
|
|
670
|
+
return b(v, 23);
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* Return a new ``bytes24`` type for %%v%%.
|
|
674
|
+
*/
|
|
675
|
+
static bytes24(v) {
|
|
676
|
+
return b(v, 24);
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* Return a new ``bytes25`` type for %%v%%.
|
|
680
|
+
*/
|
|
681
|
+
static bytes25(v) {
|
|
682
|
+
return b(v, 25);
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Return a new ``bytes26`` type for %%v%%.
|
|
686
|
+
*/
|
|
687
|
+
static bytes26(v) {
|
|
688
|
+
return b(v, 26);
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* Return a new ``bytes27`` type for %%v%%.
|
|
692
|
+
*/
|
|
693
|
+
static bytes27(v) {
|
|
694
|
+
return b(v, 27);
|
|
695
|
+
}
|
|
696
|
+
/**
|
|
697
|
+
* Return a new ``bytes28`` type for %%v%%.
|
|
698
|
+
*/
|
|
699
|
+
static bytes28(v) {
|
|
700
|
+
return b(v, 28);
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* Return a new ``bytes29`` type for %%v%%.
|
|
704
|
+
*/
|
|
705
|
+
static bytes29(v) {
|
|
706
|
+
return b(v, 29);
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* Return a new ``bytes30`` type for %%v%%.
|
|
710
|
+
*/
|
|
711
|
+
static bytes30(v) {
|
|
712
|
+
return b(v, 30);
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* Return a new ``bytes31`` type for %%v%%.
|
|
716
|
+
*/
|
|
717
|
+
static bytes31(v) {
|
|
718
|
+
return b(v, 31);
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
* Return a new ``bytes32`` type for %%v%%.
|
|
722
|
+
*/
|
|
723
|
+
static bytes32(v) {
|
|
724
|
+
return b(v, 32);
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* Return a new ``address`` type for %%v%%.
|
|
728
|
+
*/
|
|
729
|
+
static address(v) {
|
|
730
|
+
return new _Typed(_gaurd, "address", v);
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* Return a new ``bool`` type for %%v%%.
|
|
734
|
+
*/
|
|
735
|
+
static bool(v) {
|
|
736
|
+
return new _Typed(_gaurd, "bool", !!v);
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* Return a new ``bytes`` type for %%v%%.
|
|
740
|
+
*/
|
|
741
|
+
static bytes(v) {
|
|
742
|
+
return new _Typed(_gaurd, "bytes", v);
|
|
743
|
+
}
|
|
744
|
+
/**
|
|
745
|
+
* Return a new ``string`` type for %%v%%.
|
|
746
|
+
*/
|
|
747
|
+
static string(v) {
|
|
748
|
+
return new _Typed(_gaurd, "string", v);
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* Return a new ``array`` type for %%v%%, allowing %%dynamic%% length.
|
|
752
|
+
*/
|
|
753
|
+
static array(v, dynamic) {
|
|
754
|
+
throw new Error("not implemented yet");
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* Return a new ``tuple`` type for %%v%%, with the optional %%name%%.
|
|
758
|
+
*/
|
|
759
|
+
static tuple(v, name) {
|
|
760
|
+
throw new Error("not implemented yet");
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* Return a new ``uint8`` type for %%v%%.
|
|
764
|
+
*/
|
|
765
|
+
static overrides(v) {
|
|
766
|
+
return new _Typed(_gaurd, "overrides", Object.assign({}, v));
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* Returns true only if %%value%% is a [[Typed]] instance.
|
|
770
|
+
*/
|
|
771
|
+
static isTyped(value) {
|
|
772
|
+
return value && typeof value === "object" && "_typedSymbol" in value && value._typedSymbol === _typedSymbol;
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* If the value is a [[Typed]] instance, validates the underlying value
|
|
776
|
+
* and returns it, otherwise returns value directly.
|
|
777
|
+
*
|
|
778
|
+
* This is useful for functions that with to accept either a [[Typed]]
|
|
779
|
+
* object or values.
|
|
780
|
+
*/
|
|
781
|
+
static dereference(value, type) {
|
|
782
|
+
if (_Typed.isTyped(value)) {
|
|
783
|
+
if (value.type !== type) {
|
|
784
|
+
throw new Error(`invalid type: expecetd ${type}, got ${value.type}`);
|
|
785
|
+
}
|
|
786
|
+
return value.value;
|
|
787
|
+
}
|
|
788
|
+
return value;
|
|
789
|
+
}
|
|
790
|
+
};
|
|
791
|
+
_options = new WeakMap();
|
|
792
|
+
let Typed = _Typed;
|
|
1281
793
|
export {
|
|
1282
|
-
|
|
1283
|
-
ErrorFragment,
|
|
1284
|
-
EventFragment,
|
|
1285
|
-
FallbackFragment,
|
|
1286
|
-
Fragment,
|
|
1287
|
-
FunctionFragment,
|
|
1288
|
-
NamedFragment,
|
|
1289
|
-
ParamType,
|
|
1290
|
-
StructFragment
|
|
794
|
+
Typed
|
|
1291
795
|
};
|
|
1292
796
|
//# sourceMappingURL=standards-sdk.es57.js.map
|