@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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Provex
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -438,4 +438,4 @@ interface BuyProps {
438
438
 
439
439
  ## License
440
440
 
441
- PrivateProvex Protocol
441
+ MITsee `LICENSE` in this package.
@@ -705,7 +705,13 @@ interface ReputationLimitsParams {
705
705
  selectedPaymentMethod: ProviderKey;
706
706
  /** User's reputation tier */
707
707
  tier: TakerTier;
708
- /** Amount in fiat currency (for cap exceeded check) - in token base units (e.g., 6 decimals for USDC) */
708
+ /** Settlement-token decimals used to scale the tier cap into token
709
+ * base units so the comparison against `amountInInt` is a direct
710
+ * bigint compare. Pass `6` for USDC; future non-USDC tokens supply
711
+ * their own decimals. */
712
+ decimals: number;
713
+ /** Amount the user is trying to spend, in settlement-token base
714
+ * units matching `decimals`. */
709
715
  amountInInt?: bigint | null;
710
716
  /** When the user's cooldown ends (from useReputation) */
711
717
  cooldownEndsAt?: Date | null;
@@ -722,8 +728,11 @@ interface ReputationLimits {
722
728
  cooldownRemaining: string | null;
723
729
  /** Whether user is currently on cooldown for the selected payment method */
724
730
  isOnCooldown: boolean;
725
- /** Effective cap in USD for the selected payment method (null if no cap) */
726
- effectiveCap: number | null;
731
+ /** Effective cap in settlement-token base units for the selected
732
+ * payment method. `null` = locked. `UNLIMITED_CAP_BASE_UNITS` =
733
+ * president (no upper bound). Otherwise compare an amount in the
734
+ * same base-units scale directly. */
735
+ effectiveCap: bigint | null;
727
736
  /** Whether the current amount exceeds the cap */
728
737
  amountExceedsCap: boolean;
729
738
  /** Error message when cap is exceeded */
@@ -748,7 +757,7 @@ interface ReputationLimits {
748
757
  * })
749
758
  * ```
750
759
  */
751
- declare function useReputationLimits({ chainId, selectedPaymentMethod, tier, amountInInt, cooldownEndsAt, }: ReputationLimitsParams): ReputationLimits;
760
+ declare function useReputationLimits({ chainId, selectedPaymentMethod, tier, decimals, amountInInt, cooldownEndsAt, }: ReputationLimitsParams): ReputationLimits;
752
761
 
753
762
  /** Intent status values representing the lifecycle state. */
754
763
  declare const intentStatuses: {
@@ -705,7 +705,13 @@ interface ReputationLimitsParams {
705
705
  selectedPaymentMethod: ProviderKey;
706
706
  /** User's reputation tier */
707
707
  tier: TakerTier;
708
- /** Amount in fiat currency (for cap exceeded check) - in token base units (e.g., 6 decimals for USDC) */
708
+ /** Settlement-token decimals used to scale the tier cap into token
709
+ * base units so the comparison against `amountInInt` is a direct
710
+ * bigint compare. Pass `6` for USDC; future non-USDC tokens supply
711
+ * their own decimals. */
712
+ decimals: number;
713
+ /** Amount the user is trying to spend, in settlement-token base
714
+ * units matching `decimals`. */
709
715
  amountInInt?: bigint | null;
710
716
  /** When the user's cooldown ends (from useReputation) */
711
717
  cooldownEndsAt?: Date | null;
@@ -722,8 +728,11 @@ interface ReputationLimits {
722
728
  cooldownRemaining: string | null;
723
729
  /** Whether user is currently on cooldown for the selected payment method */
724
730
  isOnCooldown: boolean;
725
- /** Effective cap in USD for the selected payment method (null if no cap) */
726
- effectiveCap: number | null;
731
+ /** Effective cap in settlement-token base units for the selected
732
+ * payment method. `null` = locked. `UNLIMITED_CAP_BASE_UNITS` =
733
+ * president (no upper bound). Otherwise compare an amount in the
734
+ * same base-units scale directly. */
735
+ effectiveCap: bigint | null;
727
736
  /** Whether the current amount exceeds the cap */
728
737
  amountExceedsCap: boolean;
729
738
  /** Error message when cap is exceeded */
@@ -748,7 +757,7 @@ interface ReputationLimits {
748
757
  * })
749
758
  * ```
750
759
  */
751
- declare function useReputationLimits({ chainId, selectedPaymentMethod, tier, amountInInt, cooldownEndsAt, }: ReputationLimitsParams): ReputationLimits;
760
+ declare function useReputationLimits({ chainId, selectedPaymentMethod, tier, decimals, amountInInt, cooldownEndsAt, }: ReputationLimitsParams): ReputationLimits;
752
761
 
753
762
  /** Intent status values representing the lifecycle state. */
754
763
  declare const intentStatuses: {
@@ -12,7 +12,7 @@ import { V3EscrowAbi, OrchestratorAbi, PaymentVerifierRegistryAbi, UnifiedPaymen
12
12
  import { publicClient, getDefaultToken } from '@provex/utils/tokens';
13
13
  import { chainIdToChain } from '@provex/utils/chain';
14
14
  import { base } from 'viem/chains';
15
- import { DEFAULT_REPUTATION, getTierFromVolume, TIER_ORDER, TAKER_TIERS, getVolumeRangeDisplay, getCooldownHours, getEffectiveCap } from '@provex/utils/reputation';
15
+ import { DEFAULT_REPUTATION, getTierFromVolume, TIER_ORDER, TAKER_TIERS, getVolumeRangeDisplay, getCooldownHours, getEffectiveCap, UNLIMITED_CAP_BASE_UNITS, getEffectiveCapDisplayUsd } from '@provex/utils/reputation';
16
16
 
17
17
  // src/lib/api.ts
18
18
  function createApiClient(apiUrl) {
@@ -916,7 +916,9 @@ var ProveXClient = class {
916
916
  let errorMessage = `Attestation error: ${res.status}`;
917
917
  try {
918
918
  const errorJson = await res.json();
919
- if (errorJson.message) errorMessage = errorJson.message;
919
+ if (errorJson.details?.message) errorMessage = errorJson.details.message;
920
+ else if (errorJson.message) errorMessage = errorJson.message;
921
+ else if (errorJson.error) errorMessage = errorJson.error;
920
922
  } catch {
921
923
  }
922
924
  return {
@@ -1208,6 +1210,7 @@ function useReputationLimits({
1208
1210
  chainId,
1209
1211
  selectedPaymentMethod,
1210
1212
  tier,
1213
+ decimals,
1211
1214
  amountInInt,
1212
1215
  cooldownEndsAt
1213
1216
  }) {
@@ -1240,19 +1243,20 @@ function useReputationLimits({
1240
1243
  return getCooldownHours({ tier, providerKey: selectedPaymentMethod });
1241
1244
  }, [hasLimits, tier, selectedPaymentMethod]);
1242
1245
  const effectiveCap = useMemo(() => {
1243
- return getEffectiveCap({ tier, providerKey: selectedPaymentMethod });
1244
- }, [hasLimits, tier, selectedPaymentMethod]);
1246
+ return getEffectiveCap({ tier, providerKey: selectedPaymentMethod, decimals });
1247
+ }, [hasLimits, tier, selectedPaymentMethod, decimals]);
1245
1248
  const amountExceedsCap = useMemo(() => {
1246
1249
  if (effectiveCap === null) return false;
1247
1250
  if (!amountInInt) return false;
1248
- const amountUsd = Number(amountInInt) / 1e6;
1249
- return amountUsd > effectiveCap;
1251
+ return amountInInt > effectiveCap;
1250
1252
  }, [effectiveCap, amountInInt]);
1251
1253
  const capExceededMessage = useMemo(() => {
1252
1254
  if (!amountExceedsCap || effectiveCap === null) return null;
1255
+ if (effectiveCap === UNLIMITED_CAP_BASE_UNITS) return null;
1256
+ const capUsd = getEffectiveCapDisplayUsd(effectiveCap, decimals) ?? 0;
1253
1257
  const providerName = providerConfigs(chainId)[selectedPaymentMethod]?.name ?? selectedPaymentMethod;
1254
- return `Amount exceeds your $${effectiveCap.toLocaleString()} limit for ${providerName}`;
1255
- }, [amountExceedsCap, effectiveCap, chainId, selectedPaymentMethod]);
1258
+ return `Amount exceeds your $${capUsd.toLocaleString()} limit for ${providerName}`;
1259
+ }, [amountExceedsCap, effectiveCap, chainId, selectedPaymentMethod, decimals]);
1256
1260
  return {
1257
1261
  hasLimits,
1258
1262
  noCooldownProviders,
@@ -1604,11 +1608,18 @@ function useProvexBuy({
1604
1608
  () => parseAmountSafe(amount, currency.decimals),
1605
1609
  [amount, currency.decimals]
1606
1610
  );
1611
+ const tokenDecimals = token?.decimals ?? 6;
1612
+ const amountInTokenUnits = useMemo(() => {
1613
+ if (amountBigInt === null) return null;
1614
+ const decimalShift = BigInt(tokenDecimals - currency.decimals);
1615
+ return decimalShift >= 0n ? amountBigInt * 10n ** decimalShift : amountBigInt / 10n ** -decimalShift;
1616
+ }, [amountBigInt, tokenDecimals, currency.decimals]);
1607
1617
  const limits = useReputationLimits({
1608
1618
  chainId,
1609
1619
  selectedPaymentMethod: activePaymentMethod,
1610
1620
  tier: reputation.tier,
1611
- amountInInt: amountBigInt,
1621
+ decimals: tokenDecimals,
1622
+ amountInInt: amountInTokenUnits,
1612
1623
  cooldownEndsAt: reputation.cooldownEndsAt
1613
1624
  });
1614
1625
  const signalIntent = useSignalIntent({
@@ -2177,5 +2188,5 @@ function ProvexBuyRoot({
2177
2188
  }
2178
2189
 
2179
2190
  export { BrowsePhase, CommittedPhase, CompletePhase, ProveXClient, ProveXError, ProvexBuy, ProvexBuyProvider, ProvexProvider, ProvingPhase, checkMutation, checkTransactionIndexed, createApiClient, createProveXClient, getRate, getTierDisplayInfo, getTransactionGasInputs, getUserFriendlyErrorMessage, intentStatuses, isUserRejectionError, useContractRead, useDeposits, useOptionalProvex, useOptionalProvexPublicClient, useOptionalProvexWallet, useOrchestratorAddress, usePayeeDetails, useProtocolFeePercentage, useProtocolFees, useProvex, useProvexBuy, useProvexBuyContext, useProvexPublicClient, useProvexWallet, useReputation, useReputationLimits, useSignalIntent };
2180
- //# sourceMappingURL=chunk-VWWANYB2.js.map
2181
- //# sourceMappingURL=chunk-VWWANYB2.js.map
2191
+ //# sourceMappingURL=chunk-NAGOACEK.js.map
2192
+ //# sourceMappingURL=chunk-NAGOACEK.js.map