@lightsparkdev/core 1.2.7 → 1.3.0

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,32 @@
1
1
  # @lightsparkdev/core
2
2
 
3
+ ## 1.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - b1f160b: - CJS + ESM improvements
8
+
9
+ - Updated `package.json` to provide separate CommonJS (`index.cjs`) and ES modules (`index.js`).
10
+ - Added an `exports` section to explicitly define import/require entry points.
11
+ - attw support
12
+
13
+ - Added a `.attw.json` file and introduced a `"package-types"` script (`yarn attw --pack .`) for detecting type issues.
14
+
15
+ - Expanded currency utilities
16
+
17
+ - Introduced `EUR` handling in `CurrencyUnit` and extended the conversion logic to accommodate more fiat/btc transformations.
18
+ - Added new helper methods like `isUmaCurrencyAmount` and `isRecord` to strengthen type checks and conversions.
19
+ - Updated `formatCurrencyStr()` to handle `UmaCurrencyAmount` and incorporate new format logic.
20
+
21
+ - Refined the `mapCurrencyAmount()` function and improved `formatCurrencyStr()` to handle short vs. full precision more flexibly.
22
+ - Revised sub‐paths (e.g. `./utils`) in `package.json` exports for both ESM and CJS.
23
+
24
+ ## 1.2.8
25
+
26
+ ### Patch Changes
27
+
28
+ - 47733a2: - Allow injecting a custom fetchImpl into the JS SDK. This is helpful for clients who need custom requesting logic, logging, etc.
29
+
3
30
  ## 1.2.7
4
31
 
5
32
  ### Patch Changes
