@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.
@@ -0,0 +1,5 @@
1
+ export { enrichPvDepositView, enrichPvIntentView, parseDepositView, parseIntentView } from './chunk-BRIDD433.mjs';
2
+ import './chunk-ZFBH4HD7.mjs';
3
+ import './chunk-J5LGTIGS.mjs';
4
+ //# sourceMappingURL=protocolViewerParsers-ZZKVAPPA.mjs.map
5
+ //# sourceMappingURL=protocolViewerParsers-ZZKVAPPA.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"protocolViewerParsers-QMHI74AA.mjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"protocolViewerParsers-ZZKVAPPA.mjs"}
package/dist/react.cjs CHANGED
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var react = require('react');
4
- var viem = require('viem');
5
4
 
6
5
  // src/react/hooks/useCreateDeposit.ts
7
6
  function useCreateDeposit({ client, onSuccess, onError }) {
@@ -106,135 +105,6 @@ function useSignalIntent({ client, onSuccess, onError }) {
106
105
  [signalIntent, prepareSignalIntent, isLoading, error, txHash, prepared]
107
106
  );
108
107
  }
109
-
110
- // src/takerTiers.ts
111
- var TAKER_TIER_SCHEDULE = [
112
- { tier: "PLATINUM", perIntentCapUsd: 5e3, minVolumeUsd: 1e5, maxVolumeUsd: Infinity },
113
- { tier: "PRO", perIntentCapUsd: 2500, minVolumeUsd: 5e4, maxVolumeUsd: 99999 },
114
- { tier: "PLUS", perIntentCapUsd: 1e3, minVolumeUsd: 1e4, maxVolumeUsd: 49999 },
115
- { tier: "PEER", perIntentCapUsd: 250, minVolumeUsd: 1e3, maxVolumeUsd: 9999 },
116
- { tier: "PEASANT", perIntentCapUsd: 100, minVolumeUsd: 0, maxVolumeUsd: 999 }
117
- ];
118
- var TAKER_TIER_ORDER = [
119
- "PEASANT",
120
- "PEER",
121
- "PLUS",
122
- "PRO",
123
- "PLATINUM"
124
- ];
125
- var TAKER_TIER_CAPS = Object.fromEntries(
126
- TAKER_TIER_SCHEDULE.map((entry) => [entry.tier, entry.perIntentCapUsd])
127
- );
128
- function getNextTakerTier(currentTier) {
129
- if (!currentTier) return null;
130
- const index = TAKER_TIER_ORDER.indexOf(currentTier);
131
- if (index === -1 || index >= TAKER_TIER_ORDER.length - 1) return null;
132
- return TAKER_TIER_ORDER[index + 1];
133
- }
134
-
135
- // src/react/hooks/useGetTakerTier.ts
136
- function useGetTakerTier({
137
- client,
138
- owner,
139
- chainId,
140
- autoFetch = true,
141
- onSuccess,
142
- onError
143
- }) {
144
- const [isLoading, setIsLoading] = react.useState(false);
145
- const [error, setError] = react.useState(null);
146
- const [takerTier, setTakerTier] = react.useState(null);
147
- const getTakerTier = react.useCallback(
148
- async (params) => {
149
- if (!client) {
150
- const err = new Error("Zkp2pClient is not initialized");
151
- setError(err);
152
- onError?.(err);
153
- return null;
154
- }
155
- const request = params ?? (owner && chainId ? { owner, chainId } : null);
156
- if (!request) {
157
- const err = new Error("Owner address and chainId are required");
158
- setError(err);
159
- onError?.(err);
160
- return null;
161
- }
162
- setIsLoading(true);
163
- setError(null);
164
- setTakerTier(null);
165
- try {
166
- const response = await client.getTakerTier(request);
167
- setTakerTier(response.responseObject);
168
- onSuccess?.(response.responseObject);
169
- return response;
170
- } catch (err) {
171
- const e = err instanceof Error ? err : new Error(String(err));
172
- setError(e);
173
- onError?.(e);
174
- return null;
175
- } finally {
176
- setIsLoading(false);
177
- }
178
- },
179
- [client, owner, chainId, onSuccess, onError]
180
- );
181
- react.useEffect(() => {
182
- if (!autoFetch || !owner || !chainId) return;
183
- void getTakerTier({ owner, chainId });
184
- }, [autoFetch, owner, chainId, getTakerTier]);
185
- return react.useMemo(
186
- () => ({ getTakerTier, takerTier, isLoading, error }),
187
- [getTakerTier, takerTier, isLoading, error]
188
- );
189
- }
190
- function getNextTierCap(currentTier) {
191
- const nextTier = getNextTakerTier(currentTier);
192
- if (!nextTier) return null;
193
- const nextCap = TAKER_TIER_CAPS[nextTier];
194
- return nextCap != null ? `$${nextCap.toLocaleString()}` : null;
195
- }
196
- function formatCapFromBaseUnits(baseUnits) {
197
- if (!baseUnits || baseUnits === "") return "$0";
198
- const value = Number(viem.formatUnits(BigInt(baseUnits), 6));
199
- return `$${value.toLocaleString()}`;
200
- }
201
- function getCapForDisplay(tier) {
202
- const platformLimits = tier.platformLimits ?? [];
203
- if (platformLimits.length === 0) {
204
- return tier.perIntentCapBaseUnits ?? tier.maxOrderSize;
205
- }
206
- const bestCap = platformLimits.filter((limit) => !limit.isLocked && limit.effectiveCap && limit.effectiveCap !== "0").reduce((current, limit) => {
207
- if (!current) return limit.effectiveCap;
208
- return BigInt(limit.effectiveCap) > BigInt(current) ? limit.effectiveCap : current;
209
- }, void 0);
210
- return bestCap ?? "0";
211
- }
212
- function getTierDisplayInfo(tier) {
213
- if (!tier) {
214
- return {
215
- tierLabel: "Loading...",
216
- capDisplay: "...",
217
- isNewUser: false,
218
- showScore: false
219
- };
220
- }
221
- const isNewUser = tier.source === "fallback";
222
- const isZeroFulfills = tier.stats?.lifetimeFulfilledCount === 0;
223
- const tierLabels = {
224
- PEASANT: "Peer Peasant",
225
- PEER: "Peer",
226
- PLUS: "Peer Plus",
227
- PRO: "Peer Pro",
228
- PLATINUM: "Peer Platinum"
229
- };
230
- const capDisplay = formatCapFromBaseUnits(getCapForDisplay(tier));
231
- return {
232
- tierLabel: tierLabels[tier.tier] || tier.tier,
233
- capDisplay,
234
- isNewUser: isNewUser || isZeroFulfills,
235
- showScore: !isNewUser && !!tier.stats && tier.stats.lockScoreDiluted !== "0"
236
- };
237
- }
238
108
  function useFulfillIntent({ client, onSuccess, onError }) {
239
109
  const [isLoading, setIsLoading] = react.useState(false);
240
110
  const [error, setError] = react.useState(null);
@@ -1722,8 +1592,6 @@ exports.asErrorMessage = asErrorMessage;
1722
1592
  exports.assertDelegationMethodSupport = assertDelegationMethodSupport;
1723
1593
  exports.classifyDelegationState = classifyDelegationState;
1724
1594
  exports.getDelegationRoute = getDelegationRoute;
1725
- exports.getNextTierCap = getNextTierCap;
1726
- exports.getTierDisplayInfo = getTierDisplayInfo;
1727
1595
  exports.isZeroRateManagerId = isZeroRateManagerId;
1728
1596
  exports.normalizeRateManagerId = normalizeRateManagerId;
1729
1597
  exports.normalizeRegistry = normalizeRegistry;
@@ -1735,7 +1603,6 @@ exports.useCreateVault = useCreateVault;
1735
1603
  exports.useDeactivateCurrency = useDeactivateCurrency;
1736
1604
  exports.useExtendIntentLifetime = useExtendIntentLifetime;
1737
1605
  exports.useFulfillIntent = useFulfillIntent;
1738
- exports.useGetTakerTier = useGetTakerTier;
1739
1606
  exports.usePruneExpiredIntents = usePruneExpiredIntents;
1740
1607
  exports.useReleaseFundsToPayer = useReleaseFundsToPayer;
1741
1608
  exports.useRemoveCurrency = useRemoveCurrency;