@zkp2p/sdk 0.10.0 → 0.11.0-rc.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/dist/react.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { Z as Zkp2pClient, P as PostDepositDetailsRequest, a1 as SignalIntentMethodParams, bK as PreparedTransaction, bN as TakerTier, E as GetTakerTierRequest, F as GetTakerTierResponse, a2 as FulfillIntentMethodParams, d5 as SendTransactionFn, d6 as SendBatchFn, d3 as DelegationDepositTarget, d4 as BatchResult, aa as IntentGuardianErrorCode, a6 as IntentGuardianPolicy, a7 as IntentGuardianQuote } from './vaultUtils-DeUFIx3l.mjs';
2
- export { d1 as DelegationRoute, d2 as DelegationState, dl as VAULT_ZERO_ADDRESS, cX as ZERO_RATE_MANAGER_ID, dm as asErrorMessage, dn as assertDelegationMethodSupport, d0 as classifyDelegationState, c$ as getDelegationRoute, cY as isZeroRateManagerId, cZ as normalizeRateManagerId, c_ as normalizeRegistry } from './vaultUtils-DeUFIx3l.mjs';
1
+ import { Z as Zkp2pClient, P as PostDepositDetailsRequest, _ as SignalIntentMethodParams, bI as PreparedTransaction, $ as FulfillIntentMethodParams, cZ as SendTransactionFn, c_ as SendBatchFn, cX as DelegationDepositTarget, cY as BatchResult, a7 as IntentGuardianErrorCode, a3 as IntentGuardianPolicy, a4 as IntentGuardianQuote } from './vaultUtils-BnXI9_ng.mjs';
2
+ export { cV as DelegationRoute, cW as DelegationState, dd as VAULT_ZERO_ADDRESS, cP as ZERO_RATE_MANAGER_ID, de as asErrorMessage, df as assertDelegationMethodSupport, cU as classifyDelegationState, cT as getDelegationRoute, cQ as isZeroRateManagerId, cR as normalizeRateManagerId, cS as normalizeRegistry } from './vaultUtils-BnXI9_ng.mjs';
3
3
  import { Hash, Address, Hex } from 'viem';
4
4
  import '@zkp2p/indexer-schema';
5
5
  import 'abitype';
@@ -60,28 +60,6 @@ declare function useSignalIntent({ client, onSuccess, onError }: UseSignalIntent
60
60
  prepared: PreparedTransaction | null;
61
61
  };
62
62
 
