@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.mjs CHANGED
@@ -1,9 +1,6 @@
1
- import { Program, AnchorProvider, BN } from '@coral-xyz/anchor';
2
- import { bs58 } from '@coral-xyz/anchor/dist/cjs/utils/bytes';
3
- import { getStakePoolAccount, STAKE_POOL_PROGRAM_ID, StakePoolInstruction } from '@solana/spl-stake-pool';
1
+ import { utils, Program, AnchorProvider, BN } from '@coral-xyz/anchor';
4
2
  import { TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID, getAssociatedTokenAddressSync, ACCOUNT_SIZE, AccountLayout } from '@solana/spl-token';
5
3
  import { PublicKey, Transaction, SystemProgram, LAMPORTS_PER_SOL } from '@solana/web3.js';
6
- import bs58$1 from 'bs58';
7
4
 
8
5
  var __create = Object.create;
9
6
  var __defProp = Object.defineProperty;
@@ -1818,8 +1815,8 @@ var require_bn = __commonJS({
1818
1815
  ctor.prototype = new TempCtor();
1819
1816
  ctor.prototype.constructor = ctor;
1820
1817
  }
1821
- function BN4(number, base, endian) {
1822
- if (BN4.isBN(number)) {
1818
+ function BN3(number, base, endian) {
1819
+ if (BN3.isBN(number)) {
1823
1820
  return number;
1824
1821
  }
1825
1822
  this.negative = 0;
@@ -1835,12 +1832,12 @@ var require_bn = __commonJS({
1835
1832
  }
1836
1833
  }
1837
1834
  if (typeof module2 === "object") {
1838
- module2.exports = BN4;
1835
+ module2.exports = BN3;
1839
1836
  } else {
1840
- exports2.BN = BN4;
1837
+ exports2.BN = BN3;
1841
1838
  }
1842
- BN4.BN = BN4;
1843
- BN4.wordSize = 26;
1839
+ BN3.BN = BN3;
1840
+ BN3.wordSize = 26;
1844
1841
  var Buffer2;
1845
1842
  try {
1846
1843
  if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") {
@@ -1850,21 +1847,21 @@ var require_bn = __commonJS({
1850
1847
  }
1851
1848
  } catch (e) {
1852
1849
  }
1853
- BN4.isBN = function isBN(num) {
1854
- if (num instanceof BN4) {
1850
+ BN3.isBN = function isBN(num) {
1851
+ if (num instanceof BN3) {
1855
1852
  return true;
1856
1853
  }
1857
- return num !== null && typeof num === "object" && num.constructor.wordSize === BN4.wordSize && Array.isArray(num.words);
1854
+ return num !== null && typeof num === "object" && num.constructor.wordSize === BN3.wordSize && Array.isArray(num.words);
1858
1855
  };
1859
- BN4.max = function max(left, right) {
1856
+ BN3.max = function max(left, right) {
1860
1857
  if (left.cmp(right) > 0) return left;
1861
1858
  return right;
1862
1859
  };
1863
- BN4.min = function min(left, right) {
1860
+ BN3.min = function min(left, right) {
1864
1861
  if (left.cmp(right) < 0) return left;
1865
1862
  return right;
1866
1863
  };
1867
- BN4.prototype._init = function init(number, base, endian) {
1864
+ BN3.prototype._init = function init(number, base, endian) {
1868
1865
  if (typeof number === "number") {
1869
1866
  return this._initNumber(number, base, endian);
1870
1867
  }
@@ -1892,7 +1889,7 @@ var require_bn = __commonJS({
1892
1889
  }
1893
1890
  }
1894
1891
  };
1895
- BN4.prototype._initNumber = function _initNumber(number, base, endian) {
1892
+ BN3.prototype._initNumber = function _initNumber(number, base, endian) {
1896
1893
  if (number < 0) {
1897
1894
  this.negative = 1;
1898
1895
  number = -number;
@@ -1918,7 +1915,7 @@ var require_bn = __commonJS({
1918
1915
  if (endian !== "le") return;
1919
1916
  this._initArray(this.toArray(), base, endian);
1920
1917
  };
1921
- BN4.prototype._initArray = function _initArray(number, base, endian) {
1918
+ BN3.prototype._initArray = function _initArray(number, base, endian) {
1922
1919
  assert(typeof number.length === "number");
1923
1920
  if (number.length <= 0) {
1924
1921
  this.words = [0];
@@ -1976,7 +1973,7 @@ var require_bn = __commonJS({
1976
1973
  }
1977
1974
  return r;
1978
1975
  }
1979
- BN4.prototype._parseHex = function _parseHex(number, start, endian) {
1976
+ BN3.prototype._parseHex = function _parseHex(number, start, endian) {
1980
1977
  this.length = Math.ceil((number.length - start) / 6);
1981
1978
  this.words = new Array(this.length);
1982
1979
  for (var i = 0; i < this.length; i++) {
@@ -2032,7 +2029,7 @@ var require_bn = __commonJS({
2032
2029
  }
2033
2030
  return r;
2034
2031
  }
2035
- BN4.prototype._parseBase = function _parseBase(number, base, start) {
2032
+ BN3.prototype._parseBase = function _parseBase(number, base, start) {
2036
2033
  this.words = [0];
2037
2034
  this.length = 1;
2038
2035
  for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base) {
@@ -2068,7 +2065,7 @@ var require_bn = __commonJS({
2068
2065
  }
2069
2066
  this._strip();
2070
2067
  };
2071
- BN4.prototype.copy = function copy(dest) {
2068
+ BN3.prototype.copy = function copy(dest) {
2072
2069
  dest.words = new Array(this.length);
2073
2070
  for (var i = 0; i < this.length; i++) {
2074
2071
  dest.words[i] = this.words[i];
@@ -2083,27 +2080,27 @@ var require_bn = __commonJS({
2083
2080
  dest.negative = src.negative;
2084
2081
  dest.red = src.red;
2085
2082
  }
2086
- BN4.prototype._move = function _move(dest) {
2083
+ BN3.prototype._move = function _move(dest) {
2087
2084
  move(dest, this);
2088
2085
  };
2089
- BN4.prototype.clone = function clone() {
2090
- var r = new BN4(null);
2086
+ BN3.prototype.clone = function clone() {
2087
+ var r = new BN3(null);
2091
2088
  this.copy(r);
2092
2089
  return r;
2093
2090
  };
2094
- BN4.prototype._expand = function _expand(size) {
2091
+ BN3.prototype._expand = function _expand(size) {
2095
2092
  while (this.length < size) {
2096
2093
  this.words[this.length++] = 0;
2097
2094
  }
2098
2095
  return this;
2099
2096
  };
2100
- BN4.prototype._strip = function strip() {
2097
+ BN3.prototype._strip = function strip() {
2101
2098
  while (this.length > 1 && this.words[this.length - 1] === 0) {
2102
2099
  this.length--;
2103
2100
  }
2104
2101
  return this._normSign();
2105
2102
  };
2106
- BN4.prototype._normSign = function _normSign() {
2103
+ BN3.prototype._normSign = function _normSign() {
2107
2104
  if (this.length === 1 && this.words[0] === 0) {
2108
2105
  this.negative = 0;
2109
2106
  }
@@ -2111,12 +2108,12 @@ var require_bn = __commonJS({
2111
2108
  };
2112
2109
  if (typeof Symbol !== "undefined" && typeof Symbol.for === "function") {
2113
2110
  try {
2114
- BN4.prototype[Symbol.for("nodejs.util.inspect.custom")] = inspect;
2111
+ BN3.prototype[Symbol.for("nodejs.util.inspect.custom")] = inspect;
2115
2112
  } catch (e) {
2116
- BN4.prototype.inspect = inspect;
2113
+ BN3.prototype.inspect = inspect;
2117
2114
  }
2118
2115
  } else {
2119
- BN4.prototype.inspect = inspect;
2116
+ BN3.prototype.inspect = inspect;
2120
2117
  }
2121
2118
  function inspect() {
2122
2119
  return (this.red ? "<BN-R: " : "<BN: ") + this.toString(16) + ">";
@@ -2227,7 +2224,7 @@ var require_bn = __commonJS({
2227
2224
  52521875,
2228
2225
  60466176
2229
2226
  ];
2230
- BN4.prototype.toString = function toString(base, padding) {
2227
+ BN3.prototype.toString = function toString(base, padding) {
2231
2228
  base = base || 10;
2232
2229
  padding = padding | 0 || 1;
2233
2230
  var out;
@@ -2289,7 +2286,7 @@ var require_bn = __commonJS({
2289
2286
  }
2290
2287
  assert(false, "Base should be between 2 and 36");
2291
2288
  };
2292
- BN4.prototype.toNumber = function toNumber() {
2289
+ BN3.prototype.toNumber = function toNumber() {
2293
2290
  var ret = this.words[0];
2294
2291
  if (this.length === 2) {
2295
2292
  ret += this.words[1] * 67108864;
@@ -2300,15 +2297,15 @@ var require_bn = __commonJS({
2300
2297
  }
2301
2298
  return this.negative !== 0 ? -ret : ret;
2302
2299
  };
2303
- BN4.prototype.toJSON = function toJSON() {
2300
+ BN3.prototype.toJSON = function toJSON() {
2304
2301
  return this.toString(16, 2);
2305
2302
  };
2306
2303
  if (Buffer2) {
2307
- BN4.prototype.toBuffer = function toBuffer(endian, length) {
2304
+ BN3.prototype.toBuffer = function toBuffer(endian, length) {
2308
2305
  return this.toArrayLike(Buffer2, endian, length);
2309
2306
  };
2310
2307
  }
2311
- BN4.prototype.toArray = function toArray(endian, length) {
2308
+ BN3.prototype.toArray = function toArray(endian, length) {
2312
2309
  return this.toArrayLike(Array, endian, length);
2313
2310
  };
2314
2311
  var allocate = function allocate2(ArrayType, size) {
@@ -2317,7 +2314,7 @@ var require_bn = __commonJS({
2317
2314
  }
2318
2315
  return new ArrayType(size);
2319
2316
  };
2320
- BN4.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length) {
2317
+ BN3.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length) {
2321
2318
  this._strip();
2322
2319
  var byteLength = this.byteLength();
2323
2320
  var reqLength = length || Math.max(1, byteLength);
@@ -2328,7 +2325,7 @@ var require_bn = __commonJS({
2328
2325
  this["_toArrayLike" + postfix](res, byteLength);
2329
2326
  return res;
2330
2327
  };
2331
- BN4.prototype._toArrayLikeLE = function _toArrayLikeLE(res, byteLength) {
2328
+ BN3.prototype._toArrayLikeLE = function _toArrayLikeLE(res, byteLength) {
2332
2329
  var position = 0;
2333
2330
  var carry = 0;
2334
2331
  for (var i = 0, shift = 0; i < this.length; i++) {
@@ -2358,7 +2355,7 @@ var require_bn = __commonJS({
2358
2355
  }
2359
2356
  }
2360
2357
  };
2361
- BN4.prototype._toArrayLikeBE = function _toArrayLikeBE(res, byteLength) {
2358
+ BN3.prototype._toArrayLikeBE = function _toArrayLikeBE(res, byteLength) {
2362
2359
  var position = res.length - 1;
2363
2360
  var carry = 0;
2364
2361
  for (var i = 0, shift = 0; i < this.length; i++) {
@@ -2389,11 +2386,11 @@ var require_bn = __commonJS({
2389
2386
  }
2390
2387
  };
2391
2388
  if (Math.clz32) {
2392
- BN4.prototype._countBits = function _countBits(w) {
2389
+ BN3.prototype._countBits = function _countBits(w) {
2393
2390
  return 32 - Math.clz32(w);
2394
2391
  };
2395
2392
  } else {
2396
- BN4.prototype._countBits = function _countBits(w) {
2393
+ BN3.prototype._countBits = function _countBits(w) {
2397
2394
  var t = w;
2398
2395
  var r = 0;
2399
2396
  if (t >= 4096) {
@@ -2415,7 +2412,7 @@ var require_bn = __commonJS({
2415
2412
  return r + t;
2416
2413
  };
2417
2414
  }
2418
- BN4.prototype._zeroBits = function _zeroBits(w) {
2415
+ BN3.prototype._zeroBits = function _zeroBits(w) {
2419
2416
  if (w === 0) return 26;
2420
2417
  var t = w;
2421
2418
  var r = 0;
@@ -2440,7 +2437,7 @@ var require_bn = __commonJS({
2440
2437
  }
2441
2438
  return r;
2442
2439
  };
2443
- BN4.prototype.bitLength = function bitLength() {
2440
+ BN3.prototype.bitLength = function bitLength() {
2444
2441
  var w = this.words[this.length - 1];
2445
2442
  var hi = this._countBits(w);
2446
2443
  return (this.length - 1) * 26 + hi;
@@ -2454,7 +2451,7 @@ var require_bn = __commonJS({
2454
2451
  }
2455
2452
  return w;
2456
2453
  }
2457
- BN4.prototype.zeroBits = function zeroBits() {
2454
+ BN3.prototype.zeroBits = function zeroBits() {
2458
2455
  if (this.isZero()) return 0;
2459
2456
  var r = 0;
2460
2457
  for (var i = 0; i < this.length; i++) {
@@ -2464,34 +2461,34 @@ var require_bn = __commonJS({
2464
2461
  }
2465
2462
  return r;
2466
2463
  };
2467
- BN4.prototype.byteLength = function byteLength() {
2464
+ BN3.prototype.byteLength = function byteLength() {
2468
2465
  return Math.ceil(this.bitLength() / 8);
2469
2466
  };
2470
- BN4.prototype.toTwos = function toTwos(width) {
2467
+ BN3.prototype.toTwos = function toTwos(width) {
2471
2468
  if (this.negative !== 0) {
2472
2469
  return this.abs().inotn(width).iaddn(1);
2473
2470
  }
2474
2471
  return this.clone();
2475
2472
  };
2476
- BN4.prototype.fromTwos = function fromTwos(width) {
2473
+ BN3.prototype.fromTwos = function fromTwos(width) {
2477
2474
  if (this.testn(width - 1)) {
2478
2475
  return this.notn(width).iaddn(1).ineg();
2479
2476
  }
2480
2477
  return this.clone();
2481
2478
  };
2482
- BN4.prototype.isNeg = function isNeg() {
2479
+ BN3.prototype.isNeg = function isNeg() {
2483
2480
  return this.negative !== 0;
2484
2481
  };
2485
- BN4.prototype.neg = function neg() {
2482
+ BN3.prototype.neg = function neg() {
2486
2483
  return this.clone().ineg();
2487
2484
  };
2488
- BN4.prototype.ineg = function ineg() {
2485
+ BN3.prototype.ineg = function ineg() {
2489
2486
  if (!this.isZero()) {
2490
2487
  this.negative ^= 1;
2491
2488
  }
2492
2489
  return this;
2493
2490
  };
2494
- BN4.prototype.iuor = function iuor(num) {
2491
+ BN3.prototype.iuor = function iuor(num) {
2495
2492
  while (this.length < num.length) {
2496
2493
  this.words[this.length++] = 0;
2497
2494
  }
@@ -2500,19 +2497,19 @@ var require_bn = __commonJS({
2500
2497
  }
2501
2498
  return this._strip();
2502
2499
  };
2503
- BN4.prototype.ior = function ior(num) {
2500
+ BN3.prototype.ior = function ior(num) {
2504
2501
  assert((this.negative | num.negative) === 0);
2505
2502
  return this.iuor(num);
2506
2503
  };
2507
- BN4.prototype.or = function or(num) {
2504
+ BN3.prototype.or = function or(num) {
2508
2505
  if (this.length > num.length) return this.clone().ior(num);
2509
2506
  return num.clone().ior(this);
2510
2507
  };
2511
- BN4.prototype.uor = function uor(num) {
2508
+ BN3.prototype.uor = function uor(num) {
2512
2509
  if (this.length > num.length) return this.clone().iuor(num);
2513
2510
  return num.clone().iuor(this);
2514
2511
  };
2515
- BN4.prototype.iuand = function iuand(num) {
2512
+ BN3.prototype.iuand = function iuand(num) {
2516
2513
  var b;
2517
2514
  if (this.length > num.length) {
2518
2515
  b = num;
@@ -2525,19 +2522,19 @@ var require_bn = __commonJS({
2525
2522
  this.length = b.length;
2526
2523
  return this._strip();
2527
2524
  };
2528
- BN4.prototype.iand = function iand(num) {
2525
+ BN3.prototype.iand = function iand(num) {
2529
2526
  assert((this.negative | num.negative) === 0);
2530
2527
  return this.iuand(num);
2531
2528
  };
2532
- BN4.prototype.and = function and(num) {
2529
+ BN3.prototype.and = function and(num) {
2533
2530
  if (this.length > num.length) return this.clone().iand(num);
2534
2531
  return num.clone().iand(this);
2535
2532
  };
2536
- BN4.prototype.uand = function uand(num) {
2533
+ BN3.prototype.uand = function uand(num) {
2537
2534
  if (this.length > num.length) return this.clone().iuand(num);
2538
2535
  return num.clone().iuand(this);
2539
2536
  };
2540
- BN4.prototype.iuxor = function iuxor(num) {
2537
+ BN3.prototype.iuxor = function iuxor(num) {
2541
2538
  var a;
2542
2539
  var b;
2543
2540
  if (this.length > num.length) {
@@ -2558,19 +2555,19 @@ var require_bn = __commonJS({
2558
2555
  this.length = a.length;
2559
2556
  return this._strip();
2560
2557
  };
2561
- BN4.prototype.ixor = function ixor(num) {
2558
+ BN3.prototype.ixor = function ixor(num) {
2562
2559
  assert((this.negative | num.negative) === 0);
2563
2560
  return this.iuxor(num);
2564
2561
  };
2565
- BN4.prototype.xor = function xor(num) {
2562
+ BN3.prototype.xor = function xor(num) {
2566
2563
  if (this.length > num.length) return this.clone().ixor(num);
2567
2564
  return num.clone().ixor(this);
2568
2565
  };
2569
- BN4.prototype.uxor = function uxor(num) {
2566
+ BN3.prototype.uxor = function uxor(num) {
2570
2567
  if (this.length > num.length) return this.clone().iuxor(num);
2571
2568
  return num.clone().iuxor(this);
2572
2569
  };
2573
- BN4.prototype.inotn = function inotn(width) {
2570
+ BN3.prototype.inotn = function inotn(width) {
2574
2571
  assert(typeof width === "number" && width >= 0);
2575
2572
  var bytesNeeded = Math.ceil(width / 26) | 0;
2576
2573
  var bitsLeft = width % 26;
@@ -2586,10 +2583,10 @@ var require_bn = __commonJS({
2586
2583
  }
2587
2584
  return this._strip();
2588
2585
  };
2589
- BN4.prototype.notn = function notn(width) {
2586
+ BN3.prototype.notn = function notn(width) {
2590
2587
  return this.clone().inotn(width);
2591
2588
  };
2592
- BN4.prototype.setn = function setn(bit, val) {
2589
+ BN3.prototype.setn = function setn(bit, val) {
2593
2590
  assert(typeof bit === "number" && bit >= 0);
2594
2591
  var off = bit / 26 | 0;
2595
2592
  var wbit = bit % 26;
@@ -2601,7 +2598,7 @@ var require_bn = __commonJS({
2601
2598
  }
2602
2599
  return this._strip();
2603
2600
  };
2604
- BN4.prototype.iadd = function iadd(num) {
2601
+ BN3.prototype.iadd = function iadd(num) {
2605
2602
  var r;
2606
2603
  if (this.negative !== 0 && num.negative === 0) {
2607
2604
  this.negative = 0;
@@ -2644,7 +2641,7 @@ var require_bn = __commonJS({
2644
2641
  }
2645
2642
  return this;
2646
2643
  };
2647
- BN4.prototype.add = function add(num) {
2644
+ BN3.prototype.add = function add(num) {
2648
2645
  var res;
2649
2646
  if (num.negative !== 0 && this.negative === 0) {
2650
2647
  num.negative = 0;
@@ -2660,7 +2657,7 @@ var require_bn = __commonJS({
2660
2657
  if (this.length > num.length) return this.clone().iadd(num);
2661
2658
  return num.clone().iadd(this);
2662
2659
  };
2663
- BN4.prototype.isub = function isub(num) {
2660
+ BN3.prototype.isub = function isub(num) {
2664
2661
  if (num.negative !== 0) {
2665
2662
  num.negative = 0;
2666
2663
  var r = this.iadd(num);
@@ -2709,7 +2706,7 @@ var require_bn = __commonJS({
2709
2706
  }
2710
2707
  return this._strip();
2711
2708
  };
2712
- BN4.prototype.sub = function sub(num) {
2709
+ BN3.prototype.sub = function sub(num) {
2713
2710
  return this.clone().isub(num);
2714
2711
  };
2715
2712
  function smallMulTo(self, num, out) {
@@ -3337,7 +3334,7 @@ var require_bn = __commonJS({
3337
3334
  function jumboMulTo(self, num, out) {
3338
3335
  return bigMulTo(self, num, out);
3339
3336
  }
3340
- BN4.prototype.mulTo = function mulTo(num, out) {
3337
+ BN3.prototype.mulTo = function mulTo(num, out) {
3341
3338
  var res;
3342
3339
  var len = this.length + num.length;
3343
3340
  if (this.length === 10 && num.length === 10) {
@@ -3351,20 +3348,20 @@ var require_bn = __commonJS({
3351
3348
  }
3352
3349
  return res;
3353
3350
  };
3354
- BN4.prototype.mul = function mul(num) {
3355
- var out = new BN4(null);
3351
+ BN3.prototype.mul = function mul(num) {
3352
+ var out = new BN3(null);
3356
3353
  out.words = new Array(this.length + num.length);
3357
3354
  return this.mulTo(num, out);
3358
3355
  };
3359
- BN4.prototype.mulf = function mulf(num) {
3360
- var out = new BN4(null);
3356
+ BN3.prototype.mulf = function mulf(num) {
3357
+ var out = new BN3(null);
3361
3358
  out.words = new Array(this.length + num.length);
3362
3359
  return jumboMulTo(this, num, out);
3363
3360
  };
3364
- BN4.prototype.imul = function imul(num) {
3361
+ BN3.prototype.imul = function imul(num) {
3365
3362
  return this.clone().mulTo(num, this);
3366
3363
  };
3367
- BN4.prototype.imuln = function imuln(num) {
3364
+ BN3.prototype.imuln = function imuln(num) {
3368
3365
  var isNegNum = num < 0;
3369
3366
  if (isNegNum) num = -num;
3370
3367
  assert(typeof num === "number");
@@ -3385,18 +3382,18 @@ var require_bn = __commonJS({
3385
3382
  this.length = num === 0 ? 1 : this.length;
3386
3383
  return isNegNum ? this.ineg() : this;
3387
3384
  };
3388
- BN4.prototype.muln = function muln(num) {
3385
+ BN3.prototype.muln = function muln(num) {
3389
3386
  return this.clone().imuln(num);
3390
3387
  };
3391
- BN4.prototype.sqr = function sqr() {
3388
+ BN3.prototype.sqr = function sqr() {
3392
3389
  return this.mul(this);
3393
3390
  };
3394
- BN4.prototype.isqr = function isqr() {
3391
+ BN3.prototype.isqr = function isqr() {
3395
3392
  return this.imul(this.clone());
3396
3393
  };
3397
- BN4.prototype.pow = function pow(num) {
3394
+ BN3.prototype.pow = function pow(num) {
3398
3395
  var w = toBitArray(num);
3399
- if (w.length === 0) return new BN4(1);
3396
+ if (w.length === 0) return new BN3(1);
3400
3397
  var res = this;
3401
3398
  for (var i = 0; i < w.length; i++, res = res.sqr()) {
3402
3399
  if (w[i] !== 0) break;
@@ -3409,7 +3406,7 @@ var require_bn = __commonJS({
3409
3406
  }
3410
3407
  return res;
3411
3408
  };
3412
- BN4.prototype.iushln = function iushln(bits) {
3409
+ BN3.prototype.iushln = function iushln(bits) {
3413
3410
  assert(typeof bits === "number" && bits >= 0);
3414
3411
  var r = bits % 26;
3415
3412
  var s = (bits - r) / 26;
@@ -3439,11 +3436,11 @@ var require_bn = __commonJS({
3439
3436
  }
3440
3437
  return this._strip();
3441
3438
  };
3442
- BN4.prototype.ishln = function ishln(bits) {
3439
+ BN3.prototype.ishln = function ishln(bits) {
3443
3440
  assert(this.negative === 0);
3444
3441
  return this.iushln(bits);
3445
3442
  };
3446
- BN4.prototype.iushrn = function iushrn(bits, hint, extended) {
3443
+ BN3.prototype.iushrn = function iushrn(bits, hint, extended) {
3447
3444
  assert(typeof bits === "number" && bits >= 0);
3448
3445
  var h;
3449
3446
  if (hint) {
@@ -3487,23 +3484,23 @@ var require_bn = __commonJS({
3487
3484
  }
3488
3485
  return this._strip();
3489
3486
  };
3490
- BN4.prototype.ishrn = function ishrn(bits, hint, extended) {
3487
+ BN3.prototype.ishrn = function ishrn(bits, hint, extended) {
3491
3488
  assert(this.negative === 0);
3492
3489
  return this.iushrn(bits, hint, extended);
3493
3490
  };
3494
- BN4.prototype.shln = function shln(bits) {
3491
+ BN3.prototype.shln = function shln(bits) {
3495
3492
  return this.clone().ishln(bits);
3496
3493
  };
3497
- BN4.prototype.ushln = function ushln(bits) {
3494
+ BN3.prototype.ushln = function ushln(bits) {
3498
3495
  return this.clone().iushln(bits);
3499
3496
  };
3500
- BN4.prototype.shrn = function shrn(bits) {
3497
+ BN3.prototype.shrn = function shrn(bits) {
3501
3498
  return this.clone().ishrn(bits);
3502
3499
  };
3503
- BN4.prototype.ushrn = function ushrn(bits) {
3500
+ BN3.prototype.ushrn = function ushrn(bits) {
3504
3501
  return this.clone().iushrn(bits);
3505
3502
  };
3506
- BN4.prototype.testn = function testn(bit) {
3503
+ BN3.prototype.testn = function testn(bit) {
3507
3504
  assert(typeof bit === "number" && bit >= 0);
3508
3505
  var r = bit % 26;
3509
3506
  var s = (bit - r) / 26;
@@ -3512,7 +3509,7 @@ var require_bn = __commonJS({
3512
3509
  var w = this.words[s];
3513
3510
  return !!(w & q);
3514
3511
  };
3515
- BN4.prototype.imaskn = function imaskn(bits) {
3512
+ BN3.prototype.imaskn = function imaskn(bits) {
3516
3513
  assert(typeof bits === "number" && bits >= 0);
3517
3514
  var r = bits % 26;
3518
3515
  var s = (bits - r) / 26;
@@ -3530,10 +3527,10 @@ var require_bn = __commonJS({
3530
3527
  }
3531
3528
  return this._strip();
3532
3529
  };
3533
- BN4.prototype.maskn = function maskn(bits) {
3530
+ BN3.prototype.maskn = function maskn(bits) {
3534
3531
  return this.clone().imaskn(bits);
3535
3532
  };
3536
- BN4.prototype.iaddn = function iaddn(num) {
3533
+ BN3.prototype.iaddn = function iaddn(num) {
3537
3534
  assert(typeof num === "number");
3538
3535
  assert(num < 67108864);
3539
3536
  if (num < 0) return this.isubn(-num);
@@ -3550,7 +3547,7 @@ var require_bn = __commonJS({
3550
3547
  }
3551
3548
  return this._iaddn(num);
3552
3549
  };
3553
- BN4.prototype._iaddn = function _iaddn(num) {
3550
+ BN3.prototype._iaddn = function _iaddn(num) {
3554
3551
  this.words[0] += num;
3555
3552
  for (var i = 0; i < this.length && this.words[i] >= 67108864; i++) {
3556
3553
  this.words[i] -= 67108864;
@@ -3563,7 +3560,7 @@ var require_bn = __commonJS({
3563
3560
  this.length = Math.max(this.length, i + 1);
3564
3561
  return this;
3565
3562
  };
3566
- BN4.prototype.isubn = function isubn(num) {
3563
+ BN3.prototype.isubn = function isubn(num) {
3567
3564
  assert(typeof num === "number");
3568
3565
  assert(num < 67108864);
3569
3566
  if (num < 0) return this.iaddn(-num);
@@ -3585,20 +3582,20 @@ var require_bn = __commonJS({
3585
3582
  }
3586
3583
  return this._strip();
3587
3584
  };
3588
- BN4.prototype.addn = function addn(num) {
3585
+ BN3.prototype.addn = function addn(num) {
3589
3586
  return this.clone().iaddn(num);
3590
3587
  };
3591
- BN4.prototype.subn = function subn(num) {
3588
+ BN3.prototype.subn = function subn(num) {
3592
3589
  return this.clone().isubn(num);
3593
3590
  };
3594
- BN4.prototype.iabs = function iabs() {
3591
+ BN3.prototype.iabs = function iabs() {
3595
3592
  this.negative = 0;
3596
3593
  return this;
3597
3594
  };
3598
- BN4.prototype.abs = function abs() {
3595
+ BN3.prototype.abs = function abs() {
3599
3596
  return this.clone().iabs();
3600
3597
  };
3601
- BN4.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) {
3598
+ BN3.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) {
3602
3599
  var len = num.length + shift;
3603
3600
  var i;
3604
3601
  this._expand(len);
@@ -3627,7 +3624,7 @@ var require_bn = __commonJS({
3627
3624
  this.negative = 1;
3628
3625
  return this._strip();
3629
3626
  };
3630
- BN4.prototype._wordDiv = function _wordDiv(num, mode) {
3627
+ BN3.prototype._wordDiv = function _wordDiv(num, mode) {
3631
3628
  var shift = this.length - num.length;
3632
3629
  var a = this.clone();
3633
3630
  var b = num;
@@ -3642,7 +3639,7 @@ var require_bn = __commonJS({
3642
3639
  var m = a.length - b.length;
3643
3640
  var q;
3644
3641
  if (mode !== "mod") {
3645
- q = new BN4(null);
3642
+ q = new BN3(null);
3646
3643
  q.length = m + 1;
3647
3644
  q.words = new Array(q.length);
3648
3645
  for (var i = 0; i < q.length; i++) {
@@ -3684,12 +3681,12 @@ var require_bn = __commonJS({
3684
3681
  mod: a
3685
3682
  };
3686
3683
  };
3687
- BN4.prototype.divmod = function divmod(num, mode, positive) {
3684
+ BN3.prototype.divmod = function divmod(num, mode, positive) {
3688
3685
  assert(!num.isZero());
3689
3686
  if (this.isZero()) {
3690
3687
  return {
3691
- div: new BN4(0),
3692
- mod: new BN4(0)
3688
+ div: new BN3(0),
3689
+ mod: new BN3(0)
3693
3690
  };
3694
3691
  }
3695
3692
  var div, mod, res;
@@ -3734,7 +3731,7 @@ var require_bn = __commonJS({
3734
3731
  }
3735
3732
  if (num.length > this.length || this.cmp(num) < 0) {
3736
3733
  return {
3737
- div: new BN4(0),
3734
+ div: new BN3(0),
3738
3735
  mod: this
3739
3736
  };
3740
3737
  }
@@ -3748,26 +3745,26 @@ var require_bn = __commonJS({
3748
3745
  if (mode === "mod") {
3749
3746
  return {
3750
3747
  div: null,
3751
- mod: new BN4(this.modrn(num.words[0]))
3748
+ mod: new BN3(this.modrn(num.words[0]))
3752
3749
  };
3753
3750
  }
3754
3751
  return {
3755
3752
  div: this.divn(num.words[0]),
3756
- mod: new BN4(this.modrn(num.words[0]))
3753
+ mod: new BN3(this.modrn(num.words[0]))
3757
3754
  };
3758
3755
  }
3759
3756
  return this._wordDiv(num, mode);
3760
3757
  };
3761
- BN4.prototype.div = function div(num) {
3758
+ BN3.prototype.div = function div(num) {
3762
3759
  return this.divmod(num, "div", false).div;
3763
3760
  };
3764
- BN4.prototype.mod = function mod(num) {
3761
+ BN3.prototype.mod = function mod(num) {
3765
3762
  return this.divmod(num, "mod", false).mod;
3766
3763
  };
3767
- BN4.prototype.umod = function umod(num) {
3764
+ BN3.prototype.umod = function umod(num) {
3768
3765
  return this.divmod(num, "mod", true).mod;
3769
3766
  };
3770
- BN4.prototype.divRound = function divRound(num) {
3767
+ BN3.prototype.divRound = function divRound(num) {
3771
3768
  var dm = this.divmod(num);
3772
3769
  if (dm.mod.isZero()) return dm.div;
3773
3770
  var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
@@ -3777,7 +3774,7 @@ var require_bn = __commonJS({
3777
3774
  if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
3778
3775
  return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
3779
3776
  };
3780
- BN4.prototype.modrn = function modrn(num) {
3777
+ BN3.prototype.modrn = function modrn(num) {
3781
3778
  var isNegNum = num < 0;
3782
3779
  if (isNegNum) num = -num;
3783
3780
  assert(num <= 67108863);
@@ -3788,10 +3785,10 @@ var require_bn = __commonJS({
3788
3785
  }
3789
3786
  return isNegNum ? -acc : acc;
3790
3787
  };
3791
- BN4.prototype.modn = function modn(num) {
3788
+ BN3.prototype.modn = function modn(num) {
3792
3789
  return this.modrn(num);
3793
3790
  };
3794
- BN4.prototype.idivn = function idivn(num) {
3791
+ BN3.prototype.idivn = function idivn(num) {
3795
3792
  var isNegNum = num < 0;
3796
3793
  if (isNegNum) num = -num;
3797
3794
  assert(num <= 67108863);
@@ -3804,10 +3801,10 @@ var require_bn = __commonJS({
3804
3801
  this._strip();
3805
3802
  return isNegNum ? this.ineg() : this;
3806
3803
  };
3807
- BN4.prototype.divn = function divn(num) {
3804
+ BN3.prototype.divn = function divn(num) {
3808
3805
  return this.clone().idivn(num);
3809
3806
  };
3810
- BN4.prototype.egcd = function egcd(p) {
3807
+ BN3.prototype.egcd = function egcd(p) {
3811
3808
  assert(p.negative === 0);
3812
3809
  assert(!p.isZero());
3813
3810
  var x = this;
@@ -3817,10 +3814,10 @@ var require_bn = __commonJS({
3817
3814
  } else {
3818
3815
  x = x.clone();
3819
3816
  }
3820
- var A = new BN4(1);
3821
- var B = new BN4(0);
3822
- var C = new BN4(0);
3823
- var D = new BN4(1);
3817
+ var A = new BN3(1);
3818
+ var B = new BN3(0);
3819
+ var C = new BN3(0);
3820
+ var D = new BN3(1);
3824
3821
  var g = 0;
3825
3822
  while (x.isEven() && y.isEven()) {
3826
3823
  x.iushrn(1);
@@ -3870,7 +3867,7 @@ var require_bn = __commonJS({
3870
3867
  gcd: y.iushln(g)
3871
3868
  };
3872
3869
  };
3873
- BN4.prototype._invmp = function _invmp(p) {
3870
+ BN3.prototype._invmp = function _invmp(p) {
3874
3871
  assert(p.negative === 0);
3875
3872
  assert(!p.isZero());
3876
3873
  var a = this;
@@ -3880,8 +3877,8 @@ var require_bn = __commonJS({
3880
3877
  } else {
3881
3878
  a = a.clone();
3882
3879
  }
3883
- var x1 = new BN4(1);
3884
- var x2 = new BN4(0);
3880
+ var x1 = new BN3(1);
3881
+ var x2 = new BN3(0);
3885
3882
  var delta = b.clone();
3886
3883
  while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
3887
3884
  for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1) ;
@@ -3923,7 +3920,7 @@ var require_bn = __commonJS({
3923
3920
  }
3924
3921
  return res;
3925
3922
  };
3926
- BN4.prototype.gcd = function gcd(num) {
3923
+ BN3.prototype.gcd = function gcd(num) {
3927
3924
  if (this.isZero()) return num.abs();
3928
3925
  if (num.isZero()) return this.abs();
3929
3926
  var a = this.clone();
@@ -3953,19 +3950,19 @@ var require_bn = __commonJS({
3953
3950
  } while (true);
3954
3951
  return b.iushln(shift);
3955
3952
  };
3956
- BN4.prototype.invm = function invm(num) {
3953
+ BN3.prototype.invm = function invm(num) {
3957
3954
  return this.egcd(num).a.umod(num);
3958
3955
  };
3959
- BN4.prototype.isEven = function isEven() {
3956
+ BN3.prototype.isEven = function isEven() {
3960
3957
  return (this.words[0] & 1) === 0;
3961
3958
  };
3962
- BN4.prototype.isOdd = function isOdd() {
3959
+ BN3.prototype.isOdd = function isOdd() {
3963
3960
  return (this.words[0] & 1) === 1;
3964
3961
  };
3965
- BN4.prototype.andln = function andln(num) {
3962
+ BN3.prototype.andln = function andln(num) {
3966
3963
  return this.words[0] & num;
3967
3964
  };
3968
- BN4.prototype.bincn = function bincn(bit) {
3965
+ BN3.prototype.bincn = function bincn(bit) {
3969
3966
  assert(typeof bit === "number");
3970
3967
  var r = bit % 26;
3971
3968
  var s = (bit - r) / 26;
@@ -3989,10 +3986,10 @@ var require_bn = __commonJS({
3989
3986
  }
3990
3987
  return this;
3991
3988
  };
3992
- BN4.prototype.isZero = function isZero() {
3989
+ BN3.prototype.isZero = function isZero() {
3993
3990
  return this.length === 1 && this.words[0] === 0;
3994
3991
  };
3995
- BN4.prototype.cmpn = function cmpn(num) {
3992
+ BN3.prototype.cmpn = function cmpn(num) {
3996
3993
  var negative = num < 0;
3997
3994
  if (this.negative !== 0 && !negative) return -1;
3998
3995
  if (this.negative === 0 && negative) return 1;
@@ -4011,14 +4008,14 @@ var require_bn = __commonJS({
4011
4008
  if (this.negative !== 0) return -res | 0;
4012
4009
  return res;
4013
4010
  };
4014
- BN4.prototype.cmp = function cmp(num) {
4011
+ BN3.prototype.cmp = function cmp(num) {
4015
4012
  if (this.negative !== 0 && num.negative === 0) return -1;
4016
4013
  if (this.negative === 0 && num.negative !== 0) return 1;
4017
4014
  var res = this.ucmp(num);
4018
4015
  if (this.negative !== 0) return -res | 0;
4019
4016
  return res;
4020
4017
  };
4021
- BN4.prototype.ucmp = function ucmp(num) {
4018
+ BN3.prototype.ucmp = function ucmp(num) {
4022
4019
  if (this.length > num.length) return 1;
4023
4020
  if (this.length < num.length) return -1;
4024
4021
  var res = 0;
@@ -4035,112 +4032,112 @@ var require_bn = __commonJS({
4035
4032
  }
4036
4033
  return res;
4037
4034
  };
4038
- BN4.prototype.gtn = function gtn(num) {
4035
+ BN3.prototype.gtn = function gtn(num) {
4039
4036
  return this.cmpn(num) === 1;
4040
4037
  };
4041
- BN4.prototype.gt = function gt(num) {
4038
+ BN3.prototype.gt = function gt(num) {
4042
4039
  return this.cmp(num) === 1;
4043
4040
  };
4044
- BN4.prototype.gten = function gten(num) {
4041
+ BN3.prototype.gten = function gten(num) {
4045
4042
  return this.cmpn(num) >= 0;
4046
4043
  };
4047
- BN4.prototype.gte = function gte(num) {
4044
+ BN3.prototype.gte = function gte(num) {
4048
4045
  return this.cmp(num) >= 0;
4049
4046
  };
4050
- BN4.prototype.ltn = function ltn(num) {
4047
+ BN3.prototype.ltn = function ltn(num) {
4051
4048
  return this.cmpn(num) === -1;
4052
4049
  };
4053
- BN4.prototype.lt = function lt(num) {
4050
+ BN3.prototype.lt = function lt(num) {
4054
4051
  return this.cmp(num) === -1;
4055
4052
  };
4056
- BN4.prototype.lten = function lten(num) {
4053
+ BN3.prototype.lten = function lten(num) {
4057
4054
  return this.cmpn(num) <= 0;
4058
4055
  };
4059
- BN4.prototype.lte = function lte(num) {
4056
+ BN3.prototype.lte = function lte(num) {
4060
4057
  return this.cmp(num) <= 0;
4061
4058
  };
4062
- BN4.prototype.eqn = function eqn(num) {
4059
+ BN3.prototype.eqn = function eqn(num) {
4063
4060
  return this.cmpn(num) === 0;
4064
4061
  };
4065
- BN4.prototype.eq = function eq(num) {
4062
+ BN3.prototype.eq = function eq(num) {
4066
4063
  return this.cmp(num) === 0;
4067
4064
  };
4068
- BN4.red = function red(num) {
4065
+ BN3.red = function red(num) {
4069
4066
  return new Red(num);
4070
4067
  };
4071
- BN4.prototype.toRed = function toRed(ctx) {
4068
+ BN3.prototype.toRed = function toRed(ctx) {
4072
4069
  assert(!this.red, "Already a number in reduction context");
4073
4070
  assert(this.negative === 0, "red works only with positives");
4074
4071
  return ctx.convertTo(this)._forceRed(ctx);
4075
4072
  };
4076
- BN4.prototype.fromRed = function fromRed() {
4073
+ BN3.prototype.fromRed = function fromRed() {
4077
4074
  assert(this.red, "fromRed works only with numbers in reduction context");
4078
4075
  return this.red.convertFrom(this);
4079
4076
  };
4080
- BN4.prototype._forceRed = function _forceRed(ctx) {
4077
+ BN3.prototype._forceRed = function _forceRed(ctx) {
4081
4078
  this.red = ctx;
4082
4079
  return this;
4083
4080
  };
4084
- BN4.prototype.forceRed = function forceRed(ctx) {
4081
+ BN3.prototype.forceRed = function forceRed(ctx) {
4085
4082
  assert(!this.red, "Already a number in reduction context");
4086
4083
  return this._forceRed(ctx);
4087
4084
  };
4088
- BN4.prototype.redAdd = function redAdd(num) {
4085
+ BN3.prototype.redAdd = function redAdd(num) {
4089
4086
  assert(this.red, "redAdd works only with red numbers");
4090
4087
  return this.red.add(this, num);
4091
4088
  };
4092
- BN4.prototype.redIAdd = function redIAdd(num) {
4089
+ BN3.prototype.redIAdd = function redIAdd(num) {
4093
4090
  assert(this.red, "redIAdd works only with red numbers");
4094
4091
  return this.red.iadd(this, num);
4095
4092
  };
4096
- BN4.prototype.redSub = function redSub(num) {
4093
+ BN3.prototype.redSub = function redSub(num) {
4097
4094
  assert(this.red, "redSub works only with red numbers");
4098
4095
  return this.red.sub(this, num);
4099
4096
  };
4100
- BN4.prototype.redISub = function redISub(num) {
4097
+ BN3.prototype.redISub = function redISub(num) {
4101
4098
  assert(this.red, "redISub works only with red numbers");
4102
4099
  return this.red.isub(this, num);
4103
4100
  };
4104
- BN4.prototype.redShl = function redShl(num) {
4101
+ BN3.prototype.redShl = function redShl(num) {
4105
4102
  assert(this.red, "redShl works only with red numbers");
4106
4103
  return this.red.shl(this, num);
4107
4104
  };
4108
- BN4.prototype.redMul = function redMul(num) {
4105
+ BN3.prototype.redMul = function redMul(num) {
4109
4106
  assert(this.red, "redMul works only with red numbers");
4110
4107
  this.red._verify2(this, num);
4111
4108
  return this.red.mul(this, num);
4112
4109
  };
4113
- BN4.prototype.redIMul = function redIMul(num) {
4110
+ BN3.prototype.redIMul = function redIMul(num) {
4114
4111
  assert(this.red, "redMul works only with red numbers");
4115
4112
  this.red._verify2(this, num);
4116
4113
  return this.red.imul(this, num);
4117
4114
  };
4118
- BN4.prototype.redSqr = function redSqr() {
4115
+ BN3.prototype.redSqr = function redSqr() {
4119
4116
  assert(this.red, "redSqr works only with red numbers");
4120
4117
  this.red._verify1(this);
4121
4118
  return this.red.sqr(this);
4122
4119
  };
4123
- BN4.prototype.redISqr = function redISqr() {
4120
+ BN3.prototype.redISqr = function redISqr() {
4124
4121
  assert(this.red, "redISqr works only with red numbers");
4125
4122
  this.red._verify1(this);
4126
4123
  return this.red.isqr(this);
4127
4124
  };
4128
- BN4.prototype.redSqrt = function redSqrt() {
4125
+ BN3.prototype.redSqrt = function redSqrt() {
4129
4126
  assert(this.red, "redSqrt works only with red numbers");
4130
4127
  this.red._verify1(this);
4131
4128
  return this.red.sqrt(this);
4132
4129
  };
4133
- BN4.prototype.redInvm = function redInvm() {
4130
+ BN3.prototype.redInvm = function redInvm() {
4134
4131
  assert(this.red, "redInvm works only with red numbers");
4135
4132
  this.red._verify1(this);
4136
4133
  return this.red.invm(this);
4137
4134
  };
4138
- BN4.prototype.redNeg = function redNeg() {
4135
+ BN3.prototype.redNeg = function redNeg() {
4139
4136
  assert(this.red, "redNeg works only with red numbers");
4140
4137
  this.red._verify1(this);
4141
4138
  return this.red.neg(this);
4142
4139
  };
4143
- BN4.prototype.redPow = function redPow(num) {
4140
+ BN3.prototype.redPow = function redPow(num) {
4144
4141
  assert(this.red && !num.red, "redPow(normalNum)");
4145
4142
  this.red._verify1(this);
4146
4143
  return this.red.pow(this, num);
@@ -4153,13 +4150,13 @@ var require_bn = __commonJS({
4153
4150
  };
4154
4151
  function MPrime(name, p) {
4155
4152
  this.name = name;
4156
- this.p = new BN4(p, 16);
4153
+ this.p = new BN3(p, 16);
4157
4154
  this.n = this.p.bitLength();
4158
- this.k = new BN4(1).iushln(this.n).isub(this.p);
4155
+ this.k = new BN3(1).iushln(this.n).isub(this.p);
4159
4156
  this.tmp = this._tmp();
4160
4157
  }
4161
4158
  MPrime.prototype._tmp = function _tmp() {
4162
- var tmp = new BN4(null);
4159
+ var tmp = new BN3(null);
4163
4160
  tmp.words = new Array(Math.ceil(this.n / 13));
4164
4161
  return tmp;
4165
4162
  };
@@ -4285,7 +4282,7 @@ var require_bn = __commonJS({
4285
4282
  }
4286
4283
  return num;
4287
4284
  };
4288
- BN4._prime = function prime(name) {
4285
+ BN3._prime = function prime(name) {
4289
4286
  if (primes[name]) return primes[name];
4290
4287
  var prime2;
4291
4288
  if (name === "k256") {
@@ -4304,7 +4301,7 @@ var require_bn = __commonJS({
4304
4301
  };
4305
4302
  function Red(m) {
4306
4303
  if (typeof m === "string") {
4307
- var prime = BN4._prime(m);
4304
+ var prime = BN3._prime(m);
4308
4305
  this.m = prime.p;
4309
4306
  this.prime = prime;
4310
4307
  } else {
@@ -4390,7 +4387,7 @@ var require_bn = __commonJS({
4390
4387
  var mod3 = this.m.andln(3);
4391
4388
  assert(mod3 % 2 === 1);
4392
4389
  if (mod3 === 3) {
4393
- var pow = this.m.add(new BN4(1)).iushrn(2);
4390
+ var pow = this.m.add(new BN3(1)).iushrn(2);
4394
4391
  return this.pow(a, pow);
4395
4392
  }
4396
4393
  var q = this.m.subn(1);
@@ -4400,11 +4397,11 @@ var require_bn = __commonJS({
4400
4397
  q.iushrn(1);
4401
4398
  }
4402
4399
  assert(!q.isZero());
4403
- var one = new BN4(1).toRed(this);
4400
+ var one = new BN3(1).toRed(this);
4404
4401
  var nOne = one.redNeg();
4405
4402
  var lpow = this.m.subn(1).iushrn(1);
4406
4403
  var z = this.m.bitLength();
4407
- z = new BN4(2 * z * z).toRed(this);
4404
+ z = new BN3(2 * z * z).toRed(this);
4408
4405
  while (this.pow(z, lpow).cmp(nOne) !== 0) {
4409
4406
  z.redIAdd(nOne);
4410
4407
  }
@@ -4418,7 +4415,7 @@ var require_bn = __commonJS({
4418
4415
  tmp = tmp.redSqr();
4419
4416
  }
4420
4417
  assert(i < m);
4421
- var b = this.pow(c, new BN4(1).iushln(m - i - 1));
4418
+ var b = this.pow(c, new BN3(1).iushln(m - i - 1));
4422
4419
  r = r.redMul(b);
4423
4420
  c = b.redSqr();
4424
4421
  t = t.redMul(c);
@@ -4436,11 +4433,11 @@ var require_bn = __commonJS({
4436
4433
  }
4437
4434
  };
4438
4435
  Red.prototype.pow = function pow(a, num) {
4439
- if (num.isZero()) return new BN4(1).toRed(this);
4436
+ if (num.isZero()) return new BN3(1).toRed(this);
4440
4437
  if (num.cmpn(1) === 0) return a.clone();
4441
4438
  var windowSize = 4;
4442
4439
  var wnd = new Array(1 << windowSize);
4443
- wnd[0] = new BN4(1).toRed(this);
4440
+ wnd[0] = new BN3(1).toRed(this);
4444
4441
  wnd[1] = a;
4445
4442
  for (var i = 2; i < wnd.length; i++) {
4446
4443
  wnd[i] = this.mul(wnd[i - 1], a);
@@ -4484,7 +4481,7 @@ var require_bn = __commonJS({
4484
4481
  res.red = null;
4485
4482
  return res;
4486
4483
  };
4487
- BN4.mont = function mont(num) {
4484
+ BN3.mont = function mont(num) {
4488
4485
  return new Mont(num);
4489
4486
  };
4490
4487
  function Mont(m) {
@@ -4493,7 +4490,7 @@ var require_bn = __commonJS({
4493
4490
  if (this.shift % 26 !== 0) {
4494
4491
  this.shift += 26 - this.shift % 26;
4495
4492
  }
4496
- this.r = new BN4(1).iushln(this.shift);
4493
+ this.r = new BN3(1).iushln(this.shift);
4497
4494
  this.r2 = this.imod(this.r.sqr());
4498
4495
  this.rinv = this.r._invmp(this.m);
4499
4496
  this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
@@ -4527,7 +4524,7 @@ var require_bn = __commonJS({
4527
4524
  return res._forceRed(this);
4528
4525
  };
4529
4526
  Mont.prototype.mul = function mul(a, b) {
4530
- if (a.isZero() || b.isZero()) return new BN4(0)._forceRed(this);
4527
+ if (a.isZero() || b.isZero()) return new BN3(0)._forceRed(this);
4531
4528
  var t = a.mul(b);
4532
4529
  var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
4533
4530
  var u = t.isub(c).iushrn(this.shift);
@@ -4548,7 +4545,7 @@ var require_bn = __commonJS({
4548
4545
  });
4549
4546
 
4550
4547
  // src/client.ts
4551
- var import_bn2 = __toESM(require_bn());
4548
+ var import_bn = __toESM(require_bn());
4552
4549
  var JPOOL_STAKE_POOL = new PublicKey("CtMyWsrUtAwXWiGr9WjHT5fC3p3fgV8cyGpLTo2LJzG1");
4553
4550
  var Seeds = /* @__PURE__ */ ((Seeds2) => {
4554
4551
  Seeds2["GlobalState"] = "global_state";
@@ -4587,7 +4584,7 @@ var SessionStatus = /* @__PURE__ */ ((SessionStatus2) => {
4587
4584
  return SessionStatus2;
4588
4585
  })(SessionStatus || {});
4589
4586
 
4590
- // src/utils/enum-utils.ts
4587
+ // src/utils/enum.ts
4591
4588
  function getVariant(v) {
4592
4589
  const key = Object.keys(v)[0];
4593
4590
  return [key, v[key]];
@@ -4651,7 +4648,7 @@ var NodeWallet = class {
4651
4648
  }
4652
4649
  };
4653
4650
 
4654
- // src/utils/index.ts
4651
+ // src/utils/web3.ts
4655
4652
  var SLOTS_PER_EPOCH_MAINNET = 432e3;
4656
4653
  var SLOTS_PER_EPOCH_DEVNET = 4e5;
4657
4654
  function slotToEpoch(slot, cluster) {
@@ -4660,6 +4657,7 @@ function slotToEpoch(slot, cluster) {
4660
4657
  }
4661
4658
 
4662
4659
  // src/history.ts
4660
+ var { bs58 } = utils.bytes;
4663
4661
  var HistoryManager = class {
4664
4662
  program;
4665
4663
  connection;
@@ -4762,12 +4760,18 @@ var HistoryManager = class {
4762
4760
  }
4763
4761
  decodeInstructionData(data) {
4764
4762
  if (!data) {
4765
- return { type: null, amount: 0 };
4763
+ return {
4764
+ type: null,
4765
+ amount: 0
4766
+ };
4766
4767
  }
4767
4768
  try {
4768
- const buf = bs58$1.decode(data);
4769
+ const buf = bs58.decode(data);
4769
4770
  if (buf.length < 16) {
4770
- return { type: null, amount: 0 };
4771
+ return {
4772
+ type: null,
4773
+ amount: 0
4774
+ };
4771
4775
  }
4772
4776
  const disc = buf.slice(0, 8);
4773
4777
  const amountBytes = buf.slice(8, 16);
@@ -5506,9 +5510,6 @@ var jbond_default = {
5506
5510
  },
5507
5511
  {
5508
5512
  name: "global_initialize",
5509
- docs: [
5510
- "----------------------------- Global Instructions ----------------------------"
5511
- ],
5512
5513
  discriminator: [
5513
5514
  30,
5514
5515
  79,
@@ -6386,57 +6387,8 @@ var jbond_default = {
6386
6387
  ]
6387
6388
  };
6388
6389
 
6389
- // src/utils/stake-pool.ts
6390
- var import_bn = __toESM(require_bn());
6391
- function createStakePoolManager(stakePoolAccount, user) {
6392
- if (!stakePoolAccount || !stakePoolAccount.account || !stakePoolAccount.account.data) {
6393
- throw new Error("Invalid stake pool account structure");
6394
- }
6395
- const stakePool = stakePoolAccount.account.data;
6396
- const userPoolTokenAccount = getAssociatedTokenAddressSync(stakePool.poolMint, user, true);
6397
- const [withdrawAuthority] = PublicKey.findProgramAddressSync(
6398
- [stakePoolAccount.pubkey.toBuffer(), Buffer.from("withdraw")],
6399
- STAKE_POOL_PROGRAM_ID
6400
- );
6401
- return {
6402
- stakePoolAddress: stakePoolAccount.pubkey,
6403
- depositSol: (lamports) => StakePoolInstruction.depositSol({
6404
- stakePool: stakePoolAccount.pubkey,
6405
- reserveStake: stakePool.reserveStake,
6406
- fundingAccount: user,
6407
- destinationPoolAccount: userPoolTokenAccount,
6408
- managerFeeAccount: stakePool.managerFeeAccount,
6409
- referralPoolAccount: userPoolTokenAccount,
6410
- poolMint: stakePool.poolMint,
6411
- lamports: lamports.toNumber(),
6412
- withdrawAuthority
6413
- }),
6414
- withdrawSol: (poolTokens) => StakePoolInstruction.withdrawSol({
6415
- stakePool: stakePoolAccount.pubkey,
6416
- withdrawAuthority,
6417
- reserveStake: stakePool.reserveStake,
6418
- sourcePoolAccount: userPoolTokenAccount,
6419
- sourceTransferAuthority: user,
6420
- destinationSystemAccount: user,
6421
- managerFeeAccount: stakePool.managerFeeAccount,
6422
- poolMint: stakePool.poolMint,
6423
- poolTokens: poolTokens.toNumber()
6424
- }),
6425
- get exchangeRate() {
6426
- const poolTokenSupply = new import_bn.default(stakePool.poolTokenSupply);
6427
- const totalLamports = new import_bn.default(stakePool.totalLamports);
6428
- if (poolTokenSupply.isZero()) {
6429
- return 0;
6430
- }
6431
- return totalLamports.toNumber() / poolTokenSupply.toNumber();
6432
- },
6433
- get withdrawSolFee() {
6434
- return stakePool.solWithdrawalFee;
6435
- }
6436
- };
6437
- }
6438
-
6439
6390
  // src/client.ts
6391
+ var { bs58: bs582 } = utils.bytes;
6440
6392
  var BondClientEnv = /* @__PURE__ */ ((BondClientEnv2) => {
6441
6393
  BondClientEnv2["DEV"] = "dev";
6442
6394
  BondClientEnv2["STAGE"] = "stage";
@@ -6867,7 +6819,7 @@ var JBondClient = class _JBondClient {
6867
6819
  }
6868
6820
  async buildBondStartIx(props) {
6869
6821
  const [bondState] = this.pda.bondState(props.bondType, props.name);
6870
- return this.program.methods.sessionStart(new import_bn2.BN(props.duration_secs)).accountsPartial({
6822
+ return this.program.methods.sessionStart(new import_bn.BN(props.duration_secs)).accountsPartial({
6871
6823
  bondState,
6872
6824
  authority: this.program.provider.wallet?.publicKey
6873
6825
  }).instruction();
@@ -7071,10 +7023,6 @@ var JBondClient = class _JBondClient {
7071
7023
  this.programId
7072
7024
  );
7073
7025
  const validatorBond = this.pda.validatorBond(bondType, bondName, vote);
7074
- console.log("Derived legacy validator bond account:", legacyValidatorBondAccount.toBase58());
7075
- console.log("Derived new validator bond account:", validatorBond[0].toBase58());
7076
- console.log("Fetching history for legacy validator bond account:", legacyValidatorBondAccount.toBase58());
7077
- console.log("Fetching history for new validator bond account:", validatorBond[0].toBase58());
7078
7026
  const legacySignatures = (await this.connection.getSignaturesForAddress(
7079
7027
  legacyValidatorBondAccount,
7080
7028
  {
@@ -7132,7 +7080,7 @@ var JBondClient = class _JBondClient {
7132
7080
  let type = null;
7133
7081
  let amount = 0;
7134
7082
  try {
7135
- const dataBuffer = bs58.decode(data);
7083
+ const dataBuffer = bs582.decode(data);
7136
7084
  if (dataBuffer.length >= 8) {
7137
7085
  const discriminator = dataBuffer.subarray(0, 8);
7138
7086
  const legacyRegisterDiscriminator = this.getInstructionDiscriminator("register");
@@ -7148,14 +7096,12 @@ var JBondClient = class _JBondClient {
7148
7096
  type = "deposit" /* Deposit */;
7149
7097
  if (dataBuffer.length >= 16 && Buffer.from(discriminator).equals(Buffer.from(legacyRegisterDiscriminator))) {
7150
7098
  const amountBytes = dataBuffer.subarray(8, 16);
7151
- const amountBN = new import_bn2.BN(amountBytes, "le");
7099
+ const amountBN = new import_bn.BN(amountBytes, "le");
7152
7100
  amount = amountBN.toNumber() / LAMPORTS_PER_SOL;
7153
- } else {
7154
- amount = 0;
7155
7101
  }
7156
7102
  } else if (dataBuffer.length >= 16) {
7157
7103
  const amountBytes = dataBuffer.subarray(8, 16);
7158
- const amountBN = new import_bn2.BN(amountBytes, "le");
7104
+ const amountBN = new import_bn.BN(amountBytes, "le");
7159
7105
  amount = amountBN.toNumber() / LAMPORTS_PER_SOL;
7160
7106
  if (Buffer.from(discriminator).equals(Buffer.from(legacyTopUpDiscriminator)) || Buffer.from(discriminator).equals(Buffer.from(bondTopUpDiscriminator))) {
7161
7107
  type = "deposit" /* Deposit */;
@@ -7256,35 +7202,8 @@ var JBondClient = class _JBondClient {
7256
7202
  status: this.getBondStateSessionStatus(state)
7257
7203
  };
7258
7204
  }
7259
- /**
7260
- * Load stake pool account and cache it if not already cached
7261
- * @private
7262
- */
7263
- async loadStakePoolAccount() {
7264
- return await getStakePoolAccount(this.provider.connection, JPOOL_STAKE_POOL);
7265
- }
7266
- /**
7267
- * Manages the interaction with a stake pool, allowing deposits and withdrawals of SOL.
7268
- */
7269
- async stakePoolManager(props) {
7270
- const user = this.ensureUser(props);
7271
- const stakePoolAccount = await this.loadStakePoolAccount();
7272
- return createStakePoolManager(stakePoolAccount, user);
7273
- }
7274
- /**
7275
- * Ensures that a valid user is provided. If a user is not explicitly passed
7276
- * in the properties, it defaults to the provider's public key.
7277
- * Throws an error if no user is available.
7278
- */
7279
- ensureUser(props) {
7280
- const user = props?.user ?? this.provider.publicKey;
7281
- if (!user) {
7282
- throw new Error("User public key is required but not provided");
7283
- }
7284
- return user;
7285
- }
7286
7205
  lamports(n) {
7287
- return new import_bn2.BN((n ?? 0) * LAMPORTS_PER_SOL);
7206
+ return new import_bn.BN((n ?? 0) * LAMPORTS_PER_SOL);
7288
7207
  }
7289
7208
  };
7290
7209
  /*! Bundled license information: