@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
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, a2 as SignalIntentMethodParams, bM as PreparedTransaction, bX as TakerStake, E as GetTakerStakeRequest, F as GetTakerStakeResponse, c8 as TakerCapacity, H as GetTakerCapacityRequest, J as GetTakerCapacityResponse, a3 as FulfillIntentMethodParams, dw as SendTransactionFn, dx as SendBatchFn, du as DelegationDepositTarget, dv as BatchResult } from './vaultUtils-CxUP_m-J.mjs';
|
|
2
|
+
export { ds as DelegationRoute, dt as DelegationState, dy as VAULT_ZERO_ADDRESS, dl as ZERO_RATE_MANAGER_ID, dz as asErrorMessage, dA as assertDelegationMethodSupport, dr as classifyDelegationState, dq as getDelegationRoute, dm as isZeroRateManagerId, dn as normalizeRateManagerId, dp as normalizeRegistry } from './vaultUtils-CxUP_m-J.mjs';
|
|
3
3
|
import { Hash, Address, Hex } from 'viem';
|
|
4
4
|
import '@zkp2p/indexer-schema';
|
|
5
5
|
import 'abitype';
|
|
@@ -60,26 +60,45 @@ declare function useSignalIntent({ client, onSuccess, onError }: UseSignalIntent
|
|
|
60
60
|
prepared: PreparedTransaction | null;
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
interface
|
|
63
|
+
interface UseGetTakerStakeOptions {
|
|
64
64
|
client: Zkp2pClient | null;
|
|
65
65
|
owner?: string | null;
|
|
66
66
|
chainId?: number | null;
|
|
67
67
|
autoFetch?: boolean;
|
|
68
|
-
onSuccess?: (
|
|
68
|
+
onSuccess?: (stake: TakerStake) => void;
|
|
69
69
|
onError?: (error: Error) => void;
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Fetches the stake portfolio backing a taker: balances, reservation
|
|
73
|
+
* aggregates, delegation, and exit state.
|
|
74
|
+
*/
|
|
75
|
+
declare function useGetTakerStake({ client, owner, chainId, autoFetch, onSuccess, onError, }: UseGetTakerStakeOptions): {
|
|
76
|
+
getTakerStake: (params?: GetTakerStakeRequest) => Promise<GetTakerStakeResponse | null>;
|
|
77
|
+
takerStake: TakerStake | null;
|
|
74
78
|
isLoading: boolean;
|
|
75
79
|
error: Error | null;
|
|
76
80
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
|
|
82
|
+
interface UseGetTakerCapacityOptions {
|
|
83
|
+
client: Zkp2pClient | null;
|
|
84
|
+
owner?: string | null;
|
|
85
|
+
chainId?: number | null;
|
|
86
|
+
autoFetch?: boolean;
|
|
87
|
+
onSuccess?: (capacity: TakerCapacity) => void;
|
|
88
|
+
onError?: (error: Error) => void;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Fetches per-platform bonded taking capacity, free takes, and operational
|
|
92
|
+
* gates for a taker's shared stake portfolio. Platform capacities are
|
|
93
|
+
* alternative views of one shared balance — never sum them. Capacity can
|
|
94
|
+
* change whenever any authorized relayer uses the shared stake, so refetch
|
|
95
|
+
* immediately before signaling an intent; the contract stays authoritative.
|
|
96
|
+
*/
|
|
97
|
+
declare function useGetTakerCapacity({ client, owner, chainId, autoFetch, onSuccess, onError, }: UseGetTakerCapacityOptions): {
|
|
98
|
+
getTakerCapacity: (params?: GetTakerCapacityRequest) => Promise<GetTakerCapacityResponse | null>;
|
|
99
|
+
takerCapacity: TakerCapacity | null;
|
|
100
|
+
isLoading: boolean;
|
|
101
|
+
error: Error | null;
|
|
83
102
|
};
|
|
84
103
|
|
|
85
104
|
interface UseFulfillIntentOptions {
|
|
@@ -431,4 +450,4 @@ declare function usePruneExpiredIntents({ client, onSuccess, onError }: UsePrune
|
|
|
431
450
|
txHash: `0x${string}` | null;
|
|
432
451
|
};
|
|
433
452
|
|
|
434
|
-
export { BatchResult, type CreateVaultParams, DelegationDepositTarget, PreparedTransaction, SendBatchFn, SendTransactionFn, type UseAddCurrenciesOptions, type UseAddFundsOptions, type UseAddPaymentMethodsOptions, type UseCreateDepositOptions, type UseCreateVaultOptions, type UseDeactivateCurrencyOptions, type UseFulfillIntentOptions, type
|
|
453
|
+
export { BatchResult, type CreateVaultParams, DelegationDepositTarget, PreparedTransaction, SendBatchFn, SendTransactionFn, type UseAddCurrenciesOptions, type UseAddFundsOptions, type UseAddPaymentMethodsOptions, type UseCreateDepositOptions, type UseCreateVaultOptions, type UseDeactivateCurrencyOptions, type UseFulfillIntentOptions, type UseGetTakerCapacityOptions, type UseGetTakerStakeOptions, 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, useFulfillIntent, useGetTakerCapacity, useGetTakerStake, 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, a2 as SignalIntentMethodParams, bM as PreparedTransaction, bX as TakerStake, E as GetTakerStakeRequest, F as GetTakerStakeResponse, c8 as TakerCapacity, H as GetTakerCapacityRequest, J as GetTakerCapacityResponse, a3 as FulfillIntentMethodParams, dw as SendTransactionFn, dx as SendBatchFn, du as DelegationDepositTarget, dv as BatchResult } from './vaultUtils-CxUP_m-J.js';
|
|
2
|
+
export { ds as DelegationRoute, dt as DelegationState, dy as VAULT_ZERO_ADDRESS, dl as ZERO_RATE_MANAGER_ID, dz as asErrorMessage, dA as assertDelegationMethodSupport, dr as classifyDelegationState, dq as getDelegationRoute, dm as isZeroRateManagerId, dn as normalizeRateManagerId, dp as normalizeRegistry } from './vaultUtils-CxUP_m-J.js';
|
|
3
3
|
import { Hash, Address, Hex } from 'viem';
|
|
4
4
|
import '@zkp2p/indexer-schema';
|
|
5
5
|
import 'abitype';
|
|
@@ -60,26 +60,45 @@ declare function useSignalIntent({ client, onSuccess, onError }: UseSignalIntent
|
|
|
60
60
|
prepared: PreparedTransaction | null;
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
interface
|
|
63
|
+
interface UseGetTakerStakeOptions {
|
|
64
64
|
client: Zkp2pClient | null;
|
|
65
65
|
owner?: string | null;
|
|
66
66
|
chainId?: number | null;
|
|
67
67
|
autoFetch?: boolean;
|
|
68
|
-
onSuccess?: (
|
|
68
|
+
onSuccess?: (stake: TakerStake) => void;
|
|
69
69
|
onError?: (error: Error) => void;
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Fetches the stake portfolio backing a taker: balances, reservation
|
|
73
|
+
* aggregates, delegation, and exit state.
|
|
74
|
+
*/
|
|
75
|
+
declare function useGetTakerStake({ client, owner, chainId, autoFetch, onSuccess, onError, }: UseGetTakerStakeOptions): {
|
|
76
|
+
getTakerStake: (params?: GetTakerStakeRequest) => Promise<GetTakerStakeResponse | null>;
|
|
77
|
+
takerStake: TakerStake | null;
|
|
74
78
|
isLoading: boolean;
|
|
75
79
|
error: Error | null;
|
|
76
80
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
|
|
82
|
+
interface UseGetTakerCapacityOptions {
|
|
83
|
+
client: Zkp2pClient | null;
|
|
84
|
+
owner?: string | null;
|
|
85
|
+
chainId?: number | null;
|
|
86
|
+
autoFetch?: boolean;
|
|
87
|
+
onSuccess?: (capacity: TakerCapacity) => void;
|
|
88
|
+
onError?: (error: Error) => void;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Fetches per-platform bonded taking capacity, free takes, and operational
|
|
92
|
+
* gates for a taker's shared stake portfolio. Platform capacities are
|
|
93
|
+
* alternative views of one shared balance — never sum them. Capacity can
|
|
94
|
+
* change whenever any authorized relayer uses the shared stake, so refetch
|
|
95
|
+
* immediately before signaling an intent; the contract stays authoritative.
|
|
96
|
+
*/
|
|
97
|
+
declare function useGetTakerCapacity({ client, owner, chainId, autoFetch, onSuccess, onError, }: UseGetTakerCapacityOptions): {
|
|
98
|
+
getTakerCapacity: (params?: GetTakerCapacityRequest) => Promise<GetTakerCapacityResponse | null>;
|
|
99
|
+
takerCapacity: TakerCapacity | null;
|
|
100
|
+
isLoading: boolean;
|
|
101
|
+
error: Error | null;
|
|
83
102
|
};
|
|
84
103
|
|
|
85
104
|
interface UseFulfillIntentOptions {
|
|
@@ -431,4 +450,4 @@ declare function usePruneExpiredIntents({ client, onSuccess, onError }: UsePrune
|
|
|
431
450
|
txHash: `0x${string}` | null;
|
|
432
451
|
};
|
|
433
452
|
|
|
434
|
-
export { BatchResult, type CreateVaultParams, DelegationDepositTarget, PreparedTransaction, SendBatchFn, SendTransactionFn, type UseAddCurrenciesOptions, type UseAddFundsOptions, type UseAddPaymentMethodsOptions, type UseCreateDepositOptions, type UseCreateVaultOptions, type UseDeactivateCurrencyOptions, type UseFulfillIntentOptions, type
|
|
453
|
+
export { BatchResult, type CreateVaultParams, DelegationDepositTarget, PreparedTransaction, SendBatchFn, SendTransactionFn, type UseAddCurrenciesOptions, type UseAddFundsOptions, type UseAddPaymentMethodsOptions, type UseCreateDepositOptions, type UseCreateVaultOptions, type UseDeactivateCurrencyOptions, type UseFulfillIntentOptions, type UseGetTakerCapacityOptions, type UseGetTakerStakeOptions, 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, useFulfillIntent, useGetTakerCapacity, useGetTakerStake, 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 } from './chunk-LPJE2MN7.mjs';
|
|
2
|
+
export { ZERO_ADDRESS as VAULT_ZERO_ADDRESS, ZERO_RATE_MANAGER_ID, asErrorMessage, assertDelegationMethodSupport, classifyDelegationState, getDelegationRoute, isZeroRateManagerId, normalizeRateManagerId, normalizeRegistry } from './chunk-LPJE2MN7.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, useRef, useEffect } from 'react';
|
|
6
5
|
|
|
7
6
|
function useCreateDeposit({ client, onSuccess, onError }) {
|
|
8
7
|
const [isLoading, setIsLoading] = useState(false);
|
|
@@ -106,7 +105,7 @@ function useSignalIntent({ client, onSuccess, onError }) {
|
|
|
106
105
|
[signalIntent, prepareSignalIntent, isLoading, error, txHash, prepared]
|
|
107
106
|
);
|
|
108
107
|
}
|
|
109
|
-
function
|
|
108
|
+
function useGetTakerStake({
|
|
110
109
|
client,
|
|
111
110
|
owner,
|
|
112
111
|
chainId,
|
|
@@ -116,97 +115,129 @@ function useGetTakerTier({
|
|
|
116
115
|
}) {
|
|
117
116
|
const [isLoading, setIsLoading] = useState(false);
|
|
118
117
|
const [error, setError] = useState(null);
|
|
119
|
-
const [
|
|
120
|
-
const
|
|
118
|
+
const [takerStake, setTakerStake] = useState(null);
|
|
119
|
+
const onSuccessRef = useRef(onSuccess);
|
|
120
|
+
const onErrorRef = useRef(onError);
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
onSuccessRef.current = onSuccess;
|
|
123
|
+
onErrorRef.current = onError;
|
|
124
|
+
});
|
|
125
|
+
const requestSeqRef = useRef(0);
|
|
126
|
+
const getTakerStake = useCallback(
|
|
121
127
|
async (params) => {
|
|
122
128
|
if (!client) {
|
|
123
129
|
const err = new Error("Zkp2pClient is not initialized");
|
|
124
130
|
setError(err);
|
|
125
|
-
|
|
131
|
+
onErrorRef.current?.(err);
|
|
126
132
|
return null;
|
|
127
133
|
}
|
|
128
134
|
const request = params ?? (owner && chainId ? { owner, chainId } : null);
|
|
129
135
|
if (!request) {
|
|
130
136
|
const err = new Error("Owner address and chainId are required");
|
|
131
137
|
setError(err);
|
|
132
|
-
|
|
138
|
+
onErrorRef.current?.(err);
|
|
133
139
|
return null;
|
|
134
140
|
}
|
|
141
|
+
const requestId = ++requestSeqRef.current;
|
|
135
142
|
setIsLoading(true);
|
|
136
143
|
setError(null);
|
|
137
|
-
|
|
144
|
+
setTakerStake(null);
|
|
138
145
|
try {
|
|
139
|
-
const response = await client.
|
|
140
|
-
|
|
141
|
-
|
|
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);
|
|
142
153
|
return response;
|
|
143
154
|
} catch (err) {
|
|
155
|
+
if (requestId !== requestSeqRef.current) return null;
|
|
144
156
|
const e = err instanceof Error ? err : new Error(String(err));
|
|
145
157
|
setError(e);
|
|
146
|
-
|
|
158
|
+
onErrorRef.current?.(e);
|
|
147
159
|
return null;
|
|
148
160
|
} finally {
|
|
149
|
-
setIsLoading(false);
|
|
161
|
+
if (requestId === requestSeqRef.current) setIsLoading(false);
|
|
150
162
|
}
|
|
151
163
|
},
|
|
152
|
-
[client, owner, chainId
|
|
164
|
+
[client, owner, chainId]
|
|
153
165
|
);
|
|
154
166
|
useEffect(() => {
|
|
155
167
|
if (!autoFetch || !owner || !chainId) return;
|
|
156
|
-
void
|
|
157
|
-
}, [autoFetch, owner, chainId,
|
|
168
|
+
void getTakerStake({ owner, chainId });
|
|
169
|
+
}, [autoFetch, owner, chainId, getTakerStake]);
|
|
158
170
|
return useMemo(
|
|
159
|
-
() => ({
|
|
160
|
-
[
|
|
171
|
+
() => ({ getTakerStake, takerStake, isLoading, error }),
|
|
172
|
+
[getTakerStake, takerStake, isLoading, error]
|
|
161
173
|
);
|
|
162
174
|
}
|
|
163
|
-
function
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
175
|
+
function useGetTakerCapacity({
|
|
176
|
+
client,
|
|
177
|
+
owner,
|
|
178
|
+
chainId,
|
|
179
|
+
autoFetch = true,
|
|
180
|
+
onSuccess,
|
|
181
|
+
onError
|
|
182
|
+
}) {
|
|
183
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
184
|
+
const [error, setError] = useState(null);
|
|
185
|
+
const [takerCapacity, setTakerCapacity] = useState(null);
|
|
186
|
+
const onSuccessRef = useRef(onSuccess);
|
|
187
|
+
const onErrorRef = useRef(onError);
|
|
188
|
+
useEffect(() => {
|
|
189
|
+
onSuccessRef.current = onSuccess;
|
|
190
|
+
onErrorRef.current = onError;
|
|
191
|
+
});
|
|
192
|
+
const requestSeqRef = useRef(0);
|
|
193
|
+
const getTakerCapacity = 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
|
+
useEffect(() => {
|
|
234
|
+
if (!autoFetch || !owner || !chainId) return;
|
|
235
|
+
void getTakerCapacity({ owner, chainId });
|
|
236
|
+
}, [autoFetch, owner, chainId, getTakerCapacity]);
|
|
237
|
+
return useMemo(
|
|
238
|
+
() => ({ getTakerCapacity, takerCapacity, isLoading, error }),
|
|
239
|
+
[getTakerCapacity, takerCapacity, isLoading, error]
|
|
240
|
+
);
|
|
210
241
|
}
|
|
211
242
|
function useFulfillIntent({ client, onSuccess, onError }) {
|
|
212
243
|
const [isLoading, setIsLoading] = useState(false);
|
|
@@ -1467,6 +1498,6 @@ function usePruneExpiredIntents({ client, onSuccess, onError }) {
|
|
|
1467
1498
|
return useMemo(() => ({ pruneExpiredIntents, isLoading, error, txHash }), [pruneExpiredIntents, isLoading, error, txHash]);
|
|
1468
1499
|
}
|
|
1469
1500
|
|
|
1470
|
-
export {
|
|
1501
|
+
export { useAddCurrencies, useAddFunds, useAddPaymentMethods, useCreateDeposit, useCreateVault, useDeactivateCurrency, useFulfillIntent, useGetTakerCapacity, useGetTakerStake, usePruneExpiredIntents, useReleaseFundsToPayer, useRemoveCurrency, useRemoveDelegate, useRemoveFunds, useRemovePaymentMethod, useSetAcceptingIntents, useSetCurrencyMinRate, useSetDelegate, useSetIntentRange, useSetPaymentMethodActive, useSetRetainOnEmpty, useSetVaultConfig, useSetVaultFee, useSetVaultMinRate, useSignalIntent, useVaultDelegation, useWithdrawDeposit };
|
|
1471
1502
|
//# sourceMappingURL=react.mjs.map
|
|
1472
1503
|
//# sourceMappingURL=react.mjs.map
|