@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/README.md +29 -21
- package/dist/{chunk-JRLUSPR3.mjs → chunk-BRIDD433.mjs} +27831 -17236
- package/dist/chunk-BRIDD433.mjs.map +1 -0
- package/dist/{chunk-WXEP544Y.mjs → chunk-FCOH36IX.mjs} +3 -39
- package/dist/chunk-FCOH36IX.mjs.map +1 -0
- package/dist/index.cjs +28583 -18008
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +9 -64
- package/dist/index.d.ts +9 -64
- package/dist/index.mjs +124 -197
- package/dist/index.mjs.map +1 -1
- package/dist/protocolViewerParsers-ZZKVAPPA.mjs +5 -0
- package/dist/{protocolViewerParsers-QMHI74AA.mjs.map → protocolViewerParsers-ZZKVAPPA.mjs.map} +1 -1
- package/dist/react.cjs +0 -133
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.mts +3 -25
- package/dist/react.d.ts +3 -25
- package/dist/react.mjs +4 -107
- package/dist/react.mjs.map +1 -1
- package/dist/{vaultUtils-DeUFIx3l.d.mts → vaultUtils-BnXI9_ng.d.mts} +48 -131
- package/dist/{vaultUtils-DeUFIx3l.d.ts → vaultUtils-BnXI9_ng.d.ts} +48 -131
- package/package.json +3 -3
- package/dist/chunk-JRLUSPR3.mjs.map +0 -1
- package/dist/chunk-WXEP544Y.mjs.map +0 -1
- package/dist/protocolViewerParsers-QMHI74AA.mjs +0 -5
package/dist/react.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Z as Zkp2pClient, P as PostDepositDetailsRequest,
|
|
2
|
-
export {
|
|
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
|
|
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,
|
|
2
|
-
export {
|
|
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
|
|
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 {
|
|
2
|
-
export { ZERO_ADDRESS as VAULT_ZERO_ADDRESS, ZERO_RATE_MANAGER_ID, asErrorMessage, assertDelegationMethodSupport, classifyDelegationState, getDelegationRoute, isZeroRateManagerId, normalizeRateManagerId, normalizeRegistry } from './chunk-
|
|
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
|
|
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 {
|
|
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
|