@lightsparkdev/core 1.2.2 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @lightsparkdev/core
2
2
 
3
+ ## 1.2.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 1a063b6: - Add MXN to currency conversion util
8
+ - 1a063b6: - Remove text-encoding dependency previously needed for React Native support
9
+
10
+ ## 1.2.3
11
+
12
+ ### Patch Changes
13
+
14
+ - d61a209: - Changes to internal use of currency utils
15
+
3
16
  ## 1.2.2
4
17
 
5
18
  ### Patch Changes
@@ -402,18 +402,37 @@ var CurrencyUnit = {
402
402
  BITCOIN: "BITCOIN",
403
403
  SATOSHI: "SATOSHI",
404
404
  MILLISATOSHI: "MILLISATOSHI",
405
- USD: "USD",
406
405
  NANOBITCOIN: "NANOBITCOIN",
407
406
  MICROBITCOIN: "MICROBITCOIN",
408
407
  MILLIBITCOIN: "MILLIBITCOIN",
408
+ USD: "USD",
409
+ MXN: "MXN",
409
410
  Bitcoin: "BITCOIN",
410
411
  Microbitcoin: "MICROBITCOIN",
411
412
  Millibitcoin: "MILLIBITCOIN",
412
413
  Millisatoshi: "MILLISATOSHI",
413
414
  Nanobitcoin: "NANOBITCOIN",
414
415
  Satoshi: "SATOSHI",
415
- Usd: "USD"
416
+ Usd: "USD",
417
+ Mxn: "MXN"
418
+ };
419
+ var standardUnitConversionObj = {
420
+ [CurrencyUnit.BITCOIN]: (v, unitsPerBtc = 1) => v / unitsPerBtc,
421
+ [CurrencyUnit.MICROBITCOIN]: (v, unitsPerBtc = 1) => v / unitsPerBtc * 1e6,
422
+ [CurrencyUnit.MILLIBITCOIN]: (v, unitsPerBtc = 1) => v / unitsPerBtc * 1e3,
423
+ [CurrencyUnit.MILLISATOSHI]: (v, unitsPerBtc = 1) => v / unitsPerBtc * 1e11,
424
+ [CurrencyUnit.NANOBITCOIN]: (v, unitsPerBtc = 1) => v / unitsPerBtc * 1e9,
425
+ [CurrencyUnit.SATOSHI]: (v, unitsPerBtc = 1) => v / unitsPerBtc * 1e8,
426
+ /* Converting between two different fiat types is not currently supported */
427
+ [CurrencyUnit.USD]: (v) => v,
428
+ [CurrencyUnit.MXN]: (v) => v
416
429
  };
