@jpool/bond-sdk 0.10.2 → 0.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,15 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var anchor = require('@coral-xyz/anchor');
4
- var bytes = require('@coral-xyz/anchor/dist/cjs/utils/bytes');
5
- var splStakePool = require('@solana/spl-stake-pool');
6
4
  var splToken = require('@solana/spl-token');
7
5
  var web3_js = require('@solana/web3.js');
8
- var bs58 = require('bs58');
9
-
10
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
-
12
- var bs58__default = /*#__PURE__*/_interopDefault(bs58);
13
6
 
14
7
  var __create = Object.create;
15
8
  var __defProp = Object.defineProperty;
@@ -1837,8 +1830,8 @@ var require_bn = __commonJS({
1837
1830
  ctor.prototype = new TempCtor();
1838
1831
  ctor.prototype.constructor = ctor;
1839
1832
  }
1840
- function BN4(number, base, endian) {
1841
- if (BN4.isBN(number)) {
1833
+ function BN3(number, base, endian) {
1834
+ if (BN3.isBN(number)) {
1842
1835
  return number;
1843
1836
  }
1844
1837
  this.negative = 0;
@@ -1854,12 +1847,12 @@ var require_bn = __commonJS({
1854
1847
  }
1855
1848
  }
1856
1849
  if (typeof module2 === "object") {
1857
- module2.exports = BN4;
1850
+ module2.exports = BN3;
1858
1851
  } else {
1859
- exports2.BN = BN4;
1852
+ exports2.BN = BN3;
1860
1853
  }
1861
- BN4.BN = BN4;
1862
- BN4.wordSize = 26;
1854
+ BN3.BN = BN3;
1855
+ BN3.wordSize = 26;
1863
1856
  var Buffer2;
1864
1857
  try {
1865
1858
  if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") {
@@ -1869,21 +1862,21 @@ var require_bn = __commonJS({
1869
1862
  }
1870
1863
  } catch (e) {
1871
1864
  }
1872
- BN4.isBN = function isBN(num) {
1873
- if (num instanceof BN4) {
1865
+ BN3.isBN = function isBN(num) {
1866
+ if (num instanceof BN3) {
1874
1867
  return true;
1875
1868
  }
1876
- return num !== null && typeof num === "object" && num.constructor.wordSize === BN4.wordSize && Array.isArray(num.words);
1869
+ return num !== null && typeof num === "object" && num.constructor.wordSize === BN3.wordSize && Array.isArray(num.words);
1877
1870
  };
1878
- BN4.max = function max(left, right) {
1871
+ BN3.max = function max(left, right) {
1879
1872
  if (left.cmp(right) > 0) return left;
1880
1873
  return right;
1881
1874
  };
1882
- BN4.min = function min(left, right) {
1875
+ BN3.min = function min(left, right) {
1883
1876
  if (left.cmp(right) < 0) return left;
1884
1877
  return right;
1885
1878
  };
1886
- BN4.prototype._init = function init(number, base, endian) {
1879
+ BN3.prototype._init = function init(number, base, endian) {
1887
1880
  if (typeof number === "number") {
1888
1881
  return this._initNumber(number, base, endian);
1889
1882
  }
@@ -1911,7 +1904,7 @@ var require_bn = __commonJS({
1911
1904
  }
1912
1905
  }
1913
1906
  };
1914
- BN4.prototype._initNumber = function _initNumber(number, base, endian) {
1907
+ BN3.prototype._initNumber = function _initNumber(number, base, endian) {
1915
1908
  if (number < 0) {
1916
1909
  this.negative = 1;
1917
1910
  number = -number;
@@ -1937,7 +1930,7 @@ var require_bn = __commonJS({
1937
1930
  if (endian !== "le") return;
1938
1931
  this._initArray(this.toArray(), base, endian);
1939
1932
  };
1940
- BN4.prototype._initArray = function _initArray(number, base, endian) {
1933
+ BN3.prototype._initArray = function _initArray(number, base, endian) {
1941
1934
  assert(typeof number.length === "number");
1942
1935
  if (number.length <= 0) {
1943
1936
  this.words = [0];
@@ -1995,7 +1988,7 @@ var require_bn = __commonJS({
1995
1988
  }
1996
1989
  return r;
1997
1990
  }
1998
- BN4.prototype._parseHex = function _parseHex(number, start, endian) {
1991
+ BN3.prototype._parseHex = function _parseHex(number, start, endian) {
1999
1992
  this.length = Math.ceil((number.length - start) / 6);
2000
1993
  this.words = new Array(this.length);
2001
1994
  for (var i = 0; i < this.length; i++) {
@@ -2051,7 +2044,7 @@ var require_bn = __commonJS({
2051
2044
  }
2052
2045
  return r;
2053
2046
  }
2054
- BN4.prototype._parseBase = function _parseBase(number, base, start) {
2047
+ BN3.prototype._parseBase = function _parseBase(number, base, start) {
2055
2048
  this.words = [0];
2056
2049
  this.length = 1;
2057
2050
  for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base) {
@@ -2087,7 +2080,7 @@ var require_bn = __commonJS({
2087
2080
  }
2088
2081
  this._strip();
2089
2082
  };
2090
- BN4.prototype.copy = function copy(dest) {
2083
+ BN3.prototype.copy = function copy(dest) {
2091
2084
  dest.words = new Array(this.length);
2092
2085
  for (var i = 0; i < this.length; i++) {
2093
2086
  dest.words[i] = this.words[i];
@@ -2102,27 +2095,27 @@ var require_bn = __commonJS({
2102
2095
  dest.negative = src.negative;
2103
2096
  dest.red = src.red;
2104
2097
  }
2105
- BN4.prototype._move = function _move(dest) {
2098
+ BN3.prototype._move = function _move(dest) {
2106
2099
  move(dest, this);
2107
2100
  };
2108
- BN4.prototype.clone = function clone() {
2109
- var r = new BN4(null);
2101
+ BN3.prototype.clone = function clone() {
2102
+ var r = new BN3(null);
2110
2103
  this.copy(r);
2111
2104
  return r;
2112
2105
  };
2113
- BN4.prototype._expand = function _expand(size) {
2106
+ BN3.prototype._expand = function _expand(size) {
2114
2107
  while (this.length < size) {
2115
2108
  this.words[this.length++] = 0;
2116
2109
  }
2117
2110
  return this;
2118
2111
  };
2119
- BN4.prototype._strip = function strip() {
2112
+ BN3.prototype._strip = function strip() {
2120
2113
  while (this.length > 1 && this.words[this.length - 1] === 0) {
2121
2114
  this.length--;
2122
2115
  }
2123
2116
  return this._normSign();
2124
2117
  };
2125
- BN4.prototype._normSign = function _normSign() {
2118
+ BN3.prototype._normSign = function _normSign() {
2126
2119
  if (this.length === 1 && this.words[0] === 0) {
2127
2120
  this.negative = 0;
2128
2121
  }
@@ -2130,12 +2123,12 @@ var require_bn = __commonJS({
2130
2123
  };
2131
2124
  if (typeof Symbol !== "undefined" && typeof Symbol.for === "function") {
2132
2125
  try {
2133
- BN4.prototype[Symbol.for("nodejs.util.inspect.custom")] = inspect;
2126
+ BN3.prototype[Symbol.for("nodejs.util.inspect.custom")] = inspect;
2134
2127
  } catch (e) {
2135
- BN4.prototype.inspect = inspect;
2128
+ BN3.prototype.inspect = inspect;
2136
2129
  }
2137
2130
  } else {
2138
- BN4.prototype.inspect = inspect;
2131
+ BN3.prototype.inspect = inspect;
2139
2132
  }
2140
2133
  function inspect() {
2141
2134
  return (this.red ? "<BN-R: " : "<BN: ") + this.toString(16) + ">";
@@ -2246,7 +2239,7 @@ var require_bn = __commonJS({
2246
2239
  52521875,
2247
2240
  60466176
2248
2241
  ];
2249
- BN4.prototype.toString = function toString(base, padding) {
2242
+ BN3.prototype.toString = function toString(base, padding) {
2250
2243
  base = base || 10;
2251
2244
  padding = padding | 0 || 1;
2252
2245
  var out;
@@ -2308,7 +2301,7 @@ var require_bn = __commonJS({
2308
2301
  }
2309
2302
  assert(false, "Base should be between 2 and 36");
2310
2303
  };
2311
- BN4.prototype.toNumber = function toNumber() {
2304
+ BN3.prototype.toNumber = function toNumber() {
2312
2305
  var ret = this.words[0];
2313
2306
  if (this.length === 2) {
2314
2307
  ret += this.words[1] * 67108864;
@@ -2319,15 +2312,15 @@ var require_bn = __commonJS({
2319
2312
  }
2320
2313
  return this.negative !== 0 ? -ret : ret;
2321
2314
  };
2322
- BN4.prototype.toJSON = function toJSON() {
2315
+ BN3.prototype.toJSON = function toJSON() {
2323
2316
  return this.toString(16, 2);
2324
2317
  };
2325
2318
  if (Buffer2) {
2326
- BN4.prototype.toBuffer = function toBuffer(endian, length) {
2319
+ BN3.prototype.toBuffer = function toBuffer(endian, length) {
2327
2320
  return this.toArrayLike(Buffer2, endian, length);
2328
2321
  };
2329
2322
  }
2330
- BN4.prototype.toArray = function toArray(endian, length) {
2323
+ BN3.prototype.toArray = function toArray(endian, length) {
2331
2324
  return this.toArrayLike(Array, endian, length);
2332
2325
  };
2333
2326
  var allocate = function allocate2(ArrayType, size) {
@@ -2336,7 +2329,7 @@ var require_bn = __commonJS({
2336
2329
  }
2337
2330
  return new ArrayType(size);
2338
2331
  };
2339
- BN4.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length) {
2332
+ BN3.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length) {
2340
2333
  this._strip();
2341
2334
  var byteLength = this.byteLength();
2342
2335
  var reqLength = length || Math.max(1, byteLength);
@@ -2347,7 +2340,7 @@ var require_bn = __commonJS({
2347
2340
  this["_toArrayLike" + postfix](res, byteLength);
2348
2341
  return res;
2349
2342
  };
2350
- BN4.prototype._toArrayLikeLE = function _toArrayLikeLE(res, byteLength) {
2343
+ BN3.prototype._toArrayLikeLE = function _toArrayLikeLE(res, byteLength) {
2351
2344
  var position = 0;
2352
2345
  var carry = 0;
2353
2346
  for (var i = 0, shift = 0; i < this.length; i++) {
@@ -2377,7 +2370,7 @@ var require_bn = __commonJS({
2377
2370
  }
2378
2371
  }
2379
2372
  };
2380
- BN4.prototype._toArrayLikeBE = function _toArrayLikeBE(res, byteLength) {
2373
+ BN3.prototype._toArrayLikeBE = function _toArrayLikeBE(res, byteLength) {
2381
2374
  var position = res.length - 1;
2382
2375
  var carry = 0;
2383
2376
  for (var i = 0, shift = 0; i < this.length; i++) {
@@ -2408,11 +2401,11 @@ var require_bn = __commonJS({
2408
2401
  }
2409
2402
  };
2410
2403
  if (Math.clz32) {
2411
- BN4.prototype._countBits = function _countBits(w) {
2404
+ BN3.prototype._countBits = function _countBits(w) {
2412
2405
  return 32 - Math.clz32(w);
2413
2406
  };
2414
2407
  } else {
2415
- BN4.prototype._countBits = function _countBits(w) {
2408
+ BN3.prototype._countBits = function _countBits(w) {
2416
2409
  var t = w;
2417
2410
  var r = 0;
2418
2411
  if (t >= 4096) {
@@ -2434,7 +2427,7 @@ var require_bn = __commonJS({
2434
2427
  return r + t;
2435
2428
  };
2436
2429
  }
2437
- BN4.prototype._zeroBits = function _zeroBits(w) {
2430
+ BN3.prototype._zeroBits = function _zeroBits(w) {
2438
2431
  if (w === 0) return 26;
2439
2432
  var t = w;
2440
2433
  var r = 0;
@@ -2459,7 +2452,7 @@ var require_bn = __commonJS({
2459
2452
  }
2460
2453
  return r;
2461
2454
  };
2462
- BN4.prototype.bitLength = function bitLength() {
2455
+ BN3.prototype.bitLength = function bitLength() {
2463
2456
  var w = this.words[this.length - 1];
2464
2457
  var hi = this._countBits(w);
2465
2458
  return (this.length - 1) * 26 + hi;
@@ -2473,7 +2466,7 @@ var require_bn = __commonJS({
2473
2466
  }
2474
2467
  return w;
2475
2468
  }
2476
- BN4.prototype.zeroBits = function zeroBits() {
2469
+ BN3.prototype.zeroBits = function zeroBits() {
2477
2470
  if (this.isZero()) return 0;
2478
2471
  var r = 0;
2479
2472
  for (var i = 0; i < this.length; i++) {
@@ -2483,34 +2476,34 @@ var require_bn = __commonJS({
2483
2476
  }
2484
2477
  return r;
2485
2478
  };
2486
- BN4.prototype.byteLength = function byteLength() {
2479
+ BN3.prototype.byteLength = function byteLength() {
2487
2480
  return Math.ceil(this.bitLength() / 8);
2488
2481
  };
2489
- BN4.prototype.toTwos = function toTwos(width) {
2482
+ BN3.prototype.toTwos = function toTwos(width) {
2490
2483
  if (this.negative !== 0) {
2491
2484
  return this.abs().inotn(width).iaddn(1);
2492
2485
  }
2493
2486
  return this.clone();
2494
2487
  };
2495
- BN4.prototype.fromTwos = function fromTwos(width) {
2488
+ BN3.prototype.fromTwos = function fromTwos(width) {
2496
2489
  if (this.testn(width - 1)) {
2497
2490
  return this.notn(width).iaddn(1).ineg();
2498
2491
  }
2499
2492
  return this.clone();
2500
2493
  };
2501
- BN4.prototype.isNeg = function isNeg() {
2494
+ BN3.prototype.isNeg = function isNeg() {
2502
2495
  return this.negative !== 0;
2503
2496
  };
2504
- BN4.prototype.neg = function neg() {
2497
+ BN3.prototype.neg = function neg() {
2505
2498
  return this.clone().ineg();
2506
2499
  };
2507
- BN4.prototype.ineg = function ineg() {
2500
+ BN3.prototype.ineg = function ineg() {
2508
2501
  if (!this.isZero()) {
2509
2502
  this.negative ^= 1;
2510
2503
  }
2511
2504
  return this;
2512
2505
  };
2513
- BN4.prototype.iuor = function iuor(num) {
2506
+ BN3.prototype.iuor = function iuor(num) {
2514
2507
  while (this.length < num.length) {
2515
2508
  this.words[this.length++] = 0;
2516
2509
  }
@@ -2519,19 +2512,19 @@ var require_bn = __commonJS({
2519
2512
  }
2520
2513
  return this._strip();
2521
2514
  };
2522
- BN4.prototype.ior = function ior(num) {
2515
+ BN3.prototype.ior = function ior(num) {
2523
2516
  assert((this.negative | num.negative) === 0);
2524
2517
  return this.iuor(num);
2525
2518
  };
2526
- BN4.prototype.or = function or(num) {
2519
+ BN3.prototype.or = function or(num) {
2527
2520
  if (this.length > num.length) return this.clone().ior(num);
2528
2521
  return num.clone().ior(this);
2529
2522
  };
2530
- BN4.prototype.uor = function uor(num) {
2523
+ BN3.prototype.uor = function uor(num) {
2531
2524
  if (this.length > num.length) return this.clone().iuor(num);
2532
2525
  return num.clone().iuor(this);
2533
2526
  };
2534
- BN4.prototype.iuand = function iuand(num) {
2527
+ BN3.prototype.iuand = function iuand(num) {
2535
2528
  var b;
2536
2529
  if (this.length > num.length) {
2537
2530
  b = num;
@@ -2544,19 +2537,19 @@ var require_bn = __commonJS({
2544
2537
  this.length = b.length;
2545
2538
  return this._strip();
2546
2539
  };
2547
- BN4.prototype.iand = function iand(num) {
2540
+ BN3.prototype.iand = function iand(num) {
2548
2541
  assert((this.negative | num.negative) === 0);
2549
2542
  return this.iuand(num);
2550
2543
  };
2551
- BN4.prototype.and = function and(num) {
2544
+ BN3.prototype.and = function and(num) {
2552
2545
  if (this.length > num.length) return this.clone().iand(num);
2553
2546
  return num.clone().iand(this);
2554
2547
  };
2555
- BN4.prototype.uand = function uand(num) {
2548
+ BN3.prototype.uand = function uand(num) {
2556
2549
  if (this.length > num.length) return this.clone().iuand(num);
2557
2550
  return num.clone().iuand(this);
2558
2551
  };
2559
- BN4.prototype.iuxor = function iuxor(num) {
2552
+ BN3.prototype.iuxor = function iuxor(num) {
2560
2553
  var a;
2561
2554
  var b;
2562
2555
  if (this.length > num.length) {
@@ -2577,19 +2570,19 @@ var require_bn = __commonJS({
2577
2570
  this.length = a.length;
2578
2571
  return this._strip();
2579
2572
  };
2580
- BN4.prototype.ixor = function ixor(num) {
2573
+ BN3.prototype.ixor = function ixor(num) {
2581
2574
  assert((this.negative | num.negative) === 0);
2582
2575
  return this.iuxor(num);
2583
2576
  };
2584
- BN4.prototype.xor = function xor(num) {
2577
+ BN3.prototype.xor = function xor(num) {
2585
2578
  if (this.length > num.length) return this.clone().ixor(num);
2586
2579
  return num.clone().ixor(this);
2587
2580
  };
2588
- BN4.prototype.uxor = function uxor(num) {
2581
+ BN3.prototype.uxor = function uxor(num) {
2589
2582
  if (this.length > num.length) return this.clone().iuxor(num);
2590
2583
  return num.clone().iuxor(this);
2591
2584
  };
2592
- BN4.prototype.inotn = function inotn(width) {
2585
+ BN3.prototype.inotn = function inotn(width) {
2593
2586
  assert(typeof width === "number" && width >= 0);
2594
2587
  var bytesNeeded = Math.ceil(width / 26) | 0;
2595
2588
  var bitsLeft = width % 26;
@@ -2605,10 +2598,10 @@ var require_bn = __commonJS({
2605
2598
  }
2606
2599
  return this._strip();
2607
2600
  };
2608
- BN4.prototype.notn = function notn(width) {
2601
+ BN3.prototype.notn = function notn(width) {
2609
2602
  return this.clone().inotn(width);
2610
2603
  };
2611
- BN4.prototype.setn = function setn(bit, val) {
2604
+ BN3.prototype.setn = function setn(bit, val) {
2612
2605
  assert(typeof bit === "number" && bit >= 0);
2613
2606
  var off = bit / 26 | 0;
2614
2607
  var wbit = bit % 26;
@@ -2620,7 +2613,7 @@ var require_bn = __commonJS({
2620
2613
  }
2621
2614
  return this._strip();
2622
2615
  };
2623
- BN4.prototype.iadd = function iadd(num) {
2616
+ BN3.prototype.iadd = function iadd(num) {
2624
2617
  var r;
2625
2618
  if (this.negative !== 0 && num.negative === 0) {
2626
2619
  this.negative = 0;
@@ -2663,7 +2656,7 @@ var require_bn = __commonJS({
2663
2656
  }
2664
2657
  return this;
2665
2658
  };
2666
- BN4.prototype.add = function add(num) {
2659
+ BN3.prototype.add = function add(num) {
2667
2660
  var res;
2668
2661
  if (num.negative !== 0 && this.negative === 0) {
2669
2662
  num.negative = 0;
@@ -2679,7 +2672,7 @@ var require_bn = __commonJS({
2679
2672
  if (this.length > num.length) return this.clone().iadd(num);
2680
2673
  return num.clone().iadd(this);
2681
2674
  };
2682
- BN4.prototype.isub = function isub(num) {
2675
+ BN3.prototype.isub = function isub(num) {
2683
2676
  if (num.negative !== 0) {
2684
2677
  num.negative = 0;
2685
2678
  var r = this.iadd(num);
@@ -2728,7 +2721,7 @@ var require_bn = __commonJS({
2728
2721
  }
2729
2722
  return this._strip();
2730
2723
  };
2731
- BN4.prototype.sub = function sub(num) {
2724
+ BN3.prototype.sub = function sub(num) {
2732
2725
  return this.clone().isub(num);
2733
2726
  };
2734
2727
  function smallMulTo(self, num, out) {
@@ -3356,7 +3349,7 @@ var require_bn = __commonJS({
3356
3349
  function jumboMulTo(self, num, out) {
3357
3350
  return bigMulTo(self, num, out);
3358
3351
  }
3359
- BN4.prototype.mulTo = function mulTo(num, out) {
3352
+ BN3.prototype.mulTo = function mulTo(num, out) {
3360
3353
  var res;
3361
3354
  var len = this.length + num.length;
3362
3355
  if (this.length === 10 && num.length === 10) {
@@ -3370,20 +3363,20 @@ var require_bn = __commonJS({
3370
3363
  }
3371
3364
  return res;
3372
3365
  };
3373
- BN4.prototype.mul = function mul(num) {
3374
- var out = new BN4(null);
3366
+ BN3.prototype.mul = function mul(num) {
3367
+ var out = new BN3(null);
3375
3368
  out.words = new Array(this.length + num.length);
3376
3369
  return this.mulTo(num, out);
3377
3370
  };
3378
- BN4.prototype.mulf = function mulf(num) {
3379
- var out = new BN4(null);
3371
+ BN3.prototype.mulf = function mulf(num) {
3372
+ var out = new BN3(null);
3380
3373
  out.words = new Array(this.length + num.length);
3381
3374
  return jumboMulTo(this, num, out);
3382
3375
  };
3383
- BN4.prototype.imul = function imul(num) {
3376
+ BN3.prototype.imul = function imul(num) {
3384
3377
  return this.clone().mulTo(num, this);
3385
3378
  };
3386
- BN4.prototype.imuln = function imuln(num) {
3379
+ BN3.prototype.imuln = function imuln(num) {
3387
3380
  var isNegNum = num < 0;
3388
3381
  if (isNegNum) num = -num;
3389
3382
  assert(typeof num === "number");
@@ -3404,18 +3397,18 @@ var require_bn = __commonJS({
3404
3397
  this.length = num === 0 ? 1 : this.length;
3405
3398
  return isNegNum ? this.ineg() : this;
3406
3399
  };
3407
- BN4.prototype.muln = function muln(num) {
3400
+ BN3.prototype.muln = function muln(num) {
3408
3401
  return this.clone().imuln(num);
3409
3402
  };
3410
- BN4.prototype.sqr = function sqr() {
3403
+ BN3.prototype.sqr = function sqr() {
3411
3404
  return this.mul(this);
3412
3405
  };
3413
- BN4.prototype.isqr = function isqr() {
3406
+ BN3.prototype.isqr = function isqr() {
3414
3407
  return this.imul(this.clone());
3415
3408
  };
3416
- BN4.prototype.pow = function pow(num) {
3409
+ BN3.prototype.pow = function pow(num) {
3417
3410
  var w = toBitArray(num);
3418
- if (w.length === 0) return new BN4(1);
3411
+ if (w.length === 0) return new BN3(1);
3419
3412
  var res = this;
3420
3413
  for (var i = 0; i < w.length; i++, res = res.sqr()) {
3421
3414
  if (w[i] !== 0) break;
@@ -3428,7 +3421,7 @@ var require_bn = __commonJS({
3428
3421
  }
3429
3422
  return res;
3430
3423
  };
3431
- BN4.prototype.iushln = function iushln(bits) {
3424
+ BN3.prototype.iushln = function iushln(bits) {
3432
3425
  assert(typeof bits === "number" && bits >= 0);
3433
3426
  var r = bits % 26;
3434
3427
  var s = (bits - r) / 26;
@@ -3458,11 +3451,11 @@ var require_bn = __commonJS({
3458
3451
  }
3459
3452
  return this._strip();
3460
3453
  };
3461
- BN4.prototype.ishln = function ishln(bits) {
3454
+ BN3.prototype.ishln = function ishln(bits) {
3462
3455
  assert(this.negative === 0);
3463
3456
  return this.iushln(bits);
3464
3457
  };
3465
- BN4.prototype.iushrn = function iushrn(bits, hint, extended) {
3458
+ BN3.prototype.iushrn = function iushrn(bits, hint, extended) {
3466
3459
  assert(typeof bits === "number" && bits >= 0);
3467
3460
  var h;
3468
3461
  if (hint) {
@@ -3506,23 +3499,23 @@ var require_bn = __commonJS({
3506
3499
  }
3507
3500
  return this._strip();
3508
3501
  };
3509
- BN4.prototype.ishrn = function ishrn(bits, hint, extended) {
3502
+ BN3.prototype.ishrn = function ishrn(bits, hint, extended) {
3510
3503
  assert(this.negative === 0);
3511
3504
  return this.iushrn(bits, hint, extended);
3512
3505
  };
3513
- BN4.prototype.shln = function shln(bits) {
3506
+ BN3.prototype.shln = function shln(bits) {
3514
3507
  return this.clone().ishln(bits);
3515
3508
  };
3516
- BN4.prototype.ushln = function ushln(bits) {
3509
+ BN3.prototype.ushln = function ushln(bits) {
3517
3510
  return this.clone().iushln(bits);
3518
3511
  };
3519
- BN4.prototype.shrn = function shrn(bits) {
3512
+ BN3.prototype.shrn = function shrn(bits) {
3520
3513
  return this.clone().ishrn(bits);
3521
3514
  };
3522
- BN4.prototype.ushrn = function ushrn(bits) {
3515
+ BN3.prototype.ushrn = function ushrn(bits) {
3523
3516
  return this.clone().iushrn(bits);
3524
3517
  };
3525
- BN4.prototype.testn = function testn(bit) {
3518
+ BN3.prototype.testn = function testn(bit) {
3526
3519
  assert(typeof bit === "number" && bit >= 0);
3527
3520
  var r = bit % 26;
3528
3521
  var s = (bit - r) / 26;
@@ -3531,7 +3524,7 @@ var require_bn = __commonJS({
3531
3524
  var w = this.words[s];
3532
3525
  return !!(w & q);
3533
3526
  };
3534
- BN4.prototype.imaskn = function imaskn(bits) {
3527
+ BN3.prototype.imaskn = function imaskn(bits) {
3535
3528
  assert(typeof bits === "number" && bits >= 0);
3536
3529
  var r = bits % 26;
3537
3530
  var s = (bits - r) / 26;
@@ -3549,10 +3542,10 @@ var require_bn = __commonJS({
3549
3542
  }
3550
3543
  return this._strip();
3551
3544
  };
3552
- BN4.prototype.maskn = function maskn(bits) {
3545
+ BN3.prototype.maskn = function maskn(bits) {
3553
3546
  return this.clone().imaskn(bits);
3554
3547
  };
3555
- BN4.prototype.iaddn = function iaddn(num) {
3548
+ BN3.prototype.iaddn = function iaddn(num) {
3556
3549
  assert(typeof num === "number");
3557
3550
  assert(num < 67108864);
3558
3551
  if (num < 0) return this.isubn(-num);
@@ -3569,7 +3562,7 @@ var require_bn = __commonJS({
3569
3562
  }
3570
3563
  return this._iaddn(num);
3571
3564
  };
3572
- BN4.prototype._iaddn = function _iaddn(num) {
3565
+ BN3.prototype._iaddn = function _iaddn(num) {
3573
3566
  this.words[0] += num;
3574
3567
  for (var i = 0; i < this.length && this.words[i] >= 67108864; i++) {
3575
3568
  this.words[i] -= 67108864;
@@ -3582,7 +3575,7 @@ var require_bn = __commonJS({
3582
3575
  this.length = Math.max(this.length, i + 1);
3583
3576
  return this;
3584
3577
  };
3585
- BN4.prototype.isubn = function isubn(num) {
3578
+ BN3.prototype.isubn = function isubn(num) {
3586
3579
  assert(typeof num === "number");
3587
3580
  assert(num < 67108864);
3588
3581
  if (num < 0) return this.iaddn(-num);
@@ -3604,20 +3597,20 @@ var require_bn = __commonJS({
3604
3597
  }
3605
3598
  return this._strip();
3606
3599
  };
3607
- BN4.prototype.addn = function addn(num) {
3600
+ BN3.prototype.addn = function addn(num) {
3608
3601
  return this.clone().iaddn(num);
3609
3602
  };
3610
- BN4.prototype.subn = function subn(num) {
3603
+ BN3.prototype.subn = function subn(num) {
3611
3604
  return this.clone().isubn(num);
3612
3605
  };
3613
- BN4.prototype.iabs = function iabs() {
3606
+ BN3.prototype.iabs = function iabs() {
3614
3607
  this.negative = 0;
3615
3608
  return this;
3616
3609
  };
3617
- BN4.prototype.abs = function abs() {
3610
+ BN3.prototype.abs = function abs() {
3618
3611
  return this.clone().iabs();
3619
3612
  };
3620
- BN4.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) {
3613
+ BN3.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) {
3621
3614
  var len = num.length + shift;
3622
3615
  var i;
3623
3616
  this._expand(len);
@@ -3646,7 +3639,7 @@ var require_bn = __commonJS({
3646
3639
  this.negative = 1;
3647
3640
  return this._strip();
3648
3641
  };
3649
- BN4.prototype._wordDiv = function _wordDiv(num, mode) {
3642
+ BN3.prototype._wordDiv = function _wordDiv(num, mode) {
3650
3643
  var shift = this.length - num.length;
3651
3644
  var a = this.clone();
3652
3645
  var b = num;
@@ -3661,7 +3654,7 @@ var require_bn = __commonJS({
3661
3654
  var m = a.length - b.length;
3662
3655
  var q;
3663
3656
  if (mode !== "mod") {
3664
- q = new BN4(null);
3657
+ q = new BN3(null);
3665
3658
  q.length = m + 1;
3666
3659
  q.words = new Array(q.length);
3667
3660
  for (var i = 0; i < q.length; i++) {
@@ -3703,12 +3696,12 @@ var require_bn = __commonJS({
3703
3696
  mod: a
3704
3697
  };
3705
3698
  };
3706
- BN4.prototype.divmod = function divmod(num, mode, positive) {
3699
+ BN3.prototype.divmod = function divmod(num, mode, positive) {
3707
3700
  assert(!num.isZero());
3708
3701
  if (this.isZero()) {
3709
3702
  return {
3710
- div: new BN4(0),
3711
- mod: new BN4(0)
3703
+ div: new BN3(0),
3704
+ mod: new BN3(0)
3712
3705
  };
3713
3706
  }
3714
3707
  var div, mod, res;
@@ -3753,7 +3746,7 @@ var require_bn = __commonJS({
3753
3746
  }
3754
3747
  if (num.length > this.length || this.cmp(num) < 0) {
3755
3748
  return {
3756
- div: new BN4(0),
3749
+ div: new BN3(0),
3757
3750
  mod: this
3758
3751
  };
3759
3752
  }
@@ -3767,26 +3760,26 @@ var require_bn = __commonJS({
3767
3760
  if (mode === "mod") {
3768
3761
  return {
3769
3762
  div: null,
3770
- mod: new BN4(this.modrn(num.words[0]))
3763
+ mod: new BN3(this.modrn(num.words[0]))
3771
3764
  };
3772
3765
  }
3773
3766
  return {
3774
3767
  div: this.divn(num.words[0]),
3775
- mod: new BN4(this.modrn(num.words[0]))
3768
+ mod: new BN3(this.modrn(num.words[0]))
3776
3769
  };
3777
3770
  }
3778
3771
  return this._wordDiv(num, mode);
3779
3772
  };
3780
- BN4.prototype.div = function div(num) {
3773
+ BN3.prototype.div = function div(num) {
3781
3774
  return this.divmod(num, "div", false).div;
3782
3775
  };
3783
- BN4.prototype.mod = function mod(num) {
3776
+ BN3.prototype.mod = function mod(num) {
3784
3777
  return this.divmod(num, "mod", false).mod;
3785
3778
  };
3786
- BN4.prototype.umod = function umod(num) {
3779
+ BN3.prototype.umod = function umod(num) {
3787
3780
  return this.divmod(num, "mod", true).mod;
3788
3781
  };
3789
- BN4.prototype.divRound = function divRound(num) {
3782
+ BN3.prototype.divRound = function divRound(num) {
3790
3783
  var dm = this.divmod(num);
3791
3784
  if (dm.mod.isZero()) return dm.div;
3792
3785
  var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
@@ -3796,7 +3789,7 @@ var require_bn = __commonJS({
3796
3789
  if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
3797
3790
  return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
3798
3791
  };
3799
- BN4.prototype.modrn = function modrn(num) {
3792
+ BN3.prototype.modrn = function modrn(num) {
3800
3793
  var isNegNum = num < 0;
3801
3794
  if (isNegNum) num = -num;
3802
3795
  assert(num <= 67108863);
@@ -3807,10 +3800,10 @@ var require_bn = __commonJS({
3807
3800
  }
3808
3801
  return isNegNum ? -acc : acc;
3809
3802
  };
3810
- BN4.prototype.modn = function modn(num) {
3803
+ BN3.prototype.modn = function modn(num) {
3811
3804
  return this.modrn(num);
3812
3805
  };
3813
- BN4.prototype.idivn = function idivn(num) {
3806
+ BN3.prototype.idivn = function idivn(num) {
3814
3807
  var isNegNum = num < 0;
3815
3808
  if (isNegNum) num = -num;
3816
3809
  assert(num <= 67108863);
@@ -3823,10 +3816,10 @@ var require_bn = __commonJS({
3823
3816
  this._strip();
3824
3817
  return isNegNum ? this.ineg() : this;
3825
3818
  };
3826
- BN4.prototype.divn = function divn(num) {
3819
+ BN3.prototype.divn = function divn(num) {
3827
3820
  return this.clone().idivn(num);
3828
3821
  };
3829
- BN4.prototype.egcd = function egcd(p) {
3822
+ BN3.prototype.egcd = function egcd(p) {
3830
3823
  assert(p.negative === 0);
3831
3824
  assert(!p.isZero());
3832
3825
  var x = this;
@@ -3836,10 +3829,10 @@ var require_bn = __commonJS({
3836
3829
  } else {
3837
3830
  x = x.clone();
3838
3831
  }
3839
- var A = new BN4(1);
3840
- var B = new BN4(0);
3841
- var C = new BN4(0);
3842
- var D = new BN4(1);
3832
+ var A = new BN3(1);
3833
+ var B = new BN3(0);
3834
+ var C = new BN3(0);
3835
+ var D = new BN3(1);
3843
3836
  var g = 0;
3844
3837
  while (x.isEven() && y.isEven()) {
3845
3838
  x.iushrn(1);
@@ -3889,7 +3882,7 @@ var require_bn = __commonJS({
3889
3882
  gcd: y.iushln(g)
3890
3883
  };
3891
3884
  };
3892
- BN4.prototype._invmp = function _invmp(p) {
3885
+ BN3.prototype._invmp = function _invmp(p) {
3893
3886
  assert(p.negative === 0);
3894
3887
  assert(!p.isZero());
3895
3888
  var a = this;
@@ -3899,8 +3892,8 @@ var require_bn = __commonJS({
3899
3892
  } else {
3900
3893
  a = a.clone();
3901
3894
  }
3902
- var x1 = new BN4(1);
3903
- var x2 = new BN4(0);
3895
+ var x1 = new BN3(1);
3896
+ var x2 = new BN3(0);
3904
3897
  var delta = b.clone();
3905
3898
  while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
3906
3899
  for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1) ;
@@ -3942,7 +3935,7 @@ var require_bn = __commonJS({
3942
3935
  }
3943
3936
  return res;
3944
3937
  };
3945
- BN4.prototype.gcd = function gcd(num) {
3938
+ BN3.prototype.gcd = function gcd(num) {
3946
3939
  if (this.isZero()) return num.abs();
3947
3940
  if (num.isZero()) return this.abs();
3948
3941
  var a = this.clone();
@@ -3972,19 +3965,19 @@ var require_bn = __commonJS({
3972
3965
  } while (true);
3973
3966
  return b.iushln(shift);
3974
3967
  };
3975
- BN4.prototype.invm = function invm(num) {
3968
+ BN3.prototype.invm = function invm(num) {
3976
3969
  return this.egcd(num).a.umod(num);
3977
3970
  };
3978
- BN4.prototype.isEven = function isEven() {
3971
+ BN3.prototype.isEven = function isEven() {
3979
3972
  return (this.words[0] & 1) === 0;
3980
3973
  };
3981
- BN4.prototype.isOdd = function isOdd() {
3974
+ BN3.prototype.isOdd = function isOdd() {
3982
3975
  return (this.words[0] & 1) === 1;
3983
3976
  };
3984
- BN4.prototype.andln = function andln(num) {
3977
+ BN3.prototype.andln = function andln(num) {
3985
3978
  return this.words[0] & num;
3986
3979
  };
3987
- BN4.prototype.bincn = function bincn(bit) {
3980
+ BN3.prototype.bincn = function bincn(bit) {
3988
3981
  assert(typeof bit === "number");
3989
3982
  var r = bit % 26;
3990
3983
  var s = (bit - r) / 26;
@@ -4008,10 +4001,10 @@ var require_bn = __commonJS({
4008
4001
  }
4009
4002
  return this;
4010
4003
  };
4011
- BN4.prototype.isZero = function isZero() {
4004
+ BN3.prototype.isZero = function isZero() {
4012
4005
  return this.length === 1 && this.words[0] === 0;
4013
4006
  };
4014
- BN4.prototype.cmpn = function cmpn(num) {
4007
+ BN3.prototype.cmpn = function cmpn(num) {
4015
4008
  var negative = num < 0;
4016
4009
  if (this.negative !== 0 && !negative) return -1;
4017
4010
  if (this.negative === 0 && negative) return 1;
@@ -4030,14 +4023,14 @@ var require_bn = __commonJS({
4030
4023
  if (this.negative !== 0) return -res | 0;
4031
4024
  return res;
4032
4025
  };
4033
- BN4.prototype.cmp = function cmp(num) {
4026
+ BN3.prototype.cmp = function cmp(num) {
4034
4027
  if (this.negative !== 0 && num.negative === 0) return -1;
4035
4028
  if (this.negative === 0 && num.negative !== 0) return 1;
4036
4029
  var res = this.ucmp(num);
4037
4030
  if (this.negative !== 0) return -res | 0;
4038
4031
  return res;
4039
4032
  };
4040
- BN4.prototype.ucmp = function ucmp(num) {
4033
+ BN3.prototype.ucmp = function ucmp(num) {
4041
4034
  if (this.length > num.length) return 1;
4042
4035
  if (this.length < num.length) return -1;
4043
4036
  var res = 0;
@@ -4054,112 +4047,112 @@ var require_bn = __commonJS({
4054
4047
  }
4055
4048
  return res;
4056
4049
  };
4057
- BN4.prototype.gtn = function gtn(num) {
4050
+ BN3.prototype.gtn = function gtn(num) {
4058
4051
  return this.cmpn(num) === 1;
4059
4052
  };
4060
- BN4.prototype.gt = function gt(num) {
4053
+ BN3.prototype.gt = function gt(num) {
4061
4054
  return this.cmp(num) === 1;
4062
4055
  };
4063
- BN4.prototype.gten = function gten(num) {
4056
+ BN3.prototype.gten = function gten(num) {
4064
4057
  return this.cmpn(num) >= 0;
4065
4058
  };
4066
- BN4.prototype.gte = function gte(num) {
4059
+ BN3.prototype.gte = function gte(num) {
4067
4060
  return this.cmp(num) >= 0;
4068
4061
  };
4069
- BN4.prototype.ltn = function ltn(num) {
4062
+ BN3.prototype.ltn = function ltn(num) {
4070
4063
  return this.cmpn(num) === -1;
4071
4064
  };
4072
- BN4.prototype.lt = function lt(num) {
4065
+ BN3.prototype.lt = function lt(num) {
4073
4066
  return this.cmp(num) === -1;
4074
4067
  };
4075
- BN4.prototype.lten = function lten(num) {
4068
+ BN3.prototype.lten = function lten(num) {
4076
4069
  return this.cmpn(num) <= 0;
4077
4070
  };
4078
- BN4.prototype.lte = function lte(num) {
4071
+ BN3.prototype.lte = function lte(num) {
4079
4072
  return this.cmp(num) <= 0;
4080
4073
  };
4081
- BN4.prototype.eqn = function eqn(num) {
4074
+ BN3.prototype.eqn = function eqn(num) {
4082
4075
  return this.cmpn(num) === 0;
4083
4076
  };
4084
- BN4.prototype.eq = function eq(num) {
4077
+ BN3.prototype.eq = function eq(num) {
4085
4078
  return this.cmp(num) === 0;
4086
4079
  };
4087
- BN4.red = function red(num) {
4080
+ BN3.red = function red(num) {
4088
4081
  return new Red(num);
4089
4082
  };
4090
- BN4.prototype.toRed = function toRed(ctx) {
4083
+ BN3.prototype.toRed = function toRed(ctx) {
4091
4084
  assert(!this.red, "Already a number in reduction context");
4092
4085
  assert(this.negative === 0, "red works only with positives");
4093
4086
  return ctx.convertTo(this)._forceRed(ctx);
4094
4087
  };
4095
- BN4.prototype.fromRed = function fromRed() {
4088
+ BN3.prototype.fromRed = function fromRed() {
4096
4089
  assert(this.red, "fromRed works only with numbers in reduction context");
4097
4090
  return this.red.convertFrom(this);
4098
4091
  };
4099
- BN4.prototype._forceRed = function _forceRed(ctx) {
4092
+ BN3.prototype._forceRed = function _forceRed(ctx) {
4100
4093
  this.red = ctx;
4101
4094
  return this;
4102
4095
  };
4103
- BN4.prototype.forceRed = function forceRed(ctx) {
4096
+ BN3.prototype.forceRed = function forceRed(ctx) {
4104
4097
  assert(!this.red, "Already a number in reduction context");
4105
4098
  return this._forceRed(ctx);
4106
4099
  };
4107
- BN4.prototype.redAdd = function redAdd(num) {
4100
+ BN3.prototype.redAdd = function redAdd(num) {
4108
4101
  assert(this.red, "redAdd works only with red numbers");
4109
4102
  return this.red.add(this, num);
4110
4103
  };
4111
- BN4.prototype.redIAdd = function redIAdd(num) {
4104
+ BN3.prototype.redIAdd = function redIAdd(num) {
4112
4105
  assert(this.red, "redIAdd works only with red numbers");
4113
4106
  return this.red.iadd(this, num);
4114
4107
  };
4115
- BN4.prototype.redSub = function redSub(num) {
4108
+ BN3.prototype.redSub = function redSub(num) {
4116
4109
  assert(this.red, "redSub works only with red numbers");
4117
4110
  return this.red.sub(this, num);
4118
4111
  };
4119
- BN4.prototype.redISub = function redISub(num) {
4112
+ BN3.prototype.redISub = function redISub(num) {
4120
4113
  assert(this.red, "redISub works only with red numbers");
4121
4114
  return this.red.isub(this, num);
4122
4115
  };
4123
- BN4.prototype.redShl = function redShl(num) {
4116
+ BN3.prototype.redShl = function redShl(num) {
4124
4117
  assert(this.red, "redShl works only with red numbers");
4125
4118
  return this.red.shl(this, num);
4126
4119
  };
4127
- BN4.prototype.redMul = function redMul(num) {
4120
+ BN3.prototype.redMul = function redMul(num) {
4128
4121
  assert(this.red, "redMul works only with red numbers");
4129
4122
  this.red._verify2(this, num);
4130
4123
  return this.red.mul(this, num);
4131
4124
  };
4132
- BN4.prototype.redIMul = function redIMul(num) {
4125
+ BN3.prototype.redIMul = function redIMul(num) {
4133
4126
  assert(this.red, "redMul works only with red numbers");
4134
4127
  this.red._verify2(this, num);
4135
4128
  return this.red.imul(this, num);
4136
4129
  };
4137
- BN4.prototype.redSqr = function redSqr() {
4130
+ BN3.prototype.redSqr = function redSqr() {
4138
4131
  assert(this.red, "redSqr works only with red numbers");
4139
4132
  this.red._verify1(this);
4140
4133
  return this.red.sqr(this);
4141
4134
  };
4142
- BN4.prototype.redISqr = function redISqr() {
4135
+ BN3.prototype.redISqr = function redISqr() {
4143
4136
  assert(this.red, "redISqr works only with red numbers");
4144
4137
  this.red._verify1(this);
4145
4138
  return this.red.isqr(this);
4146
4139
  };
4147
- BN4.prototype.redSqrt = function redSqrt() {
4140
+ BN3.prototype.redSqrt = function redSqrt() {
4148
4141
  assert(this.red, "redSqrt works only with red numbers");
4149
4142
  this.red._verify1(this);
4150
4143
  return this.red.sqrt(this);
4151
4144
  };
4152
- BN4.prototype.redInvm = function redInvm() {
4145
+ BN3.prototype.redInvm = function redInvm() {
4153
4146
  assert(this.red, "redInvm works only with red numbers");
4154
4147
  this.red._verify1(this);
4155
4148
  return this.red.invm(this);
4156
4149
  };
4157
- BN4.prototype.redNeg = function redNeg() {
4150
+ BN3.prototype.redNeg = function redNeg() {
4158
4151
  assert(this.red, "redNeg works only with red numbers");
4159
4152
  this.red._verify1(this);
4160
4153
  return this.red.neg(this);
4161
4154
  };
4162
- BN4.prototype.redPow = function redPow(num) {
4155
+ BN3.prototype.redPow = function redPow(num) {
4163
4156
  assert(this.red && !num.red, "redPow(normalNum)");
4164
4157
  this.red._verify1(this);
4165
4158
  return this.red.pow(this, num);
@@ -4172,13 +4165,13 @@ var require_bn = __commonJS({
4172
4165
  };
4173
4166
  function MPrime(name, p) {
4174
4167
  this.name = name;
4175
- this.p = new BN4(p, 16);
4168
+ this.p = new BN3(p, 16);
4176
4169
  this.n = this.p.bitLength();
4177
- this.k = new BN4(1).iushln(this.n).isub(this.p);
4170
+ this.k = new BN3(1).iushln(this.n).isub(this.p);
4178
4171
  this.tmp = this._tmp();
4179
4172
  }
4180
4173
  MPrime.prototype._tmp = function _tmp() {
4181
- var tmp = new BN4(null);
4174
+ var tmp = new BN3(null);
4182
4175
  tmp.words = new Array(Math.ceil(this.n / 13));
4183
4176
  return tmp;
4184
4177
  };
@@ -4304,7 +4297,7 @@ var require_bn = __commonJS({
4304
4297
  }
4305
4298
  return num;
4306
4299
  };
4307
- BN4._prime = function prime(name) {
4300
+ BN3._prime = function prime(name) {
4308
4301
  if (primes[name]) return primes[name];
4309
4302
  var prime2;
4310
4303
  if (name === "k256") {
@@ -4323,7 +4316,7 @@ var require_bn = __commonJS({
4323
4316
  };
4324
4317
  function Red(m) {
4325
4318
  if (typeof m === "string") {
4326
- var prime = BN4._prime(m);
4319
+ var prime = BN3._prime(m);
4327
4320
  this.m = prime.p;
4328
4321
  this.prime = prime;
4329
4322
  } else {
@@ -4409,7 +4402,7 @@ var require_bn = __commonJS({
4409
4402
  var mod3 = this.m.andln(3);
4410
4403
  assert(mod3 % 2 === 1);
4411
4404
  if (mod3 === 3) {
4412
- var pow = this.m.add(new BN4(1)).iushrn(2);
4405
+ var pow = this.m.add(new BN3(1)).iushrn(2);
4413
4406
  return this.pow(a, pow);
4414
4407
  }
4415
4408
  var q = this.m.subn(1);
@@ -4419,11 +4412,11 @@ var require_bn = __commonJS({
4419
4412
  q.iushrn(1);
4420
4413
  }
4421
4414
  assert(!q.isZero());
4422
- var one = new BN4(1).toRed(this);
4415
+ var one = new BN3(1).toRed(this);
4423
4416
  var nOne = one.redNeg();
4424
4417
  var lpow = this.m.subn(1).iushrn(1);
4425
4418
  var z = this.m.bitLength();
4426
- z = new BN4(2 * z * z).toRed(this);
4419
+ z = new BN3(2 * z * z).toRed(this);
4427
4420
  while (this.pow(z, lpow).cmp(nOne) !== 0) {
4428
4421
  z.redIAdd(nOne);
4429
4422
  }
@@ -4437,7 +4430,7 @@ var require_bn = __commonJS({
4437
4430
  tmp = tmp.redSqr();
4438
4431
  }
4439
4432
  assert(i < m);
4440
- var b = this.pow(c, new BN4(1).iushln(m - i - 1));
4433
+ var b = this.pow(c, new BN3(1).iushln(m - i - 1));
4441
4434
  r = r.redMul(b);
4442
4435
  c = b.redSqr();
4443
4436
  t = t.redMul(c);
@@ -4455,11 +4448,11 @@ var require_bn = __commonJS({
4455
4448
  }
4456
4449
  };
4457
4450
  Red.prototype.pow = function pow(a, num) {
4458
- if (num.isZero()) return new BN4(1).toRed(this);
4451
+ if (num.isZero()) return new BN3(1).toRed(this);
4459
4452
  if (num.cmpn(1) === 0) return a.clone();
4460
4453
  var windowSize = 4;
4461
4454
  var wnd = new Array(1 << windowSize);
4462
- wnd[0] = new BN4(1).toRed(this);
4455
+ wnd[0] = new BN3(1).toRed(this);
4463
4456
  wnd[1] = a;
4464
4457
  for (var i = 2; i < wnd.length; i++) {
4465
4458
  wnd[i] = this.mul(wnd[i - 1], a);
@@ -4503,7 +4496,7 @@ var require_bn = __commonJS({
4503
4496
  res.red = null;
4504
4497
  return res;
4505
4498
  };
4506
- BN4.mont = function mont(num) {
4499
+ BN3.mont = function mont(num) {
4507
4500
  return new Mont(num);
4508
4501
  };
4509
4502
  function Mont(m) {
@@ -4512,7 +4505,7 @@ var require_bn = __commonJS({
4512
4505
  if (this.shift % 26 !== 0) {
4513
4506
  this.shift += 26 - this.shift % 26;
4514
4507
  }
4515
- this.r = new BN4(1).iushln(this.shift);
4508
+ this.r = new BN3(1).iushln(this.shift);
4516
4509
  this.r2 = this.imod(this.r.sqr());
4517
4510
  this.rinv = this.r._invmp(this.m);
4518
4511
  this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
@@ -4546,7 +4539,7 @@ var require_bn = __commonJS({
4546
4539
  return res._forceRed(this);
4547
4540
  };
4548
4541
  Mont.prototype.mul = function mul(a, b) {
4549
- if (a.isZero() || b.isZero()) return new BN4(0)._forceRed(this);
4542
+ if (a.isZero() || b.isZero()) return new BN3(0)._forceRed(this);
4550
4543
  var t = a.mul(b);
4551
4544
  var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
4552
4545
  var u = t.isub(c).iushrn(this.shift);
@@ -4571,7 +4564,7 @@ init_cjs_shims();
4571
4564
 
4572
4565
  // src/client.ts
4573
4566
  init_cjs_shims();
4574
- var import_bn2 = __toESM(require_bn());
4567
+ var import_bn = __toESM(require_bn());
4575
4568
 
4576
4569
  // src/constants.ts
4577
4570
  init_cjs_shims();
@@ -4617,10 +4610,7 @@ var SessionStatus = /* @__PURE__ */ ((SessionStatus2) => {
4617
4610
  return SessionStatus2;
4618
4611
  })(SessionStatus || {});
4619
4612
 
4620
- // src/utils/index.ts
4621
- init_cjs_shims();
4622
-
4623
- // src/utils/enum-utils.ts
4613
+ // src/utils/enum.ts
4624
4614
  init_cjs_shims();
4625
4615
  function getVariant(v) {
4626
4616
  const key = Object.keys(v)[0];
@@ -4686,7 +4676,8 @@ var NodeWallet = class {
4686
4676
  }
4687
4677
  };
4688
4678
 
4689
- // src/utils/index.ts
4679
+ // src/utils/web3.ts
4680
+ init_cjs_shims();
4690
4681
  var SLOTS_PER_EPOCH_MAINNET = 432e3;
4691
4682
  var SLOTS_PER_EPOCH_DEVNET = 4e5;
4692
4683
  function slotToEpoch(slot, cluster) {
@@ -4695,6 +4686,7 @@ function slotToEpoch(slot, cluster) {
4695
4686
  }
4696
4687
 
4697
4688
  // src/history.ts
4689
+ var { bs58 } = anchor.utils.bytes;
4698
4690
  var HistoryManager = class {
4699
4691
  program;
4700
4692
  connection;
@@ -4797,12 +4789,18 @@ var HistoryManager = class {
4797
4789
  }
4798
4790
  decodeInstructionData(data) {
4799
4791
  if (!data) {
4800
- return { type: null, amount: 0 };
4792
+ return {
4793
+ type: null,
4794
+ amount: 0
4795
+ };
4801
4796
  }
4802
4797
  try {
4803
- const buf = bs58__default.default.decode(data);
4798
+ const buf = bs58.decode(data);
4804
4799
  if (buf.length < 16) {
4805
- return { type: null, amount: 0 };
4800
+ return {
4801
+ type: null,
4802
+ amount: 0
4803
+ };
4806
4804
  }
4807
4805
  const disc = buf.slice(0, 8);
4808
4806
  const amountBytes = buf.slice(8, 16);
@@ -5541,9 +5539,6 @@ var jbond_default = {
5541
5539
  },
5542
5540
  {
5543
5541
  name: "global_initialize",
5544
- docs: [
5545
- "----------------------------- Global Instructions ----------------------------"
5546
- ],
5547
5542
  discriminator: [
5548
5543
  30,
5549
5544
  79,
@@ -6421,58 +6416,8 @@ var jbond_default = {
6421
6416
  ]
6422
6417
  };
6423
6418
 
6424
- // src/utils/stake-pool.ts
6425
- init_cjs_shims();
6426
- var import_bn = __toESM(require_bn());
6427
- function createStakePoolManager(stakePoolAccount, user) {
6428
- if (!stakePoolAccount || !stakePoolAccount.account || !stakePoolAccount.account.data) {
6429
- throw new Error("Invalid stake pool account structure");
6430
- }
6431
- const stakePool = stakePoolAccount.account.data;
6432
- const userPoolTokenAccount = splToken.getAssociatedTokenAddressSync(stakePool.poolMint, user, true);
6433
- const [withdrawAuthority] = web3_js.PublicKey.findProgramAddressSync(
6434
- [stakePoolAccount.pubkey.toBuffer(), Buffer.from("withdraw")],
6435
- splStakePool.STAKE_POOL_PROGRAM_ID
6436
- );
6437
- return {
6438
- stakePoolAddress: stakePoolAccount.pubkey,
6439
- depositSol: (lamports) => splStakePool.StakePoolInstruction.depositSol({
6440
- stakePool: stakePoolAccount.pubkey,
6441
- reserveStake: stakePool.reserveStake,
6442
- fundingAccount: user,
6443
- destinationPoolAccount: userPoolTokenAccount,
6444
- managerFeeAccount: stakePool.managerFeeAccount,
6445
- referralPoolAccount: userPoolTokenAccount,
6446
- poolMint: stakePool.poolMint,
6447
- lamports: lamports.toNumber(),
6448
- withdrawAuthority
6449
- }),
6450
- withdrawSol: (poolTokens) => splStakePool.StakePoolInstruction.withdrawSol({
6451
- stakePool: stakePoolAccount.pubkey,
6452
- withdrawAuthority,
6453
- reserveStake: stakePool.reserveStake,
6454
- sourcePoolAccount: userPoolTokenAccount,
6455
- sourceTransferAuthority: user,
6456
- destinationSystemAccount: user,
6457
- managerFeeAccount: stakePool.managerFeeAccount,
6458
- poolMint: stakePool.poolMint,
6459
- poolTokens: poolTokens.toNumber()
6460
- }),
6461
- get exchangeRate() {
6462
- const poolTokenSupply = new import_bn.default(stakePool.poolTokenSupply);
6463
- const totalLamports = new import_bn.default(stakePool.totalLamports);
6464
- if (poolTokenSupply.isZero()) {
6465
- return 0;
6466
- }
6467
- return totalLamports.toNumber() / poolTokenSupply.toNumber();
6468
- },
6469
- get withdrawSolFee() {
6470
- return stakePool.solWithdrawalFee;
6471
- }
6472
- };
6473
- }
6474
-
6475
6419
  // src/client.ts
6420
+ var { bs58: bs582 } = anchor.utils.bytes;
6476
6421
  var BondClientEnv = /* @__PURE__ */ ((BondClientEnv2) => {
6477
6422
  BondClientEnv2["DEV"] = "dev";
6478
6423
  BondClientEnv2["STAGE"] = "stage";
@@ -6903,7 +6848,7 @@ var JBondClient = class _JBondClient {
6903
6848
  }
6904
6849
  async buildBondStartIx(props) {
6905
6850
  const [bondState] = this.pda.bondState(props.bondType, props.name);
6906
- return this.program.methods.sessionStart(new import_bn2.BN(props.duration_secs)).accountsPartial({
6851
+ return this.program.methods.sessionStart(new import_bn.BN(props.duration_secs)).accountsPartial({
6907
6852
  bondState,
6908
6853
  authority: this.program.provider.wallet?.publicKey
6909
6854
  }).instruction();
@@ -7107,10 +7052,6 @@ var JBondClient = class _JBondClient {
7107
7052
  this.programId
7108
7053
  );
7109
7054
  const validatorBond = this.pda.validatorBond(bondType, bondName, vote);
7110
- console.log("Derived legacy validator bond account:", legacyValidatorBondAccount.toBase58());
7111
- console.log("Derived new validator bond account:", validatorBond[0].toBase58());
7112
- console.log("Fetching history for legacy validator bond account:", legacyValidatorBondAccount.toBase58());
7113
- console.log("Fetching history for new validator bond account:", validatorBond[0].toBase58());
7114
7055
  const legacySignatures = (await this.connection.getSignaturesForAddress(
7115
7056
  legacyValidatorBondAccount,
7116
7057
  {
@@ -7168,7 +7109,7 @@ var JBondClient = class _JBondClient {
7168
7109
  let type = null;
7169
7110
  let amount = 0;
7170
7111
  try {
7171
- const dataBuffer = bytes.bs58.decode(data);
7112
+ const dataBuffer = bs582.decode(data);
7172
7113
  if (dataBuffer.length >= 8) {
7173
7114
  const discriminator = dataBuffer.subarray(0, 8);
7174
7115
  const legacyRegisterDiscriminator = this.getInstructionDiscriminator("register");
@@ -7184,14 +7125,12 @@ var JBondClient = class _JBondClient {
7184
7125
  type = "deposit" /* Deposit */;
7185
7126
  if (dataBuffer.length >= 16 && Buffer.from(discriminator).equals(Buffer.from(legacyRegisterDiscriminator))) {
7186
7127
  const amountBytes = dataBuffer.subarray(8, 16);
7187
- const amountBN = new import_bn2.BN(amountBytes, "le");
7128
+ const amountBN = new import_bn.BN(amountBytes, "le");
7188
7129
  amount = amountBN.toNumber() / web3_js.LAMPORTS_PER_SOL;
7189
- } else {
7190
- amount = 0;
7191
7130
  }
7192
7131
  } else if (dataBuffer.length >= 16) {
7193
7132
  const amountBytes = dataBuffer.subarray(8, 16);
7194
- const amountBN = new import_bn2.BN(amountBytes, "le");
7133
+ const amountBN = new import_bn.BN(amountBytes, "le");
7195
7134
  amount = amountBN.toNumber() / web3_js.LAMPORTS_PER_SOL;
7196
7135
  if (Buffer.from(discriminator).equals(Buffer.from(legacyTopUpDiscriminator)) || Buffer.from(discriminator).equals(Buffer.from(bondTopUpDiscriminator))) {
7197
7136
  type = "deposit" /* Deposit */;
@@ -7292,35 +7231,8 @@ var JBondClient = class _JBondClient {
7292
7231
  status: this.getBondStateSessionStatus(state)
7293
7232
  };
7294
7233
  }
7295
- /**
7296
- * Load stake pool account and cache it if not already cached
7297
- * @private
7298
- */
7299
- async loadStakePoolAccount() {
7300
- return await splStakePool.getStakePoolAccount(this.provider.connection, JPOOL_STAKE_POOL);
7301
- }
7302
- /**
7303
- * Manages the interaction with a stake pool, allowing deposits and withdrawals of SOL.
7304
- */
7305
- async stakePoolManager(props) {
7306
- const user = this.ensureUser(props);
7307
- const stakePoolAccount = await this.loadStakePoolAccount();
7308
- return createStakePoolManager(stakePoolAccount, user);
7309
- }
7310
- /**
7311
- * Ensures that a valid user is provided. If a user is not explicitly passed
7312
- * in the properties, it defaults to the provider's public key.
7313
- * Throws an error if no user is available.
7314
- */
7315
- ensureUser(props) {
7316
- const user = props?.user ?? this.provider.publicKey;
7317
- if (!user) {
7318
- throw new Error("User public key is required but not provided");
7319
- }
7320
- return user;
7321
- }
7322
7234
  lamports(n) {
7323
- return new import_bn2.BN((n ?? 0) * web3_js.LAMPORTS_PER_SOL);
7235
+ return new import_bn.BN((n ?? 0) * web3_js.LAMPORTS_PER_SOL);
7324
7236
  }
7325
7237
  };
7326
7238
  /*! Bundled license information: