@latticexyz/cli 2.0.0-alpha.57 → 2.0.0-alpha.58

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.
@@ -0,0 +1,3730 @@
1
+ import {
2
+ deploy
3
+ } from "./chunk-4UUSCPKW.js";
4
+ import {
5
+ MUDError,
6
+ loadStoreConfig,
7
+ loadWorldConfig,
8
+ logError
9
+ } from "./chunk-S7JI7355.js";
10
+ import {
11
+ execLog
12
+ } from "./chunk-FFY7VTYB.js";
13
+ import {
14
+ anvil,
15
+ forge,
16
+ getRpcUrl,
17
+ getSrcDirectory
18
+ } from "./chunk-FPG73MVN.js";
19
+ import {
20
+ renderArguments,
21
+ renderImports,
22
+ renderList,
23
+ renderedSolidityHeader,
24
+ tablegen
25
+ } from "./chunk-MXDV47JM.js";
26
+ import {
27
+ tsgen
28
+ } from "./chunk-TPZUS44H.js";
29
+ import {
30
+ formatAndWriteSolidity
31
+ } from "./chunk-5NC2OON2.js";
32
+ import {
33
+ __commonJS,
34
+ __toESM
35
+ } from "./chunk-O6HOO6WA.js";
36
+
37
+ // ../../node_modules/@protobufjs/aspromise/index.js
38
+ var require_aspromise = __commonJS({
39
+ "../../node_modules/@protobufjs/aspromise/index.js"(exports2, module2) {
40
+ "use strict";
41
+ module2.exports = asPromise;
42
+ function asPromise(fn, ctx) {
43
+ var params = new Array(arguments.length - 1), offset = 0, index = 2, pending = true;
44
+ while (index < arguments.length)
45
+ params[offset++] = arguments[index++];
46
+ return new Promise(function executor(resolve, reject) {
47
+ params[offset] = function callback(err) {
48
+ if (pending) {
49
+ pending = false;
50
+ if (err)
51
+ reject(err);
52
+ else {
53
+ var params2 = new Array(arguments.length - 1), offset2 = 0;
54
+ while (offset2 < params2.length)
55
+ params2[offset2++] = arguments[offset2];
56
+ resolve.apply(null, params2);
57
+ }
58
+ }
59
+ };
60
+ try {
61
+ fn.apply(ctx || null, params);
62
+ } catch (err) {
63
+ if (pending) {
64
+ pending = false;
65
+ reject(err);
66
+ }
67
+ }
68
+ });
69
+ }
70
+ }
71
+ });
72
+
73
+ // ../../node_modules/@protobufjs/base64/index.js
74
+ var require_base64 = __commonJS({
75
+ "../../node_modules/@protobufjs/base64/index.js"(exports2) {
76
+ "use strict";
77
+ var base64 = exports2;
78
+ base64.length = function length(string) {
79
+ var p = string.length;
80
+ if (!p)
81
+ return 0;
82
+ var n = 0;
83
+ while (--p % 4 > 1 && string.charAt(p) === "=")
84
+ ++n;
85
+ return Math.ceil(string.length * 3) / 4 - n;
86
+ };
87
+ var b64 = new Array(64);
88
+ var s64 = new Array(123);
89
+ for (i = 0; i < 64; )
90
+ s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++;
91
+ var i;
92
+ base64.encode = function encode(buffer, start, end) {
93
+ var parts = null, chunk = [];
94
+ var i2 = 0, j = 0, t;
95
+ while (start < end) {
96
+ var b = buffer[start++];
97
+ switch (j) {
98
+ case 0:
99
+ chunk[i2++] = b64[b >> 2];
100
+ t = (b & 3) << 4;
101
+ j = 1;
102
+ break;
103
+ case 1:
104
+ chunk[i2++] = b64[t | b >> 4];
105
+ t = (b & 15) << 2;
106
+ j = 2;
107
+ break;
108
+ case 2:
109
+ chunk[i2++] = b64[t | b >> 6];
110
+ chunk[i2++] = b64[b & 63];
111
+ j = 0;
112
+ break;
113
+ }
114
+ if (i2 > 8191) {
115
+ (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
116
+ i2 = 0;
117
+ }
118
+ }
119
+ if (j) {
120
+ chunk[i2++] = b64[t];
121
+ chunk[i2++] = 61;
122
+ if (j === 1)
123
+ chunk[i2++] = 61;
124
+ }
125
+ if (parts) {
126
+ if (i2)
127
+ parts.push(String.fromCharCode.apply(String, chunk.slice(0, i2)));
128
+ return parts.join("");
129
+ }
130
+ return String.fromCharCode.apply(String, chunk.slice(0, i2));
131
+ };
132
+ var invalidEncoding = "invalid encoding";
133
+ base64.decode = function decode(string, buffer, offset) {
134
+ var start = offset;
135
+ var j = 0, t;
136
+ for (var i2 = 0; i2 < string.length; ) {
137
+ var c = string.charCodeAt(i2++);
138
+ if (c === 61 && j > 1)
139
+ break;
140
+ if ((c = s64[c]) === void 0)
141
+ throw Error(invalidEncoding);
142
+ switch (j) {
143
+ case 0:
144
+ t = c;
145
+ j = 1;
146
+ break;
147
+ case 1:
148
+ buffer[offset++] = t << 2 | (c & 48) >> 4;
149
+ t = c;
150
+ j = 2;
151
+ break;
152
+ case 2:
153
+ buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2;
154
+ t = c;
155
+ j = 3;
156
+ break;
157
+ case 3:
158
+ buffer[offset++] = (t & 3) << 6 | c;
159
+ j = 0;
160
+ break;
161
+ }
162
+ }
163
+ if (j === 1)
164
+ throw Error(invalidEncoding);
165
+ return offset - start;
166
+ };
167
+ base64.test = function test(string) {
168
+ return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(string);
169
+ };
170
+ }
171
+ });
172
+
173
+ // ../../node_modules/@protobufjs/eventemitter/index.js
174
+ var require_eventemitter = __commonJS({
175
+ "../../node_modules/@protobufjs/eventemitter/index.js"(exports2, module2) {
176
+ "use strict";
177
+ module2.exports = EventEmitter;
178
+ function EventEmitter() {
179
+ this._listeners = {};
180
+ }
181
+ EventEmitter.prototype.on = function on(evt, fn, ctx) {
182
+ (this._listeners[evt] || (this._listeners[evt] = [])).push({
183
+ fn,
184
+ ctx: ctx || this
185
+ });
186
+ return this;
187
+ };
188
+ EventEmitter.prototype.off = function off(evt, fn) {
189
+ if (evt === void 0)
190
+ this._listeners = {};
191
+ else {
192
+ if (fn === void 0)
193
+ this._listeners[evt] = [];
194
+ else {
195
+ var listeners = this._listeners[evt];
196
+ for (var i = 0; i < listeners.length; )
197
+ if (listeners[i].fn === fn)
198
+ listeners.splice(i, 1);
199
+ else
200
+ ++i;
201
+ }
202
+ }
203
+ return this;
204
+ };
205
+ EventEmitter.prototype.emit = function emit(evt) {
206
+ var listeners = this._listeners[evt];
207
+ if (listeners) {
208
+ var args = [], i = 1;
209
+ for (; i < arguments.length; )
210
+ args.push(arguments[i++]);
211
+ for (i = 0; i < listeners.length; )
212
+ listeners[i].fn.apply(listeners[i++].ctx, args);
213
+ }
214
+ return this;
215
+ };
216
+ }
217
+ });
218
+
219
+ // ../../node_modules/@protobufjs/float/index.js
220
+ var require_float = __commonJS({
221
+ "../../node_modules/@protobufjs/float/index.js"(exports2, module2) {
222
+ "use strict";
223
+ module2.exports = factory(factory);
224
+ function factory(exports3) {
225
+ if (typeof Float32Array !== "undefined")
226
+ (function() {
227
+ var f32 = new Float32Array([-0]), f8b = new Uint8Array(f32.buffer), le = f8b[3] === 128;
228
+ function writeFloat_f32_cpy(val, buf, pos) {
229
+ f32[0] = val;
230
+ buf[pos] = f8b[0];
231
+ buf[pos + 1] = f8b[1];
232
+ buf[pos + 2] = f8b[2];
233
+ buf[pos + 3] = f8b[3];
234
+ }
235
+ function writeFloat_f32_rev(val, buf, pos) {
236
+ f32[0] = val;
237
+ buf[pos] = f8b[3];
238
+ buf[pos + 1] = f8b[2];
239
+ buf[pos + 2] = f8b[1];
240
+ buf[pos + 3] = f8b[0];
241
+ }
242
+ exports3.writeFloatLE = le ? writeFloat_f32_cpy : writeFloat_f32_rev;
243
+ exports3.writeFloatBE = le ? writeFloat_f32_rev : writeFloat_f32_cpy;
244
+ function readFloat_f32_cpy(buf, pos) {
245
+ f8b[0] = buf[pos];
246
+ f8b[1] = buf[pos + 1];
247
+ f8b[2] = buf[pos + 2];
248
+ f8b[3] = buf[pos + 3];
249
+ return f32[0];
250
+ }
251
+ function readFloat_f32_rev(buf, pos) {
252
+ f8b[3] = buf[pos];
253
+ f8b[2] = buf[pos + 1];
254
+ f8b[1] = buf[pos + 2];
255
+ f8b[0] = buf[pos + 3];
256
+ return f32[0];
257
+ }
258
+ exports3.readFloatLE = le ? readFloat_f32_cpy : readFloat_f32_rev;
259
+ exports3.readFloatBE = le ? readFloat_f32_rev : readFloat_f32_cpy;
260
+ })();
261
+ else
262
+ (function() {
263
+ function writeFloat_ieee754(writeUint, val, buf, pos) {
264
+ var sign = val < 0 ? 1 : 0;
265
+ if (sign)
266
+ val = -val;
267
+ if (val === 0)
268
+ writeUint(1 / val > 0 ? (
269
+ /* positive */
270
+ 0
271
+ ) : (
272
+ /* negative 0 */
273
+ 2147483648
274
+ ), buf, pos);
275
+ else if (isNaN(val))
276
+ writeUint(2143289344, buf, pos);
277
+ else if (val > 34028234663852886e22)
278
+ writeUint((sign << 31 | 2139095040) >>> 0, buf, pos);
279
+ else if (val < 11754943508222875e-54)
280
+ writeUint((sign << 31 | Math.round(val / 1401298464324817e-60)) >>> 0, buf, pos);
281
+ else {
282
+ var exponent = Math.floor(Math.log(val) / Math.LN2), mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607;
283
+ writeUint((sign << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos);
284
+ }
285
+ }
286
+ exports3.writeFloatLE = writeFloat_ieee754.bind(null, writeUintLE);
287
+ exports3.writeFloatBE = writeFloat_ieee754.bind(null, writeUintBE);
288
+ function readFloat_ieee754(readUint, buf, pos) {
289
+ var uint = readUint(buf, pos), sign = (uint >> 31) * 2 + 1, exponent = uint >>> 23 & 255, mantissa = uint & 8388607;
290
+ return exponent === 255 ? mantissa ? NaN : sign * Infinity : exponent === 0 ? sign * 1401298464324817e-60 * mantissa : sign * Math.pow(2, exponent - 150) * (mantissa + 8388608);
291
+ }
292
+ exports3.readFloatLE = readFloat_ieee754.bind(null, readUintLE);
293
+ exports3.readFloatBE = readFloat_ieee754.bind(null, readUintBE);
294
+ })();
295
+ if (typeof Float64Array !== "undefined")
296
+ (function() {
297
+ var f64 = new Float64Array([-0]), f8b = new Uint8Array(f64.buffer), le = f8b[7] === 128;
298
+ function writeDouble_f64_cpy(val, buf, pos) {
299
+ f64[0] = val;
300
+ buf[pos] = f8b[0];
301
+ buf[pos + 1] = f8b[1];
302
+ buf[pos + 2] = f8b[2];
303
+ buf[pos + 3] = f8b[3];
304
+ buf[pos + 4] = f8b[4];
305
+ buf[pos + 5] = f8b[5];
306
+ buf[pos + 6] = f8b[6];
307
+ buf[pos + 7] = f8b[7];
308
+ }
309
+ function writeDouble_f64_rev(val, buf, pos) {
310
+ f64[0] = val;
311
+ buf[pos] = f8b[7];
312
+ buf[pos + 1] = f8b[6];
313
+ buf[pos + 2] = f8b[5];
314
+ buf[pos + 3] = f8b[4];
315
+ buf[pos + 4] = f8b[3];
316
+ buf[pos + 5] = f8b[2];
317
+ buf[pos + 6] = f8b[1];
318
+ buf[pos + 7] = f8b[0];
319
+ }
320
+ exports3.writeDoubleLE = le ? writeDouble_f64_cpy : writeDouble_f64_rev;
321
+ exports3.writeDoubleBE = le ? writeDouble_f64_rev : writeDouble_f64_cpy;
322
+ function readDouble_f64_cpy(buf, pos) {
323
+ f8b[0] = buf[pos];
324
+ f8b[1] = buf[pos + 1];
325
+ f8b[2] = buf[pos + 2];
326
+ f8b[3] = buf[pos + 3];
327
+ f8b[4] = buf[pos + 4];
328
+ f8b[5] = buf[pos + 5];
329
+ f8b[6] = buf[pos + 6];
330
+ f8b[7] = buf[pos + 7];
331
+ return f64[0];
332
+ }
333
+ function readDouble_f64_rev(buf, pos) {
334
+ f8b[7] = buf[pos];
335
+ f8b[6] = buf[pos + 1];
336
+ f8b[5] = buf[pos + 2];
337
+ f8b[4] = buf[pos + 3];
338
+ f8b[3] = buf[pos + 4];
339
+ f8b[2] = buf[pos + 5];
340
+ f8b[1] = buf[pos + 6];
341
+ f8b[0] = buf[pos + 7];
342
+ return f64[0];
343
+ }
344
+ exports3.readDoubleLE = le ? readDouble_f64_cpy : readDouble_f64_rev;
345
+ exports3.readDoubleBE = le ? readDouble_f64_rev : readDouble_f64_cpy;
346
+ })();
347
+ else
348
+ (function() {
349
+ function writeDouble_ieee754(writeUint, off0, off1, val, buf, pos) {
350
+ var sign = val < 0 ? 1 : 0;
351
+ if (sign)
352
+ val = -val;
353
+ if (val === 0) {
354
+ writeUint(0, buf, pos + off0);
355
+ writeUint(1 / val > 0 ? (
356
+ /* positive */
357
+ 0
358
+ ) : (
359
+ /* negative 0 */
360
+ 2147483648
361
+ ), buf, pos + off1);
362
+ } else if (isNaN(val)) {
363
+ writeUint(0, buf, pos + off0);
364
+ writeUint(2146959360, buf, pos + off1);
365
+ } else if (val > 17976931348623157e292) {
366
+ writeUint(0, buf, pos + off0);
367
+ writeUint((sign << 31 | 2146435072) >>> 0, buf, pos + off1);
368
+ } else {
369
+ var mantissa;
370
+ if (val < 22250738585072014e-324) {
371
+ mantissa = val / 5e-324;
372
+ writeUint(mantissa >>> 0, buf, pos + off0);
373
+ writeUint((sign << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1);
374
+ } else {
375
+ var exponent = Math.floor(Math.log(val) / Math.LN2);
376
+ if (exponent === 1024)
377
+ exponent = 1023;
378
+ mantissa = val * Math.pow(2, -exponent);
379
+ writeUint(mantissa * 4503599627370496 >>> 0, buf, pos + off0);
380
+ writeUint((sign << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1);
381
+ }
382
+ }
383
+ }
384
+ exports3.writeDoubleLE = writeDouble_ieee754.bind(null, writeUintLE, 0, 4);
385
+ exports3.writeDoubleBE = writeDouble_ieee754.bind(null, writeUintBE, 4, 0);
386
+ function readDouble_ieee754(readUint, off0, off1, buf, pos) {
387
+ var lo = readUint(buf, pos + off0), hi = readUint(buf, pos + off1);
388
+ var sign = (hi >> 31) * 2 + 1, exponent = hi >>> 20 & 2047, mantissa = 4294967296 * (hi & 1048575) + lo;
389
+ return exponent === 2047 ? mantissa ? NaN : sign * Infinity : exponent === 0 ? sign * 5e-324 * mantissa : sign * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496);
390
+ }
391
+ exports3.readDoubleLE = readDouble_ieee754.bind(null, readUintLE, 0, 4);
392
+ exports3.readDoubleBE = readDouble_ieee754.bind(null, readUintBE, 4, 0);
393
+ })();
394
+ return exports3;
395
+ }
396
+ function writeUintLE(val, buf, pos) {
397
+ buf[pos] = val & 255;
398
+ buf[pos + 1] = val >>> 8 & 255;
399
+ buf[pos + 2] = val >>> 16 & 255;
400
+ buf[pos + 3] = val >>> 24;
401
+ }
402
+ function writeUintBE(val, buf, pos) {
403
+ buf[pos] = val >>> 24;
404
+ buf[pos + 1] = val >>> 16 & 255;
405
+ buf[pos + 2] = val >>> 8 & 255;
406
+ buf[pos + 3] = val & 255;
407
+ }
408
+ function readUintLE(buf, pos) {
409
+ return (buf[pos] | buf[pos + 1] << 8 | buf[pos + 2] << 16 | buf[pos + 3] << 24) >>> 0;
410
+ }
411
+ function readUintBE(buf, pos) {
412
+ return (buf[pos] << 24 | buf[pos + 1] << 16 | buf[pos + 2] << 8 | buf[pos + 3]) >>> 0;
413
+ }
414
+ }
415
+ });
416
+
417
+ // ../../node_modules/@protobufjs/inquire/index.js
418
+ var require_inquire = __commonJS({
419
+ "../../node_modules/@protobufjs/inquire/index.js"(exports, module) {
420
+ "use strict";
421
+ module.exports = inquire;
422
+ function inquire(moduleName) {
423
+ try {
424
+ var mod = eval("quire".replace(/^/, "re"))(moduleName);
425
+ if (mod && (mod.length || Object.keys(mod).length))
426
+ return mod;
427
+ } catch (e) {
428
+ }
429
+ return null;
430
+ }
431
+ }
432
+ });
433
+
434
+ // ../../node_modules/@protobufjs/utf8/index.js
435
+ var require_utf8 = __commonJS({
436
+ "../../node_modules/@protobufjs/utf8/index.js"(exports2) {
437
+ "use strict";
438
+ var utf8 = exports2;
439
+ utf8.length = function utf8_length(string) {
440
+ var len = 0, c = 0;
441
+ for (var i = 0; i < string.length; ++i) {
442
+ c = string.charCodeAt(i);
443
+ if (c < 128)
444
+ len += 1;
445
+ else if (c < 2048)
446
+ len += 2;
447
+ else if ((c & 64512) === 55296 && (string.charCodeAt(i + 1) & 64512) === 56320) {
448
+ ++i;
449
+ len += 4;
450
+ } else
451
+ len += 3;
452
+ }
453
+ return len;
454
+ };
455
+ utf8.read = function utf8_read(buffer, start, end) {
456
+ var len = end - start;
457
+ if (len < 1)
458
+ return "";
459
+ var parts = null, chunk = [], i = 0, t;
460
+ while (start < end) {
461
+ t = buffer[start++];
462
+ if (t < 128)
463
+ chunk[i++] = t;
464
+ else if (t > 191 && t < 224)
465
+ chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;
466
+ else if (t > 239 && t < 365) {
467
+ t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 65536;
468
+ chunk[i++] = 55296 + (t >> 10);
469
+ chunk[i++] = 56320 + (t & 1023);
470
+ } else
471
+ chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
472
+ if (i > 8191) {
473
+ (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
474
+ i = 0;
475
+ }
476
+ }
477
+ if (parts) {
478
+ if (i)
479
+ parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
480
+ return parts.join("");
481
+ }
482
+ return String.fromCharCode.apply(String, chunk.slice(0, i));
483
+ };
484
+ utf8.write = function utf8_write(string, buffer, offset) {
485
+ var start = offset, c1, c2;
486
+ for (var i = 0; i < string.length; ++i) {
487
+ c1 = string.charCodeAt(i);
488
+ if (c1 < 128) {
489
+ buffer[offset++] = c1;
490
+ } else if (c1 < 2048) {
491
+ buffer[offset++] = c1 >> 6 | 192;
492
+ buffer[offset++] = c1 & 63 | 128;
493
+ } else if ((c1 & 64512) === 55296 && ((c2 = string.charCodeAt(i + 1)) & 64512) === 56320) {
494
+ c1 = 65536 + ((c1 & 1023) << 10) + (c2 & 1023);
495
+ ++i;
496
+ buffer[offset++] = c1 >> 18 | 240;
497
+ buffer[offset++] = c1 >> 12 & 63 | 128;
498
+ buffer[offset++] = c1 >> 6 & 63 | 128;
499
+ buffer[offset++] = c1 & 63 | 128;
500
+ } else {
501
+ buffer[offset++] = c1 >> 12 | 224;
502
+ buffer[offset++] = c1 >> 6 & 63 | 128;
503
+ buffer[offset++] = c1 & 63 | 128;
504
+ }
505
+ }
506
+ return offset - start;
507
+ };
508
+ }
509
+ });
510
+
511
+ // ../../node_modules/@protobufjs/pool/index.js
512
+ var require_pool = __commonJS({
513
+ "../../node_modules/@protobufjs/pool/index.js"(exports2, module2) {
514
+ "use strict";
515
+ module2.exports = pool;
516
+ function pool(alloc, slice, size) {
517
+ var SIZE = size || 8192;
518
+ var MAX = SIZE >>> 1;
519
+ var slab = null;
520
+ var offset = SIZE;
521
+ return function pool_alloc(size2) {
522
+ if (size2 < 1 || size2 > MAX)
523
+ return alloc(size2);
524
+ if (offset + size2 > SIZE) {
525
+ slab = alloc(SIZE);
526
+ offset = 0;
527
+ }
528
+ var buf = slice.call(slab, offset, offset += size2);
529
+ if (offset & 7)
530
+ offset = (offset | 7) + 1;
531
+ return buf;
532
+ };
533
+ }
534
+ }
535
+ });
536
+
537
+ // ../services/node_modules/protobufjs/src/util/longbits.js
538
+ var require_longbits = __commonJS({
539
+ "../services/node_modules/protobufjs/src/util/longbits.js"(exports2, module2) {
540
+ "use strict";
541
+ module2.exports = LongBits;
542
+ var util = require_minimal();
543
+ function LongBits(lo, hi) {
544
+ this.lo = lo >>> 0;
545
+ this.hi = hi >>> 0;
546
+ }
547
+ var zero = LongBits.zero = new LongBits(0, 0);
548
+ zero.toNumber = function() {
549
+ return 0;
550
+ };
551
+ zero.zzEncode = zero.zzDecode = function() {
552
+ return this;
553
+ };
554
+ zero.length = function() {
555
+ return 1;
556
+ };
557
+ var zeroHash = LongBits.zeroHash = "\0\0\0\0\0\0\0\0";
558
+ LongBits.fromNumber = function fromNumber2(value) {
559
+ if (value === 0)
560
+ return zero;
561
+ var sign = value < 0;
562
+ if (sign)
563
+ value = -value;
564
+ var lo = value >>> 0, hi = (value - lo) / 4294967296 >>> 0;
565
+ if (sign) {
566
+ hi = ~hi >>> 0;
567
+ lo = ~lo >>> 0;
568
+ if (++lo > 4294967295) {
569
+ lo = 0;
570
+ if (++hi > 4294967295)
571
+ hi = 0;
572
+ }
573
+ }
574
+ return new LongBits(lo, hi);
575
+ };
576
+ LongBits.from = function from(value) {
577
+ if (typeof value === "number")
578
+ return LongBits.fromNumber(value);
579
+ if (util.isString(value)) {
580
+ if (util.Long)
581
+ value = util.Long.fromString(value);
582
+ else
583
+ return LongBits.fromNumber(parseInt(value, 10));
584
+ }
585
+ return value.low || value.high ? new LongBits(value.low >>> 0, value.high >>> 0) : zero;
586
+ };
587
+ LongBits.prototype.toNumber = function toNumber2(unsigned) {
588
+ if (!unsigned && this.hi >>> 31) {
589
+ var lo = ~this.lo + 1 >>> 0, hi = ~this.hi >>> 0;
590
+ if (!lo)
591
+ hi = hi + 1 >>> 0;
592
+ return -(lo + hi * 4294967296);
593
+ }
594
+ return this.lo + this.hi * 4294967296;
595
+ };
596
+ LongBits.prototype.toLong = function toLong(unsigned) {
597
+ return util.Long ? new util.Long(this.lo | 0, this.hi | 0, Boolean(unsigned)) : { low: this.lo | 0, high: this.hi | 0, unsigned: Boolean(unsigned) };
598
+ };
599
+ var charCodeAt = String.prototype.charCodeAt;
600
+ LongBits.fromHash = function fromHash(hash) {
601
+ if (hash === zeroHash)
602
+ return zero;
603
+ return new LongBits(
604
+ (charCodeAt.call(hash, 0) | charCodeAt.call(hash, 1) << 8 | charCodeAt.call(hash, 2) << 16 | charCodeAt.call(hash, 3) << 24) >>> 0,
605
+ (charCodeAt.call(hash, 4) | charCodeAt.call(hash, 5) << 8 | charCodeAt.call(hash, 6) << 16 | charCodeAt.call(hash, 7) << 24) >>> 0
606
+ );
607
+ };
608
+ LongBits.prototype.toHash = function toHash() {
609
+ return String.fromCharCode(
610
+ this.lo & 255,
611
+ this.lo >>> 8 & 255,
612
+ this.lo >>> 16 & 255,
613
+ this.lo >>> 24,
614
+ this.hi & 255,
615
+ this.hi >>> 8 & 255,
616
+ this.hi >>> 16 & 255,
617
+ this.hi >>> 24
618
+ );
619
+ };
620
+ LongBits.prototype.zzEncode = function zzEncode() {
621
+ var mask = this.hi >> 31;
622
+ this.hi = ((this.hi << 1 | this.lo >>> 31) ^ mask) >>> 0;
623
+ this.lo = (this.lo << 1 ^ mask) >>> 0;
624
+ return this;
625
+ };
626
+ LongBits.prototype.zzDecode = function zzDecode() {
627
+ var mask = -(this.lo & 1);
628
+ this.lo = ((this.lo >>> 1 | this.hi << 31) ^ mask) >>> 0;
629
+ this.hi = (this.hi >>> 1 ^ mask) >>> 0;
630
+ return this;
631
+ };
632
+ LongBits.prototype.length = function length() {
633
+ var part0 = this.lo, part1 = (this.lo >>> 28 | this.hi << 4) >>> 0, part2 = this.hi >>> 24;
634
+ return part2 === 0 ? part1 === 0 ? part0 < 16384 ? part0 < 128 ? 1 : 2 : part0 < 2097152 ? 3 : 4 : part1 < 16384 ? part1 < 128 ? 5 : 6 : part1 < 2097152 ? 7 : 8 : part2 < 128 ? 9 : 10;
635
+ };
636
+ }
637
+ });
638
+
639
+ // ../services/node_modules/protobufjs/src/util/minimal.js
640
+ var require_minimal = __commonJS({
641
+ "../services/node_modules/protobufjs/src/util/minimal.js"(exports2) {
642
+ "use strict";
643
+ var util = exports2;
644
+ util.asPromise = require_aspromise();
645
+ util.base64 = require_base64();
646
+ util.EventEmitter = require_eventemitter();
647
+ util.float = require_float();
648
+ util.inquire = require_inquire();
649
+ util.utf8 = require_utf8();
650
+ util.pool = require_pool();
651
+ util.LongBits = require_longbits();
652
+ util.isNode = Boolean(typeof global !== "undefined" && global && global.process && global.process.versions && global.process.versions.node);
653
+ util.global = util.isNode && global || typeof window !== "undefined" && window || typeof self !== "undefined" && self || exports2;
654
+ util.emptyArray = Object.freeze ? Object.freeze([]) : (
655
+ /* istanbul ignore next */
656
+ []
657
+ );
658
+ util.emptyObject = Object.freeze ? Object.freeze({}) : (
659
+ /* istanbul ignore next */
660
+ {}
661
+ );
662
+ util.isInteger = Number.isInteger || /* istanbul ignore next */
663
+ function isInteger(value) {
664
+ return typeof value === "number" && isFinite(value) && Math.floor(value) === value;
665
+ };
666
+ util.isString = function isString(value) {
667
+ return typeof value === "string" || value instanceof String;
668
+ };
669
+ util.isObject = function isObject(value) {
670
+ return value && typeof value === "object";
671
+ };
672
+ util.isset = /**
673
+ * Checks if a property on a message is considered to be present.
674
+ * @param {Object} obj Plain object or message instance
675
+ * @param {string} prop Property name
676
+ * @returns {boolean} `true` if considered to be present, otherwise `false`
677
+ */
678
+ util.isSet = function isSet(obj, prop) {
679
+ var value = obj[prop];
680
+ if (value != null && obj.hasOwnProperty(prop))
681
+ return typeof value !== "object" || (Array.isArray(value) ? value.length : Object.keys(value).length) > 0;
682
+ return false;
683
+ };
684
+ util.Buffer = function() {
685
+ try {
686
+ var Buffer = util.inquire("buffer").Buffer;
687
+ return Buffer.prototype.utf8Write ? Buffer : (
688
+ /* istanbul ignore next */
689
+ null
690
+ );
691
+ } catch (e) {
692
+ return null;
693
+ }
694
+ }();
695
+ util._Buffer_from = null;
696
+ util._Buffer_allocUnsafe = null;
697
+ util.newBuffer = function newBuffer(sizeOrArray) {
698
+ return typeof sizeOrArray === "number" ? util.Buffer ? util._Buffer_allocUnsafe(sizeOrArray) : new util.Array(sizeOrArray) : util.Buffer ? util._Buffer_from(sizeOrArray) : typeof Uint8Array === "undefined" ? sizeOrArray : new Uint8Array(sizeOrArray);
699
+ };
700
+ util.Array = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
701
+ util.Long = /* istanbul ignore next */
702
+ util.global.dcodeIO && /* istanbul ignore next */
703
+ util.global.dcodeIO.Long || /* istanbul ignore next */
704
+ util.global.Long || util.inquire("long");
705
+ util.key2Re = /^true|false|0|1$/;
706
+ util.key32Re = /^-?(?:0|[1-9][0-9]*)$/;
707
+ util.key64Re = /^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;
708
+ util.longToHash = function longToHash(value) {
709
+ return value ? util.LongBits.from(value).toHash() : util.LongBits.zeroHash;
710
+ };
711
+ util.longFromHash = function longFromHash(hash, unsigned) {
712
+ var bits = util.LongBits.fromHash(hash);
713
+ if (util.Long)
714
+ return util.Long.fromBits(bits.lo, bits.hi, unsigned);
715
+ return bits.toNumber(Boolean(unsigned));
716
+ };
717
+ function merge(dst, src, ifNotSet) {
718
+ for (var keys = Object.keys(src), i = 0; i < keys.length; ++i)
719
+ if (dst[keys[i]] === void 0 || !ifNotSet)
720
+ dst[keys[i]] = src[keys[i]];
721
+ return dst;
722
+ }
723
+ util.merge = merge;
724
+ util.lcFirst = function lcFirst(str) {
725
+ return str.charAt(0).toLowerCase() + str.substring(1);
726
+ };
727
+ function newError(name) {
728
+ function CustomError(message, properties) {
729
+ if (!(this instanceof CustomError))
730
+ return new CustomError(message, properties);
731
+ Object.defineProperty(this, "message", { get: function() {
732
+ return message;
733
+ } });
734
+ if (Error.captureStackTrace)
735
+ Error.captureStackTrace(this, CustomError);
736
+ else
737
+ Object.defineProperty(this, "stack", { value: new Error().stack || "" });
738
+ if (properties)
739
+ merge(this, properties);
740
+ }
741
+ CustomError.prototype = Object.create(Error.prototype, {
742
+ constructor: {
743
+ value: CustomError,
744
+ writable: true,
745
+ enumerable: false,
746
+ configurable: true
747
+ },
748
+ name: {
749
+ get() {
750
+ return name;
751
+ },
752
+ set: void 0,
753
+ enumerable: false,
754
+ // configurable: false would accurately preserve the behavior of
755
+ // the original, but I'm guessing that was not intentional.
756
+ // For an actual error subclass, this property would
757
+ // be configurable.
758
+ configurable: true
759
+ },
760
+ toString: {
761
+ value() {
762
+ return this.name + ": " + this.message;
763
+ },
764
+ writable: true,
765
+ enumerable: false,
766
+ configurable: true
767
+ }
768
+ });
769
+ return CustomError;
770
+ }
771
+ util.newError = newError;
772
+ util.ProtocolError = newError("ProtocolError");
773
+ util.oneOfGetter = function getOneOf(fieldNames) {
774
+ var fieldMap = {};
775
+ for (var i = 0; i < fieldNames.length; ++i)
776
+ fieldMap[fieldNames[i]] = 1;
777
+ return function() {
778
+ for (var keys = Object.keys(this), i2 = keys.length - 1; i2 > -1; --i2)
779
+ if (fieldMap[keys[i2]] === 1 && this[keys[i2]] !== void 0 && this[keys[i2]] !== null)
780
+ return keys[i2];
781
+ };
782
+ };
783
+ util.oneOfSetter = function setOneOf(fieldNames) {
784
+ return function(name) {
785
+ for (var i = 0; i < fieldNames.length; ++i)
786
+ if (fieldNames[i] !== name)
787
+ delete this[fieldNames[i]];
788
+ };
789
+ };
790
+ util.toJSONOptions = {
791
+ longs: String,
792
+ enums: String,
793
+ bytes: String,
794
+ json: true
795
+ };
796
+ util._configure = function() {
797
+ var Buffer = util.Buffer;
798
+ if (!Buffer) {
799
+ util._Buffer_from = util._Buffer_allocUnsafe = null;
800
+ return;
801
+ }
802
+ util._Buffer_from = Buffer.from !== Uint8Array.from && Buffer.from || /* istanbul ignore next */
803
+ function Buffer_from(value, encoding) {
804
+ return new Buffer(value, encoding);
805
+ };
806
+ util._Buffer_allocUnsafe = Buffer.allocUnsafe || /* istanbul ignore next */
807
+ function Buffer_allocUnsafe(size) {
808
+ return new Buffer(size);
809
+ };
810
+ };
811
+ }
812
+ });
813
+
814
+ // ../services/node_modules/protobufjs/src/writer.js
815
+ var require_writer = __commonJS({
816
+ "../services/node_modules/protobufjs/src/writer.js"(exports2, module2) {
817
+ "use strict";
818
+ module2.exports = Writer;
819
+ var util = require_minimal();
820
+ var BufferWriter;
821
+ var LongBits = util.LongBits;
822
+ var base64 = util.base64;
823
+ var utf8 = util.utf8;
824
+ function Op(fn, len, val) {
825
+ this.fn = fn;
826
+ this.len = len;
827
+ this.next = void 0;
828
+ this.val = val;
829
+ }
830
+ function noop() {
831
+ }
832
+ function State(writer) {
833
+ this.head = writer.head;
834
+ this.tail = writer.tail;
835
+ this.len = writer.len;
836
+ this.next = writer.states;
837
+ }
838
+ function Writer() {
839
+ this.len = 0;
840
+ this.head = new Op(noop, 0, 0);
841
+ this.tail = this.head;
842
+ this.states = null;
843
+ }
844
+ var create = function create2() {
845
+ return util.Buffer ? function create_buffer_setup() {
846
+ return (Writer.create = function create_buffer() {
847
+ return new BufferWriter();
848
+ })();
849
+ } : function create_array() {
850
+ return new Writer();
851
+ };
852
+ };
853
+ Writer.create = create();
854
+ Writer.alloc = function alloc(size) {
855
+ return new util.Array(size);
856
+ };
857
+ if (util.Array !== Array)
858
+ Writer.alloc = util.pool(Writer.alloc, util.Array.prototype.subarray);
859
+ Writer.prototype._push = function push(fn, len, val) {
860
+ this.tail = this.tail.next = new Op(fn, len, val);
861
+ this.len += len;
862
+ return this;
863
+ };
864
+ function writeByte(val, buf, pos) {
865
+ buf[pos] = val & 255;
866
+ }
867
+ function writeVarint32(val, buf, pos) {
868
+ while (val > 127) {
869
+ buf[pos++] = val & 127 | 128;
870
+ val >>>= 7;
871
+ }
872
+ buf[pos] = val;
873
+ }
874
+ function VarintOp(len, val) {
875
+ this.len = len;
876
+ this.next = void 0;
877
+ this.val = val;
878
+ }
879
+ VarintOp.prototype = Object.create(Op.prototype);
880
+ VarintOp.prototype.fn = writeVarint32;
881
+ Writer.prototype.uint32 = function write_uint32(value) {
882
+ this.len += (this.tail = this.tail.next = new VarintOp(
883
+ (value = value >>> 0) < 128 ? 1 : value < 16384 ? 2 : value < 2097152 ? 3 : value < 268435456 ? 4 : 5,
884
+ value
885
+ )).len;
886
+ return this;
887
+ };
888
+ Writer.prototype.int32 = function write_int32(value) {
889
+ return value < 0 ? this._push(writeVarint64, 10, LongBits.fromNumber(value)) : this.uint32(value);
890
+ };
891
+ Writer.prototype.sint32 = function write_sint32(value) {
892
+ return this.uint32((value << 1 ^ value >> 31) >>> 0);
893
+ };
894
+ function writeVarint64(val, buf, pos) {
895
+ while (val.hi) {
896
+ buf[pos++] = val.lo & 127 | 128;
897
+ val.lo = (val.lo >>> 7 | val.hi << 25) >>> 0;
898
+ val.hi >>>= 7;
899
+ }
900
+ while (val.lo > 127) {
901
+ buf[pos++] = val.lo & 127 | 128;
902
+ val.lo = val.lo >>> 7;
903
+ }
904
+ buf[pos++] = val.lo;
905
+ }
906
+ Writer.prototype.uint64 = function write_uint64(value) {
907
+ var bits = LongBits.from(value);
908
+ return this._push(writeVarint64, bits.length(), bits);
909
+ };
910
+ Writer.prototype.int64 = Writer.prototype.uint64;
911
+ Writer.prototype.sint64 = function write_sint64(value) {
912
+ var bits = LongBits.from(value).zzEncode();
913
+ return this._push(writeVarint64, bits.length(), bits);
914
+ };
915
+ Writer.prototype.bool = function write_bool(value) {
916
+ return this._push(writeByte, 1, value ? 1 : 0);
917
+ };
918
+ function writeFixed32(val, buf, pos) {
919
+ buf[pos] = val & 255;
920
+ buf[pos + 1] = val >>> 8 & 255;
921
+ buf[pos + 2] = val >>> 16 & 255;
922
+ buf[pos + 3] = val >>> 24;
923
+ }
924
+ Writer.prototype.fixed32 = function write_fixed32(value) {
925
+ return this._push(writeFixed32, 4, value >>> 0);
926
+ };
927
+ Writer.prototype.sfixed32 = Writer.prototype.fixed32;
928
+ Writer.prototype.fixed64 = function write_fixed64(value) {
929
+ var bits = LongBits.from(value);
930
+ return this._push(writeFixed32, 4, bits.lo)._push(writeFixed32, 4, bits.hi);
931
+ };
932
+ Writer.prototype.sfixed64 = Writer.prototype.fixed64;
933
+ Writer.prototype.float = function write_float(value) {
934
+ return this._push(util.float.writeFloatLE, 4, value);
935
+ };
936
+ Writer.prototype.double = function write_double(value) {
937
+ return this._push(util.float.writeDoubleLE, 8, value);
938
+ };
939
+ var writeBytes = util.Array.prototype.set ? function writeBytes_set(val, buf, pos) {
940
+ buf.set(val, pos);
941
+ } : function writeBytes_for(val, buf, pos) {
942
+ for (var i = 0; i < val.length; ++i)
943
+ buf[pos + i] = val[i];
944
+ };
945
+ Writer.prototype.bytes = function write_bytes(value) {
946
+ var len = value.length >>> 0;
947
+ if (!len)
948
+ return this._push(writeByte, 1, 0);
949
+ if (util.isString(value)) {
950
+ var buf = Writer.alloc(len = base64.length(value));
951
+ base64.decode(value, buf, 0);
952
+ value = buf;
953
+ }
954
+ return this.uint32(len)._push(writeBytes, len, value);
955
+ };
956
+ Writer.prototype.string = function write_string(value) {
957
+ var len = utf8.length(value);
958
+ return len ? this.uint32(len)._push(utf8.write, len, value) : this._push(writeByte, 1, 0);
959
+ };
960
+ Writer.prototype.fork = function fork() {
961
+ this.states = new State(this);
962
+ this.head = this.tail = new Op(noop, 0, 0);
963
+ this.len = 0;
964
+ return this;
965
+ };
966
+ Writer.prototype.reset = function reset() {
967
+ if (this.states) {
968
+ this.head = this.states.head;
969
+ this.tail = this.states.tail;
970
+ this.len = this.states.len;
971
+ this.states = this.states.next;
972
+ } else {
973
+ this.head = this.tail = new Op(noop, 0, 0);
974
+ this.len = 0;
975
+ }
976
+ return this;
977
+ };
978
+ Writer.prototype.ldelim = function ldelim() {
979
+ var head = this.head, tail = this.tail, len = this.len;
980
+ this.reset().uint32(len);
981
+ if (len) {
982
+ this.tail.next = head.next;
983
+ this.tail = tail;
984
+ this.len += len;
985
+ }
986
+ return this;
987
+ };
988
+ Writer.prototype.finish = function finish() {
989
+ var head = this.head.next, buf = this.constructor.alloc(this.len), pos = 0;
990
+ while (head) {
991
+ head.fn(head.val, buf, pos);
992
+ pos += head.len;
993
+ head = head.next;
994
+ }
995
+ return buf;
996
+ };
997
+ Writer._configure = function(BufferWriter_) {
998
+ BufferWriter = BufferWriter_;
999
+ Writer.create = create();
1000
+ BufferWriter._configure();
1001
+ };
1002
+ }
1003
+ });
1004
+
1005
+ // ../services/node_modules/protobufjs/src/writer_buffer.js
1006
+ var require_writer_buffer = __commonJS({
1007
+ "../services/node_modules/protobufjs/src/writer_buffer.js"(exports2, module2) {
1008
+ "use strict";
1009
+ module2.exports = BufferWriter;
1010
+ var Writer = require_writer();
1011
+ (BufferWriter.prototype = Object.create(Writer.prototype)).constructor = BufferWriter;
1012
+ var util = require_minimal();
1013
+ function BufferWriter() {
1014
+ Writer.call(this);
1015
+ }
1016
+ BufferWriter._configure = function() {
1017
+ BufferWriter.alloc = util._Buffer_allocUnsafe;
1018
+ BufferWriter.writeBytesBuffer = util.Buffer && util.Buffer.prototype instanceof Uint8Array && util.Buffer.prototype.set.name === "set" ? function writeBytesBuffer_set(val, buf, pos) {
1019
+ buf.set(val, pos);
1020
+ } : function writeBytesBuffer_copy(val, buf, pos) {
1021
+ if (val.copy)
1022
+ val.copy(buf, pos, 0, val.length);
1023
+ else
1024
+ for (var i = 0; i < val.length; )
1025
+ buf[pos++] = val[i++];
1026
+ };
1027
+ };
1028
+ BufferWriter.prototype.bytes = function write_bytes_buffer(value) {
1029
+ if (util.isString(value))
1030
+ value = util._Buffer_from(value, "base64");
1031
+ var len = value.length >>> 0;
1032
+ this.uint32(len);
1033
+ if (len)
1034
+ this._push(BufferWriter.writeBytesBuffer, len, value);
1035
+ return this;
1036
+ };
1037
+ function writeStringBuffer(val, buf, pos) {
1038
+ if (val.length < 40)
1039
+ util.utf8.write(val, buf, pos);
1040
+ else if (buf.utf8Write)
1041
+ buf.utf8Write(val, pos);
1042
+ else
1043
+ buf.write(val, pos);
1044
+ }
1045
+ BufferWriter.prototype.string = function write_string_buffer(value) {
1046
+ var len = util.Buffer.byteLength(value);
1047
+ this.uint32(len);
1048
+ if (len)
1049
+ this._push(writeStringBuffer, len, value);
1050
+ return this;
1051
+ };
1052
+ BufferWriter._configure();
1053
+ }
1054
+ });
1055
+
1056
+ // ../services/node_modules/protobufjs/src/reader.js
1057
+ var require_reader = __commonJS({
1058
+ "../services/node_modules/protobufjs/src/reader.js"(exports2, module2) {
1059
+ "use strict";
1060
+ module2.exports = Reader;
1061
+ var util = require_minimal();
1062
+ var BufferReader;
1063
+ var LongBits = util.LongBits;
1064
+ var utf8 = util.utf8;
1065
+ function indexOutOfRange(reader, writeLength) {
1066
+ return RangeError("index out of range: " + reader.pos + " + " + (writeLength || 1) + " > " + reader.len);
1067
+ }
1068
+ function Reader(buffer) {
1069
+ this.buf = buffer;
1070
+ this.pos = 0;
1071
+ this.len = buffer.length;
1072
+ }
1073
+ var create_array = typeof Uint8Array !== "undefined" ? function create_typed_array(buffer) {
1074
+ if (buffer instanceof Uint8Array || Array.isArray(buffer))
1075
+ return new Reader(buffer);
1076
+ throw Error("illegal buffer");
1077
+ } : function create_array2(buffer) {
1078
+ if (Array.isArray(buffer))
1079
+ return new Reader(buffer);
1080
+ throw Error("illegal buffer");
1081
+ };
1082
+ var create = function create2() {
1083
+ return util.Buffer ? function create_buffer_setup(buffer) {
1084
+ return (Reader.create = function create_buffer(buffer2) {
1085
+ return util.Buffer.isBuffer(buffer2) ? new BufferReader(buffer2) : create_array(buffer2);
1086
+ })(buffer);
1087
+ } : create_array;
1088
+ };
1089
+ Reader.create = create();
1090
+ Reader.prototype._slice = util.Array.prototype.subarray || /* istanbul ignore next */
1091
+ util.Array.prototype.slice;
1092
+ Reader.prototype.uint32 = function read_uint32_setup() {
1093
+ var value = 4294967295;
1094
+ return function read_uint32() {
1095
+ value = (this.buf[this.pos] & 127) >>> 0;
1096
+ if (this.buf[this.pos++] < 128)
1097
+ return value;
1098
+ value = (value | (this.buf[this.pos] & 127) << 7) >>> 0;
1099
+ if (this.buf[this.pos++] < 128)
1100
+ return value;
1101
+ value = (value | (this.buf[this.pos] & 127) << 14) >>> 0;
1102
+ if (this.buf[this.pos++] < 128)
1103
+ return value;
1104
+ value = (value | (this.buf[this.pos] & 127) << 21) >>> 0;
1105
+ if (this.buf[this.pos++] < 128)
1106
+ return value;
1107
+ value = (value | (this.buf[this.pos] & 15) << 28) >>> 0;
1108
+ if (this.buf[this.pos++] < 128)
1109
+ return value;
1110
+ if ((this.pos += 5) > this.len) {
1111
+ this.pos = this.len;
1112
+ throw indexOutOfRange(this, 10);
1113
+ }
1114
+ return value;
1115
+ };
1116
+ }();
1117
+ Reader.prototype.int32 = function read_int32() {
1118
+ return this.uint32() | 0;
1119
+ };
1120
+ Reader.prototype.sint32 = function read_sint32() {
1121
+ var value = this.uint32();
1122
+ return value >>> 1 ^ -(value & 1) | 0;
1123
+ };
1124
+ function readLongVarint() {
1125
+ var bits = new LongBits(0, 0);
1126
+ var i = 0;
1127
+ if (this.len - this.pos > 4) {
1128
+ for (; i < 4; ++i) {
1129
+ bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0;
1130
+ if (this.buf[this.pos++] < 128)
1131
+ return bits;
1132
+ }
1133
+ bits.lo = (bits.lo | (this.buf[this.pos] & 127) << 28) >>> 0;
1134
+ bits.hi = (bits.hi | (this.buf[this.pos] & 127) >> 4) >>> 0;
1135
+ if (this.buf[this.pos++] < 128)
1136
+ return bits;
1137
+ i = 0;
1138
+ } else {
1139
+ for (; i < 3; ++i) {
1140
+ if (this.pos >= this.len)
1141
+ throw indexOutOfRange(this);
1142
+ bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0;
1143
+ if (this.buf[this.pos++] < 128)
1144
+ return bits;
1145
+ }
1146
+ bits.lo = (bits.lo | (this.buf[this.pos++] & 127) << i * 7) >>> 0;
1147
+ return bits;
1148
+ }
1149
+ if (this.len - this.pos > 4) {
1150
+ for (; i < 5; ++i) {
1151
+ bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0;
1152
+ if (this.buf[this.pos++] < 128)
1153
+ return bits;
1154
+ }
1155
+ } else {
1156
+ for (; i < 5; ++i) {
1157
+ if (this.pos >= this.len)
1158
+ throw indexOutOfRange(this);
1159
+ bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0;
1160
+ if (this.buf[this.pos++] < 128)
1161
+ return bits;
1162
+ }
1163
+ }
1164
+ throw Error("invalid varint encoding");
1165
+ }
1166
+ Reader.prototype.bool = function read_bool() {
1167
+ return this.uint32() !== 0;
1168
+ };
1169
+ function readFixed32_end(buf, end) {
1170
+ return (buf[end - 4] | buf[end - 3] << 8 | buf[end - 2] << 16 | buf[end - 1] << 24) >>> 0;
1171
+ }
1172
+ Reader.prototype.fixed32 = function read_fixed32() {
1173
+ if (this.pos + 4 > this.len)
1174
+ throw indexOutOfRange(this, 4);
1175
+ return readFixed32_end(this.buf, this.pos += 4);
1176
+ };
1177
+ Reader.prototype.sfixed32 = function read_sfixed32() {
1178
+ if (this.pos + 4 > this.len)
1179
+ throw indexOutOfRange(this, 4);
1180
+ return readFixed32_end(this.buf, this.pos += 4) | 0;
1181
+ };
1182
+ function readFixed64() {
1183
+ if (this.pos + 8 > this.len)
1184
+ throw indexOutOfRange(this, 8);
1185
+ return new LongBits(readFixed32_end(this.buf, this.pos += 4), readFixed32_end(this.buf, this.pos += 4));
1186
+ }
1187
+ Reader.prototype.float = function read_float() {
1188
+ if (this.pos + 4 > this.len)
1189
+ throw indexOutOfRange(this, 4);
1190
+ var value = util.float.readFloatLE(this.buf, this.pos);
1191
+ this.pos += 4;
1192
+ return value;
1193
+ };
1194
+ Reader.prototype.double = function read_double() {
1195
+ if (this.pos + 8 > this.len)
1196
+ throw indexOutOfRange(this, 4);
1197
+ var value = util.float.readDoubleLE(this.buf, this.pos);
1198
+ this.pos += 8;
1199
+ return value;
1200
+ };
1201
+ Reader.prototype.bytes = function read_bytes() {
1202
+ var length = this.uint32(), start = this.pos, end = this.pos + length;
1203
+ if (end > this.len)
1204
+ throw indexOutOfRange(this, length);
1205
+ this.pos += length;
1206
+ if (Array.isArray(this.buf))
1207
+ return this.buf.slice(start, end);
1208
+ return start === end ? new this.buf.constructor(0) : this._slice.call(this.buf, start, end);
1209
+ };
1210
+ Reader.prototype.string = function read_string() {
1211
+ var bytes = this.bytes();
1212
+ return utf8.read(bytes, 0, bytes.length);
1213
+ };
1214
+ Reader.prototype.skip = function skip(length) {
1215
+ if (typeof length === "number") {
1216
+ if (this.pos + length > this.len)
1217
+ throw indexOutOfRange(this, length);
1218
+ this.pos += length;
1219
+ } else {
1220
+ do {
1221
+ if (this.pos >= this.len)
1222
+ throw indexOutOfRange(this);
1223
+ } while (this.buf[this.pos++] & 128);
1224
+ }
1225
+ return this;
1226
+ };
1227
+ Reader.prototype.skipType = function(wireType) {
1228
+ switch (wireType) {
1229
+ case 0:
1230
+ this.skip();
1231
+ break;
1232
+ case 1:
1233
+ this.skip(8);
1234
+ break;
1235
+ case 2:
1236
+ this.skip(this.uint32());
1237
+ break;
1238
+ case 3:
1239
+ while ((wireType = this.uint32() & 7) !== 4) {
1240
+ this.skipType(wireType);
1241
+ }
1242
+ break;
1243
+ case 5:
1244
+ this.skip(4);
1245
+ break;
1246
+ default:
1247
+ throw Error("invalid wire type " + wireType + " at offset " + this.pos);
1248
+ }
1249
+ return this;
1250
+ };
1251
+ Reader._configure = function(BufferReader_) {
1252
+ BufferReader = BufferReader_;
1253
+ Reader.create = create();
1254
+ BufferReader._configure();
1255
+ var fn = util.Long ? "toLong" : (
1256
+ /* istanbul ignore next */
1257
+ "toNumber"
1258
+ );
1259
+ util.merge(Reader.prototype, {
1260
+ int64: function read_int64() {
1261
+ return readLongVarint.call(this)[fn](false);
1262
+ },
1263
+ uint64: function read_uint64() {
1264
+ return readLongVarint.call(this)[fn](true);
1265
+ },
1266
+ sint64: function read_sint64() {
1267
+ return readLongVarint.call(this).zzDecode()[fn](false);
1268
+ },
1269
+ fixed64: function read_fixed64() {
1270
+ return readFixed64.call(this)[fn](true);
1271
+ },
1272
+ sfixed64: function read_sfixed64() {
1273
+ return readFixed64.call(this)[fn](false);
1274
+ }
1275
+ });
1276
+ };
1277
+ }
1278
+ });
1279
+
1280
+ // ../services/node_modules/protobufjs/src/reader_buffer.js
1281
+ var require_reader_buffer = __commonJS({
1282
+ "../services/node_modules/protobufjs/src/reader_buffer.js"(exports2, module2) {
1283
+ "use strict";
1284
+ module2.exports = BufferReader;
1285
+ var Reader = require_reader();
1286
+ (BufferReader.prototype = Object.create(Reader.prototype)).constructor = BufferReader;
1287
+ var util = require_minimal();
1288
+ function BufferReader(buffer) {
1289
+ Reader.call(this, buffer);
1290
+ }
1291
+ BufferReader._configure = function() {
1292
+ if (util.Buffer)
1293
+ BufferReader.prototype._slice = util.Buffer.prototype.slice;
1294
+ };
1295
+ BufferReader.prototype.string = function read_string_buffer() {
1296
+ var len = this.uint32();
1297
+ return this.buf.utf8Slice ? this.buf.utf8Slice(this.pos, this.pos = Math.min(this.pos + len, this.len)) : this.buf.toString("utf-8", this.pos, this.pos = Math.min(this.pos + len, this.len));
1298
+ };
1299
+ BufferReader._configure();
1300
+ }
1301
+ });
1302
+
1303
+ // ../services/node_modules/protobufjs/src/rpc/service.js
1304
+ var require_service = __commonJS({
1305
+ "../services/node_modules/protobufjs/src/rpc/service.js"(exports2, module2) {
1306
+ "use strict";
1307
+ module2.exports = Service;
1308
+ var util = require_minimal();
1309
+ (Service.prototype = Object.create(util.EventEmitter.prototype)).constructor = Service;
1310
+ function Service(rpcImpl, requestDelimited, responseDelimited) {
1311
+ if (typeof rpcImpl !== "function")
1312
+ throw TypeError("rpcImpl must be a function");
1313
+ util.EventEmitter.call(this);
1314
+ this.rpcImpl = rpcImpl;
1315
+ this.requestDelimited = Boolean(requestDelimited);
1316
+ this.responseDelimited = Boolean(responseDelimited);
1317
+ }
1318
+ Service.prototype.rpcCall = function rpcCall(method, requestCtor, responseCtor, request, callback) {
1319
+ if (!request)
1320
+ throw TypeError("request must be specified");
1321
+ var self2 = this;
1322
+ if (!callback)
1323
+ return util.asPromise(rpcCall, self2, method, requestCtor, responseCtor, request);
1324
+ if (!self2.rpcImpl) {
1325
+ setTimeout(function() {
1326
+ callback(Error("already ended"));
1327
+ }, 0);
1328
+ return void 0;
1329
+ }
1330
+ try {
1331
+ return self2.rpcImpl(
1332
+ method,
1333
+ requestCtor[self2.requestDelimited ? "encodeDelimited" : "encode"](request).finish(),
1334
+ function rpcCallback(err, response) {
1335
+ if (err) {
1336
+ self2.emit("error", err, method);
1337
+ return callback(err);
1338
+ }
1339
+ if (response === null) {
1340
+ self2.end(
1341
+ /* endedByRPC */
1342
+ true
1343
+ );
1344
+ return void 0;
1345
+ }
1346
+ if (!(response instanceof responseCtor)) {
1347
+ try {
1348
+ response = responseCtor[self2.responseDelimited ? "decodeDelimited" : "decode"](response);
1349
+ } catch (err2) {
1350
+ self2.emit("error", err2, method);
1351
+ return callback(err2);
1352
+ }
1353
+ }
1354
+ self2.emit("data", response, method);
1355
+ return callback(null, response);
1356
+ }
1357
+ );
1358
+ } catch (err) {
1359
+ self2.emit("error", err, method);
1360
+ setTimeout(function() {
1361
+ callback(err);
1362
+ }, 0);
1363
+ return void 0;
1364
+ }
1365
+ };
1366
+ Service.prototype.end = function end(endedByRPC) {
1367
+ if (this.rpcImpl) {
1368
+ if (!endedByRPC)
1369
+ this.rpcImpl(null, null, null);
1370
+ this.rpcImpl = null;
1371
+ this.emit("end").off();
1372
+ }
1373
+ return this;
1374
+ };
1375
+ }
1376
+ });
1377
+
1378
+ // ../services/node_modules/protobufjs/src/rpc.js
1379
+ var require_rpc = __commonJS({
1380
+ "../services/node_modules/protobufjs/src/rpc.js"(exports2) {
1381
+ "use strict";
1382
+ var rpc = exports2;
1383
+ rpc.Service = require_service();
1384
+ }
1385
+ });
1386
+
1387
+ // ../services/node_modules/protobufjs/src/roots.js
1388
+ var require_roots = __commonJS({
1389
+ "../services/node_modules/protobufjs/src/roots.js"(exports2, module2) {
1390
+ "use strict";
1391
+ module2.exports = {};
1392
+ }
1393
+ });
1394
+
1395
+ // ../services/node_modules/protobufjs/src/index-minimal.js
1396
+ var require_index_minimal = __commonJS({
1397
+ "../services/node_modules/protobufjs/src/index-minimal.js"(exports2) {
1398
+ "use strict";
1399
+ var protobuf = exports2;
1400
+ protobuf.build = "minimal";
1401
+ protobuf.Writer = require_writer();
1402
+ protobuf.BufferWriter = require_writer_buffer();
1403
+ protobuf.Reader = require_reader();
1404
+ protobuf.BufferReader = require_reader_buffer();
1405
+ protobuf.util = require_minimal();
1406
+ protobuf.rpc = require_rpc();
1407
+ protobuf.roots = require_roots();
1408
+ protobuf.configure = configure;
1409
+ function configure() {
1410
+ protobuf.util._configure();
1411
+ protobuf.Writer._configure(protobuf.BufferWriter);
1412
+ protobuf.Reader._configure(protobuf.BufferReader);
1413
+ }
1414
+ configure();
1415
+ }
1416
+ });
1417
+
1418
+ // ../services/node_modules/protobufjs/minimal.js
1419
+ var require_minimal2 = __commonJS({
1420
+ "../services/node_modules/protobufjs/minimal.js"(exports2, module2) {
1421
+ "use strict";
1422
+ module2.exports = require_index_minimal();
1423
+ }
1424
+ });
1425
+
1426
+ // src/commands/devnode.ts
1427
+ import { rmSync } from "fs";
1428
+ import { homedir } from "os";
1429
+ import path from "path";
1430
+ var commandModule = {
1431
+ command: "devnode",
1432
+ describe: "Start a local Ethereum node for development",
1433
+ builder(yargs) {
1434
+ return yargs.options({
1435
+ blocktime: { type: "number", default: 1, decs: "Interval in which new blocks are produced" }
1436
+ });
1437
+ },
1438
+ async handler({ blocktime }) {
1439
+ console.log("Clearing devnode history");
1440
+ const userHomeDir = homedir();
1441
+ rmSync(path.join(userHomeDir, ".foundry", "anvil", "tmp"), { recursive: true, force: true });
1442
+ const child = execLog("anvil", ["-b", String(blocktime), "--block-base-fee-per-gas", "0"]);
1443
+ process.on("SIGINT", () => {
1444
+ console.log("\ngracefully shutting down from SIGINT (Crtl-C)");
1445
+ child.kill();
1446
+ process.exit();
1447
+ });
1448
+ await child;
1449
+ }
1450
+ };
1451
+ var devnode_default = commandModule;
1452
+
1453
+ // ../services/node_modules/long/index.js
1454
+ var wasm = null;
1455
+ try {
1456
+ wasm = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([
1457
+ 0,
1458
+ 97,
1459
+ 115,
1460
+ 109,
1461
+ 1,
1462
+ 0,
1463
+ 0,
1464
+ 0,
1465
+ 1,
1466
+ 13,
1467
+ 2,
1468
+ 96,
1469
+ 0,
1470
+ 1,
1471
+ 127,
1472
+ 96,
1473
+ 4,
1474
+ 127,
1475
+ 127,
1476
+ 127,
1477
+ 127,
1478
+ 1,
1479
+ 127,
1480
+ 3,
1481
+ 7,
1482
+ 6,
1483
+ 0,
1484
+ 1,
1485
+ 1,
1486
+ 1,
1487
+ 1,
1488
+ 1,
1489
+ 6,
1490
+ 6,
1491
+ 1,
1492
+ 127,
1493
+ 1,
1494
+ 65,
1495
+ 0,
1496
+ 11,
1497
+ 7,
1498
+ 50,
1499
+ 6,
1500
+ 3,
1501
+ 109,
1502
+ 117,
1503
+ 108,
1504
+ 0,
1505
+ 1,
1506
+ 5,
1507
+ 100,
1508
+ 105,
1509
+ 118,
1510
+ 95,
1511
+ 115,
1512
+ 0,
1513
+ 2,
1514
+ 5,
1515
+ 100,
1516
+ 105,
1517
+ 118,
1518
+ 95,
1519
+ 117,
1520
+ 0,
1521
+ 3,
1522
+ 5,
1523
+ 114,
1524
+ 101,
1525
+ 109,
1526
+ 95,
1527
+ 115,
1528
+ 0,
1529
+ 4,
1530
+ 5,
1531
+ 114,
1532
+ 101,
1533
+ 109,
1534
+ 95,
1535
+ 117,
1536
+ 0,
1537
+ 5,
1538
+ 8,
1539
+ 103,
1540
+ 101,
1541
+ 116,
1542
+ 95,
1543
+ 104,
1544
+ 105,
1545
+ 103,
1546
+ 104,
1547
+ 0,
1548
+ 0,
1549
+ 10,
1550
+ 191,
1551
+ 1,
1552
+ 6,
1553
+ 4,
1554
+ 0,
1555
+ 35,
1556
+ 0,
1557
+ 11,
1558
+ 36,
1559
+ 1,
1560
+ 1,
1561
+ 126,
1562
+ 32,
1563
+ 0,
1564
+ 173,
1565
+ 32,
1566
+ 1,
1567
+ 173,
1568
+ 66,
1569
+ 32,
1570
+ 134,
1571
+ 132,
1572
+ 32,
1573
+ 2,
1574
+ 173,
1575
+ 32,
1576
+ 3,
1577
+ 173,
1578
+ 66,
1579
+ 32,
1580
+ 134,
1581
+ 132,
1582
+ 126,
1583
+ 34,
1584
+ 4,
1585
+ 66,
1586
+ 32,
1587
+ 135,
1588
+ 167,
1589
+ 36,
1590
+ 0,
1591
+ 32,
1592
+ 4,
1593
+ 167,
1594
+ 11,
1595
+ 36,
1596
+ 1,
1597
+ 1,
1598
+ 126,
1599
+ 32,
1600
+ 0,
1601
+ 173,
1602
+ 32,
1603
+ 1,
1604
+ 173,
1605
+ 66,
1606
+ 32,
1607
+ 134,
1608
+ 132,
1609
+ 32,
1610
+ 2,
1611
+ 173,
1612
+ 32,
1613
+ 3,
1614
+ 173,
1615
+ 66,
1616
+ 32,
1617
+ 134,
1618
+ 132,
1619
+ 127,
1620
+ 34,
1621
+ 4,
1622
+ 66,
1623
+ 32,
1624
+ 135,
1625
+ 167,
1626
+ 36,
1627
+ 0,
1628
+ 32,
1629
+ 4,
1630
+ 167,
1631
+ 11,
1632
+ 36,
1633
+ 1,
1634
+ 1,
1635
+ 126,
1636
+ 32,
1637
+ 0,
1638
+ 173,
1639
+ 32,
1640
+ 1,
1641
+ 173,
1642
+ 66,
1643
+ 32,
1644
+ 134,
1645
+ 132,
1646
+ 32,
1647
+ 2,
1648
+ 173,
1649
+ 32,
1650
+ 3,
1651
+ 173,
1652
+ 66,
1653
+ 32,
1654
+ 134,
1655
+ 132,
1656
+ 128,
1657
+ 34,
1658
+ 4,
1659
+ 66,
1660
+ 32,
1661
+ 135,
1662
+ 167,
1663
+ 36,
1664
+ 0,
1665
+ 32,
1666
+ 4,
1667
+ 167,
1668
+ 11,
1669
+ 36,
1670
+ 1,
1671
+ 1,
1672
+ 126,
1673
+ 32,
1674
+ 0,
1675
+ 173,
1676
+ 32,
1677
+ 1,
1678
+ 173,
1679
+ 66,
1680
+ 32,
1681
+ 134,
1682
+ 132,
1683
+ 32,
1684
+ 2,
1685
+ 173,
1686
+ 32,
1687
+ 3,
1688
+ 173,
1689
+ 66,
1690
+ 32,
1691
+ 134,
1692
+ 132,
1693
+ 129,
1694
+ 34,
1695
+ 4,
1696
+ 66,
1697
+ 32,
1698
+ 135,
1699
+ 167,
1700
+ 36,
1701
+ 0,
1702
+ 32,
1703
+ 4,
1704
+ 167,
1705
+ 11,
1706
+ 36,
1707
+ 1,
1708
+ 1,
1709
+ 126,
1710
+ 32,
1711
+ 0,
1712
+ 173,
1713
+ 32,
1714
+ 1,
1715
+ 173,
1716
+ 66,
1717
+ 32,
1718
+ 134,
1719
+ 132,
1720
+ 32,
1721
+ 2,
1722
+ 173,
1723
+ 32,
1724
+ 3,
1725
+ 173,
1726
+ 66,
1727
+ 32,
1728
+ 134,
1729
+ 132,
1730
+ 130,
1731
+ 34,
1732
+ 4,
1733
+ 66,
1734
+ 32,
1735
+ 135,
1736
+ 167,
1737
+ 36,
1738
+ 0,
1739
+ 32,
1740
+ 4,
1741
+ 167,
1742
+ 11
1743
+ ])), {}).exports;
1744
+ } catch (e) {
1745
+ }
1746
+ function Long(low, high, unsigned) {
1747
+ this.low = low | 0;
1748
+ this.high = high | 0;
1749
+ this.unsigned = !!unsigned;
1750
+ }
1751
+ Long.prototype.__isLong__;
1752
+ Object.defineProperty(Long.prototype, "__isLong__", { value: true });
1753
+ function isLong(obj) {
1754
+ return (obj && obj["__isLong__"]) === true;
1755
+ }
1756
+ function ctz32(value) {
1757
+ var c = Math.clz32(value & -value);
1758
+ return value ? 31 - c : c;
1759
+ }
1760
+ Long.isLong = isLong;
1761
+ var INT_CACHE = {};
1762
+ var UINT_CACHE = {};
1763
+ function fromInt(value, unsigned) {
1764
+ var obj, cachedObj, cache;
1765
+ if (unsigned) {
1766
+ value >>>= 0;
1767
+ if (cache = 0 <= value && value < 256) {
1768
+ cachedObj = UINT_CACHE[value];
1769
+ if (cachedObj)
1770
+ return cachedObj;
1771
+ }
1772
+ obj = fromBits(value, 0, true);
1773
+ if (cache)
1774
+ UINT_CACHE[value] = obj;
1775
+ return obj;
1776
+ } else {
1777
+ value |= 0;
1778
+ if (cache = -128 <= value && value < 128) {
1779
+ cachedObj = INT_CACHE[value];
1780
+ if (cachedObj)
1781
+ return cachedObj;
1782
+ }
1783
+ obj = fromBits(value, value < 0 ? -1 : 0, false);
1784
+ if (cache)
1785
+ INT_CACHE[value] = obj;
1786
+ return obj;
1787
+ }
1788
+ }
1789
+ Long.fromInt = fromInt;
1790
+ function fromNumber(value, unsigned) {
1791
+ if (isNaN(value))
1792
+ return unsigned ? UZERO : ZERO;
1793
+ if (unsigned) {
1794
+ if (value < 0)
1795
+ return UZERO;
1796
+ if (value >= TWO_PWR_64_DBL)
1797
+ return MAX_UNSIGNED_VALUE;
1798
+ } else {
1799
+ if (value <= -TWO_PWR_63_DBL)
1800
+ return MIN_VALUE;
1801
+ if (value + 1 >= TWO_PWR_63_DBL)
1802
+ return MAX_VALUE;
1803
+ }
1804
+ if (value < 0)
1805
+ return fromNumber(-value, unsigned).neg();
1806
+ return fromBits(value % TWO_PWR_32_DBL | 0, value / TWO_PWR_32_DBL | 0, unsigned);
1807
+ }
1808
+ Long.fromNumber = fromNumber;
1809
+ function fromBits(lowBits, highBits, unsigned) {
1810
+ return new Long(lowBits, highBits, unsigned);
1811
+ }
1812
+ Long.fromBits = fromBits;
1813
+ var pow_dbl = Math.pow;
1814
+ function fromString(str, unsigned, radix) {
1815
+ if (str.length === 0)
1816
+ throw Error("empty string");
1817
+ if (typeof unsigned === "number") {
1818
+ radix = unsigned;
1819
+ unsigned = false;
1820
+ } else {
1821
+ unsigned = !!unsigned;
1822
+ }
1823
+ if (str === "NaN" || str === "Infinity" || str === "+Infinity" || str === "-Infinity")
1824
+ return unsigned ? UZERO : ZERO;
1825
+ radix = radix || 10;
1826
+ if (radix < 2 || 36 < radix)
1827
+ throw RangeError("radix");
1828
+ var p;
1829
+ if ((p = str.indexOf("-")) > 0)
1830
+ throw Error("interior hyphen");
1831
+ else if (p === 0) {
1832
+ return fromString(str.substring(1), unsigned, radix).neg();
1833
+ }
1834
+ var radixToPower = fromNumber(pow_dbl(radix, 8));
1835
+ var result = ZERO;
1836
+ for (var i = 0; i < str.length; i += 8) {
1837
+ var size = Math.min(8, str.length - i), value = parseInt(str.substring(i, i + size), radix);
1838
+ if (size < 8) {
1839
+ var power = fromNumber(pow_dbl(radix, size));
1840
+ result = result.mul(power).add(fromNumber(value));
1841
+ } else {
1842
+ result = result.mul(radixToPower);
1843
+ result = result.add(fromNumber(value));
1844
+ }
1845
+ }
1846
+ result.unsigned = unsigned;
1847
+ return result;
1848
+ }
1849
+ Long.fromString = fromString;
1850
+ function fromValue(val, unsigned) {
1851
+ if (typeof val === "number")
1852
+ return fromNumber(val, unsigned);
1853
+ if (typeof val === "string")
1854
+ return fromString(val, unsigned);
1855
+ return fromBits(val.low, val.high, typeof unsigned === "boolean" ? unsigned : val.unsigned);
1856
+ }
1857
+ Long.fromValue = fromValue;
1858
+ var TWO_PWR_16_DBL = 1 << 16;
1859
+ var TWO_PWR_24_DBL = 1 << 24;
1860
+ var TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL;
1861
+ var TWO_PWR_64_DBL = TWO_PWR_32_DBL * TWO_PWR_32_DBL;
1862
+ var TWO_PWR_63_DBL = TWO_PWR_64_DBL / 2;
1863
+ var TWO_PWR_24 = fromInt(TWO_PWR_24_DBL);
1864
+ var ZERO = fromInt(0);
1865
+ Long.ZERO = ZERO;
1866
+ var UZERO = fromInt(0, true);
1867
+ Long.UZERO = UZERO;
1868
+ var ONE = fromInt(1);
1869
+ Long.ONE = ONE;
1870
+ var UONE = fromInt(1, true);
1871
+ Long.UONE = UONE;
1872
+ var NEG_ONE = fromInt(-1);
1873
+ Long.NEG_ONE = NEG_ONE;
1874
+ var MAX_VALUE = fromBits(4294967295 | 0, 2147483647 | 0, false);
1875
+ Long.MAX_VALUE = MAX_VALUE;
1876
+ var MAX_UNSIGNED_VALUE = fromBits(4294967295 | 0, 4294967295 | 0, true);
1877
+ Long.MAX_UNSIGNED_VALUE = MAX_UNSIGNED_VALUE;
1878
+ var MIN_VALUE = fromBits(0, 2147483648 | 0, false);
1879
+ Long.MIN_VALUE = MIN_VALUE;
1880
+ var LongPrototype = Long.prototype;
1881
+ LongPrototype.toInt = function toInt() {
1882
+ return this.unsigned ? this.low >>> 0 : this.low;
1883
+ };
1884
+ LongPrototype.toNumber = function toNumber() {
1885
+ if (this.unsigned)
1886
+ return (this.high >>> 0) * TWO_PWR_32_DBL + (this.low >>> 0);
1887
+ return this.high * TWO_PWR_32_DBL + (this.low >>> 0);
1888
+ };
1889
+ LongPrototype.toString = function toString(radix) {
1890
+ radix = radix || 10;
1891
+ if (radix < 2 || 36 < radix)
1892
+ throw RangeError("radix");
1893
+ if (this.isZero())
1894
+ return "0";
1895
+ if (this.isNegative()) {
1896
+ if (this.eq(MIN_VALUE)) {
1897
+ var radixLong = fromNumber(radix), div = this.div(radixLong), rem1 = div.mul(radixLong).sub(this);
1898
+ return div.toString(radix) + rem1.toInt().toString(radix);
1899
+ } else
1900
+ return "-" + this.neg().toString(radix);
1901
+ }
1902
+ var radixToPower = fromNumber(pow_dbl(radix, 6), this.unsigned), rem = this;
1903
+ var result = "";
1904
+ while (true) {
1905
+ var remDiv = rem.div(radixToPower), intval = rem.sub(remDiv.mul(radixToPower)).toInt() >>> 0, digits = intval.toString(radix);
1906
+ rem = remDiv;
1907
+ if (rem.isZero())
1908
+ return digits + result;
1909
+ else {
1910
+ while (digits.length < 6)
1911
+ digits = "0" + digits;
1912
+ result = "" + digits + result;
1913
+ }
1914
+ }
1915
+ };
1916
+ LongPrototype.getHighBits = function getHighBits() {
1917
+ return this.high;
1918
+ };
1919
+ LongPrototype.getHighBitsUnsigned = function getHighBitsUnsigned() {
1920
+ return this.high >>> 0;
1921
+ };
1922
+ LongPrototype.getLowBits = function getLowBits() {
1923
+ return this.low;
1924
+ };
1925
+ LongPrototype.getLowBitsUnsigned = function getLowBitsUnsigned() {
1926
+ return this.low >>> 0;
1927
+ };
1928
+ LongPrototype.getNumBitsAbs = function getNumBitsAbs() {
1929
+ if (this.isNegative())
1930
+ return this.eq(MIN_VALUE) ? 64 : this.neg().getNumBitsAbs();
1931
+ var val = this.high != 0 ? this.high : this.low;
1932
+ for (var bit = 31; bit > 0; bit--)
1933
+ if ((val & 1 << bit) != 0)
1934
+ break;
1935
+ return this.high != 0 ? bit + 33 : bit + 1;
1936
+ };
1937
+ LongPrototype.isZero = function isZero() {
1938
+ return this.high === 0 && this.low === 0;
1939
+ };
1940
+ LongPrototype.eqz = LongPrototype.isZero;
1941
+ LongPrototype.isNegative = function isNegative() {
1942
+ return !this.unsigned && this.high < 0;
1943
+ };
1944
+ LongPrototype.isPositive = function isPositive() {
1945
+ return this.unsigned || this.high >= 0;
1946
+ };
1947
+ LongPrototype.isOdd = function isOdd() {
1948
+ return (this.low & 1) === 1;
1949
+ };
1950
+ LongPrototype.isEven = function isEven() {
1951
+ return (this.low & 1) === 0;
1952
+ };
1953
+ LongPrototype.equals = function equals(other) {
1954
+ if (!isLong(other))
1955
+ other = fromValue(other);
1956
+ if (this.unsigned !== other.unsigned && this.high >>> 31 === 1 && other.high >>> 31 === 1)
1957
+ return false;
1958
+ return this.high === other.high && this.low === other.low;
1959
+ };
1960
+ LongPrototype.eq = LongPrototype.equals;
1961
+ LongPrototype.notEquals = function notEquals(other) {
1962
+ return !this.eq(
1963
+ /* validates */
1964
+ other
1965
+ );
1966
+ };
1967
+ LongPrototype.neq = LongPrototype.notEquals;
1968
+ LongPrototype.ne = LongPrototype.notEquals;
1969
+ LongPrototype.lessThan = function lessThan(other) {
1970
+ return this.comp(
1971
+ /* validates */
1972
+ other
1973
+ ) < 0;
1974
+ };
1975
+ LongPrototype.lt = LongPrototype.lessThan;
1976
+ LongPrototype.lessThanOrEqual = function lessThanOrEqual(other) {
1977
+ return this.comp(
1978
+ /* validates */
1979
+ other
1980
+ ) <= 0;
1981
+ };
1982
+ LongPrototype.lte = LongPrototype.lessThanOrEqual;
1983
+ LongPrototype.le = LongPrototype.lessThanOrEqual;
1984
+ LongPrototype.greaterThan = function greaterThan(other) {
1985
+ return this.comp(
1986
+ /* validates */
1987
+ other
1988
+ ) > 0;
1989
+ };
1990
+ LongPrototype.gt = LongPrototype.greaterThan;
1991
+ LongPrototype.greaterThanOrEqual = function greaterThanOrEqual(other) {
1992
+ return this.comp(
1993
+ /* validates */
1994
+ other
1995
+ ) >= 0;
1996
+ };
1997
+ LongPrototype.gte = LongPrototype.greaterThanOrEqual;
1998
+ LongPrototype.ge = LongPrototype.greaterThanOrEqual;
1999
+ LongPrototype.compare = function compare(other) {
2000
+ if (!isLong(other))
2001
+ other = fromValue(other);
2002
+ if (this.eq(other))
2003
+ return 0;
2004
+ var thisNeg = this.isNegative(), otherNeg = other.isNegative();
2005
+ if (thisNeg && !otherNeg)
2006
+ return -1;
2007
+ if (!thisNeg && otherNeg)
2008
+ return 1;
2009
+ if (!this.unsigned)
2010
+ return this.sub(other).isNegative() ? -1 : 1;
2011
+ return other.high >>> 0 > this.high >>> 0 || other.high === this.high && other.low >>> 0 > this.low >>> 0 ? -1 : 1;
2012
+ };
2013
+ LongPrototype.comp = LongPrototype.compare;
2014
+ LongPrototype.negate = function negate() {
2015
+ if (!this.unsigned && this.eq(MIN_VALUE))
2016
+ return MIN_VALUE;
2017
+ return this.not().add(ONE);
2018
+ };
2019
+ LongPrototype.neg = LongPrototype.negate;
2020
+ LongPrototype.add = function add(addend) {
2021
+ if (!isLong(addend))
2022
+ addend = fromValue(addend);
2023
+ var a48 = this.high >>> 16;
2024
+ var a32 = this.high & 65535;
2025
+ var a16 = this.low >>> 16;
2026
+ var a00 = this.low & 65535;
2027
+ var b48 = addend.high >>> 16;
2028
+ var b32 = addend.high & 65535;
2029
+ var b16 = addend.low >>> 16;
2030
+ var b00 = addend.low & 65535;
2031
+ var c48 = 0, c32 = 0, c16 = 0, c00 = 0;
2032
+ c00 += a00 + b00;
2033
+ c16 += c00 >>> 16;
2034
+ c00 &= 65535;
2035
+ c16 += a16 + b16;
2036
+ c32 += c16 >>> 16;
2037
+ c16 &= 65535;
2038
+ c32 += a32 + b32;
2039
+ c48 += c32 >>> 16;
2040
+ c32 &= 65535;
2041
+ c48 += a48 + b48;
2042
+ c48 &= 65535;
2043
+ return fromBits(c16 << 16 | c00, c48 << 16 | c32, this.unsigned);
2044
+ };
2045
+ LongPrototype.subtract = function subtract(subtrahend) {
2046
+ if (!isLong(subtrahend))
2047
+ subtrahend = fromValue(subtrahend);
2048
+ return this.add(subtrahend.neg());
2049
+ };
2050
+ LongPrototype.sub = LongPrototype.subtract;
2051
+ LongPrototype.multiply = function multiply(multiplier) {
2052
+ if (this.isZero())
2053
+ return this;
2054
+ if (!isLong(multiplier))
2055
+ multiplier = fromValue(multiplier);
2056
+ if (wasm) {
2057
+ var low = wasm["mul"](
2058
+ this.low,
2059
+ this.high,
2060
+ multiplier.low,
2061
+ multiplier.high
2062
+ );
2063
+ return fromBits(low, wasm["get_high"](), this.unsigned);
2064
+ }
2065
+ if (multiplier.isZero())
2066
+ return this.unsigned ? UZERO : ZERO;
2067
+ if (this.eq(MIN_VALUE))
2068
+ return multiplier.isOdd() ? MIN_VALUE : ZERO;
2069
+ if (multiplier.eq(MIN_VALUE))
2070
+ return this.isOdd() ? MIN_VALUE : ZERO;
2071
+ if (this.isNegative()) {
2072
+ if (multiplier.isNegative())
2073
+ return this.neg().mul(multiplier.neg());
2074
+ else
2075
+ return this.neg().mul(multiplier).neg();
2076
+ } else if (multiplier.isNegative())
2077
+ return this.mul(multiplier.neg()).neg();
2078
+ if (this.lt(TWO_PWR_24) && multiplier.lt(TWO_PWR_24))
2079
+ return fromNumber(this.toNumber() * multiplier.toNumber(), this.unsigned);
2080
+ var a48 = this.high >>> 16;
2081
+ var a32 = this.high & 65535;
2082
+ var a16 = this.low >>> 16;
2083
+ var a00 = this.low & 65535;
2084
+ var b48 = multiplier.high >>> 16;
2085
+ var b32 = multiplier.high & 65535;
2086
+ var b16 = multiplier.low >>> 16;
2087
+ var b00 = multiplier.low & 65535;
2088
+ var c48 = 0, c32 = 0, c16 = 0, c00 = 0;
2089
+ c00 += a00 * b00;
2090
+ c16 += c00 >>> 16;
2091
+ c00 &= 65535;
2092
+ c16 += a16 * b00;
2093
+ c32 += c16 >>> 16;
2094
+ c16 &= 65535;
2095
+ c16 += a00 * b16;
2096
+ c32 += c16 >>> 16;
2097
+ c16 &= 65535;
2098
+ c32 += a32 * b00;
2099
+ c48 += c32 >>> 16;
2100
+ c32 &= 65535;
2101
+ c32 += a16 * b16;
2102
+ c48 += c32 >>> 16;
2103
+ c32 &= 65535;
2104
+ c32 += a00 * b32;
2105
+ c48 += c32 >>> 16;
2106
+ c32 &= 65535;
2107
+ c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48;
2108
+ c48 &= 65535;
2109
+ return fromBits(c16 << 16 | c00, c48 << 16 | c32, this.unsigned);
2110
+ };
2111
+ LongPrototype.mul = LongPrototype.multiply;
2112
+ LongPrototype.divide = function divide(divisor) {
2113
+ if (!isLong(divisor))
2114
+ divisor = fromValue(divisor);
2115
+ if (divisor.isZero())
2116
+ throw Error("division by zero");
2117
+ if (wasm) {
2118
+ if (!this.unsigned && this.high === -2147483648 && divisor.low === -1 && divisor.high === -1) {
2119
+ return this;
2120
+ }
2121
+ var low = (this.unsigned ? wasm["div_u"] : wasm["div_s"])(
2122
+ this.low,
2123
+ this.high,
2124
+ divisor.low,
2125
+ divisor.high
2126
+ );
2127
+ return fromBits(low, wasm["get_high"](), this.unsigned);
2128
+ }
2129
+ if (this.isZero())
2130
+ return this.unsigned ? UZERO : ZERO;
2131
+ var approx, rem, res;
2132
+ if (!this.unsigned) {
2133
+ if (this.eq(MIN_VALUE)) {
2134
+ if (divisor.eq(ONE) || divisor.eq(NEG_ONE))
2135
+ return MIN_VALUE;
2136
+ else if (divisor.eq(MIN_VALUE))
2137
+ return ONE;
2138
+ else {
2139
+ var halfThis = this.shr(1);
2140
+ approx = halfThis.div(divisor).shl(1);
2141
+ if (approx.eq(ZERO)) {
2142
+ return divisor.isNegative() ? ONE : NEG_ONE;
2143
+ } else {
2144
+ rem = this.sub(divisor.mul(approx));
2145
+ res = approx.add(rem.div(divisor));
2146
+ return res;
2147
+ }
2148
+ }
2149
+ } else if (divisor.eq(MIN_VALUE))
2150
+ return this.unsigned ? UZERO : ZERO;
2151
+ if (this.isNegative()) {
2152
+ if (divisor.isNegative())
2153
+ return this.neg().div(divisor.neg());
2154
+ return this.neg().div(divisor).neg();
2155
+ } else if (divisor.isNegative())
2156
+ return this.div(divisor.neg()).neg();
2157
+ res = ZERO;
2158
+ } else {
2159
+ if (!divisor.unsigned)
2160
+ divisor = divisor.toUnsigned();
2161
+ if (divisor.gt(this))
2162
+ return UZERO;
2163
+ if (divisor.gt(this.shru(1)))
2164
+ return UONE;
2165
+ res = UZERO;
2166
+ }
2167
+ rem = this;
2168
+ while (rem.gte(divisor)) {
2169
+ approx = Math.max(1, Math.floor(rem.toNumber() / divisor.toNumber()));
2170
+ var log2 = Math.ceil(Math.log(approx) / Math.LN2), delta = log2 <= 48 ? 1 : pow_dbl(2, log2 - 48), approxRes = fromNumber(approx), approxRem = approxRes.mul(divisor);
2171
+ while (approxRem.isNegative() || approxRem.gt(rem)) {
2172
+ approx -= delta;
2173
+ approxRes = fromNumber(approx, this.unsigned);
2174
+ approxRem = approxRes.mul(divisor);
2175
+ }
2176
+ if (approxRes.isZero())
2177
+ approxRes = ONE;
2178
+ res = res.add(approxRes);
2179
+ rem = rem.sub(approxRem);
2180
+ }
2181
+ return res;
2182
+ };
2183
+ LongPrototype.div = LongPrototype.divide;
2184
+ LongPrototype.modulo = function modulo(divisor) {
2185
+ if (!isLong(divisor))
2186
+ divisor = fromValue(divisor);
2187
+ if (wasm) {
2188
+ var low = (this.unsigned ? wasm["rem_u"] : wasm["rem_s"])(
2189
+ this.low,
2190
+ this.high,
2191
+ divisor.low,
2192
+ divisor.high
2193
+ );
2194
+ return fromBits(low, wasm["get_high"](), this.unsigned);
2195
+ }
2196
+ return this.sub(this.div(divisor).mul(divisor));
2197
+ };
2198
+ LongPrototype.mod = LongPrototype.modulo;
2199
+ LongPrototype.rem = LongPrototype.modulo;
2200
+ LongPrototype.not = function not() {
2201
+ return fromBits(~this.low, ~this.high, this.unsigned);
2202
+ };
2203
+ LongPrototype.countLeadingZeros = function countLeadingZeros() {
2204
+ return this.high ? Math.clz32(this.high) : Math.clz32(this.low) + 32;
2205
+ };
2206
+ LongPrototype.clz = LongPrototype.countLeadingZeros;
2207
+ LongPrototype.countTrailingZeros = function countTrailingZeros() {
2208
+ return this.low ? ctz32(this.low) : ctz32(this.high) + 32;
2209
+ };
2210
+ LongPrototype.ctz = LongPrototype.countTrailingZeros;
2211
+ LongPrototype.and = function and(other) {
2212
+ if (!isLong(other))
2213
+ other = fromValue(other);
2214
+ return fromBits(this.low & other.low, this.high & other.high, this.unsigned);
2215
+ };
2216
+ LongPrototype.or = function or(other) {
2217
+ if (!isLong(other))
2218
+ other = fromValue(other);
2219
+ return fromBits(this.low | other.low, this.high | other.high, this.unsigned);
2220
+ };
2221
+ LongPrototype.xor = function xor(other) {
2222
+ if (!isLong(other))
2223
+ other = fromValue(other);
2224
+ return fromBits(this.low ^ other.low, this.high ^ other.high, this.unsigned);
2225
+ };
2226
+ LongPrototype.shiftLeft = function shiftLeft(numBits) {
2227
+ if (isLong(numBits))
2228
+ numBits = numBits.toInt();
2229
+ if ((numBits &= 63) === 0)
2230
+ return this;
2231
+ else if (numBits < 32)
2232
+ return fromBits(this.low << numBits, this.high << numBits | this.low >>> 32 - numBits, this.unsigned);
2233
+ else
2234
+ return fromBits(0, this.low << numBits - 32, this.unsigned);
2235
+ };
2236
+ LongPrototype.shl = LongPrototype.shiftLeft;
2237
+ LongPrototype.shiftRight = function shiftRight(numBits) {
2238
+ if (isLong(numBits))
2239
+ numBits = numBits.toInt();
2240
+ if ((numBits &= 63) === 0)
2241
+ return this;
2242
+ else if (numBits < 32)
2243
+ return fromBits(this.low >>> numBits | this.high << 32 - numBits, this.high >> numBits, this.unsigned);
2244
+ else
2245
+ return fromBits(this.high >> numBits - 32, this.high >= 0 ? 0 : -1, this.unsigned);
2246
+ };
2247
+ LongPrototype.shr = LongPrototype.shiftRight;
2248
+ LongPrototype.shiftRightUnsigned = function shiftRightUnsigned(numBits) {
2249
+ if (isLong(numBits))
2250
+ numBits = numBits.toInt();
2251
+ if ((numBits &= 63) === 0)
2252
+ return this;
2253
+ if (numBits < 32)
2254
+ return fromBits(this.low >>> numBits | this.high << 32 - numBits, this.high >>> numBits, this.unsigned);
2255
+ if (numBits === 32)
2256
+ return fromBits(this.high, 0, this.unsigned);
2257
+ return fromBits(this.high >>> numBits - 32, 0, this.unsigned);
2258
+ };
2259
+ LongPrototype.shru = LongPrototype.shiftRightUnsigned;
2260
+ LongPrototype.shr_u = LongPrototype.shiftRightUnsigned;
2261
+ LongPrototype.rotateLeft = function rotateLeft(numBits) {
2262
+ var b;
2263
+ if (isLong(numBits))
2264
+ numBits = numBits.toInt();
2265
+ if ((numBits &= 63) === 0)
2266
+ return this;
2267
+ if (numBits === 32)
2268
+ return fromBits(this.high, this.low, this.unsigned);
2269
+ if (numBits < 32) {
2270
+ b = 32 - numBits;
2271
+ return fromBits(this.low << numBits | this.high >>> b, this.high << numBits | this.low >>> b, this.unsigned);
2272
+ }
2273
+ numBits -= 32;
2274
+ b = 32 - numBits;
2275
+ return fromBits(this.high << numBits | this.low >>> b, this.low << numBits | this.high >>> b, this.unsigned);
2276
+ };
2277
+ LongPrototype.rotl = LongPrototype.rotateLeft;
2278
+ LongPrototype.rotateRight = function rotateRight(numBits) {
2279
+ var b;
2280
+ if (isLong(numBits))
2281
+ numBits = numBits.toInt();
2282
+ if ((numBits &= 63) === 0)
2283
+ return this;
2284
+ if (numBits === 32)
2285
+ return fromBits(this.high, this.low, this.unsigned);
2286
+ if (numBits < 32) {
2287
+ b = 32 - numBits;
2288
+ return fromBits(this.high << b | this.low >>> numBits, this.low << b | this.high >>> numBits, this.unsigned);
2289
+ }
2290
+ numBits -= 32;
2291
+ b = 32 - numBits;
2292
+ return fromBits(this.low << b | this.high >>> numBits, this.high << b | this.low >>> numBits, this.unsigned);
2293
+ };
2294
+ LongPrototype.rotr = LongPrototype.rotateRight;
2295
+ LongPrototype.toSigned = function toSigned() {
2296
+ if (!this.unsigned)
2297
+ return this;
2298
+ return fromBits(this.low, this.high, false);
2299
+ };
2300
+ LongPrototype.toUnsigned = function toUnsigned() {
2301
+ if (this.unsigned)
2302
+ return this;
2303
+ return fromBits(this.low, this.high, true);
2304
+ };
2305
+ LongPrototype.toBytes = function toBytes(le) {
2306
+ return le ? this.toBytesLE() : this.toBytesBE();
2307
+ };
2308
+ LongPrototype.toBytesLE = function toBytesLE() {
2309
+ var hi = this.high, lo = this.low;
2310
+ return [
2311
+ lo & 255,
2312
+ lo >>> 8 & 255,
2313
+ lo >>> 16 & 255,
2314
+ lo >>> 24,
2315
+ hi & 255,
2316
+ hi >>> 8 & 255,
2317
+ hi >>> 16 & 255,
2318
+ hi >>> 24
2319
+ ];
2320
+ };
2321
+ LongPrototype.toBytesBE = function toBytesBE() {
2322
+ var hi = this.high, lo = this.low;
2323
+ return [
2324
+ hi >>> 24,
2325
+ hi >>> 16 & 255,
2326
+ hi >>> 8 & 255,
2327
+ hi & 255,
2328
+ lo >>> 24,
2329
+ lo >>> 16 & 255,
2330
+ lo >>> 8 & 255,
2331
+ lo & 255
2332
+ ];
2333
+ };
2334
+ Long.fromBytes = function fromBytes(bytes, unsigned, le) {
2335
+ return le ? Long.fromBytesLE(bytes, unsigned) : Long.fromBytesBE(bytes, unsigned);
2336
+ };
2337
+ Long.fromBytesLE = function fromBytesLE(bytes, unsigned) {
2338
+ return new Long(
2339
+ bytes[0] | bytes[1] << 8 | bytes[2] << 16 | bytes[3] << 24,
2340
+ bytes[4] | bytes[5] << 8 | bytes[6] << 16 | bytes[7] << 24,
2341
+ unsigned
2342
+ );
2343
+ };
2344
+ Long.fromBytesBE = function fromBytesBE(bytes, unsigned) {
2345
+ return new Long(
2346
+ bytes[4] << 24 | bytes[5] << 16 | bytes[6] << 8 | bytes[7],
2347
+ bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3],
2348
+ unsigned
2349
+ );
2350
+ };
2351
+ var long_default = Long;
2352
+
2353
+ // ../services/protobuf/ts/faucet/faucet.ts
2354
+ var import_minimal = __toESM(require_minimal2(), 1);
2355
+ function createBaseLinkedTwitterPair() {
2356
+ return { username: "", address: "" };
2357
+ }
2358
+ var LinkedTwitterPair = {
2359
+ encode(message, writer = import_minimal.default.Writer.create()) {
2360
+ if (message.username !== "") {
2361
+ writer.uint32(10).string(message.username);
2362
+ }
2363
+ if (message.address !== "") {
2364
+ writer.uint32(18).string(message.address);
2365
+ }
2366
+ return writer;
2367
+ },
2368
+ decode(input, length) {
2369
+ const reader = input instanceof import_minimal.default.Reader ? input : new import_minimal.default.Reader(input);
2370
+ let end = length === void 0 ? reader.len : reader.pos + length;
2371
+ const message = createBaseLinkedTwitterPair();
2372
+ while (reader.pos < end) {
2373
+ const tag = reader.uint32();
2374
+ switch (tag >>> 3) {
2375
+ case 1:
2376
+ message.username = reader.string();
2377
+ break;
2378
+ case 2:
2379
+ message.address = reader.string();
2380
+ break;
2381
+ default:
2382
+ reader.skipType(tag & 7);
2383
+ break;
2384
+ }
2385
+ }
2386
+ return message;
2387
+ },
2388
+ fromPartial(object) {
2389
+ const message = createBaseLinkedTwitterPair();
2390
+ message.username = object.username ?? "";
2391
+ message.address = object.address ?? "";
2392
+ return message;
2393
+ }
2394
+ };
2395
+ function createBaseDripRequest() {
2396
+ return { username: "", address: "" };
2397
+ }
2398
+ var DripRequest = {
2399
+ encode(message, writer = import_minimal.default.Writer.create()) {
2400
+ if (message.username !== "") {
2401
+ writer.uint32(10).string(message.username);
2402
+ }
2403
+ if (message.address !== "") {
2404
+ writer.uint32(18).string(message.address);
2405
+ }
2406
+ return writer;
2407
+ },
2408
+ decode(input, length) {
2409
+ const reader = input instanceof import_minimal.default.Reader ? input : new import_minimal.default.Reader(input);
2410
+ let end = length === void 0 ? reader.len : reader.pos + length;
2411
+ const message = createBaseDripRequest();
2412
+ while (reader.pos < end) {
2413
+ const tag = reader.uint32();
2414
+ switch (tag >>> 3) {
2415
+ case 1:
2416
+ message.username = reader.string();
2417
+ break;
2418
+ case 2:
2419
+ message.address = reader.string();
2420
+ break;
2421
+ default:
2422
+ reader.skipType(tag & 7);
2423
+ break;
2424
+ }
2425
+ }
2426
+ return message;
2427
+ },
2428
+ fromPartial(object) {
2429
+ const message = createBaseDripRequest();
2430
+ message.username = object.username ?? "";
2431
+ message.address = object.address ?? "";
2432
+ return message;
2433
+ }
2434
+ };
2435
+ function createBaseDripDevRequest() {
2436
+ return { address: "" };
2437
+ }
2438
+ var DripDevRequest = {
2439
+ encode(message, writer = import_minimal.default.Writer.create()) {
2440
+ if (message.address !== "") {
2441
+ writer.uint32(10).string(message.address);
2442
+ }
2443
+ return writer;
2444
+ },
2445
+ decode(input, length) {
2446
+ const reader = input instanceof import_minimal.default.Reader ? input : new import_minimal.default.Reader(input);
2447
+ let end = length === void 0 ? reader.len : reader.pos + length;
2448
+ const message = createBaseDripDevRequest();
2449
+ while (reader.pos < end) {
2450
+ const tag = reader.uint32();
2451
+ switch (tag >>> 3) {
2452
+ case 1:
2453
+ message.address = reader.string();
2454
+ break;
2455
+ default:
2456
+ reader.skipType(tag & 7);
2457
+ break;
2458
+ }
2459
+ }
2460
+ return message;
2461
+ },
2462
+ fromPartial(object) {
2463
+ const message = createBaseDripDevRequest();
2464
+ message.address = object.address ?? "";
2465
+ return message;
2466
+ }
2467
+ };
2468
+ function createBaseDripResponse() {
2469
+ return { dripTxHash: "", ecsTxHash: "" };
2470
+ }
2471
+ var DripResponse = {
2472
+ encode(message, writer = import_minimal.default.Writer.create()) {
2473
+ if (message.dripTxHash !== "") {
2474
+ writer.uint32(10).string(message.dripTxHash);
2475
+ }
2476
+ if (message.ecsTxHash !== "") {
2477
+ writer.uint32(18).string(message.ecsTxHash);
2478
+ }
2479
+ return writer;
2480
+ },
2481
+ decode(input, length) {
2482
+ const reader = input instanceof import_minimal.default.Reader ? input : new import_minimal.default.Reader(input);
2483
+ let end = length === void 0 ? reader.len : reader.pos + length;
2484
+ const message = createBaseDripResponse();
2485
+ while (reader.pos < end) {
2486
+ const tag = reader.uint32();
2487
+ switch (tag >>> 3) {
2488
+ case 1:
2489
+ message.dripTxHash = reader.string();
2490
+ break;
2491
+ case 2:
2492
+ message.ecsTxHash = reader.string();
2493
+ break;
2494
+ default:
2495
+ reader.skipType(tag & 7);
2496
+ break;
2497
+ }
2498
+ }
2499
+ return message;
2500
+ },
2501
+ fromPartial(object) {
2502
+ const message = createBaseDripResponse();
2503
+ message.dripTxHash = object.dripTxHash ?? "";
2504
+ message.ecsTxHash = object.ecsTxHash ?? "";
2505
+ return message;
2506
+ }
2507
+ };
2508
+ function createBaseTimeUntilDripResponse() {
2509
+ return { timeUntilDripMinutes: 0, timeUntilDripSeconds: 0 };
2510
+ }
2511
+ var TimeUntilDripResponse = {
2512
+ encode(message, writer = import_minimal.default.Writer.create()) {
2513
+ if (message.timeUntilDripMinutes !== 0) {
2514
+ writer.uint32(9).double(message.timeUntilDripMinutes);
2515
+ }
2516
+ if (message.timeUntilDripSeconds !== 0) {
2517
+ writer.uint32(17).double(message.timeUntilDripSeconds);
2518
+ }
2519
+ return writer;
2520
+ },
2521
+ decode(input, length) {
2522
+ const reader = input instanceof import_minimal.default.Reader ? input : new import_minimal.default.Reader(input);
2523
+ let end = length === void 0 ? reader.len : reader.pos + length;
2524
+ const message = createBaseTimeUntilDripResponse();
2525
+ while (reader.pos < end) {
2526
+ const tag = reader.uint32();
2527
+ switch (tag >>> 3) {
2528
+ case 1:
2529
+ message.timeUntilDripMinutes = reader.double();
2530
+ break;
2531
+ case 2:
2532
+ message.timeUntilDripSeconds = reader.double();
2533
+ break;
2534
+ default:
2535
+ reader.skipType(tag & 7);
2536
+ break;
2537
+ }
2538
+ }
2539
+ return message;
2540
+ },
2541
+ fromPartial(object) {
2542
+ const message = createBaseTimeUntilDripResponse();
2543
+ message.timeUntilDripMinutes = object.timeUntilDripMinutes ?? 0;
2544
+ message.timeUntilDripSeconds = object.timeUntilDripSeconds ?? 0;
2545
+ return message;
2546
+ }
2547
+ };
2548
+ function createBaseGetLinkedTwittersRequest() {
2549
+ return {};
2550
+ }
2551
+ var GetLinkedTwittersRequest = {
2552
+ encode(_, writer = import_minimal.default.Writer.create()) {
2553
+ return writer;
2554
+ },
2555
+ decode(input, length) {
2556
+ const reader = input instanceof import_minimal.default.Reader ? input : new import_minimal.default.Reader(input);
2557
+ let end = length === void 0 ? reader.len : reader.pos + length;
2558
+ const message = createBaseGetLinkedTwittersRequest();
2559
+ while (reader.pos < end) {
2560
+ const tag = reader.uint32();
2561
+ switch (tag >>> 3) {
2562
+ default:
2563
+ reader.skipType(tag & 7);
2564
+ break;
2565
+ }
2566
+ }
2567
+ return message;
2568
+ },
2569
+ fromPartial(_) {
2570
+ const message = createBaseGetLinkedTwittersRequest();
2571
+ return message;
2572
+ }
2573
+ };
2574
+ function createBaseGetLinkedTwittersResponse() {
2575
+ return { linkedTwitters: [] };
2576
+ }
2577
+ var GetLinkedTwittersResponse = {
2578
+ encode(message, writer = import_minimal.default.Writer.create()) {
2579
+ for (const v of message.linkedTwitters) {
2580
+ LinkedTwitterPair.encode(v, writer.uint32(10).fork()).ldelim();
2581
+ }
2582
+ return writer;
2583
+ },
2584
+ decode(input, length) {
2585
+ const reader = input instanceof import_minimal.default.Reader ? input : new import_minimal.default.Reader(input);
2586
+ let end = length === void 0 ? reader.len : reader.pos + length;
2587
+ const message = createBaseGetLinkedTwittersResponse();
2588
+ while (reader.pos < end) {
2589
+ const tag = reader.uint32();
2590
+ switch (tag >>> 3) {
2591
+ case 1:
2592
+ message.linkedTwitters.push(LinkedTwitterPair.decode(reader, reader.uint32()));
2593
+ break;
2594
+ default:
2595
+ reader.skipType(tag & 7);
2596
+ break;
2597
+ }
2598
+ }
2599
+ return message;
2600
+ },
2601
+ fromPartial(object) {
2602
+ const message = createBaseGetLinkedTwittersResponse();
2603
+ message.linkedTwitters = object.linkedTwitters?.map((e) => LinkedTwitterPair.fromPartial(e)) || [];
2604
+ return message;
2605
+ }
2606
+ };
2607
+ function createBaseLinkedTwitterForAddressRequest() {
2608
+ return { address: "" };
2609
+ }
2610
+ var LinkedTwitterForAddressRequest = {
2611
+ encode(message, writer = import_minimal.default.Writer.create()) {
2612
+ if (message.address !== "") {
2613
+ writer.uint32(10).string(message.address);
2614
+ }
2615
+ return writer;
2616
+ },
2617
+ decode(input, length) {
2618
+ const reader = input instanceof import_minimal.default.Reader ? input : new import_minimal.default.Reader(input);
2619
+ let end = length === void 0 ? reader.len : reader.pos + length;
2620
+ const message = createBaseLinkedTwitterForAddressRequest();
2621
+ while (reader.pos < end) {
2622
+ const tag = reader.uint32();
2623
+ switch (tag >>> 3) {
2624
+ case 1:
2625
+ message.address = reader.string();
2626
+ break;
2627
+ default:
2628
+ reader.skipType(tag & 7);
2629
+ break;
2630
+ }
2631
+ }
2632
+ return message;
2633
+ },
2634
+ fromPartial(object) {
2635
+ const message = createBaseLinkedTwitterForAddressRequest();
2636
+ message.address = object.address ?? "";
2637
+ return message;
2638
+ }
2639
+ };
2640
+ function createBaseLinkedTwitterForAddressResponse() {
2641
+ return { username: "" };
2642
+ }
2643
+ var LinkedTwitterForAddressResponse = {
2644
+ encode(message, writer = import_minimal.default.Writer.create()) {
2645
+ if (message.username !== "") {
2646
+ writer.uint32(10).string(message.username);
2647
+ }
2648
+ return writer;
2649
+ },
2650
+ decode(input, length) {
2651
+ const reader = input instanceof import_minimal.default.Reader ? input : new import_minimal.default.Reader(input);
2652
+ let end = length === void 0 ? reader.len : reader.pos + length;
2653
+ const message = createBaseLinkedTwitterForAddressResponse();
2654
+ while (reader.pos < end) {
2655
+ const tag = reader.uint32();
2656
+ switch (tag >>> 3) {
2657
+ case 1:
2658
+ message.username = reader.string();
2659
+ break;
2660
+ default:
2661
+ reader.skipType(tag & 7);
2662
+ break;
2663
+ }
2664
+ }
2665
+ return message;
2666
+ },
2667
+ fromPartial(object) {
2668
+ const message = createBaseLinkedTwitterForAddressResponse();
2669
+ message.username = object.username ?? "";
2670
+ return message;
2671
+ }
2672
+ };
2673
+ function createBaseLinkedAddressForTwitterRequest() {
2674
+ return { username: "" };
2675
+ }
2676
+ var LinkedAddressForTwitterRequest = {
2677
+ encode(message, writer = import_minimal.default.Writer.create()) {
2678
+ if (message.username !== "") {
2679
+ writer.uint32(10).string(message.username);
2680
+ }
2681
+ return writer;
2682
+ },
2683
+ decode(input, length) {
2684
+ const reader = input instanceof import_minimal.default.Reader ? input : new import_minimal.default.Reader(input);
2685
+ let end = length === void 0 ? reader.len : reader.pos + length;
2686
+ const message = createBaseLinkedAddressForTwitterRequest();
2687
+ while (reader.pos < end) {
2688
+ const tag = reader.uint32();
2689
+ switch (tag >>> 3) {
2690
+ case 1:
2691
+ message.username = reader.string();
2692
+ break;
2693
+ default:
2694
+ reader.skipType(tag & 7);
2695
+ break;
2696
+ }
2697
+ }
2698
+ return message;
2699
+ },
2700
+ fromPartial(object) {
2701
+ const message = createBaseLinkedAddressForTwitterRequest();
2702
+ message.username = object.username ?? "";
2703
+ return message;
2704
+ }
2705
+ };
2706
+ function createBaseLinkedAddressForTwitterResponse() {
2707
+ return { address: "" };
2708
+ }
2709
+ var LinkedAddressForTwitterResponse = {
2710
+ encode(message, writer = import_minimal.default.Writer.create()) {
2711
+ if (message.address !== "") {
2712
+ writer.uint32(10).string(message.address);
2713
+ }
2714
+ return writer;
2715
+ },
2716
+ decode(input, length) {
2717
+ const reader = input instanceof import_minimal.default.Reader ? input : new import_minimal.default.Reader(input);
2718
+ let end = length === void 0 ? reader.len : reader.pos + length;
2719
+ const message = createBaseLinkedAddressForTwitterResponse();
2720
+ while (reader.pos < end) {
2721
+ const tag = reader.uint32();
2722
+ switch (tag >>> 3) {
2723
+ case 1:
2724
+ message.address = reader.string();
2725
+ break;
2726
+ default:
2727
+ reader.skipType(tag & 7);
2728
+ break;
2729
+ }
2730
+ }
2731
+ return message;
2732
+ },
2733
+ fromPartial(object) {
2734
+ const message = createBaseLinkedAddressForTwitterResponse();
2735
+ message.address = object.address ?? "";
2736
+ return message;
2737
+ }
2738
+ };
2739
+ function createBaseSetLinkedTwitterRequest() {
2740
+ return { address: "", username: "", signature: "" };
2741
+ }
2742
+ var SetLinkedTwitterRequest = {
2743
+ encode(message, writer = import_minimal.default.Writer.create()) {
2744
+ if (message.address !== "") {
2745
+ writer.uint32(10).string(message.address);
2746
+ }
2747
+ if (message.username !== "") {
2748
+ writer.uint32(18).string(message.username);
2749
+ }
2750
+ if (message.signature !== "") {
2751
+ writer.uint32(26).string(message.signature);
2752
+ }
2753
+ return writer;
2754
+ },
2755
+ decode(input, length) {
2756
+ const reader = input instanceof import_minimal.default.Reader ? input : new import_minimal.default.Reader(input);
2757
+ let end = length === void 0 ? reader.len : reader.pos + length;
2758
+ const message = createBaseSetLinkedTwitterRequest();
2759
+ while (reader.pos < end) {
2760
+ const tag = reader.uint32();
2761
+ switch (tag >>> 3) {
2762
+ case 1:
2763
+ message.address = reader.string();
2764
+ break;
2765
+ case 2:
2766
+ message.username = reader.string();
2767
+ break;
2768
+ case 3:
2769
+ message.signature = reader.string();
2770
+ break;
2771
+ default:
2772
+ reader.skipType(tag & 7);
2773
+ break;
2774
+ }
2775
+ }
2776
+ return message;
2777
+ },
2778
+ fromPartial(object) {
2779
+ const message = createBaseSetLinkedTwitterRequest();
2780
+ message.address = object.address ?? "";
2781
+ message.username = object.username ?? "";
2782
+ message.signature = object.signature ?? "";
2783
+ return message;
2784
+ }
2785
+ };
2786
+ function createBaseSetLinkedTwitterResponse() {
2787
+ return {};
2788
+ }
2789
+ var SetLinkedTwitterResponse = {
2790
+ encode(_, writer = import_minimal.default.Writer.create()) {
2791
+ return writer;
2792
+ },
2793
+ decode(input, length) {
2794
+ const reader = input instanceof import_minimal.default.Reader ? input : new import_minimal.default.Reader(input);
2795
+ let end = length === void 0 ? reader.len : reader.pos + length;
2796
+ const message = createBaseSetLinkedTwitterResponse();
2797
+ while (reader.pos < end) {
2798
+ const tag = reader.uint32();
2799
+ switch (tag >>> 3) {
2800
+ default:
2801
+ reader.skipType(tag & 7);
2802
+ break;
2803
+ }
2804
+ }
2805
+ return message;
2806
+ },
2807
+ fromPartial(_) {
2808
+ const message = createBaseSetLinkedTwitterResponse();
2809
+ return message;
2810
+ }
2811
+ };
2812
+ var FaucetServiceDefinition = {
2813
+ name: "FaucetService",
2814
+ fullName: "faucet.FaucetService",
2815
+ methods: {
2816
+ drip: {
2817
+ name: "Drip",
2818
+ requestType: DripRequest,
2819
+ requestStream: false,
2820
+ responseType: DripResponse,
2821
+ responseStream: false,
2822
+ options: {}
2823
+ },
2824
+ dripDev: {
2825
+ name: "DripDev",
2826
+ requestType: DripDevRequest,
2827
+ requestStream: false,
2828
+ responseType: DripResponse,
2829
+ responseStream: false,
2830
+ options: {}
2831
+ },
2832
+ dripVerifyTweet: {
2833
+ name: "DripVerifyTweet",
2834
+ requestType: DripRequest,
2835
+ requestStream: false,
2836
+ responseType: DripResponse,
2837
+ responseStream: false,
2838
+ options: {}
2839
+ },
2840
+ timeUntilDrip: {
2841
+ name: "TimeUntilDrip",
2842
+ requestType: DripRequest,
2843
+ requestStream: false,
2844
+ responseType: TimeUntilDripResponse,
2845
+ responseStream: false,
2846
+ options: {}
2847
+ },
2848
+ getLinkedTwitters: {
2849
+ name: "GetLinkedTwitters",
2850
+ requestType: GetLinkedTwittersRequest,
2851
+ requestStream: false,
2852
+ responseType: GetLinkedTwittersResponse,
2853
+ responseStream: false,
2854
+ options: {}
2855
+ },
2856
+ getLinkedTwitterForAddress: {
2857
+ name: "GetLinkedTwitterForAddress",
2858
+ requestType: LinkedTwitterForAddressRequest,
2859
+ requestStream: false,
2860
+ responseType: LinkedTwitterForAddressResponse,
2861
+ responseStream: false,
2862
+ options: {}
2863
+ },
2864
+ getLinkedAddressForTwitter: {
2865
+ name: "GetLinkedAddressForTwitter",
2866
+ requestType: LinkedAddressForTwitterRequest,
2867
+ requestStream: false,
2868
+ responseType: LinkedAddressForTwitterResponse,
2869
+ responseStream: false,
2870
+ options: {}
2871
+ },
2872
+ /** Admin utility endpoints for modifying state. Requires a signature with faucet private key. */
2873
+ setLinkedTwitter: {
2874
+ name: "SetLinkedTwitter",
2875
+ requestType: SetLinkedTwitterRequest,
2876
+ requestStream: false,
2877
+ responseType: SetLinkedTwitterResponse,
2878
+ responseStream: false,
2879
+ options: {}
2880
+ }
2881
+ }
2882
+ };
2883
+ var globalThis = (() => {
2884
+ if (typeof globalThis !== "undefined") {
2885
+ return globalThis;
2886
+ }
2887
+ if (typeof self !== "undefined") {
2888
+ return self;
2889
+ }
2890
+ if (typeof window !== "undefined") {
2891
+ return window;
2892
+ }
2893
+ if (typeof global !== "undefined") {
2894
+ return global;
2895
+ }
2896
+ throw "Unable to locate global object";
2897
+ })();
2898
+ if (import_minimal.default.util.Long !== long_default) {
2899
+ import_minimal.default.util.Long = long_default;
2900
+ import_minimal.default.configure();
2901
+ }
2902
+
2903
+ // src/commands/faucet.ts
2904
+ import { createChannel, createClient } from "nice-grpc-web";
2905
+ import chalk from "chalk";
2906
+ import { NodeHttpTransport } from "@improbable-eng/grpc-web-node-http-transport";
2907
+ function createFaucetService(url) {
2908
+ return createClient(FaucetServiceDefinition, createChannel(url, NodeHttpTransport()));
2909
+ }
2910
+ var commandModule2 = {
2911
+ command: "faucet",
2912
+ describe: "Interact with a MUD faucet",
2913
+ builder(yargs) {
2914
+ return yargs.options({
2915
+ dripDev: {
2916
+ type: "boolean",
2917
+ desc: "Request a drip from the dev endpoint (requires faucet to have dev mode enabled)",
2918
+ default: true
2919
+ },
2920
+ faucetUrl: {
2921
+ type: "string",
2922
+ desc: "URL of the MUD faucet",
2923
+ default: "https://faucet.testnet-mud-services.linfra.xyz"
2924
+ },
2925
+ address: {
2926
+ type: "string",
2927
+ desc: "Ethereum address to fund",
2928
+ required: true
2929
+ }
2930
+ });
2931
+ },
2932
+ async handler({ dripDev, faucetUrl, address }) {
2933
+ const faucet = createFaucetService(faucetUrl);
2934
+ if (dripDev) {
2935
+ console.log(chalk.yellow("Dripping to", address));
2936
+ await faucet.dripDev({ address });
2937
+ console.log(chalk.yellow("Success"));
2938
+ }
2939
+ process.exit(0);
2940
+ }
2941
+ };
2942
+ var faucet_default = commandModule2;
2943
+
2944
+ // src/commands/gas-report.ts
2945
+ import { readFileSync, writeFileSync, rmSync as rmSync2 } from "fs";
2946
+ import { execa } from "execa";
2947
+ import chalk2 from "chalk";
2948
+ import { table, getBorderCharacters } from "table";
2949
+ var commandModule3 = {
2950
+ command: "gas-report",
2951
+ describe: "Create a gas report",
2952
+ builder(yargs) {
2953
+ return yargs.options({
2954
+ path: { type: "array", string: true, default: ["Gas.t.sol"], desc: "File containing the gas tests" },
2955
+ save: { type: "string", desc: "Save the gas report to a file" },
2956
+ compare: { type: "string", desc: "Compare to an existing gas report" }
2957
+ });
2958
+ },
2959
+ async handler({ path: path6, save, compare: compare2 }) {
2960
+ let gasReport = [];
2961
+ for (const file of path6) {
2962
+ gasReport = gasReport.concat(await runGasReport(file));
2963
+ }
2964
+ const compareGasReport = [];
2965
+ if (compare2) {
2966
+ try {
2967
+ const compareFileContents = readFileSync(compare2, "utf8");
2968
+ const compareGasReportRegex = new RegExp(/\((.*)\) \| (.*) \[(.*)\]: (.*)/g);
2969
+ let compareGasReportMatch;
2970
+ while ((compareGasReportMatch = compareGasReportRegex.exec(compareFileContents)) !== null) {
2971
+ const source = compareGasReportMatch[1];
2972
+ const name = compareGasReportMatch[2];
2973
+ const functionCall = compareGasReportMatch[3];
2974
+ const gasUsed = compareGasReportMatch[4];
2975
+ compareGasReport.push({ source, name, functionCall, gasUsed: parseInt(gasUsed) });
2976
+ }
2977
+ } catch {
2978
+ console.log(chalk2.red(`Gas report to compare not found: ${compare2}`));
2979
+ compare2 = void 0;
2980
+ }
2981
+ }
2982
+ gasReport = gasReport.map((entry) => {
2983
+ const prevEntry = compareGasReport.find((e) => e.name === entry.name && e.functionCall === entry.functionCall);
2984
+ return { ...entry, prevGasUsed: prevEntry?.gasUsed };
2985
+ });
2986
+ printGasReport(gasReport, compare2);
2987
+ if (save)
2988
+ saveGasReport(gasReport, save);
2989
+ process.exit(0);
2990
+ }
2991
+ };
2992
+ var gas_report_default = commandModule3;
2993
+ async function runGasReport(path6) {
2994
+ if (!path6.endsWith(".t.sol")) {
2995
+ console.log("Skipping gas report for", chalk2.bold(path6), "(not a test file)");
2996
+ return [];
2997
+ }
2998
+ console.log("Running gas report for", chalk2.bold(path6));
2999
+ const gasReport = [];
3000
+ const fileContents = readFileSync(path6, "utf8");
3001
+ let newFile = fileContents;
3002
+ const functionRegex = new RegExp(/function (.*){/g);
3003
+ let functionMatch;
3004
+ while ((functionMatch = functionRegex.exec(fileContents)) !== null) {
3005
+ const functionSignature = functionMatch[0];
3006
+ newFile = newFile.replace(functionSignature, `${functionSignature}
3007
+ uint256 _gasreport;`);
3008
+ }
3009
+ const regex = new RegExp(/\/\/ !gasreport (.*)\n(.*)/g);
3010
+ let match;
3011
+ while ((match = regex.exec(fileContents)) !== null) {
3012
+ const name = match[1];
3013
+ const functionCall = match[2].trim();
3014
+ newFile = newFile.replace(
3015
+ match[0],
3016
+ `
3017
+ _gasreport = gasleft();
3018
+ ${functionCall}
3019
+ _gasreport = _gasreport - gasleft();
3020
+ console.log("GAS REPORT: ${name} [${functionCall.replaceAll('"', '\\"')}]:", _gasreport);`
3021
+ );
3022
+ }
3023
+ newFile = newFile.replace(/pure/g, "view");
3024
+ const tempFileName = path6.replace(/\.t\.sol$/, "MudGasReport.t.sol");
3025
+ writeFileSync(tempFileName, newFile);
3026
+ const child = execa("forge", ["test", "--match-path", tempFileName, "-vvv"], {
3027
+ stdio: ["inherit", "pipe", "inherit"]
3028
+ });
3029
+ let logs = "";
3030
+ try {
3031
+ logs = (await child).stdout;
3032
+ rmSync2(tempFileName);
3033
+ } catch (e) {
3034
+ console.log(e.stdout ?? e);
3035
+ console.log(chalk2.red("\n-----------\nError while running the gas report (see above)"));
3036
+ rmSync2(tempFileName);
3037
+ process.exit();
3038
+ }
3039
+ const gasReportRegex = new RegExp(/GAS REPORT: (.*) \[(.*)\]: (.*)/g);
3040
+ let gasReportMatch;
3041
+ while ((gasReportMatch = gasReportRegex.exec(logs)) !== null) {
3042
+ const name = gasReportMatch[1];
3043
+ const functionCall = gasReportMatch[2].replace(";", "");
3044
+ const gasUsed = gasReportMatch[3];
3045
+ gasReport.push({ source: path6, name, functionCall, gasUsed: parseInt(gasUsed) });
3046
+ }
3047
+ return gasReport;
3048
+ }
3049
+ function printGasReport(gasReport, compare2) {
3050
+ if (compare2)
3051
+ console.log(chalk2.bold(`Gas report compared to ${compare2}`));
3052
+ const headers = [
3053
+ chalk2.bold("Source"),
3054
+ chalk2.bold("Name"),
3055
+ chalk2.bold("Function call"),
3056
+ chalk2.bold("Gas used"),
3057
+ ...compare2 ? [chalk2.bold("Prev gas used"), chalk2.bold("Difference")] : []
3058
+ ];
3059
+ const values = gasReport.map((entry) => {
3060
+ const diff = entry.prevGasUsed ? entry.gasUsed - entry.prevGasUsed : 0;
3061
+ const diffEntry = diff > 0 ? chalk2.red(`+${diff}`) : diff < 0 ? chalk2.green(`${diff}`) : diff;
3062
+ const compareColumns = compare2 ? [entry.prevGasUsed ?? "n/a", diffEntry] : [];
3063
+ const gasUsedEntry = diff > 0 ? chalk2.red(entry.gasUsed) : diff < 0 ? chalk2.green(entry.gasUsed) : entry.gasUsed;
3064
+ return [entry.source, entry.name, entry.functionCall, gasUsedEntry, ...compareColumns];
3065
+ });
3066
+ const rows = [headers, ...values];
3067
+ console.log(table(rows, { border: getBorderCharacters("norc") }));
3068
+ }
3069
+ function saveGasReport(gasReport, path6) {
3070
+ console.log(chalk2.bold(`Saving gas report to ${path6}`));
3071
+ const serializedGasReport = gasReport.map((entry) => `(${entry.source}) | ${entry.name} [${entry.functionCall}]: ${entry.gasUsed}`).join("\n");
3072
+ writeFileSync(path6, serializedGasReport);
3073
+ }
3074
+
3075
+ // src/commands/hello.ts
3076
+ var commandModule4 = {
3077
+ command: "hello <name>",
3078
+ describe: "Greet <name> with Hello",
3079
+ builder(yargs) {
3080
+ return yargs.options({
3081
+ upper: { type: "boolean" }
3082
+ }).positional("name", { type: "string", demandOption: true });
3083
+ },
3084
+ handler({ name }) {
3085
+ const greeting = `Gm, ${name}!`;
3086
+ console.log(greeting);
3087
+ process.exit(0);
3088
+ }
3089
+ };
3090
+ var hello_default = commandModule4;
3091
+
3092
+ // src/commands/tablegen.ts
3093
+ var commandModule5 = {
3094
+ command: "tablegen",
3095
+ describe: "Autogenerate MUD Store table libraries based on the config file",
3096
+ builder(yargs) {
3097
+ return yargs.options({
3098
+ configPath: { type: "string", desc: "Path to the config file" }
3099
+ });
3100
+ },
3101
+ async handler({ configPath }) {
3102
+ const srcDirectory = await getSrcDirectory();
3103
+ const config = await loadStoreConfig(configPath);
3104
+ await tablegen(config, srcDirectory);
3105
+ process.exit(0);
3106
+ }
3107
+ };
3108
+ var tablegen_default = commandModule5;
3109
+
3110
+ // src/commands/tsgen.ts
3111
+ var commandModule6 = {
3112
+ command: "tsgen",
3113
+ describe: "Autogenerate MUD typescript definitions based on the config file",
3114
+ builder(yargs) {
3115
+ return yargs.options({
3116
+ configPath: { type: "string", demandOption: true, desc: "Path to the config file" },
3117
+ out: { type: "string", demandOption: true, desc: "Directory to output MUD typescript definition files" }
3118
+ });
3119
+ },
3120
+ async handler(args) {
3121
+ const { configPath, out } = args;
3122
+ const config = await loadStoreConfig(configPath);
3123
+ await tsgen(config, out);
3124
+ process.exit(0);
3125
+ }
3126
+ };
3127
+ var tsgen_default = commandModule6;
3128
+
3129
+ // src/commands/deploy-v2.ts
3130
+ import chalk3 from "chalk";
3131
+ import glob from "glob";
3132
+ import path2, { basename } from "path";
3133
+ import { mkdirSync, writeFileSync as writeFileSync2 } from "fs";
3134
+
3135
+ // src/utils/getChainId.ts
3136
+ import { ethers } from "ethers";
3137
+ async function getChainId(rpc) {
3138
+ const { result: chainId } = await ethers.utils.fetchJson(
3139
+ rpc,
3140
+ '{ "id": 42, "jsonrpc": "2.0", "method": "eth_chainId", "params": [ ] }'
3141
+ );
3142
+ return Number(chainId);
3143
+ }
3144
+
3145
+ // src/commands/deploy-v2.ts
3146
+ var yDeployOptions = {
3147
+ configPath: { type: "string", desc: "Path to the config file" },
3148
+ clean: { type: "boolean", desc: "Remove the build forge artifacts and cache directories before building" },
3149
+ printConfig: { type: "boolean", desc: "Print the resolved config" },
3150
+ profile: { type: "string", desc: "The foundry profile to use" },
3151
+ debug: { type: "boolean", desc: "Print debug logs, like full error messages" },
3152
+ priorityFeeMultiplier: {
3153
+ type: "number",
3154
+ desc: "Multiply the estimated priority fee by the provided factor",
3155
+ default: 1
3156
+ },
3157
+ saveDeployment: { type: "boolean", desc: "Save the deployment info to a file", default: true },
3158
+ rpc: { type: "string", desc: "The RPC URL to use. Defaults to the RPC url from the local foundry.toml" }
3159
+ };
3160
+ async function deployHandler(args) {
3161
+ args.profile = args.profile ?? process.env.FOUNDRY_PROFILE;
3162
+ const { configPath, printConfig, profile, clean } = args;
3163
+ const rpc = args.rpc ?? await getRpcUrl(profile);
3164
+ console.log(
3165
+ chalk3.bgBlue(
3166
+ chalk3.whiteBright(`
3167
+ Deploying MUD v2 contracts${profile ? " with profile " + profile : ""} to RPC ${rpc}
3168
+ `)
3169
+ )
3170
+ );
3171
+ if (clean)
3172
+ await forge(["clean"], { profile });
3173
+ await forge(["build"], { profile });
3174
+ const srcDir = await getSrcDirectory();
3175
+ const existingContracts = glob.sync(`${srcDir}/**/*.sol`).map((path6) => basename(path6, ".sol"));
3176
+ const worldConfig = await loadWorldConfig(configPath, existingContracts);
3177
+ const storeConfig = await loadStoreConfig(configPath);
3178
+ const mudConfig = { ...worldConfig, ...storeConfig };
3179
+ if (printConfig)
3180
+ console.log(chalk3.green("\nResolved config:\n"), JSON.stringify(mudConfig, null, 2));
3181
+ try {
3182
+ const privateKey = process.env.PRIVATE_KEY;
3183
+ if (!privateKey)
3184
+ throw new MUDError("Missing PRIVATE_KEY environment variable");
3185
+ const deploymentInfo = await deploy(mudConfig, { ...args, rpc, privateKey });
3186
+ if (args.saveDeployment) {
3187
+ const chainId = await getChainId(rpc);
3188
+ const outputDir = path2.join(mudConfig.deploysDirectory, chainId.toString());
3189
+ mkdirSync(outputDir, { recursive: true });
3190
+ writeFileSync2(path2.join(outputDir, "latest.json"), JSON.stringify(deploymentInfo, null, 2));
3191
+ writeFileSync2(path2.join(outputDir, Date.now() + ".json"), JSON.stringify(deploymentInfo, null, 2));
3192
+ console.log(chalk3.bgGreen(chalk3.whiteBright(`
3193
+ Deployment result (written to ${outputDir}):
3194
+ `)));
3195
+ }
3196
+ console.log(deploymentInfo);
3197
+ return deploymentInfo;
3198
+ } catch (error) {
3199
+ logError(error);
3200
+ process.exit(1);
3201
+ }
3202
+ }
3203
+ var commandModule7 = {
3204
+ command: "deploy-v2",
3205
+ describe: "Deploy MUD v2 contracts",
3206
+ builder(yargs) {
3207
+ return yargs.options(yDeployOptions);
3208
+ },
3209
+ async handler(args) {
3210
+ await deployHandler(args);
3211
+ process.exit(0);
3212
+ }
3213
+ };
3214
+ var deploy_v2_default = commandModule7;
3215
+
3216
+ // src/commands/worldgen.ts
3217
+ import glob2 from "glob";
3218
+ import path4, { basename as basename2 } from "path";
3219
+
3220
+ // src/render-solidity/worldgen.ts
3221
+ import { readFileSync as readFileSync2 } from "fs";
3222
+ import path3 from "path";
3223
+
3224
+ // src/utils/contractToInterface.ts
3225
+ import { parse, visit } from "@solidity-parser/parser";
3226
+ function contractToInterface(data, contractName) {
3227
+ const ast = parse(data);
3228
+ let withContract = false;
3229
+ let symbols = [];
3230
+ const functions = [];
3231
+ visit(ast, {
3232
+ ContractDefinition({ name }) {
3233
+ if (name === contractName) {
3234
+ withContract = true;
3235
+ }
3236
+ },
3237
+ FunctionDefinition({ name, visibility, parameters, returnParameters, isConstructor, isFallback, isReceiveEther }, parent) {
3238
+ if (parent !== void 0 && parent.type === "ContractDefinition" && parent.name === contractName) {
3239
+ try {
3240
+ if (isConstructor || isFallback || isReceiveEther)
3241
+ return;
3242
+ if (visibility === "default")
3243
+ throw new MUDError(`Visibility is not specified`);
3244
+ if (visibility === "external" || visibility === "public") {
3245
+ functions.push({
3246
+ name: name === null ? "" : name,
3247
+ parameters: parameters.map(parseParameter),
3248
+ returnParameters: returnParameters === null ? [] : returnParameters.map(parseParameter)
3249
+ });
3250
+ for (const { typeName } of parameters.concat(returnParameters ?? [])) {
3251
+ symbols = symbols.concat(typeNameToExternalSymbols(typeName));
3252
+ }
3253
+ }
3254
+ } catch (error) {
3255
+ if (error instanceof MUDError) {
3256
+ error.message = `Function "${name}" in contract "${contractName}": ${error.message}`;
3257
+ }
3258
+ throw error;
3259
+ }
3260
+ }
3261
+ }
3262
+ });
3263
+ if (!withContract) {
3264
+ throw new MUDError(`Contract not found: ${contractName}`);
3265
+ }
3266
+ return {
3267
+ functions,
3268
+ symbols
3269
+ };
3270
+ }
3271
+ function parseParameter({ name, typeName, storageLocation }) {
3272
+ let typedNameWithLocation = "";
3273
+ const { name: flattenedTypeName, stateMutability } = flattenTypeName(typeName);
3274
+ typedNameWithLocation += flattenedTypeName;
3275
+ if (stateMutability !== null) {
3276
+ typedNameWithLocation += ` ${stateMutability}`;
3277
+ }
3278
+ if (storageLocation !== null) {
3279
+ typedNameWithLocation += ` ${storageLocation}`;
3280
+ }
3281
+ if (name !== null) {
3282
+ typedNameWithLocation += ` ${name}`;
3283
+ }
3284
+ return typedNameWithLocation;
3285
+ }
3286
+ function flattenTypeName(typeName) {
3287
+ if (typeName === null) {
3288
+ return {
3289
+ name: "",
3290
+ stateMutability: null
3291
+ };
3292
+ }
3293
+ if (typeName.type === "ElementaryTypeName") {
3294
+ return {
3295
+ name: typeName.name,
3296
+ stateMutability: typeName.stateMutability
3297
+ };
3298
+ } else if (typeName.type === "UserDefinedTypeName") {
3299
+ return {
3300
+ name: typeName.namePath,
3301
+ stateMutability: null
3302
+ };
3303
+ } else if (typeName.type === "ArrayTypeName") {
3304
+ const length = typeName.length?.type === "NumberLiteral" ? typeName.length.number : "";
3305
+ const { name, stateMutability } = flattenTypeName(typeName.baseTypeName);
3306
+ return {
3307
+ name: `${name}[${length}]`,
3308
+ stateMutability
3309
+ };
3310
+ } else {
3311
+ throw new MUDError(`Invalid typeName.type ${typeName.type}`);
3312
+ }
3313
+ }
3314
+ function typeNameToExternalSymbols(typeName) {
3315
+ if (typeName?.type === "UserDefinedTypeName") {
3316
+ const symbol = typeName.namePath.split(".")[0];
3317
+ return [symbol];
3318
+ } else if (typeName?.type === "ArrayTypeName") {
3319
+ return typeNameToExternalSymbols(typeName.baseTypeName);
3320
+ } else {
3321
+ return [];
3322
+ }
3323
+ }
3324
+
3325
+ // src/render-solidity/renderSystemInterface.ts
3326
+ function renderSystemInterface(options) {
3327
+ const { imports, name, functionPrefix, functions } = options;
3328
+ return `${renderedSolidityHeader}
3329
+
3330
+ ${renderImports(imports)}
3331
+
3332
+ interface ${name} {
3333
+ ${renderList(
3334
+ functions,
3335
+ ({ name: name2, parameters, returnParameters }) => `
3336
+ function ${functionPrefix}${name2}(${renderArguments(parameters)}) external ${renderReturnParameters(
3337
+ returnParameters
3338
+ )};
3339
+ `
3340
+ )}
3341
+ }
3342
+
3343
+ `;
3344
+ }
3345
+ function renderReturnParameters(returnParameters) {
3346
+ if (returnParameters.length > 0) {
3347
+ return `returns (${renderArguments(returnParameters)})`;
3348
+ } else {
3349
+ return "";
3350
+ }
3351
+ }
3352
+
3353
+ // src/render-solidity/renderWorld.ts
3354
+ function renderWorld(options) {
3355
+ const { interfaceName, storeImportPath, worldImportPath, imports } = options;
3356
+ return `${renderedSolidityHeader}
3357
+
3358
+ import { IStore } from "${storeImportPath}IStore.sol";
3359
+
3360
+ import { IWorldCore } from "${worldImportPath}interfaces/IWorldCore.sol";
3361
+
3362
+ ${renderImports(imports)}
3363
+
3364
+ /**
3365
+ * The ${interfaceName} interface includes all systems dynamically added to the World
3366
+ * during the deploy process.
3367
+ */
3368
+ interface ${interfaceName} is ${renderArguments(["IStore", "IWorldCore", ...imports.map(({ symbol }) => symbol)])} {
3369
+
3370
+ }
3371
+
3372
+ `;
3373
+ }
3374
+
3375
+ // src/render-solidity/worldgen.ts
3376
+ async function worldgen(config, existingContracts, outputBaseDirectory) {
3377
+ const worldgenBaseDirectory = path3.join(outputBaseDirectory, config.worldgenDirectory);
3378
+ const systems = existingContracts.filter(({ basename: basename3 }) => Object.keys(config.systems).includes(basename3));
3379
+ const systemInterfaceImports = [];
3380
+ for (const system of systems) {
3381
+ const data = readFileSync2(system.path, "utf8");
3382
+ const { functions, symbols } = contractToInterface(data, system.basename);
3383
+ const imports = symbols.map((symbol) => ({
3384
+ symbol,
3385
+ fromPath: system.path,
3386
+ usedInPath: worldgenBaseDirectory
3387
+ }));
3388
+ const systemInterfaceName = `I${system.basename}`;
3389
+ const { fileSelector } = config.systems[system.basename];
3390
+ const output2 = renderSystemInterface({
3391
+ name: systemInterfaceName,
3392
+ functionPrefix: config.namespace === "" ? "" : `${config.namespace}_${fileSelector}_`,
3393
+ functions,
3394
+ imports
3395
+ });
3396
+ const fullOutputPath2 = path3.join(worldgenBaseDirectory, systemInterfaceName + ".sol");
3397
+ await formatAndWriteSolidity(output2, fullOutputPath2, "Generated system interface");
3398
+ systemInterfaceImports.push({
3399
+ symbol: systemInterfaceName,
3400
+ fromPath: `${systemInterfaceName}.sol`,
3401
+ usedInPath: "./"
3402
+ });
3403
+ }
3404
+ const output = renderWorld({
3405
+ interfaceName: config.worldInterfaceName,
3406
+ imports: systemInterfaceImports,
3407
+ storeImportPath: config.storeImportPath,
3408
+ worldImportPath: config.worldImportPath
3409
+ });
3410
+ const fullOutputPath = path3.join(worldgenBaseDirectory, config.worldInterfaceName + ".sol");
3411
+ await formatAndWriteSolidity(output, fullOutputPath, "Generated system interface");
3412
+ }
3413
+
3414
+ // src/commands/worldgen.ts
3415
+ import { rmSync as rmSync3 } from "fs";
3416
+ var commandModule8 = {
3417
+ command: "worldgen",
3418
+ describe: "Autogenerate interfaces for Systems and World based on existing contracts and the config file",
3419
+ builder(yargs) {
3420
+ return yargs.options({
3421
+ configPath: { type: "string", desc: "Path to the config file" },
3422
+ clean: { type: "boolean", desc: "Clear the worldgen directory before generating new interfaces" }
3423
+ });
3424
+ },
3425
+ async handler(args) {
3426
+ const { configPath, clean } = args;
3427
+ const srcDir = await getSrcDirectory();
3428
+ const existingContracts = glob2.sync(`${srcDir}/**/*.sol`).map((path6) => ({
3429
+ path: path6,
3430
+ basename: basename2(path6, ".sol")
3431
+ }));
3432
+ const worldConfig = await loadWorldConfig(
3433
+ configPath,
3434
+ existingContracts.map(({ basename: basename3 }) => basename3)
3435
+ );
3436
+ const storeConfig = await loadStoreConfig(configPath);
3437
+ const mudConfig = { ...worldConfig, ...storeConfig };
3438
+ if (clean)
3439
+ rmSync3(path4.join(srcDir, worldConfig.worldgenDirectory), { recursive: true, force: true });
3440
+ await worldgen(mudConfig, existingContracts, srcDir);
3441
+ process.exit(0);
3442
+ }
3443
+ };
3444
+ var worldgen_default = commandModule8;
3445
+
3446
+ // src/commands/set-version.ts
3447
+ import chalk4 from "chalk";
3448
+ import { existsSync, readFileSync as readFileSync3, rmSync as rmSync4, writeFileSync as writeFileSync3 } from "fs";
3449
+ import path5 from "path";
3450
+
3451
+ // package.json
3452
+ var package_default = {
3453
+ name: "@latticexyz/cli",
3454
+ version: "2.0.0-alpha.58+785a3249",
3455
+ description: "Command line interface for mud",
3456
+ main: "dist/index.js",
3457
+ types: "dist/index.d.ts",
3458
+ type: "module",
3459
+ license: "MIT",
3460
+ bin: {
3461
+ mud: "./dist/mud.js",
3462
+ mud2: "./dist/mud2.js"
3463
+ },
3464
+ repository: {
3465
+ type: "git",
3466
+ url: "https://github.com/latticexyz/mud.git",
3467
+ directory: "packages/cli"
3468
+ },
3469
+ scripts: {
3470
+ prepare: "yarn build && chmod u+x git-install.sh",
3471
+ codegen: "ts-node --esm --files ./scripts/codegen.ts",
3472
+ lint: "eslint . --ext .ts",
3473
+ dev: "tsup --watch",
3474
+ build: "tsup",
3475
+ link: "yarn link",
3476
+ test: "vitest typecheck --run && yarn test:contracts",
3477
+ "test:contracts": "yarn codegen && forge test",
3478
+ "git:install": "bash git-install.sh",
3479
+ release: "npm publish --access=public"
3480
+ },
3481
+ devDependencies: {
3482
+ "@latticexyz/store": "^2.0.0-alpha.58+785a3249",
3483
+ "@types/ejs": "^3.1.1",
3484
+ "@types/glob": "^7.2.0",
3485
+ "@types/node": "^17.0.34",
3486
+ "@types/openurl": "^1.0.0",
3487
+ "@types/yargs": "^17.0.10",
3488
+ esbuild: "^0.15.16",
3489
+ tsup: "^6.6.3",
3490
+ vitest: "^0.29.8"
3491
+ },
3492
+ dependencies: {
3493
+ "@improbable-eng/grpc-web": "^0.15.0",
3494
+ "@improbable-eng/grpc-web-node-http-transport": "^0.15.0",
3495
+ "@latticexyz/schema-type": "^2.0.0-alpha.58+785a3249",
3496
+ "@latticexyz/services": "^2.0.0-alpha.58+785a3249",
3497
+ "@latticexyz/solecs": "^2.0.0-alpha.58+785a3249",
3498
+ "@latticexyz/std-contracts": "^2.0.0-alpha.58+785a3249",
3499
+ "@solidity-parser/parser": "^0.16.0",
3500
+ "@typechain/ethers-v5": "^10.1.1",
3501
+ chalk: "^5.0.1",
3502
+ chokidar: "^3.5.3",
3503
+ dotenv: "^16.0.3",
3504
+ "ds-test": "https://github.com/dapphub/ds-test.git#c9ce3f25bde29fc5eb9901842bf02850dfd2d084",
3505
+ ejs: "^3.1.8",
3506
+ esbuild: "^0.17.14",
3507
+ ethers: "^5.7.2",
3508
+ execa: "^7.0.0",
3509
+ "find-up": "^6.3.0",
3510
+ "forge-std": "https://github.com/foundry-rs/forge-std.git#b4f121555729b3afb3c5ffccb62ff4b6e2818fd3",
3511
+ glob: "^8.0.3",
3512
+ "nice-grpc-web": "^2.0.1",
3513
+ openurl: "^1.1.1",
3514
+ path: "^0.12.7",
3515
+ prettier: "^2.8.4",
3516
+ "prettier-plugin-solidity": "^1.1.2",
3517
+ solmate: "https://github.com/Rari-Capital/solmate.git#9cf1428245074e39090dceacb0c28b1f684f584c",
3518
+ table: "^6.8.1",
3519
+ "ts-node": "^10.9.1",
3520
+ typechain: "^8.1.1",
3521
+ typescript: "^4.9.5",
3522
+ yargs: "^17.7.1",
3523
+ zod: "^3.21.4",
3524
+ "zod-validation-error": "^1.0.1"
3525
+ },
3526
+ gitHead: "785a324920c11e24399c5edf575a9099ee4077b6"
3527
+ };
3528
+
3529
+ // src/commands/set-version.ts
3530
+ var BACKUP_FILE = ".mudbackup";
3531
+ var MUD_PREFIX = "@latticexyz";
3532
+ var commandModule9 = {
3533
+ command: "set-version",
3534
+ describe: "Install a custom MUD version and optionally backup the previously installed version",
3535
+ builder(yargs) {
3536
+ return yargs.options({
3537
+ backup: { type: "boolean", description: `Back up the current MUD versions to "${BACKUP_FILE}"` },
3538
+ force: {
3539
+ type: "boolean",
3540
+ description: `Backup fails if a "${BACKUP_FILE}" file is found, unless --force is provided`
3541
+ },
3542
+ restore: { type: "boolean", description: `Restore the previous MUD versions from "${BACKUP_FILE}"` },
3543
+ mudVersion: { alias: "v", type: "string", description: "The MUD version to install" }
3544
+ });
3545
+ },
3546
+ async handler(options) {
3547
+ try {
3548
+ if (!options.mudVersion && !options.restore) {
3549
+ throw new MUDError(`Version parameter is required unless --restore is provided.`);
3550
+ }
3551
+ options.mudVersion = options.mudVersion === "canary" ? await getCanaryVersion(package_default.name) : options.mudVersion;
3552
+ const rootPath = "./package.json";
3553
+ const { workspaces } = updatePackageJson(rootPath, options);
3554
+ if (workspaces) {
3555
+ for (const workspace of workspaces) {
3556
+ const filePath = path5.join(workspace, "/package.json");
3557
+ updatePackageJson(filePath, options);
3558
+ }
3559
+ }
3560
+ } catch (e) {
3561
+ logError(e);
3562
+ } finally {
3563
+ process.exit(0);
3564
+ }
3565
+ }
3566
+ };
3567
+ function updatePackageJson(filePath, options) {
3568
+ const { backup, restore, force, mudVersion } = options;
3569
+ const backupFilePath = path5.join(path5.dirname(filePath), BACKUP_FILE);
3570
+ if (backup && !force && existsSync(backupFilePath)) {
3571
+ throw new MUDError(
3572
+ `A backup file already exists at ${backupFilePath}.
3573
+ Use --force to overwrite it or --restore to restore it.`
3574
+ );
3575
+ }
3576
+ const packageJson = readPackageJson(filePath);
3577
+ const backupJson = restore ? readPackageJson(backupFilePath) : void 0;
3578
+ const mudDependencies = {};
3579
+ for (const key in packageJson.dependencies) {
3580
+ if (key.startsWith(MUD_PREFIX)) {
3581
+ mudDependencies[key] = packageJson.dependencies[key];
3582
+ }
3583
+ }
3584
+ const mudDevDependencies = {};
3585
+ for (const key in packageJson.devDependencies) {
3586
+ if (key.startsWith(MUD_PREFIX)) {
3587
+ mudDevDependencies[key] = packageJson.devDependencies[key];
3588
+ }
3589
+ }
3590
+ if (backup) {
3591
+ writeFileSync3(
3592
+ backupFilePath,
3593
+ JSON.stringify({ dependencies: mudDependencies, devDependencies: mudDevDependencies }, null, 2)
3594
+ );
3595
+ console.log(chalk4.green(`Backed up MUD dependencies from ${filePath} to ${backupFilePath}`));
3596
+ }
3597
+ for (const key in packageJson.dependencies) {
3598
+ if (key.startsWith(MUD_PREFIX)) {
3599
+ packageJson.dependencies[key] = restore && backupJson ? backupJson.dependencies[key] : mudVersion || packageJson.dependencies[key];
3600
+ }
3601
+ }
3602
+ for (const key in packageJson.devDependencies) {
3603
+ if (key.startsWith(MUD_PREFIX)) {
3604
+ packageJson.devDependencies[key] = restore && backupJson ? backupJson.devDependencies[key] : mudVersion || packageJson.devDependencies[key];
3605
+ }
3606
+ }
3607
+ writeFileSync3(filePath, JSON.stringify(packageJson, null, 2) + "\n");
3608
+ console.log(`Updating ${filePath}`);
3609
+ logComparison(mudDependencies, packageJson.dependencies);
3610
+ logComparison(mudDevDependencies, packageJson.devDependencies);
3611
+ if (restore && !backup) {
3612
+ rmSync4(backupFilePath);
3613
+ console.log(chalk4.green(`Cleaned up ${backupFilePath}`));
3614
+ }
3615
+ return packageJson;
3616
+ }
3617
+ function readPackageJson(path6) {
3618
+ try {
3619
+ const jsonString = readFileSync3(path6, "utf8");
3620
+ return JSON.parse(jsonString);
3621
+ } catch {
3622
+ throw new MUDError("Could not read JSON at " + path6);
3623
+ }
3624
+ }
3625
+ async function getCanaryVersion(pkg) {
3626
+ try {
3627
+ console.log(chalk4.blue("fetching MUD canary version..."));
3628
+ const result = await (await fetch(`https://registry.npmjs.org/${pkg}`)).json();
3629
+ const canary = result["dist-tags"].canary;
3630
+ console.log(chalk4.green("MUD canary version:", canary));
3631
+ return canary;
3632
+ } catch (e) {
3633
+ throw new MUDError(`Could not fetch canary version of ${pkg}`);
3634
+ }
3635
+ }
3636
+ function logComparison(prev, curr) {
3637
+ for (const key in prev) {
3638
+ if (prev[key] !== curr[key]) {
3639
+ console.log(`${key}: ${chalk4.red(prev[key])} -> ${chalk4.green(curr[key])}`);
3640
+ }
3641
+ }
3642
+ }
3643
+ var set_version_default = commandModule9;
3644
+
3645
+ // src/commands/test-v2.ts
3646
+ import chalk5 from "chalk";
3647
+ import { rmSync as rmSync5, writeFileSync as writeFileSync4 } from "fs";
3648
+ var WORLD_ADDRESS_FILE = ".mudtest";
3649
+ var commandModule10 = {
3650
+ command: "test-v2",
3651
+ describe: "Run tests in MUD v2 contracts",
3652
+ builder(yargs) {
3653
+ return yargs.options({
3654
+ ...yDeployOptions,
3655
+ port: { type: "number", description: "Port to run internal node for fork testing on", default: 4242 },
3656
+ worldAddress: {
3657
+ type: "string",
3658
+ description: "Address of an existing world contract. If provided, deployment is skipped and the RPC provided in the foundry.toml is used for fork testing."
3659
+ },
3660
+ forgeOptions: { type: "string", description: "Options to pass to forge test" }
3661
+ });
3662
+ },
3663
+ async handler(args) {
3664
+ if (!args.worldAddress) {
3665
+ const anvilArgs = ["--block-base-fee-per-gas", "0", "--port", String(args.port)];
3666
+ anvil(anvilArgs);
3667
+ }
3668
+ const forkRpc = args.worldAddress ? await getRpcUrl(args.profile) : `http://127.0.0.1:${args.port}`;
3669
+ const worldAddress = args.worldAddress ?? (await deployHandler({
3670
+ ...args,
3671
+ saveDeployment: false,
3672
+ rpc: forkRpc
3673
+ })).worldAddress;
3674
+ console.log(chalk5.blue("World address", worldAddress));
3675
+ writeFileSync4(WORLD_ADDRESS_FILE, worldAddress);
3676
+ const userOptions = args.forgeOptions?.replaceAll("\\", "").split(" ") ?? [];
3677
+ try {
3678
+ const testResult = await forge(["test", "--fork-url", forkRpc, ...userOptions], {
3679
+ profile: args.profile
3680
+ });
3681
+ console.log(testResult);
3682
+ } catch (e) {
3683
+ console.error(e);
3684
+ }
3685
+ rmSync5(WORLD_ADDRESS_FILE);
3686
+ process.exit(0);
3687
+ }
3688
+ };
3689
+ var test_v2_default = commandModule10;
3690
+
3691
+ // src/commands/index.ts
3692
+ var commands = [
3693
+ deploy_v2_default,
3694
+ devnode_default,
3695
+ faucet_default,
3696
+ gas_report_default,
3697
+ hello_default,
3698
+ tablegen_default,
3699
+ tsgen_default,
3700
+ worldgen_default,
3701
+ set_version_default,
3702
+ test_v2_default
3703
+ ];
3704
+
3705
+ export {
3706
+ commands
3707
+ };
3708
+ /*! Bundled license information:
3709
+
3710
+ long/index.js:
3711
+ (**
3712
+ * @license
3713
+ * Copyright 2009 The Closure Library Authors
3714
+ * Copyright 2020 Daniel Wirtz / The long.js Authors.
3715
+ *
3716
+ * Licensed under the Apache License, Version 2.0 (the "License");
3717
+ * you may not use this file except in compliance with the License.
3718
+ * You may obtain a copy of the License at
3719
+ *
3720
+ * http://www.apache.org/licenses/LICENSE-2.0
3721
+ *
3722
+ * Unless required by applicable law or agreed to in writing, software
3723
+ * distributed under the License is distributed on an "AS IS" BASIS,
3724
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3725
+ * See the License for the specific language governing permissions and
3726
+ * limitations under the License.
3727
+ *
3728
+ * SPDX-License-Identifier: Apache-2.0
3729
+ *)
3730
+ */