63
- interface UseGetTakerTierOptions {
64
- client: Zkp2pClient | null;
65
- owner?: string | null;
66
- chainId?: number | null;
67
- autoFetch?: boolean;
68
- onSuccess?: (tier: TakerTier) => void;
69
- onError?: (error: Error) => void;
70
- }
71
- declare function useGetTakerTier({ client, owner, chainId, autoFetch, onSuccess, onError, }: UseGetTakerTierOptions): {
72
- getTakerTier: (params?: GetTakerTierRequest) => Promise<GetTakerTierResponse | null>;
73
- takerTier: TakerTier | null;
74
- isLoading: boolean;
75
- error: Error | null;
76
- };
77
- declare function getNextTierCap(currentTier: string | undefined): string | null;
78
- declare function getTierDisplayInfo(tier: TakerTier | undefined): {
79
- tierLabel: string;
80
- capDisplay: string;
81
- isNewUser: boolean;
82
- showScore: boolean;
83
- };
84
-
85
63
  interface UseFulfillIntentOptions {
86
64
  client: Zkp2pClient | null;
87
65
  onSuccess?: (txHash: Hash) => void;
@@ -463,4 +441,4 @@ declare function usePruneExpiredIntents({ client, onSuccess, onError }: UsePrune
463
441
  txHash: `0x${string}` | null;
464
442
  };
465
443
 
466
- export { BatchResult, type CreateVaultParams, DelegationDepositTarget, PreparedTransaction, SendBatchFn, SendTransactionFn, type UseAddCurrenciesOptions, type UseAddFundsOptions, type UseAddPaymentMethodsOptions, type UseCreateDepositOptions, type UseCreateVaultOptions, type UseDeactivateCurrencyOptions, type UseExtendIntentLifetimeOptions, type UseFulfillIntentOptions, type UseGetTakerTierOptions, type UsePruneExpiredIntentsOptions, type UseReleaseFundsToPayerOptions, type UseRemoveCurrencyOptions, type UseRemoveDelegateOptions, type UseRemoveFundsOptions, type UseRemovePaymentMethodOptions, type UseSetAcceptingIntentsOptions, type UseSetCurrencyMinRateOptions, type UseSetDelegateOptions, type UseSetIntentRangeOptions, type UseSetPaymentMethodActiveOptions, type UseSetRetainOnEmptyOptions, type UseSetVaultConfigOptions, type UseSetVaultFeeOptions, type UseSetVaultMinRateOptions, type UseSignalIntentOptions, type UseVaultDelegationOptions, type UseWithdrawDepositOptions, getNextTierCap, getTierDisplayInfo, useAddCurrencies, useAddFunds, useAddPaymentMethods, useCreateDeposit, useCreateVault, useDeactivateCurrency, useExtendIntentLifetime, useFulfillIntent, useGetTakerTier, usePruneExpiredIntents, useReleaseFundsToPayer, useRemoveCurrency, useRemoveDelegate, useRemoveFunds, useRemovePaymentMethod, useSetAcceptingIntents, useSetCurrencyMinRate, useSetDelegate, useSetIntentRange, useSetPaymentMethodActive, useSetRetainOnEmpty, useSetVaultConfig, useSetVaultFee, useSetVaultMinRate, useSignalIntent, useVaultDelegation, useWithdrawDeposit };
444
+ export { BatchResult, type CreateVaultParams, DelegationDepositTarget, PreparedTransaction, SendBatchFn, SendTransactionFn, type UseAddCurrenciesOptions, type UseAddFundsOptions, type UseAddPaymentMethodsOptions, type UseCreateDepositOptions, type UseCreateVaultOptions, type UseDeactivateCurrencyOptions, type UseExtendIntentLifetimeOptions, type UseFulfillIntentOptions, type UsePruneExpiredIntentsOptions, type UseReleaseFundsToPayerOptions, type UseRemoveCurrencyOptions, type UseRemoveDelegateOptions, type UseRemoveFundsOptions, type UseRemovePaymentMethodOptions, type UseSetAcceptingIntentsOptions, type UseSetCurrencyMinRateOptions, type UseSetDelegateOptions, type UseSetIntentRangeOptions, type UseSetPaymentMethodActiveOptions, type UseSetRetainOnEmptyOptions, type UseSetVaultConfigOptions, type UseSetVaultFeeOptions, type UseSetVaultMinRateOptions, type UseSignalIntentOptions, type UseVaultDelegationOptions, type UseWithdrawDepositOptions, useAddCurrencies, useAddFunds, useAddPaymentMethods, useCreateDeposit, useCreateVault, useDeactivateCurrency, useExtendIntentLifetime, useFulfillIntent, usePruneExpiredIntents, useReleaseFundsToPayer, useRemoveCurrency, useRemoveDelegate, useRemoveFunds, useRemovePaymentMethod, useSetAcceptingIntents, useSetCurrencyMinRate, useSetDelegate, useSetIntentRange, useSetPaymentMethodActive, useSetRetainOnEmpty, useSetVaultConfig, useSetVaultFee, useSetVaultMinRate, useSignalIntent, useVaultDelegation, useWithdrawDeposit };
package/dist/react.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Z as Zkp2pClient, P as PostDepositDetailsRequest, a1 as SignalIntentMethodParams, bK as PreparedTransaction, bN as TakerTier, E as GetTakerTierRequest, F as GetTakerTierResponse, a2 as FulfillIntentMethodParams, d5 as SendTransactionFn, d6 as SendBatchFn, d3 as DelegationDepositTarget, d4 as BatchResult, aa as IntentGuardianErrorCode, a6 as IntentGuardianPolicy, a7 as IntentGuardianQuote } from './vaultUtils-DeUFIx3l.js';
2
- export { d1 as DelegationRoute, d2 as DelegationState, dl as VAULT_ZERO_ADDRESS, cX as ZERO_RATE_MANAGER_ID, dm as asErrorMessage, dn as assertDelegationMethodSupport, d0 as classifyDelegationState, c$ as getDelegationRoute, cY as isZeroRateManagerId, cZ as normalizeRateManagerId, c_ as normalizeRegistry } from './vaultUtils-DeUFIx3l.js';
1
+ import { Z as Zkp2pClient, P as PostDepositDetailsRequest, _ as SignalIntentMethodParams, bI as PreparedTransaction, $ as FulfillIntentMethodParams, cZ as SendTransactionFn, c_ as SendBatchFn, cX as DelegationDepositTarget, cY as BatchResult, a7 as IntentGuardianErrorCode, a3 as IntentGuardianPolicy, a4 as IntentGuardianQuote } from './vaultUtils-BnXI9_ng.js';
2
+ export { cV as DelegationRoute, cW as DelegationState, dd as VAULT_ZERO_ADDRESS, cP as ZERO_RATE_MANAGER_ID, de as asErrorMessage, df as assertDelegationMethodSupport, cU as classifyDelegationState, cT as getDelegationRoute, cQ as isZeroRateManagerId, cR as normalizeRateManagerId, cS as normalizeRegistry } from './vaultUtils-BnXI9_ng.js';
3
3
  import { Hash, Address, Hex } from 'viem';