@@ -408,6 +408,7 @@ var CurrencyUnit = {
408
408
  USD: "USD",
409
409
  MXN: "MXN",
410
410
  PHP: "PHP",
411
+ EUR: "EUR",
411
412
  Bitcoin: "BITCOIN",
412
413
  Microbitcoin: "MICROBITCOIN",
413
414
  Millibitcoin: "MILLIBITCOIN",
@@ -428,7 +429,8 @@ var standardUnitConversionObj = {
428
429
  /* Converting between two different fiat types is not currently supported */
429
430
  [CurrencyUnit.USD]: (v) => v,
430
431
  [CurrencyUnit.MXN]: (v) => v,
431
- [CurrencyUnit.PHP]: (v) => v
432
+ [CurrencyUnit.PHP]: (v) => v,
433
+ [CurrencyUnit.EUR]: (v) => v
432
434
  };
433
435
  var toBitcoinConversion = (v, unitsPerBtc = 1) => round(v * unitsPerBtc);
434
436
  var toMicrobitcoinConversion = (v, unitsPerBtc = 1) => round(v / 1e6 * unitsPerBtc);
@@ -446,7 +448,8 @@ var CONVERSION_MAP = {
446
448
  [CurrencyUnit.SATOSHI]: (v) => v * 1e8,
447
449
  [CurrencyUnit.USD]: toBitcoinConversion,
448
450
  [CurrencyUnit.MXN]: toBitcoinConversion,
449
- [CurrencyUnit.PHP]: toBitcoinConversion
451
+ [CurrencyUnit.PHP]: toBitcoinConversion,
452
+ [CurrencyUnit.EUR]: toBitcoinConversion
450
453
  },
451
454
  [CurrencyUnit.MICROBITCOIN]: {
452
455
  [CurrencyUnit.BITCOIN]: (v) => v / 1e6,
@@ -457,7 +460,8 @@ var CONVERSION_MAP = {
457
460
  [CurrencyUnit.SATOSHI]: (v) => v * 100,
458
461
  [CurrencyUnit.USD]: toMicrobitcoinConversion,
459
462
  [CurrencyUnit.MXN]: toMicrobitcoinConversion,
460
- [CurrencyUnit.PHP]: toMicrobitcoinConversion
463
+ [CurrencyUnit.PHP]: toMicrobitcoinConversion,
464
+ [CurrencyUnit.EUR]: toMicrobitcoinConversion
461
465
  },
462
466
  [CurrencyUnit.MILLIBITCOIN]: {
463
467
  [CurrencyUnit.BITCOIN]: (v) => v / 1e3,
@@ -468,7 +472,8 @@ var CONVERSION_MAP = {
468
472
  [CurrencyUnit.SATOSHI]: (v) => v * 1e5,
469
473
  [CurrencyUnit.USD]: toMillibitcoinConversion,
470
474
  [CurrencyUnit.MXN]: toMillibitcoinConversion,
471
- [CurrencyUnit.PHP]: toMillibitcoinConversion
475
+ [CurrencyUnit.PHP]: toMillibitcoinConversion,
476
+ [CurrencyUnit.EUR]: toMillibitcoinConversion
472
477
  },
473
478
  [CurrencyUnit.MILLISATOSHI]: {
474
479
  [CurrencyUnit.BITCOIN]: (v) => v / 1e11,
@@ -479,7 +484,8 @@ var CONVERSION_MAP = {
479
484
  [CurrencyUnit.SATOSHI]: (v) => v / 1e3,
480
485
  [CurrencyUnit.USD]: toMillisatoshiConversion,
481
486
  [CurrencyUnit.MXN]: toMillisatoshiConversion,
482
- [CurrencyUnit.PHP]: toMillisatoshiConversion
487
+ [CurrencyUnit.PHP]: toMillisatoshiConversion,
488
+ [CurrencyUnit.EUR]: toMillisatoshiConversion
483
489
  },
484
490
  [CurrencyUnit.NANOBITCOIN]: {
485
491
  [CurrencyUnit.BITCOIN]: (v) => v / 1e9,
@@ -490,7 +496,8 @@ var CONVERSION_MAP = {
490
496
  [CurrencyUnit.SATOSHI]: (v) => v / 10,
491
497
  [CurrencyUnit.USD]: toNanobitcoinConversion,
492
498
  [CurrencyUnit.MXN]: toNanobitcoinConversion,
493
- [CurrencyUnit.PHP]: toNanobitcoinConversion
499
+ [CurrencyUnit.PHP]: toNanobitcoinConversion,
500
+ [CurrencyUnit.EUR]: toNanobitcoinConversion
494
501
  },
495
502
  [CurrencyUnit.SATOSHI]: {
496
503
  [CurrencyUnit.BITCOIN]: (v) => v / 1e8,
@@ -501,11 +508,13 @@ var CONVERSION_MAP = {
501
508
  [CurrencyUnit.SATOSHI]: (v) => v,
502
509
  [CurrencyUnit.USD]: toSatoshiConversion,
503
510
  [CurrencyUnit.MXN]: toSatoshiConversion,
504
- [CurrencyUnit.PHP]: toSatoshiConversion
511
+ [CurrencyUnit.PHP]: toSatoshiConversion,
512
+ [CurrencyUnit.EUR]: toSatoshiConversion
505
513
  },
506
514
  [CurrencyUnit.USD]: standardUnitConversionObj,
507
515
  [CurrencyUnit.MXN]: standardUnitConversionObj,
508
- [CurrencyUnit.PHP]: standardUnitConversionObj
516
+ [CurrencyUnit.PHP]: standardUnitConversionObj,
517
+ [CurrencyUnit.EUR]: standardUnitConversionObj
509
518
  };
510
519
  function convertCurrencyAmountValue(fromUnit, toUnit, amount, unitsPerBtc = 1) {
511
520
  if (fromUnit === CurrencyUnit.FUTURE_VALUE || toUnit === CurrencyUnit.FUTURE_VALUE) {
@@ -539,6 +548,9 @@ var convertCurrencyAmount = (from, toUnit) => {
539
548
  function isCurrencyAmountInputObj(arg) {
540
549
  return typeof arg === "object" && arg !== null && "value" in arg && (typeof arg.value === "number" || typeof arg.value === "string" || arg.value === null) && "unit" in arg && typeof arg.unit === "string";
541
550
  }
551
+ function isUmaCurrencyAmount(arg) {
552
+ return typeof arg === "object" && arg !== null && "value" in arg && typeof arg.value === "number" && "currency" in arg && typeof arg.currency === "object" && typeof arg.currency.code === "string" && typeof arg.currency.symbol === "string" && typeof arg.currency.name === "string" && typeof arg.currency.decimals === "number";
553
+ }
542
554
  function isDeprecatedCurrencyAmountObj(arg) {
543
555
  return typeof arg === "object" && arg !== null && "value" in arg && "unit" in arg;
544
556
  }
@@ -585,6 +597,7 @@ function convertCurrencyAmountValues(fromUnit, amount, unitsPerBtc = 1, conversi
585
597
  usd: CurrencyUnit.USD,
586
598
  mxn: CurrencyUnit.MXN,
587
599
  php: CurrencyUnit.PHP,
600
+ eur: CurrencyUnit.EUR,
588
601
  mibtc: CurrencyUnit.MICROBITCOIN,
589
602
  mlbtc: CurrencyUnit.MILLIBITCOIN,
590
603
  nbtc: CurrencyUnit.NANOBITCOIN
@@ -623,7 +636,7 @@ function getPreferredConversionOverride(currencyAmountArg) {
623
636
  function mapCurrencyAmount(currencyAmountArg, unitsPerBtc = 1) {
624
637
  const { value, unit } = getCurrencyAmount(currencyAmountArg);
625
638
  const conversionOverride = getPreferredConversionOverride(currencyAmountArg);
626
- const { sats, msats, btc, usd, mxn, php, mibtc, mlbtc, nbtc } = convertCurrencyAmountValues(unit, value, unitsPerBtc, conversionOverride);
639
+ const { sats, msats, btc, usd, mxn, php, mibtc, mlbtc, nbtc, eur } = convertCurrencyAmountValues(unit, value, unitsPerBtc, conversionOverride);
627
640
  const mapWithCurrencyUnits = {
628
641
  [CurrencyUnit.BITCOIN]: btc,
629
642
  [CurrencyUnit.SATOSHI]: sats,
@@ -631,6 +644,7 @@ function mapCurrencyAmount(currencyAmountArg, unitsPerBtc = 1) {
631
644
  [CurrencyUnit.USD]: usd,
632
645
  [CurrencyUnit.MXN]: mxn,
633
646
  [CurrencyUnit.PHP]: php,
647
+ [CurrencyUnit.EUR]: eur,
634
648
  [CurrencyUnit.MICROBITCOIN]: mibtc,
635
649
  [CurrencyUnit.MILLIBITCOIN]: mlbtc,
636
650
  [CurrencyUnit.NANOBITCOIN]: nbtc,
@@ -672,6 +686,10 @@ function mapCurrencyAmount(currencyAmountArg, unitsPerBtc = 1) {
672
686
  value: php,
673
687
  unit: CurrencyUnit.PHP
674
688
  }),
689
+ [CurrencyUnit.EUR]: formatCurrencyStr({
690
+ value: eur,
691
+ unit: CurrencyUnit.EUR
692
+ }),
675
693
  [CurrencyUnit.FUTURE_VALUE]: "-"
676
694
  }
677
695
  };
@@ -736,6 +754,8 @@ var abbrCurrencyUnit = (unit) => {
736
754
  return "MXN";
737
755
  case CurrencyUnit.PHP:
738
756
  return "PHP";
757
+ case CurrencyUnit.EUR:
758
+ return "EUR";
739
759
  }
740
760
  return "Unsupported CurrencyUnit";
741
761
  };
@@ -751,16 +771,27 @@ function formatCurrencyStr(amount, options) {
751
771
  ...defaultOptions,
752
772
  ...options
753
773
  };
754
- const currencyAmount = getCurrencyAmount(amount);
755
- let { value: num } = currencyAmount;
756
- const { unit } = currencyAmount;
757
- const centCurrencies = [
758
- CurrencyUnit.USD,
759
- CurrencyUnit.MXN,
760
- CurrencyUnit.PHP
761
- ];
762
- if (centCurrencies.includes(unit)) {
763
- num = num / 100;
774
+ let num;
775
+ let unit;
776
+ if (isUmaCurrencyAmount(amount)) {
777
+ num = amount.value;
778
+ unit = amount.currency.code;
779
+ if (amount.currency.decimals > 0) {
780
+ num = amount.value / Math.pow(10, amount.currency.decimals);
781
+ }
782
+ } else {
783
+ const currencyAmount = getCurrencyAmount(amount);
784
+ num = currencyAmount.value;
785
+ unit = currencyAmount.unit;
786
+ const centCurrencies = [
787
+ CurrencyUnit.USD,
788
+ CurrencyUnit.MXN,
789
+ CurrencyUnit.PHP,
790
+ CurrencyUnit.EUR
791
+ ];
792
+ if (centCurrencies.includes(unit)) {
793
+ num = num / 100;
794
+ }
764
795
  }
765
796
  function getDefaultMaxFractionDigits(defaultDigits, fullPrecisionDigits) {
766
797
  let digits = defaultDigits;
@@ -773,21 +804,22 @@ function formatCurrencyStr(amount, options) {
773
804
  }
774
805
  return digits;
775
806
  }
776
- const symbol = !showBtcSymbol ? "" : unit === CurrencyUnit.BITCOIN ? "\uE903" : unit === CurrencyUnit.SATOSHI ? "\uE902" : "";
807
+ const symbol = !showBtcSymbol ? "" : unit === CurrencyUnit.BITCOIN ? "\uE903" : unit === CurrencyUnit.SATOSHI || unit === abbrCurrencyUnit(CurrencyUnit.SATOSHI) ? "\uE902" : "";
777
808
  const currentLocale = getCurrentLocale();
778
- let formattedStr = "";
779
- switch (unit) {
780
- case CurrencyUnit.MXN:
781
- case CurrencyUnit.USD:
782
- case CurrencyUnit.PHP:
783
- formattedStr = num.toLocaleString(currentLocale, {
809
+ function isFormattableFiatCurrencyCode(currencyCode) {
810
+ try {
811
+ new Intl.NumberFormat(currentLocale, {
784
812
  style: "currency",
785
- currency: unit,
786
- currencyDisplay: "narrowSymbol",
787
- notation: compact ? "compact" : void 0,
788
- maximumFractionDigits: getDefaultMaxFractionDigits(2, 2)
813
+ currency: currencyCode
789
814
  });
790
- break;
815
+ return true;
816
+ } catch (e) {
817
+ return false;
818
+ }
819
+ }
820
+ let formattedStr = "";
821
+ let forceAppendUnits = false;
822
+ switch (unit) {
791
823
  case CurrencyUnit.BITCOIN:
792
824
  formattedStr = `${symbol}${num.toLocaleString(currentLocale, {
793
825
  notation: compact ? "compact" : void 0,
@@ -795,6 +827,7 @@ function formatCurrencyStr(amount, options) {
795
827
  })}`;
796
828
  break;
797
829
  case CurrencyUnit.SATOSHI:
830
+ case abbrCurrencyUnit(CurrencyUnit.SATOSHI):
798
831
  formattedStr = `${symbol}${num.toLocaleString(currentLocale, {
799
832
  notation: compact ? "compact" : void 0,
800
833
  maximumFractionDigits: getDefaultMaxFractionDigits(0, 3)
@@ -804,21 +837,35 @@ function formatCurrencyStr(amount, options) {
804
837
  case CurrencyUnit.MICROBITCOIN:
805
838
  case CurrencyUnit.MILLIBITCOIN:
806
839
  case CurrencyUnit.NANOBITCOIN:
807
- default:
808
840
  formattedStr = `${symbol}${num.toLocaleString(currentLocale, {
809
841
  notation: compact ? "compact" : void 0,
810
842
  maximumFractionDigits: getDefaultMaxFractionDigits(0, 0)
811
843
  })}`;
844
+ break;
845
+ default:
846
+ if (isFormattableFiatCurrencyCode(unit)) {
847
+ formattedStr = num.toLocaleString(currentLocale, {
848
+ style: "currency",
849
+ currency: unit,
850
+ currencyDisplay: "narrowSymbol",
851
+ notation: compact ? "compact" : void 0,
852
+ maximumFractionDigits: getDefaultMaxFractionDigits(2, 2)
853
+ });
854
+ } else {
855
+ formattedStr = `${num}`;
856
+ forceAppendUnits = true;
857
+ }
858
+ break;
812
859
  }
813
- if (options?.appendUnits) {
860
+ if (options?.appendUnits || forceAppendUnits) {
814
861
  const localeCurrencyCode = localeToCurrencyCode(currentLocale);
815
- if (unit === localeCurrencyCode && !options.appendUnits.showForCurrentLocaleUnit) {
862
+ if (unit === localeCurrencyCode && options?.appendUnits && !options.appendUnits.showForCurrentLocaleUnit) {
816
863
  return formattedStr;
817
864
  }
818
- const unitStr = abbrCurrencyUnit(unit);
819
- const unitSuffix = options.appendUnits.plural && num > 1 ? "s" : "";
865
+ const unitStr = isUmaCurrencyAmount(amount) ? amount.currency.code : abbrCurrencyUnit(unit);
866
+ const unitSuffix = options?.appendUnits?.plural && num > 1 ? "s" : "";
820
867
  const unitStrWithSuffix = `${unitStr}${unitSuffix}`;
821
- formattedStr += ` ${options.appendUnits.lowercase ? unitStrWithSuffix.toLowerCase() : unitStrWithSuffix}`;
868
+ formattedStr += ` ${options?.appendUnits?.lowercase ? unitStrWithSuffix.toLowerCase() : unitStrWithSuffix}`;
822
869
  }
823
870
  return formattedStr;
824
871
  }
@@ -1043,6 +1090,9 @@ var isType = (typename) => (node) => {
1043
1090
  function notNullUndefined(value) {
1044
1091
  return value !== null && value !== void 0;
1045
1092
  }
1093
+ function isRecord(value) {
1094
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1095
+ }
1046
1096
 
1047
1097
  export {
1048
1098
  LightsparkException_default,
@@ -1068,6 +1118,7 @@ export {
1068
1118
  convertCurrencyAmountValue,
1069
1119
  convertCurrencyAmount,
1070
1120
  isCurrencyAmountInputObj,
1121
+ isUmaCurrencyAmount,
1071
1122
  isDeprecatedCurrencyAmountObj,
1072
1123
  isCurrencyAmountObj,
1073
1124
  isCurrencyAmountPreferenceObj,
@@ -1094,7 +1145,8 @@ export {
1094
1145
  isUint8Array,
1095
1146
  isObject2 as isObject,
1096
1147
  isType,
1097
- notNullUndefined
1148
+ notNullUndefined,
1149
+ isRecord
1098
1150
  };
1099
1151
  /*! Bundled license information:
1100
1152
 
@@ -26,6 +26,7 @@ declare const CurrencyUnit: {
26
26
  readonly USD: "USD";
27
27
  readonly MXN: "MXN";
28
28
  readonly PHP: "PHP";
29
+ readonly EUR: "EUR";
29
30
  readonly Bitcoin: "BITCOIN";
30
31
  readonly Microbitcoin: "MICROBITCOIN";
31
32
  readonly Millibitcoin: "MILLIBITCOIN";
@@ -59,6 +60,7 @@ type CurrencyMap = {
59
60
  [CurrencyUnit.USD]: number;
60
61
  [CurrencyUnit.MXN]: number;
61
62
  [CurrencyUnit.PHP]: number;
63
+ [CurrencyUnit.EUR]: number;
62
64
  [CurrencyUnit.FUTURE_VALUE]: number;
63
65
  formatted: {
64
66
  sats: string;
@@ -73,6 +75,7 @@ type CurrencyMap = {
73
75
  [CurrencyUnit.USD]: string;
74
76
  [CurrencyUnit.MXN]: string;
75
77
  [CurrencyUnit.PHP]: string;
78
+ [CurrencyUnit.EUR]: string;
76
79
  [CurrencyUnit.FUTURE_VALUE]: string;
77
80
  };
78
81
  isZero: boolean;
@@ -85,6 +88,19 @@ type CurrencyAmountInputObj = {
85
88
  value: number | string | null;
86
89
  unit: CurrencyUnitType;
87
90
  };
91
+ /**
92
+ * UMA has flexible currency types which contain details needed to render amounts.
93
+ */
94
+ type UmaCurrency = {
95
+ code: string;
96
+ symbol: string;
97
+ decimals: number;
98
+ name: string;
99
+ };
100
+ type UmaCurrencyAmount = {
101
+ value: number;
102
+ currency: UmaCurrency;
103
+ };
88
104
  type DeprecatedCurrencyAmountObj = {
89
105
  value?: number;
90
106
  unit?: CurrencyUnitType;
@@ -104,6 +120,7 @@ type CurrencyAmountPreferenceObj = {
104
120
  };
105
121
  type CurrencyAmountArg = CurrencyAmountInputObj | DeprecatedCurrencyAmountObj | CurrencyAmountObj | CurrencyAmountPreferenceObj | SDKCurrencyAmountType | undefined | null;
106
122
  declare function isCurrencyAmountInputObj(arg: unknown): arg is CurrencyAmountInputObj;
123
+ declare function isUmaCurrencyAmount(arg: unknown): arg is UmaCurrencyAmount;
107
124
  declare function isDeprecatedCurrencyAmountObj(arg: unknown): arg is DeprecatedCurrencyAmountObj;
108
125
  declare function isCurrencyAmountObj(arg: unknown): arg is CurrencyAmountObj;
109
126
  declare function isCurrencyAmountPreferenceObj(arg: unknown): arg is CurrencyAmountPreferenceObj;
@@ -114,7 +131,7 @@ declare function getCurrencyAmount(currencyAmountArg: CurrencyAmountArg): {
114
131
  };
115
132
  declare function mapCurrencyAmount(currencyAmountArg: CurrencyAmountArg, unitsPerBtc?: number): CurrencyMap;
116
133
  declare const isCurrencyMap: (currencyMap: unknown) => currencyMap is CurrencyMap;
117
- declare const abbrCurrencyUnit: (unit: CurrencyUnitType) => "USD" | "MXN" | "PHP" | "BTC" | "SAT" | "MSAT" | "mBTC" | "μBTC" | "Unsupported CurrencyUnit";
134
+ declare const abbrCurrencyUnit: (unit: CurrencyUnitType) => "EUR" | "USD" | "MXN" | "PHP" | "BTC" | "SAT" | "MSAT" | "mBTC" | "μBTC" | "Unsupported CurrencyUnit";
118
135
  type AppendUnitsOptions = {
119
136
  plural?: boolean | undefined;
120
137
  lowercase?: boolean | undefined;
@@ -126,7 +143,7 @@ type FormatCurrencyStrOptions = {
126
143
  showBtcSymbol?: boolean | undefined;
127
144
  appendUnits?: AppendUnitsOptions | undefined;
128
145
  };
129
- declare function formatCurrencyStr(amount: CurrencyAmountArg, options?: FormatCurrencyStrOptions): string;
146
+ declare function formatCurrencyStr(amount: CurrencyAmountArg | UmaCurrencyAmount, options?: FormatCurrencyStrOptions): string;
130
147
  declare function separateCurrencyStrParts(currencyStr: string): {
131
148
  symbol: string;
132
149
  amount: string;
@@ -150,6 +167,9 @@ declare const isType: <T extends string>(typename: T) => <N extends {
150
167
  }>(node: N | undefined | null) => node is Extract<N, {
151
168
  __typename: T;
152
169
  }>;
170
+ type ExtractByTypename<T, N extends string> = T extends {
171
+ __typename: N;
172
+ } ? T : never;
153
173
  type DeepPartial<T> = T extends object ? {
154
174
  [P in keyof T]?: DeepPartial<T[P]>;
155
175
  } : T;
@@ -175,6 +195,7 @@ type Complete<T> = {
175
195
  type RequiredKeys<T> = {
176
196
  [K in keyof T]-?: Record<string, never> extends Pick<T, K> ? never : K;
177
197
  }[keyof T];
198
+ declare function isRecord(value: unknown): value is Record<string, unknown>;
178
199
 
179
200
  declare const isError: (e: unknown) => e is Error;
180
201
  type ErrorWithMessage = {
@@ -287,4 +308,4 @@ declare function lsidToUUID(lsid: string): string;
287
308
  declare function isUint8Array(value: unknown): value is Uint8Array;
288
309
  declare function isObject(value: unknown): value is Record<string, unknown>;
289
310
 
290
- export { isNumber as $, type AppendUnitsOptions as A, localeToCurrencySymbol as B, ConfigKeys as C, type DeprecatedCurrencyAmountObj as D, isBrowser as E, isNode as F, isTest as G, isError as H, isErrorWithMessage as I, getErrorMsg as J, isErrorMsg as K, errorToJSON as L, bytesToHex as M, hexToBytes as N, getCurrentLocale as O, countryCodesToCurrencyCodes as P, type CurrencyLocales as Q, type CurrencyCodes as R, type SDKCurrencyAmountType as S, localeToCurrencyCode as T, getLocalStorageConfigItem as U, getLocalStorageBoolean as V, setLocalStorageBoolean as W, deleteLocalStorageItem as X, clamp as Y, linearInterpolate as Z, round as _, b64encode as a, pollUntil as a0, sleep as a1, lsidToUUID as a2, isUint8Array as a3, isObject as a4, type Maybe as a5, type ExpandRecursively as a6, type ById as a7, type OmitTypename as a8, isType as a9, type DeepPartial as aa, type JSONLiteral as ab, type JSONType as ac, type JSONObject as ad, type NN as ae, notNullUndefined as af, type PartialBy as ag, type Complete as ah, type RequiredKeys as ai, 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 CurrencyAmountInputObj as k, type CurrencyAmountObj as l, type CurrencyAmountPreferenceObj as m, type CurrencyAmountArg as n, isCurrencyAmountInputObj as o, isDeprecatedCurrencyAmountObj as p, isCurrencyAmountObj as q, isCurrencyAmountPreferenceObj as r, isSDKCurrencyAmount as s, getCurrencyAmount as t, urlsafe_b64decode as u, mapCurrencyAmount as v, isCurrencyMap as w, abbrCurrencyUnit as x, formatCurrencyStr as y, separateCurrencyStrParts as z };
311
+ export { clamp as $, type AppendUnitsOptions as A, formatCurrencyStr as B, ConfigKeys as C, type DeprecatedCurrencyAmountObj as D, separateCurrencyStrParts as E, localeToCurrencySymbol as F, isBrowser as G, isNode as H, isTest as I, isError as J, isErrorWithMessage as K, getErrorMsg as L, isErrorMsg as M, errorToJSON as N, bytesToHex as O, hexToBytes as P, getCurrentLocale as Q, countryCodesToCurrencyCodes as R, type SDKCurrencyAmountType as S, type CurrencyLocales as T, type UmaCurrency as U, type CurrencyCodes as V, localeToCurrencyCode as W, getLocalStorageConfigItem as X, getLocalStorageBoolean as Y, setLocalStorageBoolean as Z, deleteLocalStorageItem as _, b64encode as a, linearInterpolate as a0, round as a1, isNumber as a2, pollUntil as a3, sleep as a4, lsidToUUID as a5, isUint8Array as a6, isObject as a7, type Maybe as a8, type ExpandRecursively as a9, type ById as aa, type OmitTypename as ab, isType as ac, type ExtractByTypename as ad, type DeepPartial as ae, type JSONLiteral as af, type JSONType as ag, type JSONObject as ah, type NN as ai, notNullUndefined as aj, type PartialBy as ak, type Complete as al, type RequiredKeys as am, isRecord as an, 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 CurrencyAmountInputObj as k, type UmaCurrencyAmount as l, type CurrencyAmountObj as m, type CurrencyAmountPreferenceObj as n, type CurrencyAmountArg as o, isCurrencyAmountInputObj as p, isUmaCurrencyAmount as q, isDeprecatedCurrencyAmountObj as r, isCurrencyAmountObj as s, isCurrencyAmountPreferenceObj as t, urlsafe_b64decode as u, isSDKCurrencyAmount as v, getCurrencyAmount as w, mapCurrencyAmount as x, isCurrencyMap as y, abbrCurrencyUnit as z };
@@ -26,6 +26,7 @@ declare const CurrencyUnit: {
26
26
  readonly USD: "USD";
27
27
  readonly MXN: "MXN";
28
28
  readonly PHP: "PHP";
29
+ readonly EUR: "EUR";
29
30
  readonly Bitcoin: "BITCOIN";
30
31
  readonly Microbitcoin: "MICROBITCOIN";
31
32
  readonly Millibitcoin: "MILLIBITCOIN";
@@ -59,6 +60,7 @@ type CurrencyMap = {
59
60
  [CurrencyUnit.USD]: number;
60
61
  [CurrencyUnit.MXN]: number;
61
62
  [CurrencyUnit.PHP]: number;
63
+ [CurrencyUnit.EUR]: number;
62
64
  [CurrencyUnit.FUTURE_VALUE]: number;
63
65
  formatted: {
64
66
  sats: string;
@@ -73,6 +75,7 @@ type CurrencyMap = {
73
75
  [CurrencyUnit.USD]: string;
74
76
  [CurrencyUnit.MXN]: string;
75
77
  [CurrencyUnit.PHP]: string;
78
+ [CurrencyUnit.EUR]: string;
76
79
  [CurrencyUnit.FUTURE_VALUE]: string;
77
80
  };
78
81
  isZero: boolean;
@@ -85,6 +88,19 @@ type CurrencyAmountInputObj = {
85
88
  value: number | string | null;
86
89
  unit: CurrencyUnitType;
87
90
  };
91
+ /**
92
+ * UMA has flexible currency types which contain details needed to render amounts.
93
+ */
94
+ type UmaCurrency = {
95
+ code: string;
96
+ symbol: string;
97
+ decimals: number;
98
+ name: string;
99
+ };
100
+ type UmaCurrencyAmount = {
101
+ value: number;
102
+ currency: UmaCurrency;
103
+ };
88
104
  type DeprecatedCurrencyAmountObj = {
89
105
  value?: number;
90
106
  unit?: CurrencyUnitType;
@@ -104,6 +120,7 @@ type CurrencyAmountPreferenceObj = {
104
120
  };
105
121
  type CurrencyAmountArg = CurrencyAmountInputObj | DeprecatedCurrencyAmountObj | CurrencyAmountObj | CurrencyAmountPreferenceObj | SDKCurrencyAmountType | undefined | null;
106
122
  declare function isCurrencyAmountInputObj(arg: unknown): arg is CurrencyAmountInputObj;
123
+ declare function isUmaCurrencyAmount(arg: unknown): arg is UmaCurrencyAmount;
107
124
  declare function isDeprecatedCurrencyAmountObj(arg: unknown): arg is DeprecatedCurrencyAmountObj;
108
125
  declare function isCurrencyAmountObj(arg: unknown): arg is CurrencyAmountObj;
109
126
  declare function isCurrencyAmountPreferenceObj(arg: unknown): arg is CurrencyAmountPreferenceObj;
@@ -114,7 +131,7 @@ declare function getCurrencyAmount(currencyAmountArg: CurrencyAmountArg): {
114
131
  };
115
132
  declare function mapCurrencyAmount(currencyAmountArg: CurrencyAmountArg, unitsPerBtc?: number): CurrencyMap;
116
133
  declare const isCurrencyMap: (currencyMap: unknown) => currencyMap is CurrencyMap;
117
- declare const abbrCurrencyUnit: (unit: CurrencyUnitType) => "USD" | "MXN" | "PHP" | "BTC" | "SAT" | "MSAT" | "mBTC" | "μBTC" | "Unsupported CurrencyUnit";
134
+ declare const abbrCurrencyUnit: (unit: CurrencyUnitType) => "EUR" | "USD" | "MXN" | "PHP" | "BTC" | "SAT" | "MSAT" | "mBTC" | "μBTC" | "Unsupported CurrencyUnit";
118
135
  type AppendUnitsOptions = {
119
136
  plural?: boolean | undefined;
120
137
  lowercase?: boolean | undefined;
@@ -126,7 +143,7 @@ type FormatCurrencyStrOptions = {
126
143
  showBtcSymbol?: boolean | undefined;
127
144
  appendUnits?: AppendUnitsOptions | undefined;
128
145
  };
129
- declare function formatCurrencyStr(amount: CurrencyAmountArg, options?: FormatCurrencyStrOptions): string;
146
+ declare function formatCurrencyStr(amount: CurrencyAmountArg | UmaCurrencyAmount, options?: FormatCurrencyStrOptions): string;
130
147
  declare function separateCurrencyStrParts(currencyStr: string): {
131
148
  symbol: string;
132
149
  amount: string;
@@ -150,6 +167,9 @@ declare const isType: <T extends string>(typename: T) => <N extends {
150
167
  }>(node: N | undefined | null) => node is Extract<N, {
151
168
  __typename: T;
152
169
  }>;
170
+ type ExtractByTypename<T, N extends string> = T extends {
171
+ __typename: N;
172
+ } ? T : never;
153
173
  type DeepPartial<T> = T extends object ? {
154
174
  [P in keyof T]?: DeepPartial<T[P]>;
155
175
  } : T;
@@ -175,6 +195,7 @@ type Complete<T> = {
175
195
  type RequiredKeys<T> = {
176
196
  [K in keyof T]-?: Record<string, never> extends Pick<T, K> ? never : K;
177
197
  }[keyof T];
198
+ declare function isRecord(value: unknown): value is Record<string, unknown>;
178
199
 
179
200
  declare const isError: (e: unknown) => e is Error;
180
201
  type ErrorWithMessage = {
@@ -287,4 +308,4 @@ declare function lsidToUUID(lsid: string): string;
287
308
  declare function isUint8Array(value: unknown): value is Uint8Array;
288
309
  declare function isObject(value: unknown): value is Record<string, unknown>;
289
310
 
290
- export { isNumber as $, type AppendUnitsOptions as A, localeToCurrencySymbol as B, ConfigKeys as C, type DeprecatedCurrencyAmountObj as D, isBrowser as E, isNode as F, isTest as G, isError as H, isErrorWithMessage as I, getErrorMsg as J, isErrorMsg as K, errorToJSON as L, bytesToHex as M, hexToBytes as N, getCurrentLocale as O, countryCodesToCurrencyCodes as P, type CurrencyLocales as Q, type CurrencyCodes as R, type SDKCurrencyAmountType as S, localeToCurrencyCode as T, getLocalStorageConfigItem as U, getLocalStorageBoolean as V, setLocalStorageBoolean as W, deleteLocalStorageItem as X, clamp as Y, linearInterpolate as Z, round as _, b64encode as a, pollUntil as a0, sleep as a1, lsidToUUID as a2, isUint8Array as a3, isObject as a4, type Maybe as a5, type ExpandRecursively as a6, type ById as a7, type OmitTypename as a8, isType as a9, type DeepPartial as aa, type JSONLiteral as ab, type JSONType as ac, type JSONObject as ad, type NN as ae, notNullUndefined as af, type PartialBy as ag, type Complete as ah, type RequiredKeys as ai, 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 CurrencyAmountInputObj as k, type CurrencyAmountObj as l, type CurrencyAmountPreferenceObj as m, type CurrencyAmountArg as n, isCurrencyAmountInputObj as o, isDeprecatedCurrencyAmountObj as p, isCurrencyAmountObj as q, isCurrencyAmountPreferenceObj as r, isSDKCurrencyAmount as s, getCurrencyAmount as t, urlsafe_b64decode as u, mapCurrencyAmount as v, isCurrencyMap as w, abbrCurrencyUnit as x, formatCurrencyStr as y, separateCurrencyStrParts as z };
311
+ export { clamp as $, type AppendUnitsOptions as A, formatCurrencyStr as B, ConfigKeys as C, type DeprecatedCurrencyAmountObj as D, separateCurrencyStrParts as E, localeToCurrencySymbol as F, isBrowser as G, isNode as H, isTest as I, isError as J, isErrorWithMessage as K, getErrorMsg as L, isErrorMsg as M, errorToJSON as N, bytesToHex as O, hexToBytes as P, getCurrentLocale as Q, countryCodesToCurrencyCodes as R, type SDKCurrencyAmountType as S, type CurrencyLocales as T, type UmaCurrency as U, type CurrencyCodes as V, localeToCurrencyCode as W, getLocalStorageConfigItem as X, getLocalStorageBoolean as Y, setLocalStorageBoolean as Z, deleteLocalStorageItem as _, b64encode as a, linearInterpolate as a0, round as a1, isNumber as a2, pollUntil as a3, sleep as a4, lsidToUUID as a5, isUint8Array as a6, isObject as a7, type Maybe as a8, type ExpandRecursively as a9, type ById as aa, type OmitTypename as ab, isType as ac, type ExtractByTypename as ad, type DeepPartial as ae, type JSONLiteral as af, type JSONType as ag, type JSONObject as ah, type NN as ai, notNullUndefined as aj, type PartialBy as ak, type Complete as al, type RequiredKeys as am, isRecord as an, 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 CurrencyAmountInputObj as k, type UmaCurrencyAmount as l, type CurrencyAmountObj as m, type CurrencyAmountPreferenceObj as n, type CurrencyAmountArg as o, isCurrencyAmountInputObj as p, isUmaCurrencyAmount as q, isDeprecatedCurrencyAmountObj as r, isCurrencyAmountObj as s, isCurrencyAmountPreferenceObj as t, urlsafe_b64decode as u, isSDKCurrencyAmount as v, getCurrencyAmount as w, mapCurrencyAmount as x, isCurrencyMap as y, abbrCurrencyUnit as z };