@zkp2p/sdk 0.9.0 → 0.10.0-rc.1
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 +85 -14
- package/dist/{chunk-EIOXBVXP.mjs → chunk-LPJE2MN7.mjs} +3 -39
- package/dist/chunk-LPJE2MN7.mjs.map +1 -0
- package/dist/{chunk-FSIRPX4W.mjs → chunk-NKEAAPPR.mjs} +33616 -248
- package/dist/chunk-NKEAAPPR.mjs.map +1 -0
- package/dist/index.cjs +34184 -406
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +64 -61
- package/dist/index.d.ts +64 -61
- package/dist/index.mjs +456 -25
- package/dist/index.mjs.map +1 -1
- package/dist/protocolViewerParsers-WNN3TJD3.mjs +5 -0
- package/dist/{protocolViewerParsers-ER62YZ5L.mjs.map → protocolViewerParsers-WNN3TJD3.mjs.map} +1 -1
- package/dist/react.cjs +97 -94
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.mts +33 -14
- package/dist/react.d.ts +33 -14
- package/dist/react.mjs +99 -68
- package/dist/react.mjs.map +1 -1
- package/dist/{vaultUtils-aJdIIILM.d.mts → vaultUtils-CxUP_m-J.d.mts} +460 -102
- package/dist/{vaultUtils-aJdIIILM.d.ts → vaultUtils-CxUP_m-J.d.ts} +460 -102
- package/package.json +1 -1
- package/dist/chunk-EIOXBVXP.mjs.map +0 -1
- package/dist/chunk-FSIRPX4W.mjs.map +0 -1
- package/dist/protocolViewerParsers-ER62YZ5L.mjs +0 -5
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { enrichPvDepositView, enrichPvIntentView, parseDepositView, parseIntentView } from './chunk-NKEAAPPR.mjs';
|
|
2
|
+
import './chunk-ZFBH4HD7.mjs';
|
|
3
|
+
import './chunk-J5LGTIGS.mjs';
|
|
4
|
+
//# sourceMappingURL=protocolViewerParsers-WNN3TJD3.mjs.map
|
|
5
|
+
//# sourceMappingURL=protocolViewerParsers-WNN3TJD3.mjs.map
|
package/dist/{protocolViewerParsers-ER62YZ5L.mjs.map → protocolViewerParsers-WNN3TJD3.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"protocolViewerParsers-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"protocolViewerParsers-WNN3TJD3.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,34 +105,7 @@ 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({
|
|
108
|
+
function useGetTakerStake({
|
|
137
109
|
client,
|
|
138
110
|
owner,
|
|
139
111
|
chainId,
|
|
@@ -143,97 +115,129 @@ function useGetTakerTier({
|
|
|
143
115
|
}) {
|
|
144
116
|
const [isLoading, setIsLoading] = react.useState(false);
|
|
145
117
|
const [error, setError] = react.useState(null);
|
|
146
|
-
const [
|
|
147
|
-
const
|
|
118
|
+
const [takerStake, setTakerStake] = react.useState(null);
|
|
119
|
+
const onSuccessRef = react.useRef(onSuccess);
|
|
120
|
+
const onErrorRef = react.useRef(onError);
|
|
121
|
+
react.useEffect(() => {
|
|
122
|
+
onSuccessRef.current = onSuccess;
|
|
123
|
+
onErrorRef.current = onError;
|
|
124
|
+
});
|
|
125
|
+
const requestSeqRef = react.useRef(0);
|
|
126
|
+
const getTakerStake = react.useCallback(
|
|
148
127
|
async (params) => {
|
|
149
128
|
if (!client) {
|
|
150
129
|
const err = new Error("Zkp2pClient is not initialized");
|
|
151
130
|
setError(err);
|
|
152
|
-
|
|
131
|
+
onErrorRef.current?.(err);
|
|
153
132
|
return null;
|
|
154
133
|
}
|
|
155
134
|
const request = params ?? (owner && chainId ? { owner, chainId } : null);
|
|
156
135
|
if (!request) {
|
|
157
136
|
const err = new Error("Owner address and chainId are required");
|
|
158
137
|
setError(err);
|
|
159
|
-
|
|
138
|
+
onErrorRef.current?.(err);
|
|
160
139
|
return null;
|
|
161
140
|
}
|
|
141
|
+
const requestId = ++requestSeqRef.current;
|
|
162
142
|
setIsLoading(true);
|
|
163
143
|
setError(null);
|
|
164
|
-
|
|
144
|
+
setTakerStake(null);
|
|
165
145
|
try {
|
|
166
|
-
const response = await client.
|
|
167
|
-
|
|
168
|
-
|
|
146
|
+
const response = await client.getTakerStake(request);
|
|
147
|
+
if (requestId !== requestSeqRef.current) return null;
|
|
148
|
+
if (!response.success || !response.responseObject) {
|
|
149
|
+
throw new Error(response.message || "Taker stake request failed");
|
|
150
|
+
}
|
|
151
|
+
setTakerStake(response.responseObject);
|
|
152
|
+
onSuccessRef.current?.(response.responseObject);
|
|
169
153
|
return response;
|
|
170
154
|
} catch (err) {
|
|
155
|
+
if (requestId !== requestSeqRef.current) return null;
|
|
171
156
|
const e = err instanceof Error ? err : new Error(String(err));
|
|
172
157
|
setError(e);
|
|
173
|
-
|
|
158
|
+
onErrorRef.current?.(e);
|
|
174
159
|
return null;
|
|
175
160
|
} finally {
|
|
176
|
-
setIsLoading(false);
|
|
161
|
+
if (requestId === requestSeqRef.current) setIsLoading(false);
|
|
177
162
|
}
|
|
178
163
|
},
|
|
179
|
-
[client, owner, chainId
|
|
164
|
+
[client, owner, chainId]
|
|
180
165
|
);
|
|
181
166
|
react.useEffect(() => {
|
|
182
167
|
if (!autoFetch || !owner || !chainId) return;
|
|
183
|
-
void
|
|
184
|
-
}, [autoFetch, owner, chainId,
|
|
168
|
+
void getTakerStake({ owner, chainId });
|
|
169
|
+
}, [autoFetch, owner, chainId, getTakerStake]);
|
|
185
170
|
return react.useMemo(
|
|
186
|
-
() => ({
|
|
187
|
-
[
|
|
171
|
+
() => ({ getTakerStake, takerStake, isLoading, error }),
|
|
172
|
+
[getTakerStake, takerStake, isLoading, error]
|
|
188
173
|
);
|
|
189
174
|
}
|
|
190
|
-
function
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
175
|
+
function useGetTakerCapacity({
|
|
176
|
+
client,
|
|
177
|
+
owner,
|
|
178
|
+
chainId,
|
|
179
|
+
autoFetch = true,
|
|
180
|
+
onSuccess,
|
|
181
|
+
onError
|
|
182
|
+
}) {
|
|
183
|
+
const [isLoading, setIsLoading] = react.useState(false);
|
|
184
|
+
const [error, setError] = react.useState(null);
|
|
185
|
+
const [takerCapacity, setTakerCapacity] = react.useState(null);
|
|
186
|
+
const onSuccessRef = react.useRef(onSuccess);
|
|
187
|
+
const onErrorRef = react.useRef(onError);
|
|
188
|
+
react.useEffect(() => {
|
|
189
|
+
onSuccessRef.current = onSuccess;
|
|
190
|
+
onErrorRef.current = onError;
|
|
191
|
+
});
|
|
192
|
+
const requestSeqRef = react.useRef(0);
|
|
193
|
+
const getTakerCapacity = react.useCallback(
|
|
194
|
+
async (params) => {
|
|
195
|
+
if (!client) {
|
|
196
|
+
const err = new Error("Zkp2pClient is not initialized");
|
|
197
|
+
setError(err);
|
|
198
|
+
onErrorRef.current?.(err);
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
const request = params ?? (owner && chainId ? { owner, chainId } : null);
|
|
202
|
+
if (!request) {
|
|
203
|
+
const err = new Error("Owner address and chainId are required");
|
|
204
|
+
setError(err);
|
|
205
|
+
onErrorRef.current?.(err);
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
const requestId = ++requestSeqRef.current;
|
|
209
|
+
setIsLoading(true);
|
|
210
|
+
setError(null);
|
|
211
|
+
setTakerCapacity(null);
|
|
212
|
+
try {
|
|
213
|
+
const response = await client.getTakerCapacity(request);
|
|
214
|
+
if (requestId !== requestSeqRef.current) return null;
|
|
215
|
+
if (!response.success || !response.responseObject) {
|
|
216
|
+
throw new Error(response.message || "Taker capacity request failed");
|
|
217
|
+
}
|
|
218
|
+
setTakerCapacity(response.responseObject);
|
|
219
|
+
onSuccessRef.current?.(response.responseObject);
|
|
220
|
+
return response;
|
|
221
|
+
} catch (err) {
|
|
222
|
+
if (requestId !== requestSeqRef.current) return null;
|
|
223
|
+
const e = err instanceof Error ? err : new Error(String(err));
|
|
224
|
+
setError(e);
|
|
225
|
+
onErrorRef.current?.(e);
|
|
226
|
+
return null;
|
|
227
|
+
} finally {
|
|
228
|
+
if (requestId === requestSeqRef.current) setIsLoading(false);
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
[client, owner, chainId]
|
|
232
|
+
);
|
|
233
|
+
react.useEffect(() => {
|
|
234
|
+
if (!autoFetch || !owner || !chainId) return;
|
|
235
|
+
void getTakerCapacity({ owner, chainId });
|
|
236
|
+
}, [autoFetch, owner, chainId, getTakerCapacity]);
|
|
237
|
+
return react.useMemo(
|
|
238
|
+
() => ({ getTakerCapacity, takerCapacity, isLoading, error }),
|
|
239
|
+
[getTakerCapacity, takerCapacity, isLoading, error]
|
|
240
|
+
);
|
|
237
241
|
}
|
|
238
242
|
function useFulfillIntent({ client, onSuccess, onError }) {
|
|
239
243
|
const [isLoading, setIsLoading] = react.useState(false);
|
|
@@ -1566,8 +1570,6 @@ exports.asErrorMessage = asErrorMessage;
|
|
|
1566
1570
|
exports.assertDelegationMethodSupport = assertDelegationMethodSupport;
|
|
1567
1571
|
exports.classifyDelegationState = classifyDelegationState;
|
|
1568
1572
|
exports.getDelegationRoute = getDelegationRoute;
|
|
1569
|
-
exports.getNextTierCap = getNextTierCap;
|
|
1570
|
-
exports.getTierDisplayInfo = getTierDisplayInfo;
|
|
1571
1573
|
exports.isZeroRateManagerId = isZeroRateManagerId;
|
|
1572
1574
|
exports.normalizeRateManagerId = normalizeRateManagerId;
|
|
1573
1575
|
exports.normalizeRegistry = normalizeRegistry;
|
|
@@ -1578,7 +1580,8 @@ exports.useCreateDeposit = useCreateDeposit;
|
|
|
1578
1580
|
exports.useCreateVault = useCreateVault;
|
|
1579
1581
|
exports.useDeactivateCurrency = useDeactivateCurrency;
|
|
1580
1582
|
exports.useFulfillIntent = useFulfillIntent;
|
|
1581
|
-
exports.
|
|
1583
|
+
exports.useGetTakerCapacity = useGetTakerCapacity;
|
|
1584
|
+
exports.useGetTakerStake = useGetTakerStake;
|
|
1582
1585
|
exports.usePruneExpiredIntents = usePruneExpiredIntents;
|
|
1583
1586
|
exports.useReleaseFundsToPayer = useReleaseFundsToPayer;
|
|
1584
1587
|
exports.useRemoveCurrency = useRemoveCurrency;
|