@injectivelabs/wallet-base 1.16.38-alpha.7 → 1.16.39-alpha.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.
@@ -5,9 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJS = (cb, mod) => function() {
9
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
- };
11
8
  var __copyProps = (to, from, except, desc) => {
12
9
  if (from && typeof from === "object" || typeof from === "function") {
13
10
  for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
@@ -29,6 +26,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
29
26
 
30
27
  //#endregion
31
28
  let __injectivelabs_exceptions = require("@injectivelabs/exceptions");
29
+ let __injectivelabs_utils = require("@injectivelabs/utils");
32
30
  let viem_chains = require("viem/chains");
33
31
  viem_chains = __toESM(viem_chains);
34
32
  let __injectivelabs_ts_types = require("@injectivelabs/ts-types");
@@ -96,1543 +94,6 @@ const TurnkeyProvider = {
96
94
  Apple: "apple"
97
95
  };
98
96
 
99
- //#endregion
100
- //#region ../../../node_modules/.pnpm/bignumber.js@9.3.1/node_modules/bignumber.js/bignumber.mjs
101
- var isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, mathceil = Math.ceil, mathfloor = Math.floor, bignumberError = "[BigNumber Error] ", tooManyDigits = bignumberError + "Number primitive has more than 15 significant digits: ", BASE = 0x5af3107a4000, LOG_BASE = 14, MAX_SAFE_INTEGER = 9007199254740991, POWS_TEN = [
102
- 1,
103
- 10,
104
- 100,
105
- 1e3,
106
- 1e4,
107
- 1e5,
108
- 1e6,
109
- 1e7,
110
- 1e8,
111
- 1e9,
112
- 1e10,
113
- 1e11,
114
- 0xe8d4a51000,
115
- 0x9184e72a000
116
- ], SQRT_BASE = 1e7, MAX = 1e9;
117
- function clone(configObject) {
118
- var div, convertBase, parseNumeric, P = BigNumber$1.prototype = {
119
- constructor: BigNumber$1,
120
- toString: null,
121
- valueOf: null
122
- }, ONE = new BigNumber$1(1), DECIMAL_PLACES = 20, ROUNDING_MODE = 4, TO_EXP_NEG = -7, TO_EXP_POS = 21, MIN_EXP = -1e7, MAX_EXP = 1e7, CRYPTO = false, MODULO_MODE = 1, POW_PRECISION = 0, FORMAT = {
123
- prefix: "",
124
- groupSize: 3,
125
- secondaryGroupSize: 0,
126
- groupSeparator: ",",
127
- decimalSeparator: ".",
128
- fractionGroupSize: 0,
129
- fractionGroupSeparator: "\xA0",
130
- suffix: ""
131
- }, ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz", alphabetHasNormalDecimalDigits = true;
132
- function BigNumber$1(v, b) {
133
- var alphabet, c, caseChanged, e, i, isNum, len, str, x = this;
134
- if (!(x instanceof BigNumber$1)) return new BigNumber$1(v, b);
135
- if (b == null) {
136
- if (v && v._isBigNumber === true) {
137
- x.s = v.s;
138
- if (!v.c || v.e > MAX_EXP) x.c = x.e = null;
139
- else if (v.e < MIN_EXP) x.c = [x.e = 0];
140
- else {
141
- x.e = v.e;
142
- x.c = v.c.slice();
143
- }
144
- return;
145
- }
146
- if ((isNum = typeof v == "number") && v * 0 == 0) {
147
- x.s = 1 / v < 0 ? (v = -v, -1) : 1;
148
- if (v === ~~v) {
149
- for (e = 0, i = v; i >= 10; i /= 10, e++);
150
- if (e > MAX_EXP) x.c = x.e = null;
151
- else {
152
- x.e = e;
153
- x.c = [v];
154
- }
155
- return;
156
- }
157
- str = String(v);
158
- } else {
159
- if (!isNumeric.test(str = String(v))) return parseNumeric(x, str, isNum);
160
- x.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1;
161
- }
162
- if ((e = str.indexOf(".")) > -1) str = str.replace(".", "");
163
- if ((i = str.search(/e/i)) > 0) {
164
- if (e < 0) e = i;
165
- e += +str.slice(i + 1);
166
- str = str.substring(0, i);
167
- } else if (e < 0) e = str.length;
168
- } else {
169
- intCheck(b, 2, ALPHABET.length, "Base");
170
- if (b == 10 && alphabetHasNormalDecimalDigits) {
171
- x = new BigNumber$1(v);
172
- return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE);
173
- }
174
- str = String(v);
175
- if (isNum = typeof v == "number") {
176
- if (v * 0 != 0) return parseNumeric(x, str, isNum, b);
177
- x.s = 1 / v < 0 ? (str = str.slice(1), -1) : 1;
178
- if (BigNumber$1.DEBUG && str.replace(/^0\.0*|\./, "").length > 15) throw Error(tooManyDigits + v);
179
- } else x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
180
- alphabet = ALPHABET.slice(0, b);
181
- e = i = 0;
182
- for (len = str.length; i < len; i++) if (alphabet.indexOf(c = str.charAt(i)) < 0) {
183
- if (c == ".") {
184
- if (i > e) {
185
- e = len;
186
- continue;
187
- }
188
- } else if (!caseChanged) {
189
- if (str == str.toUpperCase() && (str = str.toLowerCase()) || str == str.toLowerCase() && (str = str.toUpperCase())) {
190
- caseChanged = true;
191
- i = -1;
192
- e = 0;
193
- continue;
194
- }
195
- }
196
- return parseNumeric(x, String(v), isNum, b);
197
- }
198
- isNum = false;
199
- str = convertBase(str, b, 10, x.s);
200
- if ((e = str.indexOf(".")) > -1) str = str.replace(".", "");
201
- else e = str.length;
202
- }
203
- for (i = 0; str.charCodeAt(i) === 48; i++);
204
- for (len = str.length; str.charCodeAt(--len) === 48;);
205
- if (str = str.slice(i, ++len)) {
206
- len -= i;
207
- if (isNum && BigNumber$1.DEBUG && len > 15 && (v > MAX_SAFE_INTEGER || v !== mathfloor(v))) throw Error(tooManyDigits + x.s * v);
208
- if ((e = e - i - 1) > MAX_EXP) x.c = x.e = null;
209
- else if (e < MIN_EXP) x.c = [x.e = 0];
210
- else {
211
- x.e = e;
212
- x.c = [];
213
- i = (e + 1) % LOG_BASE;
214
- if (e < 0) i += LOG_BASE;
215
- if (i < len) {
216
- if (i) x.c.push(+str.slice(0, i));
217
- for (len -= LOG_BASE; i < len;) x.c.push(+str.slice(i, i += LOG_BASE));
218
- i = LOG_BASE - (str = str.slice(i)).length;
219
- } else i -= len;
220
- for (; i--; str += "0");
221
- x.c.push(+str);
222
- }
223
- } else x.c = [x.e = 0];
224
- }
225
- BigNumber$1.clone = clone;
226
- BigNumber$1.ROUND_UP = 0;
227
- BigNumber$1.ROUND_DOWN = 1;
228
- BigNumber$1.ROUND_CEIL = 2;
229
- BigNumber$1.ROUND_FLOOR = 3;
230
- BigNumber$1.ROUND_HALF_UP = 4;
231
- BigNumber$1.ROUND_HALF_DOWN = 5;
232
- BigNumber$1.ROUND_HALF_EVEN = 6;
233
- BigNumber$1.ROUND_HALF_CEIL = 7;
234
- BigNumber$1.ROUND_HALF_FLOOR = 8;
235
- BigNumber$1.EUCLID = 9;
236
- BigNumber$1.config = BigNumber$1.set = function(obj) {
237
- var p, v;
238
- if (obj != null) if (typeof obj == "object") {
239
- if (obj.hasOwnProperty(p = "DECIMAL_PLACES")) {
240
- v = obj[p];
241
- intCheck(v, 0, MAX, p);
242
- DECIMAL_PLACES = v;
243
- }
244
- if (obj.hasOwnProperty(p = "ROUNDING_MODE")) {
245
- v = obj[p];
246
- intCheck(v, 0, 8, p);
247
- ROUNDING_MODE = v;
248
- }
249
- if (obj.hasOwnProperty(p = "EXPONENTIAL_AT")) {
250
- v = obj[p];
251
- if (v && v.pop) {
252
- intCheck(v[0], -MAX, 0, p);
253
- intCheck(v[1], 0, MAX, p);
254
- TO_EXP_NEG = v[0];
255
- TO_EXP_POS = v[1];
256
- } else {
257
- intCheck(v, -MAX, MAX, p);
258
- TO_EXP_NEG = -(TO_EXP_POS = v < 0 ? -v : v);
259
- }
260
- }
261
- if (obj.hasOwnProperty(p = "RANGE")) {
262
- v = obj[p];
263
- if (v && v.pop) {
264
- intCheck(v[0], -MAX, -1, p);
265
- intCheck(v[1], 1, MAX, p);
266
- MIN_EXP = v[0];
267
- MAX_EXP = v[1];
268
- } else {
269
- intCheck(v, -MAX, MAX, p);
270
- if (v) MIN_EXP = -(MAX_EXP = v < 0 ? -v : v);
271
- else throw Error(bignumberError + p + " cannot be zero: " + v);
272
- }
273
- }
274
- if (obj.hasOwnProperty(p = "CRYPTO")) {
275
- v = obj[p];
276
- if (v === !!v) if (v) if (typeof crypto != "undefined" && crypto && (crypto.getRandomValues || crypto.randomBytes)) CRYPTO = v;
277
- else {
278
- CRYPTO = !v;
279
- throw Error(bignumberError + "crypto unavailable");
280
- }
281
- else CRYPTO = v;
282
- else throw Error(bignumberError + p + " not true or false: " + v);
283
- }
284
- if (obj.hasOwnProperty(p = "MODULO_MODE")) {
285
- v = obj[p];
286
- intCheck(v, 0, 9, p);
287
- MODULO_MODE = v;
288
- }
289
- if (obj.hasOwnProperty(p = "POW_PRECISION")) {
290
- v = obj[p];
291
- intCheck(v, 0, MAX, p);
292
- POW_PRECISION = v;
293
- }
294
- if (obj.hasOwnProperty(p = "FORMAT")) {
295
- v = obj[p];
296
- if (typeof v == "object") FORMAT = v;
297
- else throw Error(bignumberError + p + " not an object: " + v);
298
- }
299
- if (obj.hasOwnProperty(p = "ALPHABET")) {
300
- v = obj[p];
301
- if (typeof v == "string" && !/^.?$|[+\-.\s]|(.).*\1/.test(v)) {
302
- alphabetHasNormalDecimalDigits = v.slice(0, 10) == "0123456789";
303
- ALPHABET = v;
304
- } else throw Error(bignumberError + p + " invalid: " + v);
305
- }
306
- } else throw Error(bignumberError + "Object expected: " + obj);
307
- return {
308
- DECIMAL_PLACES,
309
- ROUNDING_MODE,
310
- EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS],
311
- RANGE: [MIN_EXP, MAX_EXP],
312
- CRYPTO,
313
- MODULO_MODE,
314
- POW_PRECISION,
315
- FORMAT,
316
- ALPHABET
317
- };
318
- };
319
- BigNumber$1.isBigNumber = function(v) {
320
- if (!v || v._isBigNumber !== true) return false;
321
- if (!BigNumber$1.DEBUG) return true;
322
- var i, n, c = v.c, e = v.e, s = v.s;
323
- out: if ({}.toString.call(c) == "[object Array]") {
324
- if ((s === 1 || s === -1) && e >= -MAX && e <= MAX && e === mathfloor(e)) {
325
- if (c[0] === 0) {
326
- if (e === 0 && c.length === 1) return true;
327
- break out;
328
- }
329
- i = (e + 1) % LOG_BASE;
330
- if (i < 1) i += LOG_BASE;
331
- if (String(c[0]).length == i) {
332
- for (i = 0; i < c.length; i++) {
333
- n = c[i];
334
- if (n < 0 || n >= BASE || n !== mathfloor(n)) break out;
335
- }
336
- if (n !== 0) return true;
337
- }
338
- }
339
- } else if (c === null && e === null && (s === null || s === 1 || s === -1)) return true;
340
- throw Error(bignumberError + "Invalid BigNumber: " + v);
341
- };
342
- BigNumber$1.maximum = BigNumber$1.max = function() {
343
- return maxOrMin(arguments, -1);
344
- };
345
- BigNumber$1.minimum = BigNumber$1.min = function() {
346
- return maxOrMin(arguments, 1);
347
- };
348
- BigNumber$1.random = (function() {
349
- var pow2_53 = 9007199254740992;
350
- var random53bitInt = Math.random() * pow2_53 & 2097151 ? function() {
351
- return mathfloor(Math.random() * pow2_53);
352
- } : function() {
353
- return (Math.random() * 1073741824 | 0) * 8388608 + (Math.random() * 8388608 | 0);
354
- };
355
- return function(dp) {
356
- var a, b, e, k, v, i = 0, c = [], rand = new BigNumber$1(ONE);
357
- if (dp == null) dp = DECIMAL_PLACES;
358
- else intCheck(dp, 0, MAX);
359
- k = mathceil(dp / LOG_BASE);
360
- if (CRYPTO) if (crypto.getRandomValues) {
361
- a = crypto.getRandomValues(new Uint32Array(k *= 2));
362
- for (; i < k;) {
363
- v = a[i] * 131072 + (a[i + 1] >>> 11);
364
- if (v >= 9e15) {
365
- b = crypto.getRandomValues(new Uint32Array(2));
366
- a[i] = b[0];
367
- a[i + 1] = b[1];
368
- } else {
369
- c.push(v % 0x5af3107a4000);
370
- i += 2;
371
- }
372
- }
373
- i = k / 2;
374
- } else if (crypto.randomBytes) {
375
- a = crypto.randomBytes(k *= 7);
376
- for (; i < k;) {
377
- v = (a[i] & 31) * 281474976710656 + a[i + 1] * 1099511627776 + a[i + 2] * 4294967296 + a[i + 3] * 16777216 + (a[i + 4] << 16) + (a[i + 5] << 8) + a[i + 6];
378
- if (v >= 9e15) crypto.randomBytes(7).copy(a, i);
379
- else {
380
- c.push(v % 0x5af3107a4000);
381
- i += 7;
382
- }
383
- }
384
- i = k / 7;
385
- } else {
386
- CRYPTO = false;
387
- throw Error(bignumberError + "crypto unavailable");
388
- }
389
- if (!CRYPTO) for (; i < k;) {
390
- v = random53bitInt();
391
- if (v < 9e15) c[i++] = v % 0x5af3107a4000;
392
- }
393
- k = c[--i];
394
- dp %= LOG_BASE;
395
- if (k && dp) {
396
- v = POWS_TEN[LOG_BASE - dp];
397
- c[i] = mathfloor(k / v) * v;
398
- }
399
- for (; c[i] === 0; c.pop(), i--);
400
- if (i < 0) c = [e = 0];
401
- else {
402
- for (e = -1; c[0] === 0; c.splice(0, 1), e -= LOG_BASE);
403
- for (i = 1, v = c[0]; v >= 10; v /= 10, i++);
404
- if (i < LOG_BASE) e -= LOG_BASE - i;
405
- }
406
- rand.e = e;
407
- rand.c = c;
408
- return rand;
409
- };
410
- })();
411
- BigNumber$1.sum = function() {
412
- var i = 1, args = arguments, sum = new BigNumber$1(args[0]);
413
- for (; i < args.length;) sum = sum.plus(args[i++]);
414
- return sum;
415
- };
416
- convertBase = (function() {
417
- var decimal = "0123456789";
418
- function toBaseOut(str, baseIn, baseOut, alphabet) {
419
- var j, arr = [0], arrL, i = 0, len = str.length;
420
- for (; i < len;) {
421
- for (arrL = arr.length; arrL--; arr[arrL] *= baseIn);
422
- arr[0] += alphabet.indexOf(str.charAt(i++));
423
- for (j = 0; j < arr.length; j++) if (arr[j] > baseOut - 1) {
424
- if (arr[j + 1] == null) arr[j + 1] = 0;
425
- arr[j + 1] += arr[j] / baseOut | 0;
426
- arr[j] %= baseOut;
427
- }
428
- }
429
- return arr.reverse();
430
- }
431
- return function(str, baseIn, baseOut, sign, callerIsToString) {
432
- var alphabet, d, e, k, r, x, xc, y, i = str.indexOf("."), dp = DECIMAL_PLACES, rm = ROUNDING_MODE;
433
- if (i >= 0) {
434
- k = POW_PRECISION;
435
- POW_PRECISION = 0;
436
- str = str.replace(".", "");
437
- y = new BigNumber$1(baseIn);
438
- x = y.pow(str.length - i);
439
- POW_PRECISION = k;
440
- y.c = toBaseOut(toFixedPoint(coeffToString(x.c), x.e, "0"), 10, baseOut, decimal);
441
- y.e = y.c.length;
442
- }
443
- xc = toBaseOut(str, baseIn, baseOut, callerIsToString ? (alphabet = ALPHABET, decimal) : (alphabet = decimal, ALPHABET));
444
- e = k = xc.length;
445
- for (; xc[--k] == 0; xc.pop());
446
- if (!xc[0]) return alphabet.charAt(0);
447
- if (i < 0) --e;
448
- else {
449
- x.c = xc;
450
- x.e = e;
451
- x.s = sign;
452
- x = div(x, y, dp, rm, baseOut);
453
- xc = x.c;
454
- r = x.r;
455
- e = x.e;
456
- }
457
- d = e + dp + 1;
458
- i = xc[d];
459
- k = baseOut / 2;
460
- r = r || d < 0 || xc[d + 1] != null;
461
- r = rm < 4 ? (i != null || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : i > k || i == k && (rm == 4 || r || rm == 6 && xc[d - 1] & 1 || rm == (x.s < 0 ? 8 : 7));
462
- if (d < 1 || !xc[0]) str = r ? toFixedPoint(alphabet.charAt(1), -dp, alphabet.charAt(0)) : alphabet.charAt(0);
463
- else {
464
- xc.length = d;
465
- if (r) for (--baseOut; ++xc[--d] > baseOut;) {
466
- xc[d] = 0;
467
- if (!d) {
468
- ++e;
469
- xc = [1].concat(xc);
470
- }
471
- }
472
- for (k = xc.length; !xc[--k];);
473
- for (i = 0, str = ""; i <= k; str += alphabet.charAt(xc[i++]));
474
- str = toFixedPoint(str, e, alphabet.charAt(0));
475
- }
476
- return str;
477
- };
478
- })();
479
- div = (function() {
480
- function multiply(x, k, base) {
481
- var m, temp, xlo, xhi, carry = 0, i = x.length, klo = k % SQRT_BASE, khi = k / SQRT_BASE | 0;
482
- for (x = x.slice(); i--;) {
483
- xlo = x[i] % SQRT_BASE;
484
- xhi = x[i] / SQRT_BASE | 0;
485
- m = khi * xlo + xhi * klo;
486
- temp = klo * xlo + m % SQRT_BASE * SQRT_BASE + carry;
487
- carry = (temp / base | 0) + (m / SQRT_BASE | 0) + khi * xhi;
488
- x[i] = temp % base;
489
- }
490
- if (carry) x = [carry].concat(x);
491
- return x;
492
- }
493
- function compare$1(a, b, aL, bL) {
494
- var i, cmp;
495
- if (aL != bL) cmp = aL > bL ? 1 : -1;
496
- else for (i = cmp = 0; i < aL; i++) if (a[i] != b[i]) {
497
- cmp = a[i] > b[i] ? 1 : -1;
498
- break;
499
- }
500
- return cmp;
501
- }
502
- function subtract(a, b, aL, base) {
503
- var i = 0;
504
- for (; aL--;) {
505
- a[aL] -= i;
506
- i = a[aL] < b[aL] ? 1 : 0;
507
- a[aL] = i * base + a[aL] - b[aL];
508
- }
509
- for (; !a[0] && a.length > 1; a.splice(0, 1));
510
- }
511
- return function(x, y, dp, rm, base) {
512
- var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0, yL, yz, s = x.s == y.s ? 1 : -1, xc = x.c, yc = y.c;
513
- if (!xc || !xc[0] || !yc || !yc[0]) return new BigNumber$1(!x.s || !y.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN : xc && xc[0] == 0 || !yc ? s * 0 : s / 0);
514
- q = new BigNumber$1(s);
515
- qc = q.c = [];
516
- e = x.e - y.e;
517
- s = dp + e + 1;
518
- if (!base) {
519
- base = BASE;
520
- e = bitFloor(x.e / LOG_BASE) - bitFloor(y.e / LOG_BASE);
521
- s = s / LOG_BASE | 0;
522
- }
523
- for (i = 0; yc[i] == (xc[i] || 0); i++);
524
- if (yc[i] > (xc[i] || 0)) e--;
525
- if (s < 0) {
526
- qc.push(1);
527
- more = true;
528
- } else {
529
- xL = xc.length;
530
- yL = yc.length;
531
- i = 0;
532
- s += 2;
533
- n = mathfloor(base / (yc[0] + 1));
534
- if (n > 1) {
535
- yc = multiply(yc, n, base);
536
- xc = multiply(xc, n, base);
537
- yL = yc.length;
538
- xL = xc.length;
539
- }
540
- xi = yL;
541
- rem = xc.slice(0, yL);
542
- remL = rem.length;
543
- for (; remL < yL; rem[remL++] = 0);
544
- yz = yc.slice();
545
- yz = [0].concat(yz);
546
- yc0 = yc[0];
547
- if (yc[1] >= base / 2) yc0++;
548
- do {
549
- n = 0;
550
- cmp = compare$1(yc, rem, yL, remL);
551
- if (cmp < 0) {
552
- rem0 = rem[0];
553
- if (yL != remL) rem0 = rem0 * base + (rem[1] || 0);
554
- n = mathfloor(rem0 / yc0);
555
- if (n > 1) {
556
- if (n >= base) n = base - 1;
557
- prod = multiply(yc, n, base);
558
- prodL = prod.length;
559
- remL = rem.length;
560
- while (compare$1(prod, rem, prodL, remL) == 1) {
561
- n--;
562
- subtract(prod, yL < prodL ? yz : yc, prodL, base);
563
- prodL = prod.length;
564
- cmp = 1;
565
- }
566
- } else {
567
- if (n == 0) cmp = n = 1;
568
- prod = yc.slice();
569
- prodL = prod.length;
570
- }
571
- if (prodL < remL) prod = [0].concat(prod);
572
- subtract(rem, prod, remL, base);
573
- remL = rem.length;
574
- if (cmp == -1) while (compare$1(yc, rem, yL, remL) < 1) {
575
- n++;
576
- subtract(rem, yL < remL ? yz : yc, remL, base);
577
- remL = rem.length;
578
- }
579
- } else if (cmp === 0) {
580
- n++;
581
- rem = [0];
582
- }
583
- qc[i++] = n;
584
- if (rem[0]) rem[remL++] = xc[xi] || 0;
585
- else {
586
- rem = [xc[xi]];
587
- remL = 1;
588
- }
589
- } while ((xi++ < xL || rem[0] != null) && s--);
590
- more = rem[0] != null;
591
- if (!qc[0]) qc.splice(0, 1);
592
- }
593
- if (base == BASE) {
594
- for (i = 1, s = qc[0]; s >= 10; s /= 10, i++);
595
- round(q, dp + (q.e = i + e * LOG_BASE - 1) + 1, rm, more);
596
- } else {
597
- q.e = e;
598
- q.r = +more;
599
- }
600
- return q;
601
- };
602
- })();
603
- function format(n, i, rm, id) {
604
- var c0, e, ne, len, str;
605
- if (rm == null) rm = ROUNDING_MODE;
606
- else intCheck(rm, 0, 8);
607
- if (!n.c) return n.toString();
608
- c0 = n.c[0];
609
- ne = n.e;
610
- if (i == null) {
611
- str = coeffToString(n.c);
612
- str = id == 1 || id == 2 && (ne <= TO_EXP_NEG || ne >= TO_EXP_POS) ? toExponential(str, ne) : toFixedPoint(str, ne, "0");
613
- } else {
614
- n = round(new BigNumber$1(n), i, rm);
615
- e = n.e;
616
- str = coeffToString(n.c);
617
- len = str.length;
618
- if (id == 1 || id == 2 && (i <= e || e <= TO_EXP_NEG)) {
619
- for (; len < i; str += "0", len++);
620
- str = toExponential(str, e);
621
- } else {
622
- i -= ne + (id === 2 && e > ne);
623
- str = toFixedPoint(str, e, "0");
624
- if (e + 1 > len) {
625
- if (--i > 0) for (str += "."; i--; str += "0");
626
- } else {
627
- i += e - len;
628
- if (i > 0) {
629
- if (e + 1 == len) str += ".";
630
- for (; i--; str += "0");
631
- }
632
- }
633
- }
634
- }
635
- return n.s < 0 && c0 ? "-" + str : str;
636
- }
637
- function maxOrMin(args, n) {
638
- var k, y, i = 1, x = new BigNumber$1(args[0]);
639
- for (; i < args.length; i++) {
640
- y = new BigNumber$1(args[i]);
641
- if (!y.s || (k = compare(x, y)) === n || k === 0 && x.s === n) x = y;
642
- }
643
- return x;
644
- }
645
- function normalise(n, c, e) {
646
- var i = 1, j = c.length;
647
- for (; !c[--j]; c.pop());
648
- for (j = c[0]; j >= 10; j /= 10, i++);
649
- if ((e = i + e * LOG_BASE - 1) > MAX_EXP) n.c = n.e = null;
650
- else if (e < MIN_EXP) n.c = [n.e = 0];
651
- else {
652
- n.e = e;
653
- n.c = c;
654
- }
655
- return n;
656
- }
657
- parseNumeric = (function() {
658
- var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i, dotAfter = /^([^.]+)\.$/, dotBefore = /^\.([^.]+)$/, isInfinityOrNaN = /^-?(Infinity|NaN)$/, whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
659
- return function(x, str, isNum, b) {
660
- var base, s = isNum ? str : str.replace(whitespaceOrPlus, "");
661
- if (isInfinityOrNaN.test(s)) x.s = isNaN(s) ? null : s < 0 ? -1 : 1;
662
- else {
663
- if (!isNum) {
664
- s = s.replace(basePrefix, function(m, p1, p2) {
665
- base = (p2 = p2.toLowerCase()) == "x" ? 16 : p2 == "b" ? 2 : 8;
666
- return !b || b == base ? p1 : m;
667
- });
668
- if (b) {
669
- base = b;
670
- s = s.replace(dotAfter, "$1").replace(dotBefore, "0.$1");
671
- }
672
- if (str != s) return new BigNumber$1(s, base);
673
- }
674
- if (BigNumber$1.DEBUG) throw Error(bignumberError + "Not a" + (b ? " base " + b : "") + " number: " + str);
675
- x.s = null;
676
- }
677
- x.c = x.e = null;
678
- };
679
- })();
680
- function round(x, sd, rm, r) {
681
- var d, i, j, k, n, ni, rd, xc = x.c, pows10 = POWS_TEN;
682
- if (xc) {
683
- out: {
684
- for (d = 1, k = xc[0]; k >= 10; k /= 10, d++);
685
- i = sd - d;
686
- if (i < 0) {
687
- i += LOG_BASE;
688
- j = sd;
689
- n = xc[ni = 0];
690
- rd = mathfloor(n / pows10[d - j - 1] % 10);
691
- } else {
692
- ni = mathceil((i + 1) / LOG_BASE);
693
- if (ni >= xc.length) if (r) {
694
- for (; xc.length <= ni; xc.push(0));
695
- n = rd = 0;
696
- d = 1;
697
- i %= LOG_BASE;
698
- j = i - LOG_BASE + 1;
699
- } else break out;
700
- else {
701
- n = k = xc[ni];
702
- for (d = 1; k >= 10; k /= 10, d++);
703
- i %= LOG_BASE;
704
- j = i - LOG_BASE + d;
705
- rd = j < 0 ? 0 : mathfloor(n / pows10[d - j - 1] % 10);
706
- }
707
- }
708
- r = r || sd < 0 || xc[ni + 1] != null || (j < 0 ? n : n % pows10[d - j - 1]);
709
- r = rm < 4 ? (rd || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : rd > 5 || rd == 5 && (rm == 4 || r || rm == 6 && (i > 0 ? j > 0 ? n / pows10[d - j] : 0 : xc[ni - 1]) % 10 & 1 || rm == (x.s < 0 ? 8 : 7));
710
- if (sd < 1 || !xc[0]) {
711
- xc.length = 0;
712
- if (r) {
713
- sd -= x.e + 1;
714
- xc[0] = pows10[(LOG_BASE - sd % LOG_BASE) % LOG_BASE];
715
- x.e = -sd || 0;
716
- } else xc[0] = x.e = 0;
717
- return x;
718
- }
719
- if (i == 0) {
720
- xc.length = ni;
721
- k = 1;
722
- ni--;
723
- } else {
724
- xc.length = ni + 1;
725
- k = pows10[LOG_BASE - i];
726
- xc[ni] = j > 0 ? mathfloor(n / pows10[d - j] % pows10[j]) * k : 0;
727
- }
728
- if (r) for (;;) if (ni == 0) {
729
- for (i = 1, j = xc[0]; j >= 10; j /= 10, i++);
730
- j = xc[0] += k;
731
- for (k = 1; j >= 10; j /= 10, k++);
732
- if (i != k) {
733
- x.e++;
734
- if (xc[0] == BASE) xc[0] = 1;
735
- }
736
- break;
737
- } else {
738
- xc[ni] += k;
739
- if (xc[ni] != BASE) break;
740
- xc[ni--] = 0;
741
- k = 1;
742
- }
743
- for (i = xc.length; xc[--i] === 0; xc.pop());
744
- }
745
- if (x.e > MAX_EXP) x.c = x.e = null;
746
- else if (x.e < MIN_EXP) x.c = [x.e = 0];
747
- }
748
- return x;
749
- }
750
- function valueOf(n) {
751
- var str, e = n.e;
752
- if (e === null) return n.toString();
753
- str = coeffToString(n.c);
754
- str = e <= TO_EXP_NEG || e >= TO_EXP_POS ? toExponential(str, e) : toFixedPoint(str, e, "0");
755
- return n.s < 0 ? "-" + str : str;
756
- }
757
- P.absoluteValue = P.abs = function() {
758
- var x = new BigNumber$1(this);
759
- if (x.s < 0) x.s = 1;
760
- return x;
761
- };
762
- P.comparedTo = function(y, b) {
763
- return compare(this, new BigNumber$1(y, b));
764
- };
765
- P.decimalPlaces = P.dp = function(dp, rm) {
766
- var c, n, v, x = this;
767
- if (dp != null) {
768
- intCheck(dp, 0, MAX);
769
- if (rm == null) rm = ROUNDING_MODE;
770
- else intCheck(rm, 0, 8);
771
- return round(new BigNumber$1(x), dp + x.e + 1, rm);
772
- }
773
- if (!(c = x.c)) return null;
774
- n = ((v = c.length - 1) - bitFloor(this.e / LOG_BASE)) * LOG_BASE;
775
- if (v = c[v]) for (; v % 10 == 0; v /= 10, n--);
776
- if (n < 0) n = 0;
777
- return n;
778
- };
779
- P.dividedBy = P.div = function(y, b) {
780
- return div(this, new BigNumber$1(y, b), DECIMAL_PLACES, ROUNDING_MODE);
781
- };
782
- P.dividedToIntegerBy = P.idiv = function(y, b) {
783
- return div(this, new BigNumber$1(y, b), 0, 1);
784
- };
785
- P.exponentiatedBy = P.pow = function(n, m) {
786
- var half, isModExp, i, k, more, nIsBig, nIsNeg, nIsOdd, y, x = this;
787
- n = new BigNumber$1(n);
788
- if (n.c && !n.isInteger()) throw Error(bignumberError + "Exponent not an integer: " + valueOf(n));
789
- if (m != null) m = new BigNumber$1(m);
790
- nIsBig = n.e > 14;
791
- if (!x.c || !x.c[0] || x.c[0] == 1 && !x.e && x.c.length == 1 || !n.c || !n.c[0]) {
792
- y = new BigNumber$1(Math.pow(+valueOf(x), nIsBig ? n.s * (2 - isOdd(n)) : +valueOf(n)));
793
- return m ? y.mod(m) : y;
794
- }
795
- nIsNeg = n.s < 0;
796
- if (m) {
797
- if (m.c ? !m.c[0] : !m.s) return new BigNumber$1(NaN);
798
- isModExp = !nIsNeg && x.isInteger() && m.isInteger();
799
- if (isModExp) x = x.mod(m);
800
- } else if (n.e > 9 && (x.e > 0 || x.e < -1 || (x.e == 0 ? x.c[0] > 1 || nIsBig && x.c[1] >= 24e7 : x.c[0] < 8e13 || nIsBig && x.c[0] <= 9999975e7))) {
801
- k = x.s < 0 && isOdd(n) ? -0 : 0;
802
- if (x.e > -1) k = 1 / k;
803
- return new BigNumber$1(nIsNeg ? 1 / k : k);
804
- } else if (POW_PRECISION) k = mathceil(POW_PRECISION / LOG_BASE + 2);
805
- if (nIsBig) {
806
- half = new BigNumber$1(.5);
807
- if (nIsNeg) n.s = 1;
808
- nIsOdd = isOdd(n);
809
- } else {
810
- i = Math.abs(+valueOf(n));
811
- nIsOdd = i % 2;
812
- }
813
- y = new BigNumber$1(ONE);
814
- for (;;) {
815
- if (nIsOdd) {
816
- y = y.times(x);
817
- if (!y.c) break;
818
- if (k) {
819
- if (y.c.length > k) y.c.length = k;
820
- } else if (isModExp) y = y.mod(m);
821
- }
822
- if (i) {
823
- i = mathfloor(i / 2);
824
- if (i === 0) break;
825
- nIsOdd = i % 2;
826
- } else {
827
- n = n.times(half);
828
- round(n, n.e + 1, 1);
829
- if (n.e > 14) nIsOdd = isOdd(n);
830
- else {
831
- i = +valueOf(n);
832
- if (i === 0) break;
833
- nIsOdd = i % 2;
834
- }
835
- }
836
- x = x.times(x);
837
- if (k) {
838
- if (x.c && x.c.length > k) x.c.length = k;
839
- } else if (isModExp) x = x.mod(m);
840
- }
841
- if (isModExp) return y;
842
- if (nIsNeg) y = ONE.div(y);
843
- return m ? y.mod(m) : k ? round(y, POW_PRECISION, ROUNDING_MODE, more) : y;
844
- };
845
- P.integerValue = function(rm) {
846
- var n = new BigNumber$1(this);
847
- if (rm == null) rm = ROUNDING_MODE;
848
- else intCheck(rm, 0, 8);
849
- return round(n, n.e + 1, rm);
850
- };
851
- P.isEqualTo = P.eq = function(y, b) {
852
- return compare(this, new BigNumber$1(y, b)) === 0;
853
- };
854
- P.isFinite = function() {
855
- return !!this.c;
856
- };
857
- P.isGreaterThan = P.gt = function(y, b) {
858
- return compare(this, new BigNumber$1(y, b)) > 0;
859
- };
860
- P.isGreaterThanOrEqualTo = P.gte = function(y, b) {
861
- return (b = compare(this, new BigNumber$1(y, b))) === 1 || b === 0;
862
- };
863
- P.isInteger = function() {
864
- return !!this.c && bitFloor(this.e / LOG_BASE) > this.c.length - 2;
865
- };
866
- P.isLessThan = P.lt = function(y, b) {
867
- return compare(this, new BigNumber$1(y, b)) < 0;
868
- };
869
- P.isLessThanOrEqualTo = P.lte = function(y, b) {
870
- return (b = compare(this, new BigNumber$1(y, b))) === -1 || b === 0;
871
- };
872
- P.isNaN = function() {
873
- return !this.s;
874
- };
875
- P.isNegative = function() {
876
- return this.s < 0;
877
- };
878
- P.isPositive = function() {
879
- return this.s > 0;
880
- };
881
- P.isZero = function() {
882
- return !!this.c && this.c[0] == 0;
883
- };
884
- P.minus = function(y, b) {
885
- var i, j, t, xLTy, x = this, a = x.s;
886
- y = new BigNumber$1(y, b);
887
- b = y.s;
888
- if (!a || !b) return new BigNumber$1(NaN);
889
- if (a != b) {
890
- y.s = -b;
891
- return x.plus(y);
892
- }
893
- var xe = x.e / LOG_BASE, ye = y.e / LOG_BASE, xc = x.c, yc = y.c;
894
- if (!xe || !ye) {
895
- if (!xc || !yc) return xc ? (y.s = -b, y) : new BigNumber$1(yc ? x : NaN);
896
- if (!xc[0] || !yc[0]) return yc[0] ? (y.s = -b, y) : new BigNumber$1(xc[0] ? x : ROUNDING_MODE == 3 ? -0 : 0);
897
- }
898
- xe = bitFloor(xe);
899
- ye = bitFloor(ye);
900
- xc = xc.slice();
901
- if (a = xe - ye) {
902
- if (xLTy = a < 0) {
903
- a = -a;
904
- t = xc;
905
- } else {
906
- ye = xe;
907
- t = yc;
908
- }
909
- t.reverse();
910
- for (b = a; b--; t.push(0));
911
- t.reverse();
912
- } else {
913
- j = (xLTy = (a = xc.length) < (b = yc.length)) ? a : b;
914
- for (a = b = 0; b < j; b++) if (xc[b] != yc[b]) {
915
- xLTy = xc[b] < yc[b];
916
- break;
917
- }
918
- }
919
- if (xLTy) {
920
- t = xc;
921
- xc = yc;
922
- yc = t;
923
- y.s = -y.s;
924
- }
925
- b = (j = yc.length) - (i = xc.length);
926
- if (b > 0) for (; b--; xc[i++] = 0);
927
- b = BASE - 1;
928
- for (; j > a;) {
929
- if (xc[--j] < yc[j]) {
930
- for (i = j; i && !xc[--i]; xc[i] = b);
931
- --xc[i];
932
- xc[j] += BASE;
933
- }
934
- xc[j] -= yc[j];
935
- }
936
- for (; xc[0] == 0; xc.splice(0, 1), --ye);
937
- if (!xc[0]) {
938
- y.s = ROUNDING_MODE == 3 ? -1 : 1;
939
- y.c = [y.e = 0];
940
- return y;
941
- }
942
- return normalise(y, xc, ye);
943
- };
944
- P.modulo = P.mod = function(y, b) {
945
- var q, s, x = this;
946
- y = new BigNumber$1(y, b);
947
- if (!x.c || !y.s || y.c && !y.c[0]) return new BigNumber$1(NaN);
948
- else if (!y.c || x.c && !x.c[0]) return new BigNumber$1(x);
949
- if (MODULO_MODE == 9) {
950
- s = y.s;
951
- y.s = 1;
952
- q = div(x, y, 0, 3);
953
- y.s = s;
954
- q.s *= s;
955
- } else q = div(x, y, 0, MODULO_MODE);
956
- y = x.minus(q.times(y));
957
- if (!y.c[0] && MODULO_MODE == 1) y.s = x.s;
958
- return y;
959
- };
960
- P.multipliedBy = P.times = function(y, b) {
961
- var c, e, i, j, k, m, xcL, xlo, xhi, ycL, ylo, yhi, zc, base, sqrtBase, x = this, xc = x.c, yc = (y = new BigNumber$1(y, b)).c;
962
- if (!xc || !yc || !xc[0] || !yc[0]) {
963
- if (!x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc) y.c = y.e = y.s = null;
964
- else {
965
- y.s *= x.s;
966
- if (!xc || !yc) y.c = y.e = null;
967
- else {
968
- y.c = [0];
969
- y.e = 0;
970
- }
971
- }
972
- return y;
973
- }
974
- e = bitFloor(x.e / LOG_BASE) + bitFloor(y.e / LOG_BASE);
975
- y.s *= x.s;
976
- xcL = xc.length;
977
- ycL = yc.length;
978
- if (xcL < ycL) {
979
- zc = xc;
980
- xc = yc;
981
- yc = zc;
982
- i = xcL;
983
- xcL = ycL;
984
- ycL = i;
985
- }
986
- for (i = xcL + ycL, zc = []; i--; zc.push(0));
987
- base = BASE;
988
- sqrtBase = SQRT_BASE;
989
- for (i = ycL; --i >= 0;) {
990
- c = 0;
991
- ylo = yc[i] % sqrtBase;
992
- yhi = yc[i] / sqrtBase | 0;
993
- for (k = xcL, j = i + k; j > i;) {
994
- xlo = xc[--k] % sqrtBase;
995
- xhi = xc[k] / sqrtBase | 0;
996
- m = yhi * xlo + xhi * ylo;
997
- xlo = ylo * xlo + m % sqrtBase * sqrtBase + zc[j] + c;
998
- c = (xlo / base | 0) + (m / sqrtBase | 0) + yhi * xhi;
999
- zc[j--] = xlo % base;
1000
- }
1001
- zc[j] = c;
1002
- }
1003
- if (c) ++e;
1004
- else zc.splice(0, 1);
1005
- return normalise(y, zc, e);
1006
- };
1007
- P.negated = function() {
1008
- var x = new BigNumber$1(this);
1009
- x.s = -x.s || null;
1010
- return x;
1011
- };
1012
- P.plus = function(y, b) {
1013
- var t, x = this, a = x.s;
1014
- y = new BigNumber$1(y, b);
1015
- b = y.s;
1016
- if (!a || !b) return new BigNumber$1(NaN);
1017
- if (a != b) {
1018
- y.s = -b;
1019
- return x.minus(y);
1020
- }
1021
- var xe = x.e / LOG_BASE, ye = y.e / LOG_BASE, xc = x.c, yc = y.c;
1022
- if (!xe || !ye) {
1023
- if (!xc || !yc) return new BigNumber$1(a / 0);
1024
- if (!xc[0] || !yc[0]) return yc[0] ? y : new BigNumber$1(xc[0] ? x : a * 0);
1025
- }
1026
- xe = bitFloor(xe);
1027
- ye = bitFloor(ye);
1028
- xc = xc.slice();
1029
- if (a = xe - ye) {
1030
- if (a > 0) {
1031
- ye = xe;
1032
- t = yc;
1033
- } else {
1034
- a = -a;
1035
- t = xc;
1036
- }
1037
- t.reverse();
1038
- for (; a--; t.push(0));
1039
- t.reverse();
1040
- }
1041
- a = xc.length;
1042
- b = yc.length;
1043
- if (a - b < 0) {
1044
- t = yc;
1045
- yc = xc;
1046
- xc = t;
1047
- b = a;
1048
- }
1049
- for (a = 0; b;) {
1050
- a = (xc[--b] = xc[b] + yc[b] + a) / BASE | 0;
1051
- xc[b] = BASE === xc[b] ? 0 : xc[b] % BASE;
1052
- }
1053
- if (a) {
1054
- xc = [a].concat(xc);
1055
- ++ye;
1056
- }
1057
- return normalise(y, xc, ye);
1058
- };
1059
- P.precision = P.sd = function(sd, rm) {
1060
- var c, n, v, x = this;
1061
- if (sd != null && sd !== !!sd) {
1062
- intCheck(sd, 1, MAX);
1063
- if (rm == null) rm = ROUNDING_MODE;
1064
- else intCheck(rm, 0, 8);
1065
- return round(new BigNumber$1(x), sd, rm);
1066
- }
1067
- if (!(c = x.c)) return null;
1068
- v = c.length - 1;
1069
- n = v * LOG_BASE + 1;
1070
- if (v = c[v]) {
1071
- for (; v % 10 == 0; v /= 10, n--);
1072
- for (v = c[0]; v >= 10; v /= 10, n++);
1073
- }
1074
- if (sd && x.e + 1 > n) n = x.e + 1;
1075
- return n;
1076
- };
1077
- P.shiftedBy = function(k) {
1078
- intCheck(k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
1079
- return this.times("1e" + k);
1080
- };
1081
- P.squareRoot = P.sqrt = function() {
1082
- var m, n, r, rep, t, x = this, c = x.c, s = x.s, e = x.e, dp = DECIMAL_PLACES + 4, half = new BigNumber$1("0.5");
1083
- if (s !== 1 || !c || !c[0]) return new BigNumber$1(!s || s < 0 && (!c || c[0]) ? NaN : c ? x : Infinity);
1084
- s = Math.sqrt(+valueOf(x));
1085
- if (s == 0 || s == Infinity) {
1086
- n = coeffToString(c);
1087
- if ((n.length + e) % 2 == 0) n += "0";
1088
- s = Math.sqrt(+n);
1089
- e = bitFloor((e + 1) / 2) - (e < 0 || e % 2);
1090
- if (s == Infinity) n = "5e" + e;
1091
- else {
1092
- n = s.toExponential();
1093
- n = n.slice(0, n.indexOf("e") + 1) + e;
1094
- }
1095
- r = new BigNumber$1(n);
1096
- } else r = new BigNumber$1(s + "");
1097
- if (r.c[0]) {
1098
- e = r.e;
1099
- s = e + dp;
1100
- if (s < 3) s = 0;
1101
- for (;;) {
1102
- t = r;
1103
- r = half.times(t.plus(div(x, t, dp, 1)));
1104
- if (coeffToString(t.c).slice(0, s) === (n = coeffToString(r.c)).slice(0, s)) {
1105
- if (r.e < e) --s;
1106
- n = n.slice(s - 3, s + 1);
1107
- if (n == "9999" || !rep && n == "4999") {
1108
- if (!rep) {
1109
- round(t, t.e + DECIMAL_PLACES + 2, 0);
1110
- if (t.times(t).eq(x)) {
1111
- r = t;
1112
- break;
1113
- }
1114
- }
1115
- dp += 4;
1116
- s += 4;
1117
- rep = 1;
1118
- } else {
1119
- if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
1120
- round(r, r.e + DECIMAL_PLACES + 2, 1);
1121
- m = !r.times(r).eq(x);
1122
- }
1123
- break;
1124
- }
1125
- }
1126
- }
1127
- }
1128
- return round(r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m);
1129
- };
1130
- P.toExponential = function(dp, rm) {
1131
- if (dp != null) {
1132
- intCheck(dp, 0, MAX);
1133
- dp++;
1134
- }
1135
- return format(this, dp, rm, 1);
1136
- };
1137
- P.toFixed = function(dp, rm) {
1138
- if (dp != null) {
1139
- intCheck(dp, 0, MAX);
1140
- dp = dp + this.e + 1;
1141
- }
1142
- return format(this, dp, rm);
1143
- };
1144
- P.toFormat = function(dp, rm, format$1) {
1145
- var str, x = this;
1146
- if (format$1 == null) if (dp != null && rm && typeof rm == "object") {
1147
- format$1 = rm;
1148
- rm = null;
1149
- } else if (dp && typeof dp == "object") {
1150
- format$1 = dp;
1151
- dp = rm = null;
1152
- } else format$1 = FORMAT;
1153
- else if (typeof format$1 != "object") throw Error(bignumberError + "Argument not an object: " + format$1);
1154
- str = x.toFixed(dp, rm);
1155
- if (x.c) {
1156
- var i, arr = str.split("."), g1 = +format$1.groupSize, g2 = +format$1.secondaryGroupSize, groupSeparator = format$1.groupSeparator || "", intPart = arr[0], fractionPart = arr[1], isNeg = x.s < 0, intDigits = isNeg ? intPart.slice(1) : intPart, len = intDigits.length;
1157
- if (g2) {
1158
- i = g1;
1159
- g1 = g2;
1160
- g2 = i;
1161
- len -= i;
1162
- }
1163
- if (g1 > 0 && len > 0) {
1164
- i = len % g1 || g1;
1165
- intPart = intDigits.substr(0, i);
1166
- for (; i < len; i += g1) intPart += groupSeparator + intDigits.substr(i, g1);
1167
- if (g2 > 0) intPart += groupSeparator + intDigits.slice(i);
1168
- if (isNeg) intPart = "-" + intPart;
1169
- }
1170
- str = fractionPart ? intPart + (format$1.decimalSeparator || "") + ((g2 = +format$1.fractionGroupSize) ? fractionPart.replace(new RegExp("\\d{" + g2 + "}\\B", "g"), "$&" + (format$1.fractionGroupSeparator || "")) : fractionPart) : intPart;
1171
- }
1172
- return (format$1.prefix || "") + str + (format$1.suffix || "");
1173
- };
1174
- P.toFraction = function(md) {
1175
- var d, d0, d1, d2, e, exp, n, n0, n1, q, r, s, x = this, xc = x.c;
1176
- if (md != null) {
1177
- n = new BigNumber$1(md);
1178
- if (!n.isInteger() && (n.c || n.s !== 1) || n.lt(ONE)) throw Error(bignumberError + "Argument " + (n.isInteger() ? "out of range: " : "not an integer: ") + valueOf(n));
1179
- }
1180
- if (!xc) return new BigNumber$1(x);
1181
- d = new BigNumber$1(ONE);
1182
- n1 = d0 = new BigNumber$1(ONE);
1183
- d1 = n0 = new BigNumber$1(ONE);
1184
- s = coeffToString(xc);
1185
- e = d.e = s.length - x.e - 1;
1186
- d.c[0] = POWS_TEN[(exp = e % LOG_BASE) < 0 ? LOG_BASE + exp : exp];
1187
- md = !md || n.comparedTo(d) > 0 ? e > 0 ? d : n1 : n;
1188
- exp = MAX_EXP;
1189
- MAX_EXP = Infinity;
1190
- n = new BigNumber$1(s);
1191
- n0.c[0] = 0;
1192
- for (;;) {
1193
- q = div(n, d, 0, 1);
1194
- d2 = d0.plus(q.times(d1));
1195
- if (d2.comparedTo(md) == 1) break;
1196
- d0 = d1;
1197
- d1 = d2;
1198
- n1 = n0.plus(q.times(d2 = n1));
1199
- n0 = d2;
1200
- d = n.minus(q.times(d2 = d));
1201
- n = d2;
1202
- }
1203
- d2 = div(md.minus(d0), d1, 0, 1);
1204
- n0 = n0.plus(d2.times(n1));
1205
- d0 = d0.plus(d2.times(d1));
1206
- n0.s = n1.s = x.s;
1207
- e = e * 2;
1208
- r = div(n1, d1, e, ROUNDING_MODE).minus(x).abs().comparedTo(div(n0, d0, e, ROUNDING_MODE).minus(x).abs()) < 1 ? [n1, d1] : [n0, d0];
1209
- MAX_EXP = exp;
1210
- return r;
1211
- };
1212
- P.toNumber = function() {
1213
- return +valueOf(this);
1214
- };
1215
- P.toPrecision = function(sd, rm) {
1216
- if (sd != null) intCheck(sd, 1, MAX);
1217
- return format(this, sd, rm, 2);
1218
- };
1219
- P.toString = function(b) {
1220
- var str, n = this, s = n.s, e = n.e;
1221
- if (e === null) if (s) {
1222
- str = "Infinity";
1223
- if (s < 0) str = "-" + str;
1224
- } else str = "NaN";
1225
- else {
1226
- if (b == null) str = e <= TO_EXP_NEG || e >= TO_EXP_POS ? toExponential(coeffToString(n.c), e) : toFixedPoint(coeffToString(n.c), e, "0");
1227
- else if (b === 10 && alphabetHasNormalDecimalDigits) {
1228
- n = round(new BigNumber$1(n), DECIMAL_PLACES + e + 1, ROUNDING_MODE);
1229
- str = toFixedPoint(coeffToString(n.c), n.e, "0");
1230
- } else {
1231
- intCheck(b, 2, ALPHABET.length, "Base");
1232
- str = convertBase(toFixedPoint(coeffToString(n.c), e, "0"), 10, b, s, true);
1233
- }
1234
- if (s < 0 && n.c[0]) str = "-" + str;
1235
- }
1236
- return str;
1237
- };
1238
- P.valueOf = P.toJSON = function() {
1239
- return valueOf(this);
1240
- };
1241
- P._isBigNumber = true;
1242
- P[Symbol.toStringTag] = "BigNumber";
1243
- P[Symbol.for("nodejs.util.inspect.custom")] = P.valueOf;
1244
- if (configObject != null) BigNumber$1.set(configObject);
1245
- return BigNumber$1;
1246
- }
1247
- function bitFloor(n) {
1248
- var i = n | 0;
1249
- return n > 0 || n === i ? i : i - 1;
1250
- }
1251
- function coeffToString(a) {
1252
- var s, z, i = 1, j = a.length, r = a[0] + "";
1253
- for (; i < j;) {
1254
- s = a[i++] + "";
1255
- z = LOG_BASE - s.length;
1256
- for (; z--; s = "0" + s);
1257
- r += s;
1258
- }
1259
- for (j = r.length; r.charCodeAt(--j) === 48;);
1260
- return r.slice(0, j + 1 || 1);
1261
- }
1262
- function compare(x, y) {
1263
- var a, b, xc = x.c, yc = y.c, i = x.s, j = y.s, k = x.e, l = y.e;
1264
- if (!i || !j) return null;
1265
- a = xc && !xc[0];
1266
- b = yc && !yc[0];
1267
- if (a || b) return a ? b ? 0 : -j : i;
1268
- if (i != j) return i;
1269
- a = i < 0;
1270
- b = k == l;
1271
- if (!xc || !yc) return b ? 0 : !xc ^ a ? 1 : -1;
1272
- if (!b) return k > l ^ a ? 1 : -1;
1273
- j = (k = xc.length) < (l = yc.length) ? k : l;
1274
- for (i = 0; i < j; i++) if (xc[i] != yc[i]) return xc[i] > yc[i] ^ a ? 1 : -1;
1275
- return k == l ? 0 : k > l ^ a ? 1 : -1;
1276
- }
1277
- function intCheck(n, min, max, name) {
1278
- if (n < min || n > max || n !== mathfloor(n)) throw Error(bignumberError + (name || "Argument") + (typeof n == "number" ? n < min || n > max ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(n));
1279
- }
1280
- function isOdd(n) {
1281
- var k = n.c.length - 1;
1282
- return bitFloor(n.e / LOG_BASE) == k && n.c[k] % 2 != 0;
1283
- }
1284
- function toExponential(str, e) {
1285
- return (str.length > 1 ? str.charAt(0) + "." + str.slice(1) : str) + (e < 0 ? "e" : "e+") + e;
1286
- }
1287
- function toFixedPoint(str, e, z) {
1288
- var len, zs;
1289
- if (e < 0) {
1290
- for (zs = z + "."; ++e; zs += z);
1291
- str = zs + str;
1292
- } else {
1293
- len = str.length;
1294
- if (++e > len) {
1295
- for (zs = z, e -= len; --e; zs += z);
1296
- str += zs;
1297
- } else if (e < len) str = str.slice(0, e) + "." + str.slice(e);
1298
- }
1299
- return str;
1300
- }
1301
- var BigNumber = clone();
1302
-
1303
- //#endregion
1304
- //#region ../../utils/dist/esm/constants-BxcSsKjm.js
1305
- var BigNumber_default = BigNumber;
1306
- /**
1307
- * Converts a value to BigNumber if it isn't already
1308
- */
1309
- const toBigNumber = (value) => {
1310
- if (value instanceof BigNumber) return value;
1311
- return new BigNumber(value);
1312
- };
1313
- /**
1314
- * Converts a value to Wei (multiplies by 10^decimals) default to 18 decimals
1315
- */
1316
- const toChainFormat = (value, decimals = 18) => {
1317
- return toBigNumber(value).multipliedBy(new BigNumber(10).pow(decimals));
1318
- };
1319
- const DEFAULT_GAS_LIMIT = 4e5;
1320
- const DEFAULT_GAS_PRICE = 16e7;
1321
- const DEFAULT_BLOCK_TIMEOUT_HEIGHT = 120;
1322
- const DEFAULT_BLOCK_TIME_IN_SECONDS = .7;
1323
- /**
1324
- * Default timeout for transaction block inclusion polling.
1325
- *
1326
- * Calculation: 120 blocks × 0.7 seconds/block = 84 seconds = 84,000ms
1327
- */
1328
- const DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS = Math.floor(DEFAULT_BLOCK_TIMEOUT_HEIGHT * DEFAULT_BLOCK_TIME_IN_SECONDS * 1e3);
1329
- const DEFAULT_TIMESTAMP_TIMEOUT_MS = 60 * 1e3 * 3;
1330
- const getDefaultStdFee = () => ({
1331
- amount: [{
1332
- amount: new BigNumber_default(DEFAULT_GAS_LIMIT).times(DEFAULT_GAS_PRICE).toString(),
1333
- denom: "inj"
1334
- }],
1335
- gas: DEFAULT_GAS_LIMIT.toString(),
1336
- payer: "",
1337
- granter: "",
1338
- feePayer: ""
1339
- });
1340
-
1341
- //#endregion
1342
- //#region ../../../node_modules/.pnpm/@bangjelkoski+store2@2.14.3/node_modules/@bangjelkoski/store2/dist/store2.js
1343
- var require_store2 = /* @__PURE__ */ __commonJS({ "../../../node_modules/.pnpm/@bangjelkoski+store2@2.14.3/node_modules/@bangjelkoski/store2/dist/store2.js": ((exports, module) => {
1344
- (function(window, define) {
1345
- var _ = {
1346
- version: "2.14.3",
1347
- areas: {},
1348
- apis: {},
1349
- nsdelim: ".",
1350
- inherit: function(api, o) {
1351
- for (var p in api) if (!o.hasOwnProperty(p)) Object.defineProperty(o, p, Object.getOwnPropertyDescriptor(api, p));
1352
- return o;
1353
- },
1354
- stringify: function(d, fn) {
1355
- return d === void 0 || typeof d === "function" ? d + "" : JSON.stringify(d, fn || _.replace);
1356
- },
1357
- parse: function(s, fn) {
1358
- try {
1359
- return JSON.parse(s, fn || _.revive);
1360
- } catch (e) {
1361
- return s;
1362
- }
1363
- },
1364
- fn: function(name, fn) {
1365
- _.storeAPI[name] = fn;
1366
- for (var api in _.apis) _.apis[api][name] = fn;
1367
- },
1368
- get: function(area, key) {
1369
- return area.getItem(key);
1370
- },
1371
- set: function(area, key, string) {
1372
- area.setItem(key, string);
1373
- },
1374
- remove: function(area, key) {
1375
- area.removeItem(key);
1376
- },
1377
- key: function(area, i) {
1378
- return area.key(i);
1379
- },
1380
- length: function(area) {
1381
- return area.length;
1382
- },
1383
- clear: function(area) {
1384
- area.clear();
1385
- },
1386
- Store: function(id, area, namespace) {
1387
- var store$2 = _.inherit(_.storeAPI, function(key, data, overwrite) {
1388
- if (arguments.length === 0) return store$2.getAll();
1389
- if (typeof data === "function") return store$2.transact(key, data, overwrite);
1390
- if (data !== void 0) return store$2.set(key, data, overwrite);
1391
- if (typeof key === "string" || typeof key === "number") return store$2.get(key);
1392
- if (typeof key === "function") return store$2.each(key);
1393
- if (!key) return store$2.clear();
1394
- return store$2.setAll(key, data);
1395
- });
1396
- store$2._id = id;
1397
- try {
1398
- var testKey = "__store2_test";
1399
- area.setItem(testKey, "ok");
1400
- store$2._area = area;
1401
- area.removeItem(testKey);
1402
- } catch (e) {
1403
- store$2._area = _.storage("fake");
1404
- }
1405
- store$2._ns = namespace || "";
1406
- if (!_.areas[id]) _.areas[id] = store$2._area;
1407
- if (!_.apis[store$2._ns + store$2._id]) _.apis[store$2._ns + store$2._id] = store$2;
1408
- return store$2;
1409
- },
1410
- storeAPI: {
1411
- area: function(id, area) {
1412
- var store$2 = this[id];
1413
- if (!store$2 || !store$2.area) {
1414
- store$2 = _.Store(id, area, this._ns);
1415
- if (!this[id]) this[id] = store$2;
1416
- }
1417
- return store$2;
1418
- },
1419
- namespace: function(namespace, singleArea, delim) {
1420
- delim = delim || this._delim || _.nsdelim;
1421
- if (!namespace) return this._ns ? this._ns.substring(0, this._ns.length - delim.length) : "";
1422
- var ns = namespace, store$2 = this[ns];
1423
- if (!store$2 || !store$2.namespace) {
1424
- store$2 = _.Store(this._id, this._area, this._ns + ns + delim);
1425
- store$2._delim = delim;
1426
- if (!this[ns]) this[ns] = store$2;
1427
- if (!singleArea) for (var name in _.areas) store$2.area(name, _.areas[name]);
1428
- }
1429
- return store$2;
1430
- },
1431
- isFake: function(force) {
1432
- if (force) {
1433
- this._real = this._area;
1434
- this._area = _.storage("fake");
1435
- } else if (force === false) this._area = this._real || this._area;
1436
- return this._area.name === "fake";
1437
- },
1438
- toString: function() {
1439
- return "store" + (this._ns ? "." + this.namespace() : "") + "[" + this._id + "]";
1440
- },
1441
- has: function(key) {
1442
- if (this._area.has) return this._area.has(this._in(key));
1443
- return !!(this._in(key) in this._area);
1444
- },
1445
- size: function() {
1446
- return this.keys().length;
1447
- },
1448
- each: function(fn, fill) {
1449
- for (var i = 0, m = _.length(this._area); i < m; i++) {
1450
- var key = this._out(_.key(this._area, i));
1451
- if (key !== void 0) {
1452
- if (fn.call(this, key, this.get(key), fill) === false) break;
1453
- }
1454
- if (m > _.length(this._area)) {
1455
- m--;
1456
- i--;
1457
- }
1458
- }
1459
- return fill || this;
1460
- },
1461
- keys: function(fillList) {
1462
- return this.each(function(k, v, list) {
1463
- list.push(k);
1464
- }, fillList || []);
1465
- },
1466
- get: function(key, alt) {
1467
- var s = _.get(this._area, this._in(key)), fn;
1468
- if (typeof alt === "function") {
1469
- fn = alt;
1470
- alt = null;
1471
- }
1472
- return s !== null ? _.parse(s, fn) : alt != null ? alt : s;
1473
- },
1474
- getAll: function(fillObj) {
1475
- return this.each(function(k, v, all) {
1476
- all[k] = v;
1477
- }, fillObj || {});
1478
- },
1479
- transact: function(key, fn, alt) {
1480
- var val = this.get(key, alt), ret = fn(val);
1481
- this.set(key, ret === void 0 ? val : ret);
1482
- return this;
1483
- },
1484
- set: function(key, data, overwrite) {
1485
- var d = this.get(key), replacer;
1486
- if (d != null && overwrite === false) return data;
1487
- if (typeof overwrite === "function") {
1488
- replacer = overwrite;
1489
- overwrite = void 0;
1490
- }
1491
- return _.set(this._area, this._in(key), _.stringify(data, replacer), overwrite) || d;
1492
- },
1493
- setAll: function(data, overwrite) {
1494
- var changed, val;
1495
- for (var key in data) {
1496
- val = data[key];
1497
- if (this.set(key, val, overwrite) !== val) changed = true;
1498
- }
1499
- return changed;
1500
- },
1501
- add: function(key, data, replacer) {
1502
- var d = this.get(key);
1503
- if (d instanceof Array) data = d.concat(data);
1504
- else if (d !== null) {
1505
- var type = typeof d;
1506
- if (type === typeof data && type === "object") {
1507
- for (var k in data) d[k] = data[k];
1508
- data = d;
1509
- } else data = d + data;
1510
- }
1511
- _.set(this._area, this._in(key), _.stringify(data, replacer));
1512
- return data;
1513
- },
1514
- remove: function(key, alt) {
1515
- var d = this.get(key, alt);
1516
- _.remove(this._area, this._in(key));
1517
- return d;
1518
- },
1519
- clear: function() {
1520
- if (!this._ns) _.clear(this._area);
1521
- else this.each(function(k) {
1522
- _.remove(this._area, this._in(k));
1523
- }, 1);
1524
- return this;
1525
- },
1526
- clearAll: function() {
1527
- var area = this._area;
1528
- for (var id in _.areas) if (_.areas.hasOwnProperty(id)) {
1529
- this._area = _.areas[id];
1530
- this.clear();
1531
- }
1532
- this._area = area;
1533
- return this;
1534
- },
1535
- _in: function(k) {
1536
- if (typeof k !== "string") k = _.stringify(k);
1537
- return this._ns ? this._ns + k : k;
1538
- },
1539
- _out: function(k) {
1540
- return this._ns ? k && k.indexOf(this._ns) === 0 ? k.substring(this._ns.length) : void 0 : k;
1541
- }
1542
- },
1543
- storage: function(name) {
1544
- return _.inherit(_.storageAPI, {
1545
- items: {},
1546
- name
1547
- });
1548
- },
1549
- storageAPI: {
1550
- length: 0,
1551
- has: function(k) {
1552
- return this.items.hasOwnProperty(k);
1553
- },
1554
- key: function(i) {
1555
- var c = 0;
1556
- for (var k in this.items) if (this.has(k) && i === c++) return k;
1557
- },
1558
- setItem: function(k, v) {
1559
- if (!this.has(k)) this.length++;
1560
- this.items[k] = v;
1561
- },
1562
- removeItem: function(k) {
1563
- if (this.has(k)) {
1564
- delete this.items[k];
1565
- this.length--;
1566
- }
1567
- },
1568
- getItem: function(k) {
1569
- return this.has(k) ? this.items[k] : null;
1570
- },
1571
- clear: function() {
1572
- for (var k in this.items) this.removeItem(k);
1573
- }
1574
- }
1575
- };
1576
- var store$1 = _.Store("local", (function() {
1577
- try {
1578
- return localStorage;
1579
- } catch (e) {}
1580
- })());
1581
- store$1.local = store$1;
1582
- store$1._ = _;
1583
- store$1.area("session", (function() {
1584
- try {
1585
- return sessionStorage;
1586
- } catch (e) {}
1587
- })());
1588
- store$1.area("page", _.storage("page"));
1589
- if (typeof define === "function" && define.amd !== void 0) define("store2", [], function() {
1590
- return store$1;
1591
- });
1592
- else if (typeof module !== "undefined" && module.exports) {
1593
- module.exports = store$1;
1594
- module.exports.store = store$1;
1595
- } else {
1596
- if (window.store) _.conflict = window.store;
1597
- window.store = store$1;
1598
- }
1599
- })(exports, exports && exports.define);
1600
- }) });
1601
-
1602
- //#endregion
1603
- //#region ../../utils/dist/esm/index.js
1604
- var import_store2 = require_store2();
1605
- const getStdFeeFromObject = (args) => {
1606
- if (!args) return getDefaultStdFee();
1607
- const { payer, granter, feePayer, gasPrice = DEFAULT_GAS_PRICE, gas = DEFAULT_GAS_LIMIT.toString() } = args;
1608
- const gasNormalized = toBigNumber(gas).toFixed(0);
1609
- const gasPriceNormalized = toBigNumber(gasPrice).toFixed(0);
1610
- return {
1611
- amount: [{
1612
- denom: "inj",
1613
- amount: toBigNumber(gasNormalized).times(gasPriceNormalized).toFixed()
1614
- }],
1615
- gas: toBigNumber(gasNormalized).toFixed(),
1616
- payer,
1617
- granter,
1618
- feePayer
1619
- };
1620
- };
1621
- const getStdFeeFromString = (gasPrice) => {
1622
- const matchResult = gasPrice.match(/^([0-9.]+)([a-zA-Z][a-zA-Z0-9/:._-]*)$/);
1623
- if (!matchResult) throw new Error("Invalid gas price string");
1624
- const [_, amount] = matchResult;
1625
- return getStdFeeFromObject({
1626
- gas: toChainFormat(amount, 18).dividedBy(DEFAULT_GAS_PRICE).toFixed(0),
1627
- gasPrice: DEFAULT_GAS_PRICE
1628
- });
1629
- };
1630
- const getStdFee = (args) => {
1631
- if (!args) return getDefaultStdFee();
1632
- if (typeof args === "string") return getStdFeeFromString(args);
1633
- return getStdFeeFromObject({ ...args });
1634
- };
1635
-
1636
97
  //#endregion
1637
98
  //#region src/utils/tx.ts
1638
99
  const createEip712StdSignDoc = ({ memo, chainId, accountNumber, timeoutHeight, sequence, gas, msgs }) => ({
@@ -1640,7 +101,7 @@ const createEip712StdSignDoc = ({ memo, chainId, accountNumber, timeoutHeight, s
1640
101
  timeout_height: timeoutHeight || "",
1641
102
  account_number: accountNumber.toString(),
1642
103
  sequence: sequence.toString(),
1643
- fee: getStdFee({ gas }),
104
+ fee: (0, __injectivelabs_utils.getStdFee)({ gas }),
1644
105
  msgs: msgs.map((m) => m.toEip712()),
1645
106
  memo: memo || ""
1646
107
  });
@@ -1778,8 +239,8 @@ const getEthereumSignerAddress = (address) => {
1778
239
 
1779
240
  //#endregion
1780
241
  //#region src/utils/constants.ts
1781
- const GWEI_IN_WEI = toBigNumber(1e9);
1782
- const TIP_IN_GWEI = toBigNumber(2).times(GWEI_IN_WEI);
242
+ const GWEI_IN_WEI = (0, __injectivelabs_utils.toBigNumber)(1e9);
243
+ const TIP_IN_GWEI = (0, __injectivelabs_utils.toBigNumber)(2).times(GWEI_IN_WEI);
1783
244
  const DEFAULT_BASE_DERIVATION_PATH = "m/44'/60'";
1784
245
  const DEFAULT_NUM_ADDRESSES_TO_FETCH = 5;
1785
246
  const DEFAULT_ADDRESS_SEARCH_LIMIT = 100;