@zkp2p/sdk 0.9.0 → 0.10.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 +53 -13
- package/dist/{chunk-FSIRPX4W.mjs → chunk-7M37EVN5.mjs} +33261 -248
- package/dist/chunk-7M37EVN5.mjs.map +1 -0
- package/dist/{chunk-EIOXBVXP.mjs → chunk-LPJE2MN7.mjs} +3 -39
- package/dist/chunk-LPJE2MN7.mjs.map +1 -0
- package/dist/index.cjs +33760 -400
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +59 -60
- package/dist/index.d.ts +59 -60
- package/dist/index.mjs +389 -19
- package/dist/index.mjs.map +1 -1
- package/dist/protocolViewerParsers-VDFKSVGT.mjs +5 -0
- package/dist/{protocolViewerParsers-ER62YZ5L.mjs.map → protocolViewerParsers-VDFKSVGT.mjs.map} +1 -1
- package/dist/react.cjs +82 -93
- 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 +84 -67
- package/dist/react.mjs.map +1 -1
- package/dist/{vaultUtils-aJdIIILM.d.mts → vaultUtils-DtkWNsxi.d.mts} +388 -102
- package/dist/{vaultUtils-aJdIIILM.d.ts → vaultUtils-DtkWNsxi.d.ts} +388 -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-7M37EVN5.mjs';
|
|
2
|
+
import './chunk-ZFBH4HD7.mjs';
|
|
3
|
+
import './chunk-J5LGTIGS.mjs';
|
|
4
|
+
//# sourceMappingURL=protocolViewerParsers-VDFKSVGT.mjs.map
|
|
5
|
+
//# sourceMappingURL=protocolViewerParsers-VDFKSVGT.mjs.map
|
package/dist/{protocolViewerParsers-ER62YZ5L.mjs.map → protocolViewerParsers-VDFKSVGT.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"protocolViewerParsers-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"protocolViewerParsers-VDFKSVGT.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,115 @@ 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 getTakerStake = react.useCallback(
|
|
148
126
|
async (params) => {
|
|
149
127
|
if (!client) {
|
|
150
128
|
const err = new Error("Zkp2pClient is not initialized");
|
|
151
129
|
setError(err);
|
|
152
|
-
|
|
130
|
+
onErrorRef.current?.(err);
|
|
153
131
|
return null;
|
|
154
132
|
}
|
|
155
133
|
const request = params ?? (owner && chainId ? { owner, chainId } : null);
|
|
156
134
|
if (!request) {
|
|
157
135
|
const err = new Error("Owner address and chainId are required");
|
|
158
136
|
setError(err);
|
|
159
|
-
|
|
137
|
+
onErrorRef.current?.(err);
|
|
160
138
|
return null;
|
|
161
139
|
}
|
|
162
140
|
setIsLoading(true);
|
|
163
141
|
setError(null);
|
|
164
|
-
|
|
142
|
+
setTakerStake(null);
|
|
165
143
|
try {
|
|
166
|
-
const response = await client.
|
|
167
|
-
|
|
168
|
-
|
|
144
|
+
const response = await client.getTakerStake(request);
|
|
145
|
+
setTakerStake(response.responseObject);
|
|
146
|
+
onSuccessRef.current?.(response.responseObject);
|
|
169
147
|
return response;
|
|
170
148
|
} catch (err) {
|
|
171
149
|
const e = err instanceof Error ? err : new Error(String(err));
|
|
172
150
|
setError(e);
|
|
173
|
-
|
|
151
|
+
onErrorRef.current?.(e);
|
|
174
152
|
return null;
|
|
175
153
|
} finally {
|
|
176
154
|
setIsLoading(false);
|
|
177
155
|
}
|
|
178
156
|
},
|
|
179
|
-
[client, owner, chainId
|
|
157
|
+
[client, owner, chainId]
|
|
180
158
|
);
|
|
181
159
|
react.useEffect(() => {
|
|
182
160
|
if (!autoFetch || !owner || !chainId) return;
|
|
183
|
-
void
|
|
184
|
-
}, [autoFetch, owner, chainId,
|
|
161
|
+
void getTakerStake({ owner, chainId });
|
|
162
|
+
}, [autoFetch, owner, chainId, getTakerStake]);
|
|
185
163
|
return react.useMemo(
|
|
186
|
-
() => ({
|
|
187
|
-
[
|
|
164
|
+
() => ({ getTakerStake, takerStake, isLoading, error }),
|
|
165
|
+
[getTakerStake, takerStake, isLoading, error]
|
|
188
166
|
);
|
|
189
167
|
}
|
|
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
|
-
|
|
168
|
+
function useGetTakerCapacity({
|
|
169
|
+
client,
|
|
170
|
+
owner,
|
|
171
|
+
chainId,
|
|
172
|
+
autoFetch = true,
|
|
173
|
+
onSuccess,
|
|
174
|
+
onError
|
|
175
|
+
}) {
|
|
176
|
+
const [isLoading, setIsLoading] = react.useState(false);
|
|
177
|
+
const [error, setError] = react.useState(null);
|
|
178
|
+
const [takerCapacity, setTakerCapacity] = react.useState(null);
|
|
179
|
+
const onSuccessRef = react.useRef(onSuccess);
|
|
180
|
+
const onErrorRef = react.useRef(onError);
|
|
181
|
+
react.useEffect(() => {
|
|
182
|
+
onSuccessRef.current = onSuccess;
|
|
183
|
+
onErrorRef.current = onError;
|
|
184
|
+
});
|
|
185
|
+
const getTakerCapacity = react.useCallback(
|
|
186
|
+
async (params) => {
|
|
187
|
+
if (!client) {
|
|
188
|
+
const err = new Error("Zkp2pClient is not initialized");
|
|
189
|
+
setError(err);
|
|
190
|
+
onErrorRef.current?.(err);
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
const request = params ?? (owner && chainId ? { owner, chainId } : null);
|
|
194
|
+
if (!request) {
|
|
195
|
+
const err = new Error("Owner address and chainId are required");
|
|
196
|
+
setError(err);
|
|
197
|
+
onErrorRef.current?.(err);
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
setIsLoading(true);
|
|
201
|
+
setError(null);
|
|
202
|
+
setTakerCapacity(null);
|
|
203
|
+
try {
|
|
204
|
+
const response = await client.getTakerCapacity(request);
|
|
205
|
+
setTakerCapacity(response.responseObject);
|
|
206
|
+
onSuccessRef.current?.(response.responseObject);
|
|
207
|
+
return response;
|
|
208
|
+
} catch (err) {
|
|
209
|
+
const e = err instanceof Error ? err : new Error(String(err));
|
|
210
|
+
setError(e);
|
|
211
|
+
onErrorRef.current?.(e);
|
|
212
|
+
return null;
|
|
213
|
+
} finally {
|
|
214
|
+
setIsLoading(false);
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
[client, owner, chainId]
|
|
218
|
+
);
|
|
219
|
+
react.useEffect(() => {
|
|
220
|
+
if (!autoFetch || !owner || !chainId) return;
|
|
221
|
+
void getTakerCapacity({ owner, chainId });
|
|
222
|
+
}, [autoFetch, owner, chainId, getTakerCapacity]);
|
|
223
|
+
return react.useMemo(
|
|
224
|
+
() => ({ getTakerCapacity, takerCapacity, isLoading, error }),
|
|
225
|
+
[getTakerCapacity, takerCapacity, isLoading, error]
|
|
226
|
+
);
|
|
237
227
|
}
|
|
238
228
|
function useFulfillIntent({ client, onSuccess, onError }) {
|
|
239
229
|
const [isLoading, setIsLoading] = react.useState(false);
|
|
@@ -1566,8 +1556,6 @@ exports.asErrorMessage = asErrorMessage;
|
|
|
1566
1556
|
exports.assertDelegationMethodSupport = assertDelegationMethodSupport;
|
|
1567
1557
|
exports.classifyDelegationState = classifyDelegationState;
|
|
1568
1558
|
exports.getDelegationRoute = getDelegationRoute;
|
|
1569
|
-
exports.getNextTierCap = getNextTierCap;
|
|
1570
|
-
exports.getTierDisplayInfo = getTierDisplayInfo;
|
|
1571
1559
|
exports.isZeroRateManagerId = isZeroRateManagerId;
|
|
1572
1560
|
exports.normalizeRateManagerId = normalizeRateManagerId;
|
|
1573
1561
|
exports.normalizeRegistry = normalizeRegistry;
|
|
@@ -1578,7 +1566,8 @@ exports.useCreateDeposit = useCreateDeposit;
|
|
|
1578
1566
|
exports.useCreateVault = useCreateVault;
|
|
1579
1567
|
exports.useDeactivateCurrency = useDeactivateCurrency;
|
|
1580
1568
|
exports.useFulfillIntent = useFulfillIntent;
|
|
1581
|
-
exports.
|
|
1569
|
+
exports.useGetTakerCapacity = useGetTakerCapacity;
|
|
1570
|
+
exports.useGetTakerStake = useGetTakerStake;
|
|
1582
1571
|
exports.usePruneExpiredIntents = usePruneExpiredIntents;
|
|
1583
1572
|
exports.useReleaseFundsToPayer = useReleaseFundsToPayer;
|
|
1584
1573
|
exports.useRemoveCurrency = useRemoveCurrency;
|