@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.d.mts +2 -32
- package/dist/index.d.ts +2 -32
- package/dist/index.js +191 -279
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +191 -272
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
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
|
|
1822
|
-
if (
|
|
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 =
|
|
1835
|
+
module2.exports = BN3;
|
|
1839
1836
|
} else {
|
|
1840
|
-
exports2.BN =
|
|
1837
|
+
exports2.BN = BN3;
|
|
1841
1838
|
}
|
|
1842
|
-
|
|
1843
|
-
|
|
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
|
-
|
|
1854
|
-
if (num instanceof
|
|
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 ===
|
|
1854
|
+
return num !== null && typeof num === "object" && num.constructor.wordSize === BN3.wordSize && Array.isArray(num.words);
|
|
1858
1855
|
};
|
|
1859
|
-
|
|
1856
|
+
BN3.max = function max(left, right) {
|
|
1860
1857
|
if (left.cmp(right) > 0) return left;
|
|
1861
1858
|
return right;
|
|
1862
1859
|
};
|
|
1863
|
-
|
|
1860
|
+
BN3.min = function min(left, right) {
|
|
1864
1861
|
if (left.cmp(right) < 0) return left;
|
|
1865
1862
|
return right;
|
|
1866
1863
|
};
|
|
1867
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2083
|
+
BN3.prototype._move = function _move(dest) {
|
|
2087
2084
|
move(dest, this);
|
|
2088
2085
|
};
|
|
2089
|
-
|
|
2090
|
-
var r = new
|
|
2086
|
+
BN3.prototype.clone = function clone() {
|
|
2087
|
+
var r = new BN3(null);
|
|
2091
2088
|
this.copy(r);
|
|
2092
2089
|
return r;
|
|
2093
2090
|
};
|
|
2094
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2111
|
+
BN3.prototype[Symbol.for("nodejs.util.inspect.custom")] = inspect;
|
|
2115
2112
|
} catch (e) {
|
|
2116
|
-
|
|
2113
|
+
BN3.prototype.inspect = inspect;
|
|
2117
2114
|
}
|
|
2118
2115
|
} else {
|
|
2119
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2300
|
+
BN3.prototype.toJSON = function toJSON() {
|
|
2304
2301
|
return this.toString(16, 2);
|
|
2305
2302
|
};
|
|
2306
2303
|
if (Buffer2) {
|
|
2307
|
-
|
|
2304
|
+
BN3.prototype.toBuffer = function toBuffer(endian, length) {
|
|
2308
2305
|
return this.toArrayLike(Buffer2, endian, length);
|
|
2309
2306
|
};
|
|
2310
2307
|
}
|
|
2311
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2389
|
+
BN3.prototype._countBits = function _countBits(w) {
|
|
2393
2390
|
return 32 - Math.clz32(w);
|
|
2394
2391
|
};
|
|
2395
2392
|
} else {
|
|
2396
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2464
|
+
BN3.prototype.byteLength = function byteLength() {
|
|
2468
2465
|
return Math.ceil(this.bitLength() / 8);
|
|
2469
2466
|
};
|
|
2470
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2479
|
+
BN3.prototype.isNeg = function isNeg() {
|
|
2483
2480
|
return this.negative !== 0;
|
|
2484
2481
|
};
|
|
2485
|
-
|
|
2482
|
+
BN3.prototype.neg = function neg() {
|
|
2486
2483
|
return this.clone().ineg();
|
|
2487
2484
|
};
|
|
2488
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2500
|
+
BN3.prototype.ior = function ior(num) {
|
|
2504
2501
|
assert((this.negative | num.negative) === 0);
|
|
2505
2502
|
return this.iuor(num);
|
|
2506
2503
|
};
|
|
2507
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2525
|
+
BN3.prototype.iand = function iand(num) {
|
|
2529
2526
|
assert((this.negative | num.negative) === 0);
|
|
2530
2527
|
return this.iuand(num);
|
|
2531
2528
|
};
|
|
2532
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2558
|
+
BN3.prototype.ixor = function ixor(num) {
|
|
2562
2559
|
assert((this.negative | num.negative) === 0);
|
|
2563
2560
|
return this.iuxor(num);
|
|
2564
2561
|
};
|
|
2565
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2586
|
+
BN3.prototype.notn = function notn(width) {
|
|
2590
2587
|
return this.clone().inotn(width);
|
|
2591
2588
|
};
|
|
2592
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
3355
|
-
var out = new
|
|
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
|
-
|
|
3360
|
-
var out = new
|
|
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
|
-
|
|
3361
|
+
BN3.prototype.imul = function imul(num) {
|
|
3365
3362
|
return this.clone().mulTo(num, this);
|
|
3366
3363
|
};
|
|
3367
|
-
|
|
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
|
-
|
|
3385
|
+
BN3.prototype.muln = function muln(num) {
|
|
3389
3386
|
return this.clone().imuln(num);
|
|
3390
3387
|
};
|
|
3391
|
-
|
|
3388
|
+
BN3.prototype.sqr = function sqr() {
|
|
3392
3389
|
return this.mul(this);
|
|
3393
3390
|
};
|
|
3394
|
-
|
|
3391
|
+
BN3.prototype.isqr = function isqr() {
|
|
3395
3392
|
return this.imul(this.clone());
|
|
3396
3393
|
};
|
|
3397
|
-
|
|
3394
|
+
BN3.prototype.pow = function pow(num) {
|
|
3398
3395
|
var w = toBitArray(num);
|
|
3399
|
-
if (w.length === 0) return new
|
|
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
|
-
|
|
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
|
-
|
|
3439
|
+
BN3.prototype.ishln = function ishln(bits) {
|
|
3443
3440
|
assert(this.negative === 0);
|
|
3444
3441
|
return this.iushln(bits);
|
|
3445
3442
|
};
|
|
3446
|
-
|
|
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
|
-
|
|
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
|
-
|
|
3491
|
+
BN3.prototype.shln = function shln(bits) {
|
|
3495
3492
|
return this.clone().ishln(bits);
|
|
3496
3493
|
};
|
|
3497
|
-
|
|
3494
|
+
BN3.prototype.ushln = function ushln(bits) {
|
|
3498
3495
|
return this.clone().iushln(bits);
|
|
3499
3496
|
};
|
|
3500
|
-
|
|
3497
|
+
BN3.prototype.shrn = function shrn(bits) {
|
|
3501
3498
|
return this.clone().ishrn(bits);
|
|
3502
3499
|
};
|
|
3503
|
-
|
|
3500
|
+
BN3.prototype.ushrn = function ushrn(bits) {
|
|
3504
3501
|
return this.clone().iushrn(bits);
|
|
3505
3502
|
};
|
|
3506
|
-
|
|
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
|
-
|
|
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
|
-
|
|
3530
|
+
BN3.prototype.maskn = function maskn(bits) {
|
|
3534
3531
|
return this.clone().imaskn(bits);
|
|
3535
3532
|
};
|
|
3536
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
3585
|
+
BN3.prototype.addn = function addn(num) {
|
|
3589
3586
|
return this.clone().iaddn(num);
|
|
3590
3587
|
};
|
|
3591
|
-
|
|
3588
|
+
BN3.prototype.subn = function subn(num) {
|
|
3592
3589
|
return this.clone().isubn(num);
|
|
3593
3590
|
};
|
|
3594
|
-
|
|
3591
|
+
BN3.prototype.iabs = function iabs() {
|
|
3595
3592
|
this.negative = 0;
|
|
3596
3593
|
return this;
|
|
3597
3594
|
};
|
|
3598
|
-
|
|
3595
|
+
BN3.prototype.abs = function abs() {
|
|
3599
3596
|
return this.clone().iabs();
|
|
3600
3597
|
};
|
|
3601
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
3692
|
-
mod: new
|
|
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
|
|
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
|
|
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
|
|
3753
|
+
mod: new BN3(this.modrn(num.words[0]))
|
|
3757
3754
|
};
|
|
3758
3755
|
}
|
|
3759
3756
|
return this._wordDiv(num, mode);
|
|
3760
3757
|
};
|
|
3761
|
-
|
|
3758
|
+
BN3.prototype.div = function div(num) {
|
|
3762
3759
|
return this.divmod(num, "div", false).div;
|
|
3763
3760
|
};
|
|
3764
|
-
|
|
3761
|
+
BN3.prototype.mod = function mod(num) {
|
|
3765
3762
|
return this.divmod(num, "mod", false).mod;
|
|
3766
3763
|
};
|
|
3767
|
-
|
|
3764
|
+
BN3.prototype.umod = function umod(num) {
|
|
3768
3765
|
return this.divmod(num, "mod", true).mod;
|
|
3769
3766
|
};
|
|
3770
|
-
|
|
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
|
-
|
|
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
|
-
|
|
3788
|
+
BN3.prototype.modn = function modn(num) {
|
|
3792
3789
|
return this.modrn(num);
|
|
3793
3790
|
};
|
|
3794
|
-
|
|
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
|
-
|
|
3804
|
+
BN3.prototype.divn = function divn(num) {
|
|
3808
3805
|
return this.clone().idivn(num);
|
|
3809
3806
|
};
|
|
3810
|
-
|
|
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
|
|
3821
|
-
var B = new
|
|
3822
|
-
var C = new
|
|
3823
|
-
var D = new
|
|
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
|
-
|
|
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
|
|
3884
|
-
var x2 = new
|
|
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
|
-
|
|
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
|
-
|
|
3953
|
+
BN3.prototype.invm = function invm(num) {
|
|
3957
3954
|
return this.egcd(num).a.umod(num);
|
|
3958
3955
|
};
|
|
3959
|
-
|
|
3956
|
+
BN3.prototype.isEven = function isEven() {
|
|
3960
3957
|
return (this.words[0] & 1) === 0;
|
|
3961
3958
|
};
|
|
3962
|
-
|
|
3959
|
+
BN3.prototype.isOdd = function isOdd() {
|
|
3963
3960
|
return (this.words[0] & 1) === 1;
|
|
3964
3961
|
};
|
|
3965
|
-
|
|
3962
|
+
BN3.prototype.andln = function andln(num) {
|
|
3966
3963
|
return this.words[0] & num;
|
|
3967
3964
|
};
|
|
3968
|
-
|
|
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
|
-
|
|
3989
|
+
BN3.prototype.isZero = function isZero() {
|
|
3993
3990
|
return this.length === 1 && this.words[0] === 0;
|
|
3994
3991
|
};
|
|
3995
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
4035
|
+
BN3.prototype.gtn = function gtn(num) {
|
|
4039
4036
|
return this.cmpn(num) === 1;
|
|
4040
4037
|
};
|
|
4041
|
-
|
|
4038
|
+
BN3.prototype.gt = function gt(num) {
|
|
4042
4039
|
return this.cmp(num) === 1;
|
|
4043
4040
|
};
|
|
4044
|
-
|
|
4041
|
+
BN3.prototype.gten = function gten(num) {
|
|
4045
4042
|
return this.cmpn(num) >= 0;
|
|
4046
4043
|
};
|
|
4047
|
-
|
|
4044
|
+
BN3.prototype.gte = function gte(num) {
|
|
4048
4045
|
return this.cmp(num) >= 0;
|
|
4049
4046
|
};
|
|
4050
|
-
|
|
4047
|
+
BN3.prototype.ltn = function ltn(num) {
|
|
4051
4048
|
return this.cmpn(num) === -1;
|
|
4052
4049
|
};
|
|
4053
|
-
|
|
4050
|
+
BN3.prototype.lt = function lt(num) {
|
|
4054
4051
|
return this.cmp(num) === -1;
|
|
4055
4052
|
};
|
|
4056
|
-
|
|
4053
|
+
BN3.prototype.lten = function lten(num) {
|
|
4057
4054
|
return this.cmpn(num) <= 0;
|
|
4058
4055
|
};
|
|
4059
|
-
|
|
4056
|
+
BN3.prototype.lte = function lte(num) {
|
|
4060
4057
|
return this.cmp(num) <= 0;
|
|
4061
4058
|
};
|
|
4062
|
-
|
|
4059
|
+
BN3.prototype.eqn = function eqn(num) {
|
|
4063
4060
|
return this.cmpn(num) === 0;
|
|
4064
4061
|
};
|
|
4065
|
-
|
|
4062
|
+
BN3.prototype.eq = function eq(num) {
|
|
4066
4063
|
return this.cmp(num) === 0;
|
|
4067
4064
|
};
|
|
4068
|
-
|
|
4065
|
+
BN3.red = function red(num) {
|
|
4069
4066
|
return new Red(num);
|
|
4070
4067
|
};
|
|
4071
|
-
|
|
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
|
-
|
|
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
|
-
|
|
4077
|
+
BN3.prototype._forceRed = function _forceRed(ctx) {
|
|
4081
4078
|
this.red = ctx;
|
|
4082
4079
|
return this;
|
|
4083
4080
|
};
|
|
4084
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
4153
|
+
this.p = new BN3(p, 16);
|
|
4157
4154
|
this.n = this.p.bitLength();
|
|
4158
|
-
this.k = new
|
|
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
|
|
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
|
-
|
|
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 =
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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/
|
|
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 {
|
|
4763
|
+
return {
|
|
4764
|
+
type: null,
|
|
4765
|
+
amount: 0
|
|
4766
|
+
};
|
|
4766
4767
|
}
|
|
4767
4768
|
try {
|
|
4768
|
-
const buf = bs58
|
|
4769
|
+
const buf = bs58.decode(data);
|
|
4769
4770
|
if (buf.length < 16) {
|
|
4770
|
-
return {
|
|
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
|
|
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 =
|
|
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
|
|
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
|
|
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
|
|
7206
|
+
return new import_bn.BN((n ?? 0) * LAMPORTS_PER_SOL);
|
|
7288
7207
|
}
|
|
7289
7208
|
};
|
|
7290
7209
|
/*! Bundled license information:
|