@hashgraphonline/standards-sdk 0.0.98 → 0.0.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/hcs-10/base-client.d.ts +12 -4
- package/dist/es/hcs-10/base-client.d.ts.map +1 -1
- package/dist/es/hcs-10/connections-manager.d.ts +51 -0
- package/dist/es/hcs-10/connections-manager.d.ts.map +1 -1
- package/dist/es/hcs-10/sdk.d.ts +37 -1
- package/dist/es/hcs-10/sdk.d.ts.map +1 -1
- package/dist/es/hcs-10/types.d.ts +9 -3
- package/dist/es/hcs-10/types.d.ts.map +1 -1
- package/dist/es/inscribe/inscriber.d.ts +2 -0
- package/dist/es/inscribe/inscriber.d.ts.map +1 -1
- package/dist/es/services/index.d.ts +1 -0
- package/dist/es/services/index.d.ts.map +1 -1
- package/dist/es/services/mirror-node.d.ts +17 -1
- package/dist/es/services/mirror-node.d.ts.map +1 -1
- package/dist/es/services/types.d.ts +24 -0
- package/dist/es/services/types.d.ts.map +1 -1
- package/dist/es/standards-sdk.es.js +8 -5
- package/dist/es/standards-sdk.es.js.map +1 -1
- package/dist/es/standards-sdk.es10.js +66 -0
- package/dist/es/standards-sdk.es10.js.map +1 -1
- package/dist/es/standards-sdk.es100.js +22 -12
- package/dist/es/standards-sdk.es100.js.map +1 -1
- package/dist/es/standards-sdk.es101.js +793 -13
- package/dist/es/standards-sdk.es101.js.map +1 -1
- package/dist/es/standards-sdk.es102.js +172 -30
- package/dist/es/standards-sdk.es102.js.map +1 -1
- package/dist/es/standards-sdk.es103.js +142 -14
- package/dist/es/standards-sdk.es103.js.map +1 -1
- package/dist/es/standards-sdk.es104.js +13 -4
- package/dist/es/standards-sdk.es104.js.map +1 -1
- package/dist/es/standards-sdk.es105.js +13 -4
- package/dist/es/standards-sdk.es105.js.map +1 -1
- package/dist/es/standards-sdk.es106.js +31 -15
- package/dist/es/standards-sdk.es106.js.map +1 -1
- package/dist/es/standards-sdk.es107.js +14 -4
- package/dist/es/standards-sdk.es107.js.map +1 -1
- package/dist/es/standards-sdk.es108.js +4 -39
- package/dist/es/standards-sdk.es108.js.map +1 -1
- package/dist/es/standards-sdk.es109.js +4 -40
- package/dist/es/standards-sdk.es109.js.map +1 -1
- package/dist/es/standards-sdk.es110.js +15 -36
- package/dist/es/standards-sdk.es110.js.map +1 -1
- package/dist/es/standards-sdk.es111.js +5 -78
- package/dist/es/standards-sdk.es111.js.map +1 -1
- package/dist/es/standards-sdk.es112.js +39 -3
- package/dist/es/standards-sdk.es112.js.map +1 -1
- package/dist/es/standards-sdk.es113.js +40 -2
- package/dist/es/standards-sdk.es113.js.map +1 -1
- package/dist/es/standards-sdk.es114.js +37 -2
- package/dist/es/standards-sdk.es114.js.map +1 -1
- package/dist/es/standards-sdk.es115.js +75 -31
- package/dist/es/standards-sdk.es115.js.map +1 -1
- package/dist/es/standards-sdk.es116.js +20 -32
- package/dist/es/standards-sdk.es116.js.map +1 -1
- package/dist/es/standards-sdk.es117.js +27 -9
- package/dist/es/standards-sdk.es117.js.map +1 -1
- package/dist/es/standards-sdk.es118.js +25 -33
- package/dist/es/standards-sdk.es118.js.map +1 -1
- package/dist/es/standards-sdk.es119.js +41 -0
- package/dist/es/standards-sdk.es119.js.map +1 -0
- package/dist/es/standards-sdk.es120.js +6 -0
- package/dist/es/standards-sdk.es120.js.map +1 -0
- package/dist/es/standards-sdk.es121.js +5 -0
- package/dist/es/standards-sdk.es121.js.map +1 -0
- package/dist/es/standards-sdk.es122.js +5 -0
- package/dist/es/standards-sdk.es122.js.map +1 -0
- package/dist/es/standards-sdk.es123.js +37 -0
- package/dist/es/standards-sdk.es123.js.map +1 -0
- package/dist/es/standards-sdk.es124.js +36 -0
- package/dist/es/standards-sdk.es124.js.map +1 -0
- package/dist/es/standards-sdk.es125.js +12 -0
- package/dist/es/standards-sdk.es125.js.map +1 -0
- package/dist/es/standards-sdk.es126.js +37 -0
- package/dist/es/standards-sdk.es126.js.map +1 -0
- package/dist/es/standards-sdk.es13.js +4 -4
- package/dist/es/standards-sdk.es15.js +1 -1
- package/dist/es/standards-sdk.es16.js +1 -1
- package/dist/es/standards-sdk.es18.js +2 -2
- package/dist/es/standards-sdk.es19.js +393 -386
- package/dist/es/standards-sdk.es19.js.map +1 -1
- package/dist/es/standards-sdk.es20.js +385 -314
- package/dist/es/standards-sdk.es20.js.map +1 -1
- package/dist/es/standards-sdk.es21.js +357 -128
- package/dist/es/standards-sdk.es21.js.map +1 -1
- package/dist/es/standards-sdk.es22.js +155 -7
- package/dist/es/standards-sdk.es22.js.map +1 -1
- package/dist/es/standards-sdk.es23.js +7 -1041
- package/dist/es/standards-sdk.es23.js.map +1 -1
- package/dist/es/standards-sdk.es24.js +2 -0
- package/dist/es/standards-sdk.es24.js.map +1 -1
- package/dist/es/standards-sdk.es25.js +7190 -3
- package/dist/es/standards-sdk.es25.js.map +1 -1
- package/dist/es/standards-sdk.es26.js +3 -4167
- package/dist/es/standards-sdk.es26.js.map +1 -1
- package/dist/es/standards-sdk.es27.js +8 -7189
- package/dist/es/standards-sdk.es27.js.map +1 -1
- package/dist/es/standards-sdk.es29.js +1041 -36
- package/dist/es/standards-sdk.es29.js.map +1 -1
- package/dist/es/standards-sdk.es30.js +4168 -48
- package/dist/es/standards-sdk.es30.js.map +1 -1
- package/dist/es/standards-sdk.es31.js +36 -5
- package/dist/es/standards-sdk.es31.js.map +1 -1
- package/dist/es/standards-sdk.es32.js +47 -100
- package/dist/es/standards-sdk.es32.js.map +1 -1
- package/dist/es/standards-sdk.es33.js +5 -2
- package/dist/es/standards-sdk.es33.js.map +1 -1
- package/dist/es/standards-sdk.es34.js +9 -15
- package/dist/es/standards-sdk.es34.js.map +1 -1
- package/dist/es/standards-sdk.es35.js +89 -397
- package/dist/es/standards-sdk.es35.js.map +1 -1
- package/dist/es/standards-sdk.es36.js +2 -2
- package/dist/es/standards-sdk.es36.js.map +1 -1
- package/dist/es/standards-sdk.es37.js +16 -2282
- package/dist/es/standards-sdk.es37.js.map +1 -1
- package/dist/es/standards-sdk.es38.js +400 -155
- package/dist/es/standards-sdk.es38.js.map +1 -1
- package/dist/es/standards-sdk.es39.js +2281 -194
- package/dist/es/standards-sdk.es39.js.map +1 -1
- package/dist/es/standards-sdk.es4.js +1 -1
- package/dist/es/standards-sdk.es40.js +138 -412
- package/dist/es/standards-sdk.es40.js.map +1 -1
- package/dist/es/standards-sdk.es41.js +7129 -18
- package/dist/es/standards-sdk.es41.js.map +1 -1
- package/dist/es/standards-sdk.es42.js +9 -138
- package/dist/es/standards-sdk.es42.js.map +1 -1
- package/dist/es/standards-sdk.es43.js +8 -15
- package/dist/es/standards-sdk.es43.js.map +1 -1
- package/dist/es/standards-sdk.es44.js +16 -27
- package/dist/es/standards-sdk.es44.js.map +1 -1
- package/dist/es/standards-sdk.es45.js +4 -27
- package/dist/es/standards-sdk.es45.js.map +1 -1
- package/dist/es/standards-sdk.es46.js +8 -20
- package/dist/es/standards-sdk.es46.js.map +1 -1
- package/dist/es/standards-sdk.es47.js +3 -44
- package/dist/es/standards-sdk.es47.js.map +1 -1
- package/dist/es/standards-sdk.es48.js +414 -13
- package/dist/es/standards-sdk.es48.js.map +1 -1
- package/dist/es/standards-sdk.es49.js +2 -61
- package/dist/es/standards-sdk.es49.js.map +1 -1
- package/dist/es/standards-sdk.es5.js +34 -8
- package/dist/es/standards-sdk.es5.js.map +1 -1
- package/dist/es/standards-sdk.es50.js +114 -1283
- package/dist/es/standards-sdk.es50.js.map +1 -1
- package/dist/es/standards-sdk.es51.js +3 -147
- package/dist/es/standards-sdk.es51.js.map +1 -1
- package/dist/es/standards-sdk.es52.js +350 -77
- package/dist/es/standards-sdk.es52.js.map +1 -1
- package/dist/es/standards-sdk.es53.js +5 -83
- package/dist/es/standards-sdk.es53.js.map +1 -1
- package/dist/es/standards-sdk.es54.js +174 -27
- package/dist/es/standards-sdk.es54.js.map +1 -1
- package/dist/es/standards-sdk.es55.js +80 -5
- package/dist/es/standards-sdk.es55.js.map +1 -1
- package/dist/es/standards-sdk.es56.js +104 -149
- package/dist/es/standards-sdk.es56.js.map +1 -1
- package/dist/es/standards-sdk.es57.js +50 -21
- package/dist/es/standards-sdk.es57.js.map +1 -1
- package/dist/es/standards-sdk.es58.js +9 -792
- package/dist/es/standards-sdk.es58.js.map +1 -1
- package/dist/es/standards-sdk.es59.js +86 -163
- package/dist/es/standards-sdk.es59.js.map +1 -1
- package/dist/es/standards-sdk.es60.js +3 -142
- package/dist/es/standards-sdk.es60.js.map +1 -1
- package/dist/es/standards-sdk.es61.js +2 -21
- package/dist/es/standards-sdk.es61.js.map +1 -1
- package/dist/es/standards-sdk.es62.js +108 -22
- package/dist/es/standards-sdk.es62.js.map +1 -1
- package/dist/es/standards-sdk.es63.js +72 -24
- package/dist/es/standards-sdk.es63.js.map +1 -1
- package/dist/es/standards-sdk.es64.js +5 -37
- package/dist/es/standards-sdk.es64.js.map +1 -1
- package/dist/es/standards-sdk.es65.js +5 -3
- package/dist/es/standards-sdk.es65.js.map +1 -1
- package/dist/es/standards-sdk.es66.js +220 -3
- package/dist/es/standards-sdk.es66.js.map +1 -1
- package/dist/es/standards-sdk.es67.js +53 -7131
- package/dist/es/standards-sdk.es67.js.map +1 -1
- package/dist/es/standards-sdk.es68.js +69 -419
- package/dist/es/standards-sdk.es68.js.map +1 -1
- package/dist/es/standards-sdk.es69.js +2 -2
- package/dist/es/standards-sdk.es69.js.map +1 -1
- package/dist/es/standards-sdk.es7.js +101 -4
- package/dist/es/standards-sdk.es7.js.map +1 -1
- package/dist/es/standards-sdk.es70.js +28 -116
- package/dist/es/standards-sdk.es70.js.map +1 -1
- package/dist/es/standards-sdk.es71.js +54 -355
- package/dist/es/standards-sdk.es71.js.map +1 -1
- package/dist/es/standards-sdk.es72.js +49 -5
- package/dist/es/standards-sdk.es72.js.map +1 -1
- package/dist/es/standards-sdk.es73.js +9 -178
- package/dist/es/standards-sdk.es73.js.map +1 -1
- package/dist/es/standards-sdk.es74.js +57 -73
- package/dist/es/standards-sdk.es74.js.map +1 -1
- package/dist/es/standards-sdk.es75.js +5 -113
- package/dist/es/standards-sdk.es75.js.map +1 -1
- package/dist/es/standards-sdk.es76.js +12 -49
- package/dist/es/standards-sdk.es76.js.map +1 -1
- package/dist/es/standards-sdk.es77.js +7 -10
- package/dist/es/standards-sdk.es77.js.map +1 -1
- package/dist/es/standards-sdk.es78.js +41 -93
- package/dist/es/standards-sdk.es78.js.map +1 -1
- package/dist/es/standards-sdk.es79.js +2 -4
- 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 +136 -2
- package/dist/es/standards-sdk.es80.js.map +1 -1
- package/dist/es/standards-sdk.es81.js +162 -103
- package/dist/es/standards-sdk.es81.js.map +1 -1
- package/dist/es/standards-sdk.es82.js +190 -69
- package/dist/es/standards-sdk.es82.js.map +1 -1
- package/dist/es/standards-sdk.es83.js +437 -5
- package/dist/es/standards-sdk.es83.js.map +1 -1
- package/dist/es/standards-sdk.es84.js +24 -4
- package/dist/es/standards-sdk.es84.js.map +1 -1
- package/dist/es/standards-sdk.es85.js +122 -204
- package/dist/es/standards-sdk.es85.js.map +1 -1
- package/dist/es/standards-sdk.es86.js +17 -57
- package/dist/es/standards-sdk.es86.js.map +1 -1
- package/dist/es/standards-sdk.es87.js +29 -69
- package/dist/es/standards-sdk.es87.js.map +1 -1
- package/dist/es/standards-sdk.es88.js +24 -27
- package/dist/es/standards-sdk.es88.js.map +1 -1
- package/dist/es/standards-sdk.es89.js +15 -57
- package/dist/es/standards-sdk.es89.js.map +1 -1
- package/dist/es/standards-sdk.es90.js +39 -45
- package/dist/es/standards-sdk.es90.js.map +1 -1
- package/dist/es/standards-sdk.es91.js +17 -9
- package/dist/es/standards-sdk.es91.js.map +1 -1
- package/dist/es/standards-sdk.es92.js +57 -61
- package/dist/es/standards-sdk.es92.js.map +1 -1
- package/dist/es/standards-sdk.es93.js +1288 -5
- package/dist/es/standards-sdk.es93.js.map +1 -1
- package/dist/es/standards-sdk.es94.js +145 -12
- package/dist/es/standards-sdk.es94.js.map +1 -1
- package/dist/es/standards-sdk.es95.js +91 -7
- package/dist/es/standards-sdk.es95.js.map +1 -1
- package/dist/es/standards-sdk.es96.js +82 -43
- package/dist/es/standards-sdk.es96.js.map +1 -1
- package/dist/es/standards-sdk.es97.js +32 -2
- package/dist/es/standards-sdk.es97.js.map +1 -1
- package/dist/es/standards-sdk.es98.js +6 -136
- package/dist/es/standards-sdk.es98.js.map +1 -1
- package/dist/es/standards-sdk.es99.js +148 -161
- package/dist/es/standards-sdk.es99.js.map +1 -1
- package/dist/es/utils/index.d.ts +1 -0
- package/dist/es/utils/index.d.ts.map +1 -1
- package/dist/es/utils/transaction-parser.d.ts +103 -0
- package/dist/es/utils/transaction-parser.d.ts.map +1 -0
- package/dist/umd/hcs-10/base-client.d.ts +12 -4
- package/dist/umd/hcs-10/base-client.d.ts.map +1 -1
- package/dist/umd/hcs-10/connections-manager.d.ts +51 -0
- package/dist/umd/hcs-10/connections-manager.d.ts.map +1 -1
- package/dist/umd/hcs-10/sdk.d.ts +37 -1
- package/dist/umd/hcs-10/sdk.d.ts.map +1 -1
- package/dist/umd/hcs-10/types.d.ts +9 -3
- package/dist/umd/hcs-10/types.d.ts.map +1 -1
- package/dist/umd/inscribe/inscriber.d.ts +2 -0
- package/dist/umd/inscribe/inscriber.d.ts.map +1 -1
- package/dist/umd/services/index.d.ts +1 -0
- package/dist/umd/services/index.d.ts.map +1 -1
- package/dist/umd/services/mirror-node.d.ts +17 -1
- package/dist/umd/services/mirror-node.d.ts.map +1 -1
- package/dist/umd/services/types.d.ts +24 -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/dist/umd/utils/index.d.ts +1 -0
- package/dist/umd/utils/index.d.ts.map +1 -1
- package/dist/umd/utils/transaction-parser.d.ts +103 -0
- package/dist/umd/utils/transaction-parser.d.ts.map +1 -0
- package/package.json +11 -6
|
@@ -1,1292 +1,123 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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;
|
|
114
|
-
}
|
|
115
|
-
// Returns the top Token, throwing if out of tokens
|
|
116
|
-
peek() {
|
|
117
|
-
if (__privateGet(this, _offset) >= __privateGet(this, _tokens).length) {
|
|
118
|
-
throw new Error("out-of-bounds");
|
|
119
|
-
}
|
|
120
|
-
return __privateGet(this, _tokens)[__privateGet(this, _offset)];
|
|
121
|
-
}
|
|
122
|
-
// Returns the next value, if it is a keyword in `allowed`
|
|
123
|
-
peekKeyword(allowed) {
|
|
124
|
-
const top = this.peekType("KEYWORD");
|
|
125
|
-
return top != null && allowed.has(top) ? top : null;
|
|
126
|
-
}
|
|
127
|
-
// Returns the value of the next token if it is `type`
|
|
128
|
-
peekType(type) {
|
|
129
|
-
if (this.length === 0) {
|
|
130
|
-
return null;
|
|
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(" ")}>`;
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
_offset = new WeakMap();
|
|
151
|
-
_tokens = new WeakMap();
|
|
152
|
-
_TokenString_instances = new WeakSet();
|
|
153
|
-
subTokenString_fn = function(from = 0, to = 0) {
|
|
154
|
-
return new _TokenString(__privateGet(this, _tokens).slice(from, to).map((t) => {
|
|
155
|
-
return Object.freeze(Object.assign({}, t, {
|
|
156
|
-
match: t.match - from,
|
|
157
|
-
linkBack: t.linkBack - from,
|
|
158
|
-
linkNext: t.linkNext - from
|
|
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);
|
|
178
|
-
}
|
|
179
|
-
const token = { depth: brackets.length, linkBack: -1, linkNext: -1, match: -1, type: "", text: "", offset, value: -1 };
|
|
180
|
-
tokens.push(token);
|
|
181
|
-
let type = SimpleTokens[cur[0]] || "";
|
|
182
|
-
if (type) {
|
|
183
|
-
token.type = type;
|
|
184
|
-
token.text = cur[0];
|
|
185
|
-
offset++;
|
|
186
|
-
if (type === "OPEN_PAREN") {
|
|
187
|
-
brackets.push(tokens.length - 1);
|
|
188
|
-
commas.push(tokens.length - 1);
|
|
189
|
-
} else if (type == "CLOSE_PAREN") {
|
|
190
|
-
if (brackets.length === 0) {
|
|
191
|
-
throwError("no matching open bracket");
|
|
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");
|
|
1
|
+
var quickFormatUnescaped;
|
|
2
|
+
var hasRequiredQuickFormatUnescaped;
|
|
3
|
+
function requireQuickFormatUnescaped() {
|
|
4
|
+
if (hasRequiredQuickFormatUnescaped) return quickFormatUnescaped;
|
|
5
|
+
hasRequiredQuickFormatUnescaped = 1;
|
|
6
|
+
function tryStringify(o) {
|
|
7
|
+
try {
|
|
8
|
+
return JSON.stringify(o);
|
|
9
|
+
} catch (e) {
|
|
10
|
+
return '"[Circular]"';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
quickFormatUnescaped = format;
|
|
14
|
+
function format(f, args, opts) {
|
|
15
|
+
var ss = opts && opts.stringify || tryStringify;
|
|
16
|
+
var offset = 1;
|
|
17
|
+
if (typeof f === "object" && f !== null) {
|
|
18
|
+
var len = args.length + offset;
|
|
19
|
+
if (len === 1) return f;
|
|
20
|
+
var objects = new Array(len);
|
|
21
|
+
objects[0] = ss(f);
|
|
22
|
+
for (var index = 1; index < len; index++) {
|
|
23
|
+
objects[index] = ss(args[index]);
|
|
24
|
+
}
|
|
25
|
+
return objects.join(" ");
|
|
26
|
+
}
|
|
27
|
+
if (typeof f !== "string") {
|
|
28
|
+
return f;
|
|
29
|
+
}
|
|
30
|
+
var argLen = args.length;
|
|
31
|
+
if (argLen === 0) return f;
|
|
32
|
+
var str = "";
|
|
33
|
+
var a = 1 - offset;
|
|
34
|
+
var lastPos = -1;
|
|
35
|
+
var flen = f && f.length || 0;
|
|
36
|
+
for (var i = 0; i < flen; ) {
|
|
37
|
+
if (f.charCodeAt(i) === 37 && i + 1 < flen) {
|
|
38
|
+
lastPos = lastPos > -1 ? lastPos : 0;
|
|
39
|
+
switch (f.charCodeAt(i + 1)) {
|
|
40
|
+
case 100:
|
|
41
|
+
// 'd'
|
|
42
|
+
case 102:
|
|
43
|
+
if (a >= argLen)
|
|
44
|
+
break;
|
|
45
|
+
if (args[a] == null) break;
|
|
46
|
+
if (lastPos < i)
|
|
47
|
+
str += f.slice(lastPos, i);
|
|
48
|
+
str += Number(args[a]);
|
|
49
|
+
lastPos = i + 2;
|
|
50
|
+
i++;
|
|
51
|
+
break;
|
|
52
|
+
case 105:
|
|
53
|
+
if (a >= argLen)
|
|
54
|
+
break;
|
|
55
|
+
if (args[a] == null) break;
|
|
56
|
+
if (lastPos < i)
|
|
57
|
+
str += f.slice(lastPos, i);
|
|
58
|
+
str += Math.floor(Number(args[a]));
|
|
59
|
+
lastPos = i + 2;
|
|
60
|
+
i++;
|
|
61
|
+
break;
|
|
62
|
+
case 79:
|
|
63
|
+
// 'O'
|
|
64
|
+
case 111:
|
|
65
|
+
// 'o'
|
|
66
|
+
case 106:
|
|
67
|
+
if (a >= argLen)
|
|
68
|
+
break;
|
|
69
|
+
if (args[a] === void 0) break;
|
|
70
|
+
if (lastPos < i)
|
|
71
|
+
str += f.slice(lastPos, i);
|
|
72
|
+
var type = typeof args[a];
|
|
73
|
+
if (type === "string") {
|
|
74
|
+
str += "'" + args[a] + "'";
|
|
75
|
+
lastPos = i + 2;
|
|
76
|
+
i++;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
if (type === "function") {
|
|
80
|
+
str += args[a].name || "<anonymous>";
|
|
81
|
+
lastPos = i + 2;
|
|
82
|
+
i++;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
str += ss(args[a]);
|
|
86
|
+
lastPos = i + 2;
|
|
87
|
+
i++;
|
|
88
|
+
break;
|
|
89
|
+
case 115:
|
|
90
|
+
if (a >= argLen)
|
|
91
|
+
break;
|
|
92
|
+
if (lastPos < i)
|
|
93
|
+
str += f.slice(lastPos, i);
|
|
94
|
+
str += String(args[a]);
|
|
95
|
+
lastPos = i + 2;
|
|
96
|
+
i++;
|
|
97
|
+
break;
|
|
98
|
+
case 37:
|
|
99
|
+
if (lastPos < i)
|
|
100
|
+
str += f.slice(lastPos, i);
|
|
101
|
+
str += "%";
|
|
102
|
+
lastPos = i + 2;
|
|
103
|
+
i++;
|
|
104
|
+
a--;
|
|
105
|
+
break;
|
|
213
106
|
}
|
|
214
|
-
|
|
215
|
-
}
|
|
216
|
-
continue;
|
|
217
|
-
}
|
|
218
|
-
match = cur.match(regexIdPrefix);
|
|
219
|
-
if (match) {
|
|
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;
|
|
107
|
+
++a;
|
|
229
108
|
}
|
|
230
|
-
|
|
231
|
-
continue;
|
|
232
|
-
}
|
|
233
|
-
match = cur.match(regexNumberPrefix);
|
|
234
|
-
if (match) {
|
|
235
|
-
token.text = match[1];
|
|
236
|
-
token.type = "NUMBER";
|
|
237
|
-
offset += token.text.length;
|
|
238
|
-
continue;
|
|
239
|
-
}
|
|
240
|
-
throw new Error(`unexpected token ${JSON.stringify(cur[0])} at position ${offset}`);
|
|
241
|
-
}
|
|
242
|
-
return new TokenString(tokens.map((t) => Object.freeze(t)));
|
|
243
|
-
}
|
|
244
|
-
function allowSingle(set, allowed) {
|
|
245
|
-
let included = [];
|
|
246
|
-
for (const key in allowed.keys()) {
|
|
247
|
-
if (set.has(key)) {
|
|
248
|
-
included.push(key);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
if (included.length > 1) {
|
|
252
|
-
throw new Error(`conflicting types: ${included.join(", ")}`);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
function consumeName(type, tokens) {
|
|
256
|
-
if (tokens.peekKeyword(KwTypes)) {
|
|
257
|
-
const keyword = tokens.pop().text;
|
|
258
|
-
if (keyword !== type) {
|
|
259
|
-
throw new Error(`expected ${type}, got ${keyword}`);
|
|
109
|
+
++i;
|
|
260
110
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
const keywords = /* @__PURE__ */ new Set();
|
|
266
|
-
while (true) {
|
|
267
|
-
const keyword = tokens.peekType("KEYWORD");
|
|
268
|
-
if (keyword == null || allowed && !allowed.has(keyword)) {
|
|
269
|
-
break;
|
|
111
|
+
if (lastPos === -1)
|
|
112
|
+
return f;
|
|
113
|
+
else if (lastPos < flen) {
|
|
114
|
+
str += f.slice(lastPos);
|
|
270
115
|
}
|
|
271
|
-
|
|
272
|
-
if (keywords.has(keyword)) {
|
|
273
|
-
throw new Error(`duplicate keywords: ${JSON.stringify(keyword)}`);
|
|
274
|
-
}
|
|
275
|
-
keywords.add(keyword);
|
|
276
|
-
}
|
|
277
|
-
return Object.freeze(keywords);
|
|
278
|
-
}
|
|
279
|
-
function consumeMutability(tokens) {
|
|
280
|
-
let modifiers = consumeKeywords(tokens, KwVisib);
|
|
281
|
-
allowSingle(modifiers, setify("constant payable nonpayable".split(" ")));
|
|
282
|
-
allowSingle(modifiers, setify("pure view payable nonpayable".split(" ")));
|
|
283
|
-
if (modifiers.has("view")) {
|
|
284
|
-
return "view";
|
|
285
|
-
}
|
|
286
|
-
if (modifiers.has("pure")) {
|
|
287
|
-
return "pure";
|
|
288
|
-
}
|
|
289
|
-
if (modifiers.has("payable")) {
|
|
290
|
-
return "payable";
|
|
291
|
-
}
|
|
292
|
-
if (modifiers.has("nonpayable")) {
|
|
293
|
-
return "nonpayable";
|
|
294
|
-
}
|
|
295
|
-
if (modifiers.has("constant")) {
|
|
296
|
-
return "view";
|
|
297
|
-
}
|
|
298
|
-
return "nonpayable";
|
|
299
|
-
}
|
|
300
|
-
function consumeParams(tokens, allowIndexed) {
|
|
301
|
-
return tokens.popParams().map((t) => ParamType.from(t, allowIndexed));
|
|
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");
|
|
310
|
-
}
|
|
311
|
-
return null;
|
|
312
|
-
}
|
|
313
|
-
function consumeEoi(tokens) {
|
|
314
|
-
if (tokens.length) {
|
|
315
|
-
throw new Error(`unexpected tokens at offset ${tokens.offset}: ${tokens.toString()}`);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
const regexArrayType = new RegExp(/^(.*)\[([0-9]*)\]$/);
|
|
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"``
|
|
428
|
-
*/
|
|
429
|
-
format(format) {
|
|
430
|
-
if (format == null) {
|
|
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;
|
|
473
|
-
}
|
|
474
|
-
/**
|
|
475
|
-
* Returns true if %%this%% is an Array type.
|
|
476
|
-
*
|
|
477
|
-
* This provides a type gaurd ensuring that [[arrayChildren]]
|
|
478
|
-
* and [[arrayLength]] are non-null.
|
|
479
|
-
*/
|
|
480
|
-
isArray() {
|
|
481
|
-
return this.baseType === "array";
|
|
482
|
-
}
|
|
483
|
-
/**
|
|
484
|
-
* Returns true if %%this%% is a Tuple type.
|
|
485
|
-
*
|
|
486
|
-
* This provides a type gaurd ensuring that [[components]]
|
|
487
|
-
* is non-null.
|
|
488
|
-
*/
|
|
489
|
-
isTuple() {
|
|
490
|
-
return this.baseType === "tuple";
|
|
491
|
-
}
|
|
492
|
-
/**
|
|
493
|
-
* Returns true if %%this%% is an Indexable type.
|
|
494
|
-
*
|
|
495
|
-
* This provides a type gaurd ensuring that [[indexed]]
|
|
496
|
-
* is non-null.
|
|
497
|
-
*/
|
|
498
|
-
isIndexable() {
|
|
499
|
-
return this.indexed != null;
|
|
500
|
-
}
|
|
501
|
-
/**
|
|
502
|
-
* Walks the **ParamType** with %%value%%, calling %%process%%
|
|
503
|
-
* on each type, destructing the %%value%% recursively.
|
|
504
|
-
*/
|
|
505
|
-
walk(value, process) {
|
|
506
|
-
if (this.isArray()) {
|
|
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);
|
|
527
|
-
}
|
|
528
|
-
/**
|
|
529
|
-
* Walks the **ParamType** with %%value%%, asynchronously calling
|
|
530
|
-
* %%process%% on each type, destructing the %%value%% recursively.
|
|
531
|
-
*
|
|
532
|
-
* This can be used to resolve ENS names by walking and resolving each
|
|
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];
|
|
545
|
-
}
|
|
546
|
-
/**
|
|
547
|
-
* Creates a new **ParamType** for %%obj%%.
|
|
548
|
-
*
|
|
549
|
-
* If %%allowIndexed%% then the ``indexed`` keyword is permitted,
|
|
550
|
-
* otherwise the ``indexed`` keyword will throw an error.
|
|
551
|
-
*/
|
|
552
|
-
static from(obj, allowIndexed) {
|
|
553
|
-
if (_ParamType.isParamType(obj)) {
|
|
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);
|
|
627
|
-
}
|
|
628
|
-
/**
|
|
629
|
-
* Returns true if %%value%% is a **ParamType**.
|
|
630
|
-
*/
|
|
631
|
-
static isParamType(value) {
|
|
632
|
-
return value && value[internal] === ParamTypeInternal;
|
|
633
|
-
}
|
|
634
|
-
};
|
|
635
|
-
_ParamType_instances = new WeakSet();
|
|
636
|
-
walkAsync_fn = function(promises, value, process, setValue) {
|
|
637
|
-
if (this.isArray()) {
|
|
638
|
-
if (!Array.isArray(value)) {
|
|
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);
|
|
693
|
-
}
|
|
694
|
-
};
|
|
695
|
-
let ParamType = _ParamType;
|
|
696
|
-
class Fragment {
|
|
697
|
-
/**
|
|
698
|
-
* @private
|
|
699
|
-
*/
|
|
700
|
-
constructor(guard, type, inputs) {
|
|
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 });
|
|
712
|
-
}
|
|
713
|
-
/**
|
|
714
|
-
* Creates a new **Fragment** for %%obj%%, wich can be any supported
|
|
715
|
-
* ABI frgament type.
|
|
716
|
-
*/
|
|
717
|
-
static from(obj) {
|
|
718
|
-
if (typeof obj === "string") {
|
|
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);
|
|
763
|
-
}
|
|
764
|
-
/**
|
|
765
|
-
* Returns true if %%value%% is a [[ConstructorFragment]].
|
|
766
|
-
*/
|
|
767
|
-
static isConstructor(value) {
|
|
768
|
-
return ConstructorFragment.isFragment(value);
|
|
769
|
-
}
|
|
770
|
-
/**
|
|
771
|
-
* Returns true if %%value%% is an [[ErrorFragment]].
|
|
772
|
-
*/
|
|
773
|
-
static isError(value) {
|
|
774
|
-
return ErrorFragment.isFragment(value);
|
|
775
|
-
}
|
|
776
|
-
/**
|
|
777
|
-
* Returns true if %%value%% is an [[EventFragment]].
|
|
778
|
-
*/
|
|
779
|
-
static isEvent(value) {
|
|
780
|
-
return EventFragment.isFragment(value);
|
|
781
|
-
}
|
|
782
|
-
/**
|
|
783
|
-
* Returns true if %%value%% is a [[FunctionFragment]].
|
|
784
|
-
*/
|
|
785
|
-
static isFunction(value) {
|
|
786
|
-
return FunctionFragment.isFragment(value);
|
|
787
|
-
}
|
|
788
|
-
/**
|
|
789
|
-
* Returns true if %%value%% is a [[StructFragment]].
|
|
790
|
-
*/
|
|
791
|
-
static isStruct(value) {
|
|
792
|
-
return StructFragment.isFragment(value);
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
class NamedFragment extends Fragment {
|
|
796
|
-
/**
|
|
797
|
-
* @private
|
|
798
|
-
*/
|
|
799
|
-
constructor(guard, type, name, inputs) {
|
|
800
|
-
super(guard, type, inputs);
|
|
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 });
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
function joinParams(format, params) {
|
|
811
|
-
return "(" + params.map((p) => p.format(format)).join(format === "full" ? ", " : ",") + ")";
|
|
812
|
-
}
|
|
813
|
-
class ErrorFragment extends NamedFragment {
|
|
814
|
-
/**
|
|
815
|
-
* @private
|
|
816
|
-
*/
|
|
817
|
-
constructor(guard, name, inputs) {
|
|
818
|
-
super(guard, "error", name, inputs);
|
|
819
|
-
Object.defineProperty(this, internal, { value: ErrorFragmentInternal });
|
|
820
|
-
}
|
|
821
|
-
/**
|
|
822
|
-
* The Custom Error selector.
|
|
823
|
-
*/
|
|
824
|
-
get selector() {
|
|
825
|
-
return id(this.format("sighash")).substring(0, 10);
|
|
826
|
-
}
|
|
827
|
-
/**
|
|
828
|
-
* Returns a string representation of this fragment as %%format%%.
|
|
829
|
-
*/
|
|
830
|
-
format(format) {
|
|
831
|
-
if (format == null) {
|
|
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(" ");
|
|
847
|
-
}
|
|
848
|
-
/**
|
|
849
|
-
* Returns a new **ErrorFragment** for %%obj%%.
|
|
850
|
-
*/
|
|
851
|
-
static from(obj) {
|
|
852
|
-
if (ErrorFragment.isFragment(obj)) {
|
|
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) : []);
|
|
864
|
-
}
|
|
865
|
-
/**
|
|
866
|
-
* Returns ``true`` and provides a type guard if %%value%% is an
|
|
867
|
-
* **ErrorFragment**.
|
|
868
|
-
*/
|
|
869
|
-
static isFragment(value) {
|
|
870
|
-
return value && value[internal] === ErrorFragmentInternal;
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
class EventFragment extends NamedFragment {
|
|
874
|
-
/**
|
|
875
|
-
* @private
|
|
876
|
-
*/
|
|
877
|
-
constructor(guard, name, inputs, anonymous) {
|
|
878
|
-
super(guard, "event", name, inputs);
|
|
879
|
-
/**
|
|
880
|
-
* Whether this event is anonymous.
|
|
881
|
-
*/
|
|
882
|
-
__publicField(this, "anonymous");
|
|
883
|
-
Object.defineProperty(this, internal, { value: EventFragmentInternal });
|
|
884
|
-
defineProperties(this, { anonymous });
|
|
885
|
-
}
|
|
886
|
-
/**
|
|
887
|
-
* The Event topic hash.
|
|
888
|
-
*/
|
|
889
|
-
get topicHash() {
|
|
890
|
-
return id(this.format("sighash"));
|
|
891
|
-
}
|
|
892
|
-
/**
|
|
893
|
-
* Returns a string representation of this event as %%format%%.
|
|
894
|
-
*/
|
|
895
|
-
format(format) {
|
|
896
|
-
if (format == null) {
|
|
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(" ");
|
|
916
|
-
}
|
|
917
|
-
/**
|
|
918
|
-
* Return the topic hash for an event with %%name%% and %%params%%.
|
|
919
|
-
*/
|
|
920
|
-
static getTopicHash(name, params) {
|
|
921
|
-
params = (params || []).map((p) => ParamType.from(p));
|
|
922
|
-
const fragment = new EventFragment(_guard, name, params, false);
|
|
923
|
-
return fragment.topicHash;
|
|
924
|
-
}
|
|
925
|
-
/**
|
|
926
|
-
* Returns a new **EventFragment** for %%obj%%.
|
|
927
|
-
*/
|
|
928
|
-
static from(obj) {
|
|
929
|
-
if (EventFragment.isFragment(obj)) {
|
|
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);
|
|
946
|
-
}
|
|
947
|
-
/**
|
|
948
|
-
* Returns ``true`` and provides a type guard if %%value%% is an
|
|
949
|
-
* **EventFragment**.
|
|
950
|
-
*/
|
|
951
|
-
static isFragment(value) {
|
|
952
|
-
return value && value[internal] === EventFragmentInternal;
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
class ConstructorFragment extends Fragment {
|
|
956
|
-
/**
|
|
957
|
-
* @private
|
|
958
|
-
*/
|
|
959
|
-
constructor(guard, type, inputs, payable, gas) {
|
|
960
|
-
super(guard, type, inputs);
|
|
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(" ");
|
|
994
|
-
}
|
|
995
|
-
/**
|
|
996
|
-
* Returns a new **ConstructorFragment** for %%obj%%.
|
|
997
|
-
*/
|
|
998
|
-
static from(obj) {
|
|
999
|
-
if (ConstructorFragment.isFragment(obj)) {
|
|
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);
|
|
1017
|
-
}
|
|
1018
|
-
/**
|
|
1019
|
-
* Returns ``true`` and provides a type guard if %%value%% is a
|
|
1020
|
-
* **ConstructorFragment**.
|
|
1021
|
-
*/
|
|
1022
|
-
static isFragment(value) {
|
|
1023
|
-
return value && value[internal] === ConstructorFragmentInternal;
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
class FallbackFragment extends Fragment {
|
|
1027
|
-
constructor(guard, inputs, payable) {
|
|
1028
|
-
super(guard, "fallback", inputs);
|
|
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 });
|
|
1035
|
-
}
|
|
1036
|
-
/**
|
|
1037
|
-
* Returns a string representation of this fallback as %%format%%.
|
|
1038
|
-
*/
|
|
1039
|
-
format(format) {
|
|
1040
|
-
const type = this.inputs.length === 0 ? "receive" : "fallback";
|
|
1041
|
-
if (format === "json") {
|
|
1042
|
-
const stateMutability = this.payable ? "payable" : "nonpayable";
|
|
1043
|
-
return JSON.stringify({ type, stateMutability });
|
|
1044
|
-
}
|
|
1045
|
-
return `${type}()${this.payable ? " payable" : ""}`;
|
|
1046
|
-
}
|
|
1047
|
-
/**
|
|
1048
|
-
* Returns a new **FallbackFragment** for %%obj%%.
|
|
1049
|
-
*/
|
|
1050
|
-
static from(obj) {
|
|
1051
|
-
if (FallbackFragment.isFragment(obj)) {
|
|
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);
|
|
1096
|
-
}
|
|
1097
|
-
/**
|
|
1098
|
-
* Returns ``true`` and provides a type guard if %%value%% is a
|
|
1099
|
-
* **FallbackFragment**.
|
|
1100
|
-
*/
|
|
1101
|
-
static isFragment(value) {
|
|
1102
|
-
return value && value[internal] === FallbackFragmentInternal;
|
|
1103
|
-
}
|
|
1104
|
-
}
|
|
1105
|
-
class FunctionFragment extends NamedFragment {
|
|
1106
|
-
/**
|
|
1107
|
-
* @private
|
|
1108
|
-
*/
|
|
1109
|
-
constructor(guard, name, stateMutability, inputs, outputs, gas) {
|
|
1110
|
-
super(guard, "function", name, inputs);
|
|
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 });
|
|
1137
|
-
}
|
|
1138
|
-
/**
|
|
1139
|
-
* The Function selector.
|
|
1140
|
-
*/
|
|
1141
|
-
get selector() {
|
|
1142
|
-
return id(this.format("sighash")).substring(0, 10);
|
|
1143
|
-
}
|
|
1144
|
-
/**
|
|
1145
|
-
* Returns a string representation of this function as %%format%%.
|
|
1146
|
-
*/
|
|
1147
|
-
format(format) {
|
|
1148
|
-
if (format == null) {
|
|
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(" ");
|
|
1181
|
-
}
|
|
1182
|
-
/**
|
|
1183
|
-
* Return the selector for a function with %%name%% and %%params%%.
|
|
1184
|
-
*/
|
|
1185
|
-
static getSelector(name, params) {
|
|
1186
|
-
params = (params || []).map((p) => ParamType.from(p));
|
|
1187
|
-
const fragment = new FunctionFragment(_guard, name, "view", params, [], null);
|
|
1188
|
-
return fragment.selector;
|
|
1189
|
-
}
|
|
1190
|
-
/**
|
|
1191
|
-
* Returns a new **FunctionFragment** for %%obj%%.
|
|
1192
|
-
*/
|
|
1193
|
-
static from(obj) {
|
|
1194
|
-
if (FunctionFragment.isFragment(obj)) {
|
|
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);
|
|
1231
|
-
}
|
|
1232
|
-
/**
|
|
1233
|
-
* Returns ``true`` and provides a type guard if %%value%% is a
|
|
1234
|
-
* **FunctionFragment**.
|
|
1235
|
-
*/
|
|
1236
|
-
static isFragment(value) {
|
|
1237
|
-
return value && value[internal] === FunctionFragmentInternal;
|
|
1238
|
-
}
|
|
1239
|
-
}
|
|
1240
|
-
class StructFragment extends NamedFragment {
|
|
1241
|
-
/**
|
|
1242
|
-
* @private
|
|
1243
|
-
*/
|
|
1244
|
-
constructor(guard, name, inputs) {
|
|
1245
|
-
super(guard, "struct", name, inputs);
|
|
1246
|
-
Object.defineProperty(this, internal, { value: StructFragmentInternal });
|
|
1247
|
-
}
|
|
1248
|
-
/**
|
|
1249
|
-
* Returns a string representation of this struct as %%format%%.
|
|
1250
|
-
*/
|
|
1251
|
-
format() {
|
|
1252
|
-
throw new Error("@TODO");
|
|
1253
|
-
}
|
|
1254
|
-
/**
|
|
1255
|
-
* Returns a new **StructFragment** for %%obj%%.
|
|
1256
|
-
*/
|
|
1257
|
-
static from(obj) {
|
|
1258
|
-
if (typeof obj === "string") {
|
|
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) : []);
|
|
1271
|
-
}
|
|
1272
|
-
// @TODO: fix this return type
|
|
1273
|
-
/**
|
|
1274
|
-
* Returns ``true`` and provides a type guard if %%value%% is a
|
|
1275
|
-
* **StructFragment**.
|
|
1276
|
-
*/
|
|
1277
|
-
static isFragment(value) {
|
|
1278
|
-
return value && value[internal] === StructFragmentInternal;
|
|
116
|
+
return str;
|
|
1279
117
|
}
|
|
118
|
+
return quickFormatUnescaped;
|
|
1280
119
|
}
|
|
1281
120
|
export {
|
|
1282
|
-
|
|
1283
|
-
ErrorFragment,
|
|
1284
|
-
EventFragment,
|
|
1285
|
-
FallbackFragment,
|
|
1286
|
-
Fragment,
|
|
1287
|
-
FunctionFragment,
|
|
1288
|
-
NamedFragment,
|
|
1289
|
-
ParamType,
|
|
1290
|
-
StructFragment
|
|
121
|
+
requireQuickFormatUnescaped as __require
|
|
1291
122
|
};
|
|
1292
123
|
//# sourceMappingURL=standards-sdk.es50.js.map
|