430
+ var toBitcoinConversion = (v, unitsPerBtc = 1) => round(v * unitsPerBtc);
431
+ var toMicrobitcoinConversion = (v, unitsPerBtc = 1) => round(v / 1e6 * unitsPerBtc);
432
+ var toMillibitcoinConversion = (v, unitsPerBtc = 1) => round(v / 1e3 * unitsPerBtc);
433
+ var toMillisatoshiConversion = (v, unitsPerBtc = 1) => round(v / 1e11 * unitsPerBtc);
434
+ var toNanobitcoinConversion = (v, unitsPerBtc = 1) => round(v / 1e9 * unitsPerBtc);
435
+ var toSatoshiConversion = (v, unitsPerBtc = 1) => round(v / 1e8 * unitsPerBtc);
417
436
  var CONVERSION_MAP = {
418
437
  [CurrencyUnit.BITCOIN]: {
419
438
  [CurrencyUnit.BITCOIN]: (v) => v,
@@ -422,10 +441,8 @@ var CONVERSION_MAP = {
422
441
  [CurrencyUnit.MILLISATOSHI]: (v) => v * 1e11,
423
442
  [CurrencyUnit.NANOBITCOIN]: (v) => v * 1e9,
424
443
  [CurrencyUnit.SATOSHI]: (v) => v * 1e8,
425
- [CurrencyUnit.USD]: (v, centsPerBtc = 1) => (
426
- /* Round without decimals since we're returning cents: */
427
- round(v * centsPerBtc, 2)
428
- )
444
+ [CurrencyUnit.USD]: toBitcoinConversion,
445
+ [CurrencyUnit.MXN]: toBitcoinConversion
429
446
  },
430
447
  [CurrencyUnit.MICROBITCOIN]: {
431
448
  [CurrencyUnit.BITCOIN]: (v) => v / 1e6,
@@ -434,10 +451,8 @@ var CONVERSION_MAP = {
434
451
  [CurrencyUnit.MILLISATOSHI]: (v) => v * 1e5,
435
452
  [CurrencyUnit.NANOBITCOIN]: (v) => v * 1e3,
436
453
  [CurrencyUnit.SATOSHI]: (v) => v * 100,
437
- [CurrencyUnit.USD]: (v, centsPerBtc = 1) => (
438
- /* Round without decimals since we're returning cents: */
439
- round(v / 1e6 * centsPerBtc)
440
- )
454
+ [CurrencyUnit.USD]: toMicrobitcoinConversion,
455
+ [CurrencyUnit.MXN]: toMicrobitcoinConversion
441
456
  },
442
457
  [CurrencyUnit.MILLIBITCOIN]: {
443
458
  [CurrencyUnit.BITCOIN]: (v) => v / 1e3,
@@ -446,10 +461,8 @@ var CONVERSION_MAP = {
446
461
  [CurrencyUnit.MILLISATOSHI]: (v) => v * 1e8,
447
462
  [CurrencyUnit.NANOBITCOIN]: (v) => v * 1e6,
448
463
  [CurrencyUnit.SATOSHI]: (v) => v * 1e5,
449
- [CurrencyUnit.USD]: (v, centsPerBtc = 1) => (
450
- /* Round without decimals since we're returning cents: */
451
- round(v / 1e3 * centsPerBtc)
452
- )
464
+ [CurrencyUnit.USD]: toMillibitcoinConversion,
465
+ [CurrencyUnit.MXN]: toMillibitcoinConversion
453
466
  },
454
467
  [CurrencyUnit.MILLISATOSHI]: {
455
468
  [CurrencyUnit.BITCOIN]: (v) => v / 1e11,
@@ -458,10 +471,8 @@ var CONVERSION_MAP = {
458
471
  [CurrencyUnit.MILLISATOSHI]: (v) => v,
459
472
  [CurrencyUnit.NANOBITCOIN]: (v) => v / 100,
460
473
  [CurrencyUnit.SATOSHI]: (v) => v / 1e3,
461
- [CurrencyUnit.USD]: (v, centsPerBtc = 1) => (
462
- /* Round without decimals since we're returning cents: */
463
- round(v / 1e11 * centsPerBtc)
464
- )
474
+ [CurrencyUnit.USD]: toMillisatoshiConversion,
475
+ [CurrencyUnit.MXN]: toMillisatoshiConversion
465
476
  },
466
477
  [CurrencyUnit.NANOBITCOIN]: {
467
478
  [CurrencyUnit.BITCOIN]: (v) => v / 1e9,
@@ -470,10 +481,8 @@ var CONVERSION_MAP = {
470
481
  [CurrencyUnit.MILLISATOSHI]: (v) => v * 100,
471
482
  [CurrencyUnit.NANOBITCOIN]: (v) => v,
472
483
  [CurrencyUnit.SATOSHI]: (v) => v / 10,
473
- [CurrencyUnit.USD]: (v, centsPerBtc = 1) => (
474
- /* Round without decimals since we're returning cents: */
475
- round(v / 1e9 * centsPerBtc)
476
- )
484
+ [CurrencyUnit.USD]: toNanobitcoinConversion,
485
+ [CurrencyUnit.MXN]: toNanobitcoinConversion
477
486
  },
478
487
  [CurrencyUnit.SATOSHI]: {
479
488
  [CurrencyUnit.BITCOIN]: (v) => v / 1e8,
@@ -482,22 +491,13 @@ var CONVERSION_MAP = {
482
491
  [CurrencyUnit.MILLISATOSHI]: (v) => v * 1e3,
483
492
  [CurrencyUnit.NANOBITCOIN]: (v) => v * 10,
484
493
  [CurrencyUnit.SATOSHI]: (v) => v,
485
- [CurrencyUnit.USD]: (v, centsPerBtc = 1) => (
486
- /* Round without decimals since we're returning cents: */
487
- round(v / 1e8 * centsPerBtc)
488
- )
494
+ [CurrencyUnit.USD]: toSatoshiConversion,
495
+ [CurrencyUnit.MXN]: toSatoshiConversion
489
496
  },
490
- [CurrencyUnit.USD]: {
491
- [CurrencyUnit.BITCOIN]: (v, centsPerBtc = 1) => v / centsPerBtc,
492
- [CurrencyUnit.MICROBITCOIN]: (v, centsPerBtc = 1) => v / centsPerBtc * 1e6,
493
- [CurrencyUnit.MILLIBITCOIN]: (v, centsPerBtc = 1) => v / centsPerBtc * 1e3,
494
- [CurrencyUnit.MILLISATOSHI]: (v, centsPerBtc = 1) => v / centsPerBtc * 1e11,
495
- [CurrencyUnit.NANOBITCOIN]: (v, centsPerBtc = 1) => v / centsPerBtc * 1e9,
496
- [CurrencyUnit.SATOSHI]: (v, centsPerBtc = 1) => v / centsPerBtc * 1e8,
497
- [CurrencyUnit.USD]: (v) => v
498
- }
497
+ [CurrencyUnit.USD]: standardUnitConversionObj,
498
+ [CurrencyUnit.MXN]: standardUnitConversionObj
499
499
  };
500
- function convertCurrencyAmountValue(fromUnit, toUnit, amount, centsPerBtc = 1) {
500
+ function convertCurrencyAmountValue(fromUnit, toUnit, amount, unitsPerBtc = 1) {
501
501
  if (fromUnit === CurrencyUnit.FUTURE_VALUE || toUnit === CurrencyUnit.FUTURE_VALUE) {
502
502
  throw new LightsparkException_default("CurrencyError", `Unsupported CurrencyUnit.`);
503
503
  }
@@ -511,7 +511,7 @@ function convertCurrencyAmountValue(fromUnit, toUnit, amount, centsPerBtc = 1) {
511
511
  `Cannot convert from ${fromUnit} to ${toUnit}`
512
512
  );
513
513
  }
514
- return conversionFn(amount, centsPerBtc);
514
+ return conversionFn(amount, unitsPerBtc);
515
515
  }
516
516
  var convertCurrencyAmount = (from, toUnit) => {
517
517
  const value = convertCurrencyAmountValue(
@@ -526,9 +526,15 @@ var convertCurrencyAmount = (from, toUnit) => {
526
526
  preferredCurrencyValueRounded: value
527
527
  };
528
528
  };
529
- function isCurrencyAmountObj(arg) {
529
+ function isDeprecatedCurrencyAmountObj(arg) {
530
530
  return typeof arg === "object" && arg !== null && "value" in arg && "unit" in arg;
531
531
  }
532
+ function isCurrencyAmountObj(arg) {
533
+ return typeof arg === "object" && arg !== null && "original_value" in arg && "original_unit" in arg;
534
+ }
535
+ function isCurrencyAmountPreferenceObj(arg) {
536
+ return typeof arg === "object" && arg !== null && "preferred_currency_unit" in arg && "preferred_currency_value_rounded" in arg;
537
+ }
532
538
  function isSDKCurrencyAmount(arg) {
533
539
  return typeof arg === "object" && arg !== null && /* We can expect all SDK CurrencyAmount types to always have these exact properties: */
534
540
  "originalValue" in arg && "originalUnit" in arg && "preferredCurrencyUnit" in arg && "preferredCurrencyValueRounded" in arg && "preferredCurrencyValueApprox" in arg;
@@ -545,7 +551,13 @@ function getCurrencyAmount(currencyAmountArg) {
545
551
  if (isSDKCurrencyAmount(currencyAmountArg)) {
546
552
  value = currencyAmountArg.originalValue;
547
553
  unit = currencyAmountArg.originalUnit;
554
+ } else if (isCurrencyAmountPreferenceObj(currencyAmountArg)) {
555
+ value = asNumber(currencyAmountArg.preferred_currency_value_rounded);
556
+ unit = currencyAmountArg.preferred_currency_unit;
548
557
  } else if (isCurrencyAmountObj(currencyAmountArg)) {
558
+ value = asNumber(currencyAmountArg.original_value);
559
+ unit = currencyAmountArg.original_unit;
560
+ } else if (isDeprecatedCurrencyAmountObj(currencyAmountArg)) {
549
561
  value = asNumber(currencyAmountArg.value);
550
562
  unit = currencyAmountArg.unit;
551
563
  }
@@ -554,21 +566,23 @@ function getCurrencyAmount(currencyAmountArg) {
554
566
  unit: unit || CurrencyUnit.SATOSHI
555
567
  };
556
568
  }
557
- function mapCurrencyAmount(currencyAmountArg, centsPerBtc = 1) {
569
+ function mapCurrencyAmount(currencyAmountArg, unitsPerBtc = 1) {
558
570
  const { value, unit } = getCurrencyAmount(currencyAmountArg);
559
571
  const convert = convertCurrencyAmountValue;
560
- const sats = convert(unit, CurrencyUnit.SATOSHI, value, centsPerBtc);
561
- const btc = convert(unit, CurrencyUnit.BITCOIN, value, centsPerBtc);
562
- const msats = convert(unit, CurrencyUnit.MILLISATOSHI, value, centsPerBtc);
563
- const usd = convert(unit, CurrencyUnit.USD, value, centsPerBtc);
564
- const mibtc = convert(unit, CurrencyUnit.MICROBITCOIN, value, centsPerBtc);
565
- const mlbtc = convert(unit, CurrencyUnit.MILLIBITCOIN, value, centsPerBtc);
566
- const nbtc = convert(unit, CurrencyUnit.NANOBITCOIN, value, centsPerBtc);
572
+ const sats = convert(unit, CurrencyUnit.SATOSHI, value, unitsPerBtc);
573
+ const btc = convert(unit, CurrencyUnit.BITCOIN, value, unitsPerBtc);
574
+ const msats = convert(unit, CurrencyUnit.MILLISATOSHI, value, unitsPerBtc);
575
+ const usd = convert(unit, CurrencyUnit.USD, value, unitsPerBtc);
576
+ const mxn = convert(unit, CurrencyUnit.MXN, value, unitsPerBtc);
577
+ const mibtc = convert(unit, CurrencyUnit.MICROBITCOIN, value, unitsPerBtc);
578
+ const mlbtc = convert(unit, CurrencyUnit.MILLIBITCOIN, value, unitsPerBtc);
579
+ const nbtc = convert(unit, CurrencyUnit.NANOBITCOIN, value, unitsPerBtc);
567
580
  const mapWithCurrencyUnits = {
568
581
  [CurrencyUnit.BITCOIN]: btc,
569
582
  [CurrencyUnit.SATOSHI]: sats,
570
583
  [CurrencyUnit.MILLISATOSHI]: msats,
571
584
  [CurrencyUnit.USD]: usd,
585
+ [CurrencyUnit.MXN]: mxn,
572
586
  [CurrencyUnit.MICROBITCOIN]: mibtc,
573
587
  [CurrencyUnit.MILLIBITCOIN]: mlbtc,
574
588
  [CurrencyUnit.NANOBITCOIN]: nbtc,
@@ -602,6 +616,10 @@ function mapCurrencyAmount(currencyAmountArg, centsPerBtc = 1) {
602
616
  value: usd,
603
617
  unit: CurrencyUnit.USD
604
618
  }),
619
+ [CurrencyUnit.MXN]: formatCurrencyStr({
620
+ value: mxn,
621
+ unit: CurrencyUnit.MXN
622
+ }),
605
623
  [CurrencyUnit.FUTURE_VALUE]: "-"
606
624
  }
607
625
  };
@@ -965,7 +983,9 @@ export {
965
983
  CurrencyUnit,
966
984
  convertCurrencyAmountValue,
967
985
  convertCurrencyAmount,
986
+ isDeprecatedCurrencyAmountObj,
968
987
  isCurrencyAmountObj,
988
+ isCurrencyAmountPreferenceObj,
969
989
  isSDKCurrencyAmount,
970
990
  mapCurrencyAmount,
971
991
  isCurrencyMap,
@@ -20,10 +20,11 @@ declare const CurrencyUnit: {
20
20
  readonly BITCOIN: "BITCOIN";
21
21
  readonly SATOSHI: "SATOSHI";
22
22
  readonly MILLISATOSHI: "MILLISATOSHI";
23
- readonly USD: "USD";
24
23
  readonly NANOBITCOIN: "NANOBITCOIN";
25
24
  readonly MICROBITCOIN: "MICROBITCOIN";
26
25
  readonly MILLIBITCOIN: "MILLIBITCOIN";
26
+ readonly USD: "USD";
27
+ readonly MXN: "MXN";
27
28
  readonly Bitcoin: "BITCOIN";
28
29
  readonly Microbitcoin: "MICROBITCOIN";
29
30
  readonly Millibitcoin: "MILLIBITCOIN";
@@ -31,6 +32,7 @@ declare const CurrencyUnit: {
31
32
  readonly Nanobitcoin: "NANOBITCOIN";
32
33
  readonly Satoshi: "SATOSHI";
33
34
  readonly Usd: "USD";
35
+ readonly Mxn: "MXN";
34
36
  };
35
37
  type CurrencyUnitType = (typeof CurrencyUnit)[keyof typeof CurrencyUnit];
36
38
  type SDKCurrencyAmountType = {
@@ -40,7 +42,7 @@ type SDKCurrencyAmountType = {
40
42
  preferredCurrencyValueRounded: number;
41
43
  preferredCurrencyValueApprox: number;
42
44
  };
43
- declare function convertCurrencyAmountValue(fromUnit: CurrencyUnitType, toUnit: CurrencyUnitType, amount: number, centsPerBtc?: number): number;
45
+ declare function convertCurrencyAmountValue(fromUnit: CurrencyUnitType, toUnit: CurrencyUnitType, amount: number, unitsPerBtc?: number): number;
44
46
  declare const convertCurrencyAmount: (from: SDKCurrencyAmountType, toUnit: CurrencyUnitType) => SDKCurrencyAmountType;
45
47
  type CurrencyMap = {
46
48
  sats: number;
@@ -53,6 +55,7 @@ type CurrencyMap = {
53
55
  [CurrencyUnit.MILLIBITCOIN]: number;
54
56
  [CurrencyUnit.NANOBITCOIN]: number;
55
57
  [CurrencyUnit.USD]: number;
58
+ [CurrencyUnit.MXN]: number;
56
59
  [CurrencyUnit.FUTURE_VALUE]: number;
57
60
  formatted: {
58
61
  sats: string;
@@ -65,6 +68,7 @@ type CurrencyMap = {
65
68
  [CurrencyUnit.MICROBITCOIN]: string;
66
69
  [CurrencyUnit.NANOBITCOIN]: string;
67
70
  [CurrencyUnit.USD]: string;
71
+ [CurrencyUnit.MXN]: string;
68
72
  [CurrencyUnit.FUTURE_VALUE]: string;
69
73
  };
70
74
  isZero: boolean;
@@ -73,15 +77,27 @@ type CurrencyMap = {
73
77
  isEqualTo: (other: CurrencyMap | CurrencyAmountObj | number) => boolean;
74
78
  type: "CurrencyMap";
75
79
  };
76
- type CurrencyAmountObj = {
80
+ type DeprecatedCurrencyAmountObj = {
77
81
  value?: number | string | null;
78
82
  unit?: CurrencyUnitType;
79
83
  __typename?: "CurrencyAmount" | undefined;
80
84
  };
81
- type CurrencyAmountArg = CurrencyAmountObj | SDKCurrencyAmountType | undefined | null;
85
+ type CurrencyAmountObj = {
86
+ original_value?: number | string | null;
87
+ original_unit?: CurrencyUnitType;
88
+ __typename?: "CurrencyAmount" | undefined;
89
+ };
90
+ type CurrencyAmountPreferenceObj = {
91
+ preferred_currency_unit?: CurrencyUnitType;
92
+ preferred_currency_value_rounded?: number | string | null;
93
+ __typename?: "CurrencyAmount" | undefined;
94
+ };
95
+ type CurrencyAmountArg = DeprecatedCurrencyAmountObj | CurrencyAmountObj | CurrencyAmountPreferenceObj | SDKCurrencyAmountType | undefined | null;
96
+ declare function isDeprecatedCurrencyAmountObj(arg: unknown): arg is DeprecatedCurrencyAmountObj;
82
97
  declare function isCurrencyAmountObj(arg: unknown): arg is CurrencyAmountObj;
98
+ declare function isCurrencyAmountPreferenceObj(arg: unknown): arg is CurrencyAmountPreferenceObj;
83
99
  declare function isSDKCurrencyAmount(arg: unknown): arg is SDKCurrencyAmountType;
84
- declare function mapCurrencyAmount(currencyAmountArg: CurrencyAmountArg, centsPerBtc?: number): CurrencyMap;
100
+ declare function mapCurrencyAmount(currencyAmountArg: CurrencyAmountArg, unitsPerBtc?: number): CurrencyMap;
85
101
  declare const isCurrencyMap: (currencyMap: unknown) => currencyMap is CurrencyMap;
86
102
  declare const abbrCurrencyUnit: (unit: CurrencyUnitType) => "USD" | "BTC" | "SAT" | "MSAT" | "Unsupported CurrencyUnit";
87
103
  type FormatCurrencyStrOptions = {
@@ -241,4 +257,4 @@ declare function lsidToUUID(lsid: string): string;
241
257
  declare function isUint8Array(value: unknown): value is Uint8Array;
242
258
  declare function isObject(value: unknown): value is Record<string, unknown>;
243
259
 
244
- export { type ById as $, getErrorMsg as A, isErrorMsg as B, ConfigKeys as C, errorToJSON as D, bytesToHex as E, hexToBytes as F, getCurrentLocale as G, countryCodesToCurrencyCodes as H, type CurrencyLocales as I, type CurrencyCodes as J, localeToCurrencyCode as K, getLocalStorageConfigItem as L, getLocalStorageBoolean as M, setLocalStorageBoolean as N, deleteLocalStorageItem as O, clamp as P, linearInterpolate as Q, round as R, type SDKCurrencyAmountType as S, isNumber as T, pollUntil as U, sleep as V, lsidToUUID as W, isUint8Array as X, isObject as Y, type Maybe as Z, type ExpandRecursively as _, b64encode as a, type OmitTypename as a0, isType as a1, type DeepPartial as a2, type JSONLiteral as a3, type JSONType as a4, type JSONObject as a5, type NN as a6, notNullUndefined as a7, type PartialBy as a8, type Complete as a9, b64decode as b, createSha256Hash as c, defaultCurrencyCode as d, ensureArray as e, CurrencyUnit as f, type CurrencyUnitType as g, convertCurrencyAmountValue as h, convertCurrencyAmount as i, type CurrencyMap as j, type CurrencyAmountObj as k, type CurrencyAmountArg as l, isCurrencyAmountObj as m, isSDKCurrencyAmount as n, mapCurrencyAmount as o, isCurrencyMap as p, abbrCurrencyUnit as q, formatCurrencyStr as r, separateCurrencyStrParts as s, localeToCurrencySymbol as t, urlsafe_b64decode as u, isBrowser as v, isNode as w, isTest as x, isError as y, isErrorWithMessage as z };
260
+ export { isUint8Array as $, isTest as A, isError as B, ConfigKeys as C, type DeprecatedCurrencyAmountObj as D, isErrorWithMessage as E, getErrorMsg as F, isErrorMsg as G, errorToJSON as H, bytesToHex as I, hexToBytes as J, getCurrentLocale as K, countryCodesToCurrencyCodes as L, type CurrencyLocales as M, type CurrencyCodes as N, localeToCurrencyCode as O, getLocalStorageConfigItem as P, getLocalStorageBoolean as Q, setLocalStorageBoolean as R, type SDKCurrencyAmountType as S, deleteLocalStorageItem as T, clamp as U, linearInterpolate as V, round as W, isNumber as X, pollUntil as Y, sleep as Z, lsidToUUID as _, b64encode as a, isObject as a0, type Maybe as a1, type ExpandRecursively as a2, type ById as a3, type OmitTypename as a4, isType as a5, type DeepPartial as a6, type JSONLiteral as a7, type JSONType as a8, type JSONObject as a9, type NN as aa, notNullUndefined as ab, type PartialBy as ac, type Complete as ad, b64decode as b, createSha256Hash as c, defaultCurrencyCode as d, ensureArray as e, CurrencyUnit as f, type CurrencyUnitType as g, convertCurrencyAmountValue as h, convertCurrencyAmount as i, type CurrencyMap as j, type CurrencyAmountObj as k, type CurrencyAmountPreferenceObj as l, type CurrencyAmountArg as m, isDeprecatedCurrencyAmountObj as n, isCurrencyAmountObj as o, isCurrencyAmountPreferenceObj as p, isSDKCurrencyAmount as q, mapCurrencyAmount as r, isCurrencyMap as s, abbrCurrencyUnit as t, urlsafe_b64decode as u, formatCurrencyStr as v, separateCurrencyStrParts as w, localeToCurrencySymbol as x, isBrowser as y, isNode as z };
@@ -20,10 +20,11 @@ declare const CurrencyUnit: {
20
20
  readonly BITCOIN: "BITCOIN";
21
21
  readonly SATOSHI: "SATOSHI";
22
22
  readonly MILLISATOSHI: "MILLISATOSHI";
23
- readonly USD: "USD";
24
23
  readonly NANOBITCOIN: "NANOBITCOIN";
25
24
  readonly MICROBITCOIN: "MICROBITCOIN";
26
25
  readonly MILLIBITCOIN: "MILLIBITCOIN";
26
+ readonly USD: "USD";
27
+ readonly MXN: "MXN";
27
28
  readonly Bitcoin: "BITCOIN";
28
29
  readonly Microbitcoin: "MICROBITCOIN";
29
30
  readonly Millibitcoin: "MILLIBITCOIN";
@@ -31,6 +32,7 @@ declare const CurrencyUnit: {
31
32
  readonly Nanobitcoin: "NANOBITCOIN";
32
33
  readonly Satoshi: "SATOSHI";
33
34
  readonly Usd: "USD";
35
+ readonly Mxn: "MXN";
34
36
  };
35
37
  type CurrencyUnitType = (typeof CurrencyUnit)[keyof typeof CurrencyUnit];
36
38
  type SDKCurrencyAmountType = {
@@ -40,7 +42,7 @@ type SDKCurrencyAmountType = {
40
42
  preferredCurrencyValueRounded: number;
41
43
  preferredCurrencyValueApprox: number;
42
44
  };
43
- declare function convertCurrencyAmountValue(fromUnit: CurrencyUnitType, toUnit: CurrencyUnitType, amount: number, centsPerBtc?: number): number;
45
+ declare function convertCurrencyAmountValue(fromUnit: CurrencyUnitType, toUnit: CurrencyUnitType, amount: number, unitsPerBtc?: number): number;
44
46
  declare const convertCurrencyAmount: (from: SDKCurrencyAmountType, toUnit: CurrencyUnitType) => SDKCurrencyAmountType;
45
47
  type CurrencyMap = {
46
48
  sats: number;
@@ -53,6 +55,7 @@ type CurrencyMap = {
53
55
  [CurrencyUnit.MILLIBITCOIN]: number;
54
56
  [CurrencyUnit.NANOBITCOIN]: number;
55
57
  [CurrencyUnit.USD]: number;
58
+ [CurrencyUnit.MXN]: number;
56
59
  [CurrencyUnit.FUTURE_VALUE]: number;
57
60
  formatted: {
58
61
  sats: string;
@@ -65,6 +68,7 @@ type CurrencyMap = {
65
68
  [CurrencyUnit.MICROBITCOIN]: string;
66
69
  [CurrencyUnit.NANOBITCOIN]: string;
67
70
  [CurrencyUnit.USD]: string;
71
+ [CurrencyUnit.MXN]: string;
68
72
  [CurrencyUnit.FUTURE_VALUE]: string;
69
73
  };
70
74
  isZero: boolean;
@@ -73,15 +77,27 @@ type CurrencyMap = {
73
77
  isEqualTo: (other: CurrencyMap | CurrencyAmountObj | number) => boolean;
74
78
  type: "CurrencyMap";
75
79
  };
76
- type CurrencyAmountObj = {
80
+ type DeprecatedCurrencyAmountObj = {
77
81
  value?: number | string | null;
78
82
  unit?: CurrencyUnitType;
79
83
  __typename?: "CurrencyAmount" | undefined;
80
84
  };
81
- type CurrencyAmountArg = CurrencyAmountObj | SDKCurrencyAmountType | undefined | null;
85
+ type CurrencyAmountObj = {
86
+ original_value?: number | string | null;
87
+ original_unit?: CurrencyUnitType;
88
+ __typename?: "CurrencyAmount" | undefined;
89
+ };
90
+ type CurrencyAmountPreferenceObj = {
91
+ preferred_currency_unit?: CurrencyUnitType;
92
+ preferred_currency_value_rounded?: number | string | null;
93
+ __typename?: "CurrencyAmount" | undefined;
94
+ };
95
+ type CurrencyAmountArg = DeprecatedCurrencyAmountObj | CurrencyAmountObj | CurrencyAmountPreferenceObj | SDKCurrencyAmountType | undefined | null;
96
+ declare function isDeprecatedCurrencyAmountObj(arg: unknown): arg is DeprecatedCurrencyAmountObj;
82
97
  declare function isCurrencyAmountObj(arg: unknown): arg is CurrencyAmountObj;
98
+ declare function isCurrencyAmountPreferenceObj(arg: unknown): arg is CurrencyAmountPreferenceObj;
83
99
  declare function isSDKCurrencyAmount(arg: unknown): arg is SDKCurrencyAmountType;
84
- declare function mapCurrencyAmount(currencyAmountArg: CurrencyAmountArg, centsPerBtc?: number): CurrencyMap;
100
+ declare function mapCurrencyAmount(currencyAmountArg: CurrencyAmountArg, unitsPerBtc?: number): CurrencyMap;
85
101
  declare const isCurrencyMap: (currencyMap: unknown) => currencyMap is CurrencyMap;
86
102
  declare const abbrCurrencyUnit: (unit: CurrencyUnitType) => "USD" | "BTC" | "SAT" | "MSAT" | "Unsupported CurrencyUnit";
87
103
  type FormatCurrencyStrOptions = {
@@ -241,4 +257,4 @@ declare function lsidToUUID(lsid: string): string;
241
257
  declare function isUint8Array(value: unknown): value is Uint8Array;
242
258
  declare function isObject(value: unknown): value is Record<string, unknown>;
243
259
 
244
- export { type ById as $, getErrorMsg as A, isErrorMsg as B, ConfigKeys as C, errorToJSON as D, bytesToHex as E, hexToBytes as F, getCurrentLocale as G, countryCodesToCurrencyCodes as H, type CurrencyLocales as I, type CurrencyCodes as J, localeToCurrencyCode as K, getLocalStorageConfigItem as L, getLocalStorageBoolean as M, setLocalStorageBoolean as N, deleteLocalStorageItem as O, clamp as P, linearInterpolate as Q, round as R, type SDKCurrencyAmountType as S, isNumber as T, pollUntil as U, sleep as V, lsidToUUID as W, isUint8Array as X, isObject as Y, type Maybe as Z, type ExpandRecursively as _, b64encode as a, type OmitTypename as a0, isType as a1, type DeepPartial as a2, type JSONLiteral as a3, type JSONType as a4, type JSONObject as a5, type NN as a6, notNullUndefined as a7, type PartialBy as a8, type Complete as a9, b64decode as b, createSha256Hash as c, defaultCurrencyCode as d, ensureArray as e, CurrencyUnit as f, type CurrencyUnitType as g, convertCurrencyAmountValue as h, convertCurrencyAmount as i, type CurrencyMap as j, type CurrencyAmountObj as k, type CurrencyAmountArg as l, isCurrencyAmountObj as m, isSDKCurrencyAmount as n, mapCurrencyAmount as o, isCurrencyMap as p, abbrCurrencyUnit as q, formatCurrencyStr as r, separateCurrencyStrParts as s, localeToCurrencySymbol as t, urlsafe_b64decode as u, isBrowser as v, isNode as w, isTest as x, isError as y, isErrorWithMessage as z };
260
+ export { isUint8Array as $, isTest as A, isError as B, ConfigKeys as C, type DeprecatedCurrencyAmountObj as D, isErrorWithMessage as E, getErrorMsg as F, isErrorMsg as G, errorToJSON as H, bytesToHex as I, hexToBytes as J, getCurrentLocale as K, countryCodesToCurrencyCodes as L, type CurrencyLocales as M, type CurrencyCodes as N, localeToCurrencyCode as O, getLocalStorageConfigItem as P, getLocalStorageBoolean as Q, setLocalStorageBoolean as R, type SDKCurrencyAmountType as S, deleteLocalStorageItem as T, clamp as U, linearInterpolate as V, round as W, isNumber as X, pollUntil as Y, sleep as Z, lsidToUUID as _, b64encode as a, isObject as a0, type Maybe as a1, type ExpandRecursively as a2, type ById as a3, type OmitTypename as a4, isType as a5, type DeepPartial as a6, type JSONLiteral as a7, type JSONType as a8, type JSONObject as a9, type NN as aa, notNullUndefined as ab, type PartialBy as ac, type Complete as ad, b64decode as b, createSha256Hash as c, defaultCurrencyCode as d, ensureArray as e, CurrencyUnit as f, type CurrencyUnitType as g, convertCurrencyAmountValue as h, convertCurrencyAmount as i, type CurrencyMap as j, type CurrencyAmountObj as k, type CurrencyAmountPreferenceObj as l, type CurrencyAmountArg as m, isDeprecatedCurrencyAmountObj as n, isCurrencyAmountObj as o, isCurrencyAmountPreferenceObj as p, isSDKCurrencyAmount as q, mapCurrencyAmount as r, isCurrencyMap as s, abbrCurrencyUnit as t, urlsafe_b64decode as u, formatCurrencyStr as v, separateCurrencyStrParts as w, localeToCurrencySymbol as x, isBrowser as y, isNode as z };