@jpool/bond-sdk 0.10.1 → 0.10.3
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.d.mts +2 -32
- package/dist/index.d.ts +2 -32
- package/dist/index.js +189 -273
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +190 -273
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
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
6
|
var bs58 = require('bs58');
|
|
@@ -1837,8 +1835,8 @@ var require_bn = __commonJS({
|
|
|
1837
1835
|
ctor.prototype = new TempCtor();
|
|
1838
1836
|
ctor.prototype.constructor = ctor;
|
|
1839
1837
|
}
|
|
1840
|
-
function
|
|
1841
|
-
if (
|
|
1838
|
+
function BN3(number, base, endian) {
|
|
1839
|
+
if (BN3.isBN(number)) {
|
|
1842
1840
|
return number;
|
|
1843
1841
|
}
|
|
1844
1842
|
this.negative = 0;
|
|
@@ -1854,12 +1852,12 @@ var require_bn = __commonJS({
|
|
|
1854
1852
|
}
|
|
1855
1853
|
}
|
|
1856
1854
|
if (typeof module2 === "object") {
|
|
1857
|
-
module2.exports =
|
|
1855
|
+
module2.exports = BN3;
|
|
1858
1856
|
} else {
|
|
1859
|
-
exports2.BN =
|
|
1857
|
+
exports2.BN = BN3;
|
|
1860
1858
|
}
|
|
1861
|
-
|
|
1862
|
-
|
|
1859
|
+
BN3.BN = BN3;
|
|
1860
|
+
BN3.wordSize = 26;
|
|
1863
1861
|
var Buffer2;
|
|
1864
1862
|
try {
|
|
1865
1863
|
if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") {
|
|
@@ -1869,21 +1867,21 @@ var require_bn = __commonJS({
|
|
|
1869
1867
|
}
|
|
1870
1868
|
} catch (e) {
|
|
1871
1869
|
}
|
|
1872
|
-
|
|
1873
|
-
if (num instanceof
|
|
1870
|
+
BN3.isBN = function isBN(num) {
|
|
1871
|
+
if (num instanceof BN3) {
|
|
1874
1872
|
return true;
|
|
1875
1873
|
}
|
|
1876
|
-
return num !== null && typeof num === "object" && num.constructor.wordSize ===
|
|
1874
|
+
return num !== null && typeof num === "object" && num.constructor.wordSize === BN3.wordSize && Array.isArray(num.words);
|
|
1877
1875
|
};
|
|
1878
|
-
|
|
1876
|
+
BN3.max = function max(left, right) {
|
|
1879
1877
|
if (left.cmp(right) > 0) return left;
|
|
1880
1878
|
return right;
|
|
1881
1879
|
};
|
|
1882
|
-
|
|
1880
|
+
BN3.min = function min(left, right) {
|
|
1883
1881
|
if (left.cmp(right) < 0) return left;
|
|
1884
1882
|
return right;
|
|
1885
1883
|
};
|
|
1886
|
-
|
|
1884
|
+
BN3.prototype._init = function init(number, base, endian) {
|
|
1887
1885
|
if (typeof number === "number") {
|
|
1888
1886
|
return this._initNumber(number, base, endian);
|
|
1889
1887
|
}
|
|
@@ -1911,7 +1909,7 @@ var require_bn = __commonJS({
|
|
|
1911
1909
|
}
|
|
1912
1910
|
}
|
|
1913
1911
|
};
|
|
1914
|
-
|
|
1912
|
+
BN3.prototype._initNumber = function _initNumber(number, base, endian) {
|
|
1915
1913
|
if (number < 0) {
|
|
1916
1914
|
this.negative = 1;
|
|
1917
1915
|
number = -number;
|
|
@@ -1937,7 +1935,7 @@ var require_bn = __commonJS({
|
|
|
1937
1935
|
if (endian !== "le") return;
|
|
1938
1936
|
this._initArray(this.toArray(), base, endian);
|
|
1939
1937
|
};
|
|
1940
|
-
|
|
1938
|
+
BN3.prototype._initArray = function _initArray(number, base, endian) {
|
|
1941
1939
|
assert(typeof number.length === "number");
|
|
1942
1940
|
if (number.length <= 0) {
|
|
1943
1941
|
this.words = [0];
|
|
@@ -1995,7 +1993,7 @@ var require_bn = __commonJS({
|
|
|
1995
1993
|
}
|
|
1996
1994
|
return r;
|
|
1997
1995
|
}
|
|
1998
|
-
|
|
1996
|
+
BN3.prototype._parseHex = function _parseHex(number, start, endian) {
|
|
1999
1997
|
this.length = Math.ceil((number.length - start) / 6);
|
|
2000
1998
|
this.words = new Array(this.length);
|
|
2001
1999
|
for (var i = 0; i < this.length; i++) {
|
|
@@ -2051,7 +2049,7 @@ var require_bn = __commonJS({
|
|
|
2051
2049
|
}
|
|
2052
2050
|
return r;
|
|
2053
2051
|
}
|
|
2054
|
-
|
|
2052
|
+
BN3.prototype._parseBase = function _parseBase(number, base, start) {
|
|
2055
2053
|
this.words = [0];
|
|
2056
2054
|
this.length = 1;
|
|
2057
2055
|
for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base) {
|
|
@@ -2087,7 +2085,7 @@ var require_bn = __commonJS({
|
|
|
2087
2085
|
}
|
|
2088
2086
|
this._strip();
|
|
2089
2087
|
};
|
|
2090
|
-
|
|
2088
|
+
BN3.prototype.copy = function copy(dest) {
|
|
2091
2089
|
dest.words = new Array(this.length);
|
|
2092
2090
|
for (var i = 0; i < this.length; i++) {
|
|
2093
2091
|
dest.words[i] = this.words[i];
|
|
@@ -2102,27 +2100,27 @@ var require_bn = __commonJS({
|
|
|
2102
2100
|
dest.negative = src.negative;
|
|
2103
2101
|
dest.red = src.red;
|
|
2104
2102
|
}
|
|
2105
|
-
|
|
2103
|
+
BN3.prototype._move = function _move(dest) {
|
|
2106
2104
|
move(dest, this);
|
|
2107
2105
|
};
|
|
2108
|
-
|
|
2109
|
-
var r = new
|
|
2106
|
+
BN3.prototype.clone = function clone() {
|
|
2107
|
+
var r = new BN3(null);
|
|
2110
2108
|
this.copy(r);
|
|
2111
2109
|
return r;
|
|
2112
2110
|
};
|
|
2113
|
-
|
|
2111
|
+
BN3.prototype._expand = function _expand(size) {
|
|
2114
2112
|
while (this.length < size) {
|
|
2115
2113
|
this.words[this.length++] = 0;
|
|
2116
2114
|
}
|
|
2117
2115
|
return this;
|
|
2118
2116
|
};
|
|
2119
|
-
|
|
2117
|
+
BN3.prototype._strip = function strip() {
|
|
2120
2118
|
while (this.length > 1 && this.words[this.length - 1] === 0) {
|
|
2121
2119
|
this.length--;
|
|
2122
2120
|
}
|
|
2123
2121
|
return this._normSign();
|
|
2124
2122
|
};
|
|
2125
|
-
|
|
2123
|
+
BN3.prototype._normSign = function _normSign() {
|
|
2126
2124
|
if (this.length === 1 && this.words[0] === 0) {
|
|
2127
2125
|
this.negative = 0;
|
|
2128
2126
|
}
|
|
@@ -2130,12 +2128,12 @@ var require_bn = __commonJS({
|
|
|
2130
2128
|
};
|
|
2131
2129
|
if (typeof Symbol !== "undefined" && typeof Symbol.for === "function") {
|
|
2132
2130
|
try {
|
|
2133
|
-
|
|
2131
|
+
BN3.prototype[Symbol.for("nodejs.util.inspect.custom")] = inspect;
|
|
2134
2132
|
} catch (e) {
|
|
2135
|
-
|
|
2133
|
+
BN3.prototype.inspect = inspect;
|
|
2136
2134
|
}
|
|
2137
2135
|
} else {
|
|
2138
|
-
|
|
2136
|
+
BN3.prototype.inspect = inspect;
|
|
2139
2137
|
}
|
|
2140
2138
|
function inspect() {
|
|
2141
2139
|
return (this.red ? "<BN-R: " : "<BN: ") + this.toString(16) + ">";
|
|
@@ -2246,7 +2244,7 @@ var require_bn = __commonJS({
|
|
|
2246
2244
|
52521875,
|
|
2247
2245
|
60466176
|
|
2248
2246
|
];
|
|
2249
|
-
|
|
2247
|
+
BN3.prototype.toString = function toString(base, padding) {
|
|
2250
2248
|
base = base || 10;
|
|
2251
2249
|
padding = padding | 0 || 1;
|
|
2252
2250
|
var out;
|
|
@@ -2308,7 +2306,7 @@ var require_bn = __commonJS({
|
|
|
2308
2306
|
}
|
|
2309
2307
|
assert(false, "Base should be between 2 and 36");
|
|
2310
2308
|
};
|
|
2311
|
-
|
|
2309
|
+
BN3.prototype.toNumber = function toNumber() {
|
|
2312
2310
|
var ret = this.words[0];
|
|
2313
2311
|
if (this.length === 2) {
|
|
2314
2312
|
ret += this.words[1] * 67108864;
|
|
@@ -2319,15 +2317,15 @@ var require_bn = __commonJS({
|
|
|
2319
2317
|
}
|
|
2320
2318
|
return this.negative !== 0 ? -ret : ret;
|
|
2321
2319
|
};
|
|
2322
|
-
|
|
2320
|
+
BN3.prototype.toJSON = function toJSON() {
|
|
2323
2321
|
return this.toString(16, 2);
|
|
2324
2322
|
};
|
|
2325
2323
|
if (Buffer2) {
|
|
2326
|
-
|
|
2324
|
+
BN3.prototype.toBuffer = function toBuffer(endian, length) {
|
|
2327
2325
|
return this.toArrayLike(Buffer2, endian, length);
|
|
2328
2326
|
};
|
|
2329
2327
|
}
|
|
2330
|
-
|
|
2328
|
+
BN3.prototype.toArray = function toArray(endian, length) {
|
|
2331
2329
|
return this.toArrayLike(Array, endian, length);
|
|
2332
2330
|
};
|
|
2333
2331
|
var allocate = function allocate2(ArrayType, size) {
|
|
@@ -2336,7 +2334,7 @@ var require_bn = __commonJS({
|
|
|
2336
2334
|
}
|
|
2337
2335
|
return new ArrayType(size);
|
|
2338
2336
|
};
|
|
2339
|
-
|
|
2337
|
+
BN3.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length) {
|
|
2340
2338
|
this._strip();
|
|
2341
2339
|
var byteLength = this.byteLength();
|
|
2342
2340
|
var reqLength = length || Math.max(1, byteLength);
|
|
@@ -2347,7 +2345,7 @@ var require_bn = __commonJS({
|
|
|
2347
2345
|
this["_toArrayLike" + postfix](res, byteLength);
|
|
2348
2346
|
return res;
|
|
2349
2347
|
};
|
|
2350
|
-
|
|
2348
|
+
BN3.prototype._toArrayLikeLE = function _toArrayLikeLE(res, byteLength) {
|
|
2351
2349
|
var position = 0;
|
|
2352
2350
|
var carry = 0;
|
|
2353
2351
|
for (var i = 0, shift = 0; i < this.length; i++) {
|
|
@@ -2377,7 +2375,7 @@ var require_bn = __commonJS({
|
|
|
2377
2375
|
}
|
|
2378
2376
|
}
|
|
2379
2377
|
};
|
|
2380
|
-
|
|
2378
|
+
BN3.prototype._toArrayLikeBE = function _toArrayLikeBE(res, byteLength) {
|
|
2381
2379
|
var position = res.length - 1;
|
|
2382
2380
|
var carry = 0;
|
|
2383
2381
|
for (var i = 0, shift = 0; i < this.length; i++) {
|
|
@@ -2408,11 +2406,11 @@ var require_bn = __commonJS({
|
|
|
2408
2406
|
}
|
|
2409
2407
|
};
|
|
2410
2408
|
if (Math.clz32) {
|
|
2411
|
-
|
|
2409
|
+
BN3.prototype._countBits = function _countBits(w) {
|
|
2412
2410
|
return 32 - Math.clz32(w);
|
|
2413
2411
|
};
|
|
2414
2412
|
} else {
|
|
2415
|
-
|
|
2413
|
+
BN3.prototype._countBits = function _countBits(w) {
|
|
2416
2414
|
var t = w;
|
|
2417
2415
|
var r = 0;
|
|
2418
2416
|
if (t >= 4096) {
|
|
@@ -2434,7 +2432,7 @@ var require_bn = __commonJS({
|
|
|
2434
2432
|
return r + t;
|
|
2435
2433
|
};
|
|
2436
2434
|
}
|
|
2437
|
-
|
|
2435
|
+
BN3.prototype._zeroBits = function _zeroBits(w) {
|
|
2438
2436
|
if (w === 0) return 26;
|
|
2439
2437
|
var t = w;
|
|
2440
2438
|
var r = 0;
|
|
@@ -2459,7 +2457,7 @@ var require_bn = __commonJS({
|
|
|
2459
2457
|
}
|
|
2460
2458
|
return r;
|
|
2461
2459
|
};
|
|
2462
|
-
|
|
2460
|
+
BN3.prototype.bitLength = function bitLength() {
|
|
2463
2461
|
var w = this.words[this.length - 1];
|
|
2464
2462
|
var hi = this._countBits(w);
|
|
2465
2463
|
return (this.length - 1) * 26 + hi;
|
|
@@ -2473,7 +2471,7 @@ var require_bn = __commonJS({
|
|
|
2473
2471
|
}
|
|
2474
2472
|
return w;
|
|
2475
2473
|
}
|
|
2476
|
-
|
|
2474
|
+
BN3.prototype.zeroBits = function zeroBits() {
|
|
2477
2475
|
if (this.isZero()) return 0;
|
|
2478
2476
|
var r = 0;
|
|
2479
2477
|
for (var i = 0; i < this.length; i++) {
|
|
@@ -2483,34 +2481,34 @@ var require_bn = __commonJS({
|
|
|
2483
2481
|
}
|
|
2484
2482
|
return r;
|
|
2485
2483
|
};
|
|
2486
|
-
|
|
2484
|
+
BN3.prototype.byteLength = function byteLength() {
|
|
2487
2485
|
return Math.ceil(this.bitLength() / 8);
|
|
2488
2486
|
};
|
|
2489
|
-
|
|
2487
|
+
BN3.prototype.toTwos = function toTwos(width) {
|
|
2490
2488
|
if (this.negative !== 0) {
|
|
2491
2489
|
return this.abs().inotn(width).iaddn(1);
|
|
2492
2490
|
}
|
|
2493
2491
|
return this.clone();
|
|
2494
2492
|
};
|
|
2495
|
-
|
|
2493
|
+
BN3.prototype.fromTwos = function fromTwos(width) {
|
|
2496
2494
|
if (this.testn(width - 1)) {
|
|
2497
2495
|
return this.notn(width).iaddn(1).ineg();
|
|
2498
2496
|
}
|
|
2499
2497
|
return this.clone();
|
|
2500
2498
|
};
|
|
2501
|
-
|
|
2499
|
+
BN3.prototype.isNeg = function isNeg() {
|
|
2502
2500
|
return this.negative !== 0;
|
|
2503
2501
|
};
|
|
2504
|
-
|
|
2502
|
+
BN3.prototype.neg = function neg() {
|
|
2505
2503
|
return this.clone().ineg();
|
|
2506
2504
|
};
|
|
2507
|
-
|
|
2505
|
+
BN3.prototype.ineg = function ineg() {
|
|
2508
2506
|
if (!this.isZero()) {
|
|
2509
2507
|
this.negative ^= 1;
|
|
2510
2508
|
}
|
|
2511
2509
|
return this;
|
|
2512
2510
|
};
|
|
2513
|
-
|
|
2511
|
+
BN3.prototype.iuor = function iuor(num) {
|
|
2514
2512
|
while (this.length < num.length) {
|
|
2515
2513
|
this.words[this.length++] = 0;
|
|
2516
2514
|
}
|
|
@@ -2519,19 +2517,19 @@ var require_bn = __commonJS({
|
|
|
2519
2517
|
}
|
|
2520
2518
|
return this._strip();
|
|
2521
2519
|
};
|
|
2522
|
-
|
|
2520
|
+
BN3.prototype.ior = function ior(num) {
|
|
2523
2521
|
assert((this.negative | num.negative) === 0);
|
|
2524
2522
|
return this.iuor(num);
|
|
2525
2523
|
};
|
|
2526
|
-
|
|
2524
|
+
BN3.prototype.or = function or(num) {
|
|
2527
2525
|
if (this.length > num.length) return this.clone().ior(num);
|
|
2528
2526
|
return num.clone().ior(this);
|
|
2529
2527
|
};
|
|
2530
|
-
|
|
2528
|
+
BN3.prototype.uor = function uor(num) {
|
|
2531
2529
|
if (this.length > num.length) return this.clone().iuor(num);
|
|
2532
2530
|
return num.clone().iuor(this);
|
|
2533
2531
|
};
|
|
2534
|
-
|
|
2532
|
+
BN3.prototype.iuand = function iuand(num) {
|
|
2535
2533
|
var b;
|
|
2536
2534
|
if (this.length > num.length) {
|
|
2537
2535
|
b = num;
|
|
@@ -2544,19 +2542,19 @@ var require_bn = __commonJS({
|
|
|
2544
2542
|
this.length = b.length;
|
|
2545
2543
|
return this._strip();
|
|
2546
2544
|
};
|
|
2547
|
-
|
|
2545
|
+
BN3.prototype.iand = function iand(num) {
|
|
2548
2546
|
assert((this.negative | num.negative) === 0);
|
|
2549
2547
|
return this.iuand(num);
|
|
2550
2548
|
};
|
|
2551
|
-
|
|
2549
|
+
BN3.prototype.and = function and(num) {
|
|
2552
2550
|
if (this.length > num.length) return this.clone().iand(num);
|
|
2553
2551
|
return num.clone().iand(this);
|
|
2554
2552
|
};
|
|
2555
|
-
|
|
2553
|
+
BN3.prototype.uand = function uand(num) {
|
|
2556
2554
|
if (this.length > num.length) return this.clone().iuand(num);
|
|
2557
2555
|
return num.clone().iuand(this);
|
|
2558
2556
|
};
|
|
2559
|
-
|
|
2557
|
+
BN3.prototype.iuxor = function iuxor(num) {
|
|
2560
2558
|
var a;
|
|
2561
2559
|
var b;
|
|
2562
2560
|
if (this.length > num.length) {
|
|
@@ -2577,19 +2575,19 @@ var require_bn = __commonJS({
|
|
|
2577
2575
|
this.length = a.length;
|
|
2578
2576
|
return this._strip();
|
|
2579
2577
|
};
|
|
2580
|
-
|
|
2578
|
+
BN3.prototype.ixor = function ixor(num) {
|
|
2581
2579
|
assert((this.negative | num.negative) === 0);
|
|
2582
2580
|
return this.iuxor(num);
|
|
2583
2581
|
};
|
|
2584
|
-
|
|
2582
|
+
BN3.prototype.xor = function xor(num) {
|
|
2585
2583
|
if (this.length > num.length) return this.clone().ixor(num);
|
|
2586
2584
|
return num.clone().ixor(this);
|
|
2587
2585
|
};
|
|
2588
|
-
|
|
2586
|
+
BN3.prototype.uxor = function uxor(num) {
|
|
2589
2587
|
if (this.length > num.length) return this.clone().iuxor(num);
|
|
2590
2588
|
return num.clone().iuxor(this);
|
|
2591
2589
|
};
|
|
2592
|
-
|
|
2590
|
+
BN3.prototype.inotn = function inotn(width) {
|
|
2593
2591
|
assert(typeof width === "number" && width >= 0);
|
|
2594
2592
|
var bytesNeeded = Math.ceil(width / 26) | 0;
|
|
2595
2593
|
var bitsLeft = width % 26;
|
|
@@ -2605,10 +2603,10 @@ var require_bn = __commonJS({
|
|
|
2605
2603
|
}
|
|
2606
2604
|
return this._strip();
|
|
2607
2605
|
};
|
|
2608
|
-
|
|
2606
|
+
BN3.prototype.notn = function notn(width) {
|
|
2609
2607
|
return this.clone().inotn(width);
|
|
2610
2608
|
};
|
|
2611
|
-
|
|
2609
|
+
BN3.prototype.setn = function setn(bit, val) {
|
|
2612
2610
|
assert(typeof bit === "number" && bit >= 0);
|
|
2613
2611
|
var off = bit / 26 | 0;
|
|
2614
2612
|
var wbit = bit % 26;
|
|
@@ -2620,7 +2618,7 @@ var require_bn = __commonJS({
|
|
|
2620
2618
|
}
|
|
2621
2619
|
return this._strip();
|
|
2622
2620
|
};
|
|
2623
|
-
|
|
2621
|
+
BN3.prototype.iadd = function iadd(num) {
|
|
2624
2622
|
var r;
|
|
2625
2623
|
if (this.negative !== 0 && num.negative === 0) {
|
|
2626
2624
|
this.negative = 0;
|
|
@@ -2663,7 +2661,7 @@ var require_bn = __commonJS({
|
|
|
2663
2661
|
}
|
|
2664
2662
|
return this;
|
|
2665
2663
|
};
|
|
2666
|
-
|
|
2664
|
+
BN3.prototype.add = function add(num) {
|
|
2667
2665
|
var res;
|
|
2668
2666
|
if (num.negative !== 0 && this.negative === 0) {
|
|
2669
2667
|
num.negative = 0;
|
|
@@ -2679,7 +2677,7 @@ var require_bn = __commonJS({
|
|
|
2679
2677
|
if (this.length > num.length) return this.clone().iadd(num);
|
|
2680
2678
|
return num.clone().iadd(this);
|
|
2681
2679
|
};
|
|
2682
|
-
|
|
2680
|
+
BN3.prototype.isub = function isub(num) {
|
|
2683
2681
|
if (num.negative !== 0) {
|
|
2684
2682
|
num.negative = 0;
|
|
2685
2683
|
var r = this.iadd(num);
|
|
@@ -2728,7 +2726,7 @@ var require_bn = __commonJS({
|
|
|
2728
2726
|
}
|
|
2729
2727
|
return this._strip();
|
|
2730
2728
|
};
|
|
2731
|
-
|
|
2729
|
+
BN3.prototype.sub = function sub(num) {
|
|
2732
2730
|
return this.clone().isub(num);
|
|
2733
2731
|
};
|
|
2734
2732
|
function smallMulTo(self, num, out) {
|
|
@@ -3356,7 +3354,7 @@ var require_bn = __commonJS({
|
|
|
3356
3354
|
function jumboMulTo(self, num, out) {
|
|
3357
3355
|
return bigMulTo(self, num, out);
|
|
3358
3356
|
}
|
|
3359
|
-
|
|
3357
|
+
BN3.prototype.mulTo = function mulTo(num, out) {
|
|
3360
3358
|
var res;
|
|
3361
3359
|
var len = this.length + num.length;
|
|
3362
3360
|
if (this.length === 10 && num.length === 10) {
|
|
@@ -3370,20 +3368,20 @@ var require_bn = __commonJS({
|
|
|
3370
3368
|
}
|
|
3371
3369
|
return res;
|
|
3372
3370
|
};
|
|
3373
|
-
|
|
3374
|
-
var out = new
|
|
3371
|
+
BN3.prototype.mul = function mul(num) {
|
|
3372
|
+
var out = new BN3(null);
|
|
3375
3373
|
out.words = new Array(this.length + num.length);
|
|
3376
3374
|
return this.mulTo(num, out);
|
|
3377
3375
|
};
|
|
3378
|
-
|
|
3379
|
-
var out = new
|
|
3376
|
+
BN3.prototype.mulf = function mulf(num) {
|
|
3377
|
+
var out = new BN3(null);
|
|
3380
3378
|
out.words = new Array(this.length + num.length);
|
|
3381
3379
|
return jumboMulTo(this, num, out);
|
|
3382
3380
|
};
|
|
3383
|
-
|
|
3381
|
+
BN3.prototype.imul = function imul(num) {
|
|
3384
3382
|
return this.clone().mulTo(num, this);
|
|
3385
3383
|
};
|
|
3386
|
-
|
|
3384
|
+
BN3.prototype.imuln = function imuln(num) {
|
|
3387
3385
|
var isNegNum = num < 0;
|
|
3388
3386
|
if (isNegNum) num = -num;
|
|
3389
3387
|
assert(typeof num === "number");
|
|
@@ -3404,18 +3402,18 @@ var require_bn = __commonJS({
|
|
|
3404
3402
|
this.length = num === 0 ? 1 : this.length;
|
|
3405
3403
|
return isNegNum ? this.ineg() : this;
|
|
3406
3404
|
};
|
|
3407
|
-
|
|
3405
|
+
BN3.prototype.muln = function muln(num) {
|
|
3408
3406
|
return this.clone().imuln(num);
|
|
3409
3407
|
};
|
|
3410
|
-
|
|
3408
|
+
BN3.prototype.sqr = function sqr() {
|
|
3411
3409
|
return this.mul(this);
|
|
3412
3410
|
};
|
|
3413
|
-
|
|
3411
|
+
BN3.prototype.isqr = function isqr() {
|
|
3414
3412
|
return this.imul(this.clone());
|
|
3415
3413
|
};
|
|
3416
|
-
|
|
3414
|
+
BN3.prototype.pow = function pow(num) {
|
|
3417
3415
|
var w = toBitArray(num);
|
|
3418
|
-
if (w.length === 0) return new
|
|
3416
|
+
if (w.length === 0) return new BN3(1);
|
|
3419
3417
|
var res = this;
|
|
3420
3418
|
for (var i = 0; i < w.length; i++, res = res.sqr()) {
|
|
3421
3419
|
if (w[i] !== 0) break;
|
|
@@ -3428,7 +3426,7 @@ var require_bn = __commonJS({
|
|
|
3428
3426
|
}
|
|
3429
3427
|
return res;
|
|
3430
3428
|
};
|
|
3431
|
-
|
|
3429
|
+
BN3.prototype.iushln = function iushln(bits) {
|
|
3432
3430
|
assert(typeof bits === "number" && bits >= 0);
|
|
3433
3431
|
var r = bits % 26;
|
|
3434
3432
|
var s = (bits - r) / 26;
|
|
@@ -3458,11 +3456,11 @@ var require_bn = __commonJS({
|
|
|
3458
3456
|
}
|
|
3459
3457
|
return this._strip();
|
|
3460
3458
|
};
|
|
3461
|
-
|
|
3459
|
+
BN3.prototype.ishln = function ishln(bits) {
|
|
3462
3460
|
assert(this.negative === 0);
|
|
3463
3461
|
return this.iushln(bits);
|
|
3464
3462
|
};
|
|
3465
|
-
|
|
3463
|
+
BN3.prototype.iushrn = function iushrn(bits, hint, extended) {
|
|
3466
3464
|
assert(typeof bits === "number" && bits >= 0);
|
|
3467
3465
|
var h;
|
|
3468
3466
|
if (hint) {
|
|
@@ -3506,23 +3504,23 @@ var require_bn = __commonJS({
|
|
|
3506
3504
|
}
|
|
3507
3505
|
return this._strip();
|
|
3508
3506
|
};
|
|
3509
|
-
|
|
3507
|
+
BN3.prototype.ishrn = function ishrn(bits, hint, extended) {
|
|
3510
3508
|
assert(this.negative === 0);
|
|
3511
3509
|
return this.iushrn(bits, hint, extended);
|
|
3512
3510
|
};
|
|
3513
|
-
|
|
3511
|
+
BN3.prototype.shln = function shln(bits) {
|
|
3514
3512
|
return this.clone().ishln(bits);
|
|
3515
3513
|
};
|
|
3516
|
-
|
|
3514
|
+
BN3.prototype.ushln = function ushln(bits) {
|
|
3517
3515
|
return this.clone().iushln(bits);
|
|
3518
3516
|
};
|
|
3519
|
-
|
|
3517
|
+
BN3.prototype.shrn = function shrn(bits) {
|
|
3520
3518
|
return this.clone().ishrn(bits);
|
|
3521
3519
|
};
|
|
3522
|
-
|
|
3520
|
+
BN3.prototype.ushrn = function ushrn(bits) {
|
|
3523
3521
|
return this.clone().iushrn(bits);
|
|
3524
3522
|
};
|
|
3525
|
-
|
|
3523
|
+
BN3.prototype.testn = function testn(bit) {
|
|
3526
3524
|
assert(typeof bit === "number" && bit >= 0);
|
|
3527
3525
|
var r = bit % 26;
|
|
3528
3526
|
var s = (bit - r) / 26;
|
|
@@ -3531,7 +3529,7 @@ var require_bn = __commonJS({
|
|
|
3531
3529
|
var w = this.words[s];
|
|
3532
3530
|
return !!(w & q);
|
|
3533
3531
|
};
|
|
3534
|
-
|
|
3532
|
+
BN3.prototype.imaskn = function imaskn(bits) {
|
|
3535
3533
|
assert(typeof bits === "number" && bits >= 0);
|
|
3536
3534
|
var r = bits % 26;
|
|
3537
3535
|
var s = (bits - r) / 26;
|
|
@@ -3549,10 +3547,10 @@ var require_bn = __commonJS({
|
|
|
3549
3547
|
}
|
|
3550
3548
|
return this._strip();
|
|
3551
3549
|
};
|
|
3552
|
-
|
|
3550
|
+
BN3.prototype.maskn = function maskn(bits) {
|
|
3553
3551
|
return this.clone().imaskn(bits);
|
|
3554
3552
|
};
|
|
3555
|
-
|
|
3553
|
+
BN3.prototype.iaddn = function iaddn(num) {
|
|
3556
3554
|
assert(typeof num === "number");
|
|
3557
3555
|
assert(num < 67108864);
|
|
3558
3556
|
if (num < 0) return this.isubn(-num);
|
|
@@ -3569,7 +3567,7 @@ var require_bn = __commonJS({
|
|
|
3569
3567
|
}
|
|
3570
3568
|
return this._iaddn(num);
|
|
3571
3569
|
};
|
|
3572
|
-
|
|
3570
|
+
BN3.prototype._iaddn = function _iaddn(num) {
|
|
3573
3571
|
this.words[0] += num;
|
|
3574
3572
|
for (var i = 0; i < this.length && this.words[i] >= 67108864; i++) {
|
|
3575
3573
|
this.words[i] -= 67108864;
|
|
@@ -3582,7 +3580,7 @@ var require_bn = __commonJS({
|
|
|
3582
3580
|
this.length = Math.max(this.length, i + 1);
|
|
3583
3581
|
return this;
|
|
3584
3582
|
};
|
|
3585
|
-
|
|
3583
|
+
BN3.prototype.isubn = function isubn(num) {
|
|
3586
3584
|
assert(typeof num === "number");
|
|
3587
3585
|
assert(num < 67108864);
|
|
3588
3586
|
if (num < 0) return this.iaddn(-num);
|
|
@@ -3604,20 +3602,20 @@ var require_bn = __commonJS({
|
|
|
3604
3602
|
}
|
|
3605
3603
|
return this._strip();
|
|
3606
3604
|
};
|
|
3607
|
-
|
|
3605
|
+
BN3.prototype.addn = function addn(num) {
|
|
3608
3606
|
return this.clone().iaddn(num);
|
|
3609
3607
|
};
|
|
3610
|
-
|
|
3608
|
+
BN3.prototype.subn = function subn(num) {
|
|
3611
3609
|
return this.clone().isubn(num);
|
|
3612
3610
|
};
|
|
3613
|
-
|
|
3611
|
+
BN3.prototype.iabs = function iabs() {
|
|
3614
3612
|
this.negative = 0;
|
|
3615
3613
|
return this;
|
|
3616
3614
|
};
|
|
3617
|
-
|
|
3615
|
+
BN3.prototype.abs = function abs() {
|
|
3618
3616
|
return this.clone().iabs();
|
|
3619
3617
|
};
|
|
3620
|
-
|
|
3618
|
+
BN3.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) {
|
|
3621
3619
|
var len = num.length + shift;
|
|
3622
3620
|
var i;
|
|
3623
3621
|
this._expand(len);
|
|
@@ -3646,7 +3644,7 @@ var require_bn = __commonJS({
|
|
|
3646
3644
|
this.negative = 1;
|
|
3647
3645
|
return this._strip();
|
|
3648
3646
|
};
|
|
3649
|
-
|
|
3647
|
+
BN3.prototype._wordDiv = function _wordDiv(num, mode) {
|
|
3650
3648
|
var shift = this.length - num.length;
|
|
3651
3649
|
var a = this.clone();
|
|
3652
3650
|
var b = num;
|
|
@@ -3661,7 +3659,7 @@ var require_bn = __commonJS({
|
|
|
3661
3659
|
var m = a.length - b.length;
|
|
3662
3660
|
var q;
|
|
3663
3661
|
if (mode !== "mod") {
|
|
3664
|
-
q = new
|
|
3662
|
+
q = new BN3(null);
|
|
3665
3663
|
q.length = m + 1;
|
|
3666
3664
|
q.words = new Array(q.length);
|
|
3667
3665
|
for (var i = 0; i < q.length; i++) {
|
|
@@ -3703,12 +3701,12 @@ var require_bn = __commonJS({
|
|
|
3703
3701
|
mod: a
|
|
3704
3702
|
};
|
|
3705
3703
|
};
|
|
3706
|
-
|
|
3704
|
+
BN3.prototype.divmod = function divmod(num, mode, positive) {
|
|
3707
3705
|
assert(!num.isZero());
|
|
3708
3706
|
if (this.isZero()) {
|
|
3709
3707
|
return {
|
|
3710
|
-
div: new
|
|
3711
|
-
mod: new
|
|
3708
|
+
div: new BN3(0),
|
|
3709
|
+
mod: new BN3(0)
|
|
3712
3710
|
};
|
|
3713
3711
|
}
|
|
3714
3712
|
var div, mod, res;
|
|
@@ -3753,7 +3751,7 @@ var require_bn = __commonJS({
|
|
|
3753
3751
|
}
|
|
3754
3752
|
if (num.length > this.length || this.cmp(num) < 0) {
|
|
3755
3753
|
return {
|
|
3756
|
-
div: new
|
|
3754
|
+
div: new BN3(0),
|
|
3757
3755
|
mod: this
|
|
3758
3756
|
};
|
|
3759
3757
|
}
|
|
@@ -3767,26 +3765,26 @@ var require_bn = __commonJS({
|
|
|
3767
3765
|
if (mode === "mod") {
|
|
3768
3766
|
return {
|
|
3769
3767
|
div: null,
|
|
3770
|
-
mod: new
|
|
3768
|
+
mod: new BN3(this.modrn(num.words[0]))
|
|
3771
3769
|
};
|
|
3772
3770
|
}
|
|
3773
3771
|
return {
|
|
3774
3772
|
div: this.divn(num.words[0]),
|
|
3775
|
-
mod: new
|
|
3773
|
+
mod: new BN3(this.modrn(num.words[0]))
|
|
3776
3774
|
};
|
|
3777
3775
|
}
|
|
3778
3776
|
return this._wordDiv(num, mode);
|
|
3779
3777
|
};
|
|
3780
|
-
|
|
3778
|
+
BN3.prototype.div = function div(num) {
|
|
3781
3779
|
return this.divmod(num, "div", false).div;
|
|
3782
3780
|
};
|
|
3783
|
-
|
|
3781
|
+
BN3.prototype.mod = function mod(num) {
|
|
3784
3782
|
return this.divmod(num, "mod", false).mod;
|
|
3785
3783
|
};
|
|
3786
|
-
|
|
3784
|
+
BN3.prototype.umod = function umod(num) {
|
|
3787
3785
|
return this.divmod(num, "mod", true).mod;
|
|
3788
3786
|
};
|
|
3789
|
-
|
|
3787
|
+
BN3.prototype.divRound = function divRound(num) {
|
|
3790
3788
|
var dm = this.divmod(num);
|
|
3791
3789
|
if (dm.mod.isZero()) return dm.div;
|
|
3792
3790
|
var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
|
|
@@ -3796,7 +3794,7 @@ var require_bn = __commonJS({
|
|
|
3796
3794
|
if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
|
|
3797
3795
|
return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
|
|
3798
3796
|
};
|
|
3799
|
-
|
|
3797
|
+
BN3.prototype.modrn = function modrn(num) {
|
|
3800
3798
|
var isNegNum = num < 0;
|
|
3801
3799
|
if (isNegNum) num = -num;
|
|
3802
3800
|
assert(num <= 67108863);
|
|
@@ -3807,10 +3805,10 @@ var require_bn = __commonJS({
|
|
|
3807
3805
|
}
|
|
3808
3806
|
return isNegNum ? -acc : acc;
|
|
3809
3807
|
};
|
|
3810
|
-
|
|
3808
|
+
BN3.prototype.modn = function modn(num) {
|
|
3811
3809
|
return this.modrn(num);
|
|
3812
3810
|
};
|
|
3813
|
-
|
|
3811
|
+
BN3.prototype.idivn = function idivn(num) {
|
|
3814
3812
|
var isNegNum = num < 0;
|
|
3815
3813
|
if (isNegNum) num = -num;
|
|
3816
3814
|
assert(num <= 67108863);
|
|
@@ -3823,10 +3821,10 @@ var require_bn = __commonJS({
|
|
|
3823
3821
|
this._strip();
|
|
3824
3822
|
return isNegNum ? this.ineg() : this;
|
|
3825
3823
|
};
|
|
3826
|
-
|
|
3824
|
+
BN3.prototype.divn = function divn(num) {
|
|
3827
3825
|
return this.clone().idivn(num);
|
|
3828
3826
|
};
|
|
3829
|
-
|
|
3827
|
+
BN3.prototype.egcd = function egcd(p) {
|
|
3830
3828
|
assert(p.negative === 0);
|
|
3831
3829
|
assert(!p.isZero());
|
|
3832
3830
|
var x = this;
|
|
@@ -3836,10 +3834,10 @@ var require_bn = __commonJS({
|
|
|
3836
3834
|
} else {
|
|
3837
3835
|
x = x.clone();
|
|
3838
3836
|
}
|
|
3839
|
-
var A = new
|
|
3840
|
-
var B = new
|
|
3841
|
-
var C = new
|
|
3842
|
-
var D = new
|
|
3837
|
+
var A = new BN3(1);
|
|
3838
|
+
var B = new BN3(0);
|
|
3839
|
+
var C = new BN3(0);
|
|
3840
|
+
var D = new BN3(1);
|
|
3843
3841
|
var g = 0;
|
|
3844
3842
|
while (x.isEven() && y.isEven()) {
|
|
3845
3843
|
x.iushrn(1);
|
|
@@ -3889,7 +3887,7 @@ var require_bn = __commonJS({
|
|
|
3889
3887
|
gcd: y.iushln(g)
|
|
3890
3888
|
};
|
|
3891
3889
|
};
|
|
3892
|
-
|
|
3890
|
+
BN3.prototype._invmp = function _invmp(p) {
|
|
3893
3891
|
assert(p.negative === 0);
|
|
3894
3892
|
assert(!p.isZero());
|
|
3895
3893
|
var a = this;
|
|
@@ -3899,8 +3897,8 @@ var require_bn = __commonJS({
|
|
|
3899
3897
|
} else {
|
|
3900
3898
|
a = a.clone();
|
|
3901
3899
|
}
|
|
3902
|
-
var x1 = new
|
|
3903
|
-
var x2 = new
|
|
3900
|
+
var x1 = new BN3(1);
|
|
3901
|
+
var x2 = new BN3(0);
|
|
3904
3902
|
var delta = b.clone();
|
|
3905
3903
|
while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
|
|
3906
3904
|
for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1) ;
|
|
@@ -3942,7 +3940,7 @@ var require_bn = __commonJS({
|
|
|
3942
3940
|
}
|
|
3943
3941
|
return res;
|
|
3944
3942
|
};
|
|
3945
|
-
|
|
3943
|
+
BN3.prototype.gcd = function gcd(num) {
|
|
3946
3944
|
if (this.isZero()) return num.abs();
|
|
3947
3945
|
if (num.isZero()) return this.abs();
|
|
3948
3946
|
var a = this.clone();
|
|
@@ -3972,19 +3970,19 @@ var require_bn = __commonJS({
|
|
|
3972
3970
|
} while (true);
|
|
3973
3971
|
return b.iushln(shift);
|
|
3974
3972
|
};
|
|
3975
|
-
|
|
3973
|
+
BN3.prototype.invm = function invm(num) {
|
|
3976
3974
|
return this.egcd(num).a.umod(num);
|
|
3977
3975
|
};
|
|
3978
|
-
|
|
3976
|
+
BN3.prototype.isEven = function isEven() {
|
|
3979
3977
|
return (this.words[0] & 1) === 0;
|
|
3980
3978
|
};
|
|
3981
|
-
|
|
3979
|
+
BN3.prototype.isOdd = function isOdd() {
|
|
3982
3980
|
return (this.words[0] & 1) === 1;
|
|
3983
3981
|
};
|
|
3984
|
-
|
|
3982
|
+
BN3.prototype.andln = function andln(num) {
|
|
3985
3983
|
return this.words[0] & num;
|
|
3986
3984
|
};
|
|
3987
|
-
|
|
3985
|
+
BN3.prototype.bincn = function bincn(bit) {
|
|
3988
3986
|
assert(typeof bit === "number");
|
|
3989
3987
|
var r = bit % 26;
|
|
3990
3988
|
var s = (bit - r) / 26;
|
|
@@ -4008,10 +4006,10 @@ var require_bn = __commonJS({
|
|
|
4008
4006
|
}
|
|
4009
4007
|
return this;
|
|
4010
4008
|
};
|
|
4011
|
-
|
|
4009
|
+
BN3.prototype.isZero = function isZero() {
|
|
4012
4010
|
return this.length === 1 && this.words[0] === 0;
|
|
4013
4011
|
};
|
|
4014
|
-
|
|
4012
|
+
BN3.prototype.cmpn = function cmpn(num) {
|
|
4015
4013
|
var negative = num < 0;
|
|
4016
4014
|
if (this.negative !== 0 && !negative) return -1;
|
|
4017
4015
|
if (this.negative === 0 && negative) return 1;
|
|
@@ -4030,14 +4028,14 @@ var require_bn = __commonJS({
|
|
|
4030
4028
|
if (this.negative !== 0) return -res | 0;
|
|
4031
4029
|
return res;
|
|
4032
4030
|
};
|
|
4033
|
-
|
|
4031
|
+
BN3.prototype.cmp = function cmp(num) {
|
|
4034
4032
|
if (this.negative !== 0 && num.negative === 0) return -1;
|
|
4035
4033
|
if (this.negative === 0 && num.negative !== 0) return 1;
|
|
4036
4034
|
var res = this.ucmp(num);
|
|
4037
4035
|
if (this.negative !== 0) return -res | 0;
|
|
4038
4036
|
return res;
|
|
4039
4037
|
};
|
|
4040
|
-
|
|
4038
|
+
BN3.prototype.ucmp = function ucmp(num) {
|
|
4041
4039
|
if (this.length > num.length) return 1;
|
|
4042
4040
|
if (this.length < num.length) return -1;
|
|
4043
4041
|
var res = 0;
|
|
@@ -4054,112 +4052,112 @@ var require_bn = __commonJS({
|
|
|
4054
4052
|
}
|
|
4055
4053
|
return res;
|
|
4056
4054
|
};
|
|
4057
|
-
|
|
4055
|
+
BN3.prototype.gtn = function gtn(num) {
|
|
4058
4056
|
return this.cmpn(num) === 1;
|
|
4059
4057
|
};
|
|
4060
|
-
|
|
4058
|
+
BN3.prototype.gt = function gt(num) {
|
|
4061
4059
|
return this.cmp(num) === 1;
|
|
4062
4060
|
};
|
|
4063
|
-
|
|
4061
|
+
BN3.prototype.gten = function gten(num) {
|
|
4064
4062
|
return this.cmpn(num) >= 0;
|
|
4065
4063
|
};
|
|
4066
|
-
|
|
4064
|
+
BN3.prototype.gte = function gte(num) {
|
|
4067
4065
|
return this.cmp(num) >= 0;
|
|
4068
4066
|
};
|
|
4069
|
-
|
|
4067
|
+
BN3.prototype.ltn = function ltn(num) {
|
|
4070
4068
|
return this.cmpn(num) === -1;
|
|
4071
4069
|
};
|
|
4072
|
-
|
|
4070
|
+
BN3.prototype.lt = function lt(num) {
|
|
4073
4071
|
return this.cmp(num) === -1;
|
|
4074
4072
|
};
|
|
4075
|
-
|
|
4073
|
+
BN3.prototype.lten = function lten(num) {
|
|
4076
4074
|
return this.cmpn(num) <= 0;
|
|
4077
4075
|
};
|
|
4078
|
-
|
|
4076
|
+
BN3.prototype.lte = function lte(num) {
|
|
4079
4077
|
return this.cmp(num) <= 0;
|
|
4080
4078
|
};
|
|
4081
|
-
|
|
4079
|
+
BN3.prototype.eqn = function eqn(num) {
|
|
4082
4080
|
return this.cmpn(num) === 0;
|
|
4083
4081
|
};
|
|
4084
|
-
|
|
4082
|
+
BN3.prototype.eq = function eq(num) {
|
|
4085
4083
|
return this.cmp(num) === 0;
|
|
4086
4084
|
};
|
|
4087
|
-
|
|
4085
|
+
BN3.red = function red(num) {
|
|
4088
4086
|
return new Red(num);
|
|
4089
4087
|
};
|
|
4090
|
-
|
|
4088
|
+
BN3.prototype.toRed = function toRed(ctx) {
|
|
4091
4089
|
assert(!this.red, "Already a number in reduction context");
|
|
4092
4090
|
assert(this.negative === 0, "red works only with positives");
|
|
4093
4091
|
return ctx.convertTo(this)._forceRed(ctx);
|
|
4094
4092
|
};
|
|
4095
|
-
|
|
4093
|
+
BN3.prototype.fromRed = function fromRed() {
|
|
4096
4094
|
assert(this.red, "fromRed works only with numbers in reduction context");
|
|
4097
4095
|
return this.red.convertFrom(this);
|
|
4098
4096
|
};
|
|
4099
|
-
|
|
4097
|
+
BN3.prototype._forceRed = function _forceRed(ctx) {
|
|
4100
4098
|
this.red = ctx;
|
|
4101
4099
|
return this;
|
|
4102
4100
|
};
|
|
4103
|
-
|
|
4101
|
+
BN3.prototype.forceRed = function forceRed(ctx) {
|
|
4104
4102
|
assert(!this.red, "Already a number in reduction context");
|
|
4105
4103
|
return this._forceRed(ctx);
|
|
4106
4104
|
};
|
|
4107
|
-
|
|
4105
|
+
BN3.prototype.redAdd = function redAdd(num) {
|
|
4108
4106
|
assert(this.red, "redAdd works only with red numbers");
|
|
4109
4107
|
return this.red.add(this, num);
|
|
4110
4108
|
};
|
|
4111
|
-
|
|
4109
|
+
BN3.prototype.redIAdd = function redIAdd(num) {
|
|
4112
4110
|
assert(this.red, "redIAdd works only with red numbers");
|
|
4113
4111
|
return this.red.iadd(this, num);
|
|
4114
4112
|
};
|
|
4115
|
-
|
|
4113
|
+
BN3.prototype.redSub = function redSub(num) {
|
|
4116
4114
|
assert(this.red, "redSub works only with red numbers");
|
|
4117
4115
|
return this.red.sub(this, num);
|
|
4118
4116
|
};
|
|
4119
|
-
|
|
4117
|
+
BN3.prototype.redISub = function redISub(num) {
|
|
4120
4118
|
assert(this.red, "redISub works only with red numbers");
|
|
4121
4119
|
return this.red.isub(this, num);
|
|
4122
4120
|
};
|
|
4123
|
-
|
|
4121
|
+
BN3.prototype.redShl = function redShl(num) {
|
|
4124
4122
|
assert(this.red, "redShl works only with red numbers");
|
|
4125
4123
|
return this.red.shl(this, num);
|
|
4126
4124
|
};
|
|
4127
|
-
|
|
4125
|
+
BN3.prototype.redMul = function redMul(num) {
|
|
4128
4126
|
assert(this.red, "redMul works only with red numbers");
|
|
4129
4127
|
this.red._verify2(this, num);
|
|
4130
4128
|
return this.red.mul(this, num);
|
|
4131
4129
|
};
|
|
4132
|
-
|
|
4130
|
+
BN3.prototype.redIMul = function redIMul(num) {
|
|
4133
4131
|
assert(this.red, "redMul works only with red numbers");
|
|
4134
4132
|
this.red._verify2(this, num);
|
|
4135
4133
|
return this.red.imul(this, num);
|
|
4136
4134
|
};
|
|
4137
|
-
|
|
4135
|
+
BN3.prototype.redSqr = function redSqr() {
|
|
4138
4136
|
assert(this.red, "redSqr works only with red numbers");
|
|
4139
4137
|
this.red._verify1(this);
|
|
4140
4138
|
return this.red.sqr(this);
|
|
4141
4139
|
};
|
|
4142
|
-
|
|
4140
|
+
BN3.prototype.redISqr = function redISqr() {
|
|
4143
4141
|
assert(this.red, "redISqr works only with red numbers");
|
|
4144
4142
|
this.red._verify1(this);
|
|
4145
4143
|
return this.red.isqr(this);
|
|
4146
4144
|
};
|
|
4147
|
-
|
|
4145
|
+
BN3.prototype.redSqrt = function redSqrt() {
|
|
4148
4146
|
assert(this.red, "redSqrt works only with red numbers");
|
|
4149
4147
|
this.red._verify1(this);
|
|
4150
4148
|
return this.red.sqrt(this);
|
|
4151
4149
|
};
|
|
4152
|
-
|
|
4150
|
+
BN3.prototype.redInvm = function redInvm() {
|
|
4153
4151
|
assert(this.red, "redInvm works only with red numbers");
|
|
4154
4152
|
this.red._verify1(this);
|
|
4155
4153
|
return this.red.invm(this);
|
|
4156
4154
|
};
|
|
4157
|
-
|
|
4155
|
+
BN3.prototype.redNeg = function redNeg() {
|
|
4158
4156
|
assert(this.red, "redNeg works only with red numbers");
|
|
4159
4157
|
this.red._verify1(this);
|
|
4160
4158
|
return this.red.neg(this);
|
|
4161
4159
|
};
|
|
4162
|
-
|
|
4160
|
+
BN3.prototype.redPow = function redPow(num) {
|
|
4163
4161
|
assert(this.red && !num.red, "redPow(normalNum)");
|
|
4164
4162
|
this.red._verify1(this);
|
|
4165
4163
|
return this.red.pow(this, num);
|
|
@@ -4172,13 +4170,13 @@ var require_bn = __commonJS({
|
|
|
4172
4170
|
};
|
|
4173
4171
|
function MPrime(name, p) {
|
|
4174
4172
|
this.name = name;
|
|
4175
|
-
this.p = new
|
|
4173
|
+
this.p = new BN3(p, 16);
|
|
4176
4174
|
this.n = this.p.bitLength();
|
|
4177
|
-
this.k = new
|
|
4175
|
+
this.k = new BN3(1).iushln(this.n).isub(this.p);
|
|
4178
4176
|
this.tmp = this._tmp();
|
|
4179
4177
|
}
|
|
4180
4178
|
MPrime.prototype._tmp = function _tmp() {
|
|
4181
|
-
var tmp = new
|
|
4179
|
+
var tmp = new BN3(null);
|
|
4182
4180
|
tmp.words = new Array(Math.ceil(this.n / 13));
|
|
4183
4181
|
return tmp;
|
|
4184
4182
|
};
|
|
@@ -4304,7 +4302,7 @@ var require_bn = __commonJS({
|
|
|
4304
4302
|
}
|
|
4305
4303
|
return num;
|
|
4306
4304
|
};
|
|
4307
|
-
|
|
4305
|
+
BN3._prime = function prime(name) {
|
|
4308
4306
|
if (primes[name]) return primes[name];
|
|
4309
4307
|
var prime2;
|
|
4310
4308
|
if (name === "k256") {
|
|
@@ -4323,7 +4321,7 @@ var require_bn = __commonJS({
|
|
|
4323
4321
|
};
|
|
4324
4322
|
function Red(m) {
|
|
4325
4323
|
if (typeof m === "string") {
|
|
4326
|
-
var prime =
|
|
4324
|
+
var prime = BN3._prime(m);
|
|
4327
4325
|
this.m = prime.p;
|
|
4328
4326
|
this.prime = prime;
|
|
4329
4327
|
} else {
|
|
@@ -4409,7 +4407,7 @@ var require_bn = __commonJS({
|
|
|
4409
4407
|
var mod3 = this.m.andln(3);
|
|
4410
4408
|
assert(mod3 % 2 === 1);
|
|
4411
4409
|
if (mod3 === 3) {
|
|
4412
|
-
var pow = this.m.add(new
|
|
4410
|
+
var pow = this.m.add(new BN3(1)).iushrn(2);
|
|
4413
4411
|
return this.pow(a, pow);
|
|
4414
4412
|
}
|
|
4415
4413
|
var q = this.m.subn(1);
|
|
@@ -4419,11 +4417,11 @@ var require_bn = __commonJS({
|
|
|
4419
4417
|
q.iushrn(1);
|
|
4420
4418
|
}
|
|
4421
4419
|
assert(!q.isZero());
|
|
4422
|
-
var one = new
|
|
4420
|
+
var one = new BN3(1).toRed(this);
|
|
4423
4421
|
var nOne = one.redNeg();
|
|
4424
4422
|
var lpow = this.m.subn(1).iushrn(1);
|
|
4425
4423
|
var z = this.m.bitLength();
|
|
4426
|
-
z = new
|
|
4424
|
+
z = new BN3(2 * z * z).toRed(this);
|
|
4427
4425
|
while (this.pow(z, lpow).cmp(nOne) !== 0) {
|
|
4428
4426
|
z.redIAdd(nOne);
|
|
4429
4427
|
}
|
|
@@ -4437,7 +4435,7 @@ var require_bn = __commonJS({
|
|
|
4437
4435
|
tmp = tmp.redSqr();
|
|
4438
4436
|
}
|
|
4439
4437
|
assert(i < m);
|
|
4440
|
-
var b = this.pow(c, new
|
|
4438
|
+
var b = this.pow(c, new BN3(1).iushln(m - i - 1));
|
|
4441
4439
|
r = r.redMul(b);
|
|
4442
4440
|
c = b.redSqr();
|
|
4443
4441
|
t = t.redMul(c);
|
|
@@ -4455,11 +4453,11 @@ var require_bn = __commonJS({
|
|
|
4455
4453
|
}
|
|
4456
4454
|
};
|
|
4457
4455
|
Red.prototype.pow = function pow(a, num) {
|
|
4458
|
-
if (num.isZero()) return new
|
|
4456
|
+
if (num.isZero()) return new BN3(1).toRed(this);
|
|
4459
4457
|
if (num.cmpn(1) === 0) return a.clone();
|
|
4460
4458
|
var windowSize = 4;
|
|
4461
4459
|
var wnd = new Array(1 << windowSize);
|
|
4462
|
-
wnd[0] = new
|
|
4460
|
+
wnd[0] = new BN3(1).toRed(this);
|
|
4463
4461
|
wnd[1] = a;
|
|
4464
4462
|
for (var i = 2; i < wnd.length; i++) {
|
|
4465
4463
|
wnd[i] = this.mul(wnd[i - 1], a);
|
|
@@ -4503,7 +4501,7 @@ var require_bn = __commonJS({
|
|
|
4503
4501
|
res.red = null;
|
|
4504
4502
|
return res;
|
|
4505
4503
|
};
|
|
4506
|
-
|
|
4504
|
+
BN3.mont = function mont(num) {
|
|
4507
4505
|
return new Mont(num);
|
|
4508
4506
|
};
|
|
4509
4507
|
function Mont(m) {
|
|
@@ -4512,7 +4510,7 @@ var require_bn = __commonJS({
|
|
|
4512
4510
|
if (this.shift % 26 !== 0) {
|
|
4513
4511
|
this.shift += 26 - this.shift % 26;
|
|
4514
4512
|
}
|
|
4515
|
-
this.r = new
|
|
4513
|
+
this.r = new BN3(1).iushln(this.shift);
|
|
4516
4514
|
this.r2 = this.imod(this.r.sqr());
|
|
4517
4515
|
this.rinv = this.r._invmp(this.m);
|
|
4518
4516
|
this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
|
|
@@ -4546,7 +4544,7 @@ var require_bn = __commonJS({
|
|
|
4546
4544
|
return res._forceRed(this);
|
|
4547
4545
|
};
|
|
4548
4546
|
Mont.prototype.mul = function mul(a, b) {
|
|
4549
|
-
if (a.isZero() || b.isZero()) return new
|
|
4547
|
+
if (a.isZero() || b.isZero()) return new BN3(0)._forceRed(this);
|
|
4550
4548
|
var t = a.mul(b);
|
|
4551
4549
|
var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
|
|
4552
4550
|
var u = t.isub(c).iushrn(this.shift);
|
|
@@ -4571,7 +4569,7 @@ init_cjs_shims();
|
|
|
4571
4569
|
|
|
4572
4570
|
// src/client.ts
|
|
4573
4571
|
init_cjs_shims();
|
|
4574
|
-
var
|
|
4572
|
+
var import_bn = __toESM(require_bn());
|
|
4575
4573
|
|
|
4576
4574
|
// src/constants.ts
|
|
4577
4575
|
init_cjs_shims();
|
|
@@ -4617,10 +4615,7 @@ var SessionStatus = /* @__PURE__ */ ((SessionStatus2) => {
|
|
|
4617
4615
|
return SessionStatus2;
|
|
4618
4616
|
})(SessionStatus || {});
|
|
4619
4617
|
|
|
4620
|
-
// src/utils/
|
|
4621
|
-
init_cjs_shims();
|
|
4622
|
-
|
|
4623
|
-
// src/utils/enum-utils.ts
|
|
4618
|
+
// src/utils/enum.ts
|
|
4624
4619
|
init_cjs_shims();
|
|
4625
4620
|
function getVariant(v) {
|
|
4626
4621
|
const key = Object.keys(v)[0];
|
|
@@ -4686,7 +4681,8 @@ var NodeWallet = class {
|
|
|
4686
4681
|
}
|
|
4687
4682
|
};
|
|
4688
4683
|
|
|
4689
|
-
// src/utils/
|
|
4684
|
+
// src/utils/web3.ts
|
|
4685
|
+
init_cjs_shims();
|
|
4690
4686
|
var SLOTS_PER_EPOCH_MAINNET = 432e3;
|
|
4691
4687
|
var SLOTS_PER_EPOCH_DEVNET = 4e5;
|
|
4692
4688
|
function slotToEpoch(slot, cluster) {
|
|
@@ -4797,12 +4793,18 @@ var HistoryManager = class {
|
|
|
4797
4793
|
}
|
|
4798
4794
|
decodeInstructionData(data) {
|
|
4799
4795
|
if (!data) {
|
|
4800
|
-
return {
|
|
4796
|
+
return {
|
|
4797
|
+
type: null,
|
|
4798
|
+
amount: 0
|
|
4799
|
+
};
|
|
4801
4800
|
}
|
|
4802
4801
|
try {
|
|
4803
4802
|
const buf = bs58__default.default.decode(data);
|
|
4804
4803
|
if (buf.length < 16) {
|
|
4805
|
-
return {
|
|
4804
|
+
return {
|
|
4805
|
+
type: null,
|
|
4806
|
+
amount: 0
|
|
4807
|
+
};
|
|
4806
4808
|
}
|
|
4807
4809
|
const disc = buf.slice(0, 8);
|
|
4808
4810
|
const amountBytes = buf.slice(8, 16);
|
|
@@ -5541,9 +5543,6 @@ var jbond_default = {
|
|
|
5541
5543
|
},
|
|
5542
5544
|
{
|
|
5543
5545
|
name: "global_initialize",
|
|
5544
|
-
docs: [
|
|
5545
|
-
"----------------------------- Global Instructions ----------------------------"
|
|
5546
|
-
],
|
|
5547
5546
|
discriminator: [
|
|
5548
5547
|
30,
|
|
5549
5548
|
79,
|
|
@@ -6421,58 +6420,8 @@ var jbond_default = {
|
|
|
6421
6420
|
]
|
|
6422
6421
|
};
|
|
6423
6422
|
|
|
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
6423
|
// src/client.ts
|
|
6424
|
+
var { bs58: bs582 } = anchor.utils.bytes;
|
|
6476
6425
|
var BondClientEnv = /* @__PURE__ */ ((BondClientEnv2) => {
|
|
6477
6426
|
BondClientEnv2["DEV"] = "dev";
|
|
6478
6427
|
BondClientEnv2["STAGE"] = "stage";
|
|
@@ -6903,7 +6852,7 @@ var JBondClient = class _JBondClient {
|
|
|
6903
6852
|
}
|
|
6904
6853
|
async buildBondStartIx(props) {
|
|
6905
6854
|
const [bondState] = this.pda.bondState(props.bondType, props.name);
|
|
6906
|
-
return this.program.methods.sessionStart(new
|
|
6855
|
+
return this.program.methods.sessionStart(new import_bn.BN(props.duration_secs)).accountsPartial({
|
|
6907
6856
|
bondState,
|
|
6908
6857
|
authority: this.program.provider.wallet?.publicKey
|
|
6909
6858
|
}).instruction();
|
|
@@ -7107,10 +7056,6 @@ var JBondClient = class _JBondClient {
|
|
|
7107
7056
|
this.programId
|
|
7108
7057
|
);
|
|
7109
7058
|
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
7059
|
const legacySignatures = (await this.connection.getSignaturesForAddress(
|
|
7115
7060
|
legacyValidatorBondAccount,
|
|
7116
7061
|
{
|
|
@@ -7168,7 +7113,7 @@ var JBondClient = class _JBondClient {
|
|
|
7168
7113
|
let type = null;
|
|
7169
7114
|
let amount = 0;
|
|
7170
7115
|
try {
|
|
7171
|
-
const dataBuffer =
|
|
7116
|
+
const dataBuffer = bs582.decode(data);
|
|
7172
7117
|
if (dataBuffer.length >= 8) {
|
|
7173
7118
|
const discriminator = dataBuffer.subarray(0, 8);
|
|
7174
7119
|
const legacyRegisterDiscriminator = this.getInstructionDiscriminator("register");
|
|
@@ -7184,14 +7129,12 @@ var JBondClient = class _JBondClient {
|
|
|
7184
7129
|
type = "deposit" /* Deposit */;
|
|
7185
7130
|
if (dataBuffer.length >= 16 && Buffer.from(discriminator).equals(Buffer.from(legacyRegisterDiscriminator))) {
|
|
7186
7131
|
const amountBytes = dataBuffer.subarray(8, 16);
|
|
7187
|
-
const amountBN = new
|
|
7132
|
+
const amountBN = new import_bn.BN(amountBytes, "le");
|
|
7188
7133
|
amount = amountBN.toNumber() / web3_js.LAMPORTS_PER_SOL;
|
|
7189
|
-
} else {
|
|
7190
|
-
amount = 0;
|
|
7191
7134
|
}
|
|
7192
7135
|
} else if (dataBuffer.length >= 16) {
|
|
7193
7136
|
const amountBytes = dataBuffer.subarray(8, 16);
|
|
7194
|
-
const amountBN = new
|
|
7137
|
+
const amountBN = new import_bn.BN(amountBytes, "le");
|
|
7195
7138
|
amount = amountBN.toNumber() / web3_js.LAMPORTS_PER_SOL;
|
|
7196
7139
|
if (Buffer.from(discriminator).equals(Buffer.from(legacyTopUpDiscriminator)) || Buffer.from(discriminator).equals(Buffer.from(bondTopUpDiscriminator))) {
|
|
7197
7140
|
type = "deposit" /* Deposit */;
|
|
@@ -7292,35 +7235,8 @@ var JBondClient = class _JBondClient {
|
|
|
7292
7235
|
status: this.getBondStateSessionStatus(state)
|
|
7293
7236
|
};
|
|
7294
7237
|
}
|
|
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
7238
|
lamports(n) {
|
|
7323
|
-
return new
|
|
7239
|
+
return new import_bn.BN((n ?? 0) * web3_js.LAMPORTS_PER_SOL);
|
|
7324
7240
|
}
|
|
7325
7241
|
};
|
|
7326
7242
|
/*! Bundled license information:
|