starknet 5.3.0 → 5.4.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/CHANGELOG.md +17 -0
- package/dist/index.d.ts +65 -41
- package/dist/index.global.js +842 -1991
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +95 -58
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +94 -57
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -3
package/dist/index.global.js
CHANGED
|
@@ -540,1880 +540,105 @@ var starknet = (() => {
|
|
|
540
540
|
}
|
|
541
541
|
});
|
|
542
542
|
|
|
543
|
-
// node_modules/
|
|
544
|
-
var
|
|
545
|
-
"node_modules/
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
if (
|
|
566
|
-
|
|
567
|
-
if (!v.c || v.e > MAX_EXP) {
|
|
568
|
-
x.c = x.e = null;
|
|
569
|
-
} else if (v.e < MIN_EXP) {
|
|
570
|
-
x.c = [x.e = 0];
|
|
571
|
-
} else {
|
|
572
|
-
x.e = v.e;
|
|
573
|
-
x.c = v.c.slice();
|
|
574
|
-
}
|
|
575
|
-
return;
|
|
576
|
-
}
|
|
577
|
-
if ((isNum = typeof v == "number") && v * 0 == 0) {
|
|
578
|
-
x.s = 1 / v < 0 ? (v = -v, -1) : 1;
|
|
579
|
-
if (v === ~~v) {
|
|
580
|
-
for (e = 0, i = v; i >= 10; i /= 10, e++)
|
|
581
|
-
;
|
|
582
|
-
if (e > MAX_EXP) {
|
|
583
|
-
x.c = x.e = null;
|
|
584
|
-
} else {
|
|
585
|
-
x.e = e;
|
|
586
|
-
x.c = [v];
|
|
587
|
-
}
|
|
588
|
-
return;
|
|
589
|
-
}
|
|
590
|
-
str = String(v);
|
|
591
|
-
} else {
|
|
592
|
-
if (!isNumeric.test(str = String(v)))
|
|
593
|
-
return parseNumeric(x, str, isNum);
|
|
594
|
-
x.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1;
|
|
595
|
-
}
|
|
596
|
-
if ((e = str.indexOf(".")) > -1)
|
|
597
|
-
str = str.replace(".", "");
|
|
598
|
-
if ((i = str.search(/e/i)) > 0) {
|
|
599
|
-
if (e < 0)
|
|
600
|
-
e = i;
|
|
601
|
-
e += +str.slice(i + 1);
|
|
602
|
-
str = str.substring(0, i);
|
|
603
|
-
} else if (e < 0) {
|
|
604
|
-
e = str.length;
|
|
605
|
-
}
|
|
606
|
-
} else {
|
|
607
|
-
intCheck(b, 2, ALPHABET.length, "Base");
|
|
608
|
-
if (b == 10 && alphabetHasNormalDecimalDigits) {
|
|
609
|
-
x = new BigNumber2(v);
|
|
610
|
-
return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE);
|
|
611
|
-
}
|
|
612
|
-
str = String(v);
|
|
613
|
-
if (isNum = typeof v == "number") {
|
|
614
|
-
if (v * 0 != 0)
|
|
615
|
-
return parseNumeric(x, str, isNum, b);
|
|
616
|
-
x.s = 1 / v < 0 ? (str = str.slice(1), -1) : 1;
|
|
617
|
-
if (BigNumber2.DEBUG && str.replace(/^0\.0*|\./, "").length > 15) {
|
|
618
|
-
throw Error(tooManyDigits + v);
|
|
619
|
-
}
|
|
620
|
-
} else {
|
|
621
|
-
x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
|
|
622
|
-
}
|
|
623
|
-
alphabet = ALPHABET.slice(0, b);
|
|
624
|
-
e = i = 0;
|
|
625
|
-
for (len = str.length; i < len; i++) {
|
|
626
|
-
if (alphabet.indexOf(c = str.charAt(i)) < 0) {
|
|
627
|
-
if (c == ".") {
|
|
628
|
-
if (i > e) {
|
|
629
|
-
e = len;
|
|
630
|
-
continue;
|
|
631
|
-
}
|
|
632
|
-
} else if (!caseChanged) {
|
|
633
|
-
if (str == str.toUpperCase() && (str = str.toLowerCase()) || str == str.toLowerCase() && (str = str.toUpperCase())) {
|
|
634
|
-
caseChanged = true;
|
|
635
|
-
i = -1;
|
|
636
|
-
e = 0;
|
|
637
|
-
continue;
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
return parseNumeric(x, String(v), isNum, b);
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
isNum = false;
|
|
644
|
-
str = convertBase(str, b, 10, x.s);
|
|
645
|
-
if ((e = str.indexOf(".")) > -1)
|
|
646
|
-
str = str.replace(".", "");
|
|
647
|
-
else
|
|
648
|
-
e = str.length;
|
|
649
|
-
}
|
|
650
|
-
for (i = 0; str.charCodeAt(i) === 48; i++)
|
|
651
|
-
;
|
|
652
|
-
for (len = str.length; str.charCodeAt(--len) === 48; )
|
|
653
|
-
;
|
|
654
|
-
if (str = str.slice(i, ++len)) {
|
|
655
|
-
len -= i;
|
|
656
|
-
if (isNum && BigNumber2.DEBUG && len > 15 && (v > MAX_SAFE_INTEGER || v !== mathfloor(v))) {
|
|
657
|
-
throw Error(tooManyDigits + x.s * v);
|
|
658
|
-
}
|
|
659
|
-
if ((e = e - i - 1) > MAX_EXP) {
|
|
660
|
-
x.c = x.e = null;
|
|
661
|
-
} else if (e < MIN_EXP) {
|
|
662
|
-
x.c = [x.e = 0];
|
|
663
|
-
} else {
|
|
664
|
-
x.e = e;
|
|
665
|
-
x.c = [];
|
|
666
|
-
i = (e + 1) % LOG_BASE;
|
|
667
|
-
if (e < 0)
|
|
668
|
-
i += LOG_BASE;
|
|
669
|
-
if (i < len) {
|
|
670
|
-
if (i)
|
|
671
|
-
x.c.push(+str.slice(0, i));
|
|
672
|
-
for (len -= LOG_BASE; i < len; ) {
|
|
673
|
-
x.c.push(+str.slice(i, i += LOG_BASE));
|
|
674
|
-
}
|
|
675
|
-
i = LOG_BASE - (str = str.slice(i)).length;
|
|
676
|
-
} else {
|
|
677
|
-
i -= len;
|
|
678
|
-
}
|
|
679
|
-
for (; i--; str += "0")
|
|
680
|
-
;
|
|
681
|
-
x.c.push(+str);
|
|
682
|
-
}
|
|
683
|
-
} else {
|
|
684
|
-
x.c = [x.e = 0];
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
BigNumber2.clone = clone;
|
|
688
|
-
BigNumber2.ROUND_UP = 0;
|
|
689
|
-
BigNumber2.ROUND_DOWN = 1;
|
|
690
|
-
BigNumber2.ROUND_CEIL = 2;
|
|
691
|
-
BigNumber2.ROUND_FLOOR = 3;
|
|
692
|
-
BigNumber2.ROUND_HALF_UP = 4;
|
|
693
|
-
BigNumber2.ROUND_HALF_DOWN = 5;
|
|
694
|
-
BigNumber2.ROUND_HALF_EVEN = 6;
|
|
695
|
-
BigNumber2.ROUND_HALF_CEIL = 7;
|
|
696
|
-
BigNumber2.ROUND_HALF_FLOOR = 8;
|
|
697
|
-
BigNumber2.EUCLID = 9;
|
|
698
|
-
BigNumber2.config = BigNumber2.set = function(obj) {
|
|
699
|
-
var p, v;
|
|
700
|
-
if (obj != null) {
|
|
701
|
-
if (typeof obj == "object") {
|
|
702
|
-
if (obj.hasOwnProperty(p = "DECIMAL_PLACES")) {
|
|
703
|
-
v = obj[p];
|
|
704
|
-
intCheck(v, 0, MAX, p);
|
|
705
|
-
DECIMAL_PLACES = v;
|
|
706
|
-
}
|
|
707
|
-
if (obj.hasOwnProperty(p = "ROUNDING_MODE")) {
|
|
708
|
-
v = obj[p];
|
|
709
|
-
intCheck(v, 0, 8, p);
|
|
710
|
-
ROUNDING_MODE = v;
|
|
711
|
-
}
|
|
712
|
-
if (obj.hasOwnProperty(p = "EXPONENTIAL_AT")) {
|
|
713
|
-
v = obj[p];
|
|
714
|
-
if (v && v.pop) {
|
|
715
|
-
intCheck(v[0], -MAX, 0, p);
|
|
716
|
-
intCheck(v[1], 0, MAX, p);
|
|
717
|
-
TO_EXP_NEG = v[0];
|
|
718
|
-
TO_EXP_POS = v[1];
|
|
719
|
-
} else {
|
|
720
|
-
intCheck(v, -MAX, MAX, p);
|
|
721
|
-
TO_EXP_NEG = -(TO_EXP_POS = v < 0 ? -v : v);
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
if (obj.hasOwnProperty(p = "RANGE")) {
|
|
725
|
-
v = obj[p];
|
|
726
|
-
if (v && v.pop) {
|
|
727
|
-
intCheck(v[0], -MAX, -1, p);
|
|
728
|
-
intCheck(v[1], 1, MAX, p);
|
|
729
|
-
MIN_EXP = v[0];
|
|
730
|
-
MAX_EXP = v[1];
|
|
731
|
-
} else {
|
|
732
|
-
intCheck(v, -MAX, MAX, p);
|
|
733
|
-
if (v) {
|
|
734
|
-
MIN_EXP = -(MAX_EXP = v < 0 ? -v : v);
|
|
735
|
-
} else {
|
|
736
|
-
throw Error(bignumberError + p + " cannot be zero: " + v);
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
if (obj.hasOwnProperty(p = "CRYPTO")) {
|
|
741
|
-
v = obj[p];
|
|
742
|
-
if (v === !!v) {
|
|
743
|
-
if (v) {
|
|
744
|
-
if (typeof crypto != "undefined" && crypto && (crypto.getRandomValues || crypto.randomBytes)) {
|
|
745
|
-
CRYPTO = v;
|
|
746
|
-
} else {
|
|
747
|
-
CRYPTO = !v;
|
|
748
|
-
throw Error(bignumberError + "crypto unavailable");
|
|
749
|
-
}
|
|
750
|
-
} else {
|
|
751
|
-
CRYPTO = v;
|
|
752
|
-
}
|
|
753
|
-
} else {
|
|
754
|
-
throw Error(bignumberError + p + " not true or false: " + v);
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
if (obj.hasOwnProperty(p = "MODULO_MODE")) {
|
|
758
|
-
v = obj[p];
|
|
759
|
-
intCheck(v, 0, 9, p);
|
|
760
|
-
MODULO_MODE = v;
|
|
761
|
-
}
|
|
762
|
-
if (obj.hasOwnProperty(p = "POW_PRECISION")) {
|
|
763
|
-
v = obj[p];
|
|
764
|
-
intCheck(v, 0, MAX, p);
|
|
765
|
-
POW_PRECISION = v;
|
|
766
|
-
}
|
|
767
|
-
if (obj.hasOwnProperty(p = "FORMAT")) {
|
|
768
|
-
v = obj[p];
|
|
769
|
-
if (typeof v == "object")
|
|
770
|
-
FORMAT = v;
|
|
771
|
-
else
|
|
772
|
-
throw Error(bignumberError + p + " not an object: " + v);
|
|
773
|
-
}
|
|
774
|
-
if (obj.hasOwnProperty(p = "ALPHABET")) {
|
|
775
|
-
v = obj[p];
|
|
776
|
-
if (typeof v == "string" && !/^.?$|[+\-.\s]|(.).*\1/.test(v)) {
|
|
777
|
-
alphabetHasNormalDecimalDigits = v.slice(0, 10) == "0123456789";
|
|
778
|
-
ALPHABET = v;
|
|
779
|
-
} else {
|
|
780
|
-
throw Error(bignumberError + p + " invalid: " + v);
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
} else {
|
|
784
|
-
throw Error(bignumberError + "Object expected: " + obj);
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
return {
|
|
788
|
-
DECIMAL_PLACES,
|
|
789
|
-
ROUNDING_MODE,
|
|
790
|
-
EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS],
|
|
791
|
-
RANGE: [MIN_EXP, MAX_EXP],
|
|
792
|
-
CRYPTO,
|
|
793
|
-
MODULO_MODE,
|
|
794
|
-
POW_PRECISION,
|
|
795
|
-
FORMAT,
|
|
796
|
-
ALPHABET
|
|
797
|
-
};
|
|
798
|
-
};
|
|
799
|
-
BigNumber2.isBigNumber = function(v) {
|
|
800
|
-
if (!v || v._isBigNumber !== true)
|
|
801
|
-
return false;
|
|
802
|
-
if (!BigNumber2.DEBUG)
|
|
803
|
-
return true;
|
|
804
|
-
var i, n, c = v.c, e = v.e, s = v.s;
|
|
805
|
-
out:
|
|
806
|
-
if ({}.toString.call(c) == "[object Array]") {
|
|
807
|
-
if ((s === 1 || s === -1) && e >= -MAX && e <= MAX && e === mathfloor(e)) {
|
|
808
|
-
if (c[0] === 0) {
|
|
809
|
-
if (e === 0 && c.length === 1)
|
|
810
|
-
return true;
|
|
811
|
-
break out;
|
|
812
|
-
}
|
|
813
|
-
i = (e + 1) % LOG_BASE;
|
|
814
|
-
if (i < 1)
|
|
815
|
-
i += LOG_BASE;
|
|
816
|
-
if (String(c[0]).length == i) {
|
|
817
|
-
for (i = 0; i < c.length; i++) {
|
|
818
|
-
n = c[i];
|
|
819
|
-
if (n < 0 || n >= BASE || n !== mathfloor(n))
|
|
820
|
-
break out;
|
|
821
|
-
}
|
|
822
|
-
if (n !== 0)
|
|
823
|
-
return true;
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
} else if (c === null && e === null && (s === null || s === 1 || s === -1)) {
|
|
827
|
-
return true;
|
|
828
|
-
}
|
|
829
|
-
throw Error(bignumberError + "Invalid BigNumber: " + v);
|
|
830
|
-
};
|
|
831
|
-
BigNumber2.maximum = BigNumber2.max = function() {
|
|
832
|
-
return maxOrMin(arguments, P.lt);
|
|
833
|
-
};
|
|
834
|
-
BigNumber2.minimum = BigNumber2.min = function() {
|
|
835
|
-
return maxOrMin(arguments, P.gt);
|
|
836
|
-
};
|
|
837
|
-
BigNumber2.random = function() {
|
|
838
|
-
var pow2_53 = 9007199254740992;
|
|
839
|
-
var random53bitInt = Math.random() * pow2_53 & 2097151 ? function() {
|
|
840
|
-
return mathfloor(Math.random() * pow2_53);
|
|
841
|
-
} : function() {
|
|
842
|
-
return (Math.random() * 1073741824 | 0) * 8388608 + (Math.random() * 8388608 | 0);
|
|
843
|
-
};
|
|
844
|
-
return function(dp) {
|
|
845
|
-
var a, b, e, k, v, i = 0, c = [], rand = new BigNumber2(ONE);
|
|
846
|
-
if (dp == null)
|
|
847
|
-
dp = DECIMAL_PLACES;
|
|
848
|
-
else
|
|
849
|
-
intCheck(dp, 0, MAX);
|
|
850
|
-
k = mathceil(dp / LOG_BASE);
|
|
851
|
-
if (CRYPTO) {
|
|
852
|
-
if (crypto.getRandomValues) {
|
|
853
|
-
a = crypto.getRandomValues(new Uint32Array(k *= 2));
|
|
854
|
-
for (; i < k; ) {
|
|
855
|
-
v = a[i] * 131072 + (a[i + 1] >>> 11);
|
|
856
|
-
if (v >= 9e15) {
|
|
857
|
-
b = crypto.getRandomValues(new Uint32Array(2));
|
|
858
|
-
a[i] = b[0];
|
|
859
|
-
a[i + 1] = b[1];
|
|
860
|
-
} else {
|
|
861
|
-
c.push(v % 1e14);
|
|
862
|
-
i += 2;
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
i = k / 2;
|
|
866
|
-
} else if (crypto.randomBytes) {
|
|
867
|
-
a = crypto.randomBytes(k *= 7);
|
|
868
|
-
for (; i < k; ) {
|
|
869
|
-
v = (a[i] & 31) * 281474976710656 + a[i + 1] * 1099511627776 + a[i + 2] * 4294967296 + a[i + 3] * 16777216 + (a[i + 4] << 16) + (a[i + 5] << 8) + a[i + 6];
|
|
870
|
-
if (v >= 9e15) {
|
|
871
|
-
crypto.randomBytes(7).copy(a, i);
|
|
872
|
-
} else {
|
|
873
|
-
c.push(v % 1e14);
|
|
874
|
-
i += 7;
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
i = k / 7;
|
|
878
|
-
} else {
|
|
879
|
-
CRYPTO = false;
|
|
880
|
-
throw Error(bignumberError + "crypto unavailable");
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
if (!CRYPTO) {
|
|
884
|
-
for (; i < k; ) {
|
|
885
|
-
v = random53bitInt();
|
|
886
|
-
if (v < 9e15)
|
|
887
|
-
c[i++] = v % 1e14;
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
k = c[--i];
|
|
891
|
-
dp %= LOG_BASE;
|
|
892
|
-
if (k && dp) {
|
|
893
|
-
v = POWS_TEN[LOG_BASE - dp];
|
|
894
|
-
c[i] = mathfloor(k / v) * v;
|
|
895
|
-
}
|
|
896
|
-
for (; c[i] === 0; c.pop(), i--)
|
|
897
|
-
;
|
|
898
|
-
if (i < 0) {
|
|
899
|
-
c = [e = 0];
|
|
900
|
-
} else {
|
|
901
|
-
for (e = -1; c[0] === 0; c.splice(0, 1), e -= LOG_BASE)
|
|
902
|
-
;
|
|
903
|
-
for (i = 1, v = c[0]; v >= 10; v /= 10, i++)
|
|
904
|
-
;
|
|
905
|
-
if (i < LOG_BASE)
|
|
906
|
-
e -= LOG_BASE - i;
|
|
907
|
-
}
|
|
908
|
-
rand.e = e;
|
|
909
|
-
rand.c = c;
|
|
910
|
-
return rand;
|
|
911
|
-
};
|
|
912
|
-
}();
|
|
913
|
-
BigNumber2.sum = function() {
|
|
914
|
-
var i = 1, args = arguments, sum = new BigNumber2(args[0]);
|
|
915
|
-
for (; i < args.length; )
|
|
916
|
-
sum = sum.plus(args[i++]);
|
|
917
|
-
return sum;
|
|
918
|
-
};
|
|
919
|
-
convertBase = function() {
|
|
920
|
-
var decimal = "0123456789";
|
|
921
|
-
function toBaseOut(str, baseIn, baseOut, alphabet) {
|
|
922
|
-
var j, arr = [0], arrL, i = 0, len = str.length;
|
|
923
|
-
for (; i < len; ) {
|
|
924
|
-
for (arrL = arr.length; arrL--; arr[arrL] *= baseIn)
|
|
925
|
-
;
|
|
926
|
-
arr[0] += alphabet.indexOf(str.charAt(i++));
|
|
927
|
-
for (j = 0; j < arr.length; j++) {
|
|
928
|
-
if (arr[j] > baseOut - 1) {
|
|
929
|
-
if (arr[j + 1] == null)
|
|
930
|
-
arr[j + 1] = 0;
|
|
931
|
-
arr[j + 1] += arr[j] / baseOut | 0;
|
|
932
|
-
arr[j] %= baseOut;
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
return arr.reverse();
|
|
937
|
-
}
|
|
938
|
-
return function(str, baseIn, baseOut, sign2, callerIsToString) {
|
|
939
|
-
var alphabet, d, e, k, r, x, xc, y, i = str.indexOf("."), dp = DECIMAL_PLACES, rm = ROUNDING_MODE;
|
|
940
|
-
if (i >= 0) {
|
|
941
|
-
k = POW_PRECISION;
|
|
942
|
-
POW_PRECISION = 0;
|
|
943
|
-
str = str.replace(".", "");
|
|
944
|
-
y = new BigNumber2(baseIn);
|
|
945
|
-
x = y.pow(str.length - i);
|
|
946
|
-
POW_PRECISION = k;
|
|
947
|
-
y.c = toBaseOut(
|
|
948
|
-
toFixedPoint(coeffToString(x.c), x.e, "0"),
|
|
949
|
-
10,
|
|
950
|
-
baseOut,
|
|
951
|
-
decimal
|
|
952
|
-
);
|
|
953
|
-
y.e = y.c.length;
|
|
954
|
-
}
|
|
955
|
-
xc = toBaseOut(str, baseIn, baseOut, callerIsToString ? (alphabet = ALPHABET, decimal) : (alphabet = decimal, ALPHABET));
|
|
956
|
-
e = k = xc.length;
|
|
957
|
-
for (; xc[--k] == 0; xc.pop())
|
|
958
|
-
;
|
|
959
|
-
if (!xc[0])
|
|
960
|
-
return alphabet.charAt(0);
|
|
961
|
-
if (i < 0) {
|
|
962
|
-
--e;
|
|
963
|
-
} else {
|
|
964
|
-
x.c = xc;
|
|
965
|
-
x.e = e;
|
|
966
|
-
x.s = sign2;
|
|
967
|
-
x = div(x, y, dp, rm, baseOut);
|
|
968
|
-
xc = x.c;
|
|
969
|
-
r = x.r;
|
|
970
|
-
e = x.e;
|
|
971
|
-
}
|
|
972
|
-
d = e + dp + 1;
|
|
973
|
-
i = xc[d];
|
|
974
|
-
k = baseOut / 2;
|
|
975
|
-
r = r || d < 0 || xc[d + 1] != null;
|
|
976
|
-
r = rm < 4 ? (i != null || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : i > k || i == k && (rm == 4 || r || rm == 6 && xc[d - 1] & 1 || rm == (x.s < 0 ? 8 : 7));
|
|
977
|
-
if (d < 1 || !xc[0]) {
|
|
978
|
-
str = r ? toFixedPoint(alphabet.charAt(1), -dp, alphabet.charAt(0)) : alphabet.charAt(0);
|
|
979
|
-
} else {
|
|
980
|
-
xc.length = d;
|
|
981
|
-
if (r) {
|
|
982
|
-
for (--baseOut; ++xc[--d] > baseOut; ) {
|
|
983
|
-
xc[d] = 0;
|
|
984
|
-
if (!d) {
|
|
985
|
-
++e;
|
|
986
|
-
xc = [1].concat(xc);
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
}
|
|
990
|
-
for (k = xc.length; !xc[--k]; )
|
|
991
|
-
;
|
|
992
|
-
for (i = 0, str = ""; i <= k; str += alphabet.charAt(xc[i++]))
|
|
993
|
-
;
|
|
994
|
-
str = toFixedPoint(str, e, alphabet.charAt(0));
|
|
995
|
-
}
|
|
996
|
-
return str;
|
|
997
|
-
};
|
|
998
|
-
}();
|
|
999
|
-
div = function() {
|
|
1000
|
-
function multiply(x, k, base) {
|
|
1001
|
-
var m, temp, xlo, xhi, carry = 0, i = x.length, klo = k % SQRT_BASE, khi = k / SQRT_BASE | 0;
|
|
1002
|
-
for (x = x.slice(); i--; ) {
|
|
1003
|
-
xlo = x[i] % SQRT_BASE;
|
|
1004
|
-
xhi = x[i] / SQRT_BASE | 0;
|
|
1005
|
-
m = khi * xlo + xhi * klo;
|
|
1006
|
-
temp = klo * xlo + m % SQRT_BASE * SQRT_BASE + carry;
|
|
1007
|
-
carry = (temp / base | 0) + (m / SQRT_BASE | 0) + khi * xhi;
|
|
1008
|
-
x[i] = temp % base;
|
|
1009
|
-
}
|
|
1010
|
-
if (carry)
|
|
1011
|
-
x = [carry].concat(x);
|
|
1012
|
-
return x;
|
|
1013
|
-
}
|
|
1014
|
-
function compare2(a, b, aL, bL) {
|
|
1015
|
-
var i, cmp;
|
|
1016
|
-
if (aL != bL) {
|
|
1017
|
-
cmp = aL > bL ? 1 : -1;
|
|
1018
|
-
} else {
|
|
1019
|
-
for (i = cmp = 0; i < aL; i++) {
|
|
1020
|
-
if (a[i] != b[i]) {
|
|
1021
|
-
cmp = a[i] > b[i] ? 1 : -1;
|
|
1022
|
-
break;
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
return cmp;
|
|
1027
|
-
}
|
|
1028
|
-
function subtract(a, b, aL, base) {
|
|
1029
|
-
var i = 0;
|
|
1030
|
-
for (; aL--; ) {
|
|
1031
|
-
a[aL] -= i;
|
|
1032
|
-
i = a[aL] < b[aL] ? 1 : 0;
|
|
1033
|
-
a[aL] = i * base + a[aL] - b[aL];
|
|
1034
|
-
}
|
|
1035
|
-
for (; !a[0] && a.length > 1; a.splice(0, 1))
|
|
1036
|
-
;
|
|
1037
|
-
}
|
|
1038
|
-
return function(x, y, dp, rm, base) {
|
|
1039
|
-
var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0, yL, yz, s = x.s == y.s ? 1 : -1, xc = x.c, yc = y.c;
|
|
1040
|
-
if (!xc || !xc[0] || !yc || !yc[0]) {
|
|
1041
|
-
return new BigNumber2(
|
|
1042
|
-
!x.s || !y.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN : xc && xc[0] == 0 || !yc ? s * 0 : s / 0
|
|
1043
|
-
);
|
|
1044
|
-
}
|
|
1045
|
-
q = new BigNumber2(s);
|
|
1046
|
-
qc = q.c = [];
|
|
1047
|
-
e = x.e - y.e;
|
|
1048
|
-
s = dp + e + 1;
|
|
1049
|
-
if (!base) {
|
|
1050
|
-
base = BASE;
|
|
1051
|
-
e = bitFloor(x.e / LOG_BASE) - bitFloor(y.e / LOG_BASE);
|
|
1052
|
-
s = s / LOG_BASE | 0;
|
|
1053
|
-
}
|
|
1054
|
-
for (i = 0; yc[i] == (xc[i] || 0); i++)
|
|
1055
|
-
;
|
|
1056
|
-
if (yc[i] > (xc[i] || 0))
|
|
1057
|
-
e--;
|
|
1058
|
-
if (s < 0) {
|
|
1059
|
-
qc.push(1);
|
|
1060
|
-
more = true;
|
|
1061
|
-
} else {
|
|
1062
|
-
xL = xc.length;
|
|
1063
|
-
yL = yc.length;
|
|
1064
|
-
i = 0;
|
|
1065
|
-
s += 2;
|
|
1066
|
-
n = mathfloor(base / (yc[0] + 1));
|
|
1067
|
-
if (n > 1) {
|
|
1068
|
-
yc = multiply(yc, n, base);
|
|
1069
|
-
xc = multiply(xc, n, base);
|
|
1070
|
-
yL = yc.length;
|
|
1071
|
-
xL = xc.length;
|
|
1072
|
-
}
|
|
1073
|
-
xi = yL;
|
|
1074
|
-
rem = xc.slice(0, yL);
|
|
1075
|
-
remL = rem.length;
|
|
1076
|
-
for (; remL < yL; rem[remL++] = 0)
|
|
1077
|
-
;
|
|
1078
|
-
yz = yc.slice();
|
|
1079
|
-
yz = [0].concat(yz);
|
|
1080
|
-
yc0 = yc[0];
|
|
1081
|
-
if (yc[1] >= base / 2)
|
|
1082
|
-
yc0++;
|
|
1083
|
-
do {
|
|
1084
|
-
n = 0;
|
|
1085
|
-
cmp = compare2(yc, rem, yL, remL);
|
|
1086
|
-
if (cmp < 0) {
|
|
1087
|
-
rem0 = rem[0];
|
|
1088
|
-
if (yL != remL)
|
|
1089
|
-
rem0 = rem0 * base + (rem[1] || 0);
|
|
1090
|
-
n = mathfloor(rem0 / yc0);
|
|
1091
|
-
if (n > 1) {
|
|
1092
|
-
if (n >= base)
|
|
1093
|
-
n = base - 1;
|
|
1094
|
-
prod = multiply(yc, n, base);
|
|
1095
|
-
prodL = prod.length;
|
|
1096
|
-
remL = rem.length;
|
|
1097
|
-
while (compare2(prod, rem, prodL, remL) == 1) {
|
|
1098
|
-
n--;
|
|
1099
|
-
subtract(prod, yL < prodL ? yz : yc, prodL, base);
|
|
1100
|
-
prodL = prod.length;
|
|
1101
|
-
cmp = 1;
|
|
1102
|
-
}
|
|
1103
|
-
} else {
|
|
1104
|
-
if (n == 0) {
|
|
1105
|
-
cmp = n = 1;
|
|
1106
|
-
}
|
|
1107
|
-
prod = yc.slice();
|
|
1108
|
-
prodL = prod.length;
|
|
1109
|
-
}
|
|
1110
|
-
if (prodL < remL)
|
|
1111
|
-
prod = [0].concat(prod);
|
|
1112
|
-
subtract(rem, prod, remL, base);
|
|
1113
|
-
remL = rem.length;
|
|
1114
|
-
if (cmp == -1) {
|
|
1115
|
-
while (compare2(yc, rem, yL, remL) < 1) {
|
|
1116
|
-
n++;
|
|
1117
|
-
subtract(rem, yL < remL ? yz : yc, remL, base);
|
|
1118
|
-
remL = rem.length;
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1121
|
-
} else if (cmp === 0) {
|
|
1122
|
-
n++;
|
|
1123
|
-
rem = [0];
|
|
1124
|
-
}
|
|
1125
|
-
qc[i++] = n;
|
|
1126
|
-
if (rem[0]) {
|
|
1127
|
-
rem[remL++] = xc[xi] || 0;
|
|
1128
|
-
} else {
|
|
1129
|
-
rem = [xc[xi]];
|
|
1130
|
-
remL = 1;
|
|
1131
|
-
}
|
|
1132
|
-
} while ((xi++ < xL || rem[0] != null) && s--);
|
|
1133
|
-
more = rem[0] != null;
|
|
1134
|
-
if (!qc[0])
|
|
1135
|
-
qc.splice(0, 1);
|
|
1136
|
-
}
|
|
1137
|
-
if (base == BASE) {
|
|
1138
|
-
for (i = 1, s = qc[0]; s >= 10; s /= 10, i++)
|
|
1139
|
-
;
|
|
1140
|
-
round(q, dp + (q.e = i + e * LOG_BASE - 1) + 1, rm, more);
|
|
1141
|
-
} else {
|
|
1142
|
-
q.e = e;
|
|
1143
|
-
q.r = +more;
|
|
1144
|
-
}
|
|
1145
|
-
return q;
|
|
1146
|
-
};
|
|
1147
|
-
}();
|
|
1148
|
-
function format(n, i, rm, id) {
|
|
1149
|
-
var c0, e, ne, len, str;
|
|
1150
|
-
if (rm == null)
|
|
1151
|
-
rm = ROUNDING_MODE;
|
|
1152
|
-
else
|
|
1153
|
-
intCheck(rm, 0, 8);
|
|
1154
|
-
if (!n.c)
|
|
1155
|
-
return n.toString();
|
|
1156
|
-
c0 = n.c[0];
|
|
1157
|
-
ne = n.e;
|
|
1158
|
-
if (i == null) {
|
|
1159
|
-
str = coeffToString(n.c);
|
|
1160
|
-
str = id == 1 || id == 2 && (ne <= TO_EXP_NEG || ne >= TO_EXP_POS) ? toExponential(str, ne) : toFixedPoint(str, ne, "0");
|
|
1161
|
-
} else {
|
|
1162
|
-
n = round(new BigNumber2(n), i, rm);
|
|
1163
|
-
e = n.e;
|
|
1164
|
-
str = coeffToString(n.c);
|
|
1165
|
-
len = str.length;
|
|
1166
|
-
if (id == 1 || id == 2 && (i <= e || e <= TO_EXP_NEG)) {
|
|
1167
|
-
for (; len < i; str += "0", len++)
|
|
1168
|
-
;
|
|
1169
|
-
str = toExponential(str, e);
|
|
1170
|
-
} else {
|
|
1171
|
-
i -= ne;
|
|
1172
|
-
str = toFixedPoint(str, e, "0");
|
|
1173
|
-
if (e + 1 > len) {
|
|
1174
|
-
if (--i > 0)
|
|
1175
|
-
for (str += "."; i--; str += "0")
|
|
1176
|
-
;
|
|
1177
|
-
} else {
|
|
1178
|
-
i += e - len;
|
|
1179
|
-
if (i > 0) {
|
|
1180
|
-
if (e + 1 == len)
|
|
1181
|
-
str += ".";
|
|
1182
|
-
for (; i--; str += "0")
|
|
1183
|
-
;
|
|
1184
|
-
}
|
|
1185
|
-
}
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
return n.s < 0 && c0 ? "-" + str : str;
|
|
1189
|
-
}
|
|
1190
|
-
function maxOrMin(args, method) {
|
|
1191
|
-
var n, i = 1, m = new BigNumber2(args[0]);
|
|
1192
|
-
for (; i < args.length; i++) {
|
|
1193
|
-
n = new BigNumber2(args[i]);
|
|
1194
|
-
if (!n.s) {
|
|
1195
|
-
m = n;
|
|
1196
|
-
break;
|
|
1197
|
-
} else if (method.call(m, n)) {
|
|
1198
|
-
m = n;
|
|
1199
|
-
}
|
|
1200
|
-
}
|
|
1201
|
-
return m;
|
|
1202
|
-
}
|
|
1203
|
-
function normalise(n, c, e) {
|
|
1204
|
-
var i = 1, j = c.length;
|
|
1205
|
-
for (; !c[--j]; c.pop())
|
|
1206
|
-
;
|
|
1207
|
-
for (j = c[0]; j >= 10; j /= 10, i++)
|
|
1208
|
-
;
|
|
1209
|
-
if ((e = i + e * LOG_BASE - 1) > MAX_EXP) {
|
|
1210
|
-
n.c = n.e = null;
|
|
1211
|
-
} else if (e < MIN_EXP) {
|
|
1212
|
-
n.c = [n.e = 0];
|
|
1213
|
-
} else {
|
|
1214
|
-
n.e = e;
|
|
1215
|
-
n.c = c;
|
|
1216
|
-
}
|
|
1217
|
-
return n;
|
|
1218
|
-
}
|
|
1219
|
-
parseNumeric = function() {
|
|
1220
|
-
var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i, dotAfter = /^([^.]+)\.$/, dotBefore = /^\.([^.]+)$/, isInfinityOrNaN = /^-?(Infinity|NaN)$/, whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
|
|
1221
|
-
return function(x, str, isNum, b) {
|
|
1222
|
-
var base, s = isNum ? str : str.replace(whitespaceOrPlus, "");
|
|
1223
|
-
if (isInfinityOrNaN.test(s)) {
|
|
1224
|
-
x.s = isNaN(s) ? null : s < 0 ? -1 : 1;
|
|
1225
|
-
} else {
|
|
1226
|
-
if (!isNum) {
|
|
1227
|
-
s = s.replace(basePrefix, function(m, p1, p2) {
|
|
1228
|
-
base = (p2 = p2.toLowerCase()) == "x" ? 16 : p2 == "b" ? 2 : 8;
|
|
1229
|
-
return !b || b == base ? p1 : m;
|
|
1230
|
-
});
|
|
1231
|
-
if (b) {
|
|
1232
|
-
base = b;
|
|
1233
|
-
s = s.replace(dotAfter, "$1").replace(dotBefore, "0.$1");
|
|
1234
|
-
}
|
|
1235
|
-
if (str != s)
|
|
1236
|
-
return new BigNumber2(s, base);
|
|
1237
|
-
}
|
|
1238
|
-
if (BigNumber2.DEBUG) {
|
|
1239
|
-
throw Error(bignumberError + "Not a" + (b ? " base " + b : "") + " number: " + str);
|
|
1240
|
-
}
|
|
1241
|
-
x.s = null;
|
|
1242
|
-
}
|
|
1243
|
-
x.c = x.e = null;
|
|
1244
|
-
};
|
|
1245
|
-
}();
|
|
1246
|
-
function round(x, sd, rm, r) {
|
|
1247
|
-
var d, i, j, k, n, ni, rd, xc = x.c, pows10 = POWS_TEN;
|
|
1248
|
-
if (xc) {
|
|
1249
|
-
out: {
|
|
1250
|
-
for (d = 1, k = xc[0]; k >= 10; k /= 10, d++)
|
|
1251
|
-
;
|
|
1252
|
-
i = sd - d;
|
|
1253
|
-
if (i < 0) {
|
|
1254
|
-
i += LOG_BASE;
|
|
1255
|
-
j = sd;
|
|
1256
|
-
n = xc[ni = 0];
|
|
1257
|
-
rd = n / pows10[d - j - 1] % 10 | 0;
|
|
1258
|
-
} else {
|
|
1259
|
-
ni = mathceil((i + 1) / LOG_BASE);
|
|
1260
|
-
if (ni >= xc.length) {
|
|
1261
|
-
if (r) {
|
|
1262
|
-
for (; xc.length <= ni; xc.push(0))
|
|
1263
|
-
;
|
|
1264
|
-
n = rd = 0;
|
|
1265
|
-
d = 1;
|
|
1266
|
-
i %= LOG_BASE;
|
|
1267
|
-
j = i - LOG_BASE + 1;
|
|
1268
|
-
} else {
|
|
1269
|
-
break out;
|
|
1270
|
-
}
|
|
1271
|
-
} else {
|
|
1272
|
-
n = k = xc[ni];
|
|
1273
|
-
for (d = 1; k >= 10; k /= 10, d++)
|
|
1274
|
-
;
|
|
1275
|
-
i %= LOG_BASE;
|
|
1276
|
-
j = i - LOG_BASE + d;
|
|
1277
|
-
rd = j < 0 ? 0 : n / pows10[d - j - 1] % 10 | 0;
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
|
-
r = r || sd < 0 || xc[ni + 1] != null || (j < 0 ? n : n % pows10[d - j - 1]);
|
|
1281
|
-
r = rm < 4 ? (rd || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : rd > 5 || rd == 5 && (rm == 4 || r || rm == 6 && (i > 0 ? j > 0 ? n / pows10[d - j] : 0 : xc[ni - 1]) % 10 & 1 || rm == (x.s < 0 ? 8 : 7));
|
|
1282
|
-
if (sd < 1 || !xc[0]) {
|
|
1283
|
-
xc.length = 0;
|
|
1284
|
-
if (r) {
|
|
1285
|
-
sd -= x.e + 1;
|
|
1286
|
-
xc[0] = pows10[(LOG_BASE - sd % LOG_BASE) % LOG_BASE];
|
|
1287
|
-
x.e = -sd || 0;
|
|
1288
|
-
} else {
|
|
1289
|
-
xc[0] = x.e = 0;
|
|
1290
|
-
}
|
|
1291
|
-
return x;
|
|
1292
|
-
}
|
|
1293
|
-
if (i == 0) {
|
|
1294
|
-
xc.length = ni;
|
|
1295
|
-
k = 1;
|
|
1296
|
-
ni--;
|
|
1297
|
-
} else {
|
|
1298
|
-
xc.length = ni + 1;
|
|
1299
|
-
k = pows10[LOG_BASE - i];
|
|
1300
|
-
xc[ni] = j > 0 ? mathfloor(n / pows10[d - j] % pows10[j]) * k : 0;
|
|
1301
|
-
}
|
|
1302
|
-
if (r) {
|
|
1303
|
-
for (; ; ) {
|
|
1304
|
-
if (ni == 0) {
|
|
1305
|
-
for (i = 1, j = xc[0]; j >= 10; j /= 10, i++)
|
|
1306
|
-
;
|
|
1307
|
-
j = xc[0] += k;
|
|
1308
|
-
for (k = 1; j >= 10; j /= 10, k++)
|
|
1309
|
-
;
|
|
1310
|
-
if (i != k) {
|
|
1311
|
-
x.e++;
|
|
1312
|
-
if (xc[0] == BASE)
|
|
1313
|
-
xc[0] = 1;
|
|
1314
|
-
}
|
|
1315
|
-
break;
|
|
1316
|
-
} else {
|
|
1317
|
-
xc[ni] += k;
|
|
1318
|
-
if (xc[ni] != BASE)
|
|
1319
|
-
break;
|
|
1320
|
-
xc[ni--] = 0;
|
|
1321
|
-
k = 1;
|
|
1322
|
-
}
|
|
1323
|
-
}
|
|
1324
|
-
}
|
|
1325
|
-
for (i = xc.length; xc[--i] === 0; xc.pop())
|
|
1326
|
-
;
|
|
1327
|
-
}
|
|
1328
|
-
if (x.e > MAX_EXP) {
|
|
1329
|
-
x.c = x.e = null;
|
|
1330
|
-
} else if (x.e < MIN_EXP) {
|
|
1331
|
-
x.c = [x.e = 0];
|
|
1332
|
-
}
|
|
1333
|
-
}
|
|
1334
|
-
return x;
|
|
1335
|
-
}
|
|
1336
|
-
function valueOf(n) {
|
|
1337
|
-
var str, e = n.e;
|
|
1338
|
-
if (e === null)
|
|
1339
|
-
return n.toString();
|
|
1340
|
-
str = coeffToString(n.c);
|
|
1341
|
-
str = e <= TO_EXP_NEG || e >= TO_EXP_POS ? toExponential(str, e) : toFixedPoint(str, e, "0");
|
|
1342
|
-
return n.s < 0 ? "-" + str : str;
|
|
1343
|
-
}
|
|
1344
|
-
P.absoluteValue = P.abs = function() {
|
|
1345
|
-
var x = new BigNumber2(this);
|
|
1346
|
-
if (x.s < 0)
|
|
1347
|
-
x.s = 1;
|
|
1348
|
-
return x;
|
|
1349
|
-
};
|
|
1350
|
-
P.comparedTo = function(y, b) {
|
|
1351
|
-
return compare(this, new BigNumber2(y, b));
|
|
1352
|
-
};
|
|
1353
|
-
P.decimalPlaces = P.dp = function(dp, rm) {
|
|
1354
|
-
var c, n, v, x = this;
|
|
1355
|
-
if (dp != null) {
|
|
1356
|
-
intCheck(dp, 0, MAX);
|
|
1357
|
-
if (rm == null)
|
|
1358
|
-
rm = ROUNDING_MODE;
|
|
1359
|
-
else
|
|
1360
|
-
intCheck(rm, 0, 8);
|
|
1361
|
-
return round(new BigNumber2(x), dp + x.e + 1, rm);
|
|
1362
|
-
}
|
|
1363
|
-
if (!(c = x.c))
|
|
1364
|
-
return null;
|
|
1365
|
-
n = ((v = c.length - 1) - bitFloor(this.e / LOG_BASE)) * LOG_BASE;
|
|
1366
|
-
if (v = c[v])
|
|
1367
|
-
for (; v % 10 == 0; v /= 10, n--)
|
|
1368
|
-
;
|
|
1369
|
-
if (n < 0)
|
|
1370
|
-
n = 0;
|
|
1371
|
-
return n;
|
|
1372
|
-
};
|
|
1373
|
-
P.dividedBy = P.div = function(y, b) {
|
|
1374
|
-
return div(this, new BigNumber2(y, b), DECIMAL_PLACES, ROUNDING_MODE);
|
|
1375
|
-
};
|
|
1376
|
-
P.dividedToIntegerBy = P.idiv = function(y, b) {
|
|
1377
|
-
return div(this, new BigNumber2(y, b), 0, 1);
|
|
1378
|
-
};
|
|
1379
|
-
P.exponentiatedBy = P.pow = function(n, m) {
|
|
1380
|
-
var half, isModExp, i, k, more, nIsBig, nIsNeg, nIsOdd, y, x = this;
|
|
1381
|
-
n = new BigNumber2(n);
|
|
1382
|
-
if (n.c && !n.isInteger()) {
|
|
1383
|
-
throw Error(bignumberError + "Exponent not an integer: " + valueOf(n));
|
|
1384
|
-
}
|
|
1385
|
-
if (m != null)
|
|
1386
|
-
m = new BigNumber2(m);
|
|
1387
|
-
nIsBig = n.e > 14;
|
|
1388
|
-
if (!x.c || !x.c[0] || x.c[0] == 1 && !x.e && x.c.length == 1 || !n.c || !n.c[0]) {
|
|
1389
|
-
y = new BigNumber2(Math.pow(+valueOf(x), nIsBig ? n.s * (2 - isOdd(n)) : +valueOf(n)));
|
|
1390
|
-
return m ? y.mod(m) : y;
|
|
1391
|
-
}
|
|
1392
|
-
nIsNeg = n.s < 0;
|
|
1393
|
-
if (m) {
|
|
1394
|
-
if (m.c ? !m.c[0] : !m.s)
|
|
1395
|
-
return new BigNumber2(NaN);
|
|
1396
|
-
isModExp = !nIsNeg && x.isInteger() && m.isInteger();
|
|
1397
|
-
if (isModExp)
|
|
1398
|
-
x = x.mod(m);
|
|
1399
|
-
} else if (n.e > 9 && (x.e > 0 || x.e < -1 || (x.e == 0 ? x.c[0] > 1 || nIsBig && x.c[1] >= 24e7 : x.c[0] < 8e13 || nIsBig && x.c[0] <= 9999975e7))) {
|
|
1400
|
-
k = x.s < 0 && isOdd(n) ? -0 : 0;
|
|
1401
|
-
if (x.e > -1)
|
|
1402
|
-
k = 1 / k;
|
|
1403
|
-
return new BigNumber2(nIsNeg ? 1 / k : k);
|
|
1404
|
-
} else if (POW_PRECISION) {
|
|
1405
|
-
k = mathceil(POW_PRECISION / LOG_BASE + 2);
|
|
1406
|
-
}
|
|
1407
|
-
if (nIsBig) {
|
|
1408
|
-
half = new BigNumber2(0.5);
|
|
1409
|
-
if (nIsNeg)
|
|
1410
|
-
n.s = 1;
|
|
1411
|
-
nIsOdd = isOdd(n);
|
|
1412
|
-
} else {
|
|
1413
|
-
i = Math.abs(+valueOf(n));
|
|
1414
|
-
nIsOdd = i % 2;
|
|
1415
|
-
}
|
|
1416
|
-
y = new BigNumber2(ONE);
|
|
1417
|
-
for (; ; ) {
|
|
1418
|
-
if (nIsOdd) {
|
|
1419
|
-
y = y.times(x);
|
|
1420
|
-
if (!y.c)
|
|
1421
|
-
break;
|
|
1422
|
-
if (k) {
|
|
1423
|
-
if (y.c.length > k)
|
|
1424
|
-
y.c.length = k;
|
|
1425
|
-
} else if (isModExp) {
|
|
1426
|
-
y = y.mod(m);
|
|
1427
|
-
}
|
|
1428
|
-
}
|
|
1429
|
-
if (i) {
|
|
1430
|
-
i = mathfloor(i / 2);
|
|
1431
|
-
if (i === 0)
|
|
1432
|
-
break;
|
|
1433
|
-
nIsOdd = i % 2;
|
|
1434
|
-
} else {
|
|
1435
|
-
n = n.times(half);
|
|
1436
|
-
round(n, n.e + 1, 1);
|
|
1437
|
-
if (n.e > 14) {
|
|
1438
|
-
nIsOdd = isOdd(n);
|
|
1439
|
-
} else {
|
|
1440
|
-
i = +valueOf(n);
|
|
1441
|
-
if (i === 0)
|
|
1442
|
-
break;
|
|
1443
|
-
nIsOdd = i % 2;
|
|
1444
|
-
}
|
|
1445
|
-
}
|
|
1446
|
-
x = x.times(x);
|
|
1447
|
-
if (k) {
|
|
1448
|
-
if (x.c && x.c.length > k)
|
|
1449
|
-
x.c.length = k;
|
|
1450
|
-
} else if (isModExp) {
|
|
1451
|
-
x = x.mod(m);
|
|
1452
|
-
}
|
|
1453
|
-
}
|
|
1454
|
-
if (isModExp)
|
|
1455
|
-
return y;
|
|
1456
|
-
if (nIsNeg)
|
|
1457
|
-
y = ONE.div(y);
|
|
1458
|
-
return m ? y.mod(m) : k ? round(y, POW_PRECISION, ROUNDING_MODE, more) : y;
|
|
1459
|
-
};
|
|
1460
|
-
P.integerValue = function(rm) {
|
|
1461
|
-
var n = new BigNumber2(this);
|
|
1462
|
-
if (rm == null)
|
|
1463
|
-
rm = ROUNDING_MODE;
|
|
1464
|
-
else
|
|
1465
|
-
intCheck(rm, 0, 8);
|
|
1466
|
-
return round(n, n.e + 1, rm);
|
|
1467
|
-
};
|
|
1468
|
-
P.isEqualTo = P.eq = function(y, b) {
|
|
1469
|
-
return compare(this, new BigNumber2(y, b)) === 0;
|
|
1470
|
-
};
|
|
1471
|
-
P.isFinite = function() {
|
|
1472
|
-
return !!this.c;
|
|
1473
|
-
};
|
|
1474
|
-
P.isGreaterThan = P.gt = function(y, b) {
|
|
1475
|
-
return compare(this, new BigNumber2(y, b)) > 0;
|
|
1476
|
-
};
|
|
1477
|
-
P.isGreaterThanOrEqualTo = P.gte = function(y, b) {
|
|
1478
|
-
return (b = compare(this, new BigNumber2(y, b))) === 1 || b === 0;
|
|
1479
|
-
};
|
|
1480
|
-
P.isInteger = function() {
|
|
1481
|
-
return !!this.c && bitFloor(this.e / LOG_BASE) > this.c.length - 2;
|
|
1482
|
-
};
|
|
1483
|
-
P.isLessThan = P.lt = function(y, b) {
|
|
1484
|
-
return compare(this, new BigNumber2(y, b)) < 0;
|
|
1485
|
-
};
|
|
1486
|
-
P.isLessThanOrEqualTo = P.lte = function(y, b) {
|
|
1487
|
-
return (b = compare(this, new BigNumber2(y, b))) === -1 || b === 0;
|
|
1488
|
-
};
|
|
1489
|
-
P.isNaN = function() {
|
|
1490
|
-
return !this.s;
|
|
1491
|
-
};
|
|
1492
|
-
P.isNegative = function() {
|
|
1493
|
-
return this.s < 0;
|
|
1494
|
-
};
|
|
1495
|
-
P.isPositive = function() {
|
|
1496
|
-
return this.s > 0;
|
|
1497
|
-
};
|
|
1498
|
-
P.isZero = function() {
|
|
1499
|
-
return !!this.c && this.c[0] == 0;
|
|
1500
|
-
};
|
|
1501
|
-
P.minus = function(y, b) {
|
|
1502
|
-
var i, j, t, xLTy, x = this, a = x.s;
|
|
1503
|
-
y = new BigNumber2(y, b);
|
|
1504
|
-
b = y.s;
|
|
1505
|
-
if (!a || !b)
|
|
1506
|
-
return new BigNumber2(NaN);
|
|
1507
|
-
if (a != b) {
|
|
1508
|
-
y.s = -b;
|
|
1509
|
-
return x.plus(y);
|
|
1510
|
-
}
|
|
1511
|
-
var xe = x.e / LOG_BASE, ye = y.e / LOG_BASE, xc = x.c, yc = y.c;
|
|
1512
|
-
if (!xe || !ye) {
|
|
1513
|
-
if (!xc || !yc)
|
|
1514
|
-
return xc ? (y.s = -b, y) : new BigNumber2(yc ? x : NaN);
|
|
1515
|
-
if (!xc[0] || !yc[0]) {
|
|
1516
|
-
return yc[0] ? (y.s = -b, y) : new BigNumber2(xc[0] ? x : ROUNDING_MODE == 3 ? -0 : 0);
|
|
1517
|
-
}
|
|
1518
|
-
}
|
|
1519
|
-
xe = bitFloor(xe);
|
|
1520
|
-
ye = bitFloor(ye);
|
|
1521
|
-
xc = xc.slice();
|
|
1522
|
-
if (a = xe - ye) {
|
|
1523
|
-
if (xLTy = a < 0) {
|
|
1524
|
-
a = -a;
|
|
1525
|
-
t = xc;
|
|
1526
|
-
} else {
|
|
1527
|
-
ye = xe;
|
|
1528
|
-
t = yc;
|
|
1529
|
-
}
|
|
1530
|
-
t.reverse();
|
|
1531
|
-
for (b = a; b--; t.push(0))
|
|
1532
|
-
;
|
|
1533
|
-
t.reverse();
|
|
1534
|
-
} else {
|
|
1535
|
-
j = (xLTy = (a = xc.length) < (b = yc.length)) ? a : b;
|
|
1536
|
-
for (a = b = 0; b < j; b++) {
|
|
1537
|
-
if (xc[b] != yc[b]) {
|
|
1538
|
-
xLTy = xc[b] < yc[b];
|
|
1539
|
-
break;
|
|
1540
|
-
}
|
|
1541
|
-
}
|
|
1542
|
-
}
|
|
1543
|
-
if (xLTy) {
|
|
1544
|
-
t = xc;
|
|
1545
|
-
xc = yc;
|
|
1546
|
-
yc = t;
|
|
1547
|
-
y.s = -y.s;
|
|
1548
|
-
}
|
|
1549
|
-
b = (j = yc.length) - (i = xc.length);
|
|
1550
|
-
if (b > 0)
|
|
1551
|
-
for (; b--; xc[i++] = 0)
|
|
1552
|
-
;
|
|
1553
|
-
b = BASE - 1;
|
|
1554
|
-
for (; j > a; ) {
|
|
1555
|
-
if (xc[--j] < yc[j]) {
|
|
1556
|
-
for (i = j; i && !xc[--i]; xc[i] = b)
|
|
1557
|
-
;
|
|
1558
|
-
--xc[i];
|
|
1559
|
-
xc[j] += BASE;
|
|
1560
|
-
}
|
|
1561
|
-
xc[j] -= yc[j];
|
|
1562
|
-
}
|
|
1563
|
-
for (; xc[0] == 0; xc.splice(0, 1), --ye)
|
|
1564
|
-
;
|
|
1565
|
-
if (!xc[0]) {
|
|
1566
|
-
y.s = ROUNDING_MODE == 3 ? -1 : 1;
|
|
1567
|
-
y.c = [y.e = 0];
|
|
1568
|
-
return y;
|
|
1569
|
-
}
|
|
1570
|
-
return normalise(y, xc, ye);
|
|
1571
|
-
};
|
|
1572
|
-
P.modulo = P.mod = function(y, b) {
|
|
1573
|
-
var q, s, x = this;
|
|
1574
|
-
y = new BigNumber2(y, b);
|
|
1575
|
-
if (!x.c || !y.s || y.c && !y.c[0]) {
|
|
1576
|
-
return new BigNumber2(NaN);
|
|
1577
|
-
} else if (!y.c || x.c && !x.c[0]) {
|
|
1578
|
-
return new BigNumber2(x);
|
|
1579
|
-
}
|
|
1580
|
-
if (MODULO_MODE == 9) {
|
|
1581
|
-
s = y.s;
|
|
1582
|
-
y.s = 1;
|
|
1583
|
-
q = div(x, y, 0, 3);
|
|
1584
|
-
y.s = s;
|
|
1585
|
-
q.s *= s;
|
|
1586
|
-
} else {
|
|
1587
|
-
q = div(x, y, 0, MODULO_MODE);
|
|
1588
|
-
}
|
|
1589
|
-
y = x.minus(q.times(y));
|
|
1590
|
-
if (!y.c[0] && MODULO_MODE == 1)
|
|
1591
|
-
y.s = x.s;
|
|
1592
|
-
return y;
|
|
1593
|
-
};
|
|
1594
|
-
P.multipliedBy = P.times = function(y, b) {
|
|
1595
|
-
var c, e, i, j, k, m, xcL, xlo, xhi, ycL, ylo, yhi, zc, base, sqrtBase, x = this, xc = x.c, yc = (y = new BigNumber2(y, b)).c;
|
|
1596
|
-
if (!xc || !yc || !xc[0] || !yc[0]) {
|
|
1597
|
-
if (!x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc) {
|
|
1598
|
-
y.c = y.e = y.s = null;
|
|
1599
|
-
} else {
|
|
1600
|
-
y.s *= x.s;
|
|
1601
|
-
if (!xc || !yc) {
|
|
1602
|
-
y.c = y.e = null;
|
|
1603
|
-
} else {
|
|
1604
|
-
y.c = [0];
|
|
1605
|
-
y.e = 0;
|
|
1606
|
-
}
|
|
1607
|
-
}
|
|
1608
|
-
return y;
|
|
1609
|
-
}
|
|
1610
|
-
e = bitFloor(x.e / LOG_BASE) + bitFloor(y.e / LOG_BASE);
|
|
1611
|
-
y.s *= x.s;
|
|
1612
|
-
xcL = xc.length;
|
|
1613
|
-
ycL = yc.length;
|
|
1614
|
-
if (xcL < ycL) {
|
|
1615
|
-
zc = xc;
|
|
1616
|
-
xc = yc;
|
|
1617
|
-
yc = zc;
|
|
1618
|
-
i = xcL;
|
|
1619
|
-
xcL = ycL;
|
|
1620
|
-
ycL = i;
|
|
1621
|
-
}
|
|
1622
|
-
for (i = xcL + ycL, zc = []; i--; zc.push(0))
|
|
1623
|
-
;
|
|
1624
|
-
base = BASE;
|
|
1625
|
-
sqrtBase = SQRT_BASE;
|
|
1626
|
-
for (i = ycL; --i >= 0; ) {
|
|
1627
|
-
c = 0;
|
|
1628
|
-
ylo = yc[i] % sqrtBase;
|
|
1629
|
-
yhi = yc[i] / sqrtBase | 0;
|
|
1630
|
-
for (k = xcL, j = i + k; j > i; ) {
|
|
1631
|
-
xlo = xc[--k] % sqrtBase;
|
|
1632
|
-
xhi = xc[k] / sqrtBase | 0;
|
|
1633
|
-
m = yhi * xlo + xhi * ylo;
|
|
1634
|
-
xlo = ylo * xlo + m % sqrtBase * sqrtBase + zc[j] + c;
|
|
1635
|
-
c = (xlo / base | 0) + (m / sqrtBase | 0) + yhi * xhi;
|
|
1636
|
-
zc[j--] = xlo % base;
|
|
1637
|
-
}
|
|
1638
|
-
zc[j] = c;
|
|
1639
|
-
}
|
|
1640
|
-
if (c) {
|
|
1641
|
-
++e;
|
|
1642
|
-
} else {
|
|
1643
|
-
zc.splice(0, 1);
|
|
1644
|
-
}
|
|
1645
|
-
return normalise(y, zc, e);
|
|
1646
|
-
};
|
|
1647
|
-
P.negated = function() {
|
|
1648
|
-
var x = new BigNumber2(this);
|
|
1649
|
-
x.s = -x.s || null;
|
|
1650
|
-
return x;
|
|
1651
|
-
};
|
|
1652
|
-
P.plus = function(y, b) {
|
|
1653
|
-
var t, x = this, a = x.s;
|
|
1654
|
-
y = new BigNumber2(y, b);
|
|
1655
|
-
b = y.s;
|
|
1656
|
-
if (!a || !b)
|
|
1657
|
-
return new BigNumber2(NaN);
|
|
1658
|
-
if (a != b) {
|
|
1659
|
-
y.s = -b;
|
|
1660
|
-
return x.minus(y);
|
|
1661
|
-
}
|
|
1662
|
-
var xe = x.e / LOG_BASE, ye = y.e / LOG_BASE, xc = x.c, yc = y.c;
|
|
1663
|
-
if (!xe || !ye) {
|
|
1664
|
-
if (!xc || !yc)
|
|
1665
|
-
return new BigNumber2(a / 0);
|
|
1666
|
-
if (!xc[0] || !yc[0])
|
|
1667
|
-
return yc[0] ? y : new BigNumber2(xc[0] ? x : a * 0);
|
|
1668
|
-
}
|
|
1669
|
-
xe = bitFloor(xe);
|
|
1670
|
-
ye = bitFloor(ye);
|
|
1671
|
-
xc = xc.slice();
|
|
1672
|
-
if (a = xe - ye) {
|
|
1673
|
-
if (a > 0) {
|
|
1674
|
-
ye = xe;
|
|
1675
|
-
t = yc;
|
|
1676
|
-
} else {
|
|
1677
|
-
a = -a;
|
|
1678
|
-
t = xc;
|
|
1679
|
-
}
|
|
1680
|
-
t.reverse();
|
|
1681
|
-
for (; a--; t.push(0))
|
|
1682
|
-
;
|
|
1683
|
-
t.reverse();
|
|
1684
|
-
}
|
|
1685
|
-
a = xc.length;
|
|
1686
|
-
b = yc.length;
|
|
1687
|
-
if (a - b < 0) {
|
|
1688
|
-
t = yc;
|
|
1689
|
-
yc = xc;
|
|
1690
|
-
xc = t;
|
|
1691
|
-
b = a;
|
|
1692
|
-
}
|
|
1693
|
-
for (a = 0; b; ) {
|
|
1694
|
-
a = (xc[--b] = xc[b] + yc[b] + a) / BASE | 0;
|
|
1695
|
-
xc[b] = BASE === xc[b] ? 0 : xc[b] % BASE;
|
|
1696
|
-
}
|
|
1697
|
-
if (a) {
|
|
1698
|
-
xc = [a].concat(xc);
|
|
1699
|
-
++ye;
|
|
1700
|
-
}
|
|
1701
|
-
return normalise(y, xc, ye);
|
|
1702
|
-
};
|
|
1703
|
-
P.precision = P.sd = function(sd, rm) {
|
|
1704
|
-
var c, n, v, x = this;
|
|
1705
|
-
if (sd != null && sd !== !!sd) {
|
|
1706
|
-
intCheck(sd, 1, MAX);
|
|
1707
|
-
if (rm == null)
|
|
1708
|
-
rm = ROUNDING_MODE;
|
|
1709
|
-
else
|
|
1710
|
-
intCheck(rm, 0, 8);
|
|
1711
|
-
return round(new BigNumber2(x), sd, rm);
|
|
1712
|
-
}
|
|
1713
|
-
if (!(c = x.c))
|
|
1714
|
-
return null;
|
|
1715
|
-
v = c.length - 1;
|
|
1716
|
-
n = v * LOG_BASE + 1;
|
|
1717
|
-
if (v = c[v]) {
|
|
1718
|
-
for (; v % 10 == 0; v /= 10, n--)
|
|
1719
|
-
;
|
|
1720
|
-
for (v = c[0]; v >= 10; v /= 10, n++)
|
|
1721
|
-
;
|
|
1722
|
-
}
|
|
1723
|
-
if (sd && x.e + 1 > n)
|
|
1724
|
-
n = x.e + 1;
|
|
1725
|
-
return n;
|
|
1726
|
-
};
|
|
1727
|
-
P.shiftedBy = function(k) {
|
|
1728
|
-
intCheck(k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
|
|
1729
|
-
return this.times("1e" + k);
|
|
1730
|
-
};
|
|
1731
|
-
P.squareRoot = P.sqrt = function() {
|
|
1732
|
-
var m, n, r, rep, t, x = this, c = x.c, s = x.s, e = x.e, dp = DECIMAL_PLACES + 4, half = new BigNumber2("0.5");
|
|
1733
|
-
if (s !== 1 || !c || !c[0]) {
|
|
1734
|
-
return new BigNumber2(!s || s < 0 && (!c || c[0]) ? NaN : c ? x : 1 / 0);
|
|
1735
|
-
}
|
|
1736
|
-
s = Math.sqrt(+valueOf(x));
|
|
1737
|
-
if (s == 0 || s == 1 / 0) {
|
|
1738
|
-
n = coeffToString(c);
|
|
1739
|
-
if ((n.length + e) % 2 == 0)
|
|
1740
|
-
n += "0";
|
|
1741
|
-
s = Math.sqrt(+n);
|
|
1742
|
-
e = bitFloor((e + 1) / 2) - (e < 0 || e % 2);
|
|
1743
|
-
if (s == 1 / 0) {
|
|
1744
|
-
n = "5e" + e;
|
|
1745
|
-
} else {
|
|
1746
|
-
n = s.toExponential();
|
|
1747
|
-
n = n.slice(0, n.indexOf("e") + 1) + e;
|
|
1748
|
-
}
|
|
1749
|
-
r = new BigNumber2(n);
|
|
1750
|
-
} else {
|
|
1751
|
-
r = new BigNumber2(s + "");
|
|
1752
|
-
}
|
|
1753
|
-
if (r.c[0]) {
|
|
1754
|
-
e = r.e;
|
|
1755
|
-
s = e + dp;
|
|
1756
|
-
if (s < 3)
|
|
1757
|
-
s = 0;
|
|
1758
|
-
for (; ; ) {
|
|
1759
|
-
t = r;
|
|
1760
|
-
r = half.times(t.plus(div(x, t, dp, 1)));
|
|
1761
|
-
if (coeffToString(t.c).slice(0, s) === (n = coeffToString(r.c)).slice(0, s)) {
|
|
1762
|
-
if (r.e < e)
|
|
1763
|
-
--s;
|
|
1764
|
-
n = n.slice(s - 3, s + 1);
|
|
1765
|
-
if (n == "9999" || !rep && n == "4999") {
|
|
1766
|
-
if (!rep) {
|
|
1767
|
-
round(t, t.e + DECIMAL_PLACES + 2, 0);
|
|
1768
|
-
if (t.times(t).eq(x)) {
|
|
1769
|
-
r = t;
|
|
1770
|
-
break;
|
|
1771
|
-
}
|
|
1772
|
-
}
|
|
1773
|
-
dp += 4;
|
|
1774
|
-
s += 4;
|
|
1775
|
-
rep = 1;
|
|
1776
|
-
} else {
|
|
1777
|
-
if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
|
|
1778
|
-
round(r, r.e + DECIMAL_PLACES + 2, 1);
|
|
1779
|
-
m = !r.times(r).eq(x);
|
|
1780
|
-
}
|
|
1781
|
-
break;
|
|
1782
|
-
}
|
|
1783
|
-
}
|
|
1784
|
-
}
|
|
1785
|
-
}
|
|
1786
|
-
return round(r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m);
|
|
1787
|
-
};
|
|
1788
|
-
P.toExponential = function(dp, rm) {
|
|
1789
|
-
if (dp != null) {
|
|
1790
|
-
intCheck(dp, 0, MAX);
|
|
1791
|
-
dp++;
|
|
1792
|
-
}
|
|
1793
|
-
return format(this, dp, rm, 1);
|
|
1794
|
-
};
|
|
1795
|
-
P.toFixed = function(dp, rm) {
|
|
1796
|
-
if (dp != null) {
|
|
1797
|
-
intCheck(dp, 0, MAX);
|
|
1798
|
-
dp = dp + this.e + 1;
|
|
1799
|
-
}
|
|
1800
|
-
return format(this, dp, rm);
|
|
1801
|
-
};
|
|
1802
|
-
P.toFormat = function(dp, rm, format2) {
|
|
1803
|
-
var str, x = this;
|
|
1804
|
-
if (format2 == null) {
|
|
1805
|
-
if (dp != null && rm && typeof rm == "object") {
|
|
1806
|
-
format2 = rm;
|
|
1807
|
-
rm = null;
|
|
1808
|
-
} else if (dp && typeof dp == "object") {
|
|
1809
|
-
format2 = dp;
|
|
1810
|
-
dp = rm = null;
|
|
1811
|
-
} else {
|
|
1812
|
-
format2 = FORMAT;
|
|
1813
|
-
}
|
|
1814
|
-
} else if (typeof format2 != "object") {
|
|
1815
|
-
throw Error(bignumberError + "Argument not an object: " + format2);
|
|
1816
|
-
}
|
|
1817
|
-
str = x.toFixed(dp, rm);
|
|
1818
|
-
if (x.c) {
|
|
1819
|
-
var i, arr = str.split("."), g1 = +format2.groupSize, g2 = +format2.secondaryGroupSize, groupSeparator = format2.groupSeparator || "", intPart = arr[0], fractionPart = arr[1], isNeg = x.s < 0, intDigits = isNeg ? intPart.slice(1) : intPart, len = intDigits.length;
|
|
1820
|
-
if (g2) {
|
|
1821
|
-
i = g1;
|
|
1822
|
-
g1 = g2;
|
|
1823
|
-
g2 = i;
|
|
1824
|
-
len -= i;
|
|
1825
|
-
}
|
|
1826
|
-
if (g1 > 0 && len > 0) {
|
|
1827
|
-
i = len % g1 || g1;
|
|
1828
|
-
intPart = intDigits.substr(0, i);
|
|
1829
|
-
for (; i < len; i += g1)
|
|
1830
|
-
intPart += groupSeparator + intDigits.substr(i, g1);
|
|
1831
|
-
if (g2 > 0)
|
|
1832
|
-
intPart += groupSeparator + intDigits.slice(i);
|
|
1833
|
-
if (isNeg)
|
|
1834
|
-
intPart = "-" + intPart;
|
|
1835
|
-
}
|
|
1836
|
-
str = fractionPart ? intPart + (format2.decimalSeparator || "") + ((g2 = +format2.fractionGroupSize) ? fractionPart.replace(
|
|
1837
|
-
new RegExp("\\d{" + g2 + "}\\B", "g"),
|
|
1838
|
-
"$&" + (format2.fractionGroupSeparator || "")
|
|
1839
|
-
) : fractionPart) : intPart;
|
|
1840
|
-
}
|
|
1841
|
-
return (format2.prefix || "") + str + (format2.suffix || "");
|
|
1842
|
-
};
|
|
1843
|
-
P.toFraction = function(md) {
|
|
1844
|
-
var d, d0, d1, d2, e, exp, n, n0, n1, q, r, s, x = this, xc = x.c;
|
|
1845
|
-
if (md != null) {
|
|
1846
|
-
n = new BigNumber2(md);
|
|
1847
|
-
if (!n.isInteger() && (n.c || n.s !== 1) || n.lt(ONE)) {
|
|
1848
|
-
throw Error(bignumberError + "Argument " + (n.isInteger() ? "out of range: " : "not an integer: ") + valueOf(n));
|
|
1849
|
-
}
|
|
1850
|
-
}
|
|
1851
|
-
if (!xc)
|
|
1852
|
-
return new BigNumber2(x);
|
|
1853
|
-
d = new BigNumber2(ONE);
|
|
1854
|
-
n1 = d0 = new BigNumber2(ONE);
|
|
1855
|
-
d1 = n0 = new BigNumber2(ONE);
|
|
1856
|
-
s = coeffToString(xc);
|
|
1857
|
-
e = d.e = s.length - x.e - 1;
|
|
1858
|
-
d.c[0] = POWS_TEN[(exp = e % LOG_BASE) < 0 ? LOG_BASE + exp : exp];
|
|
1859
|
-
md = !md || n.comparedTo(d) > 0 ? e > 0 ? d : n1 : n;
|
|
1860
|
-
exp = MAX_EXP;
|
|
1861
|
-
MAX_EXP = 1 / 0;
|
|
1862
|
-
n = new BigNumber2(s);
|
|
1863
|
-
n0.c[0] = 0;
|
|
1864
|
-
for (; ; ) {
|
|
1865
|
-
q = div(n, d, 0, 1);
|
|
1866
|
-
d2 = d0.plus(q.times(d1));
|
|
1867
|
-
if (d2.comparedTo(md) == 1)
|
|
1868
|
-
break;
|
|
1869
|
-
d0 = d1;
|
|
1870
|
-
d1 = d2;
|
|
1871
|
-
n1 = n0.plus(q.times(d2 = n1));
|
|
1872
|
-
n0 = d2;
|
|
1873
|
-
d = n.minus(q.times(d2 = d));
|
|
1874
|
-
n = d2;
|
|
1875
|
-
}
|
|
1876
|
-
d2 = div(md.minus(d0), d1, 0, 1);
|
|
1877
|
-
n0 = n0.plus(d2.times(n1));
|
|
1878
|
-
d0 = d0.plus(d2.times(d1));
|
|
1879
|
-
n0.s = n1.s = x.s;
|
|
1880
|
-
e = e * 2;
|
|
1881
|
-
r = div(n1, d1, e, ROUNDING_MODE).minus(x).abs().comparedTo(
|
|
1882
|
-
div(n0, d0, e, ROUNDING_MODE).minus(x).abs()
|
|
1883
|
-
) < 1 ? [n1, d1] : [n0, d0];
|
|
1884
|
-
MAX_EXP = exp;
|
|
1885
|
-
return r;
|
|
1886
|
-
};
|
|
1887
|
-
P.toNumber = function() {
|
|
1888
|
-
return +valueOf(this);
|
|
1889
|
-
};
|
|
1890
|
-
P.toPrecision = function(sd, rm) {
|
|
1891
|
-
if (sd != null)
|
|
1892
|
-
intCheck(sd, 1, MAX);
|
|
1893
|
-
return format(this, sd, rm, 2);
|
|
1894
|
-
};
|
|
1895
|
-
P.toString = function(b) {
|
|
1896
|
-
var str, n = this, s = n.s, e = n.e;
|
|
1897
|
-
if (e === null) {
|
|
1898
|
-
if (s) {
|
|
1899
|
-
str = "Infinity";
|
|
1900
|
-
if (s < 0)
|
|
1901
|
-
str = "-" + str;
|
|
1902
|
-
} else {
|
|
1903
|
-
str = "NaN";
|
|
1904
|
-
}
|
|
1905
|
-
} else {
|
|
1906
|
-
if (b == null) {
|
|
1907
|
-
str = e <= TO_EXP_NEG || e >= TO_EXP_POS ? toExponential(coeffToString(n.c), e) : toFixedPoint(coeffToString(n.c), e, "0");
|
|
1908
|
-
} else if (b === 10 && alphabetHasNormalDecimalDigits) {
|
|
1909
|
-
n = round(new BigNumber2(n), DECIMAL_PLACES + e + 1, ROUNDING_MODE);
|
|
1910
|
-
str = toFixedPoint(coeffToString(n.c), n.e, "0");
|
|
1911
|
-
} else {
|
|
1912
|
-
intCheck(b, 2, ALPHABET.length, "Base");
|
|
1913
|
-
str = convertBase(toFixedPoint(coeffToString(n.c), e, "0"), 10, b, s, true);
|
|
1914
|
-
}
|
|
1915
|
-
if (s < 0 && n.c[0])
|
|
1916
|
-
str = "-" + str;
|
|
1917
|
-
}
|
|
1918
|
-
return str;
|
|
1919
|
-
};
|
|
1920
|
-
P.valueOf = P.toJSON = function() {
|
|
1921
|
-
return valueOf(this);
|
|
1922
|
-
};
|
|
1923
|
-
P._isBigNumber = true;
|
|
1924
|
-
if (configObject != null)
|
|
1925
|
-
BigNumber2.set(configObject);
|
|
1926
|
-
return BigNumber2;
|
|
1927
|
-
}
|
|
1928
|
-
function bitFloor(n) {
|
|
1929
|
-
var i = n | 0;
|
|
1930
|
-
return n > 0 || n === i ? i : i - 1;
|
|
1931
|
-
}
|
|
1932
|
-
function coeffToString(a) {
|
|
1933
|
-
var s, z, i = 1, j = a.length, r = a[0] + "";
|
|
1934
|
-
for (; i < j; ) {
|
|
1935
|
-
s = a[i++] + "";
|
|
1936
|
-
z = LOG_BASE - s.length;
|
|
1937
|
-
for (; z--; s = "0" + s)
|
|
1938
|
-
;
|
|
1939
|
-
r += s;
|
|
1940
|
-
}
|
|
1941
|
-
for (j = r.length; r.charCodeAt(--j) === 48; )
|
|
1942
|
-
;
|
|
1943
|
-
return r.slice(0, j + 1 || 1);
|
|
1944
|
-
}
|
|
1945
|
-
function compare(x, y) {
|
|
1946
|
-
var a, b, xc = x.c, yc = y.c, i = x.s, j = y.s, k = x.e, l = y.e;
|
|
1947
|
-
if (!i || !j)
|
|
1948
|
-
return null;
|
|
1949
|
-
a = xc && !xc[0];
|
|
1950
|
-
b = yc && !yc[0];
|
|
1951
|
-
if (a || b)
|
|
1952
|
-
return a ? b ? 0 : -j : i;
|
|
1953
|
-
if (i != j)
|
|
1954
|
-
return i;
|
|
1955
|
-
a = i < 0;
|
|
1956
|
-
b = k == l;
|
|
1957
|
-
if (!xc || !yc)
|
|
1958
|
-
return b ? 0 : !xc ^ a ? 1 : -1;
|
|
1959
|
-
if (!b)
|
|
1960
|
-
return k > l ^ a ? 1 : -1;
|
|
1961
|
-
j = (k = xc.length) < (l = yc.length) ? k : l;
|
|
1962
|
-
for (i = 0; i < j; i++)
|
|
1963
|
-
if (xc[i] != yc[i])
|
|
1964
|
-
return xc[i] > yc[i] ^ a ? 1 : -1;
|
|
1965
|
-
return k == l ? 0 : k > l ^ a ? 1 : -1;
|
|
1966
|
-
}
|
|
1967
|
-
function intCheck(n, min, max, name) {
|
|
1968
|
-
if (n < min || n > max || n !== mathfloor(n)) {
|
|
1969
|
-
throw Error(bignumberError + (name || "Argument") + (typeof n == "number" ? n < min || n > max ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(n));
|
|
1970
|
-
}
|
|
1971
|
-
}
|
|
1972
|
-
function isOdd(n) {
|
|
1973
|
-
var k = n.c.length - 1;
|
|
1974
|
-
return bitFloor(n.e / LOG_BASE) == k && n.c[k] % 2 != 0;
|
|
1975
|
-
}
|
|
1976
|
-
function toExponential(str, e) {
|
|
1977
|
-
return (str.length > 1 ? str.charAt(0) + "." + str.slice(1) : str) + (e < 0 ? "e" : "e+") + e;
|
|
1978
|
-
}
|
|
1979
|
-
function toFixedPoint(str, e, z) {
|
|
1980
|
-
var len, zs;
|
|
1981
|
-
if (e < 0) {
|
|
1982
|
-
for (zs = z + "."; ++e; zs += z)
|
|
1983
|
-
;
|
|
1984
|
-
str = zs + str;
|
|
1985
|
-
} else {
|
|
1986
|
-
len = str.length;
|
|
1987
|
-
if (++e > len) {
|
|
1988
|
-
for (zs = z, e -= len; --e; zs += z)
|
|
1989
|
-
;
|
|
1990
|
-
str += zs;
|
|
1991
|
-
} else if (e < len) {
|
|
1992
|
-
str = str.slice(0, e) + "." + str.slice(e);
|
|
1993
|
-
}
|
|
1994
|
-
}
|
|
1995
|
-
return str;
|
|
1996
|
-
}
|
|
1997
|
-
BigNumber = clone();
|
|
1998
|
-
BigNumber["default"] = BigNumber.BigNumber = BigNumber;
|
|
1999
|
-
if (typeof define == "function" && define.amd) {
|
|
2000
|
-
define(function() {
|
|
2001
|
-
return BigNumber;
|
|
2002
|
-
});
|
|
2003
|
-
} else if (typeof module != "undefined" && module.exports) {
|
|
2004
|
-
module.exports = BigNumber;
|
|
2005
|
-
} else {
|
|
2006
|
-
if (!globalObject) {
|
|
2007
|
-
globalObject = typeof self != "undefined" && self ? self : window;
|
|
2008
|
-
}
|
|
2009
|
-
globalObject.BigNumber = BigNumber;
|
|
2010
|
-
}
|
|
2011
|
-
})(exports);
|
|
2012
|
-
}
|
|
2013
|
-
});
|
|
2014
|
-
|
|
2015
|
-
// node_modules/json-bigint/lib/stringify.js
|
|
2016
|
-
var require_stringify = __commonJS({
|
|
2017
|
-
"node_modules/json-bigint/lib/stringify.js"(exports, module) {
|
|
2018
|
-
var BigNumber = require_bignumber();
|
|
2019
|
-
var JSON2 = module.exports;
|
|
2020
|
-
(function() {
|
|
2021
|
-
"use strict";
|
|
2022
|
-
function f(n) {
|
|
2023
|
-
return n < 10 ? "0" + n : n;
|
|
2024
|
-
}
|
|
2025
|
-
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, gap, indent, meta = {
|
|
2026
|
-
"\b": "\\b",
|
|
2027
|
-
" ": "\\t",
|
|
2028
|
-
"\n": "\\n",
|
|
2029
|
-
"\f": "\\f",
|
|
2030
|
-
"\r": "\\r",
|
|
2031
|
-
'"': '\\"',
|
|
2032
|
-
"\\": "\\\\"
|
|
2033
|
-
}, rep;
|
|
2034
|
-
function quote(string) {
|
|
2035
|
-
escapable.lastIndex = 0;
|
|
2036
|
-
return escapable.test(string) ? '"' + string.replace(escapable, function(a) {
|
|
2037
|
-
var c = meta[a];
|
|
2038
|
-
return typeof c === "string" ? c : "\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4);
|
|
2039
|
-
}) + '"' : '"' + string + '"';
|
|
2040
|
-
}
|
|
2041
|
-
function str(key, holder) {
|
|
2042
|
-
var i, k, v, length, mind = gap, partial, value = holder[key], isBigNumber = value != null && (value instanceof BigNumber || BigNumber.isBigNumber(value));
|
|
2043
|
-
if (value && typeof value === "object" && typeof value.toJSON === "function") {
|
|
2044
|
-
value = value.toJSON(key);
|
|
2045
|
-
}
|
|
2046
|
-
if (typeof rep === "function") {
|
|
2047
|
-
value = rep.call(holder, key, value);
|
|
2048
|
-
}
|
|
2049
|
-
switch (typeof value) {
|
|
2050
|
-
case "string":
|
|
2051
|
-
if (isBigNumber) {
|
|
2052
|
-
return value;
|
|
2053
|
-
} else {
|
|
2054
|
-
return quote(value);
|
|
2055
|
-
}
|
|
2056
|
-
case "number":
|
|
2057
|
-
return isFinite(value) ? String(value) : "null";
|
|
2058
|
-
case "boolean":
|
|
2059
|
-
case "null":
|
|
2060
|
-
case "bigint":
|
|
2061
|
-
return String(value);
|
|
2062
|
-
case "object":
|
|
2063
|
-
if (!value) {
|
|
2064
|
-
return "null";
|
|
2065
|
-
}
|
|
2066
|
-
gap += indent;
|
|
2067
|
-
partial = [];
|
|
2068
|
-
if (Object.prototype.toString.apply(value) === "[object Array]") {
|
|
2069
|
-
length = value.length;
|
|
2070
|
-
for (i = 0; i < length; i += 1) {
|
|
2071
|
-
partial[i] = str(i, value) || "null";
|
|
2072
|
-
}
|
|
2073
|
-
v = partial.length === 0 ? "[]" : gap ? "[\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "]" : "[" + partial.join(",") + "]";
|
|
2074
|
-
gap = mind;
|
|
2075
|
-
return v;
|
|
2076
|
-
}
|
|
2077
|
-
if (rep && typeof rep === "object") {
|
|
2078
|
-
length = rep.length;
|
|
2079
|
-
for (i = 0; i < length; i += 1) {
|
|
2080
|
-
if (typeof rep[i] === "string") {
|
|
2081
|
-
k = rep[i];
|
|
2082
|
-
v = str(k, value);
|
|
2083
|
-
if (v) {
|
|
2084
|
-
partial.push(quote(k) + (gap ? ": " : ":") + v);
|
|
2085
|
-
}
|
|
2086
|
-
}
|
|
2087
|
-
}
|
|
2088
|
-
} else {
|
|
2089
|
-
Object.keys(value).forEach(function(k2) {
|
|
2090
|
-
var v2 = str(k2, value);
|
|
2091
|
-
if (v2) {
|
|
2092
|
-
partial.push(quote(k2) + (gap ? ": " : ":") + v2);
|
|
2093
|
-
}
|
|
2094
|
-
});
|
|
2095
|
-
}
|
|
2096
|
-
v = partial.length === 0 ? "{}" : gap ? "{\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "}" : "{" + partial.join(",") + "}";
|
|
2097
|
-
gap = mind;
|
|
2098
|
-
return v;
|
|
2099
|
-
}
|
|
2100
|
-
}
|
|
2101
|
-
if (typeof JSON2.stringify !== "function") {
|
|
2102
|
-
JSON2.stringify = function(value, replacer, space) {
|
|
2103
|
-
var i;
|
|
2104
|
-
gap = "";
|
|
2105
|
-
indent = "";
|
|
2106
|
-
if (typeof space === "number") {
|
|
2107
|
-
for (i = 0; i < space; i += 1) {
|
|
2108
|
-
indent += " ";
|
|
2109
|
-
}
|
|
2110
|
-
} else if (typeof space === "string") {
|
|
2111
|
-
indent = space;
|
|
2112
|
-
}
|
|
2113
|
-
rep = replacer;
|
|
2114
|
-
if (replacer && typeof replacer !== "function" && (typeof replacer !== "object" || typeof replacer.length !== "number")) {
|
|
2115
|
-
throw new Error("JSON.stringify");
|
|
2116
|
-
}
|
|
2117
|
-
return str("", { "": value });
|
|
2118
|
-
};
|
|
2119
|
-
}
|
|
2120
|
-
})();
|
|
2121
|
-
}
|
|
2122
|
-
});
|
|
2123
|
-
|
|
2124
|
-
// node_modules/json-bigint/lib/parse.js
|
|
2125
|
-
var require_parse = __commonJS({
|
|
2126
|
-
"node_modules/json-bigint/lib/parse.js"(exports, module) {
|
|
2127
|
-
var BigNumber = null;
|
|
2128
|
-
var suspectProtoRx = /(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])/;
|
|
2129
|
-
var suspectConstructorRx = /(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)/;
|
|
2130
|
-
var json_parse = function(options) {
|
|
2131
|
-
"use strict";
|
|
2132
|
-
var _options = {
|
|
2133
|
-
strict: false,
|
|
2134
|
-
storeAsString: false,
|
|
2135
|
-
alwaysParseAsBig: false,
|
|
2136
|
-
useNativeBigInt: false,
|
|
2137
|
-
protoAction: "error",
|
|
2138
|
-
constructorAction: "error"
|
|
2139
|
-
};
|
|
2140
|
-
if (options !== void 0 && options !== null) {
|
|
2141
|
-
if (options.strict === true) {
|
|
2142
|
-
_options.strict = true;
|
|
2143
|
-
}
|
|
2144
|
-
if (options.storeAsString === true) {
|
|
2145
|
-
_options.storeAsString = true;
|
|
2146
|
-
}
|
|
2147
|
-
_options.alwaysParseAsBig = options.alwaysParseAsBig === true ? options.alwaysParseAsBig : false;
|
|
2148
|
-
_options.useNativeBigInt = options.useNativeBigInt === true ? options.useNativeBigInt : false;
|
|
2149
|
-
if (typeof options.constructorAction !== "undefined") {
|
|
2150
|
-
if (options.constructorAction === "error" || options.constructorAction === "ignore" || options.constructorAction === "preserve") {
|
|
2151
|
-
_options.constructorAction = options.constructorAction;
|
|
2152
|
-
} else {
|
|
2153
|
-
throw new Error(
|
|
2154
|
-
`Incorrect value for constructorAction option, must be "error", "ignore" or undefined but passed ${options.constructorAction}`
|
|
2155
|
-
);
|
|
2156
|
-
}
|
|
2157
|
-
}
|
|
2158
|
-
if (typeof options.protoAction !== "undefined") {
|
|
2159
|
-
if (options.protoAction === "error" || options.protoAction === "ignore" || options.protoAction === "preserve") {
|
|
2160
|
-
_options.protoAction = options.protoAction;
|
|
2161
|
-
} else {
|
|
2162
|
-
throw new Error(
|
|
2163
|
-
`Incorrect value for protoAction option, must be "error", "ignore" or undefined but passed ${options.protoAction}`
|
|
2164
|
-
);
|
|
2165
|
-
}
|
|
2166
|
-
}
|
|
2167
|
-
}
|
|
2168
|
-
var at, ch, escapee = {
|
|
2169
|
-
'"': '"',
|
|
2170
|
-
"\\": "\\",
|
|
2171
|
-
"/": "/",
|
|
2172
|
-
b: "\b",
|
|
2173
|
-
f: "\f",
|
|
2174
|
-
n: "\n",
|
|
2175
|
-
r: "\r",
|
|
2176
|
-
t: " "
|
|
2177
|
-
}, text, error = function(m) {
|
|
2178
|
-
throw {
|
|
2179
|
-
name: "SyntaxError",
|
|
2180
|
-
message: m,
|
|
2181
|
-
at,
|
|
2182
|
-
text
|
|
2183
|
-
};
|
|
2184
|
-
}, next = function(c) {
|
|
2185
|
-
if (c && c !== ch) {
|
|
2186
|
-
error("Expected '" + c + "' instead of '" + ch + "'");
|
|
2187
|
-
}
|
|
2188
|
-
ch = text.charAt(at);
|
|
2189
|
-
at += 1;
|
|
2190
|
-
return ch;
|
|
2191
|
-
}, number3 = function() {
|
|
2192
|
-
var number4, string2 = "";
|
|
2193
|
-
if (ch === "-") {
|
|
2194
|
-
string2 = "-";
|
|
2195
|
-
next("-");
|
|
2196
|
-
}
|
|
2197
|
-
while (ch >= "0" && ch <= "9") {
|
|
2198
|
-
string2 += ch;
|
|
2199
|
-
next();
|
|
2200
|
-
}
|
|
2201
|
-
if (ch === ".") {
|
|
2202
|
-
string2 += ".";
|
|
2203
|
-
while (next() && ch >= "0" && ch <= "9") {
|
|
2204
|
-
string2 += ch;
|
|
2205
|
-
}
|
|
2206
|
-
}
|
|
2207
|
-
if (ch === "e" || ch === "E") {
|
|
2208
|
-
string2 += ch;
|
|
2209
|
-
next();
|
|
2210
|
-
if (ch === "-" || ch === "+") {
|
|
2211
|
-
string2 += ch;
|
|
2212
|
-
next();
|
|
2213
|
-
}
|
|
2214
|
-
while (ch >= "0" && ch <= "9") {
|
|
2215
|
-
string2 += ch;
|
|
2216
|
-
next();
|
|
2217
|
-
}
|
|
2218
|
-
}
|
|
2219
|
-
number4 = +string2;
|
|
2220
|
-
if (!isFinite(number4)) {
|
|
2221
|
-
error("Bad number");
|
|
2222
|
-
} else {
|
|
2223
|
-
if (BigNumber == null)
|
|
2224
|
-
BigNumber = require_bignumber();
|
|
2225
|
-
if (string2.length > 15)
|
|
2226
|
-
return _options.storeAsString ? string2 : _options.useNativeBigInt ? BigInt(string2) : new BigNumber(string2);
|
|
2227
|
-
else
|
|
2228
|
-
return !_options.alwaysParseAsBig ? number4 : _options.useNativeBigInt ? BigInt(number4) : new BigNumber(number4);
|
|
2229
|
-
}
|
|
2230
|
-
}, string = function() {
|
|
2231
|
-
var hex, i, string2 = "", uffff;
|
|
2232
|
-
if (ch === '"') {
|
|
2233
|
-
var startAt = at;
|
|
2234
|
-
while (next()) {
|
|
2235
|
-
if (ch === '"') {
|
|
2236
|
-
if (at - 1 > startAt)
|
|
2237
|
-
string2 += text.substring(startAt, at - 1);
|
|
2238
|
-
next();
|
|
2239
|
-
return string2;
|
|
2240
|
-
}
|
|
2241
|
-
if (ch === "\\") {
|
|
2242
|
-
if (at - 1 > startAt)
|
|
2243
|
-
string2 += text.substring(startAt, at - 1);
|
|
2244
|
-
next();
|
|
2245
|
-
if (ch === "u") {
|
|
2246
|
-
uffff = 0;
|
|
2247
|
-
for (i = 0; i < 4; i += 1) {
|
|
2248
|
-
hex = parseInt(next(), 16);
|
|
2249
|
-
if (!isFinite(hex)) {
|
|
2250
|
-
break;
|
|
2251
|
-
}
|
|
2252
|
-
uffff = uffff * 16 + hex;
|
|
2253
|
-
}
|
|
2254
|
-
string2 += String.fromCharCode(uffff);
|
|
2255
|
-
} else if (typeof escapee[ch] === "string") {
|
|
2256
|
-
string2 += escapee[ch];
|
|
2257
|
-
} else {
|
|
2258
|
-
break;
|
|
2259
|
-
}
|
|
2260
|
-
startAt = at;
|
|
2261
|
-
}
|
|
2262
|
-
}
|
|
2263
|
-
}
|
|
2264
|
-
error("Bad string");
|
|
2265
|
-
}, white = function() {
|
|
2266
|
-
while (ch && ch <= " ") {
|
|
2267
|
-
next();
|
|
2268
|
-
}
|
|
2269
|
-
}, word = function() {
|
|
2270
|
-
switch (ch) {
|
|
2271
|
-
case "t":
|
|
2272
|
-
next("t");
|
|
2273
|
-
next("r");
|
|
2274
|
-
next("u");
|
|
2275
|
-
next("e");
|
|
2276
|
-
return true;
|
|
2277
|
-
case "f":
|
|
2278
|
-
next("f");
|
|
2279
|
-
next("a");
|
|
2280
|
-
next("l");
|
|
2281
|
-
next("s");
|
|
2282
|
-
next("e");
|
|
2283
|
-
return false;
|
|
2284
|
-
case "n":
|
|
2285
|
-
next("n");
|
|
2286
|
-
next("u");
|
|
2287
|
-
next("l");
|
|
2288
|
-
next("l");
|
|
2289
|
-
return null;
|
|
2290
|
-
}
|
|
2291
|
-
error("Unexpected '" + ch + "'");
|
|
2292
|
-
}, value, array = function() {
|
|
2293
|
-
var array2 = [];
|
|
2294
|
-
if (ch === "[") {
|
|
2295
|
-
next("[");
|
|
2296
|
-
white();
|
|
2297
|
-
if (ch === "]") {
|
|
2298
|
-
next("]");
|
|
2299
|
-
return array2;
|
|
2300
|
-
}
|
|
2301
|
-
while (ch) {
|
|
2302
|
-
array2.push(value());
|
|
2303
|
-
white();
|
|
2304
|
-
if (ch === "]") {
|
|
2305
|
-
next("]");
|
|
2306
|
-
return array2;
|
|
2307
|
-
}
|
|
2308
|
-
next(",");
|
|
2309
|
-
white();
|
|
2310
|
-
}
|
|
2311
|
-
}
|
|
2312
|
-
error("Bad array");
|
|
2313
|
-
}, object = function() {
|
|
2314
|
-
var key, object2 = /* @__PURE__ */ Object.create(null);
|
|
2315
|
-
if (ch === "{") {
|
|
2316
|
-
next("{");
|
|
2317
|
-
white();
|
|
2318
|
-
if (ch === "}") {
|
|
2319
|
-
next("}");
|
|
2320
|
-
return object2;
|
|
2321
|
-
}
|
|
2322
|
-
while (ch) {
|
|
2323
|
-
key = string();
|
|
2324
|
-
white();
|
|
2325
|
-
next(":");
|
|
2326
|
-
if (_options.strict === true && Object.hasOwnProperty.call(object2, key)) {
|
|
2327
|
-
error('Duplicate key "' + key + '"');
|
|
2328
|
-
}
|
|
2329
|
-
if (suspectProtoRx.test(key) === true) {
|
|
2330
|
-
if (_options.protoAction === "error") {
|
|
2331
|
-
error("Object contains forbidden prototype property");
|
|
2332
|
-
} else if (_options.protoAction === "ignore") {
|
|
2333
|
-
value();
|
|
2334
|
-
} else {
|
|
2335
|
-
object2[key] = value();
|
|
2336
|
-
}
|
|
2337
|
-
} else if (suspectConstructorRx.test(key) === true) {
|
|
2338
|
-
if (_options.constructorAction === "error") {
|
|
2339
|
-
error("Object contains forbidden constructor property");
|
|
2340
|
-
} else if (_options.constructorAction === "ignore") {
|
|
2341
|
-
value();
|
|
2342
|
-
} else {
|
|
2343
|
-
object2[key] = value();
|
|
2344
|
-
}
|
|
2345
|
-
} else {
|
|
2346
|
-
object2[key] = value();
|
|
2347
|
-
}
|
|
2348
|
-
white();
|
|
2349
|
-
if (ch === "}") {
|
|
2350
|
-
next("}");
|
|
2351
|
-
return object2;
|
|
2352
|
-
}
|
|
2353
|
-
next(",");
|
|
2354
|
-
white();
|
|
543
|
+
// node_modules/ts-custom-error/dist/custom-error.js
|
|
544
|
+
var require_custom_error = __commonJS({
|
|
545
|
+
"node_modules/ts-custom-error/dist/custom-error.js"(exports) {
|
|
546
|
+
function fixProto(target, prototype) {
|
|
547
|
+
var setPrototypeOf = Object.setPrototypeOf;
|
|
548
|
+
setPrototypeOf ? setPrototypeOf(target, prototype) : target.__proto__ = prototype;
|
|
549
|
+
}
|
|
550
|
+
function fixStack(target, fn) {
|
|
551
|
+
if (fn === void 0) {
|
|
552
|
+
fn = target.constructor;
|
|
553
|
+
}
|
|
554
|
+
var captureStackTrace = Error.captureStackTrace;
|
|
555
|
+
captureStackTrace && captureStackTrace(target, fn);
|
|
556
|
+
}
|
|
557
|
+
var __extends = function() {
|
|
558
|
+
var _extendStatics = function extendStatics(d, b) {
|
|
559
|
+
_extendStatics = Object.setPrototypeOf || {
|
|
560
|
+
__proto__: []
|
|
561
|
+
} instanceof Array && function(d2, b2) {
|
|
562
|
+
d2.__proto__ = b2;
|
|
563
|
+
} || function(d2, b2) {
|
|
564
|
+
for (var p in b2) {
|
|
565
|
+
if (Object.prototype.hasOwnProperty.call(b2, p))
|
|
566
|
+
d2[p] = b2[p];
|
|
2355
567
|
}
|
|
2356
|
-
}
|
|
2357
|
-
|
|
568
|
+
};
|
|
569
|
+
return _extendStatics(d, b);
|
|
2358
570
|
};
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
return array();
|
|
2366
|
-
case '"':
|
|
2367
|
-
return string();
|
|
2368
|
-
case "-":
|
|
2369
|
-
return number3();
|
|
2370
|
-
default:
|
|
2371
|
-
return ch >= "0" && ch <= "9" ? number3() : word();
|
|
571
|
+
return function(d, b) {
|
|
572
|
+
if (typeof b !== "function" && b !== null)
|
|
573
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
574
|
+
_extendStatics(d, b);
|
|
575
|
+
function __() {
|
|
576
|
+
this.constructor = d;
|
|
2372
577
|
}
|
|
578
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
2373
579
|
};
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
580
|
+
}();
|
|
581
|
+
var CustomError2 = function(_super) {
|
|
582
|
+
__extends(CustomError3, _super);
|
|
583
|
+
function CustomError3(message, options) {
|
|
584
|
+
var _newTarget = this.constructor;
|
|
585
|
+
var _this = _super.call(this, message, options) || this;
|
|
586
|
+
Object.defineProperty(_this, "name", {
|
|
587
|
+
value: _newTarget.name,
|
|
588
|
+
enumerable: false,
|
|
589
|
+
configurable: true
|
|
590
|
+
});
|
|
591
|
+
fixProto(_this, _newTarget.prototype);
|
|
592
|
+
fixStack(_this);
|
|
593
|
+
return _this;
|
|
594
|
+
}
|
|
595
|
+
return CustomError3;
|
|
596
|
+
}(Error);
|
|
597
|
+
var __spreadArray = function(to, from, pack) {
|
|
598
|
+
if (pack || arguments.length === 2)
|
|
599
|
+
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
600
|
+
if (ar || !(i in from)) {
|
|
601
|
+
if (!ar)
|
|
602
|
+
ar = Array.prototype.slice.call(from, 0, i);
|
|
603
|
+
ar[i] = from[i];
|
|
2395
604
|
}
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
};
|
|
2399
|
-
};
|
|
2400
|
-
module.exports = json_parse;
|
|
2401
|
-
}
|
|
2402
|
-
});
|
|
2403
|
-
|
|
2404
|
-
// node_modules/json-bigint/index.js
|
|
2405
|
-
var require_json_bigint = __commonJS({
|
|
2406
|
-
"node_modules/json-bigint/index.js"(exports, module) {
|
|
2407
|
-
var json_stringify = require_stringify().stringify;
|
|
2408
|
-
var json_parse = require_parse();
|
|
2409
|
-
module.exports = function(options) {
|
|
2410
|
-
return {
|
|
2411
|
-
parse: json_parse(options),
|
|
2412
|
-
stringify: json_stringify
|
|
2413
|
-
};
|
|
605
|
+
}
|
|
606
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
2414
607
|
};
|
|
2415
|
-
|
|
2416
|
-
|
|
608
|
+
function customErrorFactory(fn, parent) {
|
|
609
|
+
if (parent === void 0) {
|
|
610
|
+
parent = Error;
|
|
611
|
+
}
|
|
612
|
+
function CustomError3() {
|
|
613
|
+
var args = [];
|
|
614
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
615
|
+
args[_i] = arguments[_i];
|
|
616
|
+
}
|
|
617
|
+
if (!(this instanceof CustomError3))
|
|
618
|
+
return new (CustomError3.bind.apply(CustomError3, __spreadArray([void 0], args, false)))();
|
|
619
|
+
parent.apply(this, args);
|
|
620
|
+
Object.defineProperty(this, "name", {
|
|
621
|
+
value: fn.name || parent.name,
|
|
622
|
+
enumerable: false,
|
|
623
|
+
configurable: true
|
|
624
|
+
});
|
|
625
|
+
fn.apply(this, args);
|
|
626
|
+
fixStack(this, CustomError3);
|
|
627
|
+
}
|
|
628
|
+
return Object.defineProperties(CustomError3, {
|
|
629
|
+
prototype: {
|
|
630
|
+
value: Object.create(parent.prototype, {
|
|
631
|
+
constructor: {
|
|
632
|
+
value: CustomError3,
|
|
633
|
+
writable: true,
|
|
634
|
+
configurable: true
|
|
635
|
+
}
|
|
636
|
+
})
|
|
637
|
+
}
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
exports.CustomError = CustomError2;
|
|
641
|
+
exports.customErrorFactory = customErrorFactory;
|
|
2417
642
|
}
|
|
2418
643
|
});
|
|
2419
644
|
|
|
@@ -2737,11 +962,8 @@ var starknet = (() => {
|
|
|
2737
962
|
};
|
|
2738
963
|
var u64_default = u64;
|
|
2739
964
|
|
|
2740
|
-
// node_modules/@noble/hashes/esm/
|
|
2741
|
-
var
|
|
2742
|
-
node: void 0,
|
|
2743
|
-
web: typeof self === "object" && "crypto" in self ? self.crypto : void 0
|
|
2744
|
-
};
|
|
965
|
+
// node_modules/@noble/hashes/esm/crypto.js
|
|
966
|
+
var crypto = typeof globalThis === "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
|
|
2745
967
|
|
|
2746
968
|
// node_modules/@noble/hashes/esm/utils.js
|
|
2747
969
|
var u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
@@ -2800,13 +1022,10 @@ var starknet = (() => {
|
|
|
2800
1022
|
return hashC;
|
|
2801
1023
|
}
|
|
2802
1024
|
function randomBytes(bytesLength = 32) {
|
|
2803
|
-
if (
|
|
2804
|
-
return
|
|
2805
|
-
} else if (crypto2.node) {
|
|
2806
|
-
return new Uint8Array(crypto2.node.randomBytes(bytesLength).buffer);
|
|
2807
|
-
} else {
|
|
2808
|
-
throw new Error("The environment doesn't have randomBytes function");
|
|
1025
|
+
if (crypto && typeof crypto.getRandomValues === "function") {
|
|
1026
|
+
return crypto.getRandomValues(new Uint8Array(bytesLength));
|
|
2809
1027
|
}
|
|
1028
|
+
throw new Error("crypto.getRandomValues must be defined");
|
|
2810
1029
|
}
|
|
2811
1030
|
|
|
2812
1031
|
// node_modules/@noble/hashes/esm/sha3.js
|
|
@@ -7401,24 +5620,669 @@ var starknet = (() => {
|
|
|
7401
5620
|
// src/utils/json.ts
|
|
7402
5621
|
var json_exports = {};
|
|
7403
5622
|
__export(json_exports, {
|
|
7404
|
-
|
|
7405
|
-
parse: () => parse,
|
|
5623
|
+
parse: () => parse2,
|
|
7406
5624
|
parseAlwaysAsBig: () => parseAlwaysAsBig,
|
|
7407
|
-
stringify: () =>
|
|
5625
|
+
stringify: () => stringify2,
|
|
7408
5626
|
stringifyAlwaysAsBig: () => stringifyAlwaysAsBig
|
|
7409
5627
|
});
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
5628
|
+
|
|
5629
|
+
// node_modules/lossless-json/lib/esm/utils.js
|
|
5630
|
+
function isInteger(value) {
|
|
5631
|
+
return INTEGER_REGEX.test(value);
|
|
5632
|
+
}
|
|
5633
|
+
var INTEGER_REGEX = /^-?[0-9]+$/;
|
|
5634
|
+
function isNumber(value) {
|
|
5635
|
+
return NUMBER_REGEX.test(value);
|
|
5636
|
+
}
|
|
5637
|
+
var NUMBER_REGEX = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
|
|
5638
|
+
function isSafeNumber(value, config) {
|
|
5639
|
+
var num = parseFloat(value);
|
|
5640
|
+
var str = String(num);
|
|
5641
|
+
var v = extractSignificantDigits(value);
|
|
5642
|
+
var s = extractSignificantDigits(str);
|
|
5643
|
+
if (v === s) {
|
|
5644
|
+
return true;
|
|
5645
|
+
}
|
|
5646
|
+
if ((config === null || config === void 0 ? void 0 : config.approx) === true) {
|
|
5647
|
+
var requiredDigits = 14;
|
|
5648
|
+
if (!isInteger(value) && s.length >= requiredDigits && v.startsWith(s.substring(0, requiredDigits))) {
|
|
5649
|
+
return true;
|
|
5650
|
+
}
|
|
5651
|
+
}
|
|
5652
|
+
return false;
|
|
5653
|
+
}
|
|
5654
|
+
var UnsafeNumberReason;
|
|
5655
|
+
(function(UnsafeNumberReason2) {
|
|
5656
|
+
UnsafeNumberReason2["underflow"] = "underflow";
|
|
5657
|
+
UnsafeNumberReason2["overflow"] = "overflow";
|
|
5658
|
+
UnsafeNumberReason2["truncate_integer"] = "truncate_integer";
|
|
5659
|
+
UnsafeNumberReason2["truncate_float"] = "truncate_float";
|
|
5660
|
+
})(UnsafeNumberReason || (UnsafeNumberReason = {}));
|
|
5661
|
+
function getUnsafeNumberReason(value) {
|
|
5662
|
+
if (isSafeNumber(value, {
|
|
5663
|
+
approx: false
|
|
5664
|
+
})) {
|
|
5665
|
+
return void 0;
|
|
5666
|
+
}
|
|
5667
|
+
if (isInteger(value)) {
|
|
5668
|
+
return UnsafeNumberReason.truncate_integer;
|
|
5669
|
+
}
|
|
5670
|
+
var num = parseFloat(value);
|
|
5671
|
+
if (!isFinite(num)) {
|
|
5672
|
+
return UnsafeNumberReason.overflow;
|
|
5673
|
+
}
|
|
5674
|
+
if (num === 0) {
|
|
5675
|
+
return UnsafeNumberReason.underflow;
|
|
5676
|
+
}
|
|
5677
|
+
return UnsafeNumberReason.truncate_float;
|
|
5678
|
+
}
|
|
5679
|
+
function extractSignificantDigits(value) {
|
|
5680
|
+
return value.replace(EXPONENTIAL_PART_REGEX, "").replace(DOT_REGEX, "").replace(TRAILING_ZEROS_REGEX, "").replace(LEADING_MINUS_AND_ZEROS_REGEX, "");
|
|
5681
|
+
}
|
|
5682
|
+
var EXPONENTIAL_PART_REGEX = /[eE][+-]?\d+$/;
|
|
5683
|
+
var LEADING_MINUS_AND_ZEROS_REGEX = /^-?(0*)?/;
|
|
5684
|
+
var DOT_REGEX = /\./;
|
|
5685
|
+
var TRAILING_ZEROS_REGEX = /0+$/;
|
|
5686
|
+
|
|
5687
|
+
// node_modules/lossless-json/lib/esm/LosslessNumber.js
|
|
5688
|
+
function _typeof(obj) {
|
|
5689
|
+
"@babel/helpers - typeof";
|
|
5690
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
|
|
5691
|
+
return typeof obj2;
|
|
5692
|
+
} : function(obj2) {
|
|
5693
|
+
return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
5694
|
+
}, _typeof(obj);
|
|
5695
|
+
}
|
|
5696
|
+
function _classCallCheck(instance, Constructor) {
|
|
5697
|
+
if (!(instance instanceof Constructor)) {
|
|
5698
|
+
throw new TypeError("Cannot call a class as a function");
|
|
5699
|
+
}
|
|
5700
|
+
}
|
|
5701
|
+
function _defineProperties(target, props) {
|
|
5702
|
+
for (var i = 0; i < props.length; i++) {
|
|
5703
|
+
var descriptor = props[i];
|
|
5704
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
5705
|
+
descriptor.configurable = true;
|
|
5706
|
+
if ("value" in descriptor)
|
|
5707
|
+
descriptor.writable = true;
|
|
5708
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
5709
|
+
}
|
|
5710
|
+
}
|
|
5711
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
5712
|
+
if (protoProps)
|
|
5713
|
+
_defineProperties(Constructor.prototype, protoProps);
|
|
5714
|
+
if (staticProps)
|
|
5715
|
+
_defineProperties(Constructor, staticProps);
|
|
5716
|
+
Object.defineProperty(Constructor, "prototype", { writable: false });
|
|
5717
|
+
return Constructor;
|
|
5718
|
+
}
|
|
5719
|
+
function _defineProperty(obj, key, value) {
|
|
5720
|
+
key = _toPropertyKey(key);
|
|
5721
|
+
if (key in obj) {
|
|
5722
|
+
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
5723
|
+
} else {
|
|
5724
|
+
obj[key] = value;
|
|
5725
|
+
}
|
|
5726
|
+
return obj;
|
|
5727
|
+
}
|
|
5728
|
+
function _toPropertyKey(arg) {
|
|
5729
|
+
var key = _toPrimitive(arg, "string");
|
|
5730
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
5731
|
+
}
|
|
5732
|
+
function _toPrimitive(input, hint) {
|
|
5733
|
+
if (_typeof(input) !== "object" || input === null)
|
|
5734
|
+
return input;
|
|
5735
|
+
var prim = input[Symbol.toPrimitive];
|
|
5736
|
+
if (prim !== void 0) {
|
|
5737
|
+
var res = prim.call(input, hint || "default");
|
|
5738
|
+
if (_typeof(res) !== "object")
|
|
5739
|
+
return res;
|
|
5740
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
5741
|
+
}
|
|
5742
|
+
return (hint === "string" ? String : Number)(input);
|
|
5743
|
+
}
|
|
5744
|
+
var LosslessNumber = /* @__PURE__ */ function() {
|
|
5745
|
+
function LosslessNumber2(value) {
|
|
5746
|
+
_classCallCheck(this, LosslessNumber2);
|
|
5747
|
+
_defineProperty(this, "isLosslessNumber", true);
|
|
5748
|
+
if (!isNumber(value)) {
|
|
5749
|
+
throw new Error('Invalid number (value: "' + value + '")');
|
|
5750
|
+
}
|
|
5751
|
+
this.value = value;
|
|
5752
|
+
}
|
|
5753
|
+
_createClass(LosslessNumber2, [{
|
|
5754
|
+
key: "valueOf",
|
|
5755
|
+
value: function valueOf() {
|
|
5756
|
+
var unsafeReason = getUnsafeNumberReason(this.value);
|
|
5757
|
+
if (unsafeReason === void 0 || unsafeReason === UnsafeNumberReason.truncate_float) {
|
|
5758
|
+
return parseFloat(this.value);
|
|
5759
|
+
}
|
|
5760
|
+
if (isInteger(this.value)) {
|
|
5761
|
+
return BigInt(this.value);
|
|
5762
|
+
}
|
|
5763
|
+
throw new Error("Cannot safely convert to number: " + "the value '".concat(this.value, "' would ").concat(unsafeReason, " and become ").concat(parseFloat(this.value)));
|
|
5764
|
+
}
|
|
5765
|
+
}, {
|
|
5766
|
+
key: "toString",
|
|
5767
|
+
value: function toString2() {
|
|
5768
|
+
return this.value;
|
|
5769
|
+
}
|
|
5770
|
+
}]);
|
|
5771
|
+
return LosslessNumber2;
|
|
5772
|
+
}();
|
|
5773
|
+
function isLosslessNumber(value) {
|
|
5774
|
+
return value && _typeof(value) === "object" && value.isLosslessNumber === true || false;
|
|
5775
|
+
}
|
|
5776
|
+
|
|
5777
|
+
// node_modules/lossless-json/lib/esm/numberParsers.js
|
|
5778
|
+
function parseLosslessNumber(value) {
|
|
5779
|
+
return new LosslessNumber(value);
|
|
5780
|
+
}
|
|
5781
|
+
function parseNumberAndBigInt(value) {
|
|
5782
|
+
return isInteger(value) ? BigInt(value) : parseFloat(value);
|
|
5783
|
+
}
|
|
5784
|
+
|
|
5785
|
+
// node_modules/lossless-json/lib/esm/revive.js
|
|
5786
|
+
function _typeof2(obj) {
|
|
5787
|
+
"@babel/helpers - typeof";
|
|
5788
|
+
return _typeof2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
|
|
5789
|
+
return typeof obj2;
|
|
5790
|
+
} : function(obj2) {
|
|
5791
|
+
return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
5792
|
+
}, _typeof2(obj);
|
|
5793
|
+
}
|
|
5794
|
+
function revive(json, reviver) {
|
|
5795
|
+
return reviveValue({
|
|
5796
|
+
"": json
|
|
5797
|
+
}, "", json, reviver);
|
|
5798
|
+
}
|
|
5799
|
+
function reviveValue(context, key, value, reviver) {
|
|
5800
|
+
if (Array.isArray(value)) {
|
|
5801
|
+
return reviver.call(context, key, reviveArray(value, reviver));
|
|
5802
|
+
} else if (value && _typeof2(value) === "object" && !isLosslessNumber(value)) {
|
|
5803
|
+
return reviver.call(context, key, reviveObject(value, reviver));
|
|
5804
|
+
} else {
|
|
5805
|
+
return reviver.call(context, key, value);
|
|
5806
|
+
}
|
|
5807
|
+
}
|
|
5808
|
+
function reviveObject(object, reviver) {
|
|
5809
|
+
Object.keys(object).forEach(function(key) {
|
|
5810
|
+
var value = reviveValue(object, key, object[key], reviver);
|
|
5811
|
+
if (value !== void 0) {
|
|
5812
|
+
object[key] = value;
|
|
5813
|
+
} else {
|
|
5814
|
+
delete object[key];
|
|
5815
|
+
}
|
|
7417
5816
|
});
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
5817
|
+
return object;
|
|
5818
|
+
}
|
|
5819
|
+
function reviveArray(array, reviver) {
|
|
5820
|
+
for (var i = 0; i < array.length; i++) {
|
|
5821
|
+
array[i] = reviveValue(array, i + "", array[i], reviver);
|
|
5822
|
+
}
|
|
5823
|
+
return array;
|
|
5824
|
+
}
|
|
5825
|
+
|
|
5826
|
+
// node_modules/lossless-json/lib/esm/parse.js
|
|
5827
|
+
function _typeof3(obj) {
|
|
5828
|
+
"@babel/helpers - typeof";
|
|
5829
|
+
return _typeof3 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
|
|
5830
|
+
return typeof obj2;
|
|
5831
|
+
} : function(obj2) {
|
|
5832
|
+
return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
5833
|
+
}, _typeof3(obj);
|
|
5834
|
+
}
|
|
5835
|
+
function _toConsumableArray(arr) {
|
|
5836
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
5837
|
+
}
|
|
5838
|
+
function _nonIterableSpread() {
|
|
5839
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
5840
|
+
}
|
|
5841
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
5842
|
+
if (!o)
|
|
5843
|
+
return;
|
|
5844
|
+
if (typeof o === "string")
|
|
5845
|
+
return _arrayLikeToArray(o, minLen);
|
|
5846
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
5847
|
+
if (n === "Object" && o.constructor)
|
|
5848
|
+
n = o.constructor.name;
|
|
5849
|
+
if (n === "Map" || n === "Set")
|
|
5850
|
+
return Array.from(o);
|
|
5851
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
5852
|
+
return _arrayLikeToArray(o, minLen);
|
|
5853
|
+
}
|
|
5854
|
+
function _iterableToArray(iter) {
|
|
5855
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
|
|
5856
|
+
return Array.from(iter);
|
|
5857
|
+
}
|
|
5858
|
+
function _arrayWithoutHoles(arr) {
|
|
5859
|
+
if (Array.isArray(arr))
|
|
5860
|
+
return _arrayLikeToArray(arr);
|
|
5861
|
+
}
|
|
5862
|
+
function _arrayLikeToArray(arr, len) {
|
|
5863
|
+
if (len == null || len > arr.length)
|
|
5864
|
+
len = arr.length;
|
|
5865
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
5866
|
+
arr2[i] = arr[i];
|
|
5867
|
+
}
|
|
5868
|
+
return arr2;
|
|
5869
|
+
}
|
|
5870
|
+
function parse(text, reviver) {
|
|
5871
|
+
var parseNumber = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : parseLosslessNumber;
|
|
5872
|
+
var i = 0;
|
|
5873
|
+
var value = parseValue();
|
|
5874
|
+
expectValue(value);
|
|
5875
|
+
expectEndOfInput();
|
|
5876
|
+
return reviver ? revive(value, reviver) : value;
|
|
5877
|
+
function parseObject() {
|
|
5878
|
+
if (text.charCodeAt(i) === codeOpeningBrace) {
|
|
5879
|
+
i++;
|
|
5880
|
+
skipWhitespace();
|
|
5881
|
+
var object = {};
|
|
5882
|
+
var initial = true;
|
|
5883
|
+
while (i < text.length && text.charCodeAt(i) !== codeClosingBrace) {
|
|
5884
|
+
if (!initial) {
|
|
5885
|
+
eatComma();
|
|
5886
|
+
skipWhitespace();
|
|
5887
|
+
} else {
|
|
5888
|
+
initial = false;
|
|
5889
|
+
}
|
|
5890
|
+
var start = i;
|
|
5891
|
+
var key = parseString();
|
|
5892
|
+
if (key === void 0) {
|
|
5893
|
+
throwObjectKeyExpected();
|
|
5894
|
+
}
|
|
5895
|
+
skipWhitespace();
|
|
5896
|
+
eatColon();
|
|
5897
|
+
var _value = parseValue();
|
|
5898
|
+
if (Object.prototype.hasOwnProperty.call(object, key) && !isDeepEqual(_value, object[key])) {
|
|
5899
|
+
throwDuplicateKey(key, start + 1);
|
|
5900
|
+
}
|
|
5901
|
+
object[key] = _value;
|
|
5902
|
+
}
|
|
5903
|
+
if (text.charCodeAt(i) !== codeClosingBrace) {
|
|
5904
|
+
throwObjectKeyOrEndExpected();
|
|
5905
|
+
}
|
|
5906
|
+
i++;
|
|
5907
|
+
return object;
|
|
5908
|
+
}
|
|
5909
|
+
}
|
|
5910
|
+
function parseArray() {
|
|
5911
|
+
if (text.charCodeAt(i) === codeOpeningBracket) {
|
|
5912
|
+
i++;
|
|
5913
|
+
skipWhitespace();
|
|
5914
|
+
var array = [];
|
|
5915
|
+
var initial = true;
|
|
5916
|
+
while (i < text.length && text.charCodeAt(i) !== codeClosingBracket) {
|
|
5917
|
+
if (!initial) {
|
|
5918
|
+
eatComma();
|
|
5919
|
+
} else {
|
|
5920
|
+
initial = false;
|
|
5921
|
+
}
|
|
5922
|
+
var _value2 = parseValue();
|
|
5923
|
+
expectArrayItem(_value2);
|
|
5924
|
+
array.push(_value2);
|
|
5925
|
+
}
|
|
5926
|
+
if (text.charCodeAt(i) !== codeClosingBracket) {
|
|
5927
|
+
throwArrayItemOrEndExpected();
|
|
5928
|
+
}
|
|
5929
|
+
i++;
|
|
5930
|
+
return array;
|
|
5931
|
+
}
|
|
5932
|
+
}
|
|
5933
|
+
function parseValue() {
|
|
5934
|
+
var _ref, _ref2, _ref3, _ref4, _ref5, _parseString;
|
|
5935
|
+
skipWhitespace();
|
|
5936
|
+
var value2 = (_ref = (_ref2 = (_ref3 = (_ref4 = (_ref5 = (_parseString = parseString()) !== null && _parseString !== void 0 ? _parseString : parseNumeric()) !== null && _ref5 !== void 0 ? _ref5 : parseObject()) !== null && _ref4 !== void 0 ? _ref4 : parseArray()) !== null && _ref3 !== void 0 ? _ref3 : parseKeyword("true", true)) !== null && _ref2 !== void 0 ? _ref2 : parseKeyword("false", false)) !== null && _ref !== void 0 ? _ref : parseKeyword("null", null);
|
|
5937
|
+
skipWhitespace();
|
|
5938
|
+
return value2;
|
|
5939
|
+
}
|
|
5940
|
+
function parseKeyword(name, value2) {
|
|
5941
|
+
if (text.slice(i, i + name.length) === name) {
|
|
5942
|
+
i += name.length;
|
|
5943
|
+
return value2;
|
|
5944
|
+
}
|
|
5945
|
+
}
|
|
5946
|
+
function skipWhitespace() {
|
|
5947
|
+
while (isWhitespace(text.charCodeAt(i))) {
|
|
5948
|
+
i++;
|
|
5949
|
+
}
|
|
5950
|
+
}
|
|
5951
|
+
function parseString() {
|
|
5952
|
+
if (text.charCodeAt(i) === codeDoubleQuote) {
|
|
5953
|
+
i++;
|
|
5954
|
+
var result = "";
|
|
5955
|
+
while (i < text.length && text.charCodeAt(i) !== codeDoubleQuote) {
|
|
5956
|
+
if (text.charCodeAt(i) === codeBackslash) {
|
|
5957
|
+
var char = text[i + 1];
|
|
5958
|
+
var escapeChar = escapeCharacters[char];
|
|
5959
|
+
if (escapeChar !== void 0) {
|
|
5960
|
+
result += escapeChar;
|
|
5961
|
+
i++;
|
|
5962
|
+
} else if (char === "u") {
|
|
5963
|
+
if (isHex2(text.charCodeAt(i + 2)) && isHex2(text.charCodeAt(i + 3)) && isHex2(text.charCodeAt(i + 4)) && isHex2(text.charCodeAt(i + 5))) {
|
|
5964
|
+
result += String.fromCharCode(parseInt(text.slice(i + 2, i + 6), 16));
|
|
5965
|
+
i += 5;
|
|
5966
|
+
} else {
|
|
5967
|
+
throwInvalidUnicodeCharacter(i);
|
|
5968
|
+
}
|
|
5969
|
+
} else {
|
|
5970
|
+
throwInvalidEscapeCharacter(i);
|
|
5971
|
+
}
|
|
5972
|
+
} else {
|
|
5973
|
+
if (isValidStringCharacter(text.charCodeAt(i))) {
|
|
5974
|
+
result += text[i];
|
|
5975
|
+
} else {
|
|
5976
|
+
throwInvalidCharacter(text[i]);
|
|
5977
|
+
}
|
|
5978
|
+
}
|
|
5979
|
+
i++;
|
|
5980
|
+
}
|
|
5981
|
+
expectEndOfString();
|
|
5982
|
+
i++;
|
|
5983
|
+
return result;
|
|
5984
|
+
}
|
|
5985
|
+
}
|
|
5986
|
+
function parseNumeric() {
|
|
5987
|
+
var start = i;
|
|
5988
|
+
if (text.charCodeAt(i) === codeMinus) {
|
|
5989
|
+
i++;
|
|
5990
|
+
expectDigit(start);
|
|
5991
|
+
}
|
|
5992
|
+
if (text.charCodeAt(i) === codeZero) {
|
|
5993
|
+
i++;
|
|
5994
|
+
} else if (isNonZeroDigit(text.charCodeAt(i))) {
|
|
5995
|
+
i++;
|
|
5996
|
+
while (isDigit(text.charCodeAt(i))) {
|
|
5997
|
+
i++;
|
|
5998
|
+
}
|
|
5999
|
+
}
|
|
6000
|
+
if (text.charCodeAt(i) === codeDot) {
|
|
6001
|
+
i++;
|
|
6002
|
+
expectDigit(start);
|
|
6003
|
+
while (isDigit(text.charCodeAt(i))) {
|
|
6004
|
+
i++;
|
|
6005
|
+
}
|
|
6006
|
+
}
|
|
6007
|
+
if (text.charCodeAt(i) === codeLowercaseE || text.charCodeAt(i) === codeUppercaseE) {
|
|
6008
|
+
i++;
|
|
6009
|
+
if (text.charCodeAt(i) === codeMinus || text.charCodeAt(i) === codePlus) {
|
|
6010
|
+
i++;
|
|
6011
|
+
}
|
|
6012
|
+
expectDigit(start);
|
|
6013
|
+
while (isDigit(text.charCodeAt(i))) {
|
|
6014
|
+
i++;
|
|
6015
|
+
}
|
|
6016
|
+
}
|
|
6017
|
+
if (i > start) {
|
|
6018
|
+
return parseNumber(text.slice(start, i));
|
|
6019
|
+
}
|
|
6020
|
+
}
|
|
6021
|
+
function eatComma() {
|
|
6022
|
+
if (text.charCodeAt(i) !== codeComma) {
|
|
6023
|
+
throw new SyntaxError("Comma ',' expected after value ".concat(gotAt()));
|
|
6024
|
+
}
|
|
6025
|
+
i++;
|
|
6026
|
+
}
|
|
6027
|
+
function eatColon() {
|
|
6028
|
+
if (text.charCodeAt(i) !== codeColon) {
|
|
6029
|
+
throw new SyntaxError("Colon ':' expected after property name ".concat(gotAt()));
|
|
6030
|
+
}
|
|
6031
|
+
i++;
|
|
6032
|
+
}
|
|
6033
|
+
function expectValue(value2) {
|
|
6034
|
+
if (value2 === void 0) {
|
|
6035
|
+
throw new SyntaxError("JSON value expected ".concat(gotAt()));
|
|
6036
|
+
}
|
|
6037
|
+
}
|
|
6038
|
+
function expectArrayItem(value2) {
|
|
6039
|
+
if (value2 === void 0) {
|
|
6040
|
+
throw new SyntaxError("Array item expected ".concat(gotAt()));
|
|
6041
|
+
}
|
|
6042
|
+
}
|
|
6043
|
+
function expectEndOfInput() {
|
|
6044
|
+
if (i < text.length) {
|
|
6045
|
+
throw new SyntaxError("Expected end of input ".concat(gotAt()));
|
|
6046
|
+
}
|
|
6047
|
+
}
|
|
6048
|
+
function expectDigit(start) {
|
|
6049
|
+
if (!isDigit(text.charCodeAt(i))) {
|
|
6050
|
+
var numSoFar = text.slice(start, i);
|
|
6051
|
+
throw new SyntaxError("Invalid number '".concat(numSoFar, "', expecting a digit ").concat(gotAt()));
|
|
6052
|
+
}
|
|
6053
|
+
}
|
|
6054
|
+
function expectEndOfString() {
|
|
6055
|
+
if (text.charCodeAt(i) !== codeDoubleQuote) {
|
|
6056
|
+
throw new SyntaxError(`End of string '"' expected `.concat(gotAt()));
|
|
6057
|
+
}
|
|
6058
|
+
}
|
|
6059
|
+
function throwObjectKeyExpected() {
|
|
6060
|
+
throw new SyntaxError("Quoted object key expected ".concat(gotAt()));
|
|
6061
|
+
}
|
|
6062
|
+
function throwDuplicateKey(key, pos2) {
|
|
6063
|
+
throw new SyntaxError("Duplicate key '".concat(key, "' encountered at position ").concat(pos2));
|
|
6064
|
+
}
|
|
6065
|
+
function throwObjectKeyOrEndExpected() {
|
|
6066
|
+
throw new SyntaxError("Quoted object key or end of object '}' expected ".concat(gotAt()));
|
|
6067
|
+
}
|
|
6068
|
+
function throwArrayItemOrEndExpected() {
|
|
6069
|
+
throw new SyntaxError("Array item or end of array ']' expected ".concat(gotAt()));
|
|
6070
|
+
}
|
|
6071
|
+
function throwInvalidCharacter(char) {
|
|
6072
|
+
throw new SyntaxError("Invalid character '".concat(char, "' ").concat(pos()));
|
|
6073
|
+
}
|
|
6074
|
+
function throwInvalidEscapeCharacter(start) {
|
|
6075
|
+
var chars = text.slice(start, start + 2);
|
|
6076
|
+
throw new SyntaxError("Invalid escape character '".concat(chars, "' ").concat(pos()));
|
|
6077
|
+
}
|
|
6078
|
+
function throwInvalidUnicodeCharacter(start) {
|
|
6079
|
+
var end = start + 2;
|
|
6080
|
+
while (/\w/.test(text[end])) {
|
|
6081
|
+
end++;
|
|
6082
|
+
}
|
|
6083
|
+
var chars = text.slice(start, end);
|
|
6084
|
+
throw new SyntaxError("Invalid unicode character '".concat(chars, "' ").concat(pos()));
|
|
6085
|
+
}
|
|
6086
|
+
function pos() {
|
|
6087
|
+
return "at position ".concat(i);
|
|
6088
|
+
}
|
|
6089
|
+
function got() {
|
|
6090
|
+
return i < text.length ? "but got '".concat(text[i], "'") : "but reached end of input";
|
|
6091
|
+
}
|
|
6092
|
+
function gotAt() {
|
|
6093
|
+
return got() + " " + pos();
|
|
6094
|
+
}
|
|
6095
|
+
}
|
|
6096
|
+
function isWhitespace(code) {
|
|
6097
|
+
return code === codeSpace || code === codeNewline || code === codeTab || code === codeReturn;
|
|
6098
|
+
}
|
|
6099
|
+
function isHex2(code) {
|
|
6100
|
+
return code >= codeZero && code <= codeNine || code >= codeUppercaseA && code <= codeUppercaseF || code >= codeLowercaseA && code <= codeLowercaseF;
|
|
6101
|
+
}
|
|
6102
|
+
function isDigit(code) {
|
|
6103
|
+
return code >= codeZero && code <= codeNine;
|
|
6104
|
+
}
|
|
6105
|
+
function isNonZeroDigit(code) {
|
|
6106
|
+
return code >= codeOne && code <= codeNine;
|
|
6107
|
+
}
|
|
6108
|
+
function isValidStringCharacter(code) {
|
|
6109
|
+
return code >= 32 && code <= 1114111;
|
|
6110
|
+
}
|
|
6111
|
+
function isDeepEqual(a, b) {
|
|
6112
|
+
if (a === b) {
|
|
6113
|
+
return true;
|
|
6114
|
+
}
|
|
6115
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
6116
|
+
return a.length === b.length && a.every(function(item, index) {
|
|
6117
|
+
return isDeepEqual(item, b[index]);
|
|
6118
|
+
});
|
|
6119
|
+
}
|
|
6120
|
+
if (isObject(a) && isObject(b)) {
|
|
6121
|
+
var keys = _toConsumableArray(new Set([].concat(_toConsumableArray(Object.keys(a)), _toConsumableArray(Object.keys(b)))));
|
|
6122
|
+
return keys.every(function(key) {
|
|
6123
|
+
return isDeepEqual(a[key], b[key]);
|
|
6124
|
+
});
|
|
6125
|
+
}
|
|
6126
|
+
return false;
|
|
6127
|
+
}
|
|
6128
|
+
function isObject(value) {
|
|
6129
|
+
return _typeof3(value) === "object" && value !== null;
|
|
6130
|
+
}
|
|
6131
|
+
var escapeCharacters = {
|
|
6132
|
+
'"': '"',
|
|
6133
|
+
"\\": "\\",
|
|
6134
|
+
"/": "/",
|
|
6135
|
+
b: "\b",
|
|
6136
|
+
f: "\f",
|
|
6137
|
+
n: "\n",
|
|
6138
|
+
r: "\r",
|
|
6139
|
+
t: " "
|
|
6140
|
+
};
|
|
6141
|
+
var codeBackslash = 92;
|
|
6142
|
+
var codeOpeningBrace = 123;
|
|
6143
|
+
var codeClosingBrace = 125;
|
|
6144
|
+
var codeOpeningBracket = 91;
|
|
6145
|
+
var codeClosingBracket = 93;
|
|
6146
|
+
var codeSpace = 32;
|
|
6147
|
+
var codeNewline = 10;
|
|
6148
|
+
var codeTab = 9;
|
|
6149
|
+
var codeReturn = 13;
|
|
6150
|
+
var codeDoubleQuote = 34;
|
|
6151
|
+
var codePlus = 43;
|
|
6152
|
+
var codeMinus = 45;
|
|
6153
|
+
var codeZero = 48;
|
|
6154
|
+
var codeOne = 49;
|
|
6155
|
+
var codeNine = 57;
|
|
6156
|
+
var codeComma = 44;
|
|
6157
|
+
var codeDot = 46;
|
|
6158
|
+
var codeColon = 58;
|
|
6159
|
+
var codeUppercaseA = 65;
|
|
6160
|
+
var codeLowercaseA = 97;
|
|
6161
|
+
var codeUppercaseE = 69;
|
|
6162
|
+
var codeLowercaseE = 101;
|
|
6163
|
+
var codeUppercaseF = 70;
|
|
6164
|
+
var codeLowercaseF = 102;
|
|
6165
|
+
|
|
6166
|
+
// node_modules/lossless-json/lib/esm/stringify.js
|
|
6167
|
+
function _typeof4(obj) {
|
|
6168
|
+
"@babel/helpers - typeof";
|
|
6169
|
+
return _typeof4 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
|
|
6170
|
+
return typeof obj2;
|
|
6171
|
+
} : function(obj2) {
|
|
6172
|
+
return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
6173
|
+
}, _typeof4(obj);
|
|
6174
|
+
}
|
|
6175
|
+
function stringify(value, replacer, space, numberStringifiers) {
|
|
6176
|
+
var resolvedSpace = resolveSpace(space);
|
|
6177
|
+
var replacedValue = typeof replacer === "function" ? replacer.call({
|
|
6178
|
+
"": value
|
|
6179
|
+
}, "", value) : value;
|
|
6180
|
+
return stringifyValue(replacedValue, "");
|
|
6181
|
+
function stringifyValue(value2, indent) {
|
|
6182
|
+
if (Array.isArray(numberStringifiers)) {
|
|
6183
|
+
var stringifier = numberStringifiers.find(function(item) {
|
|
6184
|
+
return item.test(value2);
|
|
6185
|
+
});
|
|
6186
|
+
if (stringifier) {
|
|
6187
|
+
var str = stringifier.stringify(value2);
|
|
6188
|
+
if (typeof str !== "string" || !isNumber(str)) {
|
|
6189
|
+
throw new Error("Invalid JSON number: output of a number stringifier must be a string containing a JSON number " + "(output: ".concat(str, ")"));
|
|
6190
|
+
}
|
|
6191
|
+
return str;
|
|
6192
|
+
}
|
|
6193
|
+
}
|
|
6194
|
+
if (typeof value2 === "boolean" || typeof value2 === "number" || typeof value2 === "string" || value2 === null || value2 instanceof Date || value2 instanceof Boolean || value2 instanceof Number || value2 instanceof String) {
|
|
6195
|
+
return JSON.stringify(value2);
|
|
6196
|
+
}
|
|
6197
|
+
if (value2 && value2.isLosslessNumber) {
|
|
6198
|
+
return value2.toString();
|
|
6199
|
+
}
|
|
6200
|
+
if (typeof value2 === "bigint") {
|
|
6201
|
+
return value2.toString();
|
|
6202
|
+
}
|
|
6203
|
+
if (Array.isArray(value2)) {
|
|
6204
|
+
return stringifyArray(value2, indent);
|
|
6205
|
+
}
|
|
6206
|
+
if (value2 && _typeof4(value2) === "object") {
|
|
6207
|
+
return stringifyObject(value2, indent);
|
|
6208
|
+
}
|
|
6209
|
+
return void 0;
|
|
6210
|
+
}
|
|
6211
|
+
function stringifyArray(array, indent) {
|
|
6212
|
+
if (array.length === 0) {
|
|
6213
|
+
return "[]";
|
|
6214
|
+
}
|
|
6215
|
+
var childIndent = resolvedSpace ? indent + resolvedSpace : void 0;
|
|
6216
|
+
var str = resolvedSpace ? "[\n" : "[";
|
|
6217
|
+
for (var i = 0; i < array.length; i++) {
|
|
6218
|
+
var item = typeof replacer === "function" ? replacer.call(array, String(i), array[i]) : array[i];
|
|
6219
|
+
if (resolvedSpace) {
|
|
6220
|
+
str += childIndent;
|
|
6221
|
+
}
|
|
6222
|
+
if (typeof item !== "undefined" && typeof item !== "function") {
|
|
6223
|
+
str += stringifyValue(item, childIndent);
|
|
6224
|
+
} else {
|
|
6225
|
+
str += "null";
|
|
6226
|
+
}
|
|
6227
|
+
if (i < array.length - 1) {
|
|
6228
|
+
str += resolvedSpace ? ",\n" : ",";
|
|
6229
|
+
}
|
|
6230
|
+
}
|
|
6231
|
+
str += resolvedSpace ? "\n" + indent + "]" : "]";
|
|
6232
|
+
return str;
|
|
6233
|
+
}
|
|
6234
|
+
function stringifyObject(object, indent) {
|
|
6235
|
+
if (typeof object.toJSON === "function") {
|
|
6236
|
+
return stringify(object.toJSON(), replacer, space, void 0);
|
|
6237
|
+
}
|
|
6238
|
+
var keys = Array.isArray(replacer) ? replacer.map(String) : Object.keys(object);
|
|
6239
|
+
if (keys.length === 0) {
|
|
6240
|
+
return "{}";
|
|
6241
|
+
}
|
|
6242
|
+
var childIndent = resolvedSpace ? indent + resolvedSpace : void 0;
|
|
6243
|
+
var first = true;
|
|
6244
|
+
var str = resolvedSpace ? "{\n" : "{";
|
|
6245
|
+
keys.forEach(function(key) {
|
|
6246
|
+
var value2 = typeof replacer === "function" ? replacer.call(object, key, object[key]) : object[key];
|
|
6247
|
+
if (includeProperty(key, value2)) {
|
|
6248
|
+
if (first) {
|
|
6249
|
+
first = false;
|
|
6250
|
+
} else {
|
|
6251
|
+
str += resolvedSpace ? ",\n" : ",";
|
|
6252
|
+
}
|
|
6253
|
+
var keyStr = JSON.stringify(key);
|
|
6254
|
+
str += resolvedSpace ? childIndent + keyStr + ": " : keyStr + ":";
|
|
6255
|
+
str += stringifyValue(value2, childIndent);
|
|
6256
|
+
}
|
|
6257
|
+
});
|
|
6258
|
+
str += resolvedSpace ? "\n" + indent + "}" : "}";
|
|
6259
|
+
return str;
|
|
6260
|
+
}
|
|
6261
|
+
function includeProperty(key, value2) {
|
|
6262
|
+
return typeof value2 !== "undefined" && typeof value2 !== "function" && _typeof4(value2) !== "symbol";
|
|
6263
|
+
}
|
|
6264
|
+
}
|
|
6265
|
+
function resolveSpace(space) {
|
|
6266
|
+
if (typeof space === "number") {
|
|
6267
|
+
return " ".repeat(space);
|
|
6268
|
+
}
|
|
6269
|
+
if (typeof space === "string" && space !== "") {
|
|
6270
|
+
return space;
|
|
6271
|
+
}
|
|
6272
|
+
return void 0;
|
|
6273
|
+
}
|
|
6274
|
+
|
|
6275
|
+
// src/utils/json.ts
|
|
6276
|
+
var parseIntAsNumberOrBigInt = (x) => {
|
|
6277
|
+
if (!isInteger(x))
|
|
6278
|
+
return parseFloat(x);
|
|
6279
|
+
const v = parseInt(x, 10);
|
|
6280
|
+
return Number.isSafeInteger(v) ? v : BigInt(x);
|
|
6281
|
+
};
|
|
6282
|
+
var parse2 = (x) => parse(String(x), null, parseIntAsNumberOrBigInt);
|
|
6283
|
+
var parseAlwaysAsBig = (x) => parse(String(x), null, parseNumberAndBigInt);
|
|
6284
|
+
var stringify2 = (...p) => stringify(...p);
|
|
6285
|
+
var stringifyAlwaysAsBig = stringify2;
|
|
7422
6286
|
|
|
7423
6287
|
// src/utils/hash.ts
|
|
7424
6288
|
var transactionVersion = 1n;
|
|
@@ -7533,10 +6397,10 @@ var starknet = (() => {
|
|
|
7533
6397
|
}
|
|
7534
6398
|
return value === null ? void 0 : value;
|
|
7535
6399
|
}
|
|
7536
|
-
function formatSpaces(
|
|
6400
|
+
function formatSpaces(json) {
|
|
7537
6401
|
let insideQuotes = false;
|
|
7538
6402
|
let newString = "";
|
|
7539
|
-
for (const char of
|
|
6403
|
+
for (const char of json) {
|
|
7540
6404
|
if (char === '"' && newString.endsWith("\\") === false) {
|
|
7541
6405
|
insideQuotes = !insideQuotes;
|
|
7542
6406
|
}
|
|
@@ -7551,11 +6415,11 @@ var starknet = (() => {
|
|
|
7551
6415
|
function computeHintedClassHash(compiledContract) {
|
|
7552
6416
|
const { abi, program } = compiledContract;
|
|
7553
6417
|
const contractClass = { abi, program };
|
|
7554
|
-
const serializedJson = formatSpaces(
|
|
6418
|
+
const serializedJson = formatSpaces(stringify2(contractClass, nullSkipReplacer));
|
|
7555
6419
|
return addHexPrefix(esm_exports.keccak(utf8ToArray(serializedJson)).toString(16));
|
|
7556
6420
|
}
|
|
7557
6421
|
function computeLegacyContractClassHash(contract) {
|
|
7558
|
-
const compiledContract = typeof contract === "string" ?
|
|
6422
|
+
const compiledContract = typeof contract === "string" ? parse2(contract) : contract;
|
|
7559
6423
|
const apiVersion = toHex(API_VERSION);
|
|
7560
6424
|
const externalEntryPointsHash = computeHashOnElements2(
|
|
7561
6425
|
compiledContract.entry_points_by_type.EXTERNAL.flatMap((e) => [e.selector, e.offset])
|
|
@@ -7618,7 +6482,7 @@ var starknet = (() => {
|
|
|
7618
6482
|
return poseidonHashMany(base);
|
|
7619
6483
|
}
|
|
7620
6484
|
function hashAbi(sierra) {
|
|
7621
|
-
const indentString = formatSpaces(
|
|
6485
|
+
const indentString = formatSpaces(stringify2(sierra.abi, null));
|
|
7622
6486
|
return BigInt(addHexPrefix(esm_exports.keccak(utf8ToArray(indentString)).toString(16)));
|
|
7623
6487
|
}
|
|
7624
6488
|
function computeSierraContractClassHash(sierra) {
|
|
@@ -7641,7 +6505,7 @@ var starknet = (() => {
|
|
|
7641
6505
|
);
|
|
7642
6506
|
}
|
|
7643
6507
|
function computeContractClassHash(contract) {
|
|
7644
|
-
const compiledContract = typeof contract === "string" ?
|
|
6508
|
+
const compiledContract = typeof contract === "string" ? parse2(contract) : contract;
|
|
7645
6509
|
if ("sierra_program" in compiledContract) {
|
|
7646
6510
|
return computeSierraContractClassHash(compiledContract);
|
|
7647
6511
|
}
|
|
@@ -7649,9 +6513,8 @@ var starknet = (() => {
|
|
|
7649
6513
|
}
|
|
7650
6514
|
|
|
7651
6515
|
// src/utils/contract.ts
|
|
7652
|
-
var import_json_bigint2 = __toESM(require_json_bigint());
|
|
7653
6516
|
function isSierra(contract) {
|
|
7654
|
-
const compiledContract = typeof contract === "string" ? (
|
|
6517
|
+
const compiledContract = typeof contract === "string" ? parse2(contract) : contract;
|
|
7655
6518
|
return "sierra_program" in compiledContract;
|
|
7656
6519
|
}
|
|
7657
6520
|
function extractContractHashes(payload) {
|
|
@@ -7679,7 +6542,6 @@ var starknet = (() => {
|
|
|
7679
6542
|
estimatedFeeToMaxFee: () => estimatedFeeToMaxFee,
|
|
7680
6543
|
formatSignature: () => formatSignature,
|
|
7681
6544
|
makeAddress: () => makeAddress,
|
|
7682
|
-
parseSignature: () => parseSignature,
|
|
7683
6545
|
randomAddress: () => randomAddress,
|
|
7684
6546
|
signatureToDecimalArray: () => signatureToDecimalArray,
|
|
7685
6547
|
signatureToHexArray: () => signatureToHexArray
|
|
@@ -11761,7 +10623,7 @@ var starknet = (() => {
|
|
|
11761
10623
|
|
|
11762
10624
|
// src/utils/stark.ts
|
|
11763
10625
|
function compressProgram(jsonProgram) {
|
|
11764
|
-
const stringified = typeof jsonProgram === "string" ? jsonProgram :
|
|
10626
|
+
const stringified = typeof jsonProgram === "string" ? jsonProgram : stringify2(jsonProgram);
|
|
11765
10627
|
const compressedProgram = gzip_1(stringified);
|
|
11766
10628
|
return btoaUniversal(compressedProgram);
|
|
11767
10629
|
}
|
|
@@ -11774,12 +10636,15 @@ var starknet = (() => {
|
|
|
11774
10636
|
}
|
|
11775
10637
|
function formatSignature(sig) {
|
|
11776
10638
|
if (!sig)
|
|
11777
|
-
|
|
10639
|
+
throw Error("formatSignature: provided signature is undefined");
|
|
10640
|
+
if (Array.isArray(sig)) {
|
|
10641
|
+
return sig.map((it) => toHex(it));
|
|
10642
|
+
}
|
|
11778
10643
|
try {
|
|
11779
10644
|
const { r, s } = sig;
|
|
11780
10645
|
return [toHex(r), toHex(s)];
|
|
11781
10646
|
} catch (e) {
|
|
11782
|
-
|
|
10647
|
+
throw new Error("Signature need to be weierstrass.SignatureType or an array for custom");
|
|
11783
10648
|
}
|
|
11784
10649
|
}
|
|
11785
10650
|
function signatureToDecimalArray(sig) {
|
|
@@ -11788,12 +10653,6 @@ var starknet = (() => {
|
|
|
11788
10653
|
function signatureToHexArray(sig) {
|
|
11789
10654
|
return bigNumberishArrayToHexadecimalStringArray(formatSignature(sig));
|
|
11790
10655
|
}
|
|
11791
|
-
function parseSignature(sig) {
|
|
11792
|
-
if (!sig)
|
|
11793
|
-
return void 0;
|
|
11794
|
-
const [r, s] = sig;
|
|
11795
|
-
return new Signature(toBigInt(r), toBigInt(s));
|
|
11796
|
-
}
|
|
11797
10656
|
function compileCalldata(args) {
|
|
11798
10657
|
const compiledData = Object.values(args).flatMap((value) => {
|
|
11799
10658
|
if (Array.isArray(value))
|
|
@@ -11831,13 +10690,13 @@ var starknet = (() => {
|
|
|
11831
10690
|
function createSierraContractClass(contract) {
|
|
11832
10691
|
const result = { ...contract };
|
|
11833
10692
|
delete result.sierra_program_debug_info;
|
|
11834
|
-
result.abi = formatSpaces(
|
|
11835
|
-
result.sierra_program = formatSpaces(
|
|
10693
|
+
result.abi = formatSpaces(stringify2(contract.abi));
|
|
10694
|
+
result.sierra_program = formatSpaces(stringify2(contract.sierra_program));
|
|
11836
10695
|
result.sierra_program = compressProgram(result.sierra_program);
|
|
11837
10696
|
return result;
|
|
11838
10697
|
}
|
|
11839
10698
|
function parseContract(contract) {
|
|
11840
|
-
const parsedContract = typeof contract === "string" ?
|
|
10699
|
+
const parsedContract = typeof contract === "string" ? parse2(contract) : contract;
|
|
11841
10700
|
if (!isSierra(contract)) {
|
|
11842
10701
|
return {
|
|
11843
10702
|
...parsedContract,
|
|
@@ -11886,61 +10745,9 @@ var starknet = (() => {
|
|
|
11886
10745
|
}
|
|
11887
10746
|
};
|
|
11888
10747
|
|
|
11889
|
-
// node_modules/ts-custom-error/dist/custom-error.mjs
|
|
11890
|
-
function fixProto(target, prototype) {
|
|
11891
|
-
var setPrototypeOf = Object.setPrototypeOf;
|
|
11892
|
-
setPrototypeOf ? setPrototypeOf(target, prototype) : target.__proto__ = prototype;
|
|
11893
|
-
}
|
|
11894
|
-
function fixStack(target, fn) {
|
|
11895
|
-
if (fn === void 0) {
|
|
11896
|
-
fn = target.constructor;
|
|
11897
|
-
}
|
|
11898
|
-
var captureStackTrace = Error.captureStackTrace;
|
|
11899
|
-
captureStackTrace && captureStackTrace(target, fn);
|
|
11900
|
-
}
|
|
11901
|
-
var __extends = function() {
|
|
11902
|
-
var _extendStatics = function extendStatics(d, b) {
|
|
11903
|
-
_extendStatics = Object.setPrototypeOf || {
|
|
11904
|
-
__proto__: []
|
|
11905
|
-
} instanceof Array && function(d2, b2) {
|
|
11906
|
-
d2.__proto__ = b2;
|
|
11907
|
-
} || function(d2, b2) {
|
|
11908
|
-
for (var p in b2) {
|
|
11909
|
-
if (Object.prototype.hasOwnProperty.call(b2, p))
|
|
11910
|
-
d2[p] = b2[p];
|
|
11911
|
-
}
|
|
11912
|
-
};
|
|
11913
|
-
return _extendStatics(d, b);
|
|
11914
|
-
};
|
|
11915
|
-
return function(d, b) {
|
|
11916
|
-
if (typeof b !== "function" && b !== null)
|
|
11917
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11918
|
-
_extendStatics(d, b);
|
|
11919
|
-
function __() {
|
|
11920
|
-
this.constructor = d;
|
|
11921
|
-
}
|
|
11922
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
11923
|
-
};
|
|
11924
|
-
}();
|
|
11925
|
-
var CustomError = function(_super) {
|
|
11926
|
-
__extends(CustomError2, _super);
|
|
11927
|
-
function CustomError2(message, options) {
|
|
11928
|
-
var _newTarget = this.constructor;
|
|
11929
|
-
var _this = _super.call(this, message, options) || this;
|
|
11930
|
-
Object.defineProperty(_this, "name", {
|
|
11931
|
-
value: _newTarget.name,
|
|
11932
|
-
enumerable: false,
|
|
11933
|
-
configurable: true
|
|
11934
|
-
});
|
|
11935
|
-
fixProto(_this, _newTarget.prototype);
|
|
11936
|
-
fixStack(_this);
|
|
11937
|
-
return _this;
|
|
11938
|
-
}
|
|
11939
|
-
return CustomError2;
|
|
11940
|
-
}(Error);
|
|
11941
|
-
|
|
11942
10748
|
// src/provider/errors.ts
|
|
11943
|
-
var
|
|
10749
|
+
var import_custom_error = __toESM(require_custom_error());
|
|
10750
|
+
var LibraryError = class extends import_custom_error.CustomError {
|
|
11944
10751
|
};
|
|
11945
10752
|
var GatewayError = class extends LibraryError {
|
|
11946
10753
|
constructor(message, errorCode) {
|
|
@@ -12161,7 +10968,7 @@ var starknet = (() => {
|
|
|
12161
10968
|
fetch(method, params) {
|
|
12162
10969
|
return fetchPonyfill_default(this.nodeUrl, {
|
|
12163
10970
|
method: "POST",
|
|
12164
|
-
body:
|
|
10971
|
+
body: stringify2({ method, jsonrpc: "2.0", params, id: 0 }),
|
|
12165
10972
|
headers: this.headers
|
|
12166
10973
|
});
|
|
12167
10974
|
}
|
|
@@ -12480,7 +11287,7 @@ var starknet = (() => {
|
|
|
12480
11287
|
max_fee: "max_fee" in res.transaction ? res.transaction.max_fee : void 0,
|
|
12481
11288
|
nonce: res.transaction.nonce,
|
|
12482
11289
|
sender_address: "sender_address" in res.transaction ? res.transaction.sender_address : void 0,
|
|
12483
|
-
signature: "signature" in res.transaction ?
|
|
11290
|
+
signature: "signature" in res.transaction ? res.transaction.signature : void 0,
|
|
12484
11291
|
transaction_hash: "transaction_hash" in res.transaction ? res.transaction.transaction_hash : void 0,
|
|
12485
11292
|
version: "version" in res.transaction ? res.transaction.version : void 0
|
|
12486
11293
|
};
|
|
@@ -12748,20 +11555,20 @@ var starknet = (() => {
|
|
|
12748
11555
|
try {
|
|
12749
11556
|
const response = await fetchPonyfill_default(url, {
|
|
12750
11557
|
method,
|
|
12751
|
-
body:
|
|
11558
|
+
body: stringify2(options == null ? void 0 : options.body),
|
|
12752
11559
|
headers
|
|
12753
11560
|
});
|
|
12754
11561
|
const textResponse = await response.text();
|
|
12755
11562
|
if (!response.ok) {
|
|
12756
11563
|
let responseBody;
|
|
12757
11564
|
try {
|
|
12758
|
-
responseBody =
|
|
11565
|
+
responseBody = parse2(textResponse);
|
|
12759
11566
|
} catch {
|
|
12760
11567
|
throw new HttpError(response.statusText, response.status);
|
|
12761
11568
|
}
|
|
12762
11569
|
throw new GatewayError(responseBody.message, responseBody.code);
|
|
12763
11570
|
}
|
|
12764
|
-
const parseChoice = (options == null ? void 0 : options.parseAlwaysAsBigInt) ? parseAlwaysAsBig :
|
|
11571
|
+
const parseChoice = (options == null ? void 0 : options.parseAlwaysAsBigInt) ? parseAlwaysAsBig : parse2;
|
|
12765
11572
|
return parseChoice(textResponse);
|
|
12766
11573
|
} catch (error) {
|
|
12767
11574
|
if (error instanceof Error && !(error instanceof LibraryError))
|
|
@@ -13830,7 +12637,10 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
13830
12637
|
__export(transaction_exports, {
|
|
13831
12638
|
fromCallsToExecuteCalldata: () => fromCallsToExecuteCalldata,
|
|
13832
12639
|
fromCallsToExecuteCalldataWithNonce: () => fromCallsToExecuteCalldataWithNonce,
|
|
13833
|
-
|
|
12640
|
+
fromCallsToExecuteCalldata_cairo1: () => fromCallsToExecuteCalldata_cairo1,
|
|
12641
|
+
getExecuteCalldata: () => getExecuteCalldata,
|
|
12642
|
+
transformCallsToMulticallArrays: () => transformCallsToMulticallArrays,
|
|
12643
|
+
transformCallsToMulticallArrays_cairo1: () => transformCallsToMulticallArrays_cairo1
|
|
13834
12644
|
});
|
|
13835
12645
|
var transformCallsToMulticallArrays = (calls) => {
|
|
13836
12646
|
const callArray = [];
|
|
@@ -13864,6 +12674,27 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
13864
12674
|
var fromCallsToExecuteCalldataWithNonce = (calls, nonce) => {
|
|
13865
12675
|
return [...fromCallsToExecuteCalldata(calls), toBigInt(nonce).toString()];
|
|
13866
12676
|
};
|
|
12677
|
+
var transformCallsToMulticallArrays_cairo1 = (calls) => {
|
|
12678
|
+
const callArray = calls.map((call) => ({
|
|
12679
|
+
to: toBigInt(call.contractAddress).toString(10),
|
|
12680
|
+
selector: toBigInt(getSelectorFromName(call.entrypoint)).toString(10),
|
|
12681
|
+
calldata: bigNumberishArrayToDecimalStringArray(call.calldata || [])
|
|
12682
|
+
}));
|
|
12683
|
+
return callArray;
|
|
12684
|
+
};
|
|
12685
|
+
var fromCallsToExecuteCalldata_cairo1 = (calls) => {
|
|
12686
|
+
const callArray = transformCallsToMulticallArrays_cairo1(calls);
|
|
12687
|
+
return [
|
|
12688
|
+
callArray.length.toString(),
|
|
12689
|
+
...callArray.map(({ to, selector, calldata }) => [to, selector, calldata.length.toString(), ...calldata]).flat()
|
|
12690
|
+
];
|
|
12691
|
+
};
|
|
12692
|
+
var getExecuteCalldata = (calls, cairoVersion = "0") => {
|
|
12693
|
+
if (cairoVersion === "1") {
|
|
12694
|
+
return fromCallsToExecuteCalldata_cairo1(calls);
|
|
12695
|
+
}
|
|
12696
|
+
return fromCallsToExecuteCalldata(calls);
|
|
12697
|
+
};
|
|
13867
12698
|
|
|
13868
12699
|
// src/utils/typedData/index.ts
|
|
13869
12700
|
var typedData_exports = {};
|
|
@@ -14090,7 +12921,7 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
14090
12921
|
if (abis && abis.length !== transactions.length) {
|
|
14091
12922
|
throw new Error("ABI must be provided for each transaction or no transaction");
|
|
14092
12923
|
}
|
|
14093
|
-
const calldata =
|
|
12924
|
+
const calldata = getExecuteCalldata(transactions, transactionsDetail.cairoVersion);
|
|
14094
12925
|
const msgHash = calculateTransactionHash(
|
|
14095
12926
|
transactionsDetail.walletAddress,
|
|
14096
12927
|
transactionsDetail.version,
|
|
@@ -14181,7 +13012,7 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
14181
13012
|
async estimateFee(calls, estimateFeeDetails) {
|
|
14182
13013
|
return this.estimateInvokeFee(calls, estimateFeeDetails);
|
|
14183
13014
|
}
|
|
14184
|
-
async estimateInvokeFee(calls, { nonce: providedNonce, blockIdentifier, skipValidate } = {}) {
|
|
13015
|
+
async estimateInvokeFee(calls, { nonce: providedNonce, blockIdentifier, skipValidate, cairoVersion } = {}) {
|
|
14185
13016
|
const transactions = Array.isArray(calls) ? calls : [calls];
|
|
14186
13017
|
const nonce = toBigInt(providedNonce ?? await this.getNonce());
|
|
14187
13018
|
const version = toBigInt(feeTransactionVersion);
|
|
@@ -14191,7 +13022,8 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
14191
13022
|
nonce,
|
|
14192
13023
|
maxFee: ZERO,
|
|
14193
13024
|
version,
|
|
14194
|
-
chainId
|
|
13025
|
+
chainId,
|
|
13026
|
+
cairoVersion: cairoVersion ?? "0"
|
|
14195
13027
|
};
|
|
14196
13028
|
const invocation = await this.buildInvocation(transactions, signerDetails);
|
|
14197
13029
|
const response = await super.getInvokeEstimateFee(
|
|
@@ -14206,13 +13038,20 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
14206
13038
|
suggestedMaxFee
|
|
14207
13039
|
};
|
|
14208
13040
|
}
|
|
14209
|
-
async estimateDeclareFee({ contract, classHash: providedClassHash, casm, compiledClassHash }, { blockIdentifier, nonce: providedNonce, skipValidate } = {}) {
|
|
13041
|
+
async estimateDeclareFee({ contract, classHash: providedClassHash, casm, compiledClassHash }, { blockIdentifier, nonce: providedNonce, skipValidate, cairoVersion } = {}) {
|
|
14210
13042
|
const nonce = toBigInt(providedNonce ?? await this.getNonce());
|
|
14211
13043
|
const version = !isSierra(contract) ? toBigInt(feeTransactionVersion) : transactionVersion_2;
|
|
14212
13044
|
const chainId = await this.getChainId();
|
|
14213
13045
|
const declareContractTransaction = await this.buildDeclarePayload(
|
|
14214
13046
|
{ classHash: providedClassHash, contract, casm, compiledClassHash },
|
|
14215
|
-
{
|
|
13047
|
+
{
|
|
13048
|
+
nonce,
|
|
13049
|
+
chainId,
|
|
13050
|
+
version,
|
|
13051
|
+
walletAddress: this.address,
|
|
13052
|
+
maxFee: ZERO,
|
|
13053
|
+
cairoVersion: cairoVersion ?? "0"
|
|
13054
|
+
}
|
|
14216
13055
|
);
|
|
14217
13056
|
const response = await super.getDeclareEstimateFee(
|
|
14218
13057
|
declareContractTransaction,
|
|
@@ -14231,13 +13070,20 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
14231
13070
|
addressSalt = 0,
|
|
14232
13071
|
constructorCalldata = [],
|
|
14233
13072
|
contractAddress: providedContractAddress
|
|
14234
|
-
}, { blockIdentifier, skipValidate } = {}) {
|
|
13073
|
+
}, { blockIdentifier, skipValidate, cairoVersion } = {}) {
|
|
14235
13074
|
const version = toBigInt(feeTransactionVersion);
|
|
14236
13075
|
const nonce = ZERO;
|
|
14237
13076
|
const chainId = await this.getChainId();
|
|
14238
13077
|
const payload = await this.buildAccountDeployPayload(
|
|
14239
13078
|
{ classHash, addressSalt, constructorCalldata, contractAddress: providedContractAddress },
|
|
14240
|
-
{
|
|
13079
|
+
{
|
|
13080
|
+
nonce,
|
|
13081
|
+
chainId,
|
|
13082
|
+
version,
|
|
13083
|
+
walletAddress: this.address,
|
|
13084
|
+
maxFee: ZERO,
|
|
13085
|
+
cairoVersion: cairoVersion ?? "0"
|
|
13086
|
+
}
|
|
14241
13087
|
);
|
|
14242
13088
|
const response = await super.getDeployAccountEstimateFee(
|
|
14243
13089
|
{ ...payload },
|
|
@@ -14255,7 +13101,7 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
14255
13101
|
const calls = this.buildUDCContractPayload(payload);
|
|
14256
13102
|
return this.estimateInvokeFee(calls, transactionsDetail);
|
|
14257
13103
|
}
|
|
14258
|
-
async estimateFeeBulk(transactions, { nonce: providedNonce, blockIdentifier } = {}) {
|
|
13104
|
+
async estimateFeeBulk(transactions, { nonce: providedNonce, blockIdentifier, cairoVersion } = {}) {
|
|
14259
13105
|
const nonce = toBigInt(providedNonce ?? await this.getNonce());
|
|
14260
13106
|
const version = toBigInt(feeTransactionVersion);
|
|
14261
13107
|
const chainId = await this.getChainId();
|
|
@@ -14266,7 +13112,8 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
14266
13112
|
nonce: toBigInt(Number(nonce) + index),
|
|
14267
13113
|
maxFee: ZERO,
|
|
14268
13114
|
version,
|
|
14269
|
-
chainId
|
|
13115
|
+
chainId,
|
|
13116
|
+
cairoVersion: cairoVersion ?? "0"
|
|
14270
13117
|
};
|
|
14271
13118
|
const txPayload = transaction.payload;
|
|
14272
13119
|
let res;
|
|
@@ -14324,7 +13171,7 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
14324
13171
|
});
|
|
14325
13172
|
}
|
|
14326
13173
|
async buildInvocation(call, signerDetails) {
|
|
14327
|
-
const calldata =
|
|
13174
|
+
const calldata = getExecuteCalldata(call, signerDetails.cairoVersion);
|
|
14328
13175
|
const signature = await this.signer.signTransaction(call, signerDetails);
|
|
14329
13176
|
return {
|
|
14330
13177
|
contractAddress: this.address,
|
|
@@ -14341,15 +13188,17 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
14341
13188
|
);
|
|
14342
13189
|
const version = toBigInt(transactionVersion);
|
|
14343
13190
|
const chainId = await this.getChainId();
|
|
13191
|
+
const cairoVersion = transactionsDetail.cairoVersion ?? "0";
|
|
14344
13192
|
const signerDetails = {
|
|
14345
13193
|
walletAddress: this.address,
|
|
14346
13194
|
nonce,
|
|
14347
13195
|
maxFee,
|
|
14348
13196
|
version,
|
|
14349
|
-
chainId
|
|
13197
|
+
chainId,
|
|
13198
|
+
cairoVersion
|
|
14350
13199
|
};
|
|
14351
13200
|
const signature = await this.signer.signTransaction(transactions, signerDetails, abis);
|
|
14352
|
-
const calldata =
|
|
13201
|
+
const calldata = getExecuteCalldata(transactions, cairoVersion);
|
|
14353
13202
|
return this.invokeFunction(
|
|
14354
13203
|
{ contractAddress: this.address, calldata, signature },
|
|
14355
13204
|
{
|
|
@@ -14374,7 +13223,8 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
14374
13223
|
details.chainId = await this.getChainId();
|
|
14375
13224
|
const declareContractTransaction = await this.buildDeclarePayload(declareContractPayload, {
|
|
14376
13225
|
...details,
|
|
14377
|
-
walletAddress: this.address
|
|
13226
|
+
walletAddress: this.address,
|
|
13227
|
+
cairoVersion: transactionsDetail.cairoVersion ?? "0"
|
|
14378
13228
|
});
|
|
14379
13229
|
return this.declareContract(declareContractTransaction, details);
|
|
14380
13230
|
}
|
|
@@ -14484,7 +13334,7 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
14484
13334
|
entrypoint: "isValidSignature",
|
|
14485
13335
|
calldata: compileCalldata({
|
|
14486
13336
|
hash: toBigInt(hash2).toString(),
|
|
14487
|
-
signature:
|
|
13337
|
+
signature: formatSignature(signature)
|
|
14488
13338
|
})
|
|
14489
13339
|
});
|
|
14490
13340
|
return true;
|
|
@@ -14515,7 +13365,7 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
14515
13365
|
feeEstimate = { suggestedMaxFee: ZERO, overall_fee: ZERO };
|
|
14516
13366
|
break;
|
|
14517
13367
|
}
|
|
14518
|
-
return feeEstimate.suggestedMaxFee
|
|
13368
|
+
return feeEstimate.suggestedMaxFee;
|
|
14519
13369
|
}
|
|
14520
13370
|
async buildDeclarePayload(payload, { nonce, chainId, version, walletAddress, maxFee }) {
|
|
14521
13371
|
const { classHash, contract, compiledClassHash } = extractContractHashes(payload);
|
|
@@ -14583,7 +13433,7 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
14583
13433
|
});
|
|
14584
13434
|
return calls;
|
|
14585
13435
|
}
|
|
14586
|
-
async simulateTransaction(calls, { nonce: providedNonce, blockIdentifier, skipValidate } = {}) {
|
|
13436
|
+
async simulateTransaction(calls, { nonce: providedNonce, blockIdentifier, skipValidate, cairoVersion } = {}) {
|
|
14587
13437
|
const transactions = Array.isArray(calls) ? calls : [calls];
|
|
14588
13438
|
const nonce = toBigInt(providedNonce ?? await this.getNonce());
|
|
14589
13439
|
const version = toBigInt(feeTransactionVersion);
|
|
@@ -14593,7 +13443,8 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
14593
13443
|
nonce,
|
|
14594
13444
|
maxFee: ZERO,
|
|
14595
13445
|
version,
|
|
14596
|
-
chainId
|
|
13446
|
+
chainId,
|
|
13447
|
+
cairoVersion: cairoVersion ?? "0"
|
|
14597
13448
|
};
|
|
14598
13449
|
const invocation = await this.buildInvocation(transactions, signerDetails);
|
|
14599
13450
|
const response = await super.getSimulateTransaction(
|