@provex/react 1.6.2 → 1.7.0-rc.20260522201545.020a3eb

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/dist/index.cjs CHANGED
@@ -921,7 +921,9 @@ var ProveXClient = class {
921
921
  let errorMessage = `Attestation error: ${res.status}`;
922
922
  try {
923
923
  const errorJson = await res.json();
924
- if (errorJson.message) errorMessage = errorJson.message;
924
+ if (errorJson.details?.message) errorMessage = errorJson.details.message;
925
+ else if (errorJson.message) errorMessage = errorJson.message;
926
+ else if (errorJson.error) errorMessage = errorJson.error;
925
927
  } catch {
926
928
  }
927
929
  return {
@@ -1215,6 +1217,7 @@ function useReputationLimits({
1215
1217
  chainId,
1216
1218
  selectedPaymentMethod,
1217
1219
  tier,
1220
+ decimals,
1218
1221
  amountInInt,
1219
1222
  cooldownEndsAt
1220
1223
  }) {
@@ -1247,19 +1250,20 @@ function useReputationLimits({
1247
1250
  return reputation.getCooldownHours({ tier, providerKey: selectedPaymentMethod });
1248
1251
  }, [hasLimits, tier, selectedPaymentMethod]);
1249
1252
  const effectiveCap = react.useMemo(() => {
1250
- return reputation.getEffectiveCap({ tier, providerKey: selectedPaymentMethod });
1251
- }, [hasLimits, tier, selectedPaymentMethod]);
1253
+ return reputation.getEffectiveCap({ tier, providerKey: selectedPaymentMethod, decimals });
1254
+ }, [hasLimits, tier, selectedPaymentMethod, decimals]);
1252
1255
  const amountExceedsCap = react.useMemo(() => {
1253
1256
  if (effectiveCap === null) return false;
1254
1257
  if (!amountInInt) return false;
1255
- const amountUsd = Number(amountInInt) / 1e6;
1256
- return amountUsd > effectiveCap;
1258
+ return amountInInt > effectiveCap;
1257
1259
  }, [effectiveCap, amountInInt]);
1258
1260
  const capExceededMessage = react.useMemo(() => {
1259
1261
  if (!amountExceedsCap || effectiveCap === null) return null;
1262
+ if (effectiveCap === reputation.UNLIMITED_CAP_BASE_UNITS) return null;
1263
+ const capUsd = reputation.getEffectiveCapDisplayUsd(effectiveCap, decimals) ?? 0;
1260
1264
  const providerName = payment.providerConfigs(chainId)[selectedPaymentMethod]?.name ?? selectedPaymentMethod;
1261
- return `Amount exceeds your $${effectiveCap.toLocaleString()} limit for ${providerName}`;
1262
- }, [amountExceedsCap, effectiveCap, chainId, selectedPaymentMethod]);
1265
+ return `Amount exceeds your $${capUsd.toLocaleString()} limit for ${providerName}`;
1266
+ }, [amountExceedsCap, effectiveCap, chainId, selectedPaymentMethod, decimals]);
1263
1267
  return {
1264
1268
  hasLimits,
1265
1269
  noCooldownProviders,
@@ -1611,11 +1615,18 @@ function useProvexBuy({
1611
1615
  () => parseAmountSafe(amount, currency.decimals),
1612
1616
  [amount, currency.decimals]
1613
1617
  );
1618
+ const tokenDecimals = token?.decimals ?? 6;
1619
+ const amountInTokenUnits = react.useMemo(() => {
1620
+ if (amountBigInt === null) return null;
1621
+ const decimalShift = BigInt(tokenDecimals - currency.decimals);
1622
+ return decimalShift >= 0n ? amountBigInt * 10n ** decimalShift : amountBigInt / 10n ** -decimalShift;
1623
+ }, [amountBigInt, tokenDecimals, currency.decimals]);
1614
1624
  const limits = useReputationLimits({
1615
1625
  chainId,
1616
1626
  selectedPaymentMethod: activePaymentMethod,
1617
1627
  tier: reputation$1.tier,
1618
- amountInInt: amountBigInt,
1628
+ decimals: tokenDecimals,
1629
+ amountInInt: amountInTokenUnits,
1619
1630
  cooldownEndsAt: reputation$1.cooldownEndsAt
1620
1631
  });
1621
1632
  const signalIntent = useSignalIntent({