@lightsparkdev/core 1.4.6 → 1.4.8
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 +14 -0
- package/dist/{chunk-NCCCATWW.js → chunk-7TABKK5I.js} +221 -12
- package/dist/{chunk-RS4VXJZY.js → chunk-YOHZRRM2.js} +1 -1
- package/dist/{index-BI-zWPu_.d.cts → index-JEN9VvIL.d.cts} +35 -1
- package/dist/{index-BI-zWPu_.d.ts → index-JEN9VvIL.d.ts} +35 -1
- package/dist/index.cjs +221 -12
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/react-native/index.cjs +221 -12
- package/dist/react-native/index.d.cts +1 -1
- package/dist/react-native/index.d.ts +1 -1
- package/dist/react-native/index.js +2 -2
- package/dist/utils/index.cjs +221 -12
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/package.json +1 -1
- package/src/utils/currency.ts +235 -0
- package/src/utils/tests/currency.test.ts +19 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @lightsparkdev/core
|
|
2
2
|
|
|
3
|
+
## 1.4.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9a7776b: Adding currency support for XOF, XAF, MWK, RWF
|
|
8
|
+
|
|
9
|
+
## 1.4.7
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 8e4690a: - Add new currencies to currency utils
|
|
14
|
+
- 8e4690a: - Added payment hash parameters to create_invoice. This is for RK customers to specify payment hash upfront when creating
|
|
15
|
+
an invoice so that a round-trip to the RK to fetch the payment hash doesn't have to be made mid-request.
|
|
16
|
+
|
|
3
17
|
## 1.4.6
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -422,7 +422,18 @@ var CurrencyUnit = {
|
|
|
422
422
|
SGD: "SGD",
|
|
423
423
|
THB: "THB",
|
|
424
424
|
VND: "VND",
|
|
425
|
+
NGN: "NGN",
|
|
426
|
+
ZAR: "ZAR",
|
|
427
|
+
KES: "KES",
|
|
428
|
+
TZS: "TZS",
|
|
429
|
+
UGX: "UGX",
|
|
430
|
+
BWP: "BWP",
|
|
431
|
+
XOF: "XOF",
|
|
432
|
+
XAF: "XAF",
|
|
433
|
+
MWK: "MWK",
|
|
434
|
+
RWF: "RWF",
|
|
425
435
|
USDT: "USDT",
|
|
436
|
+
USDC: "USDC",
|
|
426
437
|
Bitcoin: "BITCOIN",
|
|
427
438
|
Microbitcoin: "MICROBITCOIN",
|
|
428
439
|
Millibitcoin: "MILLIBITCOIN",
|
|
@@ -435,7 +446,8 @@ var CurrencyUnit = {
|
|
|
435
446
|
Gbp: "GBP",
|
|
436
447
|
Inr: "INR",
|
|
437
448
|
Brl: "BRL",
|
|
438
|
-
Usdt: "USDT"
|
|
449
|
+
Usdt: "USDT",
|
|
450
|
+
Usdc: "USDC"
|
|
439
451
|
};
|
|
440
452
|
var standardUnitConversionObj = {
|
|
441
453
|
[CurrencyUnit.BITCOIN]: (v, unitsPerBtc = 1) => v / unitsPerBtc,
|
|
@@ -460,7 +472,18 @@ var standardUnitConversionObj = {
|
|
|
460
472
|
[CurrencyUnit.SGD]: (v) => v,
|
|
461
473
|
[CurrencyUnit.THB]: (v) => v,
|
|
462
474
|
[CurrencyUnit.VND]: (v) => v,
|
|
463
|
-
[CurrencyUnit.
|
|
475
|
+
[CurrencyUnit.NGN]: (v) => v,
|
|
476
|
+
[CurrencyUnit.ZAR]: (v) => v,
|
|
477
|
+
[CurrencyUnit.KES]: (v) => v,
|
|
478
|
+
[CurrencyUnit.TZS]: (v) => v,
|
|
479
|
+
[CurrencyUnit.UGX]: (v) => v,
|
|
480
|
+
[CurrencyUnit.BWP]: (v) => v,
|
|
481
|
+
[CurrencyUnit.XOF]: (v) => v,
|
|
482
|
+
[CurrencyUnit.XAF]: (v) => v,
|
|
483
|
+
[CurrencyUnit.MWK]: (v) => v,
|
|
484
|
+
[CurrencyUnit.RWF]: (v) => v,
|
|
485
|
+
[CurrencyUnit.USDT]: (v) => v,
|
|
486
|
+
[CurrencyUnit.USDC]: (v) => v
|
|
464
487
|
};
|
|
465
488
|
var toBitcoinConversion = (v, unitsPerBtc = 1) => round(v * unitsPerBtc);
|
|
466
489
|
var toMicrobitcoinConversion = (v, unitsPerBtc = 1) => round(v / 1e6 * unitsPerBtc);
|
|
@@ -491,7 +514,18 @@ var CONVERSION_MAP = {
|
|
|
491
514
|
[CurrencyUnit.SGD]: toBitcoinConversion,
|
|
492
515
|
[CurrencyUnit.THB]: toBitcoinConversion,
|
|
493
516
|
[CurrencyUnit.VND]: toBitcoinConversion,
|
|
494
|
-
[CurrencyUnit.
|
|
517
|
+
[CurrencyUnit.NGN]: toBitcoinConversion,
|
|
518
|
+
[CurrencyUnit.ZAR]: toBitcoinConversion,
|
|
519
|
+
[CurrencyUnit.KES]: toBitcoinConversion,
|
|
520
|
+
[CurrencyUnit.TZS]: toBitcoinConversion,
|
|
521
|
+
[CurrencyUnit.UGX]: toBitcoinConversion,
|
|
522
|
+
[CurrencyUnit.BWP]: toBitcoinConversion,
|
|
523
|
+
[CurrencyUnit.XOF]: toBitcoinConversion,
|
|
524
|
+
[CurrencyUnit.XAF]: toBitcoinConversion,
|
|
525
|
+
[CurrencyUnit.MWK]: toBitcoinConversion,
|
|
526
|
+
[CurrencyUnit.RWF]: toBitcoinConversion,
|
|
527
|
+
[CurrencyUnit.USDT]: toBitcoinConversion,
|
|
528
|
+
[CurrencyUnit.USDC]: toBitcoinConversion
|
|
495
529
|
},
|
|
496
530
|
[CurrencyUnit.MICROBITCOIN]: {
|
|
497
531
|
[CurrencyUnit.BITCOIN]: (v) => v / 1e6,
|
|
@@ -515,7 +549,18 @@ var CONVERSION_MAP = {
|
|
|
515
549
|
[CurrencyUnit.SGD]: toMicrobitcoinConversion,
|
|
516
550
|
[CurrencyUnit.THB]: toMicrobitcoinConversion,
|
|
517
551
|
[CurrencyUnit.VND]: toMicrobitcoinConversion,
|
|
518
|
-
[CurrencyUnit.
|
|
552
|
+
[CurrencyUnit.NGN]: toMicrobitcoinConversion,
|
|
553
|
+
[CurrencyUnit.ZAR]: toMicrobitcoinConversion,
|
|
554
|
+
[CurrencyUnit.KES]: toMicrobitcoinConversion,
|
|
555
|
+
[CurrencyUnit.TZS]: toMicrobitcoinConversion,
|
|
556
|
+
[CurrencyUnit.UGX]: toMicrobitcoinConversion,
|
|
557
|
+
[CurrencyUnit.BWP]: toMicrobitcoinConversion,
|
|
558
|
+
[CurrencyUnit.XOF]: toMicrobitcoinConversion,
|
|
559
|
+
[CurrencyUnit.XAF]: toMicrobitcoinConversion,
|
|
560
|
+
[CurrencyUnit.MWK]: toMicrobitcoinConversion,
|
|
561
|
+
[CurrencyUnit.RWF]: toMicrobitcoinConversion,
|
|
562
|
+
[CurrencyUnit.USDT]: toMicrobitcoinConversion,
|
|
563
|
+
[CurrencyUnit.USDC]: toMicrobitcoinConversion
|
|
519
564
|
},
|
|
520
565
|
[CurrencyUnit.MILLIBITCOIN]: {
|
|
521
566
|
[CurrencyUnit.BITCOIN]: (v) => v / 1e3,
|
|
@@ -539,7 +584,18 @@ var CONVERSION_MAP = {
|
|
|
539
584
|
[CurrencyUnit.SGD]: toMillibitcoinConversion,
|
|
540
585
|
[CurrencyUnit.THB]: toMillibitcoinConversion,
|
|
541
586
|
[CurrencyUnit.VND]: toMillibitcoinConversion,
|
|
542
|
-
[CurrencyUnit.
|
|
587
|
+
[CurrencyUnit.NGN]: toMillibitcoinConversion,
|
|
588
|
+
[CurrencyUnit.ZAR]: toMillibitcoinConversion,
|
|
589
|
+
[CurrencyUnit.KES]: toMillibitcoinConversion,
|
|
590
|
+
[CurrencyUnit.TZS]: toMillibitcoinConversion,
|
|
591
|
+
[CurrencyUnit.UGX]: toMillibitcoinConversion,
|
|
592
|
+
[CurrencyUnit.BWP]: toMillibitcoinConversion,
|
|
593
|
+
[CurrencyUnit.XOF]: toMillibitcoinConversion,
|
|
594
|
+
[CurrencyUnit.XAF]: toMillibitcoinConversion,
|
|
595
|
+
[CurrencyUnit.MWK]: toMillibitcoinConversion,
|
|
596
|
+
[CurrencyUnit.RWF]: toMillibitcoinConversion,
|
|
597
|
+
[CurrencyUnit.USDT]: toMillibitcoinConversion,
|
|
598
|
+
[CurrencyUnit.USDC]: toMillibitcoinConversion
|
|
543
599
|
},
|
|
544
600
|
[CurrencyUnit.MILLISATOSHI]: {
|
|
545
601
|
[CurrencyUnit.BITCOIN]: (v) => v / 1e11,
|
|
@@ -563,7 +619,18 @@ var CONVERSION_MAP = {
|
|
|
563
619
|
[CurrencyUnit.SGD]: toMillisatoshiConversion,
|
|
564
620
|
[CurrencyUnit.THB]: toMillisatoshiConversion,
|
|
565
621
|
[CurrencyUnit.VND]: toMillisatoshiConversion,
|
|
566
|
-
[CurrencyUnit.
|
|
622
|
+
[CurrencyUnit.NGN]: toMillisatoshiConversion,
|
|
623
|
+
[CurrencyUnit.ZAR]: toMillisatoshiConversion,
|
|
624
|
+
[CurrencyUnit.KES]: toMillisatoshiConversion,
|
|
625
|
+
[CurrencyUnit.TZS]: toMillisatoshiConversion,
|
|
626
|
+
[CurrencyUnit.UGX]: toMillisatoshiConversion,
|
|
627
|
+
[CurrencyUnit.BWP]: toMillisatoshiConversion,
|
|
628
|
+
[CurrencyUnit.XOF]: toMillisatoshiConversion,
|
|
629
|
+
[CurrencyUnit.XAF]: toMillisatoshiConversion,
|
|
630
|
+
[CurrencyUnit.MWK]: toMillisatoshiConversion,
|
|
631
|
+
[CurrencyUnit.RWF]: toMillisatoshiConversion,
|
|
632
|
+
[CurrencyUnit.USDT]: toMillisatoshiConversion,
|
|
633
|
+
[CurrencyUnit.USDC]: toMillisatoshiConversion
|
|
567
634
|
},
|
|
568
635
|
[CurrencyUnit.NANOBITCOIN]: {
|
|
569
636
|
[CurrencyUnit.BITCOIN]: (v) => v / 1e9,
|
|
@@ -587,7 +654,18 @@ var CONVERSION_MAP = {
|
|
|
587
654
|
[CurrencyUnit.SGD]: toNanobitcoinConversion,
|
|
588
655
|
[CurrencyUnit.THB]: toNanobitcoinConversion,
|
|
589
656
|
[CurrencyUnit.VND]: toNanobitcoinConversion,
|
|
590
|
-
[CurrencyUnit.
|
|
657
|
+
[CurrencyUnit.NGN]: toNanobitcoinConversion,
|
|
658
|
+
[CurrencyUnit.ZAR]: toNanobitcoinConversion,
|
|
659
|
+
[CurrencyUnit.KES]: toNanobitcoinConversion,
|
|
660
|
+
[CurrencyUnit.TZS]: toNanobitcoinConversion,
|
|
661
|
+
[CurrencyUnit.UGX]: toNanobitcoinConversion,
|
|
662
|
+
[CurrencyUnit.BWP]: toNanobitcoinConversion,
|
|
663
|
+
[CurrencyUnit.XOF]: toNanobitcoinConversion,
|
|
664
|
+
[CurrencyUnit.XAF]: toNanobitcoinConversion,
|
|
665
|
+
[CurrencyUnit.MWK]: toNanobitcoinConversion,
|
|
666
|
+
[CurrencyUnit.RWF]: toNanobitcoinConversion,
|
|
667
|
+
[CurrencyUnit.USDT]: toNanobitcoinConversion,
|
|
668
|
+
[CurrencyUnit.USDC]: toNanobitcoinConversion
|
|
591
669
|
},
|
|
592
670
|
[CurrencyUnit.SATOSHI]: {
|
|
593
671
|
[CurrencyUnit.BITCOIN]: (v) => v / 1e8,
|
|
@@ -611,7 +689,18 @@ var CONVERSION_MAP = {
|
|
|
611
689
|
[CurrencyUnit.SGD]: toSatoshiConversion,
|
|
612
690
|
[CurrencyUnit.THB]: toSatoshiConversion,
|
|
613
691
|
[CurrencyUnit.VND]: toSatoshiConversion,
|
|
614
|
-
[CurrencyUnit.
|
|
692
|
+
[CurrencyUnit.NGN]: toSatoshiConversion,
|
|
693
|
+
[CurrencyUnit.ZAR]: toSatoshiConversion,
|
|
694
|
+
[CurrencyUnit.KES]: toSatoshiConversion,
|
|
695
|
+
[CurrencyUnit.TZS]: toSatoshiConversion,
|
|
696
|
+
[CurrencyUnit.UGX]: toSatoshiConversion,
|
|
697
|
+
[CurrencyUnit.BWP]: toSatoshiConversion,
|
|
698
|
+
[CurrencyUnit.XOF]: toSatoshiConversion,
|
|
699
|
+
[CurrencyUnit.XAF]: toSatoshiConversion,
|
|
700
|
+
[CurrencyUnit.MWK]: toSatoshiConversion,
|
|
701
|
+
[CurrencyUnit.RWF]: toSatoshiConversion,
|
|
702
|
+
[CurrencyUnit.USDT]: toSatoshiConversion,
|
|
703
|
+
[CurrencyUnit.USDC]: toSatoshiConversion
|
|
615
704
|
},
|
|
616
705
|
[CurrencyUnit.USD]: standardUnitConversionObj,
|
|
617
706
|
[CurrencyUnit.MXN]: standardUnitConversionObj,
|
|
@@ -628,7 +717,18 @@ var CONVERSION_MAP = {
|
|
|
628
717
|
[CurrencyUnit.SGD]: standardUnitConversionObj,
|
|
629
718
|
[CurrencyUnit.THB]: standardUnitConversionObj,
|
|
630
719
|
[CurrencyUnit.VND]: standardUnitConversionObj,
|
|
631
|
-
[CurrencyUnit.
|
|
720
|
+
[CurrencyUnit.NGN]: standardUnitConversionObj,
|
|
721
|
+
[CurrencyUnit.ZAR]: standardUnitConversionObj,
|
|
722
|
+
[CurrencyUnit.KES]: standardUnitConversionObj,
|
|
723
|
+
[CurrencyUnit.TZS]: standardUnitConversionObj,
|
|
724
|
+
[CurrencyUnit.UGX]: standardUnitConversionObj,
|
|
725
|
+
[CurrencyUnit.BWP]: standardUnitConversionObj,
|
|
726
|
+
[CurrencyUnit.XOF]: standardUnitConversionObj,
|
|
727
|
+
[CurrencyUnit.XAF]: standardUnitConversionObj,
|
|
728
|
+
[CurrencyUnit.MWK]: standardUnitConversionObj,
|
|
729
|
+
[CurrencyUnit.RWF]: standardUnitConversionObj,
|
|
730
|
+
[CurrencyUnit.USDT]: standardUnitConversionObj,
|
|
731
|
+
[CurrencyUnit.USDC]: standardUnitConversionObj
|
|
632
732
|
};
|
|
633
733
|
function convertCurrencyAmountValue(fromUnit, toUnit, amount, unitsPerBtc = 1) {
|
|
634
734
|
if (fromUnit === CurrencyUnit.FUTURE_VALUE || toUnit === CurrencyUnit.FUTURE_VALUE) {
|
|
@@ -723,10 +823,21 @@ function convertCurrencyAmountValues(fromUnit, amount, unitsPerBtc = 1, conversi
|
|
|
723
823
|
sgd: CurrencyUnit.SGD,
|
|
724
824
|
thb: CurrencyUnit.THB,
|
|
725
825
|
vnd: CurrencyUnit.VND,
|
|
826
|
+
ngn: CurrencyUnit.NGN,
|
|
827
|
+
zar: CurrencyUnit.ZAR,
|
|
828
|
+
kes: CurrencyUnit.KES,
|
|
829
|
+
tzs: CurrencyUnit.TZS,
|
|
830
|
+
ugx: CurrencyUnit.UGX,
|
|
831
|
+
bwp: CurrencyUnit.BWP,
|
|
832
|
+
xof: CurrencyUnit.XOF,
|
|
833
|
+
xaf: CurrencyUnit.XAF,
|
|
834
|
+
mwk: CurrencyUnit.MWK,
|
|
835
|
+
rwf: CurrencyUnit.RWF,
|
|
726
836
|
mibtc: CurrencyUnit.MICROBITCOIN,
|
|
727
837
|
mlbtc: CurrencyUnit.MILLIBITCOIN,
|
|
728
838
|
nbtc: CurrencyUnit.NANOBITCOIN,
|
|
729
|
-
usdt: CurrencyUnit.USDT
|
|
839
|
+
usdt: CurrencyUnit.USDT,
|
|
840
|
+
usdc: CurrencyUnit.USDC
|
|
730
841
|
};
|
|
731
842
|
return Object.entries(namesToUnits).reduce(
|
|
732
843
|
(acc, [name, unit]) => {
|
|
@@ -784,7 +895,18 @@ function mapCurrencyAmount(currencyAmountArg, unitsPerBtc = 1) {
|
|
|
784
895
|
sgd,
|
|
785
896
|
thb,
|
|
786
897
|
vnd,
|
|
787
|
-
|
|
898
|
+
ngn,
|
|
899
|
+
zar,
|
|
900
|
+
kes,
|
|
901
|
+
tzs,
|
|
902
|
+
ugx,
|
|
903
|
+
bwp,
|
|
904
|
+
xof,
|
|
905
|
+
xaf,
|
|
906
|
+
mwk,
|
|
907
|
+
rwf,
|
|
908
|
+
usdt,
|
|
909
|
+
usdc
|
|
788
910
|
} = convertCurrencyAmountValues(unit, value, unitsPerBtc, conversionOverride);
|
|
789
911
|
const mapWithCurrencyUnits = {
|
|
790
912
|
[CurrencyUnit.BITCOIN]: btc,
|
|
@@ -805,10 +927,21 @@ function mapCurrencyAmount(currencyAmountArg, unitsPerBtc = 1) {
|
|
|
805
927
|
[CurrencyUnit.SGD]: sgd,
|
|
806
928
|
[CurrencyUnit.THB]: thb,
|
|
807
929
|
[CurrencyUnit.VND]: vnd,
|
|
930
|
+
[CurrencyUnit.NGN]: ngn,
|
|
931
|
+
[CurrencyUnit.ZAR]: zar,
|
|
932
|
+
[CurrencyUnit.KES]: kes,
|
|
933
|
+
[CurrencyUnit.TZS]: tzs,
|
|
934
|
+
[CurrencyUnit.UGX]: ugx,
|
|
935
|
+
[CurrencyUnit.BWP]: bwp,
|
|
936
|
+
[CurrencyUnit.XOF]: xof,
|
|
937
|
+
[CurrencyUnit.XAF]: xaf,
|
|
938
|
+
[CurrencyUnit.MWK]: mwk,
|
|
939
|
+
[CurrencyUnit.RWF]: rwf,
|
|
808
940
|
[CurrencyUnit.MICROBITCOIN]: mibtc,
|
|
809
941
|
[CurrencyUnit.MILLIBITCOIN]: mlbtc,
|
|
810
942
|
[CurrencyUnit.NANOBITCOIN]: nbtc,
|
|
811
943
|
[CurrencyUnit.USDT]: usdt,
|
|
944
|
+
[CurrencyUnit.USDC]: usdc,
|
|
812
945
|
[CurrencyUnit.FUTURE_VALUE]: NaN,
|
|
813
946
|
formatted: {
|
|
814
947
|
[CurrencyUnit.BITCOIN]: formatCurrencyStr({
|
|
@@ -895,10 +1028,54 @@ function mapCurrencyAmount(currencyAmountArg, unitsPerBtc = 1) {
|
|
|
895
1028
|
value: vnd,
|
|
896
1029
|
unit: CurrencyUnit.VND
|
|
897
1030
|
}),
|
|
1031
|
+
[CurrencyUnit.NGN]: formatCurrencyStr({
|
|
1032
|
+
value: ngn,
|
|
1033
|
+
unit: CurrencyUnit.NGN
|
|
1034
|
+
}),
|
|
1035
|
+
[CurrencyUnit.ZAR]: formatCurrencyStr({
|
|
1036
|
+
value: zar,
|
|
1037
|
+
unit: CurrencyUnit.ZAR
|
|
1038
|
+
}),
|
|
1039
|
+
[CurrencyUnit.KES]: formatCurrencyStr({
|
|
1040
|
+
value: kes,
|
|
1041
|
+
unit: CurrencyUnit.KES
|
|
1042
|
+
}),
|
|
1043
|
+
[CurrencyUnit.TZS]: formatCurrencyStr({
|
|
1044
|
+
value: tzs,
|
|
1045
|
+
unit: CurrencyUnit.TZS
|
|
1046
|
+
}),
|
|
1047
|
+
[CurrencyUnit.UGX]: formatCurrencyStr({
|
|
1048
|
+
value: ugx,
|
|
1049
|
+
unit: CurrencyUnit.UGX
|
|
1050
|
+
}),
|
|
1051
|
+
[CurrencyUnit.BWP]: formatCurrencyStr({
|
|
1052
|
+
value: bwp,
|
|
1053
|
+
unit: CurrencyUnit.BWP
|
|
1054
|
+
}),
|
|
1055
|
+
[CurrencyUnit.XOF]: formatCurrencyStr({
|
|
1056
|
+
value: xof,
|
|
1057
|
+
unit: CurrencyUnit.XOF
|
|
1058
|
+
}),
|
|
1059
|
+
[CurrencyUnit.XAF]: formatCurrencyStr({
|
|
1060
|
+
value: xaf,
|
|
1061
|
+
unit: CurrencyUnit.XAF
|
|
1062
|
+
}),
|
|
1063
|
+
[CurrencyUnit.MWK]: formatCurrencyStr({
|
|
1064
|
+
value: mwk,
|
|
1065
|
+
unit: CurrencyUnit.MWK
|
|
1066
|
+
}),
|
|
1067
|
+
[CurrencyUnit.RWF]: formatCurrencyStr({
|
|
1068
|
+
value: rwf,
|
|
1069
|
+
unit: CurrencyUnit.RWF
|
|
1070
|
+
}),
|
|
898
1071
|
[CurrencyUnit.USDT]: formatCurrencyStr({
|
|
899
1072
|
value: usdt,
|
|
900
1073
|
unit: CurrencyUnit.USDT
|
|
901
1074
|
}),
|
|
1075
|
+
[CurrencyUnit.USDC]: formatCurrencyStr({
|
|
1076
|
+
value: usdc,
|
|
1077
|
+
unit: CurrencyUnit.USDC
|
|
1078
|
+
}),
|
|
902
1079
|
[CurrencyUnit.FUTURE_VALUE]: "-"
|
|
903
1080
|
}
|
|
904
1081
|
};
|
|
@@ -971,6 +1148,8 @@ var abbrCurrencyUnit = (unit) => {
|
|
|
971
1148
|
return "INR";
|
|
972
1149
|
case CurrencyUnit.USDT:
|
|
973
1150
|
return "USDT";
|
|
1151
|
+
case CurrencyUnit.USDC:
|
|
1152
|
+
return "USDC";
|
|
974
1153
|
case CurrencyUnit.BRL:
|
|
975
1154
|
return "BRL";
|
|
976
1155
|
case CurrencyUnit.CAD:
|
|
@@ -989,6 +1168,26 @@ var abbrCurrencyUnit = (unit) => {
|
|
|
989
1168
|
return "THB";
|
|
990
1169
|
case CurrencyUnit.VND:
|
|
991
1170
|
return "VND";
|
|
1171
|
+
case CurrencyUnit.NGN:
|
|
1172
|
+
return "NGN";
|
|
1173
|
+
case CurrencyUnit.ZAR:
|
|
1174
|
+
return "ZAR";
|
|
1175
|
+
case CurrencyUnit.KES:
|
|
1176
|
+
return "KES";
|
|
1177
|
+
case CurrencyUnit.TZS:
|
|
1178
|
+
return "TZS";
|
|
1179
|
+
case CurrencyUnit.UGX:
|
|
1180
|
+
return "UGX";
|
|
1181
|
+
case CurrencyUnit.BWP:
|
|
1182
|
+
return "BWP";
|
|
1183
|
+
case CurrencyUnit.XOF:
|
|
1184
|
+
return "XOF";
|
|
1185
|
+
case CurrencyUnit.XAF:
|
|
1186
|
+
return "XAF";
|
|
1187
|
+
case CurrencyUnit.MWK:
|
|
1188
|
+
return "MWK";
|
|
1189
|
+
case CurrencyUnit.RWF:
|
|
1190
|
+
return "RWF";
|
|
992
1191
|
}
|
|
993
1192
|
return "Unsupported CurrencyUnit";
|
|
994
1193
|
};
|
|
@@ -1022,7 +1221,14 @@ function formatCurrencyStr(amount, options) {
|
|
|
1022
1221
|
CurrencyUnit.PHP,
|
|
1023
1222
|
CurrencyUnit.EUR,
|
|
1024
1223
|
CurrencyUnit.GBP,
|
|
1025
|
-
CurrencyUnit.INR
|
|
1224
|
+
CurrencyUnit.INR,
|
|
1225
|
+
CurrencyUnit.BRL,
|
|
1226
|
+
CurrencyUnit.NGN,
|
|
1227
|
+
CurrencyUnit.ZAR,
|
|
1228
|
+
CurrencyUnit.KES,
|
|
1229
|
+
CurrencyUnit.TZS,
|
|
1230
|
+
CurrencyUnit.UGX,
|
|
1231
|
+
CurrencyUnit.BWP
|
|
1026
1232
|
];
|
|
1027
1233
|
if (centCurrencies.includes(unit)) {
|
|
1028
1234
|
num = num / 100;
|
|
@@ -1098,6 +1304,9 @@ function formatCurrencyStr(amount, options) {
|
|
|
1098
1304
|
return formattedStr;
|
|
1099
1305
|
}
|
|
1100
1306
|
const unitStr = isUmaCurrencyAmount(amount) ? amount.currency.code : abbrCurrencyUnit(unit);
|
|
1307
|
+
if (formattedStr.includes(unitStr)) {
|
|
1308
|
+
return formattedStr;
|
|
1309
|
+
}
|
|
1101
1310
|
const unitSuffix = options?.appendUnits?.plural && num > 1 ? "s" : "";
|
|
1102
1311
|
const unitStrWithSuffix = `${unitStr}${unitSuffix}`;
|
|
1103
1312
|
formattedStr += ` ${options?.appendUnits?.lowercase ? unitStrWithSuffix.toLowerCase() : unitStrWithSuffix}`;
|
|
@@ -38,7 +38,18 @@ declare const CurrencyUnit: {
|
|
|
38
38
|
readonly SGD: "SGD";
|
|
39
39
|
readonly THB: "THB";
|
|
40
40
|
readonly VND: "VND";
|
|
41
|
+
readonly NGN: "NGN";
|
|
42
|
+
readonly ZAR: "ZAR";
|
|
43
|
+
readonly KES: "KES";
|
|
44
|
+
readonly TZS: "TZS";
|
|
45
|
+
readonly UGX: "UGX";
|
|
46
|
+
readonly BWP: "BWP";
|
|
47
|
+
readonly XOF: "XOF";
|
|
48
|
+
readonly XAF: "XAF";
|
|
49
|
+
readonly MWK: "MWK";
|
|
50
|
+
readonly RWF: "RWF";
|
|
41
51
|
readonly USDT: "USDT";
|
|
52
|
+
readonly USDC: "USDC";
|
|
42
53
|
readonly Bitcoin: "BITCOIN";
|
|
43
54
|
readonly Microbitcoin: "MICROBITCOIN";
|
|
44
55
|
readonly Millibitcoin: "MILLIBITCOIN";
|
|
@@ -52,6 +63,7 @@ declare const CurrencyUnit: {
|
|
|
52
63
|
readonly Inr: "INR";
|
|
53
64
|
readonly Brl: "BRL";
|
|
54
65
|
readonly Usdt: "USDT";
|
|
66
|
+
readonly Usdc: "USDC";
|
|
55
67
|
};
|
|
56
68
|
type CurrencyUnitType = (typeof CurrencyUnit)[keyof typeof CurrencyUnit];
|
|
57
69
|
type SDKCurrencyAmountType = {
|
|
@@ -88,7 +100,18 @@ type CurrencyMap = {
|
|
|
88
100
|
[CurrencyUnit.SGD]: number;
|
|
89
101
|
[CurrencyUnit.THB]: number;
|
|
90
102
|
[CurrencyUnit.VND]: number;
|
|
103
|
+
[CurrencyUnit.NGN]: number;
|
|
104
|
+
[CurrencyUnit.ZAR]: number;
|
|
105
|
+
[CurrencyUnit.KES]: number;
|
|
106
|
+
[CurrencyUnit.TZS]: number;
|
|
107
|
+
[CurrencyUnit.UGX]: number;
|
|
108
|
+
[CurrencyUnit.BWP]: number;
|
|
109
|
+
[CurrencyUnit.XOF]: number;
|
|
110
|
+
[CurrencyUnit.XAF]: number;
|
|
111
|
+
[CurrencyUnit.MWK]: number;
|
|
112
|
+
[CurrencyUnit.RWF]: number;
|
|
91
113
|
[CurrencyUnit.USDT]: number;
|
|
114
|
+
[CurrencyUnit.USDC]: number;
|
|
92
115
|
[CurrencyUnit.FUTURE_VALUE]: number;
|
|
93
116
|
formatted: {
|
|
94
117
|
sats: string;
|
|
@@ -115,7 +138,18 @@ type CurrencyMap = {
|
|
|
115
138
|
[CurrencyUnit.SGD]: string;
|
|
116
139
|
[CurrencyUnit.THB]: string;
|
|
117
140
|
[CurrencyUnit.VND]: string;
|
|
141
|
+
[CurrencyUnit.NGN]: string;
|
|
142
|
+
[CurrencyUnit.ZAR]: string;
|
|
143
|
+
[CurrencyUnit.KES]: string;
|
|
144
|
+
[CurrencyUnit.TZS]: string;
|
|
145
|
+
[CurrencyUnit.UGX]: string;
|
|
146
|
+
[CurrencyUnit.BWP]: string;
|
|
147
|
+
[CurrencyUnit.XOF]: string;
|
|
148
|
+
[CurrencyUnit.XAF]: string;
|
|
149
|
+
[CurrencyUnit.MWK]: string;
|
|
150
|
+
[CurrencyUnit.RWF]: string;
|
|
118
151
|
[CurrencyUnit.USDT]: string;
|
|
152
|
+
[CurrencyUnit.USDC]: string;
|
|
119
153
|
[CurrencyUnit.FUTURE_VALUE]: string;
|
|
120
154
|
};
|
|
121
155
|
isZero: boolean;
|
|
@@ -171,7 +205,7 @@ declare function getCurrencyAmount(currencyAmountArg: CurrencyAmountArg): {
|
|
|
171
205
|
};
|
|
172
206
|
declare function mapCurrencyAmount(currencyAmountArg: CurrencyAmountArg, unitsPerBtc?: number): CurrencyMap;
|
|
173
207
|
declare const isCurrencyMap: (currencyMap: unknown) => currencyMap is CurrencyMap;
|
|
174
|
-
declare const abbrCurrencyUnit: (unit: CurrencyUnitType) => "EUR" | "USD" | "BRL" | "CAD" | "GBP" | "INR" | "MXN" | "PHP" | "DKK" | "HKD" | "IDR" | "MYR" | "SGD" | "THB" | "VND" | "USDT" | "BTC" | "SAT" | "MSAT" | "mBTC" | "μBTC" | "Unsupported CurrencyUnit";
|
|
208
|
+
declare const abbrCurrencyUnit: (unit: CurrencyUnitType) => "EUR" | "USD" | "BRL" | "CAD" | "GBP" | "INR" | "MXN" | "PHP" | "DKK" | "HKD" | "IDR" | "MYR" | "SGD" | "THB" | "VND" | "NGN" | "ZAR" | "KES" | "TZS" | "UGX" | "BWP" | "XOF" | "XAF" | "MWK" | "RWF" | "USDT" | "USDC" | "BTC" | "SAT" | "MSAT" | "mBTC" | "μBTC" | "Unsupported CurrencyUnit";
|
|
175
209
|
type AppendUnitsOptions = {
|
|
176
210
|
plural?: boolean | undefined;
|
|
177
211
|
lowercase?: boolean | undefined;
|
|
@@ -38,7 +38,18 @@ declare const CurrencyUnit: {
|
|
|
38
38
|
readonly SGD: "SGD";
|
|
39
39
|
readonly THB: "THB";
|
|
40
40
|
readonly VND: "VND";
|
|
41
|
+
readonly NGN: "NGN";
|
|
42
|
+
readonly ZAR: "ZAR";
|
|
43
|
+
readonly KES: "KES";
|
|
44
|
+
readonly TZS: "TZS";
|
|
45
|
+
readonly UGX: "UGX";
|
|
46
|
+
readonly BWP: "BWP";
|
|
47
|
+
readonly XOF: "XOF";
|
|
48
|
+
readonly XAF: "XAF";
|
|
49
|
+
readonly MWK: "MWK";
|
|
50
|
+
readonly RWF: "RWF";
|
|
41
51
|
readonly USDT: "USDT";
|
|
52
|
+
readonly USDC: "USDC";
|
|
42
53
|
readonly Bitcoin: "BITCOIN";
|
|
43
54
|
readonly Microbitcoin: "MICROBITCOIN";
|
|
44
55
|
readonly Millibitcoin: "MILLIBITCOIN";
|
|
@@ -52,6 +63,7 @@ declare const CurrencyUnit: {
|
|
|
52
63
|
readonly Inr: "INR";
|
|
53
64
|
readonly Brl: "BRL";
|
|
54
65
|
readonly Usdt: "USDT";
|
|
66
|
+
readonly Usdc: "USDC";
|
|
55
67
|
};
|
|
56
68
|
type CurrencyUnitType = (typeof CurrencyUnit)[keyof typeof CurrencyUnit];
|
|
57
69
|
type SDKCurrencyAmountType = {
|
|
@@ -88,7 +100,18 @@ type CurrencyMap = {
|
|
|
88
100
|
[CurrencyUnit.SGD]: number;
|
|
89
101
|
[CurrencyUnit.THB]: number;
|
|
90
102
|
[CurrencyUnit.VND]: number;
|
|
103
|
+
[CurrencyUnit.NGN]: number;
|
|
104
|
+
[CurrencyUnit.ZAR]: number;
|
|
105
|
+
[CurrencyUnit.KES]: number;
|
|
106
|
+
[CurrencyUnit.TZS]: number;
|
|
107
|
+
[CurrencyUnit.UGX]: number;
|
|
108
|
+
[CurrencyUnit.BWP]: number;
|
|
109
|
+
[CurrencyUnit.XOF]: number;
|
|
110
|
+
[CurrencyUnit.XAF]: number;
|
|
111
|
+
[CurrencyUnit.MWK]: number;
|
|
112
|
+
[CurrencyUnit.RWF]: number;
|
|
91
113
|
[CurrencyUnit.USDT]: number;
|
|
114
|
+
[CurrencyUnit.USDC]: number;
|
|
92
115
|
[CurrencyUnit.FUTURE_VALUE]: number;
|
|
93
116
|
formatted: {
|
|
94
117
|
sats: string;
|
|
@@ -115,7 +138,18 @@ type CurrencyMap = {
|
|
|
115
138
|
[CurrencyUnit.SGD]: string;
|
|
116
139
|
[CurrencyUnit.THB]: string;
|
|
117
140
|
[CurrencyUnit.VND]: string;
|
|
141
|
+
[CurrencyUnit.NGN]: string;
|
|
142
|
+
[CurrencyUnit.ZAR]: string;
|
|
143
|
+
[CurrencyUnit.KES]: string;
|
|
144
|
+
[CurrencyUnit.TZS]: string;
|
|
145
|
+
[CurrencyUnit.UGX]: string;
|
|
146
|
+
[CurrencyUnit.BWP]: string;
|
|
147
|
+
[CurrencyUnit.XOF]: string;
|
|
148
|
+
[CurrencyUnit.XAF]: string;
|
|
149
|
+
[CurrencyUnit.MWK]: string;
|
|
150
|
+
[CurrencyUnit.RWF]: string;
|
|
118
151
|
[CurrencyUnit.USDT]: string;
|
|
152
|
+
[CurrencyUnit.USDC]: string;
|
|
119
153
|
[CurrencyUnit.FUTURE_VALUE]: string;
|
|
120
154
|
};
|
|
121
155
|
isZero: boolean;
|
|
@@ -171,7 +205,7 @@ declare function getCurrencyAmount(currencyAmountArg: CurrencyAmountArg): {
|
|
|
171
205
|
};
|
|
172
206
|
declare function mapCurrencyAmount(currencyAmountArg: CurrencyAmountArg, unitsPerBtc?: number): CurrencyMap;
|
|
173
207
|
declare const isCurrencyMap: (currencyMap: unknown) => currencyMap is CurrencyMap;
|
|
174
|
-
declare const abbrCurrencyUnit: (unit: CurrencyUnitType) => "EUR" | "USD" | "BRL" | "CAD" | "GBP" | "INR" | "MXN" | "PHP" | "DKK" | "HKD" | "IDR" | "MYR" | "SGD" | "THB" | "VND" | "USDT" | "BTC" | "SAT" | "MSAT" | "mBTC" | "μBTC" | "Unsupported CurrencyUnit";
|
|
208
|
+
declare const abbrCurrencyUnit: (unit: CurrencyUnitType) => "EUR" | "USD" | "BRL" | "CAD" | "GBP" | "INR" | "MXN" | "PHP" | "DKK" | "HKD" | "IDR" | "MYR" | "SGD" | "THB" | "VND" | "NGN" | "ZAR" | "KES" | "TZS" | "UGX" | "BWP" | "XOF" | "XAF" | "MWK" | "RWF" | "USDT" | "USDC" | "BTC" | "SAT" | "MSAT" | "mBTC" | "μBTC" | "Unsupported CurrencyUnit";
|
|
175
209
|
type AppendUnitsOptions = {
|
|
176
210
|
plural?: boolean | undefined;
|
|
177
211
|
lowercase?: boolean | undefined;
|