@oasisprotocol/privana-sdk 0.5.8 → 0.5.10

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.
@@ -2878,15 +2878,16 @@ function cloneAllowance(allowance) {
2878
2878
  function cn(...inputs) {
2879
2879
  return tailwindMerge.twMerge(clsx.clsx(inputs));
2880
2880
  }
2881
- function formatTokenAmount(amount, decimals = 18) {
2881
+ function formatTokenAmount(amount, decimals = 18, maxDecimals = 6) {
2882
2882
  const value = typeof amount === "string" ? BigInt(amount) : amount;
2883
- const divisor = BigInt(10 ** decimals);
2883
+ const divisor = 10n ** BigInt(decimals);
2884
2884
  const integerPart = value / divisor;
2885
2885
  const fractionalPart = value % divisor;
2886
2886
  const fractionalStr = fractionalPart.toString().padStart(decimals, "0");
2887
- const twoDecimals = fractionalStr.slice(0, 2).padEnd(2, "0");
2887
+ const shown = fractionalStr.slice(0, Math.max(2, Math.min(maxDecimals, decimals)));
2888
+ const trimmed = shown.replace(/0+$/, "").padEnd(2, "0");
2888
2889
  const integerWithSpaces = integerPart.toString().replace(/\B(?=(\d{3})+(?!\d))/g, "\u2009");
2889
- return `${integerWithSpaces}.${twoDecimals}`;
2890
+ return `${integerWithSpaces}.${trimmed}`;
2890
2891
  }
2891
2892
  function parseTokenAmount(amount, decimals = 18) {
2892
2893
  const sanitized = amount.replace(/[\s\u2009]/g, "").replace(/,/g, ".");
@@ -6162,5 +6163,5 @@ exports.useSafePrivanaContext = useSafePrivanaContext;
6162
6163
  exports.useSiweAuth = useSiweAuth;
6163
6164
  exports.useTransakOnRamp = useTransakOnRamp;
6164
6165
  exports.waitForTransactionReceipt = waitForTransactionReceipt;
6165
- //# sourceMappingURL=chunk-EXFISDHQ.cjs.map
6166
- //# sourceMappingURL=chunk-EXFISDHQ.cjs.map
6166
+ //# sourceMappingURL=chunk-KCXYYUUG.cjs.map
6167
+ //# sourceMappingURL=chunk-KCXYYUUG.cjs.map