@cetusprotocol/aggregator-sdk 0.1.2 → 0.2.1
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 +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +234 -174
- package/dist/index.mjs +231 -174
- package/dist/src/client.d.ts +1 -0
- package/dist/src/transaction/flowx_v3.d.ts +8 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/msafe.d.ts +2 -0
- package/package.json +1 -1
- package/src/client.ts +4 -0
- package/src/transaction/flowx_v3.ts +50 -0
- package/src/transaction/haedal.ts +0 -7
- package/src/utils/index.ts +1 -0
- package/src/utils/msafe.ts +31 -0
- package/tests/router.test.ts +7 -8
package/dist/index.mjs
CHANGED
|
@@ -85,8 +85,8 @@ var require_bn = __commonJS({
|
|
|
85
85
|
ctor.prototype = new TempCtor();
|
|
86
86
|
ctor.prototype.constructor = ctor;
|
|
87
87
|
}
|
|
88
|
-
function
|
|
89
|
-
if (
|
|
88
|
+
function BN7(number, base, endian) {
|
|
89
|
+
if (BN7.isBN(number)) {
|
|
90
90
|
return number;
|
|
91
91
|
}
|
|
92
92
|
this.negative = 0;
|
|
@@ -102,12 +102,12 @@ var require_bn = __commonJS({
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
if (typeof module2 === "object") {
|
|
105
|
-
module2.exports =
|
|
105
|
+
module2.exports = BN7;
|
|
106
106
|
} else {
|
|
107
|
-
exports2.BN =
|
|
107
|
+
exports2.BN = BN7;
|
|
108
108
|
}
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
BN7.BN = BN7;
|
|
110
|
+
BN7.wordSize = 26;
|
|
111
111
|
var Buffer2;
|
|
112
112
|
try {
|
|
113
113
|
if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") {
|
|
@@ -117,21 +117,21 @@ var require_bn = __commonJS({
|
|
|
117
117
|
}
|
|
118
118
|
} catch (e) {
|
|
119
119
|
}
|
|
120
|
-
|
|
121
|
-
if (num instanceof
|
|
120
|
+
BN7.isBN = function isBN(num) {
|
|
121
|
+
if (num instanceof BN7) {
|
|
122
122
|
return true;
|
|
123
123
|
}
|
|
124
|
-
return num !== null && typeof num === "object" && num.constructor.wordSize ===
|
|
124
|
+
return num !== null && typeof num === "object" && num.constructor.wordSize === BN7.wordSize && Array.isArray(num.words);
|
|
125
125
|
};
|
|
126
|
-
|
|
126
|
+
BN7.max = function max2(left, right) {
|
|
127
127
|
if (left.cmp(right) > 0) return left;
|
|
128
128
|
return right;
|
|
129
129
|
};
|
|
130
|
-
|
|
130
|
+
BN7.min = function min2(left, right) {
|
|
131
131
|
if (left.cmp(right) < 0) return left;
|
|
132
132
|
return right;
|
|
133
133
|
};
|
|
134
|
-
|
|
134
|
+
BN7.prototype._init = function init(number, base, endian) {
|
|
135
135
|
if (typeof number === "number") {
|
|
136
136
|
return this._initNumber(number, base, endian);
|
|
137
137
|
}
|
|
@@ -159,7 +159,7 @@ var require_bn = __commonJS({
|
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
};
|
|
162
|
-
|
|
162
|
+
BN7.prototype._initNumber = function _initNumber(number, base, endian) {
|
|
163
163
|
if (number < 0) {
|
|
164
164
|
this.negative = 1;
|
|
165
165
|
number = -number;
|
|
@@ -185,7 +185,7 @@ var require_bn = __commonJS({
|
|
|
185
185
|
if (endian !== "le") return;
|
|
186
186
|
this._initArray(this.toArray(), base, endian);
|
|
187
187
|
};
|
|
188
|
-
|
|
188
|
+
BN7.prototype._initArray = function _initArray(number, base, endian) {
|
|
189
189
|
assert(typeof number.length === "number");
|
|
190
190
|
if (number.length <= 0) {
|
|
191
191
|
this.words = [0];
|
|
@@ -243,7 +243,7 @@ var require_bn = __commonJS({
|
|
|
243
243
|
}
|
|
244
244
|
return r;
|
|
245
245
|
}
|
|
246
|
-
|
|
246
|
+
BN7.prototype._parseHex = function _parseHex(number, start, endian) {
|
|
247
247
|
this.length = Math.ceil((number.length - start) / 6);
|
|
248
248
|
this.words = new Array(this.length);
|
|
249
249
|
for (var i = 0; i < this.length; i++) {
|
|
@@ -299,7 +299,7 @@ var require_bn = __commonJS({
|
|
|
299
299
|
}
|
|
300
300
|
return r;
|
|
301
301
|
}
|
|
302
|
-
|
|
302
|
+
BN7.prototype._parseBase = function _parseBase(number, base, start) {
|
|
303
303
|
this.words = [0];
|
|
304
304
|
this.length = 1;
|
|
305
305
|
for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base) {
|
|
@@ -335,7 +335,7 @@ var require_bn = __commonJS({
|
|
|
335
335
|
}
|
|
336
336
|
this._strip();
|
|
337
337
|
};
|
|
338
|
-
|
|
338
|
+
BN7.prototype.copy = function copy(dest) {
|
|
339
339
|
dest.words = new Array(this.length);
|
|
340
340
|
for (var i = 0; i < this.length; i++) {
|
|
341
341
|
dest.words[i] = this.words[i];
|
|
@@ -350,27 +350,27 @@ var require_bn = __commonJS({
|
|
|
350
350
|
dest.negative = src.negative;
|
|
351
351
|
dest.red = src.red;
|
|
352
352
|
}
|
|
353
|
-
|
|
353
|
+
BN7.prototype._move = function _move(dest) {
|
|
354
354
|
move(dest, this);
|
|
355
355
|
};
|
|
356
|
-
|
|
357
|
-
var r = new
|
|
356
|
+
BN7.prototype.clone = function clone2() {
|
|
357
|
+
var r = new BN7(null);
|
|
358
358
|
this.copy(r);
|
|
359
359
|
return r;
|
|
360
360
|
};
|
|
361
|
-
|
|
361
|
+
BN7.prototype._expand = function _expand(size) {
|
|
362
362
|
while (this.length < size) {
|
|
363
363
|
this.words[this.length++] = 0;
|
|
364
364
|
}
|
|
365
365
|
return this;
|
|
366
366
|
};
|
|
367
|
-
|
|
367
|
+
BN7.prototype._strip = function strip() {
|
|
368
368
|
while (this.length > 1 && this.words[this.length - 1] === 0) {
|
|
369
369
|
this.length--;
|
|
370
370
|
}
|
|
371
371
|
return this._normSign();
|
|
372
372
|
};
|
|
373
|
-
|
|
373
|
+
BN7.prototype._normSign = function _normSign() {
|
|
374
374
|
if (this.length === 1 && this.words[0] === 0) {
|
|
375
375
|
this.negative = 0;
|
|
376
376
|
}
|
|
@@ -378,12 +378,12 @@ var require_bn = __commonJS({
|
|
|
378
378
|
};
|
|
379
379
|
if (typeof Symbol !== "undefined" && typeof Symbol.for === "function") {
|
|
380
380
|
try {
|
|
381
|
-
|
|
381
|
+
BN7.prototype[Symbol.for("nodejs.util.inspect.custom")] = inspect;
|
|
382
382
|
} catch (e) {
|
|
383
|
-
|
|
383
|
+
BN7.prototype.inspect = inspect;
|
|
384
384
|
}
|
|
385
385
|
} else {
|
|
386
|
-
|
|
386
|
+
BN7.prototype.inspect = inspect;
|
|
387
387
|
}
|
|
388
388
|
function inspect() {
|
|
389
389
|
return (this.red ? "<BN-R: " : "<BN: ") + this.toString(16) + ">";
|
|
@@ -494,7 +494,7 @@ var require_bn = __commonJS({
|
|
|
494
494
|
52521875,
|
|
495
495
|
60466176
|
|
496
496
|
];
|
|
497
|
-
|
|
497
|
+
BN7.prototype.toString = function toString(base, padding) {
|
|
498
498
|
base = base || 10;
|
|
499
499
|
padding = padding | 0 || 1;
|
|
500
500
|
var out;
|
|
@@ -556,7 +556,7 @@ var require_bn = __commonJS({
|
|
|
556
556
|
}
|
|
557
557
|
assert(false, "Base should be between 2 and 36");
|
|
558
558
|
};
|
|
559
|
-
|
|
559
|
+
BN7.prototype.toNumber = function toNumber() {
|
|
560
560
|
var ret = this.words[0];
|
|
561
561
|
if (this.length === 2) {
|
|
562
562
|
ret += this.words[1] * 67108864;
|
|
@@ -567,15 +567,15 @@ var require_bn = __commonJS({
|
|
|
567
567
|
}
|
|
568
568
|
return this.negative !== 0 ? -ret : ret;
|
|
569
569
|
};
|
|
570
|
-
|
|
570
|
+
BN7.prototype.toJSON = function toJSON() {
|
|
571
571
|
return this.toString(16, 2);
|
|
572
572
|
};
|
|
573
573
|
if (Buffer2) {
|
|
574
|
-
|
|
574
|
+
BN7.prototype.toBuffer = function toBuffer(endian, length) {
|
|
575
575
|
return this.toArrayLike(Buffer2, endian, length);
|
|
576
576
|
};
|
|
577
577
|
}
|
|
578
|
-
|
|
578
|
+
BN7.prototype.toArray = function toArray(endian, length) {
|
|
579
579
|
return this.toArrayLike(Array, endian, length);
|
|
580
580
|
};
|
|
581
581
|
var allocate = function allocate2(ArrayType, size) {
|
|
@@ -584,7 +584,7 @@ var require_bn = __commonJS({
|
|
|
584
584
|
}
|
|
585
585
|
return new ArrayType(size);
|
|
586
586
|
};
|
|
587
|
-
|
|
587
|
+
BN7.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length) {
|
|
588
588
|
this._strip();
|
|
589
589
|
var byteLength = this.byteLength();
|
|
590
590
|
var reqLength = length || Math.max(1, byteLength);
|
|
@@ -595,7 +595,7 @@ var require_bn = __commonJS({
|
|
|
595
595
|
this["_toArrayLike" + postfix](res, byteLength);
|
|
596
596
|
return res;
|
|
597
597
|
};
|
|
598
|
-
|
|
598
|
+
BN7.prototype._toArrayLikeLE = function _toArrayLikeLE(res, byteLength) {
|
|
599
599
|
var position = 0;
|
|
600
600
|
var carry = 0;
|
|
601
601
|
for (var i = 0, shift = 0; i < this.length; i++) {
|
|
@@ -625,7 +625,7 @@ var require_bn = __commonJS({
|
|
|
625
625
|
}
|
|
626
626
|
}
|
|
627
627
|
};
|
|
628
|
-
|
|
628
|
+
BN7.prototype._toArrayLikeBE = function _toArrayLikeBE(res, byteLength) {
|
|
629
629
|
var position = res.length - 1;
|
|
630
630
|
var carry = 0;
|
|
631
631
|
for (var i = 0, shift = 0; i < this.length; i++) {
|
|
@@ -656,11 +656,11 @@ var require_bn = __commonJS({
|
|
|
656
656
|
}
|
|
657
657
|
};
|
|
658
658
|
if (Math.clz32) {
|
|
659
|
-
|
|
659
|
+
BN7.prototype._countBits = function _countBits(w) {
|
|
660
660
|
return 32 - Math.clz32(w);
|
|
661
661
|
};
|
|
662
662
|
} else {
|
|
663
|
-
|
|
663
|
+
BN7.prototype._countBits = function _countBits(w) {
|
|
664
664
|
var t = w;
|
|
665
665
|
var r = 0;
|
|
666
666
|
if (t >= 4096) {
|
|
@@ -682,7 +682,7 @@ var require_bn = __commonJS({
|
|
|
682
682
|
return r + t;
|
|
683
683
|
};
|
|
684
684
|
}
|
|
685
|
-
|
|
685
|
+
BN7.prototype._zeroBits = function _zeroBits(w) {
|
|
686
686
|
if (w === 0) return 26;
|
|
687
687
|
var t = w;
|
|
688
688
|
var r = 0;
|
|
@@ -707,7 +707,7 @@ var require_bn = __commonJS({
|
|
|
707
707
|
}
|
|
708
708
|
return r;
|
|
709
709
|
};
|
|
710
|
-
|
|
710
|
+
BN7.prototype.bitLength = function bitLength() {
|
|
711
711
|
var w = this.words[this.length - 1];
|
|
712
712
|
var hi = this._countBits(w);
|
|
713
713
|
return (this.length - 1) * 26 + hi;
|
|
@@ -721,7 +721,7 @@ var require_bn = __commonJS({
|
|
|
721
721
|
}
|
|
722
722
|
return w;
|
|
723
723
|
}
|
|
724
|
-
|
|
724
|
+
BN7.prototype.zeroBits = function zeroBits() {
|
|
725
725
|
if (this.isZero()) return 0;
|
|
726
726
|
var r = 0;
|
|
727
727
|
for (var i = 0; i < this.length; i++) {
|
|
@@ -731,34 +731,34 @@ var require_bn = __commonJS({
|
|
|
731
731
|
}
|
|
732
732
|
return r;
|
|
733
733
|
};
|
|
734
|
-
|
|
734
|
+
BN7.prototype.byteLength = function byteLength() {
|
|
735
735
|
return Math.ceil(this.bitLength() / 8);
|
|
736
736
|
};
|
|
737
|
-
|
|
737
|
+
BN7.prototype.toTwos = function toTwos(width) {
|
|
738
738
|
if (this.negative !== 0) {
|
|
739
739
|
return this.abs().inotn(width).iaddn(1);
|
|
740
740
|
}
|
|
741
741
|
return this.clone();
|
|
742
742
|
};
|
|
743
|
-
|
|
743
|
+
BN7.prototype.fromTwos = function fromTwos(width) {
|
|
744
744
|
if (this.testn(width - 1)) {
|
|
745
745
|
return this.notn(width).iaddn(1).ineg();
|
|
746
746
|
}
|
|
747
747
|
return this.clone();
|
|
748
748
|
};
|
|
749
|
-
|
|
749
|
+
BN7.prototype.isNeg = function isNeg() {
|
|
750
750
|
return this.negative !== 0;
|
|
751
751
|
};
|
|
752
|
-
|
|
752
|
+
BN7.prototype.neg = function neg() {
|
|
753
753
|
return this.clone().ineg();
|
|
754
754
|
};
|
|
755
|
-
|
|
755
|
+
BN7.prototype.ineg = function ineg() {
|
|
756
756
|
if (!this.isZero()) {
|
|
757
757
|
this.negative ^= 1;
|
|
758
758
|
}
|
|
759
759
|
return this;
|
|
760
760
|
};
|
|
761
|
-
|
|
761
|
+
BN7.prototype.iuor = function iuor(num) {
|
|
762
762
|
while (this.length < num.length) {
|
|
763
763
|
this.words[this.length++] = 0;
|
|
764
764
|
}
|
|
@@ -767,19 +767,19 @@ var require_bn = __commonJS({
|
|
|
767
767
|
}
|
|
768
768
|
return this._strip();
|
|
769
769
|
};
|
|
770
|
-
|
|
770
|
+
BN7.prototype.ior = function ior(num) {
|
|
771
771
|
assert((this.negative | num.negative) === 0);
|
|
772
772
|
return this.iuor(num);
|
|
773
773
|
};
|
|
774
|
-
|
|
774
|
+
BN7.prototype.or = function or(num) {
|
|
775
775
|
if (this.length > num.length) return this.clone().ior(num);
|
|
776
776
|
return num.clone().ior(this);
|
|
777
777
|
};
|
|
778
|
-
|
|
778
|
+
BN7.prototype.uor = function uor(num) {
|
|
779
779
|
if (this.length > num.length) return this.clone().iuor(num);
|
|
780
780
|
return num.clone().iuor(this);
|
|
781
781
|
};
|
|
782
|
-
|
|
782
|
+
BN7.prototype.iuand = function iuand(num) {
|
|
783
783
|
var b;
|
|
784
784
|
if (this.length > num.length) {
|
|
785
785
|
b = num;
|
|
@@ -792,19 +792,19 @@ var require_bn = __commonJS({
|
|
|
792
792
|
this.length = b.length;
|
|
793
793
|
return this._strip();
|
|
794
794
|
};
|
|
795
|
-
|
|
795
|
+
BN7.prototype.iand = function iand(num) {
|
|
796
796
|
assert((this.negative | num.negative) === 0);
|
|
797
797
|
return this.iuand(num);
|
|
798
798
|
};
|
|
799
|
-
|
|
799
|
+
BN7.prototype.and = function and(num) {
|
|
800
800
|
if (this.length > num.length) return this.clone().iand(num);
|
|
801
801
|
return num.clone().iand(this);
|
|
802
802
|
};
|
|
803
|
-
|
|
803
|
+
BN7.prototype.uand = function uand(num) {
|
|
804
804
|
if (this.length > num.length) return this.clone().iuand(num);
|
|
805
805
|
return num.clone().iuand(this);
|
|
806
806
|
};
|
|
807
|
-
|
|
807
|
+
BN7.prototype.iuxor = function iuxor(num) {
|
|
808
808
|
var a;
|
|
809
809
|
var b;
|
|
810
810
|
if (this.length > num.length) {
|
|
@@ -825,19 +825,19 @@ var require_bn = __commonJS({
|
|
|
825
825
|
this.length = a.length;
|
|
826
826
|
return this._strip();
|
|
827
827
|
};
|
|
828
|
-
|
|
828
|
+
BN7.prototype.ixor = function ixor(num) {
|
|
829
829
|
assert((this.negative | num.negative) === 0);
|
|
830
830
|
return this.iuxor(num);
|
|
831
831
|
};
|
|
832
|
-
|
|
832
|
+
BN7.prototype.xor = function xor(num) {
|
|
833
833
|
if (this.length > num.length) return this.clone().ixor(num);
|
|
834
834
|
return num.clone().ixor(this);
|
|
835
835
|
};
|
|
836
|
-
|
|
836
|
+
BN7.prototype.uxor = function uxor(num) {
|
|
837
837
|
if (this.length > num.length) return this.clone().iuxor(num);
|
|
838
838
|
return num.clone().iuxor(this);
|
|
839
839
|
};
|
|
840
|
-
|
|
840
|
+
BN7.prototype.inotn = function inotn(width) {
|
|
841
841
|
assert(typeof width === "number" && width >= 0);
|
|
842
842
|
var bytesNeeded = Math.ceil(width / 26) | 0;
|
|
843
843
|
var bitsLeft = width % 26;
|
|
@@ -853,10 +853,10 @@ var require_bn = __commonJS({
|
|
|
853
853
|
}
|
|
854
854
|
return this._strip();
|
|
855
855
|
};
|
|
856
|
-
|
|
856
|
+
BN7.prototype.notn = function notn(width) {
|
|
857
857
|
return this.clone().inotn(width);
|
|
858
858
|
};
|
|
859
|
-
|
|
859
|
+
BN7.prototype.setn = function setn(bit, val) {
|
|
860
860
|
assert(typeof bit === "number" && bit >= 0);
|
|
861
861
|
var off = bit / 26 | 0;
|
|
862
862
|
var wbit = bit % 26;
|
|
@@ -868,7 +868,7 @@ var require_bn = __commonJS({
|
|
|
868
868
|
}
|
|
869
869
|
return this._strip();
|
|
870
870
|
};
|
|
871
|
-
|
|
871
|
+
BN7.prototype.iadd = function iadd(num) {
|
|
872
872
|
var r;
|
|
873
873
|
if (this.negative !== 0 && num.negative === 0) {
|
|
874
874
|
this.negative = 0;
|
|
@@ -911,7 +911,7 @@ var require_bn = __commonJS({
|
|
|
911
911
|
}
|
|
912
912
|
return this;
|
|
913
913
|
};
|
|
914
|
-
|
|
914
|
+
BN7.prototype.add = function add2(num) {
|
|
915
915
|
var res;
|
|
916
916
|
if (num.negative !== 0 && this.negative === 0) {
|
|
917
917
|
num.negative = 0;
|
|
@@ -927,7 +927,7 @@ var require_bn = __commonJS({
|
|
|
927
927
|
if (this.length > num.length) return this.clone().iadd(num);
|
|
928
928
|
return num.clone().iadd(this);
|
|
929
929
|
};
|
|
930
|
-
|
|
930
|
+
BN7.prototype.isub = function isub(num) {
|
|
931
931
|
if (num.negative !== 0) {
|
|
932
932
|
num.negative = 0;
|
|
933
933
|
var r = this.iadd(num);
|
|
@@ -976,7 +976,7 @@ var require_bn = __commonJS({
|
|
|
976
976
|
}
|
|
977
977
|
return this._strip();
|
|
978
978
|
};
|
|
979
|
-
|
|
979
|
+
BN7.prototype.sub = function sub2(num) {
|
|
980
980
|
return this.clone().isub(num);
|
|
981
981
|
};
|
|
982
982
|
function smallMulTo(self, num, out) {
|
|
@@ -1604,7 +1604,7 @@ var require_bn = __commonJS({
|
|
|
1604
1604
|
function jumboMulTo(self, num, out) {
|
|
1605
1605
|
return bigMulTo(self, num, out);
|
|
1606
1606
|
}
|
|
1607
|
-
|
|
1607
|
+
BN7.prototype.mulTo = function mulTo(num, out) {
|
|
1608
1608
|
var res;
|
|
1609
1609
|
var len = this.length + num.length;
|
|
1610
1610
|
if (this.length === 10 && num.length === 10) {
|
|
@@ -1618,20 +1618,20 @@ var require_bn = __commonJS({
|
|
|
1618
1618
|
}
|
|
1619
1619
|
return res;
|
|
1620
1620
|
};
|
|
1621
|
-
|
|
1622
|
-
var out = new
|
|
1621
|
+
BN7.prototype.mul = function mul2(num) {
|
|
1622
|
+
var out = new BN7(null);
|
|
1623
1623
|
out.words = new Array(this.length + num.length);
|
|
1624
1624
|
return this.mulTo(num, out);
|
|
1625
1625
|
};
|
|
1626
|
-
|
|
1627
|
-
var out = new
|
|
1626
|
+
BN7.prototype.mulf = function mulf(num) {
|
|
1627
|
+
var out = new BN7(null);
|
|
1628
1628
|
out.words = new Array(this.length + num.length);
|
|
1629
1629
|
return jumboMulTo(this, num, out);
|
|
1630
1630
|
};
|
|
1631
|
-
|
|
1631
|
+
BN7.prototype.imul = function imul(num) {
|
|
1632
1632
|
return this.clone().mulTo(num, this);
|
|
1633
1633
|
};
|
|
1634
|
-
|
|
1634
|
+
BN7.prototype.imuln = function imuln(num) {
|
|
1635
1635
|
var isNegNum = num < 0;
|
|
1636
1636
|
if (isNegNum) num = -num;
|
|
1637
1637
|
assert(typeof num === "number");
|
|
@@ -1651,18 +1651,18 @@ var require_bn = __commonJS({
|
|
|
1651
1651
|
}
|
|
1652
1652
|
return isNegNum ? this.ineg() : this;
|
|
1653
1653
|
};
|
|
1654
|
-
|
|
1654
|
+
BN7.prototype.muln = function muln(num) {
|
|
1655
1655
|
return this.clone().imuln(num);
|
|
1656
1656
|
};
|
|
1657
|
-
|
|
1657
|
+
BN7.prototype.sqr = function sqr() {
|
|
1658
1658
|
return this.mul(this);
|
|
1659
1659
|
};
|
|
1660
|
-
|
|
1660
|
+
BN7.prototype.isqr = function isqr() {
|
|
1661
1661
|
return this.imul(this.clone());
|
|
1662
1662
|
};
|
|
1663
|
-
|
|
1663
|
+
BN7.prototype.pow = function pow2(num) {
|
|
1664
1664
|
var w = toBitArray(num);
|
|
1665
|
-
if (w.length === 0) return new
|
|
1665
|
+
if (w.length === 0) return new BN7(1);
|
|
1666
1666
|
var res = this;
|
|
1667
1667
|
for (var i = 0; i < w.length; i++, res = res.sqr()) {
|
|
1668
1668
|
if (w[i] !== 0) break;
|
|
@@ -1675,7 +1675,7 @@ var require_bn = __commonJS({
|
|
|
1675
1675
|
}
|
|
1676
1676
|
return res;
|
|
1677
1677
|
};
|
|
1678
|
-
|
|
1678
|
+
BN7.prototype.iushln = function iushln(bits) {
|
|
1679
1679
|
assert(typeof bits === "number" && bits >= 0);
|
|
1680
1680
|
var r = bits % 26;
|
|
1681
1681
|
var s = (bits - r) / 26;
|
|
@@ -1705,11 +1705,11 @@ var require_bn = __commonJS({
|
|
|
1705
1705
|
}
|
|
1706
1706
|
return this._strip();
|
|
1707
1707
|
};
|
|
1708
|
-
|
|
1708
|
+
BN7.prototype.ishln = function ishln(bits) {
|
|
1709
1709
|
assert(this.negative === 0);
|
|
1710
1710
|
return this.iushln(bits);
|
|
1711
1711
|
};
|
|
1712
|
-
|
|
1712
|
+
BN7.prototype.iushrn = function iushrn(bits, hint, extended) {
|
|
1713
1713
|
assert(typeof bits === "number" && bits >= 0);
|
|
1714
1714
|
var h;
|
|
1715
1715
|
if (hint) {
|
|
@@ -1753,23 +1753,23 @@ var require_bn = __commonJS({
|
|
|
1753
1753
|
}
|
|
1754
1754
|
return this._strip();
|
|
1755
1755
|
};
|
|
1756
|
-
|
|
1756
|
+
BN7.prototype.ishrn = function ishrn(bits, hint, extended) {
|
|
1757
1757
|
assert(this.negative === 0);
|
|
1758
1758
|
return this.iushrn(bits, hint, extended);
|
|
1759
1759
|
};
|
|
1760
|
-
|
|
1760
|
+
BN7.prototype.shln = function shln(bits) {
|
|
1761
1761
|
return this.clone().ishln(bits);
|
|
1762
1762
|
};
|
|
1763
|
-
|
|
1763
|
+
BN7.prototype.ushln = function ushln(bits) {
|
|
1764
1764
|
return this.clone().iushln(bits);
|
|
1765
1765
|
};
|
|
1766
|
-
|
|
1766
|
+
BN7.prototype.shrn = function shrn(bits) {
|
|
1767
1767
|
return this.clone().ishrn(bits);
|
|
1768
1768
|
};
|
|
1769
|
-
|
|
1769
|
+
BN7.prototype.ushrn = function ushrn(bits) {
|
|
1770
1770
|
return this.clone().iushrn(bits);
|
|
1771
1771
|
};
|
|
1772
|
-
|
|
1772
|
+
BN7.prototype.testn = function testn(bit) {
|
|
1773
1773
|
assert(typeof bit === "number" && bit >= 0);
|
|
1774
1774
|
var r = bit % 26;
|
|
1775
1775
|
var s = (bit - r) / 26;
|
|
@@ -1778,7 +1778,7 @@ var require_bn = __commonJS({
|
|
|
1778
1778
|
var w = this.words[s];
|
|
1779
1779
|
return !!(w & q);
|
|
1780
1780
|
};
|
|
1781
|
-
|
|
1781
|
+
BN7.prototype.imaskn = function imaskn(bits) {
|
|
1782
1782
|
assert(typeof bits === "number" && bits >= 0);
|
|
1783
1783
|
var r = bits % 26;
|
|
1784
1784
|
var s = (bits - r) / 26;
|
|
@@ -1796,10 +1796,10 @@ var require_bn = __commonJS({
|
|
|
1796
1796
|
}
|
|
1797
1797
|
return this._strip();
|
|
1798
1798
|
};
|
|
1799
|
-
|
|
1799
|
+
BN7.prototype.maskn = function maskn(bits) {
|
|
1800
1800
|
return this.clone().imaskn(bits);
|
|
1801
1801
|
};
|
|
1802
|
-
|
|
1802
|
+
BN7.prototype.iaddn = function iaddn(num) {
|
|
1803
1803
|
assert(typeof num === "number");
|
|
1804
1804
|
assert(num < 67108864);
|
|
1805
1805
|
if (num < 0) return this.isubn(-num);
|
|
@@ -1816,7 +1816,7 @@ var require_bn = __commonJS({
|
|
|
1816
1816
|
}
|
|
1817
1817
|
return this._iaddn(num);
|
|
1818
1818
|
};
|
|
1819
|
-
|
|
1819
|
+
BN7.prototype._iaddn = function _iaddn(num) {
|
|
1820
1820
|
this.words[0] += num;
|
|
1821
1821
|
for (var i = 0; i < this.length && this.words[i] >= 67108864; i++) {
|
|
1822
1822
|
this.words[i] -= 67108864;
|
|
@@ -1829,7 +1829,7 @@ var require_bn = __commonJS({
|
|
|
1829
1829
|
this.length = Math.max(this.length, i + 1);
|
|
1830
1830
|
return this;
|
|
1831
1831
|
};
|
|
1832
|
-
|
|
1832
|
+
BN7.prototype.isubn = function isubn(num) {
|
|
1833
1833
|
assert(typeof num === "number");
|
|
1834
1834
|
assert(num < 67108864);
|
|
1835
1835
|
if (num < 0) return this.iaddn(-num);
|
|
@@ -1851,20 +1851,20 @@ var require_bn = __commonJS({
|
|
|
1851
1851
|
}
|
|
1852
1852
|
return this._strip();
|
|
1853
1853
|
};
|
|
1854
|
-
|
|
1854
|
+
BN7.prototype.addn = function addn(num) {
|
|
1855
1855
|
return this.clone().iaddn(num);
|
|
1856
1856
|
};
|
|
1857
|
-
|
|
1857
|
+
BN7.prototype.subn = function subn(num) {
|
|
1858
1858
|
return this.clone().isubn(num);
|
|
1859
1859
|
};
|
|
1860
|
-
|
|
1860
|
+
BN7.prototype.iabs = function iabs() {
|
|
1861
1861
|
this.negative = 0;
|
|
1862
1862
|
return this;
|
|
1863
1863
|
};
|
|
1864
|
-
|
|
1864
|
+
BN7.prototype.abs = function abs2() {
|
|
1865
1865
|
return this.clone().iabs();
|
|
1866
1866
|
};
|
|
1867
|
-
|
|
1867
|
+
BN7.prototype._ishlnsubmul = function _ishlnsubmul(num, mul2, shift) {
|
|
1868
1868
|
var len = num.length + shift;
|
|
1869
1869
|
var i;
|
|
1870
1870
|
this._expand(len);
|
|
@@ -1893,7 +1893,7 @@ var require_bn = __commonJS({
|
|
|
1893
1893
|
this.negative = 1;
|
|
1894
1894
|
return this._strip();
|
|
1895
1895
|
};
|
|
1896
|
-
|
|
1896
|
+
BN7.prototype._wordDiv = function _wordDiv(num, mode) {
|
|
1897
1897
|
var shift = this.length - num.length;
|
|
1898
1898
|
var a = this.clone();
|
|
1899
1899
|
var b = num;
|
|
@@ -1908,7 +1908,7 @@ var require_bn = __commonJS({
|
|
|
1908
1908
|
var m = a.length - b.length;
|
|
1909
1909
|
var q;
|
|
1910
1910
|
if (mode !== "mod") {
|
|
1911
|
-
q = new
|
|
1911
|
+
q = new BN7(null);
|
|
1912
1912
|
q.length = m + 1;
|
|
1913
1913
|
q.words = new Array(q.length);
|
|
1914
1914
|
for (var i = 0; i < q.length; i++) {
|
|
@@ -1950,12 +1950,12 @@ var require_bn = __commonJS({
|
|
|
1950
1950
|
mod: a
|
|
1951
1951
|
};
|
|
1952
1952
|
};
|
|
1953
|
-
|
|
1953
|
+
BN7.prototype.divmod = function divmod(num, mode, positive) {
|
|
1954
1954
|
assert(!num.isZero());
|
|
1955
1955
|
if (this.isZero()) {
|
|
1956
1956
|
return {
|
|
1957
|
-
div: new
|
|
1958
|
-
mod: new
|
|
1957
|
+
div: new BN7(0),
|
|
1958
|
+
mod: new BN7(0)
|
|
1959
1959
|
};
|
|
1960
1960
|
}
|
|
1961
1961
|
var div2, mod2, res;
|
|
@@ -2000,7 +2000,7 @@ var require_bn = __commonJS({
|
|
|
2000
2000
|
}
|
|
2001
2001
|
if (num.length > this.length || this.cmp(num) < 0) {
|
|
2002
2002
|
return {
|
|
2003
|
-
div: new
|
|
2003
|
+
div: new BN7(0),
|
|
2004
2004
|
mod: this
|
|
2005
2005
|
};
|
|
2006
2006
|
}
|
|
@@ -2014,26 +2014,26 @@ var require_bn = __commonJS({
|
|
|
2014
2014
|
if (mode === "mod") {
|
|
2015
2015
|
return {
|
|
2016
2016
|
div: null,
|
|
2017
|
-
mod: new
|
|
2017
|
+
mod: new BN7(this.modrn(num.words[0]))
|
|
2018
2018
|
};
|
|
2019
2019
|
}
|
|
2020
2020
|
return {
|
|
2021
2021
|
div: this.divn(num.words[0]),
|
|
2022
|
-
mod: new
|
|
2022
|
+
mod: new BN7(this.modrn(num.words[0]))
|
|
2023
2023
|
};
|
|
2024
2024
|
}
|
|
2025
2025
|
return this._wordDiv(num, mode);
|
|
2026
2026
|
};
|
|
2027
|
-
|
|
2027
|
+
BN7.prototype.div = function div2(num) {
|
|
2028
2028
|
return this.divmod(num, "div", false).div;
|
|
2029
2029
|
};
|
|
2030
|
-
|
|
2030
|
+
BN7.prototype.mod = function mod2(num) {
|
|
2031
2031
|
return this.divmod(num, "mod", false).mod;
|
|
2032
2032
|
};
|
|
2033
|
-
|
|
2033
|
+
BN7.prototype.umod = function umod(num) {
|
|
2034
2034
|
return this.divmod(num, "mod", true).mod;
|
|
2035
2035
|
};
|
|
2036
|
-
|
|
2036
|
+
BN7.prototype.divRound = function divRound(num) {
|
|
2037
2037
|
var dm = this.divmod(num);
|
|
2038
2038
|
if (dm.mod.isZero()) return dm.div;
|
|
2039
2039
|
var mod2 = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
|
|
@@ -2043,7 +2043,7 @@ var require_bn = __commonJS({
|
|
|
2043
2043
|
if (cmp2 < 0 || r2 === 1 && cmp2 === 0) return dm.div;
|
|
2044
2044
|
return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
|
|
2045
2045
|
};
|
|
2046
|
-
|
|
2046
|
+
BN7.prototype.modrn = function modrn(num) {
|
|
2047
2047
|
var isNegNum = num < 0;
|
|
2048
2048
|
if (isNegNum) num = -num;
|
|
2049
2049
|
assert(num <= 67108863);
|
|
@@ -2054,10 +2054,10 @@ var require_bn = __commonJS({
|
|
|
2054
2054
|
}
|
|
2055
2055
|
return isNegNum ? -acc : acc;
|
|
2056
2056
|
};
|
|
2057
|
-
|
|
2057
|
+
BN7.prototype.modn = function modn(num) {
|
|
2058
2058
|
return this.modrn(num);
|
|
2059
2059
|
};
|
|
2060
|
-
|
|
2060
|
+
BN7.prototype.idivn = function idivn(num) {
|
|
2061
2061
|
var isNegNum = num < 0;
|
|
2062
2062
|
if (isNegNum) num = -num;
|
|
2063
2063
|
assert(num <= 67108863);
|
|
@@ -2070,10 +2070,10 @@ var require_bn = __commonJS({
|
|
|
2070
2070
|
this._strip();
|
|
2071
2071
|
return isNegNum ? this.ineg() : this;
|
|
2072
2072
|
};
|
|
2073
|
-
|
|
2073
|
+
BN7.prototype.divn = function divn(num) {
|
|
2074
2074
|
return this.clone().idivn(num);
|
|
2075
2075
|
};
|
|
2076
|
-
|
|
2076
|
+
BN7.prototype.egcd = function egcd(p) {
|
|
2077
2077
|
assert(p.negative === 0);
|
|
2078
2078
|
assert(!p.isZero());
|
|
2079
2079
|
var x = this;
|
|
@@ -2083,10 +2083,10 @@ var require_bn = __commonJS({
|
|
|
2083
2083
|
} else {
|
|
2084
2084
|
x = x.clone();
|
|
2085
2085
|
}
|
|
2086
|
-
var A = new
|
|
2087
|
-
var B = new
|
|
2088
|
-
var C = new
|
|
2089
|
-
var D = new
|
|
2086
|
+
var A = new BN7(1);
|
|
2087
|
+
var B = new BN7(0);
|
|
2088
|
+
var C = new BN7(0);
|
|
2089
|
+
var D = new BN7(1);
|
|
2090
2090
|
var g = 0;
|
|
2091
2091
|
while (x.isEven() && y.isEven()) {
|
|
2092
2092
|
x.iushrn(1);
|
|
@@ -2136,7 +2136,7 @@ var require_bn = __commonJS({
|
|
|
2136
2136
|
gcd: y.iushln(g)
|
|
2137
2137
|
};
|
|
2138
2138
|
};
|
|
2139
|
-
|
|
2139
|
+
BN7.prototype._invmp = function _invmp(p) {
|
|
2140
2140
|
assert(p.negative === 0);
|
|
2141
2141
|
assert(!p.isZero());
|
|
2142
2142
|
var a = this;
|
|
@@ -2146,8 +2146,8 @@ var require_bn = __commonJS({
|
|
|
2146
2146
|
} else {
|
|
2147
2147
|
a = a.clone();
|
|
2148
2148
|
}
|
|
2149
|
-
var x1 = new
|
|
2150
|
-
var x2 = new
|
|
2149
|
+
var x1 = new BN7(1);
|
|
2150
|
+
var x2 = new BN7(0);
|
|
2151
2151
|
var delta = b.clone();
|
|
2152
2152
|
while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
|
|
2153
2153
|
for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1) ;
|
|
@@ -2189,7 +2189,7 @@ var require_bn = __commonJS({
|
|
|
2189
2189
|
}
|
|
2190
2190
|
return res;
|
|
2191
2191
|
};
|
|
2192
|
-
|
|
2192
|
+
BN7.prototype.gcd = function gcd(num) {
|
|
2193
2193
|
if (this.isZero()) return num.abs();
|
|
2194
2194
|
if (num.isZero()) return this.abs();
|
|
2195
2195
|
var a = this.clone();
|
|
@@ -2219,19 +2219,19 @@ var require_bn = __commonJS({
|
|
|
2219
2219
|
} while (true);
|
|
2220
2220
|
return b.iushln(shift);
|
|
2221
2221
|
};
|
|
2222
|
-
|
|
2222
|
+
BN7.prototype.invm = function invm(num) {
|
|
2223
2223
|
return this.egcd(num).a.umod(num);
|
|
2224
2224
|
};
|
|
2225
|
-
|
|
2225
|
+
BN7.prototype.isEven = function isEven() {
|
|
2226
2226
|
return (this.words[0] & 1) === 0;
|
|
2227
2227
|
};
|
|
2228
|
-
|
|
2228
|
+
BN7.prototype.isOdd = function isOdd2() {
|
|
2229
2229
|
return (this.words[0] & 1) === 1;
|
|
2230
2230
|
};
|
|
2231
|
-
|
|
2231
|
+
BN7.prototype.andln = function andln(num) {
|
|
2232
2232
|
return this.words[0] & num;
|
|
2233
2233
|
};
|
|
2234
|
-
|
|
2234
|
+
BN7.prototype.bincn = function bincn(bit) {
|
|
2235
2235
|
assert(typeof bit === "number");
|
|
2236
2236
|
var r = bit % 26;
|
|
2237
2237
|
var s = (bit - r) / 26;
|
|
@@ -2255,10 +2255,10 @@ var require_bn = __commonJS({
|
|
|
2255
2255
|
}
|
|
2256
2256
|
return this;
|
|
2257
2257
|
};
|
|
2258
|
-
|
|
2258
|
+
BN7.prototype.isZero = function isZero() {
|
|
2259
2259
|
return this.length === 1 && this.words[0] === 0;
|
|
2260
2260
|
};
|
|
2261
|
-
|
|
2261
|
+
BN7.prototype.cmpn = function cmpn(num) {
|
|
2262
2262
|
var negative = num < 0;
|
|
2263
2263
|
if (this.negative !== 0 && !negative) return -1;
|
|
2264
2264
|
if (this.negative === 0 && negative) return 1;
|
|
@@ -2277,14 +2277,14 @@ var require_bn = __commonJS({
|
|
|
2277
2277
|
if (this.negative !== 0) return -res | 0;
|
|
2278
2278
|
return res;
|
|
2279
2279
|
};
|
|
2280
|
-
|
|
2280
|
+
BN7.prototype.cmp = function cmp2(num) {
|
|
2281
2281
|
if (this.negative !== 0 && num.negative === 0) return -1;
|
|
2282
2282
|
if (this.negative === 0 && num.negative !== 0) return 1;
|
|
2283
2283
|
var res = this.ucmp(num);
|
|
2284
2284
|
if (this.negative !== 0) return -res | 0;
|
|
2285
2285
|
return res;
|
|
2286
2286
|
};
|
|
2287
|
-
|
|
2287
|
+
BN7.prototype.ucmp = function ucmp(num) {
|
|
2288
2288
|
if (this.length > num.length) return 1;
|
|
2289
2289
|
if (this.length < num.length) return -1;
|
|
2290
2290
|
var res = 0;
|
|
@@ -2301,112 +2301,112 @@ var require_bn = __commonJS({
|
|
|
2301
2301
|
}
|
|
2302
2302
|
return res;
|
|
2303
2303
|
};
|
|
2304
|
-
|
|
2304
|
+
BN7.prototype.gtn = function gtn(num) {
|
|
2305
2305
|
return this.cmpn(num) === 1;
|
|
2306
2306
|
};
|
|
2307
|
-
|
|
2307
|
+
BN7.prototype.gt = function gt(num) {
|
|
2308
2308
|
return this.cmp(num) === 1;
|
|
2309
2309
|
};
|
|
2310
|
-
|
|
2310
|
+
BN7.prototype.gten = function gten(num) {
|
|
2311
2311
|
return this.cmpn(num) >= 0;
|
|
2312
2312
|
};
|
|
2313
|
-
|
|
2313
|
+
BN7.prototype.gte = function gte(num) {
|
|
2314
2314
|
return this.cmp(num) >= 0;
|
|
2315
2315
|
};
|
|
2316
|
-
|
|
2316
|
+
BN7.prototype.ltn = function ltn(num) {
|
|
2317
2317
|
return this.cmpn(num) === -1;
|
|
2318
2318
|
};
|
|
2319
|
-
|
|
2319
|
+
BN7.prototype.lt = function lt(num) {
|
|
2320
2320
|
return this.cmp(num) === -1;
|
|
2321
2321
|
};
|
|
2322
|
-
|
|
2322
|
+
BN7.prototype.lten = function lten(num) {
|
|
2323
2323
|
return this.cmpn(num) <= 0;
|
|
2324
2324
|
};
|
|
2325
|
-
|
|
2325
|
+
BN7.prototype.lte = function lte(num) {
|
|
2326
2326
|
return this.cmp(num) <= 0;
|
|
2327
2327
|
};
|
|
2328
|
-
|
|
2328
|
+
BN7.prototype.eqn = function eqn(num) {
|
|
2329
2329
|
return this.cmpn(num) === 0;
|
|
2330
2330
|
};
|
|
2331
|
-
|
|
2331
|
+
BN7.prototype.eq = function eq(num) {
|
|
2332
2332
|
return this.cmp(num) === 0;
|
|
2333
2333
|
};
|
|
2334
|
-
|
|
2334
|
+
BN7.red = function red(num) {
|
|
2335
2335
|
return new Red(num);
|
|
2336
2336
|
};
|
|
2337
|
-
|
|
2337
|
+
BN7.prototype.toRed = function toRed(ctx) {
|
|
2338
2338
|
assert(!this.red, "Already a number in reduction context");
|
|
2339
2339
|
assert(this.negative === 0, "red works only with positives");
|
|
2340
2340
|
return ctx.convertTo(this)._forceRed(ctx);
|
|
2341
2341
|
};
|
|
2342
|
-
|
|
2342
|
+
BN7.prototype.fromRed = function fromRed() {
|
|
2343
2343
|
assert(this.red, "fromRed works only with numbers in reduction context");
|
|
2344
2344
|
return this.red.convertFrom(this);
|
|
2345
2345
|
};
|
|
2346
|
-
|
|
2346
|
+
BN7.prototype._forceRed = function _forceRed(ctx) {
|
|
2347
2347
|
this.red = ctx;
|
|
2348
2348
|
return this;
|
|
2349
2349
|
};
|
|
2350
|
-
|
|
2350
|
+
BN7.prototype.forceRed = function forceRed(ctx) {
|
|
2351
2351
|
assert(!this.red, "Already a number in reduction context");
|
|
2352
2352
|
return this._forceRed(ctx);
|
|
2353
2353
|
};
|
|
2354
|
-
|
|
2354
|
+
BN7.prototype.redAdd = function redAdd(num) {
|
|
2355
2355
|
assert(this.red, "redAdd works only with red numbers");
|
|
2356
2356
|
return this.red.add(this, num);
|
|
2357
2357
|
};
|
|
2358
|
-
|
|
2358
|
+
BN7.prototype.redIAdd = function redIAdd(num) {
|
|
2359
2359
|
assert(this.red, "redIAdd works only with red numbers");
|
|
2360
2360
|
return this.red.iadd(this, num);
|
|
2361
2361
|
};
|
|
2362
|
-
|
|
2362
|
+
BN7.prototype.redSub = function redSub(num) {
|
|
2363
2363
|
assert(this.red, "redSub works only with red numbers");
|
|
2364
2364
|
return this.red.sub(this, num);
|
|
2365
2365
|
};
|
|
2366
|
-
|
|
2366
|
+
BN7.prototype.redISub = function redISub(num) {
|
|
2367
2367
|
assert(this.red, "redISub works only with red numbers");
|
|
2368
2368
|
return this.red.isub(this, num);
|
|
2369
2369
|
};
|
|
2370
|
-
|
|
2370
|
+
BN7.prototype.redShl = function redShl(num) {
|
|
2371
2371
|
assert(this.red, "redShl works only with red numbers");
|
|
2372
2372
|
return this.red.shl(this, num);
|
|
2373
2373
|
};
|
|
2374
|
-
|
|
2374
|
+
BN7.prototype.redMul = function redMul(num) {
|
|
2375
2375
|
assert(this.red, "redMul works only with red numbers");
|
|
2376
2376
|
this.red._verify2(this, num);
|
|
2377
2377
|
return this.red.mul(this, num);
|
|
2378
2378
|
};
|
|
2379
|
-
|
|
2379
|
+
BN7.prototype.redIMul = function redIMul(num) {
|
|
2380
2380
|
assert(this.red, "redMul works only with red numbers");
|
|
2381
2381
|
this.red._verify2(this, num);
|
|
2382
2382
|
return this.red.imul(this, num);
|
|
2383
2383
|
};
|
|
2384
|
-
|
|
2384
|
+
BN7.prototype.redSqr = function redSqr() {
|
|
2385
2385
|
assert(this.red, "redSqr works only with red numbers");
|
|
2386
2386
|
this.red._verify1(this);
|
|
2387
2387
|
return this.red.sqr(this);
|
|
2388
2388
|
};
|
|
2389
|
-
|
|
2389
|
+
BN7.prototype.redISqr = function redISqr() {
|
|
2390
2390
|
assert(this.red, "redISqr works only with red numbers");
|
|
2391
2391
|
this.red._verify1(this);
|
|
2392
2392
|
return this.red.isqr(this);
|
|
2393
2393
|
};
|
|
2394
|
-
|
|
2394
|
+
BN7.prototype.redSqrt = function redSqrt() {
|
|
2395
2395
|
assert(this.red, "redSqrt works only with red numbers");
|
|
2396
2396
|
this.red._verify1(this);
|
|
2397
2397
|
return this.red.sqrt(this);
|
|
2398
2398
|
};
|
|
2399
|
-
|
|
2399
|
+
BN7.prototype.redInvm = function redInvm() {
|
|
2400
2400
|
assert(this.red, "redInvm works only with red numbers");
|
|
2401
2401
|
this.red._verify1(this);
|
|
2402
2402
|
return this.red.invm(this);
|
|
2403
2403
|
};
|
|
2404
|
-
|
|
2404
|
+
BN7.prototype.redNeg = function redNeg() {
|
|
2405
2405
|
assert(this.red, "redNeg works only with red numbers");
|
|
2406
2406
|
this.red._verify1(this);
|
|
2407
2407
|
return this.red.neg(this);
|
|
2408
2408
|
};
|
|
2409
|
-
|
|
2409
|
+
BN7.prototype.redPow = function redPow(num) {
|
|
2410
2410
|
assert(this.red && !num.red, "redPow(normalNum)");
|
|
2411
2411
|
this.red._verify1(this);
|
|
2412
2412
|
return this.red.pow(this, num);
|
|
@@ -2419,13 +2419,13 @@ var require_bn = __commonJS({
|
|
|
2419
2419
|
};
|
|
2420
2420
|
function MPrime(name, p) {
|
|
2421
2421
|
this.name = name;
|
|
2422
|
-
this.p = new
|
|
2422
|
+
this.p = new BN7(p, 16);
|
|
2423
2423
|
this.n = this.p.bitLength();
|
|
2424
|
-
this.k = new
|
|
2424
|
+
this.k = new BN7(1).iushln(this.n).isub(this.p);
|
|
2425
2425
|
this.tmp = this._tmp();
|
|
2426
2426
|
}
|
|
2427
2427
|
MPrime.prototype._tmp = function _tmp() {
|
|
2428
|
-
var tmp = new
|
|
2428
|
+
var tmp = new BN7(null);
|
|
2429
2429
|
tmp.words = new Array(Math.ceil(this.n / 13));
|
|
2430
2430
|
return tmp;
|
|
2431
2431
|
};
|
|
@@ -2551,7 +2551,7 @@ var require_bn = __commonJS({
|
|
|
2551
2551
|
}
|
|
2552
2552
|
return num;
|
|
2553
2553
|
};
|
|
2554
|
-
|
|
2554
|
+
BN7._prime = function prime(name) {
|
|
2555
2555
|
if (primes[name]) return primes[name];
|
|
2556
2556
|
var prime2;
|
|
2557
2557
|
if (name === "k256") {
|
|
@@ -2570,7 +2570,7 @@ var require_bn = __commonJS({
|
|
|
2570
2570
|
};
|
|
2571
2571
|
function Red(m) {
|
|
2572
2572
|
if (typeof m === "string") {
|
|
2573
|
-
var prime =
|
|
2573
|
+
var prime = BN7._prime(m);
|
|
2574
2574
|
this.m = prime.p;
|
|
2575
2575
|
this.prime = prime;
|
|
2576
2576
|
} else {
|
|
@@ -2656,7 +2656,7 @@ var require_bn = __commonJS({
|
|
|
2656
2656
|
var mod3 = this.m.andln(3);
|
|
2657
2657
|
assert(mod3 % 2 === 1);
|
|
2658
2658
|
if (mod3 === 3) {
|
|
2659
|
-
var pow2 = this.m.add(new
|
|
2659
|
+
var pow2 = this.m.add(new BN7(1)).iushrn(2);
|
|
2660
2660
|
return this.pow(a, pow2);
|
|
2661
2661
|
}
|
|
2662
2662
|
var q = this.m.subn(1);
|
|
@@ -2666,11 +2666,11 @@ var require_bn = __commonJS({
|
|
|
2666
2666
|
q.iushrn(1);
|
|
2667
2667
|
}
|
|
2668
2668
|
assert(!q.isZero());
|
|
2669
|
-
var one = new
|
|
2669
|
+
var one = new BN7(1).toRed(this);
|
|
2670
2670
|
var nOne = one.redNeg();
|
|
2671
2671
|
var lpow = this.m.subn(1).iushrn(1);
|
|
2672
2672
|
var z = this.m.bitLength();
|
|
2673
|
-
z = new
|
|
2673
|
+
z = new BN7(2 * z * z).toRed(this);
|
|
2674
2674
|
while (this.pow(z, lpow).cmp(nOne) !== 0) {
|
|
2675
2675
|
z.redIAdd(nOne);
|
|
2676
2676
|
}
|
|
@@ -2684,7 +2684,7 @@ var require_bn = __commonJS({
|
|
|
2684
2684
|
tmp = tmp.redSqr();
|
|
2685
2685
|
}
|
|
2686
2686
|
assert(i < m);
|
|
2687
|
-
var b = this.pow(c, new
|
|
2687
|
+
var b = this.pow(c, new BN7(1).iushln(m - i - 1));
|
|
2688
2688
|
r = r.redMul(b);
|
|
2689
2689
|
c = b.redSqr();
|
|
2690
2690
|
t = t.redMul(c);
|
|
@@ -2702,11 +2702,11 @@ var require_bn = __commonJS({
|
|
|
2702
2702
|
}
|
|
2703
2703
|
};
|
|
2704
2704
|
Red.prototype.pow = function pow2(a, num) {
|
|
2705
|
-
if (num.isZero()) return new
|
|
2705
|
+
if (num.isZero()) return new BN7(1).toRed(this);
|
|
2706
2706
|
if (num.cmpn(1) === 0) return a.clone();
|
|
2707
2707
|
var windowSize = 4;
|
|
2708
2708
|
var wnd = new Array(1 << windowSize);
|
|
2709
|
-
wnd[0] = new
|
|
2709
|
+
wnd[0] = new BN7(1).toRed(this);
|
|
2710
2710
|
wnd[1] = a;
|
|
2711
2711
|
for (var i = 2; i < wnd.length; i++) {
|
|
2712
2712
|
wnd[i] = this.mul(wnd[i - 1], a);
|
|
@@ -2750,7 +2750,7 @@ var require_bn = __commonJS({
|
|
|
2750
2750
|
res.red = null;
|
|
2751
2751
|
return res;
|
|
2752
2752
|
};
|
|
2753
|
-
|
|
2753
|
+
BN7.mont = function mont(num) {
|
|
2754
2754
|
return new Mont(num);
|
|
2755
2755
|
};
|
|
2756
2756
|
function Mont(m) {
|
|
@@ -2759,7 +2759,7 @@ var require_bn = __commonJS({
|
|
|
2759
2759
|
if (this.shift % 26 !== 0) {
|
|
2760
2760
|
this.shift += 26 - this.shift % 26;
|
|
2761
2761
|
}
|
|
2762
|
-
this.r = new
|
|
2762
|
+
this.r = new BN7(1).iushln(this.shift);
|
|
2763
2763
|
this.r2 = this.imod(this.r.sqr());
|
|
2764
2764
|
this.rinv = this.r._invmp(this.m);
|
|
2765
2765
|
this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
|
|
@@ -2793,7 +2793,7 @@ var require_bn = __commonJS({
|
|
|
2793
2793
|
return res._forceRed(this);
|
|
2794
2794
|
};
|
|
2795
2795
|
Mont.prototype.mul = function mul2(a, b) {
|
|
2796
|
-
if (a.isZero() || b.isZero()) return new
|
|
2796
|
+
if (a.isZero() || b.isZero()) return new BN7(0)._forceRed(this);
|
|
2797
2797
|
var t = a.mul(b);
|
|
2798
2798
|
var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
|
|
2799
2799
|
var u = t.isub(c).iushrn(this.shift);
|
|
@@ -5855,7 +5855,6 @@ var Haedal = class {
|
|
|
5855
5855
|
throw new Error("Haedal not support b2a swap");
|
|
5856
5856
|
}
|
|
5857
5857
|
const func = "swap_a2b";
|
|
5858
|
-
console.log("haedal path id", path.id);
|
|
5859
5858
|
const args = [txb.object(path.id), txb.object("0x5"), inputCoin];
|
|
5860
5859
|
const res = txb.moveCall({
|
|
5861
5860
|
target: `${client.publishedAt()}::haedal::${func}`,
|
|
@@ -5935,18 +5934,49 @@ var Volo = class {
|
|
|
5935
5934
|
}
|
|
5936
5935
|
};
|
|
5937
5936
|
|
|
5937
|
+
// src/transaction/flowx_v3.ts
|
|
5938
|
+
var FlowxV3 = class {
|
|
5939
|
+
constructor(env) {
|
|
5940
|
+
if (env !== 0 /* Mainnet */) {
|
|
5941
|
+
throw new Error("Flowx clmm only supported on mainnet");
|
|
5942
|
+
}
|
|
5943
|
+
this.versioned = "0x67624a1533b5aff5d0dfcf5e598684350efd38134d2d245f475524c03a64e656";
|
|
5944
|
+
this.poolRegistry = "0x27565d24a4cd51127ac90e4074a841bbe356cca7bf5759ddc14a975be1632abc";
|
|
5945
|
+
}
|
|
5946
|
+
swap(client, txb, path, inputCoin) {
|
|
5947
|
+
return __async(this, null, function* () {
|
|
5948
|
+
const { direction, from, target } = path;
|
|
5949
|
+
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
5950
|
+
const args = [
|
|
5951
|
+
txb.object(this.poolRegistry),
|
|
5952
|
+
txb.pure.u64(path.feeRate * 1e6),
|
|
5953
|
+
inputCoin,
|
|
5954
|
+
txb.object(this.versioned),
|
|
5955
|
+
txb.object(CLOCK_ADDRESS)
|
|
5956
|
+
];
|
|
5957
|
+
const res = txb.moveCall({
|
|
5958
|
+
target: `${client.publishedAt()}::flowx_clmm::${func}`,
|
|
5959
|
+
typeArguments: [coinAType, coinBType],
|
|
5960
|
+
arguments: args
|
|
5961
|
+
});
|
|
5962
|
+
return res;
|
|
5963
|
+
});
|
|
5964
|
+
}
|
|
5965
|
+
};
|
|
5966
|
+
|
|
5938
5967
|
// src/client.ts
|
|
5939
5968
|
var CETUS = "CETUS";
|
|
5940
5969
|
var DEEPBOOKV2 = "DEEPBOOK";
|
|
5941
5970
|
var KRIYA = "KRIYA";
|
|
5942
5971
|
var FLOWXV2 = "FLOWX";
|
|
5972
|
+
var FLOWXV3 = "FLOWXV3";
|
|
5943
5973
|
var KRIYAV3 = "KRIYAV3";
|
|
5944
5974
|
var TURBOS = "TURBOS";
|
|
5945
5975
|
var AFTERMATH = "AFTERMATH";
|
|
5946
5976
|
var HAEDAL = "HAEDAL";
|
|
5947
5977
|
var VOLO = "VOLO";
|
|
5948
5978
|
var AFSUI = "AFSUI";
|
|
5949
|
-
var
|
|
5979
|
+
var AggregatorClient6 = class {
|
|
5950
5980
|
constructor(endpoint, signer, client, env) {
|
|
5951
5981
|
this.endpoint = endpoint;
|
|
5952
5982
|
this.client = client;
|
|
@@ -6225,6 +6255,8 @@ var AggregatorClient5 = class {
|
|
|
6225
6255
|
return new KriyaV3(this.env);
|
|
6226
6256
|
case FLOWXV2:
|
|
6227
6257
|
return new FlowxV2(this.env);
|
|
6258
|
+
case FLOWXV3:
|
|
6259
|
+
return new FlowxV3(this.env);
|
|
6228
6260
|
case TURBOS:
|
|
6229
6261
|
return new Turbos(this.env);
|
|
6230
6262
|
case AFTERMATH:
|
|
@@ -6317,6 +6349,31 @@ function parseRouterResponse(data) {
|
|
|
6317
6349
|
// src/transaction/index.ts
|
|
6318
6350
|
var CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
|
|
6319
6351
|
|
|
6352
|
+
// src/utils/msafe.ts
|
|
6353
|
+
var import_bn6 = __toESM(require_bn());
|
|
6354
|
+
var dealWithFastRouterSwapParamsForMsafe = (data) => {
|
|
6355
|
+
const result = data.map((route) => {
|
|
6356
|
+
return __spreadProps(__spreadValues({}, route), {
|
|
6357
|
+
amountIn: route.amountIn.toString(),
|
|
6358
|
+
amountOut: route.amountOut.toString(),
|
|
6359
|
+
initialPrice: route.initialPrice.toString(),
|
|
6360
|
+
path: route.path
|
|
6361
|
+
});
|
|
6362
|
+
});
|
|
6363
|
+
return result;
|
|
6364
|
+
};
|
|
6365
|
+
var restituteMsafeFastRouterSwapParams = (data) => {
|
|
6366
|
+
const result = data.map((route) => {
|
|
6367
|
+
return __spreadProps(__spreadValues({}, route), {
|
|
6368
|
+
amountIn: new import_bn6.default(route.amountIn),
|
|
6369
|
+
amountOut: new import_bn6.default(route.amountOut),
|
|
6370
|
+
initialPrice: new decimal_default(route.initialPrice.toString()),
|
|
6371
|
+
path: route.path
|
|
6372
|
+
});
|
|
6373
|
+
});
|
|
6374
|
+
return result;
|
|
6375
|
+
};
|
|
6376
|
+
|
|
6320
6377
|
// src/api.ts
|
|
6321
6378
|
function getRouterResult(endpoint, params) {
|
|
6322
6379
|
return __async(this, null, function* () {
|
|
@@ -6405,4 +6462,4 @@ decimal.js/decimal.mjs:
|
|
|
6405
6462
|
*)
|
|
6406
6463
|
*/
|
|
6407
6464
|
|
|
6408
|
-
export { AFSUI, AFTERMATH,
|
|
6465
|
+
export { AFSUI, AFTERMATH, AggregatorClient6 as AggregatorClient, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, Env, FLOWXV2, FLOWXV3, HAEDAL, KRIYA, KRIYAV3, ONE, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, restituteMsafeFastRouterSwapParams };
|