4
4
  import '@zkp2p/indexer-schema';
5
5
  import 'abitype';
@@ -60,28 +60,6 @@ declare function useSignalIntent({ client, onSuccess, onError }: UseSignalIntent
60
60
  prepared: PreparedTransaction | null;
61
61
  };
62
62
 
63
- interface UseGetTakerTierOptions {
64
- client: Zkp2pClient | null;
65
- owner?: string | null;
66
- chainId?: number | null;
67
- autoFetch?: boolean;
68
- onSuccess?: (tier: TakerTier) => void;
69
- onError?: (error: Error) => void;
70
- }
71
- declare function useGetTakerTier({ client, owner, chainId, autoFetch, onSuccess, onError, }: UseGetTakerTierOptions): {
72
- getTakerTier: (params?: GetTakerTierRequest) => Promise<GetTakerTierResponse | null>;
73
- takerTier: TakerTier | null;
74
- isLoading: boolean;
75
- error: Error | null;
76
- };
77
- declare function getNextTierCap(currentTier: string | undefined): string | null;
78
- declare function getTierDisplayInfo(tier: TakerTier | undefined): {
79
- tierLabel: string;
80
- capDisplay: string;
81
- isNewUser: boolean;
82
- showScore: boolean;
83
- };
84
-
85
63
  interface UseFulfillIntentOptions {
86
64
  client: Zkp2pClient | null;
87
65
  onSuccess?: (txHash: Hash) => void;
@@ -463,4 +441,4 @@ declare function usePruneExpiredIntents({ client, onSuccess, onError }: UsePrune
463
441
  txHash: `0x${string}` | null;
464
442
  };
465
443
 
466
- export { BatchResult, type CreateVaultParams, DelegationDepositTarget, PreparedTransaction, SendBatchFn, SendTransactionFn, type UseAddCurrenciesOptions, type UseAddFundsOptions, type UseAddPaymentMethodsOptions, type UseCreateDepositOptions, type UseCreateVaultOptions, type UseDeactivateCurrencyOptions, type UseExtendIntentLifetimeOptions, type UseFulfillIntentOptions, type UseGetTakerTierOptions, type UsePruneExpiredIntentsOptions, type UseReleaseFundsToPayerOptions, type UseRemoveCurrencyOptions, type UseRemoveDelegateOptions, type UseRemoveFundsOptions, type UseRemovePaymentMethodOptions, type UseSetAcceptingIntentsOptions, type UseSetCurrencyMinRateOptions, type UseSetDelegateOptions, type UseSetIntentRangeOptions, type UseSetPaymentMethodActiveOptions, type UseSetRetainOnEmptyOptions, type UseSetVaultConfigOptions, type UseSetVaultFeeOptions, type UseSetVaultMinRateOptions, type UseSignalIntentOptions, type UseVaultDelegationOptions, type UseWithdrawDepositOptions, getNextTierCap, getTierDisplayInfo, useAddCurrencies, useAddFunds, useAddPaymentMethods, useCreateDeposit, useCreateVault, useDeactivateCurrency, useExtendIntentLifetime, useFulfillIntent, useGetTakerTier, usePruneExpiredIntents, useReleaseFundsToPayer, useRemoveCurrency, useRemoveDelegate, useRemoveFunds, useRemovePaymentMethod, useSetAcceptingIntents, useSetCurrencyMinRate, useSetDelegate, useSetIntentRange, useSetPaymentMethodActive, useSetRetainOnEmpty, useSetVaultConfig, useSetVaultFee, useSetVaultMinRate, useSignalIntent, useVaultDelegation, useWithdrawDeposit };
444
+ export { BatchResult, type CreateVaultParams, DelegationDepositTarget, PreparedTransaction, SendBatchFn, SendTransactionFn, type UseAddCurrenciesOptions, type UseAddFundsOptions, type UseAddPaymentMethodsOptions, type UseCreateDepositOptions, type UseCreateVaultOptions, type UseDeactivateCurrencyOptions, type UseExtendIntentLifetimeOptions, type UseFulfillIntentOptions, type UsePruneExpiredIntentsOptions, type UseReleaseFundsToPayerOptions, type UseRemoveCurrencyOptions, type UseRemoveDelegateOptions, type UseRemoveFundsOptions, type UseRemovePaymentMethodOptions, type UseSetAcceptingIntentsOptions, type UseSetCurrencyMinRateOptions, type UseSetDelegateOptions, type UseSetIntentRangeOptions, type UseSetPaymentMethodActiveOptions, type UseSetRetainOnEmptyOptions, type UseSetVaultConfigOptions, type UseSetVaultFeeOptions, type UseSetVaultMinRateOptions, type UseSignalIntentOptions, type UseVaultDelegationOptions, type UseWithdrawDepositOptions, useAddCurrencies, useAddFunds, useAddPaymentMethods, useCreateDeposit, useCreateVault, useDeactivateCurrency, useExtendIntentLifetime, useFulfillIntent, usePruneExpiredIntents, useReleaseFundsToPayer, useRemoveCurrency, useRemoveDelegate, useRemoveFunds, useRemovePaymentMethod, useSetAcceptingIntents, useSetCurrencyMinRate, useSetDelegate, useSetIntentRange, useSetPaymentMethodActive, useSetRetainOnEmpty, useSetVaultConfig, useSetVaultFee, useSetVaultMinRate, useSignalIntent, useVaultDelegation, useWithdrawDeposit };
package/dist/react.mjs CHANGED
@@ -1,8 +1,7 @@
1
- import { getNextTakerTier, TAKER_TIER_CAPS, asErrorMessage, ZERO_ADDRESS, getDelegationRoute, assertDelegationMethodSupport, prepareClearDelegationTx, normalizeRateManagerId, normalizeRegistry, isZeroRateManagerId, assertAtomicDelegationSwitchSupport, prepareSetDelegationTx, classifyIntentGuardianError } from './chunk-WXEP544Y.mjs';
2
- export { ZERO_ADDRESS as VAULT_ZERO_ADDRESS, ZERO_RATE_MANAGER_ID, asErrorMessage, assertDelegationMethodSupport, classifyDelegationState, getDelegationRoute, isZeroRateManagerId, normalizeRateManagerId, normalizeRegistry } from './chunk-WXEP544Y.mjs';
1
+ import { asErrorMessage, ZERO_ADDRESS, getDelegationRoute, assertDelegationMethodSupport, prepareClearDelegationTx, normalizeRateManagerId, normalizeRegistry, isZeroRateManagerId, assertAtomicDelegationSwitchSupport, prepareSetDelegationTx, classifyIntentGuardianError } from './chunk-FCOH36IX.mjs';
2
+ export { ZERO_ADDRESS as VAULT_ZERO_ADDRESS, ZERO_RATE_MANAGER_ID, asErrorMessage, assertDelegationMethodSupport, classifyDelegationState, getDelegationRoute, isZeroRateManagerId, normalizeRateManagerId, normalizeRegistry } from './chunk-FCOH36IX.mjs';
3
3
  import './chunk-J5LGTIGS.mjs';
4
- import { useState, useCallback, useMemo, useEffect } from 'react';
5
- import { formatUnits } from 'viem';
4
+ import { useState, useCallback, useMemo } from 'react';
6
5
 
7
6
  function useCreateDeposit({ client, onSuccess, onError }) {
8
7
  const [isLoading, setIsLoading] = useState(false);
@@ -106,108 +105,6 @@ function useSignalIntent({ client, onSuccess, onError }) {
106
105
  [signalIntent, prepareSignalIntent, isLoading, error, txHash, prepared]
107
106
  );
108
107
  }
109
- function useGetTakerTier({
110
- client,
111
- owner,
112
- chainId,
113
- autoFetch = true,
114
- onSuccess,
115
- onError
116
- }) {
117
- const [isLoading, setIsLoading] = useState(false);
118
- const [error, setError] = useState(null);
119
- const [takerTier, setTakerTier] = useState(null);
120
- const getTakerTier = useCallback(
121
- async (params) => {
122
- if (!client) {
123
- const err = new Error("Zkp2pClient is not initialized");
124
- setError(err);
125
- onError?.(err);
126
- return null;
127
- }
128
- const request = params ?? (owner && chainId ? { owner, chainId } : null);
129
- if (!request) {
130
- const err = new Error("Owner address and chainId are required");
131
- setError(err);
132
- onError?.(err);
133
- return null;
134
- }
135
- setIsLoading(true);
136
- setError(null);
137
- setTakerTier(null);
138
- try {
139
- const response = await client.getTakerTier(request);
140
- setTakerTier(response.responseObject);
141
- onSuccess?.(response.responseObject);
142
- return response;
143
- } catch (err) {
144
- const e = err instanceof Error ? err : new Error(String(err));
145
- setError(e);
146
- onError?.(e);
147
- return null;
148
- } finally {
149
- setIsLoading(false);
150
- }
151
- },
152
- [client, owner, chainId, onSuccess, onError]
153
- );
154
- useEffect(() => {
155
- if (!autoFetch || !owner || !chainId) return;
156
- void getTakerTier({ owner, chainId });
157
- }, [autoFetch, owner, chainId, getTakerTier]);
158
- return useMemo(
159
- () => ({ getTakerTier, takerTier, isLoading, error }),
160
- [getTakerTier, takerTier, isLoading, error]
161
- );
162
- }
163
- function getNextTierCap(currentTier) {
164
- const nextTier = getNextTakerTier(currentTier);
165
- if (!nextTier) return null;
166
- const nextCap = TAKER_TIER_CAPS[nextTier];
167
- return nextCap != null ? `$${nextCap.toLocaleString()}` : null;
168
- }
169
- function formatCapFromBaseUnits(baseUnits) {
170
- if (!baseUnits || baseUnits === "") return "$0";
171
- const value = Number(formatUnits(BigInt(baseUnits), 6));
172
- return `$${value.toLocaleString()}`;
173
- }
174
- function getCapForDisplay(tier) {
175
- const platformLimits = tier.platformLimits ?? [];
176
- if (platformLimits.length === 0) {
177
- return tier.perIntentCapBaseUnits ?? tier.maxOrderSize;
178
- }
179
- const bestCap = platformLimits.filter((limit) => !limit.isLocked && limit.effectiveCap && limit.effectiveCap !== "0").reduce((current, limit) => {
180
- if (!current) return limit.effectiveCap;
181
- return BigInt(limit.effectiveCap) > BigInt(current) ? limit.effectiveCap : current;
182
- }, void 0);
183
- return bestCap ?? "0";
184
- }
185
- function getTierDisplayInfo(tier) {
186
- if (!tier) {
187
- return {
188
- tierLabel: "Loading...",
189
- capDisplay: "...",
190
- isNewUser: false,
191
- showScore: false
192
- };
193
- }
194
- const isNewUser = tier.source === "fallback";
195
- const isZeroFulfills = tier.stats?.lifetimeFulfilledCount === 0;
196
- const tierLabels = {
197
- PEASANT: "Peer Peasant",
198
- PEER: "Peer",
199
- PLUS: "Peer Plus",
200
- PRO: "Peer Pro",
201
- PLATINUM: "Peer Platinum"
202
- };
203
- const capDisplay = formatCapFromBaseUnits(getCapForDisplay(tier));
204
- return {
205
- tierLabel: tierLabels[tier.tier] || tier.tier,
206
- capDisplay,
207
- isNewUser: isNewUser || isZeroFulfills,
208
- showScore: !isNewUser && !!tier.stats && tier.stats.lockScoreDiluted !== "0"
209
- };
210
- }
211
108
  function useFulfillIntent({ client, onSuccess, onError }) {
212
109
  const [isLoading, setIsLoading] = useState(false);
213
110
  const [error, setError] = useState(null);
@@ -1604,6 +1501,6 @@ function usePruneExpiredIntents({ client, onSuccess, onError }) {
1604
1501
  return useMemo(() => ({ pruneExpiredIntents, isLoading, error, txHash }), [pruneExpiredIntents, isLoading, error, txHash]);
1605
1502
  }
1606
1503
 
1607
- export { getNextTierCap, getTierDisplayInfo, useAddCurrencies, useAddFunds, useAddPaymentMethods, useCreateDeposit, useCreateVault, useDeactivateCurrency, useExtendIntentLifetime, useFulfillIntent, useGetTakerTier, usePruneExpiredIntents, useReleaseFundsToPayer, useRemoveCurrency, useRemoveDelegate, useRemoveFunds, useRemovePaymentMethod, useSetAcceptingIntents, useSetCurrencyMinRate, useSetDelegate, useSetIntentRange, useSetPaymentMethodActive, useSetRetainOnEmpty, useSetVaultConfig, useSetVaultFee, useSetVaultMinRate, useSignalIntent, useVaultDelegation, useWithdrawDeposit };
1504
+ export { useAddCurrencies, useAddFunds, useAddPaymentMethods, useCreateDeposit, useCreateVault, useDeactivateCurrency, useExtendIntentLifetime, useFulfillIntent, usePruneExpiredIntents, useReleaseFundsToPayer, useRemoveCurrency, useRemoveDelegate, useRemoveFunds, useRemovePaymentMethod, useSetAcceptingIntents, useSetCurrencyMinRate, useSetDelegate, useSetIntentRange, useSetPaymentMethodActive, useSetRetainOnEmpty, useSetVaultConfig, useSetVaultFee, useSetVaultMinRate, useSignalIntent, useVaultDelegation, useWithdrawDeposit };
1608
1505
  //# sourceMappingURL=react.mjs.map
1609
1506
  //# sourceMappingURL=react.mjs.map