@t2000/cli 1.24.13 → 1.25.0

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.
@@ -91,720 +91,322 @@ import {
91
91
  __toESM
92
92
  } from "./chunk-YPWSCLE3.js";
93
93
 
94
- // ../../node_modules/.pnpm/eventemitter3@5.0.4/node_modules/eventemitter3/index.js
95
- var require_eventemitter3 = __commonJS({
96
- "../../node_modules/.pnpm/eventemitter3@5.0.4/node_modules/eventemitter3/index.js"(exports, module) {
94
+ // ../../node_modules/.pnpm/bn.js@5.2.3/node_modules/bn.js/lib/bn.js
95
+ var require_bn = __commonJS({
96
+ "../../node_modules/.pnpm/bn.js@5.2.3/node_modules/bn.js/lib/bn.js"(exports, module) {
97
97
  "use strict";
98
- var has = Object.prototype.hasOwnProperty;
99
- var prefix = "~";
100
- function Events() {
101
- }
102
- if (Object.create) {
103
- Events.prototype = /* @__PURE__ */ Object.create(null);
104
- if (!new Events().__proto__) prefix = false;
105
- }
106
- function EE(fn, context, once) {
107
- this.fn = fn;
108
- this.context = context;
109
- this.once = once || false;
110
- }
111
- function addListener(emitter, event, fn, context, once) {
112
- if (typeof fn !== "function") {
113
- throw new TypeError("The listener must be a function");
98
+ (function(module2, exports2) {
99
+ "use strict";
100
+ function assert(val, msg) {
101
+ if (!val) throw new Error(msg || "Assertion failed");
114
102
  }
115
- var listener = new EE(fn, context || emitter, once), evt = prefix ? prefix + event : event;
116
- if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
117
- else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
118
- else emitter._events[evt] = [emitter._events[evt], listener];
119
- return emitter;
120
- }
121
- function clearEvent(emitter, evt) {
122
- if (--emitter._eventsCount === 0) emitter._events = new Events();
123
- else delete emitter._events[evt];
124
- }
125
- function EventEmitter2() {
126
- this._events = new Events();
127
- this._eventsCount = 0;
128
- }
129
- EventEmitter2.prototype.eventNames = function eventNames() {
130
- var names = [], events, name;
131
- if (this._eventsCount === 0) return names;
132
- for (name in events = this._events) {
133
- if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
103
+ function inherits(ctor, superCtor) {
104
+ ctor.super_ = superCtor;
105
+ var TempCtor = function() {
106
+ };
107
+ TempCtor.prototype = superCtor.prototype;
108
+ ctor.prototype = new TempCtor();
109
+ ctor.prototype.constructor = ctor;
134
110
  }
135
- if (Object.getOwnPropertySymbols) {
136
- return names.concat(Object.getOwnPropertySymbols(events));
111
+ function BN2(number, base, endian) {
112
+ if (BN2.isBN(number)) {
113
+ return number;
114
+ }
115
+ this.negative = 0;
116
+ this.words = null;
117
+ this.length = 0;
118
+ this.red = null;
119
+ if (number !== null) {
120
+ if (base === "le" || base === "be") {
121
+ endian = base;
122
+ base = 10;
123
+ }
124
+ this._init(number || 0, base || 10, endian || "be");
125
+ }
137
126
  }
138
- return names;
139
- };
140
- EventEmitter2.prototype.listeners = function listeners(event) {
141
- var evt = prefix ? prefix + event : event, handlers = this._events[evt];
142
- if (!handlers) return [];
143
- if (handlers.fn) return [handlers.fn];
144
- for (var i = 0, l = handlers.length, ee2 = new Array(l); i < l; i++) {
145
- ee2[i] = handlers[i].fn;
127
+ if (typeof module2 === "object") {
128
+ module2.exports = BN2;
129
+ } else {
130
+ exports2.BN = BN2;
146
131
  }
147
- return ee2;
148
- };
149
- EventEmitter2.prototype.listenerCount = function listenerCount(event) {
150
- var evt = prefix ? prefix + event : event, listeners = this._events[evt];
151
- if (!listeners) return 0;
152
- if (listeners.fn) return 1;
153
- return listeners.length;
154
- };
155
- EventEmitter2.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
156
- var evt = prefix ? prefix + event : event;
157
- if (!this._events[evt]) return false;
158
- var listeners = this._events[evt], len = arguments.length, args, i;
159
- if (listeners.fn) {
160
- if (listeners.once) this.removeListener(event, listeners.fn, void 0, true);
161
- switch (len) {
162
- case 1:
163
- return listeners.fn.call(listeners.context), true;
164
- case 2:
165
- return listeners.fn.call(listeners.context, a1), true;
166
- case 3:
167
- return listeners.fn.call(listeners.context, a1, a2), true;
168
- case 4:
169
- return listeners.fn.call(listeners.context, a1, a2, a3), true;
170
- case 5:
171
- return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
172
- case 6:
173
- return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
132
+ BN2.BN = BN2;
133
+ BN2.wordSize = 26;
134
+ var Buffer2;
135
+ try {
136
+ if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") {
137
+ Buffer2 = window.Buffer;
138
+ } else {
139
+ Buffer2 = __require("buffer").Buffer;
174
140
  }
175
- for (i = 1, args = new Array(len - 1); i < len; i++) {
176
- args[i - 1] = arguments[i];
141
+ } catch (e) {
142
+ }
143
+ BN2.isBN = function isBN(num) {
144
+ if (num instanceof BN2) {
145
+ return true;
177
146
  }
178
- listeners.fn.apply(listeners.context, args);
179
- } else {
180
- var length = listeners.length, j;
181
- for (i = 0; i < length; i++) {
182
- if (listeners[i].once) this.removeListener(event, listeners[i].fn, void 0, true);
183
- switch (len) {
184
- case 1:
185
- listeners[i].fn.call(listeners[i].context);
186
- break;
187
- case 2:
188
- listeners[i].fn.call(listeners[i].context, a1);
189
- break;
190
- case 3:
191
- listeners[i].fn.call(listeners[i].context, a1, a2);
192
- break;
193
- case 4:
194
- listeners[i].fn.call(listeners[i].context, a1, a2, a3);
195
- break;
196
- default:
197
- if (!args) for (j = 1, args = new Array(len - 1); j < len; j++) {
198
- args[j - 1] = arguments[j];
199
- }
200
- listeners[i].fn.apply(listeners[i].context, args);
147
+ return num !== null && typeof num === "object" && num.constructor.wordSize === BN2.wordSize && Array.isArray(num.words);
148
+ };
149
+ BN2.max = function max(left, right) {
150
+ if (left.cmp(right) > 0) return left;
151
+ return right;
152
+ };
153
+ BN2.min = function min(left, right) {
154
+ if (left.cmp(right) < 0) return left;
155
+ return right;
156
+ };
157
+ BN2.prototype._init = function init(number, base, endian) {
158
+ if (typeof number === "number") {
159
+ return this._initNumber(number, base, endian);
160
+ }
161
+ if (typeof number === "object") {
162
+ return this._initArray(number, base, endian);
163
+ }
164
+ if (base === "hex") {
165
+ base = 16;
166
+ }
167
+ assert(base === (base | 0) && base >= 2 && base <= 36);
168
+ number = number.toString().replace(/\s+/g, "");
169
+ var start = 0;
170
+ if (number[0] === "-") {
171
+ start++;
172
+ this.negative = 1;
173
+ }
174
+ if (start < number.length) {
175
+ if (base === 16) {
176
+ this._parseHex(number, start, endian);
177
+ } else {
178
+ this._parseBase(number, base, start);
179
+ if (endian === "le") {
180
+ this._initArray(this.toArray(), base, endian);
181
+ }
201
182
  }
202
183
  }
203
- }
204
- return true;
205
- };
206
- EventEmitter2.prototype.on = function on(event, fn, context) {
207
- return addListener(this, event, fn, context, false);
208
- };
209
- EventEmitter2.prototype.once = function once(event, fn, context) {
210
- return addListener(this, event, fn, context, true);
211
- };
212
- EventEmitter2.prototype.removeListener = function removeListener(event, fn, context, once) {
213
- var evt = prefix ? prefix + event : event;
214
- if (!this._events[evt]) return this;
215
- if (!fn) {
216
- clearEvent(this, evt);
217
- return this;
218
- }
219
- var listeners = this._events[evt];
220
- if (listeners.fn) {
221
- if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) {
222
- clearEvent(this, evt);
184
+ };
185
+ BN2.prototype._initNumber = function _initNumber(number, base, endian) {
186
+ if (number < 0) {
187
+ this.negative = 1;
188
+ number = -number;
223
189
  }
224
- } else {
225
- for (var i = 0, events = [], length = listeners.length; i < length; i++) {
226
- if (listeners[i].fn !== fn || once && !listeners[i].once || context && listeners[i].context !== context) {
227
- events.push(listeners[i]);
190
+ if (number < 67108864) {
191
+ this.words = [number & 67108863];
192
+ this.length = 1;
193
+ } else if (number < 4503599627370496) {
194
+ this.words = [
195
+ number & 67108863,
196
+ number / 67108864 & 67108863
197
+ ];
198
+ this.length = 2;
199
+ } else {
200
+ assert(number < 9007199254740992);
201
+ this.words = [
202
+ number & 67108863,
203
+ number / 67108864 & 67108863,
204
+ 1
205
+ ];
206
+ this.length = 3;
207
+ }
208
+ if (endian !== "le") return;
209
+ this._initArray(this.toArray(), base, endian);
210
+ };
211
+ BN2.prototype._initArray = function _initArray(number, base, endian) {
212
+ assert(typeof number.length === "number");
213
+ if (number.length <= 0) {
214
+ this.words = [0];
215
+ this.length = 1;
216
+ return this;
217
+ }
218
+ this.length = Math.ceil(number.length / 3);
219
+ this.words = new Array(this.length);
220
+ for (var i = 0; i < this.length; i++) {
221
+ this.words[i] = 0;
222
+ }
223
+ var j, w2;
224
+ var off = 0;
225
+ if (endian === "be") {
226
+ for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
227
+ w2 = number[i] | number[i - 1] << 8 | number[i - 2] << 16;
228
+ this.words[j] |= w2 << off & 67108863;
229
+ this.words[j + 1] = w2 >>> 26 - off & 67108863;
230
+ off += 24;
231
+ if (off >= 26) {
232
+ off -= 26;
233
+ j++;
234
+ }
235
+ }
236
+ } else if (endian === "le") {
237
+ for (i = 0, j = 0; i < number.length; i += 3) {
238
+ w2 = number[i] | number[i + 1] << 8 | number[i + 2] << 16;
239
+ this.words[j] |= w2 << off & 67108863;
240
+ this.words[j + 1] = w2 >>> 26 - off & 67108863;
241
+ off += 24;
242
+ if (off >= 26) {
243
+ off -= 26;
244
+ j++;
245
+ }
228
246
  }
229
247
  }
230
- if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
231
- else clearEvent(this, evt);
232
- }
233
- return this;
234
- };
235
- EventEmitter2.prototype.removeAllListeners = function removeAllListeners(event) {
236
- var evt;
237
- if (event) {
238
- evt = prefix ? prefix + event : event;
239
- if (this._events[evt]) clearEvent(this, evt);
240
- } else {
241
- this._events = new Events();
242
- this._eventsCount = 0;
243
- }
244
- return this;
245
- };
246
- EventEmitter2.prototype.off = EventEmitter2.prototype.removeListener;
247
- EventEmitter2.prototype.addListener = EventEmitter2.prototype.on;
248
- EventEmitter2.prefixed = prefix;
249
- EventEmitter2.EventEmitter = EventEmitter2;
250
- if ("undefined" !== typeof module) {
251
- module.exports = EventEmitter2;
252
- }
253
- }
254
- });
255
-
256
- // ../../node_modules/.pnpm/@pythnetwork+price-service-sdk@1.9.0/node_modules/@pythnetwork/price-service-sdk/dist/cjs/schemas/PriceFeed.cjs
257
- var require_PriceFeed = __commonJS({
258
- "../../node_modules/.pnpm/@pythnetwork+price-service-sdk@1.9.0/node_modules/@pythnetwork/price-service-sdk/dist/cjs/schemas/PriceFeed.cjs"(exports) {
259
- "use strict";
260
- Object.defineProperty(exports, "__esModule", {
261
- value: true
262
- });
263
- Object.defineProperty(exports, "Convert", {
264
- enumerable: true,
265
- get: function() {
266
- return Convert;
267
- }
268
- });
269
- var Convert = class {
270
- static toPriceFeed(json) {
271
- return cast(json, r("PriceFeed"));
272
- }
273
- static priceFeedToJson(value) {
274
- return uncast(value, r("PriceFeed"));
275
- }
276
- static toPrice(json) {
277
- return cast(json, r("Price"));
278
- }
279
- static priceToJson(value) {
280
- return uncast(value, r("Price"));
281
- }
282
- static toPriceFeedMetadata(json) {
283
- return cast(json, r("PriceFeedMetadata"));
284
- }
285
- static priceFeedMetadataToJson(value) {
286
- return uncast(value, r("PriceFeedMetadata"));
287
- }
288
- };
289
- function invalidValue(typ, val, key = "") {
290
- if (key) {
291
- throw new Error(`Invalid value for key "${key}". Expected type ${JSON.stringify(typ)} but got ${JSON.stringify(val)}`);
292
- }
293
- throw new Error(`Invalid value ${JSON.stringify(val)} for type ${JSON.stringify(typ)}`);
294
- }
295
- function jsonToJSProps(typ) {
296
- if (typ.jsonToJS === void 0) {
297
- const map2 = {};
298
- typ.props.forEach((p) => map2[p.json] = {
299
- key: p.js,
300
- typ: p.typ
301
- });
302
- typ.jsonToJS = map2;
303
- }
304
- return typ.jsonToJS;
305
- }
306
- function jsToJSONProps(typ) {
307
- if (typ.jsToJSON === void 0) {
308
- const map2 = {};
309
- typ.props.forEach((p) => map2[p.js] = {
310
- key: p.json,
311
- typ: p.typ
312
- });
313
- typ.jsToJSON = map2;
314
- }
315
- return typ.jsToJSON;
316
- }
317
- function transform(val, typ, getProps, key = "") {
318
- function transformPrimitive(typ2, val2) {
319
- if (typeof typ2 === typeof val2) return val2;
320
- return invalidValue(typ2, val2, key);
321
- }
322
- function transformUnion(typs, val2) {
323
- const l = typs.length;
324
- for (let i = 0; i < l; i++) {
325
- const typ2 = typs[i];
326
- try {
327
- return transform(val2, typ2, getProps);
328
- } catch {
329
- }
248
+ return this._strip();
249
+ };
250
+ function parseHex4Bits(string, index) {
251
+ var c = string.charCodeAt(index);
252
+ if (c >= 48 && c <= 57) {
253
+ return c - 48;
254
+ } else if (c >= 65 && c <= 70) {
255
+ return c - 55;
256
+ } else if (c >= 97 && c <= 102) {
257
+ return c - 87;
258
+ } else {
259
+ assert(false, "Invalid character in " + string);
330
260
  }
331
- return invalidValue(typs, val2);
332
- }
333
- function transformEnum(cases, val2) {
334
- if (cases.includes(val2)) return val2;
335
- return invalidValue(cases, val2);
336
261
  }
337
- function transformArray(typ2, val2) {
338
- if (!Array.isArray(val2)) return invalidValue("array", val2);
339
- return val2.map((el) => transform(el, typ2, getProps));
262
+ function parseHexByte(string, lowerBound, index) {
263
+ var r = parseHex4Bits(string, index);
264
+ if (index - 1 >= lowerBound) {
265
+ r |= parseHex4Bits(string, index - 1) << 4;
266
+ }
267
+ return r;
340
268
  }
341
- function transformDate(val2) {
342
- if (val2 === null) {
343
- return null;
269
+ BN2.prototype._parseHex = function _parseHex(number, start, endian) {
270
+ this.length = Math.ceil((number.length - start) / 6);
271
+ this.words = new Array(this.length);
272
+ for (var i = 0; i < this.length; i++) {
273
+ this.words[i] = 0;
344
274
  }
345
- const d = new Date(val2);
346
- if (isNaN(d.valueOf())) {
347
- return invalidValue("Date", val2);
275
+ var off = 0;
276
+ var j = 0;
277
+ var w2;
278
+ if (endian === "be") {
279
+ for (i = number.length - 1; i >= start; i -= 2) {
280
+ w2 = parseHexByte(number, start, i) << off;
281
+ this.words[j] |= w2 & 67108863;
282
+ if (off >= 18) {
283
+ off -= 18;
284
+ j += 1;
285
+ this.words[j] |= w2 >>> 26;
286
+ } else {
287
+ off += 8;
288
+ }
289
+ }
290
+ } else {
291
+ var parseLength = number.length - start;
292
+ for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) {
293
+ w2 = parseHexByte(number, start, i) << off;
294
+ this.words[j] |= w2 & 67108863;
295
+ if (off >= 18) {
296
+ off -= 18;
297
+ j += 1;
298
+ this.words[j] |= w2 >>> 26;
299
+ } else {
300
+ off += 8;
301
+ }
302
+ }
348
303
  }
349
- return d;
304
+ this._strip();
305
+ };
306
+ function parseBase(str, start, end, mul) {
307
+ var r = 0;
308
+ var b2 = 0;
309
+ var len = Math.min(str.length, end);
310
+ for (var i = start; i < len; i++) {
311
+ var c = str.charCodeAt(i) - 48;
312
+ r *= mul;
313
+ if (c >= 49) {
314
+ b2 = c - 49 + 10;
315
+ } else if (c >= 17) {
316
+ b2 = c - 17 + 10;
317
+ } else {
318
+ b2 = c;
319
+ }
320
+ assert(c >= 0 && b2 < mul, "Invalid character");
321
+ r += b2;
322
+ }
323
+ return r;
350
324
  }
351
- function transformObject(props, additional, val2) {
352
- if (val2 === null || typeof val2 !== "object" || Array.isArray(val2)) {
353
- return invalidValue("object", val2);
325
+ BN2.prototype._parseBase = function _parseBase(number, base, start) {
326
+ this.words = [0];
327
+ this.length = 1;
328
+ for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base) {
329
+ limbLen++;
354
330
  }
355
- const result = {};
356
- for (const key2 of Object.getOwnPropertyNames(props)) {
357
- const prop = props[key2];
358
- const v = Object.prototype.hasOwnProperty.call(val2, key2) ? val2[key2] : void 0;
359
- result[prop.key] = transform(v, prop.typ, getProps, prop.key);
331
+ limbLen--;
332
+ limbPow = limbPow / base | 0;
333
+ var total = number.length - start;
334
+ var mod2 = total % limbLen;
335
+ var end = Math.min(total, total - mod2) + start;
336
+ var word = 0;
337
+ for (var i = start; i < end; i += limbLen) {
338
+ word = parseBase(number, i, i + limbLen, base);
339
+ this.imuln(limbPow);
340
+ if (this.words[0] + word < 67108864) {
341
+ this.words[0] += word;
342
+ } else {
343
+ this._iaddn(word);
344
+ }
360
345
  }
361
- for (const key2 of Object.getOwnPropertyNames(val2)) {
362
- if (!Object.prototype.hasOwnProperty.call(props, key2)) {
363
- result[key2] = transform(val2[key2], additional, getProps, key2);
346
+ if (mod2 !== 0) {
347
+ var pow = 1;
348
+ word = parseBase(number, i, number.length, base);
349
+ for (i = 0; i < mod2; i++) {
350
+ pow *= base;
351
+ }
352
+ this.imuln(pow);
353
+ if (this.words[0] + word < 67108864) {
354
+ this.words[0] += word;
355
+ } else {
356
+ this._iaddn(word);
364
357
  }
365
358
  }
366
- return result;
367
- }
368
- if (typ === "any") return val;
369
- if (typ === null) {
370
- if (val === null) return val;
371
- return invalidValue(typ, val);
372
- }
373
- if (typ === false) return invalidValue(typ, val);
374
- while (typeof typ === "object" && typ.ref !== void 0) {
375
- typ = typeMap[typ.ref];
376
- }
377
- if (Array.isArray(typ)) return transformEnum(typ, val);
378
- if (typeof typ === "object") {
379
- return typ.hasOwnProperty("unionMembers") ? transformUnion(typ.unionMembers, val) : typ.hasOwnProperty("arrayItems") ? transformArray(typ.arrayItems, val) : typ.hasOwnProperty("props") ? transformObject(getProps(typ), typ.additional, val) : invalidValue(typ, val);
380
- }
381
- if (typ === Date && typeof val !== "number") return transformDate(val);
382
- return transformPrimitive(typ, val);
383
- }
384
- function cast(val, typ) {
385
- return transform(val, typ, jsonToJSProps);
386
- }
387
- function uncast(val, typ) {
388
- return transform(val, typ, jsToJSONProps);
389
- }
390
- function u(...typs) {
391
- return {
392
- unionMembers: typs
393
- };
394
- }
395
- function o(props, additional) {
396
- return {
397
- props,
398
- additional
359
+ this._strip();
399
360
  };
400
- }
401
- function r(name) {
402
- return {
403
- ref: name
404
- };
405
- }
406
- var typeMap = {
407
- PriceFeed: o([
408
- {
409
- json: "ema_price",
410
- js: "ema_price",
411
- typ: r("Price")
412
- },
413
- {
414
- json: "id",
415
- js: "id",
416
- typ: ""
417
- },
418
- {
419
- json: "metadata",
420
- js: "metadata",
421
- typ: u(void 0, r("PriceFeedMetadata"))
422
- },
423
- {
424
- json: "price",
425
- js: "price",
426
- typ: r("Price")
427
- },
428
- {
429
- json: "vaa",
430
- js: "vaa",
431
- typ: u(void 0, "")
432
- }
433
- ], "any"),
434
- Price: o([
435
- {
436
- json: "conf",
437
- js: "conf",
438
- typ: ""
439
- },
440
- {
441
- json: "expo",
442
- js: "expo",
443
- typ: 0
444
- },
445
- {
446
- json: "price",
447
- js: "price",
448
- typ: ""
449
- },
450
- {
451
- json: "publish_time",
452
- js: "publish_time",
453
- typ: 0
454
- }
455
- ], "any"),
456
- PriceFeedMetadata: o([
457
- {
458
- json: "attestation_time",
459
- js: "attestation_time",
460
- typ: u(void 0, 0)
461
- },
462
- {
463
- json: "emitter_chain",
464
- js: "emitter_chain",
465
- typ: 0
466
- },
467
- {
468
- json: "prev_publish_time",
469
- js: "prev_publish_time",
470
- typ: u(void 0, 0)
471
- },
472
- {
473
- json: "price_service_receive_time",
474
- js: "price_service_receive_time",
475
- typ: u(void 0, 0)
476
- },
477
- {
478
- json: "sequence_number",
479
- js: "sequence_number",
480
- typ: u(void 0, 0)
481
- },
482
- {
483
- json: "slot",
484
- js: "slot",
485
- typ: u(void 0, 0)
486
- }
487
- ], "any")
488
- };
489
- }
490
- });
491
-
492
- // ../../node_modules/.pnpm/bn.js@5.2.3/node_modules/bn.js/lib/bn.js
493
- var require_bn = __commonJS({
494
- "../../node_modules/.pnpm/bn.js@5.2.3/node_modules/bn.js/lib/bn.js"(exports, module) {
495
- "use strict";
496
- (function(module2, exports2) {
497
- "use strict";
498
- function assert(val, msg) {
499
- if (!val) throw new Error(msg || "Assertion failed");
500
- }
501
- function inherits(ctor, superCtor) {
502
- ctor.super_ = superCtor;
503
- var TempCtor = function() {
504
- };
505
- TempCtor.prototype = superCtor.prototype;
506
- ctor.prototype = new TempCtor();
507
- ctor.prototype.constructor = ctor;
508
- }
509
- function BN(number, base, endian) {
510
- if (BN.isBN(number)) {
511
- return number;
512
- }
513
- this.negative = 0;
514
- this.words = null;
515
- this.length = 0;
516
- this.red = null;
517
- if (number !== null) {
518
- if (base === "le" || base === "be") {
519
- endian = base;
520
- base = 10;
521
- }
522
- this._init(number || 0, base || 10, endian || "be");
523
- }
524
- }
525
- if (typeof module2 === "object") {
526
- module2.exports = BN;
527
- } else {
528
- exports2.BN = BN;
529
- }
530
- BN.BN = BN;
531
- BN.wordSize = 26;
532
- var Buffer2;
533
- try {
534
- if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") {
535
- Buffer2 = window.Buffer;
536
- } else {
537
- Buffer2 = __require("buffer").Buffer;
538
- }
539
- } catch (e) {
540
- }
541
- BN.isBN = function isBN(num) {
542
- if (num instanceof BN) {
543
- return true;
361
+ BN2.prototype.copy = function copy(dest) {
362
+ dest.words = new Array(this.length);
363
+ for (var i = 0; i < this.length; i++) {
364
+ dest.words[i] = this.words[i];
544
365
  }
545
- return num !== null && typeof num === "object" && num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
366
+ dest.length = this.length;
367
+ dest.negative = this.negative;
368
+ dest.red = this.red;
546
369
  };
547
- BN.max = function max(left, right) {
548
- if (left.cmp(right) > 0) return left;
549
- return right;
370
+ function move(dest, src) {
371
+ dest.words = src.words;
372
+ dest.length = src.length;
373
+ dest.negative = src.negative;
374
+ dest.red = src.red;
375
+ }
376
+ BN2.prototype._move = function _move(dest) {
377
+ move(dest, this);
550
378
  };
551
- BN.min = function min(left, right) {
552
- if (left.cmp(right) < 0) return left;
553
- return right;
379
+ BN2.prototype.clone = function clone2() {
380
+ var r = new BN2(null);
381
+ this.copy(r);
382
+ return r;
554
383
  };
555
- BN.prototype._init = function init(number, base, endian) {
556
- if (typeof number === "number") {
557
- return this._initNumber(number, base, endian);
558
- }
559
- if (typeof number === "object") {
560
- return this._initArray(number, base, endian);
561
- }
562
- if (base === "hex") {
563
- base = 16;
564
- }
565
- assert(base === (base | 0) && base >= 2 && base <= 36);
566
- number = number.toString().replace(/\s+/g, "");
567
- var start = 0;
568
- if (number[0] === "-") {
569
- start++;
570
- this.negative = 1;
571
- }
572
- if (start < number.length) {
573
- if (base === 16) {
574
- this._parseHex(number, start, endian);
575
- } else {
576
- this._parseBase(number, base, start);
577
- if (endian === "le") {
578
- this._initArray(this.toArray(), base, endian);
579
- }
580
- }
384
+ BN2.prototype._expand = function _expand(size) {
385
+ while (this.length < size) {
386
+ this.words[this.length++] = 0;
581
387
  }
388
+ return this;
582
389
  };
583
- BN.prototype._initNumber = function _initNumber(number, base, endian) {
584
- if (number < 0) {
585
- this.negative = 1;
586
- number = -number;
587
- }
588
- if (number < 67108864) {
589
- this.words = [number & 67108863];
590
- this.length = 1;
591
- } else if (number < 4503599627370496) {
592
- this.words = [
593
- number & 67108863,
594
- number / 67108864 & 67108863
595
- ];
596
- this.length = 2;
597
- } else {
598
- assert(number < 9007199254740992);
599
- this.words = [
600
- number & 67108863,
601
- number / 67108864 & 67108863,
602
- 1
603
- ];
604
- this.length = 3;
390
+ BN2.prototype._strip = function strip() {
391
+ while (this.length > 1 && this.words[this.length - 1] === 0) {
392
+ this.length--;
605
393
  }
606
- if (endian !== "le") return;
607
- this._initArray(this.toArray(), base, endian);
394
+ return this._normSign();
608
395
  };
609
- BN.prototype._initArray = function _initArray(number, base, endian) {
610
- assert(typeof number.length === "number");
611
- if (number.length <= 0) {
612
- this.words = [0];
613
- this.length = 1;
614
- return this;
615
- }
616
- this.length = Math.ceil(number.length / 3);
617
- this.words = new Array(this.length);
618
- for (var i = 0; i < this.length; i++) {
619
- this.words[i] = 0;
620
- }
621
- var j, w2;
622
- var off = 0;
623
- if (endian === "be") {
624
- for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
625
- w2 = number[i] | number[i - 1] << 8 | number[i - 2] << 16;
626
- this.words[j] |= w2 << off & 67108863;
627
- this.words[j + 1] = w2 >>> 26 - off & 67108863;
628
- off += 24;
629
- if (off >= 26) {
630
- off -= 26;
631
- j++;
632
- }
633
- }
634
- } else if (endian === "le") {
635
- for (i = 0, j = 0; i < number.length; i += 3) {
636
- w2 = number[i] | number[i + 1] << 8 | number[i + 2] << 16;
637
- this.words[j] |= w2 << off & 67108863;
638
- this.words[j + 1] = w2 >>> 26 - off & 67108863;
639
- off += 24;
640
- if (off >= 26) {
641
- off -= 26;
642
- j++;
643
- }
644
- }
396
+ BN2.prototype._normSign = function _normSign() {
397
+ if (this.length === 1 && this.words[0] === 0) {
398
+ this.negative = 0;
645
399
  }
646
- return this._strip();
647
- };
648
- function parseHex4Bits(string, index) {
649
- var c = string.charCodeAt(index);
650
- if (c >= 48 && c <= 57) {
651
- return c - 48;
652
- } else if (c >= 65 && c <= 70) {
653
- return c - 55;
654
- } else if (c >= 97 && c <= 102) {
655
- return c - 87;
656
- } else {
657
- assert(false, "Invalid character in " + string);
658
- }
659
- }
660
- function parseHexByte(string, lowerBound, index) {
661
- var r = parseHex4Bits(string, index);
662
- if (index - 1 >= lowerBound) {
663
- r |= parseHex4Bits(string, index - 1) << 4;
664
- }
665
- return r;
666
- }
667
- BN.prototype._parseHex = function _parseHex(number, start, endian) {
668
- this.length = Math.ceil((number.length - start) / 6);
669
- this.words = new Array(this.length);
670
- for (var i = 0; i < this.length; i++) {
671
- this.words[i] = 0;
672
- }
673
- var off = 0;
674
- var j = 0;
675
- var w2;
676
- if (endian === "be") {
677
- for (i = number.length - 1; i >= start; i -= 2) {
678
- w2 = parseHexByte(number, start, i) << off;
679
- this.words[j] |= w2 & 67108863;
680
- if (off >= 18) {
681
- off -= 18;
682
- j += 1;
683
- this.words[j] |= w2 >>> 26;
684
- } else {
685
- off += 8;
686
- }
687
- }
688
- } else {
689
- var parseLength = number.length - start;
690
- for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) {
691
- w2 = parseHexByte(number, start, i) << off;
692
- this.words[j] |= w2 & 67108863;
693
- if (off >= 18) {
694
- off -= 18;
695
- j += 1;
696
- this.words[j] |= w2 >>> 26;
697
- } else {
698
- off += 8;
699
- }
700
- }
701
- }
702
- this._strip();
703
- };
704
- function parseBase(str, start, end, mul) {
705
- var r = 0;
706
- var b2 = 0;
707
- var len = Math.min(str.length, end);
708
- for (var i = start; i < len; i++) {
709
- var c = str.charCodeAt(i) - 48;
710
- r *= mul;
711
- if (c >= 49) {
712
- b2 = c - 49 + 10;
713
- } else if (c >= 17) {
714
- b2 = c - 17 + 10;
715
- } else {
716
- b2 = c;
717
- }
718
- assert(c >= 0 && b2 < mul, "Invalid character");
719
- r += b2;
720
- }
721
- return r;
722
- }
723
- BN.prototype._parseBase = function _parseBase(number, base, start) {
724
- this.words = [0];
725
- this.length = 1;
726
- for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base) {
727
- limbLen++;
728
- }
729
- limbLen--;
730
- limbPow = limbPow / base | 0;
731
- var total = number.length - start;
732
- var mod2 = total % limbLen;
733
- var end = Math.min(total, total - mod2) + start;
734
- var word = 0;
735
- for (var i = start; i < end; i += limbLen) {
736
- word = parseBase(number, i, i + limbLen, base);
737
- this.imuln(limbPow);
738
- if (this.words[0] + word < 67108864) {
739
- this.words[0] += word;
740
- } else {
741
- this._iaddn(word);
742
- }
743
- }
744
- if (mod2 !== 0) {
745
- var pow = 1;
746
- word = parseBase(number, i, number.length, base);
747
- for (i = 0; i < mod2; i++) {
748
- pow *= base;
749
- }
750
- this.imuln(pow);
751
- if (this.words[0] + word < 67108864) {
752
- this.words[0] += word;
753
- } else {
754
- this._iaddn(word);
755
- }
756
- }
757
- this._strip();
758
- };
759
- BN.prototype.copy = function copy(dest) {
760
- dest.words = new Array(this.length);
761
- for (var i = 0; i < this.length; i++) {
762
- dest.words[i] = this.words[i];
763
- }
764
- dest.length = this.length;
765
- dest.negative = this.negative;
766
- dest.red = this.red;
767
- };
768
- function move(dest, src) {
769
- dest.words = src.words;
770
- dest.length = src.length;
771
- dest.negative = src.negative;
772
- dest.red = src.red;
773
- }
774
- BN.prototype._move = function _move(dest) {
775
- move(dest, this);
776
- };
777
- BN.prototype.clone = function clone2() {
778
- var r = new BN(null);
779
- this.copy(r);
780
- return r;
781
- };
782
- BN.prototype._expand = function _expand(size) {
783
- while (this.length < size) {
784
- this.words[this.length++] = 0;
785
- }
786
- return this;
787
- };
788
- BN.prototype._strip = function strip() {
789
- while (this.length > 1 && this.words[this.length - 1] === 0) {
790
- this.length--;
791
- }
792
- return this._normSign();
793
- };
794
- BN.prototype._normSign = function _normSign() {
795
- if (this.length === 1 && this.words[0] === 0) {
796
- this.negative = 0;
797
- }
798
- return this;
400
+ return this;
799
401
  };
800
402
  if (typeof Symbol !== "undefined" && typeof Symbol.for === "function") {
801
403
  try {
802
- BN.prototype[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")] = inspect;
404
+ BN2.prototype[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")] = inspect;
803
405
  } catch (e) {
804
- BN.prototype.inspect = inspect;
406
+ BN2.prototype.inspect = inspect;
805
407
  }
806
408
  } else {
807
- BN.prototype.inspect = inspect;
409
+ BN2.prototype.inspect = inspect;
808
410
  }
809
411
  function inspect() {
810
412
  return (this.red ? "<BN-R: " : "<BN: ") + this.toString(16) + ">";
@@ -915,7 +517,7 @@ var require_bn = __commonJS({
915
517
  52521875,
916
518
  60466176
917
519
  ];
918
- BN.prototype.toString = function toString(base, padding) {
520
+ BN2.prototype.toString = function toString(base, padding) {
919
521
  base = base || 10;
920
522
  padding = padding | 0 || 1;
921
523
  var out;
@@ -977,7 +579,7 @@ var require_bn = __commonJS({
977
579
  }
978
580
  assert(false, "Base should be between 2 and 36");
979
581
  };
980
- BN.prototype.toNumber = function toNumber() {
582
+ BN2.prototype.toNumber = function toNumber() {
981
583
  var ret = this.words[0];
982
584
  if (this.length === 2) {
983
585
  ret += this.words[1] * 67108864;
@@ -988,15 +590,15 @@ var require_bn = __commonJS({
988
590
  }
989
591
  return this.negative !== 0 ? -ret : ret;
990
592
  };
991
- BN.prototype.toJSON = function toJSON() {
593
+ BN2.prototype.toJSON = function toJSON() {
992
594
  return this.toString(16, 2);
993
595
  };
994
596
  if (Buffer2) {
995
- BN.prototype.toBuffer = function toBuffer(endian, length) {
597
+ BN2.prototype.toBuffer = function toBuffer(endian, length) {
996
598
  return this.toArrayLike(Buffer2, endian, length);
997
599
  };
998
600
  }
999
- BN.prototype.toArray = function toArray(endian, length) {
601
+ BN2.prototype.toArray = function toArray(endian, length) {
1000
602
  return this.toArrayLike(Array, endian, length);
1001
603
  };
1002
604
  var allocate = function allocate2(ArrayType, size) {
@@ -1005,7 +607,7 @@ var require_bn = __commonJS({
1005
607
  }
1006
608
  return new ArrayType(size);
1007
609
  };
1008
- BN.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length) {
610
+ BN2.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length) {
1009
611
  this._strip();
1010
612
  var byteLength = this.byteLength();
1011
613
  var reqLength = length || Math.max(1, byteLength);
@@ -1016,7 +618,7 @@ var require_bn = __commonJS({
1016
618
  this["_toArrayLike" + postfix](res, byteLength);
1017
619
  return res;
1018
620
  };
1019
- BN.prototype._toArrayLikeLE = function _toArrayLikeLE(res, byteLength) {
621
+ BN2.prototype._toArrayLikeLE = function _toArrayLikeLE(res, byteLength) {
1020
622
  var position = 0;
1021
623
  var carry = 0;
1022
624
  for (var i = 0, shift = 0; i < this.length; i++) {
@@ -1046,7 +648,7 @@ var require_bn = __commonJS({
1046
648
  }
1047
649
  }
1048
650
  };
1049
- BN.prototype._toArrayLikeBE = function _toArrayLikeBE(res, byteLength) {
651
+ BN2.prototype._toArrayLikeBE = function _toArrayLikeBE(res, byteLength) {
1050
652
  var position = res.length - 1;
1051
653
  var carry = 0;
1052
654
  for (var i = 0, shift = 0; i < this.length; i++) {
@@ -1077,11 +679,11 @@ var require_bn = __commonJS({
1077
679
  }
1078
680
  };
1079
681
  if (Math.clz32) {
1080
- BN.prototype._countBits = function _countBits(w2) {
682
+ BN2.prototype._countBits = function _countBits(w2) {
1081
683
  return 32 - Math.clz32(w2);
1082
684
  };
1083
685
  } else {
1084
- BN.prototype._countBits = function _countBits(w2) {
686
+ BN2.prototype._countBits = function _countBits(w2) {
1085
687
  var t = w2;
1086
688
  var r = 0;
1087
689
  if (t >= 4096) {
@@ -1103,7 +705,7 @@ var require_bn = __commonJS({
1103
705
  return r + t;
1104
706
  };
1105
707
  }
1106
- BN.prototype._zeroBits = function _zeroBits(w2) {
708
+ BN2.prototype._zeroBits = function _zeroBits(w2) {
1107
709
  if (w2 === 0) return 26;
1108
710
  var t = w2;
1109
711
  var r = 0;
@@ -1128,7 +730,7 @@ var require_bn = __commonJS({
1128
730
  }
1129
731
  return r;
1130
732
  };
1131
- BN.prototype.bitLength = function bitLength() {
733
+ BN2.prototype.bitLength = function bitLength() {
1132
734
  var w2 = this.words[this.length - 1];
1133
735
  var hi = this._countBits(w2);
1134
736
  return (this.length - 1) * 26 + hi;
@@ -1142,7 +744,7 @@ var require_bn = __commonJS({
1142
744
  }
1143
745
  return w2;
1144
746
  }
1145
- BN.prototype.zeroBits = function zeroBits() {
747
+ BN2.prototype.zeroBits = function zeroBits() {
1146
748
  if (this.isZero()) return 0;
1147
749
  var r = 0;
1148
750
  for (var i = 0; i < this.length; i++) {
@@ -1152,34 +754,34 @@ var require_bn = __commonJS({
1152
754
  }
1153
755
  return r;
1154
756
  };
1155
- BN.prototype.byteLength = function byteLength() {
757
+ BN2.prototype.byteLength = function byteLength() {
1156
758
  return Math.ceil(this.bitLength() / 8);
1157
759
  };
1158
- BN.prototype.toTwos = function toTwos(width) {
760
+ BN2.prototype.toTwos = function toTwos(width) {
1159
761
  if (this.negative !== 0) {
1160
762
  return this.abs().inotn(width).iaddn(1);
1161
763
  }
1162
764
  return this.clone();
1163
765
  };
1164
- BN.prototype.fromTwos = function fromTwos(width) {
766
+ BN2.prototype.fromTwos = function fromTwos(width) {
1165
767
  if (this.testn(width - 1)) {
1166
768
  return this.notn(width).iaddn(1).ineg();
1167
769
  }
1168
770
  return this.clone();
1169
771
  };
1170
- BN.prototype.isNeg = function isNeg() {
772
+ BN2.prototype.isNeg = function isNeg() {
1171
773
  return this.negative !== 0;
1172
774
  };
1173
- BN.prototype.neg = function neg() {
775
+ BN2.prototype.neg = function neg() {
1174
776
  return this.clone().ineg();
1175
777
  };
1176
- BN.prototype.ineg = function ineg() {
778
+ BN2.prototype.ineg = function ineg() {
1177
779
  if (!this.isZero()) {
1178
780
  this.negative ^= 1;
1179
781
  }
1180
782
  return this;
1181
783
  };
1182
- BN.prototype.iuor = function iuor(num) {
784
+ BN2.prototype.iuor = function iuor(num) {
1183
785
  while (this.length < num.length) {
1184
786
  this.words[this.length++] = 0;
1185
787
  }
@@ -1188,19 +790,19 @@ var require_bn = __commonJS({
1188
790
  }
1189
791
  return this._strip();
1190
792
  };
1191
- BN.prototype.ior = function ior(num) {
793
+ BN2.prototype.ior = function ior(num) {
1192
794
  assert((this.negative | num.negative) === 0);
1193
795
  return this.iuor(num);
1194
796
  };
1195
- BN.prototype.or = function or(num) {
797
+ BN2.prototype.or = function or(num) {
1196
798
  if (this.length > num.length) return this.clone().ior(num);
1197
799
  return num.clone().ior(this);
1198
800
  };
1199
- BN.prototype.uor = function uor(num) {
801
+ BN2.prototype.uor = function uor(num) {
1200
802
  if (this.length > num.length) return this.clone().iuor(num);
1201
803
  return num.clone().iuor(this);
1202
804
  };
1203
- BN.prototype.iuand = function iuand(num) {
805
+ BN2.prototype.iuand = function iuand(num) {
1204
806
  var b2;
1205
807
  if (this.length > num.length) {
1206
808
  b2 = num;
@@ -1213,19 +815,19 @@ var require_bn = __commonJS({
1213
815
  this.length = b2.length;
1214
816
  return this._strip();
1215
817
  };
1216
- BN.prototype.iand = function iand(num) {
818
+ BN2.prototype.iand = function iand(num) {
1217
819
  assert((this.negative | num.negative) === 0);
1218
820
  return this.iuand(num);
1219
821
  };
1220
- BN.prototype.and = function and(num) {
822
+ BN2.prototype.and = function and(num) {
1221
823
  if (this.length > num.length) return this.clone().iand(num);
1222
824
  return num.clone().iand(this);
1223
825
  };
1224
- BN.prototype.uand = function uand(num) {
826
+ BN2.prototype.uand = function uand(num) {
1225
827
  if (this.length > num.length) return this.clone().iuand(num);
1226
828
  return num.clone().iuand(this);
1227
829
  };
1228
- BN.prototype.iuxor = function iuxor(num) {
830
+ BN2.prototype.iuxor = function iuxor(num) {
1229
831
  var a;
1230
832
  var b2;
1231
833
  if (this.length > num.length) {
@@ -1246,19 +848,19 @@ var require_bn = __commonJS({
1246
848
  this.length = a.length;
1247
849
  return this._strip();
1248
850
  };
1249
- BN.prototype.ixor = function ixor(num) {
851
+ BN2.prototype.ixor = function ixor(num) {
1250
852
  assert((this.negative | num.negative) === 0);
1251
853
  return this.iuxor(num);
1252
854
  };
1253
- BN.prototype.xor = function xor(num) {
855
+ BN2.prototype.xor = function xor(num) {
1254
856
  if (this.length > num.length) return this.clone().ixor(num);
1255
857
  return num.clone().ixor(this);
1256
858
  };
1257
- BN.prototype.uxor = function uxor(num) {
859
+ BN2.prototype.uxor = function uxor(num) {
1258
860
  if (this.length > num.length) return this.clone().iuxor(num);
1259
861
  return num.clone().iuxor(this);
1260
862
  };
1261
- BN.prototype.inotn = function inotn(width) {
863
+ BN2.prototype.inotn = function inotn(width) {
1262
864
  assert(typeof width === "number" && width >= 0);
1263
865
  var bytesNeeded = Math.ceil(width / 26) | 0;
1264
866
  var bitsLeft = width % 26;
@@ -1274,10 +876,10 @@ var require_bn = __commonJS({
1274
876
  }
1275
877
  return this._strip();
1276
878
  };
1277
- BN.prototype.notn = function notn(width) {
879
+ BN2.prototype.notn = function notn(width) {
1278
880
  return this.clone().inotn(width);
1279
881
  };
1280
- BN.prototype.setn = function setn(bit, val) {
882
+ BN2.prototype.setn = function setn(bit, val) {
1281
883
  assert(typeof bit === "number" && bit >= 0);
1282
884
  var off = bit / 26 | 0;
1283
885
  var wbit = bit % 26;
@@ -1289,7 +891,7 @@ var require_bn = __commonJS({
1289
891
  }
1290
892
  return this._strip();
1291
893
  };
1292
- BN.prototype.iadd = function iadd(num) {
894
+ BN2.prototype.iadd = function iadd(num) {
1293
895
  var r;
1294
896
  if (this.negative !== 0 && num.negative === 0) {
1295
897
  this.negative = 0;
@@ -1332,7 +934,7 @@ var require_bn = __commonJS({
1332
934
  }
1333
935
  return this;
1334
936
  };
1335
- BN.prototype.add = function add2(num) {
937
+ BN2.prototype.add = function add2(num) {
1336
938
  var res;
1337
939
  if (num.negative !== 0 && this.negative === 0) {
1338
940
  num.negative = 0;
@@ -1348,7 +950,7 @@ var require_bn = __commonJS({
1348
950
  if (this.length > num.length) return this.clone().iadd(num);
1349
951
  return num.clone().iadd(this);
1350
952
  };
1351
- BN.prototype.isub = function isub(num) {
953
+ BN2.prototype.isub = function isub(num) {
1352
954
  if (num.negative !== 0) {
1353
955
  num.negative = 0;
1354
956
  var r = this.iadd(num);
@@ -1397,7 +999,7 @@ var require_bn = __commonJS({
1397
999
  }
1398
1000
  return this._strip();
1399
1001
  };
1400
- BN.prototype.sub = function sub(num) {
1002
+ BN2.prototype.sub = function sub(num) {
1401
1003
  return this.clone().isub(num);
1402
1004
  };
1403
1005
  function smallMulTo(self2, num, out) {
@@ -2025,7 +1627,7 @@ var require_bn = __commonJS({
2025
1627
  function jumboMulTo(self2, num, out) {
2026
1628
  return bigMulTo(self2, num, out);
2027
1629
  }
2028
- BN.prototype.mulTo = function mulTo(num, out) {
1630
+ BN2.prototype.mulTo = function mulTo(num, out) {
2029
1631
  var res;
2030
1632
  var len = this.length + num.length;
2031
1633
  if (this.length === 10 && num.length === 10) {
@@ -2045,7 +1647,7 @@ var require_bn = __commonJS({
2045
1647
  }
2046
1648
  FFTM.prototype.makeRBT = function makeRBT(N2) {
2047
1649
  var t = new Array(N2);
2048
- var l = BN.prototype._countBits(N2) - 1;
1650
+ var l = BN2.prototype._countBits(N2) - 1;
2049
1651
  for (var i = 0; i < N2; i++) {
2050
1652
  t[i] = this.revBin(i, l, N2);
2051
1653
  }
@@ -2180,20 +1782,20 @@ var require_bn = __commonJS({
2180
1782
  out.length = x2.length + y.length;
2181
1783
  return out._strip();
2182
1784
  };
2183
- BN.prototype.mul = function mul(num) {
2184
- var out = new BN(null);
1785
+ BN2.prototype.mul = function mul(num) {
1786
+ var out = new BN2(null);
2185
1787
  out.words = new Array(this.length + num.length);
2186
1788
  return this.mulTo(num, out);
2187
1789
  };
2188
- BN.prototype.mulf = function mulf(num) {
2189
- var out = new BN(null);
1790
+ BN2.prototype.mulf = function mulf(num) {
1791
+ var out = new BN2(null);
2190
1792
  out.words = new Array(this.length + num.length);
2191
1793
  return jumboMulTo(this, num, out);
2192
1794
  };
2193
- BN.prototype.imul = function imul(num) {
1795
+ BN2.prototype.imul = function imul(num) {
2194
1796
  return this.clone().mulTo(num, this);
2195
1797
  };
2196
- BN.prototype.imuln = function imuln(num) {
1798
+ BN2.prototype.imuln = function imuln(num) {
2197
1799
  var isNegNum = num < 0;
2198
1800
  if (isNegNum) num = -num;
2199
1801
  assert(typeof num === "number");
@@ -2214,18 +1816,18 @@ var require_bn = __commonJS({
2214
1816
  this.length = num === 0 ? 1 : this.length;
2215
1817
  return isNegNum ? this.ineg() : this;
2216
1818
  };
2217
- BN.prototype.muln = function muln(num) {
1819
+ BN2.prototype.muln = function muln(num) {
2218
1820
  return this.clone().imuln(num);
2219
1821
  };
2220
- BN.prototype.sqr = function sqr() {
1822
+ BN2.prototype.sqr = function sqr() {
2221
1823
  return this.mul(this);
2222
1824
  };
2223
- BN.prototype.isqr = function isqr() {
1825
+ BN2.prototype.isqr = function isqr() {
2224
1826
  return this.imul(this.clone());
2225
1827
  };
2226
- BN.prototype.pow = function pow(num) {
1828
+ BN2.prototype.pow = function pow(num) {
2227
1829
  var w2 = toBitArray(num);
2228
- if (w2.length === 0) return new BN(1);
1830
+ if (w2.length === 0) return new BN2(1);
2229
1831
  var res = this;
2230
1832
  for (var i = 0; i < w2.length; i++, res = res.sqr()) {
2231
1833
  if (w2[i] !== 0) break;
@@ -2238,7 +1840,7 @@ var require_bn = __commonJS({
2238
1840
  }
2239
1841
  return res;
2240
1842
  };
2241
- BN.prototype.iushln = function iushln(bits) {
1843
+ BN2.prototype.iushln = function iushln(bits) {
2242
1844
  assert(typeof bits === "number" && bits >= 0);
2243
1845
  var r = bits % 26;
2244
1846
  var s = (bits - r) / 26;
@@ -2268,11 +1870,11 @@ var require_bn = __commonJS({
2268
1870
  }
2269
1871
  return this._strip();
2270
1872
  };
2271
- BN.prototype.ishln = function ishln(bits) {
1873
+ BN2.prototype.ishln = function ishln(bits) {
2272
1874
  assert(this.negative === 0);
2273
1875
  return this.iushln(bits);
2274
1876
  };
2275
- BN.prototype.iushrn = function iushrn(bits, hint, extended) {
1877
+ BN2.prototype.iushrn = function iushrn(bits, hint, extended) {
2276
1878
  assert(typeof bits === "number" && bits >= 0);
2277
1879
  var h;
2278
1880
  if (hint) {
@@ -2317,23 +1919,23 @@ var require_bn = __commonJS({
2317
1919
  }
2318
1920
  return this._strip();
2319
1921
  };
2320
- BN.prototype.ishrn = function ishrn(bits, hint, extended) {
1922
+ BN2.prototype.ishrn = function ishrn(bits, hint, extended) {
2321
1923
  assert(this.negative === 0);
2322
1924
  return this.iushrn(bits, hint, extended);
2323
1925
  };
2324
- BN.prototype.shln = function shln(bits) {
1926
+ BN2.prototype.shln = function shln(bits) {
2325
1927
  return this.clone().ishln(bits);
2326
1928
  };
2327
- BN.prototype.ushln = function ushln(bits) {
1929
+ BN2.prototype.ushln = function ushln(bits) {
2328
1930
  return this.clone().iushln(bits);
2329
1931
  };
2330
- BN.prototype.shrn = function shrn(bits) {
1932
+ BN2.prototype.shrn = function shrn(bits) {
2331
1933
  return this.clone().ishrn(bits);
2332
1934
  };
2333
- BN.prototype.ushrn = function ushrn(bits) {
1935
+ BN2.prototype.ushrn = function ushrn(bits) {
2334
1936
  return this.clone().iushrn(bits);
2335
1937
  };
2336
- BN.prototype.testn = function testn(bit) {
1938
+ BN2.prototype.testn = function testn(bit) {
2337
1939
  assert(typeof bit === "number" && bit >= 0);
2338
1940
  var r = bit % 26;
2339
1941
  var s = (bit - r) / 26;
@@ -2342,7 +1944,7 @@ var require_bn = __commonJS({
2342
1944
  var w2 = this.words[s];
2343
1945
  return !!(w2 & q2);
2344
1946
  };
2345
- BN.prototype.imaskn = function imaskn(bits) {
1947
+ BN2.prototype.imaskn = function imaskn(bits) {
2346
1948
  assert(typeof bits === "number" && bits >= 0);
2347
1949
  var r = bits % 26;
2348
1950
  var s = (bits - r) / 26;
@@ -2364,10 +1966,10 @@ var require_bn = __commonJS({
2364
1966
  }
2365
1967
  return this._strip();
2366
1968
  };
2367
- BN.prototype.maskn = function maskn(bits) {
1969
+ BN2.prototype.maskn = function maskn(bits) {
2368
1970
  return this.clone().imaskn(bits);
2369
1971
  };
2370
- BN.prototype.iaddn = function iaddn(num) {
1972
+ BN2.prototype.iaddn = function iaddn(num) {
2371
1973
  assert(typeof num === "number");
2372
1974
  assert(num < 67108864);
2373
1975
  if (num < 0) return this.isubn(-num);
@@ -2384,7 +1986,7 @@ var require_bn = __commonJS({
2384
1986
  }
2385
1987
  return this._iaddn(num);
2386
1988
  };
2387
- BN.prototype._iaddn = function _iaddn(num) {
1989
+ BN2.prototype._iaddn = function _iaddn(num) {
2388
1990
  this.words[0] += num;
2389
1991
  for (var i = 0; i < this.length && this.words[i] >= 67108864; i++) {
2390
1992
  this.words[i] -= 67108864;
@@ -2397,7 +1999,7 @@ var require_bn = __commonJS({
2397
1999
  this.length = Math.max(this.length, i + 1);
2398
2000
  return this;
2399
2001
  };
2400
- BN.prototype.isubn = function isubn(num) {
2002
+ BN2.prototype.isubn = function isubn(num) {
2401
2003
  assert(typeof num === "number");
2402
2004
  assert(num < 67108864);
2403
2005
  if (num < 0) return this.iaddn(-num);
@@ -2419,20 +2021,20 @@ var require_bn = __commonJS({
2419
2021
  }
2420
2022
  return this._strip();
2421
2023
  };
2422
- BN.prototype.addn = function addn(num) {
2024
+ BN2.prototype.addn = function addn(num) {
2423
2025
  return this.clone().iaddn(num);
2424
2026
  };
2425
- BN.prototype.subn = function subn(num) {
2027
+ BN2.prototype.subn = function subn(num) {
2426
2028
  return this.clone().isubn(num);
2427
2029
  };
2428
- BN.prototype.iabs = function iabs() {
2030
+ BN2.prototype.iabs = function iabs() {
2429
2031
  this.negative = 0;
2430
2032
  return this;
2431
2033
  };
2432
- BN.prototype.abs = function abs() {
2034
+ BN2.prototype.abs = function abs() {
2433
2035
  return this.clone().iabs();
2434
2036
  };
2435
- BN.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) {
2037
+ BN2.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) {
2436
2038
  var len = num.length + shift;
2437
2039
  var i;
2438
2040
  this._expand(len);
@@ -2461,7 +2063,7 @@ var require_bn = __commonJS({
2461
2063
  this.negative = 1;
2462
2064
  return this._strip();
2463
2065
  };
2464
- BN.prototype._wordDiv = function _wordDiv(num, mode) {
2066
+ BN2.prototype._wordDiv = function _wordDiv(num, mode) {
2465
2067
  var shift = this.length - num.length;
2466
2068
  var a = this.clone();
2467
2069
  var b2 = num;
@@ -2476,7 +2078,7 @@ var require_bn = __commonJS({
2476
2078
  var m = a.length - b2.length;
2477
2079
  var q2;
2478
2080
  if (mode !== "mod") {
2479
- q2 = new BN(null);
2081
+ q2 = new BN2(null);
2480
2082
  q2.length = m + 1;
2481
2083
  q2.words = new Array(q2.length);
2482
2084
  for (var i = 0; i < q2.length; i++) {
@@ -2518,12 +2120,12 @@ var require_bn = __commonJS({
2518
2120
  mod: a
2519
2121
  };
2520
2122
  };
2521
- BN.prototype.divmod = function divmod(num, mode, positive) {
2123
+ BN2.prototype.divmod = function divmod(num, mode, positive) {
2522
2124
  assert(!num.isZero());
2523
2125
  if (this.isZero()) {
2524
2126
  return {
2525
- div: new BN(0),
2526
- mod: new BN(0)
2127
+ div: new BN2(0),
2128
+ mod: new BN2(0)
2527
2129
  };
2528
2130
  }
2529
2131
  var div, mod2, res;
@@ -2568,7 +2170,7 @@ var require_bn = __commonJS({
2568
2170
  }
2569
2171
  if (num.length > this.length || this.cmp(num) < 0) {
2570
2172
  return {
2571
- div: new BN(0),
2173
+ div: new BN2(0),
2572
2174
  mod: this
2573
2175
  };
2574
2176
  }
@@ -2582,26 +2184,26 @@ var require_bn = __commonJS({
2582
2184
  if (mode === "mod") {
2583
2185
  return {
2584
2186
  div: null,
2585
- mod: new BN(this.modrn(num.words[0]))
2187
+ mod: new BN2(this.modrn(num.words[0]))
2586
2188
  };
2587
2189
  }
2588
2190
  return {
2589
2191
  div: this.divn(num.words[0]),
2590
- mod: new BN(this.modrn(num.words[0]))
2192
+ mod: new BN2(this.modrn(num.words[0]))
2591
2193
  };
2592
2194
  }
2593
2195
  return this._wordDiv(num, mode);
2594
2196
  };
2595
- BN.prototype.div = function div(num) {
2197
+ BN2.prototype.div = function div(num) {
2596
2198
  return this.divmod(num, "div", false).div;
2597
2199
  };
2598
- BN.prototype.mod = function mod2(num) {
2200
+ BN2.prototype.mod = function mod2(num) {
2599
2201
  return this.divmod(num, "mod", false).mod;
2600
2202
  };
2601
- BN.prototype.umod = function umod(num) {
2203
+ BN2.prototype.umod = function umod(num) {
2602
2204
  return this.divmod(num, "mod", true).mod;
2603
2205
  };
2604
- BN.prototype.divRound = function divRound(num) {
2206
+ BN2.prototype.divRound = function divRound(num) {
2605
2207
  var dm = this.divmod(num);
2606
2208
  if (dm.mod.isZero()) return dm.div;
2607
2209
  var mod2 = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
@@ -2611,7 +2213,7 @@ var require_bn = __commonJS({
2611
2213
  if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
2612
2214
  return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
2613
2215
  };
2614
- BN.prototype.modrn = function modrn(num) {
2216
+ BN2.prototype.modrn = function modrn(num) {
2615
2217
  var isNegNum = num < 0;
2616
2218
  if (isNegNum) num = -num;
2617
2219
  assert(num <= 67108863);
@@ -2622,10 +2224,10 @@ var require_bn = __commonJS({
2622
2224
  }
2623
2225
  return isNegNum ? -acc : acc;
2624
2226
  };
2625
- BN.prototype.modn = function modn(num) {
2227
+ BN2.prototype.modn = function modn(num) {
2626
2228
  return this.modrn(num);
2627
2229
  };
2628
- BN.prototype.idivn = function idivn(num) {
2230
+ BN2.prototype.idivn = function idivn(num) {
2629
2231
  var isNegNum = num < 0;
2630
2232
  if (isNegNum) num = -num;
2631
2233
  assert(num <= 67108863);
@@ -2638,10 +2240,10 @@ var require_bn = __commonJS({
2638
2240
  this._strip();
2639
2241
  return isNegNum ? this.ineg() : this;
2640
2242
  };
2641
- BN.prototype.divn = function divn(num) {
2243
+ BN2.prototype.divn = function divn(num) {
2642
2244
  return this.clone().idivn(num);
2643
2245
  };
2644
- BN.prototype.egcd = function egcd(p) {
2246
+ BN2.prototype.egcd = function egcd(p) {
2645
2247
  assert(p.negative === 0);
2646
2248
  assert(!p.isZero());
2647
2249
  var x2 = this;
@@ -2651,10 +2253,10 @@ var require_bn = __commonJS({
2651
2253
  } else {
2652
2254
  x2 = x2.clone();
2653
2255
  }
2654
- var A2 = new BN(1);
2655
- var B2 = new BN(0);
2656
- var C = new BN(0);
2657
- var D = new BN(1);
2256
+ var A2 = new BN2(1);
2257
+ var B2 = new BN2(0);
2258
+ var C = new BN2(0);
2259
+ var D = new BN2(1);
2658
2260
  var g2 = 0;
2659
2261
  while (x2.isEven() && y.isEven()) {
2660
2262
  x2.iushrn(1);
@@ -2704,7 +2306,7 @@ var require_bn = __commonJS({
2704
2306
  gcd: y.iushln(g2)
2705
2307
  };
2706
2308
  };
2707
- BN.prototype._invmp = function _invmp(p) {
2309
+ BN2.prototype._invmp = function _invmp(p) {
2708
2310
  assert(p.negative === 0);
2709
2311
  assert(!p.isZero());
2710
2312
  var a = this;
@@ -2714,8 +2316,8 @@ var require_bn = __commonJS({
2714
2316
  } else {
2715
2317
  a = a.clone();
2716
2318
  }
2717
- var x1 = new BN(1);
2718
- var x2 = new BN(0);
2319
+ var x1 = new BN2(1);
2320
+ var x2 = new BN2(0);
2719
2321
  var delta = b2.clone();
2720
2322
  while (a.cmpn(1) > 0 && b2.cmpn(1) > 0) {
2721
2323
  for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1) ;
@@ -2757,7 +2359,7 @@ var require_bn = __commonJS({
2757
2359
  }
2758
2360
  return res;
2759
2361
  };
2760
- BN.prototype.gcd = function gcd(num) {
2362
+ BN2.prototype.gcd = function gcd(num) {
2761
2363
  if (this.isZero()) return num.abs();
2762
2364
  if (num.isZero()) return this.abs();
2763
2365
  var a = this.clone();
@@ -2787,19 +2389,19 @@ var require_bn = __commonJS({
2787
2389
  } while (true);
2788
2390
  return b2.iushln(shift);
2789
2391
  };
2790
- BN.prototype.invm = function invm(num) {
2392
+ BN2.prototype.invm = function invm(num) {
2791
2393
  return this.egcd(num).a.umod(num);
2792
2394
  };
2793
- BN.prototype.isEven = function isEven() {
2395
+ BN2.prototype.isEven = function isEven() {
2794
2396
  return (this.words[0] & 1) === 0;
2795
2397
  };
2796
- BN.prototype.isOdd = function isOdd2() {
2398
+ BN2.prototype.isOdd = function isOdd2() {
2797
2399
  return (this.words[0] & 1) === 1;
2798
2400
  };
2799
- BN.prototype.andln = function andln(num) {
2401
+ BN2.prototype.andln = function andln(num) {
2800
2402
  return this.words[0] & num;
2801
2403
  };
2802
- BN.prototype.bincn = function bincn(bit) {
2404
+ BN2.prototype.bincn = function bincn(bit) {
2803
2405
  assert(typeof bit === "number");
2804
2406
  var r = bit % 26;
2805
2407
  var s = (bit - r) / 26;
@@ -2823,10 +2425,10 @@ var require_bn = __commonJS({
2823
2425
  }
2824
2426
  return this;
2825
2427
  };
2826
- BN.prototype.isZero = function isZero() {
2428
+ BN2.prototype.isZero = function isZero() {
2827
2429
  return this.length === 1 && this.words[0] === 0;
2828
2430
  };
2829
- BN.prototype.cmpn = function cmpn(num) {
2431
+ BN2.prototype.cmpn = function cmpn(num) {
2830
2432
  var negative = num < 0;
2831
2433
  if (this.negative !== 0 && !negative) return -1;
2832
2434
  if (this.negative === 0 && negative) return 1;
@@ -2845,14 +2447,14 @@ var require_bn = __commonJS({
2845
2447
  if (this.negative !== 0) return -res | 0;
2846
2448
  return res;
2847
2449
  };
2848
- BN.prototype.cmp = function cmp(num) {
2450
+ BN2.prototype.cmp = function cmp(num) {
2849
2451
  if (this.negative !== 0 && num.negative === 0) return -1;
2850
2452
  if (this.negative === 0 && num.negative !== 0) return 1;
2851
2453
  var res = this.ucmp(num);
2852
2454
  if (this.negative !== 0) return -res | 0;
2853
2455
  return res;
2854
2456
  };
2855
- BN.prototype.ucmp = function ucmp(num) {
2457
+ BN2.prototype.ucmp = function ucmp(num) {
2856
2458
  if (this.length > num.length) return 1;
2857
2459
  if (this.length < num.length) return -1;
2858
2460
  var res = 0;
@@ -2869,112 +2471,112 @@ var require_bn = __commonJS({
2869
2471
  }
2870
2472
  return res;
2871
2473
  };
2872
- BN.prototype.gtn = function gtn(num) {
2474
+ BN2.prototype.gtn = function gtn(num) {
2873
2475
  return this.cmpn(num) === 1;
2874
2476
  };
2875
- BN.prototype.gt = function gt(num) {
2477
+ BN2.prototype.gt = function gt(num) {
2876
2478
  return this.cmp(num) === 1;
2877
2479
  };
2878
- BN.prototype.gten = function gten(num) {
2480
+ BN2.prototype.gten = function gten(num) {
2879
2481
  return this.cmpn(num) >= 0;
2880
2482
  };
2881
- BN.prototype.gte = function gte(num) {
2483
+ BN2.prototype.gte = function gte(num) {
2882
2484
  return this.cmp(num) >= 0;
2883
2485
  };
2884
- BN.prototype.ltn = function ltn(num) {
2486
+ BN2.prototype.ltn = function ltn(num) {
2885
2487
  return this.cmpn(num) === -1;
2886
2488
  };
2887
- BN.prototype.lt = function lt(num) {
2489
+ BN2.prototype.lt = function lt(num) {
2888
2490
  return this.cmp(num) === -1;
2889
2491
  };
2890
- BN.prototype.lten = function lten(num) {
2492
+ BN2.prototype.lten = function lten(num) {
2891
2493
  return this.cmpn(num) <= 0;
2892
2494
  };
2893
- BN.prototype.lte = function lte(num) {
2495
+ BN2.prototype.lte = function lte(num) {
2894
2496
  return this.cmp(num) <= 0;
2895
2497
  };
2896
- BN.prototype.eqn = function eqn(num) {
2498
+ BN2.prototype.eqn = function eqn(num) {
2897
2499
  return this.cmpn(num) === 0;
2898
2500
  };
2899
- BN.prototype.eq = function eq(num) {
2501
+ BN2.prototype.eq = function eq(num) {
2900
2502
  return this.cmp(num) === 0;
2901
2503
  };
2902
- BN.red = function red(num) {
2504
+ BN2.red = function red(num) {
2903
2505
  return new Red(num);
2904
2506
  };
2905
- BN.prototype.toRed = function toRed(ctx) {
2507
+ BN2.prototype.toRed = function toRed(ctx) {
2906
2508
  assert(!this.red, "Already a number in reduction context");
2907
2509
  assert(this.negative === 0, "red works only with positives");
2908
2510
  return ctx.convertTo(this)._forceRed(ctx);
2909
2511
  };
2910
- BN.prototype.fromRed = function fromRed() {
2512
+ BN2.prototype.fromRed = function fromRed() {
2911
2513
  assert(this.red, "fromRed works only with numbers in reduction context");
2912
2514
  return this.red.convertFrom(this);
2913
2515
  };
2914
- BN.prototype._forceRed = function _forceRed(ctx) {
2516
+ BN2.prototype._forceRed = function _forceRed(ctx) {
2915
2517
  this.red = ctx;
2916
2518
  return this;
2917
2519
  };
2918
- BN.prototype.forceRed = function forceRed(ctx) {
2520
+ BN2.prototype.forceRed = function forceRed(ctx) {
2919
2521
  assert(!this.red, "Already a number in reduction context");
2920
2522
  return this._forceRed(ctx);
2921
2523
  };
2922
- BN.prototype.redAdd = function redAdd(num) {
2524
+ BN2.prototype.redAdd = function redAdd(num) {
2923
2525
  assert(this.red, "redAdd works only with red numbers");
2924
2526
  return this.red.add(this, num);
2925
2527
  };
2926
- BN.prototype.redIAdd = function redIAdd(num) {
2528
+ BN2.prototype.redIAdd = function redIAdd(num) {
2927
2529
  assert(this.red, "redIAdd works only with red numbers");
2928
2530
  return this.red.iadd(this, num);
2929
2531
  };
2930
- BN.prototype.redSub = function redSub(num) {
2532
+ BN2.prototype.redSub = function redSub(num) {
2931
2533
  assert(this.red, "redSub works only with red numbers");
2932
2534
  return this.red.sub(this, num);
2933
2535
  };
2934
- BN.prototype.redISub = function redISub(num) {
2536
+ BN2.prototype.redISub = function redISub(num) {
2935
2537
  assert(this.red, "redISub works only with red numbers");
2936
2538
  return this.red.isub(this, num);
2937
2539
  };
2938
- BN.prototype.redShl = function redShl(num) {
2540
+ BN2.prototype.redShl = function redShl(num) {
2939
2541
  assert(this.red, "redShl works only with red numbers");
2940
2542
  return this.red.shl(this, num);
2941
2543
  };
2942
- BN.prototype.redMul = function redMul(num) {
2544
+ BN2.prototype.redMul = function redMul(num) {
2943
2545
  assert(this.red, "redMul works only with red numbers");
2944
2546
  this.red._verify2(this, num);
2945
2547
  return this.red.mul(this, num);
2946
2548
  };
2947
- BN.prototype.redIMul = function redIMul(num) {
2549
+ BN2.prototype.redIMul = function redIMul(num) {
2948
2550
  assert(this.red, "redMul works only with red numbers");
2949
2551
  this.red._verify2(this, num);
2950
2552
  return this.red.imul(this, num);
2951
2553
  };
2952
- BN.prototype.redSqr = function redSqr() {
2554
+ BN2.prototype.redSqr = function redSqr() {
2953
2555
  assert(this.red, "redSqr works only with red numbers");
2954
2556
  this.red._verify1(this);
2955
2557
  return this.red.sqr(this);
2956
2558
  };
2957
- BN.prototype.redISqr = function redISqr() {
2559
+ BN2.prototype.redISqr = function redISqr() {
2958
2560
  assert(this.red, "redISqr works only with red numbers");
2959
2561
  this.red._verify1(this);
2960
2562
  return this.red.isqr(this);
2961
2563
  };
2962
- BN.prototype.redSqrt = function redSqrt() {
2564
+ BN2.prototype.redSqrt = function redSqrt() {
2963
2565
  assert(this.red, "redSqrt works only with red numbers");
2964
2566
  this.red._verify1(this);
2965
2567
  return this.red.sqrt(this);
2966
2568
  };
2967
- BN.prototype.redInvm = function redInvm() {
2569
+ BN2.prototype.redInvm = function redInvm() {
2968
2570
  assert(this.red, "redInvm works only with red numbers");
2969
2571
  this.red._verify1(this);
2970
2572
  return this.red.invm(this);
2971
2573
  };
2972
- BN.prototype.redNeg = function redNeg() {
2574
+ BN2.prototype.redNeg = function redNeg() {
2973
2575
  assert(this.red, "redNeg works only with red numbers");
2974
2576
  this.red._verify1(this);
2975
2577
  return this.red.neg(this);
2976
2578
  };
2977
- BN.prototype.redPow = function redPow(num) {
2579
+ BN2.prototype.redPow = function redPow(num) {
2978
2580
  assert(this.red && !num.red, "redPow(normalNum)");
2979
2581
  this.red._verify1(this);
2980
2582
  return this.red.pow(this, num);
@@ -2987,13 +2589,13 @@ var require_bn = __commonJS({
2987
2589
  };
2988
2590
  function MPrime(name, p) {
2989
2591
  this.name = name;
2990
- this.p = new BN(p, 16);
2592
+ this.p = new BN2(p, 16);
2991
2593
  this.n = this.p.bitLength();
2992
- this.k = new BN(1).iushln(this.n).isub(this.p);
2594
+ this.k = new BN2(1).iushln(this.n).isub(this.p);
2993
2595
  this.tmp = this._tmp();
2994
2596
  }
2995
2597
  MPrime.prototype._tmp = function _tmp() {
2996
- var tmp = new BN(null);
2598
+ var tmp = new BN2(null);
2997
2599
  tmp.words = new Array(Math.ceil(this.n / 13));
2998
2600
  return tmp;
2999
2601
  };
@@ -3119,7 +2721,7 @@ var require_bn = __commonJS({
3119
2721
  }
3120
2722
  return num;
3121
2723
  };
3122
- BN._prime = function prime(name) {
2724
+ BN2._prime = function prime(name) {
3123
2725
  if (primes[name]) return primes[name];
3124
2726
  var prime2;
3125
2727
  if (name === "k256") {
@@ -3138,7 +2740,7 @@ var require_bn = __commonJS({
3138
2740
  };
3139
2741
  function Red(m) {
3140
2742
  if (typeof m === "string") {
3141
- var prime = BN._prime(m);
2743
+ var prime = BN2._prime(m);
3142
2744
  this.m = prime.p;
3143
2745
  this.prime = prime;
3144
2746
  } else {
@@ -3224,7 +2826,7 @@ var require_bn = __commonJS({
3224
2826
  var mod3 = this.m.andln(3);
3225
2827
  assert(mod3 % 2 === 1);
3226
2828
  if (mod3 === 3) {
3227
- var pow = this.m.add(new BN(1)).iushrn(2);
2829
+ var pow = this.m.add(new BN2(1)).iushrn(2);
3228
2830
  return this.pow(a, pow);
3229
2831
  }
3230
2832
  var q2 = this.m.subn(1);
@@ -3234,11 +2836,11 @@ var require_bn = __commonJS({
3234
2836
  q2.iushrn(1);
3235
2837
  }
3236
2838
  assert(!q2.isZero());
3237
- var one = new BN(1).toRed(this);
2839
+ var one = new BN2(1).toRed(this);
3238
2840
  var nOne = one.redNeg();
3239
2841
  var lpow = this.m.subn(1).iushrn(1);
3240
2842
  var z2 = this.m.bitLength();
3241
- z2 = new BN(2 * z2 * z2).toRed(this);
2843
+ z2 = new BN2(2 * z2 * z2).toRed(this);
3242
2844
  while (this.pow(z2, lpow).cmp(nOne) !== 0) {
3243
2845
  z2.redIAdd(nOne);
3244
2846
  }
@@ -3252,7 +2854,7 @@ var require_bn = __commonJS({
3252
2854
  tmp = tmp.redSqr();
3253
2855
  }
3254
2856
  assert(i < m);
3255
- var b2 = this.pow(c, new BN(1).iushln(m - i - 1));
2857
+ var b2 = this.pow(c, new BN2(1).iushln(m - i - 1));
3256
2858
  r = r.redMul(b2);
3257
2859
  c = b2.redSqr();
3258
2860
  t = t.redMul(c);
@@ -3268,116 +2870,514 @@ var require_bn = __commonJS({
3268
2870
  } else {
3269
2871
  return this.imod(inv);
3270
2872
  }
3271
- };
3272
- Red.prototype.pow = function pow(a, num) {
3273
- if (num.isZero()) return new BN(1).toRed(this);
3274
- if (num.cmpn(1) === 0) return a.clone();
3275
- var windowSize = 4;
3276
- var wnd = new Array(1 << windowSize);
3277
- wnd[0] = new BN(1).toRed(this);
3278
- wnd[1] = a;
3279
- for (var i = 2; i < wnd.length; i++) {
3280
- wnd[i] = this.mul(wnd[i - 1], a);
2873
+ };
2874
+ Red.prototype.pow = function pow(a, num) {
2875
+ if (num.isZero()) return new BN2(1).toRed(this);
2876
+ if (num.cmpn(1) === 0) return a.clone();
2877
+ var windowSize = 4;
2878
+ var wnd = new Array(1 << windowSize);
2879
+ wnd[0] = new BN2(1).toRed(this);
2880
+ wnd[1] = a;
2881
+ for (var i = 2; i < wnd.length; i++) {
2882
+ wnd[i] = this.mul(wnd[i - 1], a);
2883
+ }
2884
+ var res = wnd[0];
2885
+ var current = 0;
2886
+ var currentLen = 0;
2887
+ var start = num.bitLength() % 26;
2888
+ if (start === 0) {
2889
+ start = 26;
2890
+ }
2891
+ for (i = num.length - 1; i >= 0; i--) {
2892
+ var word = num.words[i];
2893
+ for (var j = start - 1; j >= 0; j--) {
2894
+ var bit = word >> j & 1;
2895
+ if (res !== wnd[0]) {
2896
+ res = this.sqr(res);
2897
+ }
2898
+ if (bit === 0 && current === 0) {
2899
+ currentLen = 0;
2900
+ continue;
2901
+ }
2902
+ current <<= 1;
2903
+ current |= bit;
2904
+ currentLen++;
2905
+ if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
2906
+ res = this.mul(res, wnd[current]);
2907
+ currentLen = 0;
2908
+ current = 0;
2909
+ }
2910
+ start = 26;
2911
+ }
2912
+ return res;
2913
+ };
2914
+ Red.prototype.convertTo = function convertTo(num) {
2915
+ var r = num.umod(this.m);
2916
+ return r === num ? r.clone() : r;
2917
+ };
2918
+ Red.prototype.convertFrom = function convertFrom(num) {
2919
+ var res = num.clone();
2920
+ res.red = null;
2921
+ return res;
2922
+ };
2923
+ BN2.mont = function mont(num) {
2924
+ return new Mont(num);
2925
+ };
2926
+ function Mont(m) {
2927
+ Red.call(this, m);
2928
+ this.shift = this.m.bitLength();
2929
+ if (this.shift % 26 !== 0) {
2930
+ this.shift += 26 - this.shift % 26;
2931
+ }
2932
+ this.r = new BN2(1).iushln(this.shift);
2933
+ this.r2 = this.imod(this.r.sqr());
2934
+ this.rinv = this.r._invmp(this.m);
2935
+ this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
2936
+ this.minv = this.minv.umod(this.r);
2937
+ this.minv = this.r.sub(this.minv);
2938
+ }
2939
+ inherits(Mont, Red);
2940
+ Mont.prototype.convertTo = function convertTo(num) {
2941
+ return this.imod(num.ushln(this.shift));
2942
+ };
2943
+ Mont.prototype.convertFrom = function convertFrom(num) {
2944
+ var r = this.imod(num.mul(this.rinv));
2945
+ r.red = null;
2946
+ return r;
2947
+ };
2948
+ Mont.prototype.imul = function imul(a, b2) {
2949
+ if (a.isZero() || b2.isZero()) {
2950
+ a.words[0] = 0;
2951
+ a.length = 1;
2952
+ return a;
2953
+ }
2954
+ var t = a.imul(b2);
2955
+ var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
2956
+ var u = t.isub(c).iushrn(this.shift);
2957
+ var res = u;
2958
+ if (u.cmp(this.m) >= 0) {
2959
+ res = u.isub(this.m);
2960
+ } else if (u.cmpn(0) < 0) {
2961
+ res = u.iadd(this.m);
2962
+ }
2963
+ return res._forceRed(this);
2964
+ };
2965
+ Mont.prototype.mul = function mul(a, b2) {
2966
+ if (a.isZero() || b2.isZero()) return new BN2(0)._forceRed(this);
2967
+ var t = a.mul(b2);
2968
+ var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
2969
+ var u = t.isub(c).iushrn(this.shift);
2970
+ var res = u;
2971
+ if (u.cmp(this.m) >= 0) {
2972
+ res = u.isub(this.m);
2973
+ } else if (u.cmpn(0) < 0) {
2974
+ res = u.iadd(this.m);
2975
+ }
2976
+ return res._forceRed(this);
2977
+ };
2978
+ Mont.prototype.invm = function invm(a) {
2979
+ var res = this.imod(a._invmp(this.m).mul(this.r2));
2980
+ return res._forceRed(this);
2981
+ };
2982
+ })(typeof module === "undefined" || module, exports);
2983
+ }
2984
+ });
2985
+
2986
+ // ../../node_modules/.pnpm/eventemitter3@5.0.4/node_modules/eventemitter3/index.js
2987
+ var require_eventemitter3 = __commonJS({
2988
+ "../../node_modules/.pnpm/eventemitter3@5.0.4/node_modules/eventemitter3/index.js"(exports, module) {
2989
+ "use strict";
2990
+ var has = Object.prototype.hasOwnProperty;
2991
+ var prefix = "~";
2992
+ function Events() {
2993
+ }
2994
+ if (Object.create) {
2995
+ Events.prototype = /* @__PURE__ */ Object.create(null);
2996
+ if (!new Events().__proto__) prefix = false;
2997
+ }
2998
+ function EE(fn, context, once) {
2999
+ this.fn = fn;
3000
+ this.context = context;
3001
+ this.once = once || false;
3002
+ }
3003
+ function addListener(emitter, event, fn, context, once) {
3004
+ if (typeof fn !== "function") {
3005
+ throw new TypeError("The listener must be a function");
3006
+ }
3007
+ var listener = new EE(fn, context || emitter, once), evt = prefix ? prefix + event : event;
3008
+ if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
3009
+ else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
3010
+ else emitter._events[evt] = [emitter._events[evt], listener];
3011
+ return emitter;
3012
+ }
3013
+ function clearEvent(emitter, evt) {
3014
+ if (--emitter._eventsCount === 0) emitter._events = new Events();
3015
+ else delete emitter._events[evt];
3016
+ }
3017
+ function EventEmitter2() {
3018
+ this._events = new Events();
3019
+ this._eventsCount = 0;
3020
+ }
3021
+ EventEmitter2.prototype.eventNames = function eventNames() {
3022
+ var names = [], events, name;
3023
+ if (this._eventsCount === 0) return names;
3024
+ for (name in events = this._events) {
3025
+ if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
3026
+ }
3027
+ if (Object.getOwnPropertySymbols) {
3028
+ return names.concat(Object.getOwnPropertySymbols(events));
3029
+ }
3030
+ return names;
3031
+ };
3032
+ EventEmitter2.prototype.listeners = function listeners(event) {
3033
+ var evt = prefix ? prefix + event : event, handlers = this._events[evt];
3034
+ if (!handlers) return [];
3035
+ if (handlers.fn) return [handlers.fn];
3036
+ for (var i = 0, l = handlers.length, ee2 = new Array(l); i < l; i++) {
3037
+ ee2[i] = handlers[i].fn;
3038
+ }
3039
+ return ee2;
3040
+ };
3041
+ EventEmitter2.prototype.listenerCount = function listenerCount(event) {
3042
+ var evt = prefix ? prefix + event : event, listeners = this._events[evt];
3043
+ if (!listeners) return 0;
3044
+ if (listeners.fn) return 1;
3045
+ return listeners.length;
3046
+ };
3047
+ EventEmitter2.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
3048
+ var evt = prefix ? prefix + event : event;
3049
+ if (!this._events[evt]) return false;
3050
+ var listeners = this._events[evt], len = arguments.length, args, i;
3051
+ if (listeners.fn) {
3052
+ if (listeners.once) this.removeListener(event, listeners.fn, void 0, true);
3053
+ switch (len) {
3054
+ case 1:
3055
+ return listeners.fn.call(listeners.context), true;
3056
+ case 2:
3057
+ return listeners.fn.call(listeners.context, a1), true;
3058
+ case 3:
3059
+ return listeners.fn.call(listeners.context, a1, a2), true;
3060
+ case 4:
3061
+ return listeners.fn.call(listeners.context, a1, a2, a3), true;
3062
+ case 5:
3063
+ return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
3064
+ case 6:
3065
+ return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
3066
+ }
3067
+ for (i = 1, args = new Array(len - 1); i < len; i++) {
3068
+ args[i - 1] = arguments[i];
3069
+ }
3070
+ listeners.fn.apply(listeners.context, args);
3071
+ } else {
3072
+ var length = listeners.length, j;
3073
+ for (i = 0; i < length; i++) {
3074
+ if (listeners[i].once) this.removeListener(event, listeners[i].fn, void 0, true);
3075
+ switch (len) {
3076
+ case 1:
3077
+ listeners[i].fn.call(listeners[i].context);
3078
+ break;
3079
+ case 2:
3080
+ listeners[i].fn.call(listeners[i].context, a1);
3081
+ break;
3082
+ case 3:
3083
+ listeners[i].fn.call(listeners[i].context, a1, a2);
3084
+ break;
3085
+ case 4:
3086
+ listeners[i].fn.call(listeners[i].context, a1, a2, a3);
3087
+ break;
3088
+ default:
3089
+ if (!args) for (j = 1, args = new Array(len - 1); j < len; j++) {
3090
+ args[j - 1] = arguments[j];
3091
+ }
3092
+ listeners[i].fn.apply(listeners[i].context, args);
3093
+ }
3094
+ }
3095
+ }
3096
+ return true;
3097
+ };
3098
+ EventEmitter2.prototype.on = function on(event, fn, context) {
3099
+ return addListener(this, event, fn, context, false);
3100
+ };
3101
+ EventEmitter2.prototype.once = function once(event, fn, context) {
3102
+ return addListener(this, event, fn, context, true);
3103
+ };
3104
+ EventEmitter2.prototype.removeListener = function removeListener(event, fn, context, once) {
3105
+ var evt = prefix ? prefix + event : event;
3106
+ if (!this._events[evt]) return this;
3107
+ if (!fn) {
3108
+ clearEvent(this, evt);
3109
+ return this;
3110
+ }
3111
+ var listeners = this._events[evt];
3112
+ if (listeners.fn) {
3113
+ if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) {
3114
+ clearEvent(this, evt);
3115
+ }
3116
+ } else {
3117
+ for (var i = 0, events = [], length = listeners.length; i < length; i++) {
3118
+ if (listeners[i].fn !== fn || once && !listeners[i].once || context && listeners[i].context !== context) {
3119
+ events.push(listeners[i]);
3120
+ }
3121
+ }
3122
+ if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
3123
+ else clearEvent(this, evt);
3124
+ }
3125
+ return this;
3126
+ };
3127
+ EventEmitter2.prototype.removeAllListeners = function removeAllListeners(event) {
3128
+ var evt;
3129
+ if (event) {
3130
+ evt = prefix ? prefix + event : event;
3131
+ if (this._events[evt]) clearEvent(this, evt);
3132
+ } else {
3133
+ this._events = new Events();
3134
+ this._eventsCount = 0;
3135
+ }
3136
+ return this;
3137
+ };
3138
+ EventEmitter2.prototype.off = EventEmitter2.prototype.removeListener;
3139
+ EventEmitter2.prototype.addListener = EventEmitter2.prototype.on;
3140
+ EventEmitter2.prefixed = prefix;
3141
+ EventEmitter2.EventEmitter = EventEmitter2;
3142
+ if ("undefined" !== typeof module) {
3143
+ module.exports = EventEmitter2;
3144
+ }
3145
+ }
3146
+ });
3147
+
3148
+ // ../../node_modules/.pnpm/@pythnetwork+price-service-sdk@1.9.0/node_modules/@pythnetwork/price-service-sdk/dist/cjs/schemas/PriceFeed.cjs
3149
+ var require_PriceFeed = __commonJS({
3150
+ "../../node_modules/.pnpm/@pythnetwork+price-service-sdk@1.9.0/node_modules/@pythnetwork/price-service-sdk/dist/cjs/schemas/PriceFeed.cjs"(exports) {
3151
+ "use strict";
3152
+ Object.defineProperty(exports, "__esModule", {
3153
+ value: true
3154
+ });
3155
+ Object.defineProperty(exports, "Convert", {
3156
+ enumerable: true,
3157
+ get: function() {
3158
+ return Convert;
3159
+ }
3160
+ });
3161
+ var Convert = class {
3162
+ static toPriceFeed(json) {
3163
+ return cast(json, r("PriceFeed"));
3164
+ }
3165
+ static priceFeedToJson(value) {
3166
+ return uncast(value, r("PriceFeed"));
3167
+ }
3168
+ static toPrice(json) {
3169
+ return cast(json, r("Price"));
3170
+ }
3171
+ static priceToJson(value) {
3172
+ return uncast(value, r("Price"));
3173
+ }
3174
+ static toPriceFeedMetadata(json) {
3175
+ return cast(json, r("PriceFeedMetadata"));
3176
+ }
3177
+ static priceFeedMetadataToJson(value) {
3178
+ return uncast(value, r("PriceFeedMetadata"));
3179
+ }
3180
+ };
3181
+ function invalidValue(typ, val, key = "") {
3182
+ if (key) {
3183
+ throw new Error(`Invalid value for key "${key}". Expected type ${JSON.stringify(typ)} but got ${JSON.stringify(val)}`);
3184
+ }
3185
+ throw new Error(`Invalid value ${JSON.stringify(val)} for type ${JSON.stringify(typ)}`);
3186
+ }
3187
+ function jsonToJSProps(typ) {
3188
+ if (typ.jsonToJS === void 0) {
3189
+ const map2 = {};
3190
+ typ.props.forEach((p) => map2[p.json] = {
3191
+ key: p.js,
3192
+ typ: p.typ
3193
+ });
3194
+ typ.jsonToJS = map2;
3195
+ }
3196
+ return typ.jsonToJS;
3197
+ }
3198
+ function jsToJSONProps(typ) {
3199
+ if (typ.jsToJSON === void 0) {
3200
+ const map2 = {};
3201
+ typ.props.forEach((p) => map2[p.js] = {
3202
+ key: p.json,
3203
+ typ: p.typ
3204
+ });
3205
+ typ.jsToJSON = map2;
3206
+ }
3207
+ return typ.jsToJSON;
3208
+ }
3209
+ function transform(val, typ, getProps, key = "") {
3210
+ function transformPrimitive(typ2, val2) {
3211
+ if (typeof typ2 === typeof val2) return val2;
3212
+ return invalidValue(typ2, val2, key);
3213
+ }
3214
+ function transformUnion(typs, val2) {
3215
+ const l = typs.length;
3216
+ for (let i = 0; i < l; i++) {
3217
+ const typ2 = typs[i];
3218
+ try {
3219
+ return transform(val2, typ2, getProps);
3220
+ } catch {
3221
+ }
3222
+ }
3223
+ return invalidValue(typs, val2);
3224
+ }
3225
+ function transformEnum(cases, val2) {
3226
+ if (cases.includes(val2)) return val2;
3227
+ return invalidValue(cases, val2);
3228
+ }
3229
+ function transformArray(typ2, val2) {
3230
+ if (!Array.isArray(val2)) return invalidValue("array", val2);
3231
+ return val2.map((el) => transform(el, typ2, getProps));
3232
+ }
3233
+ function transformDate(val2) {
3234
+ if (val2 === null) {
3235
+ return null;
3236
+ }
3237
+ const d = new Date(val2);
3238
+ if (isNaN(d.valueOf())) {
3239
+ return invalidValue("Date", val2);
3281
3240
  }
3282
- var res = wnd[0];
3283
- var current = 0;
3284
- var currentLen = 0;
3285
- var start = num.bitLength() % 26;
3286
- if (start === 0) {
3287
- start = 26;
3241
+ return d;
3242
+ }
3243
+ function transformObject(props, additional, val2) {
3244
+ if (val2 === null || typeof val2 !== "object" || Array.isArray(val2)) {
3245
+ return invalidValue("object", val2);
3288
3246
  }
3289
- for (i = num.length - 1; i >= 0; i--) {
3290
- var word = num.words[i];
3291
- for (var j = start - 1; j >= 0; j--) {
3292
- var bit = word >> j & 1;
3293
- if (res !== wnd[0]) {
3294
- res = this.sqr(res);
3295
- }
3296
- if (bit === 0 && current === 0) {
3297
- currentLen = 0;
3298
- continue;
3299
- }
3300
- current <<= 1;
3301
- current |= bit;
3302
- currentLen++;
3303
- if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
3304
- res = this.mul(res, wnd[current]);
3305
- currentLen = 0;
3306
- current = 0;
3307
- }
3308
- start = 26;
3247
+ const result = {};
3248
+ for (const key2 of Object.getOwnPropertyNames(props)) {
3249
+ const prop = props[key2];
3250
+ const v = Object.prototype.hasOwnProperty.call(val2, key2) ? val2[key2] : void 0;
3251
+ result[prop.key] = transform(v, prop.typ, getProps, prop.key);
3309
3252
  }
3310
- return res;
3311
- };
3312
- Red.prototype.convertTo = function convertTo(num) {
3313
- var r = num.umod(this.m);
3314
- return r === num ? r.clone() : r;
3315
- };
3316
- Red.prototype.convertFrom = function convertFrom(num) {
3317
- var res = num.clone();
3318
- res.red = null;
3319
- return res;
3320
- };
3321
- BN.mont = function mont(num) {
3322
- return new Mont(num);
3323
- };
3324
- function Mont(m) {
3325
- Red.call(this, m);
3326
- this.shift = this.m.bitLength();
3327
- if (this.shift % 26 !== 0) {
3328
- this.shift += 26 - this.shift % 26;
3253
+ for (const key2 of Object.getOwnPropertyNames(val2)) {
3254
+ if (!Object.prototype.hasOwnProperty.call(props, key2)) {
3255
+ result[key2] = transform(val2[key2], additional, getProps, key2);
3256
+ }
3329
3257
  }
3330
- this.r = new BN(1).iushln(this.shift);
3331
- this.r2 = this.imod(this.r.sqr());
3332
- this.rinv = this.r._invmp(this.m);
3333
- this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
3334
- this.minv = this.minv.umod(this.r);
3335
- this.minv = this.r.sub(this.minv);
3258
+ return result;
3336
3259
  }
3337
- inherits(Mont, Red);
3338
- Mont.prototype.convertTo = function convertTo(num) {
3339
- return this.imod(num.ushln(this.shift));
3260
+ if (typ === "any") return val;
3261
+ if (typ === null) {
3262
+ if (val === null) return val;
3263
+ return invalidValue(typ, val);
3264
+ }
3265
+ if (typ === false) return invalidValue(typ, val);
3266
+ while (typeof typ === "object" && typ.ref !== void 0) {
3267
+ typ = typeMap[typ.ref];
3268
+ }
3269
+ if (Array.isArray(typ)) return transformEnum(typ, val);
3270
+ if (typeof typ === "object") {
3271
+ return typ.hasOwnProperty("unionMembers") ? transformUnion(typ.unionMembers, val) : typ.hasOwnProperty("arrayItems") ? transformArray(typ.arrayItems, val) : typ.hasOwnProperty("props") ? transformObject(getProps(typ), typ.additional, val) : invalidValue(typ, val);
3272
+ }
3273
+ if (typ === Date && typeof val !== "number") return transformDate(val);
3274
+ return transformPrimitive(typ, val);
3275
+ }
3276
+ function cast(val, typ) {
3277
+ return transform(val, typ, jsonToJSProps);
3278
+ }
3279
+ function uncast(val, typ) {
3280
+ return transform(val, typ, jsToJSONProps);
3281
+ }
3282
+ function u(...typs) {
3283
+ return {
3284
+ unionMembers: typs
3340
3285
  };
3341
- Mont.prototype.convertFrom = function convertFrom(num) {
3342
- var r = this.imod(num.mul(this.rinv));
3343
- r.red = null;
3344
- return r;
3286
+ }
3287
+ function o(props, additional) {
3288
+ return {
3289
+ props,
3290
+ additional
3345
3291
  };
3346
- Mont.prototype.imul = function imul(a, b2) {
3347
- if (a.isZero() || b2.isZero()) {
3348
- a.words[0] = 0;
3349
- a.length = 1;
3350
- return a;
3292
+ }
3293
+ function r(name) {
3294
+ return {
3295
+ ref: name
3296
+ };
3297
+ }
3298
+ var typeMap = {
3299
+ PriceFeed: o([
3300
+ {
3301
+ json: "ema_price",
3302
+ js: "ema_price",
3303
+ typ: r("Price")
3304
+ },
3305
+ {
3306
+ json: "id",
3307
+ js: "id",
3308
+ typ: ""
3309
+ },
3310
+ {
3311
+ json: "metadata",
3312
+ js: "metadata",
3313
+ typ: u(void 0, r("PriceFeedMetadata"))
3314
+ },
3315
+ {
3316
+ json: "price",
3317
+ js: "price",
3318
+ typ: r("Price")
3319
+ },
3320
+ {
3321
+ json: "vaa",
3322
+ js: "vaa",
3323
+ typ: u(void 0, "")
3351
3324
  }
3352
- var t = a.imul(b2);
3353
- var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
3354
- var u = t.isub(c).iushrn(this.shift);
3355
- var res = u;
3356
- if (u.cmp(this.m) >= 0) {
3357
- res = u.isub(this.m);
3358
- } else if (u.cmpn(0) < 0) {
3359
- res = u.iadd(this.m);
3325
+ ], "any"),
3326
+ Price: o([
3327
+ {
3328
+ json: "conf",
3329
+ js: "conf",
3330
+ typ: ""
3331
+ },
3332
+ {
3333
+ json: "expo",
3334
+ js: "expo",
3335
+ typ: 0
3336
+ },
3337
+ {
3338
+ json: "price",
3339
+ js: "price",
3340
+ typ: ""
3341
+ },
3342
+ {
3343
+ json: "publish_time",
3344
+ js: "publish_time",
3345
+ typ: 0
3360
3346
  }
3361
- return res._forceRed(this);
3362
- };
3363
- Mont.prototype.mul = function mul(a, b2) {
3364
- if (a.isZero() || b2.isZero()) return new BN(0)._forceRed(this);
3365
- var t = a.mul(b2);
3366
- var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
3367
- var u = t.isub(c).iushrn(this.shift);
3368
- var res = u;
3369
- if (u.cmp(this.m) >= 0) {
3370
- res = u.isub(this.m);
3371
- } else if (u.cmpn(0) < 0) {
3372
- res = u.iadd(this.m);
3347
+ ], "any"),
3348
+ PriceFeedMetadata: o([
3349
+ {
3350
+ json: "attestation_time",
3351
+ js: "attestation_time",
3352
+ typ: u(void 0, 0)
3353
+ },
3354
+ {
3355
+ json: "emitter_chain",
3356
+ js: "emitter_chain",
3357
+ typ: 0
3358
+ },
3359
+ {
3360
+ json: "prev_publish_time",
3361
+ js: "prev_publish_time",
3362
+ typ: u(void 0, 0)
3363
+ },
3364
+ {
3365
+ json: "price_service_receive_time",
3366
+ js: "price_service_receive_time",
3367
+ typ: u(void 0, 0)
3368
+ },
3369
+ {
3370
+ json: "sequence_number",
3371
+ js: "sequence_number",
3372
+ typ: u(void 0, 0)
3373
+ },
3374
+ {
3375
+ json: "slot",
3376
+ js: "slot",
3377
+ typ: u(void 0, 0)
3373
3378
  }
3374
- return res._forceRed(this);
3375
- };
3376
- Mont.prototype.invm = function invm(a) {
3377
- var res = this.imod(a._invmp(this.m).mul(this.r2));
3378
- return res._forceRed(this);
3379
- };
3380
- })(typeof module === "undefined" || module, exports);
3379
+ ], "any")
3380
+ };
3381
3381
  }
3382
3382
  });
3383
3383
 
@@ -12798,6 +12798,9 @@ var require_lib2 = __commonJS({
12798
12798
  }
12799
12799
  });
12800
12800
 
12801
+ // ../sdk/dist/index.js
12802
+ var import_bn = __toESM(require_bn(), 1);
12803
+
12801
12804
  // ../../node_modules/.pnpm/eventemitter3@5.0.4/node_modules/eventemitter3/index.mjs
12802
12805
  var import_index = __toESM(require_eventemitter3(), 1);
12803
12806
 
@@ -16710,10 +16713,111 @@ __export(cetus_swap_exports, {
16710
16713
  TOKEN_MAP: () => TOKEN_MAP,
16711
16714
  addSwapToTx: () => addSwapToTx,
16712
16715
  buildSwapTx: () => buildSwapTx,
16716
+ deserializeCetusRoute: () => deserializeCetusRoute,
16713
16717
  findSwapRoute: () => findSwapRoute,
16718
+ isCetusRouteFresh: () => isCetusRouteFresh,
16714
16719
  resolveTokenType: () => resolveTokenType,
16715
- simulateSwap: () => simulateSwap
16720
+ serializeCetusRoute: () => serializeCetusRoute,
16721
+ simulateSwap: () => simulateSwap,
16722
+ verifyCetusRouteCoinMatch: () => verifyCetusRouteCoinMatch
16716
16723
  });
16724
+ function serializeCetusRoute(route, context) {
16725
+ return {
16726
+ routerData: serializeRouterDataV3(route.routerData),
16727
+ amountIn: route.amountIn,
16728
+ amountOut: route.amountOut,
16729
+ byAmountIn: route.byAmountIn,
16730
+ priceImpact: route.priceImpact,
16731
+ insufficientLiquidity: route.insufficientLiquidity,
16732
+ discoveredAt: Date.now(),
16733
+ fromCoinType: context.fromCoinType,
16734
+ toCoinType: context.toCoinType
16735
+ };
16736
+ }
16737
+ function deserializeCetusRoute(serialized) {
16738
+ return {
16739
+ routerData: deserializeRouterDataV3(serialized.routerData),
16740
+ amountIn: serialized.amountIn,
16741
+ amountOut: serialized.amountOut,
16742
+ byAmountIn: serialized.byAmountIn,
16743
+ priceImpact: serialized.priceImpact,
16744
+ insufficientLiquidity: serialized.insufficientLiquidity
16745
+ };
16746
+ }
16747
+ function serializeRouterDataV3(rd) {
16748
+ const out = {
16749
+ amountIn: rd.amountIn.toString(),
16750
+ amountOut: rd.amountOut.toString(),
16751
+ byAmountIn: rd.byAmountIn,
16752
+ paths: rd.paths.map(serializeCetusRoutePath),
16753
+ insufficientLiquidity: rd.insufficientLiquidity,
16754
+ deviationRatio: rd.deviationRatio
16755
+ };
16756
+ if (rd.quoteID !== void 0) out.quoteID = rd.quoteID;
16757
+ if (rd.packages) {
16758
+ const obj = {};
16759
+ for (const [k2, v] of rd.packages) obj[k2] = v;
16760
+ out.packages = obj;
16761
+ }
16762
+ if (rd.totalDeepFee !== void 0) out.totalDeepFee = rd.totalDeepFee;
16763
+ if (rd.error) out.error = { code: rd.error.code, msg: rd.error.msg };
16764
+ if (rd.overlayFee !== void 0) out.overlayFee = rd.overlayFee;
16765
+ return out;
16766
+ }
16767
+ function deserializeRouterDataV3(s) {
16768
+ const out = {
16769
+ amountIn: new import_bn.default(s.amountIn),
16770
+ amountOut: new import_bn.default(s.amountOut),
16771
+ byAmountIn: s.byAmountIn,
16772
+ paths: s.paths.map(deserializeCetusRoutePath),
16773
+ insufficientLiquidity: s.insufficientLiquidity,
16774
+ deviationRatio: s.deviationRatio
16775
+ };
16776
+ if (s.quoteID !== void 0) out.quoteID = s.quoteID;
16777
+ if (s.packages) out.packages = new Map(Object.entries(s.packages));
16778
+ if (s.totalDeepFee !== void 0) out.totalDeepFee = s.totalDeepFee;
16779
+ if (s.error) out.error = { code: s.error.code, msg: s.error.msg };
16780
+ if (s.overlayFee !== void 0) out.overlayFee = s.overlayFee;
16781
+ return out;
16782
+ }
16783
+ function serializeCetusRoutePath(p) {
16784
+ const out = {
16785
+ id: p.id,
16786
+ direction: p.direction,
16787
+ provider: p.provider,
16788
+ from: p.from,
16789
+ target: p.target,
16790
+ feeRate: p.feeRate,
16791
+ amountIn: p.amountIn,
16792
+ amountOut: p.amountOut
16793
+ };
16794
+ if (p.version !== void 0) out.version = p.version;
16795
+ if (p.publishedAt !== void 0) out.publishedAt = p.publishedAt;
16796
+ if (p.extendedDetails) out.extendedDetails = { ...p.extendedDetails };
16797
+ return out;
16798
+ }
16799
+ function deserializeCetusRoutePath(p) {
16800
+ const out = {
16801
+ id: p.id,
16802
+ direction: p.direction,
16803
+ provider: p.provider,
16804
+ from: p.from,
16805
+ target: p.target,
16806
+ feeRate: p.feeRate,
16807
+ amountIn: p.amountIn,
16808
+ amountOut: p.amountOut
16809
+ };
16810
+ if (p.version !== void 0) out.version = p.version;
16811
+ if (p.publishedAt !== void 0) out.publishedAt = p.publishedAt;
16812
+ if (p.extendedDetails) out.extendedDetails = { ...p.extendedDetails };
16813
+ return out;
16814
+ }
16815
+ function verifyCetusRouteCoinMatch(serialized, expected) {
16816
+ return serialized.fromCoinType === expected.fromCoinType && serialized.toCoinType === expected.toCoinType;
16817
+ }
16818
+ function isCetusRouteFresh(serialized, maxAgeMs = 3e4) {
16819
+ return Date.now() - serialized.discoveredAt < maxAgeMs;
16820
+ }
16717
16821
  function getClient(walletAddress, overlayFee) {
16718
16822
  const rate = overlayFee?.rate ?? 0;
16719
16823
  const receiver = overlayFee?.receiver ?? "";
@@ -16803,15 +16907,22 @@ async function addSwapToTx(tx, client, address, input) {
16803
16907
  inputCoin = result.coin;
16804
16908
  effectiveRaw = result.effectiveAmount;
16805
16909
  }
16806
- const route = await findSwapRoute({
16807
- walletAddress: address,
16808
- from: fromType,
16809
- to: toType,
16810
- amount: effectiveRaw,
16811
- byAmountIn,
16812
- overlayFee: input.overlayFee,
16813
- providers: input.providers
16814
- });
16910
+ let route;
16911
+ let usedPrecomputedRoute = false;
16912
+ if (input.precomputedRoute && input.precomputedRoute.amountIn === effectiveRaw.toString() && input.precomputedRoute.byAmountIn === byAmountIn) {
16913
+ route = input.precomputedRoute;
16914
+ usedPrecomputedRoute = true;
16915
+ } else {
16916
+ route = await findSwapRoute({
16917
+ walletAddress: address,
16918
+ from: fromType,
16919
+ to: toType,
16920
+ amount: effectiveRaw,
16921
+ byAmountIn,
16922
+ overlayFee: input.overlayFee,
16923
+ providers: input.providers
16924
+ });
16925
+ }
16815
16926
  if (!route) {
16816
16927
  throw new T2000Error2("SWAP_NO_ROUTE", `No swap route found for ${input.from} \u2192 ${input.to}`);
16817
16928
  }
@@ -16830,7 +16941,8 @@ async function addSwapToTx(tx, client, address, input) {
16830
16941
  coin: outputCoin,
16831
16942
  effectiveAmountIn: Number(effectiveRaw) / 10 ** fromDecimals,
16832
16943
  expectedAmountOut: Number(route.amountOut) / 10 ** toDecimals,
16833
- route
16944
+ route,
16945
+ usedPrecomputedRoute
16834
16946
  };
16835
16947
  }
16836
16948
  async function simulateSwap(params) {
@@ -23561,7 +23673,8 @@ var WRITE_APPENDER_REGISTRY = {
23561
23673
  byAmountIn: input.byAmountIn,
23562
23674
  overlayFee: ctx.overlayFee,
23563
23675
  providers,
23564
- inputCoin: ctx.chainedCoin
23676
+ inputCoin: ctx.chainedCoin,
23677
+ precomputedRoute: input.precomputedRoute
23565
23678
  });
23566
23679
  if (!ctx.isOutputConsumed) {
23567
23680
  tx.transferObjects([result.coin], ctx.sender);
@@ -23944,13 +24057,16 @@ async function getSwapQuote(params) {
23944
24057
  const fromAmount = Number(route.amountIn) / 10 ** fromDecimals;
23945
24058
  const toAmount = Number(route.amountOut) / 10 ** toDecimals;
23946
24059
  const routeDesc = route.routerData.paths?.map((p) => p.provider).filter(Boolean).slice(0, 3).join(" + ") ?? "Cetus Aggregator";
24060
+ const { serializeCetusRoute: serializeCetusRoute2 } = await Promise.resolve().then(() => (init_cetus_swap(), cetus_swap_exports));
24061
+ const serializedRoute = serializeCetusRoute2(route, { fromCoinType: fromType, toCoinType: toType });
23947
24062
  return {
23948
24063
  fromToken: params.from,
23949
24064
  toToken: params.to,
23950
24065
  fromAmount,
23951
24066
  toAmount,
23952
24067
  priceImpact: route.priceImpact,
23953
- route: routeDesc
24068
+ route: routeDesc,
24069
+ serializedRoute
23954
24070
  };
23955
24071
  }
23956
24072
  init_cetus_swap();
@@ -24057,6 +24173,10 @@ export {
24057
24173
  fetchAllCoins,
24058
24174
  selectAndSplitCoin,
24059
24175
  selectSuiCoin,
24176
+ serializeCetusRoute,
24177
+ deserializeCetusRoute,
24178
+ verifyCetusRouteCoinMatch,
24179
+ isCetusRouteFresh,
24060
24180
  findSwapRoute,
24061
24181
  buildSwapTx,
24062
24182
  addSwapToTx,
@@ -24175,4 +24295,4 @@ axios/dist/node/axios.cjs:
24175
24295
  @scure/bip39/index.js:
24176
24296
  (*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
24177
24297
  */
24178
- //# sourceMappingURL=chunk-TTDWK2PS.js.map
24298
+ //# sourceMappingURL=chunk-GGXOFR5Y.js.map