@provex/react 1.2.3
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 +441 -0
- package/dist/index.cjs +2756 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1857 -0
- package/dist/index.d.ts +1857 -0
- package/dist/index.js +2722 -0
- package/dist/index.js.map +1 -0
- package/dist/styles/default.css +325 -0
- package/package.json +63 -0
- package/src/index.ts +115 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1857 @@
|
|
|
1
|
+
import * as viem from 'viem';
|
|
2
|
+
import { Hex, Chain, TransactionReceipt, PublicClient } from 'viem';
|
|
3
|
+
import { ChainId } from '@provex/utils/chain';
|
|
4
|
+
import * as _provex_utils_payment from '@provex/utils/payment';
|
|
5
|
+
import { ProviderKey, SubProviderKey, TakerTier } from '@provex/utils/payment';
|
|
6
|
+
import { UserReputation } from '@provex/utils/reputation';
|
|
7
|
+
import { Currency } from '@provex/utils/currencies';
|
|
8
|
+
import { TokenInfo } from '@provex/utils/tokens';
|
|
9
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
10
|
+
import * as React$1 from 'react';
|
|
11
|
+
import React__default from 'react';
|
|
12
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
13
|
+
import { FeeInfo } from '@provex/utils/fees';
|
|
14
|
+
import { Version } from '@provex/utils/contracts';
|
|
15
|
+
import * as _tanstack_query_core from '@tanstack/query-core';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @fileoverview Hook for fetching deposits that match a buyer's criteria.
|
|
19
|
+
*
|
|
20
|
+
* Queries the IndexerAdapter for active V3 deposits that:
|
|
21
|
+
* - Support the specified payment method
|
|
22
|
+
* - Support the specified fiat currency
|
|
23
|
+
* - Have sufficient liquidity for the requested amount
|
|
24
|
+
* - Are accepting intents
|
|
25
|
+
*
|
|
26
|
+
* @see {@link @provex/utils/payment} for provider configuration
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Lightweight deposit info returned by the hook.
|
|
31
|
+
* Maps from IndexedDeposit — same shape the UI already consumes.
|
|
32
|
+
*/
|
|
33
|
+
interface DepositInfo {
|
|
34
|
+
escrow: Hex;
|
|
35
|
+
localId: bigint;
|
|
36
|
+
chainId: number;
|
|
37
|
+
participantAddress: Hex;
|
|
38
|
+
token: Hex;
|
|
39
|
+
remaining: bigint;
|
|
40
|
+
deposited: bigint;
|
|
41
|
+
minAmount: bigint;
|
|
42
|
+
maxAmount: bigint;
|
|
43
|
+
status: string;
|
|
44
|
+
acceptingIntents: boolean;
|
|
45
|
+
availableFunds: bigint;
|
|
46
|
+
conversionRates: Map<string, Map<string, bigint>>;
|
|
47
|
+
verifierPaymentMethodIds: Set<string>;
|
|
48
|
+
}
|
|
49
|
+
/** Options for the useDeposits hook. */
|
|
50
|
+
interface UseDepositsOptions {
|
|
51
|
+
token: TokenInfo;
|
|
52
|
+
paymentMethod: ProviderKey;
|
|
53
|
+
currency?: Currency;
|
|
54
|
+
refetchIntervalMs?: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get the best (lowest) conversion rate for a deposit across the main provider
|
|
58
|
+
* and all sub-providers.
|
|
59
|
+
*
|
|
60
|
+
* Returns 0n when the deposit has no rate for the given payment method / currency.
|
|
61
|
+
*/
|
|
62
|
+
declare function getRate({ deposit, paymentMethod, currency, }: {
|
|
63
|
+
deposit: DepositInfo | null | undefined;
|
|
64
|
+
paymentMethod: ProviderKey | SubProviderKey;
|
|
65
|
+
currency: Currency;
|
|
66
|
+
}): bigint;
|
|
67
|
+
/**
|
|
68
|
+
* Hook to fetch matchable deposits from the indexer.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* const { deposits, isLoading, getMatchableDeposits } = useDeposits({
|
|
73
|
+
* token: usdcToken,
|
|
74
|
+
* paymentMethod: 'venmo',
|
|
75
|
+
* })
|
|
76
|
+
*
|
|
77
|
+
* const matches = getMatchableDeposits(parseUnits('100', { decimals: 2 }))
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
declare function useDeposits(options: UseDepositsOptions): {
|
|
81
|
+
deposits: DepositInfo[];
|
|
82
|
+
isLoading: boolean;
|
|
83
|
+
isUpdating: boolean;
|
|
84
|
+
error: Error | null;
|
|
85
|
+
refetch: () => void;
|
|
86
|
+
filterDepositsByAmount: (amountInInt: bigint) => DepositInfo[];
|
|
87
|
+
getMatchableDeposits: (amountInInt: bigint | null | string) => DepositInfo[];
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @fileoverview IndexerAdapter — data source abstraction for @provex/react.
|
|
92
|
+
*
|
|
93
|
+
* Decouples the react hooks from any specific indexer implementation.
|
|
94
|
+
* Consumers provide their own adapter:
|
|
95
|
+
* - `@provex/indexer-client` exports `createPonderAdapter()` for Ponder SQL
|
|
96
|
+
* - Third parties can implement against The Graph, REST APIs, or direct RPC
|
|
97
|
+
*
|
|
98
|
+
* All methods that return lists support optional pagination via `limit`/`cursor`.
|
|
99
|
+
* When omitted, the implementation returns all results.
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
/** Cursor-based pagination options. */
|
|
103
|
+
interface PaginationOptions {
|
|
104
|
+
/** Maximum number of results to return. */
|
|
105
|
+
limit?: number;
|
|
106
|
+
/** Opaque cursor from a previous response. Pass to fetch the next page. */
|
|
107
|
+
cursor?: string;
|
|
108
|
+
}
|
|
109
|
+
/** Paginated response wrapper. */
|
|
110
|
+
interface PaginatedResult<T> {
|
|
111
|
+
items: T[];
|
|
112
|
+
/** Cursor for the next page. Null when there are no more results. */
|
|
113
|
+
nextCursor: string | null;
|
|
114
|
+
}
|
|
115
|
+
/** A deposit with computed availability, rates, and payment method info. */
|
|
116
|
+
interface IndexedDeposit {
|
|
117
|
+
escrow: Hex;
|
|
118
|
+
localId: bigint;
|
|
119
|
+
chainId: ChainId;
|
|
120
|
+
participantAddress: Hex;
|
|
121
|
+
token: Hex;
|
|
122
|
+
remaining: bigint;
|
|
123
|
+
deposited: bigint;
|
|
124
|
+
minAmount: bigint;
|
|
125
|
+
maxAmount: bigint;
|
|
126
|
+
status: string;
|
|
127
|
+
acceptingIntents: boolean;
|
|
128
|
+
/** remaining + reclaimable - activeLocked */
|
|
129
|
+
availableFunds: bigint;
|
|
130
|
+
/** Map<paymentMethodId, Map<currencyId, rateValue>> */
|
|
131
|
+
conversionRates: Map<string, Map<string, bigint>>;
|
|
132
|
+
/** Set of payment method IDs this deposit accepts */
|
|
133
|
+
paymentMethodIds: Set<string>;
|
|
134
|
+
/** Verifier records for payee detail lookups */
|
|
135
|
+
verifiers: IndexedVerifier[];
|
|
136
|
+
}
|
|
137
|
+
/** A deposit verifier record. */
|
|
138
|
+
interface IndexedVerifier {
|
|
139
|
+
paymentMethodId: Hex;
|
|
140
|
+
payeeDetailsHash: Hex;
|
|
141
|
+
intentGatingService: Hex;
|
|
142
|
+
active: boolean;
|
|
143
|
+
}
|
|
144
|
+
/** An indexed intent with lifecycle status and expiry. */
|
|
145
|
+
interface IndexedIntent {
|
|
146
|
+
intentHash: Hex;
|
|
147
|
+
ownerAddress: Hex;
|
|
148
|
+
toAddress: Hex;
|
|
149
|
+
escrow: Hex;
|
|
150
|
+
depositLocalId: bigint;
|
|
151
|
+
amount: bigint;
|
|
152
|
+
timestamp: bigint;
|
|
153
|
+
paymentMethodId: Hex;
|
|
154
|
+
fiatCurrency: Hex;
|
|
155
|
+
conversionRate: bigint;
|
|
156
|
+
/** Expiry timestamp from fundsLocked (unix seconds), null if not locked */
|
|
157
|
+
expiryTime: bigint | null;
|
|
158
|
+
/** Lifecycle status */
|
|
159
|
+
status: 'pending' | 'signalled' | 'fulfilled' | 'pruned';
|
|
160
|
+
/** When the intent was pruned (unix seconds), null if not pruned */
|
|
161
|
+
prunedAt: bigint | null;
|
|
162
|
+
}
|
|
163
|
+
/** Pre-computed reputation data for tier calculation. */
|
|
164
|
+
interface ReputationData {
|
|
165
|
+
/** Total fulfilled volume in USDC (human-readable, e.g. 1500.50) */
|
|
166
|
+
fulfilledVolumeUsdc: number;
|
|
167
|
+
/** Number of fulfilled intents */
|
|
168
|
+
fulfilledCount: number;
|
|
169
|
+
/** Number of late cancellations (>15 min after signal) */
|
|
170
|
+
lateCancellations: number;
|
|
171
|
+
/** Unix timestamp (seconds) of most recent signaled intent per chain. Null if never signaled. */
|
|
172
|
+
lastSignaledAt: Partial<Record<ChainId, bigint>>;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Data source abstraction for @provex/react.
|
|
176
|
+
*
|
|
177
|
+
* Every method that returns a list accepts optional `PaginationOptions`.
|
|
178
|
+
* For batch queries, callers can specify multiple filter keys.
|
|
179
|
+
*
|
|
180
|
+
* Implementations:
|
|
181
|
+
* - `createPonderAdapter(ponderClient)` from `@provex/indexer-client`
|
|
182
|
+
* - Custom REST/Graph/RPC implementations
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```ts
|
|
186
|
+
* // Using the Ponder adapter
|
|
187
|
+
* import { createPonderAdapter } from '@provex/indexer-client'
|
|
188
|
+
* const indexer = createPonderAdapter(ponderClient)
|
|
189
|
+
*
|
|
190
|
+
* // Using a custom REST API
|
|
191
|
+
* const indexer: IndexerAdapter = {
|
|
192
|
+
* getMatchableDeposits: ({ chainId, token, currencyId }) =>
|
|
193
|
+
* fetch(`/api/deposits?chain=${chainId}&token=${token}¤cy=${currencyId}`)
|
|
194
|
+
* .then(r => r.json()),
|
|
195
|
+
* // ...
|
|
196
|
+
* }
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
interface IndexerAdapter {
|
|
200
|
+
/**
|
|
201
|
+
* Fetch active V3 deposits that match buyer criteria.
|
|
202
|
+
*
|
|
203
|
+
* Returns deposits with computed availability (remaining + reclaimable - locked),
|
|
204
|
+
* active conversion rates, and payment method IDs.
|
|
205
|
+
*
|
|
206
|
+
* The implementation should:
|
|
207
|
+
* - Filter to active, v3, acceptingIntents deposits on the given chain/token
|
|
208
|
+
* - Filter to deposits supporting the given currency
|
|
209
|
+
* - Include conversion rates and verifier data
|
|
210
|
+
* - Compute availableFunds from locked/unlocked/transferred events
|
|
211
|
+
*
|
|
212
|
+
* @param params.chainId - Chain to query
|
|
213
|
+
* @param params.token - Token address to filter by
|
|
214
|
+
* @param params.currencyId - Fiat currency contract ID to filter by
|
|
215
|
+
* @param params.pagination - Optional limit/cursor
|
|
216
|
+
*/
|
|
217
|
+
getMatchableDeposits(params: {
|
|
218
|
+
chainId: ChainId;
|
|
219
|
+
token: Hex;
|
|
220
|
+
currencyId: Hex;
|
|
221
|
+
pagination?: PaginationOptions;
|
|
222
|
+
}): Promise<PaginatedResult<IndexedDeposit>>;
|
|
223
|
+
/**
|
|
224
|
+
* Fetch a single deposit with its verifiers.
|
|
225
|
+
*
|
|
226
|
+
* Used by usePayeeDetails to look up deposit info after an intent is signaled.
|
|
227
|
+
*/
|
|
228
|
+
getDepositWithVerifiers(params: {
|
|
229
|
+
escrow: Hex;
|
|
230
|
+
localId: bigint;
|
|
231
|
+
chainId: ChainId;
|
|
232
|
+
}): Promise<IndexedDeposit | null>;
|
|
233
|
+
/**
|
|
234
|
+
* Fetch intent details including expiry time and lifecycle status.
|
|
235
|
+
*
|
|
236
|
+
* Combines intent signal data, lock data, and status (fulfilled/pruned/signalled)
|
|
237
|
+
* into a single response.
|
|
238
|
+
*/
|
|
239
|
+
getIntent(params: {
|
|
240
|
+
intentHash: Hex;
|
|
241
|
+
chainId: ChainId;
|
|
242
|
+
}): Promise<IndexedIntent | null>;
|
|
243
|
+
/**
|
|
244
|
+
* Get the payee details hash for a deposit's payment method.
|
|
245
|
+
*
|
|
246
|
+
* Used before signaling an intent — the gating service needs this hash.
|
|
247
|
+
*
|
|
248
|
+
* @returns The payeeDetailsHash, or null if no verifier is found
|
|
249
|
+
*/
|
|
250
|
+
getPayeeDetailsHash(params: {
|
|
251
|
+
escrow: Hex;
|
|
252
|
+
localId: bigint;
|
|
253
|
+
chainId: ChainId;
|
|
254
|
+
paymentMethodId: Hex;
|
|
255
|
+
}): Promise<Hex | null>;
|
|
256
|
+
/**
|
|
257
|
+
* Get user's reputation data for tier calculation.
|
|
258
|
+
*
|
|
259
|
+
* Returns pre-computed stats that the reputation hook uses to derive
|
|
260
|
+
* the tier, lock score, and cooldown.
|
|
261
|
+
*
|
|
262
|
+
* @param params.address - User's wallet address
|
|
263
|
+
* @param params.chainId - Optional chain filter. When set, only counts
|
|
264
|
+
* activity on that chain. When omitted, counts all chains.
|
|
265
|
+
*/
|
|
266
|
+
getUserReputation(params: {
|
|
267
|
+
address: Hex;
|
|
268
|
+
chainId?: ChainId;
|
|
269
|
+
}): Promise<ReputationData>;
|
|
270
|
+
/**
|
|
271
|
+
* Check if a transaction has been indexed.
|
|
272
|
+
* Returns a truthy value when indexed, null when not yet.
|
|
273
|
+
*/
|
|
274
|
+
getTransactionByHash(hash: Hex): Promise<unknown | null>;
|
|
275
|
+
/**
|
|
276
|
+
* Check a deposit's current indexed status.
|
|
277
|
+
* Returns null if the deposit isn't indexed yet.
|
|
278
|
+
*/
|
|
279
|
+
getDepositById(depositId: Hex): Promise<{
|
|
280
|
+
status: string;
|
|
281
|
+
} | null>;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* @fileoverview Types for the ProveXClient — framework-agnostic protocol client.
|
|
286
|
+
*/
|
|
287
|
+
|
|
288
|
+
interface ProveXClientConfig {
|
|
289
|
+
/**
|
|
290
|
+
* The viem Chain object to operate on. Provides chain ID, RPC URLs,
|
|
291
|
+
* block explorers, and native currency config.
|
|
292
|
+
*
|
|
293
|
+
* Import from `viem/chains` or define your own for custom RPCs / testnets.
|
|
294
|
+
*
|
|
295
|
+
* @example
|
|
296
|
+
* ```ts
|
|
297
|
+
* import { base, pulsechain } from 'viem/chains'
|
|
298
|
+
*
|
|
299
|
+
* // Standard chain
|
|
300
|
+
* createProveXClient({ chain: base })
|
|
301
|
+
*
|
|
302
|
+
* // Custom RPC
|
|
303
|
+
* createProveXClient({
|
|
304
|
+
* chain: { ...base, rpcUrls: { default: { http: ['https://my-rpc.com'] } } }
|
|
305
|
+
* })
|
|
306
|
+
*
|
|
307
|
+
* // Testnet
|
|
308
|
+
* createProveXClient({ chain: pulsechainV4, escrowAddress: '0x...' })
|
|
309
|
+
* ```
|
|
310
|
+
*/
|
|
311
|
+
chain: Chain;
|
|
312
|
+
/**
|
|
313
|
+
* Backend API URL. Defaults to `https://app.provex.com`.
|
|
314
|
+
* Override for self-hosted or staging deployments.
|
|
315
|
+
*/
|
|
316
|
+
apiUrl?: string;
|
|
317
|
+
/**
|
|
318
|
+
* Wallet adapter for signing transactions.
|
|
319
|
+
* Omit for prepare-only mode (`.prepare()` works without a wallet).
|
|
320
|
+
*/
|
|
321
|
+
wallet?: WalletAdapter;
|
|
322
|
+
/**
|
|
323
|
+
* Data source adapter for indexer queries.
|
|
324
|
+
* Omit if you only need on-chain reads and `.prepare()`.
|
|
325
|
+
*/
|
|
326
|
+
indexer?: IndexerAdapter;
|
|
327
|
+
/** Override the default V3 escrow address for this chain. */
|
|
328
|
+
escrowAddress?: Hex;
|
|
329
|
+
/** Called with the tx hash immediately after wallet submission. */
|
|
330
|
+
onTransactionHash?: (hash: Hex) => void;
|
|
331
|
+
/** Called when indexer sync takes longer than expected. */
|
|
332
|
+
onSlowSync?: () => void;
|
|
333
|
+
}
|
|
334
|
+
/** Framework-agnostic wallet interface. Works with wagmi, ethers, or custom. */
|
|
335
|
+
interface WalletAdapter {
|
|
336
|
+
/** Connected address, or undefined if disconnected. */
|
|
337
|
+
address?: Hex;
|
|
338
|
+
/** Sign and send a transaction. Returns the tx hash. */
|
|
339
|
+
sendTransaction(tx: {
|
|
340
|
+
to: Hex;
|
|
341
|
+
data: Hex;
|
|
342
|
+
value?: bigint;
|
|
343
|
+
chainId: number;
|
|
344
|
+
maxFeePerGas?: bigint;
|
|
345
|
+
maxPriorityFeePerGas?: bigint;
|
|
346
|
+
}): Promise<Hex>;
|
|
347
|
+
/** Read from a contract (optional — falls back to public RPC). */
|
|
348
|
+
readContract?(params: {
|
|
349
|
+
address: Hex;
|
|
350
|
+
abi: readonly unknown[];
|
|
351
|
+
functionName: string;
|
|
352
|
+
args?: readonly unknown[];
|
|
353
|
+
chainId?: number;
|
|
354
|
+
}): Promise<unknown>;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Unsigned transaction data. Pass to any wallet, multisig, relayer, or batch builder.
|
|
358
|
+
*
|
|
359
|
+
* @example
|
|
360
|
+
* ```ts
|
|
361
|
+
* const prepared = await client.addFunds.prepare({ depositId: 1n, amount: 100n })
|
|
362
|
+
* // Hand to Safe SDK, Privy, gasless relay, etc.
|
|
363
|
+
* await safeSDK.createTransaction({ transactions: [prepared] })
|
|
364
|
+
* ```
|
|
365
|
+
*/
|
|
366
|
+
interface PreparedTransaction {
|
|
367
|
+
to: Hex;
|
|
368
|
+
data: Hex;
|
|
369
|
+
value: bigint;
|
|
370
|
+
chainId: number;
|
|
371
|
+
}
|
|
372
|
+
/** Result of a fully executed transaction. */
|
|
373
|
+
interface TransactionResult {
|
|
374
|
+
hash: Hex;
|
|
375
|
+
receipt: TransactionReceipt;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* A protocol write operation. Callable to execute the full lifecycle,
|
|
379
|
+
* or use `.prepare()` to get unsigned transaction data.
|
|
380
|
+
*
|
|
381
|
+
* @example
|
|
382
|
+
* ```ts
|
|
383
|
+
* // Full execute: gas → wallet → receipt → indexer sync
|
|
384
|
+
* const { hash } = await client.addFunds({ depositId: 1n, amount: 100n })
|
|
385
|
+
*
|
|
386
|
+
* // Prepare only: returns { to, data, value, chainId }
|
|
387
|
+
* const prepared = await client.addFunds.prepare({ depositId: 1n, amount: 100n })
|
|
388
|
+
* ```
|
|
389
|
+
*/
|
|
390
|
+
interface WritableMethod<TParams> {
|
|
391
|
+
/** Execute the full transaction lifecycle. Requires a wallet. */
|
|
392
|
+
(params: TParams): Promise<TransactionResult>;
|
|
393
|
+
/** Return unsigned transaction data only. No wallet needed. */
|
|
394
|
+
prepare(params: TParams): Promise<PreparedTransaction>;
|
|
395
|
+
}
|
|
396
|
+
type ProveXErrorCode = 'WALLET_REJECTED' | 'WALLET_NOT_CONNECTED' | 'TX_REVERTED' | 'INSUFFICIENT_FUNDS' | 'INSUFFICIENT_LIQUIDITY' | 'INDEXER_TIMEOUT' | 'INDEXER_NOT_CONFIGURED' | 'CONTRACT_ERROR' | 'API_ERROR' | 'VALIDATION_ERROR' | 'UNKNOWN';
|
|
397
|
+
/**
|
|
398
|
+
* Typed error for ProveX protocol operations.
|
|
399
|
+
* Non-React consumers catch these directly; React hooks map them to UI state.
|
|
400
|
+
*/
|
|
401
|
+
declare class ProveXError extends Error {
|
|
402
|
+
readonly code: ProveXErrorCode;
|
|
403
|
+
readonly cause?: Error;
|
|
404
|
+
constructor(code: ProveXErrorCode, message: string, cause?: Error);
|
|
405
|
+
/** Check if this error was caused by the user rejecting in their wallet. */
|
|
406
|
+
get isRejection(): boolean;
|
|
407
|
+
}
|
|
408
|
+
/** Options for registering or validating a maker's payment identity. */
|
|
409
|
+
interface MakerRegistrationParams {
|
|
410
|
+
/** Payment provider key (e.g. 'venmo', 'zelle', 'revolut') */
|
|
411
|
+
providerKey: string;
|
|
412
|
+
/** Provider-specific user ID (e.g. Venmo username, Zelle phone) */
|
|
413
|
+
providerId: string;
|
|
414
|
+
/** Optional Telegram handle for contact */
|
|
415
|
+
telegramHandle?: string;
|
|
416
|
+
}
|
|
417
|
+
/** Payee details returned by the API. */
|
|
418
|
+
interface PayeeDetails {
|
|
419
|
+
payeeId?: string;
|
|
420
|
+
name?: string;
|
|
421
|
+
platformName?: string;
|
|
422
|
+
[key: string]: unknown;
|
|
423
|
+
}
|
|
424
|
+
/** Attestation request for zkTLS proof submission. */
|
|
425
|
+
interface AttestationParams {
|
|
426
|
+
/** Payment platform (e.g. 'chase', 'venmo') */
|
|
427
|
+
platform: string;
|
|
428
|
+
/** Action type (e.g. 'transfer_zelle', 'transfer_venmo') */
|
|
429
|
+
actionType: string;
|
|
430
|
+
/** Reclaim proofs */
|
|
431
|
+
proofs: unknown[];
|
|
432
|
+
/** Chain ID for the attestation */
|
|
433
|
+
chainId: number;
|
|
434
|
+
/** Verifying contract address */
|
|
435
|
+
verifyingContract: Hex;
|
|
436
|
+
/** Intent data for the attestation */
|
|
437
|
+
intent: unknown;
|
|
438
|
+
}
|
|
439
|
+
/** Attestation response with signed payment proof. */
|
|
440
|
+
interface AttestationResponse {
|
|
441
|
+
success: boolean;
|
|
442
|
+
message?: string;
|
|
443
|
+
statusCode?: number;
|
|
444
|
+
responseObject: {
|
|
445
|
+
paymentProof?: unknown;
|
|
446
|
+
[key: string]: unknown;
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Human-readable params for signaling an intent (buyer side).
|
|
451
|
+
*
|
|
452
|
+
* The SDK handles:
|
|
453
|
+
* 1. Looking up payee details from the indexer
|
|
454
|
+
* 2. Requesting a gating service signature from the API
|
|
455
|
+
* 3. Building and simulating the on-chain transaction
|
|
456
|
+
* 4. Extracting the intent hash from the IntentSignaled event
|
|
457
|
+
*
|
|
458
|
+
* @example
|
|
459
|
+
* ```ts
|
|
460
|
+
* const { hash, intentHash } = await client.signalIntent({
|
|
461
|
+
* deposit: { escrow: '0x...', localId: 1n },
|
|
462
|
+
* paymentMethod: '0x...', // bytes32 payment method hash
|
|
463
|
+
* tokenAmount: 100_000000n,
|
|
464
|
+
* toAddress: '0x...',
|
|
465
|
+
* fiatCurrencyCode: '0x...', // bytes32 currency code hash
|
|
466
|
+
* conversionRate: 1_000000000000000000n,
|
|
467
|
+
* })
|
|
468
|
+
* ```
|
|
469
|
+
*/
|
|
470
|
+
interface SignalIntentParams {
|
|
471
|
+
deposit: {
|
|
472
|
+
escrow: Hex;
|
|
473
|
+
localId: bigint;
|
|
474
|
+
};
|
|
475
|
+
paymentMethod: Hex;
|
|
476
|
+
tokenAmount: bigint;
|
|
477
|
+
toAddress: Hex;
|
|
478
|
+
fiatCurrencyCode: Hex;
|
|
479
|
+
conversionRate: bigint;
|
|
480
|
+
subProvider?: string;
|
|
481
|
+
}
|
|
482
|
+
/** Result of a signalIntent call. Extends TransactionResult with the intent hash. */
|
|
483
|
+
interface SignalIntentResult extends TransactionResult {
|
|
484
|
+
/** The on-chain intent hash, extracted from the IntentSignaled event. */
|
|
485
|
+
intentHash: Hex;
|
|
486
|
+
}
|
|
487
|
+
/** Raw on-chain params matching the Orchestrator's signalIntent signature. */
|
|
488
|
+
interface SignalIntentRawParams {
|
|
489
|
+
escrow: Hex;
|
|
490
|
+
depositId: bigint;
|
|
491
|
+
amount: bigint;
|
|
492
|
+
to: Hex;
|
|
493
|
+
paymentMethod: Hex;
|
|
494
|
+
fiatCurrency: Hex;
|
|
495
|
+
conversionRate: bigint;
|
|
496
|
+
referrer: Hex;
|
|
497
|
+
referrerFee: bigint;
|
|
498
|
+
gatingServiceSignature: Hex;
|
|
499
|
+
signatureExpiration: bigint;
|
|
500
|
+
postIntentHook: Hex;
|
|
501
|
+
data: Hex;
|
|
502
|
+
}
|
|
503
|
+
/** Raw contract-level params matching the V3 Escrow's createDeposit signature. */
|
|
504
|
+
interface CreateDepositRawParams {
|
|
505
|
+
token: Hex;
|
|
506
|
+
amount: bigint;
|
|
507
|
+
intentAmountRange: {
|
|
508
|
+
min: bigint;
|
|
509
|
+
max: bigint;
|
|
510
|
+
};
|
|
511
|
+
paymentMethods: Hex[];
|
|
512
|
+
paymentMethodData: Array<{
|
|
513
|
+
intentGatingService: Hex;
|
|
514
|
+
payeeDetails: Hex;
|
|
515
|
+
data: Hex;
|
|
516
|
+
}>;
|
|
517
|
+
currencies: Array<Array<{
|
|
518
|
+
code: Hex;
|
|
519
|
+
minConversionRate: bigint;
|
|
520
|
+
}>>;
|
|
521
|
+
delegate: Hex;
|
|
522
|
+
intentGuardian: Hex;
|
|
523
|
+
retainOnEmpty: boolean;
|
|
524
|
+
}
|
|
525
|
+
/** A payment method to include in a new deposit. */
|
|
526
|
+
interface DepositPaymentMethod {
|
|
527
|
+
/** Provider key (e.g., 'venmo', 'zelle', 'revolut', 'wise'). */
|
|
528
|
+
provider: string;
|
|
529
|
+
/** Plaintext payee identifier — SDK hashes and registers it automatically. */
|
|
530
|
+
payeeId: string;
|
|
531
|
+
/**
|
|
532
|
+
* Currencies this payment method accepts, with minimum conversion rates.
|
|
533
|
+
*
|
|
534
|
+
* @example
|
|
535
|
+
* ```ts
|
|
536
|
+
* currencies: [
|
|
537
|
+
* { code: 'USD', minRate: 0n }, // accept any rate
|
|
538
|
+
* { code: 'EUR', minRate: 980000000000000000n }, // min 0.98 EUR/USDC
|
|
539
|
+
* ]
|
|
540
|
+
* ```
|
|
541
|
+
*/
|
|
542
|
+
currencies: Array<{
|
|
543
|
+
code: string;
|
|
544
|
+
minRate: bigint;
|
|
545
|
+
}>;
|
|
546
|
+
/**
|
|
547
|
+
* Custom intent gating service address. Defaults to the protocol's
|
|
548
|
+
* standard Reclaim gating service for this chain.
|
|
549
|
+
*/
|
|
550
|
+
intentGatingService?: Hex;
|
|
551
|
+
/**
|
|
552
|
+
* Custom data field for the payment method (encoded ABI params).
|
|
553
|
+
* Defaults to the standard Reclaim witness signer encoding.
|
|
554
|
+
*/
|
|
555
|
+
data?: Hex;
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Human-readable params for creating a deposit.
|
|
559
|
+
* The SDK handles hashing, sub-provider expansion, maker registration, and
|
|
560
|
+
* all the encoding needed to build the on-chain transaction.
|
|
561
|
+
*
|
|
562
|
+
* @example
|
|
563
|
+
* ```ts
|
|
564
|
+
* await client.createDeposit({
|
|
565
|
+
* token: USDC_ADDRESS,
|
|
566
|
+
* amount: 1000_000000n,
|
|
567
|
+
* intentRange: { min: 10_000000n, max: 500_000000n },
|
|
568
|
+
* paymentMethods: [
|
|
569
|
+
* { provider: 'venmo', payeeId: '@myvenmo', currencies: [{ code: 'USD', minRate: 0n }] },
|
|
570
|
+
* ],
|
|
571
|
+
* })
|
|
572
|
+
* ```
|
|
573
|
+
*/
|
|
574
|
+
interface CreateDepositParams$1 {
|
|
575
|
+
/** ERC-20 token address (e.g., USDC). */
|
|
576
|
+
token: Hex;
|
|
577
|
+
/** Deposit amount in the token's smallest unit (e.g., 6 decimals for USDC). */
|
|
578
|
+
amount: bigint;
|
|
579
|
+
/**
|
|
580
|
+
* Min/max intent amount range buyers can signal.
|
|
581
|
+
* `min` defaults to 1_000000n (1 USDC). `max` defaults to `amount`.
|
|
582
|
+
*/
|
|
583
|
+
intentRange?: {
|
|
584
|
+
min?: bigint;
|
|
585
|
+
max?: bigint;
|
|
586
|
+
};
|
|
587
|
+
/** Payment methods the depositor accepts. */
|
|
588
|
+
paymentMethods: DepositPaymentMethod[];
|
|
589
|
+
/** Optional Telegram handle for buyer-seller contact. */
|
|
590
|
+
telegramHandle?: string;
|
|
591
|
+
/** Delegate address that can manage this deposit. Defaults to zero (no delegate). */
|
|
592
|
+
delegate?: Hex;
|
|
593
|
+
/** Guardian address for intent gating. Defaults to zero (no guardian). */
|
|
594
|
+
intentGuardian?: Hex;
|
|
595
|
+
/** Keep deposit active even when fully claimed. Defaults to false. */
|
|
596
|
+
retainOnEmpty?: boolean;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* @fileoverview React hook for the V3 intent signaling flow.
|
|
601
|
+
*
|
|
602
|
+
* Thin state wrapper around ProveXClient.signalIntent() —
|
|
603
|
+
* manages status, error messages, and loading state for the UI.
|
|
604
|
+
*/
|
|
605
|
+
|
|
606
|
+
/** Status of the signal intent flow. */
|
|
607
|
+
type SignalIntentStatus = 'input' | 'loading_payee' | 'loading_intent' | 'prompt_wallet_confirm' | 'writing_intent' | 'success' | 'error';
|
|
608
|
+
/**
|
|
609
|
+
* Hook for signaling intent to buy tokens via the V3 Orchestrator.
|
|
610
|
+
*
|
|
611
|
+
* Delegates to ProveXClient.signalIntent() for the full multi-step flow:
|
|
612
|
+
* 1. Fetch payee details from indexer
|
|
613
|
+
* 2. Request gating signature from API
|
|
614
|
+
* 3. Simulate, submit, and parse IntentSignaled event
|
|
615
|
+
*
|
|
616
|
+
* @example
|
|
617
|
+
* ```ts
|
|
618
|
+
* const { startOrder, status, message, isLoading } = useSignalIntent({
|
|
619
|
+
* wallet,
|
|
620
|
+
* chainId: 369,
|
|
621
|
+
* deposit: selectedDeposit,
|
|
622
|
+
* onSuccess: (intentHash) => navigate(`/verify/${intentHash}`),
|
|
623
|
+
* })
|
|
624
|
+
* ```
|
|
625
|
+
*/
|
|
626
|
+
declare function useSignalIntent({ wallet, onSuccess, onFailure, deposit, refetchDeposits, }: {
|
|
627
|
+
/** Wallet adapter for signing transactions. */
|
|
628
|
+
wallet: WalletAdapter;
|
|
629
|
+
/** @deprecated Chain is resolved from ProvexProvider. Kept for API compat. */
|
|
630
|
+
chainId?: ChainId;
|
|
631
|
+
/** Called when the intent is signaled successfully. */
|
|
632
|
+
onSuccess: (intentHash: Hex) => void;
|
|
633
|
+
/** Called when the flow fails. */
|
|
634
|
+
onFailure?: () => void;
|
|
635
|
+
/** The deposit to signal intent against. */
|
|
636
|
+
deposit: DepositInfo | null;
|
|
637
|
+
/** Called on failure to refresh deposit data. */
|
|
638
|
+
refetchDeposits?: () => void;
|
|
639
|
+
}): {
|
|
640
|
+
startOrder: ({ paymentMethod, depositId, tokenAmount, toAddress, fiatCurrencyCode, conversionRate, subProvider, }: {
|
|
641
|
+
paymentMethod: Hex;
|
|
642
|
+
depositId: bigint;
|
|
643
|
+
tokenAmount: bigint;
|
|
644
|
+
toAddress: Hex;
|
|
645
|
+
fiatCurrencyCode: Hex;
|
|
646
|
+
conversionRate: bigint;
|
|
647
|
+
subProvider?: SubProviderKey;
|
|
648
|
+
}) => Promise<void>;
|
|
649
|
+
status: SignalIntentStatus;
|
|
650
|
+
message: string | null;
|
|
651
|
+
isLoading: boolean;
|
|
652
|
+
};
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* @fileoverview Hook for calculating reputation-based trading limits.
|
|
656
|
+
*
|
|
657
|
+
* Applies tier-based restrictions on transaction caps and cooldowns.
|
|
658
|
+
* Pure computation -- no Ponder, no contract reads.
|
|
659
|
+
*
|
|
660
|
+
* @see {@link useReputation} for fetching the user's tier
|
|
661
|
+
* @see {@link @provex/utils/reputation} for tier definitions
|
|
662
|
+
*/
|
|
663
|
+
|
|
664
|
+
/** Input parameters for calculating reputation limits. */
|
|
665
|
+
interface ReputationLimitsParams {
|
|
666
|
+
/** Current chain ID */
|
|
667
|
+
chainId: ChainId;
|
|
668
|
+
/** Currently selected payment method */
|
|
669
|
+
selectedPaymentMethod: ProviderKey;
|
|
670
|
+
/** User's reputation tier */
|
|
671
|
+
tier: TakerTier;
|
|
672
|
+
/** Amount in fiat currency (for cap exceeded check) - in token base units (e.g., 6 decimals for USDC) */
|
|
673
|
+
amountInInt?: bigint | null;
|
|
674
|
+
/** When the user's cooldown ends (from useReputation) */
|
|
675
|
+
cooldownEndsAt?: Date | null;
|
|
676
|
+
}
|
|
677
|
+
/** Result of the useReputationLimits hook. */
|
|
678
|
+
interface ReputationLimits {
|
|
679
|
+
/** Whether reputation limits apply */
|
|
680
|
+
hasLimits: boolean;
|
|
681
|
+
/** Alternative providers with no cooldown */
|
|
682
|
+
noCooldownProviders: ProviderKey[];
|
|
683
|
+
/** Cooldown hours for the selected payment method (category, not remaining) */
|
|
684
|
+
selectedProviderCooldownHours: number;
|
|
685
|
+
/** Remaining cooldown time in formatted string (e.g., "5h 30m") - null if not on cooldown */
|
|
686
|
+
cooldownRemaining: string | null;
|
|
687
|
+
/** Whether user is currently on cooldown for the selected payment method */
|
|
688
|
+
isOnCooldown: boolean;
|
|
689
|
+
/** Effective cap in USD for the selected payment method (null if no cap) */
|
|
690
|
+
effectiveCap: number | null;
|
|
691
|
+
/** Whether the current amount exceeds the cap */
|
|
692
|
+
amountExceedsCap: boolean;
|
|
693
|
+
/** Error message when cap is exceeded */
|
|
694
|
+
capExceededMessage: string | null;
|
|
695
|
+
}
|
|
696
|
+
/**
|
|
697
|
+
* Hook to calculate reputation-based limits for payment methods.
|
|
698
|
+
*
|
|
699
|
+
* @example
|
|
700
|
+
* ```ts
|
|
701
|
+
* const {
|
|
702
|
+
* noCooldownProviders,
|
|
703
|
+
* selectedProviderCooldownHours,
|
|
704
|
+
* effectiveCap,
|
|
705
|
+
* amountExceedsCap,
|
|
706
|
+
* capExceededMessage,
|
|
707
|
+
* } = useReputationLimits({
|
|
708
|
+
* chainId,
|
|
709
|
+
* selectedPaymentMethod,
|
|
710
|
+
* tier: reputation.tier,
|
|
711
|
+
* amountInInt,
|
|
712
|
+
* })
|
|
713
|
+
* ```
|
|
714
|
+
*/
|
|
715
|
+
declare function useReputationLimits({ chainId, selectedPaymentMethod, tier, amountInInt, cooldownEndsAt, }: ReputationLimitsParams): ReputationLimits;
|
|
716
|
+
|
|
717
|
+
/**
|
|
718
|
+
* @fileoverview Hook for reading protocol fee configuration.
|
|
719
|
+
*
|
|
720
|
+
* Fetches the current protocol fee percentage and recipient address
|
|
721
|
+
* from the Orchestrator contract via wagmi.
|
|
722
|
+
*
|
|
723
|
+
* @remarks
|
|
724
|
+
* Fees may be stored as basis points (bps) or 18-decimal precision
|
|
725
|
+
* depending on the chain. This hook normalizes both to a consistent format.
|
|
726
|
+
*
|
|
727
|
+
* @see {@link @provex/utils/fees} for fee calculation utilities
|
|
728
|
+
*/
|
|
729
|
+
|
|
730
|
+
/** Result of the useProtocolFees hook. */
|
|
731
|
+
interface ProtocolFeesResult {
|
|
732
|
+
/** Raw protocol fee value from contract (may be bps or 18-decimal) */
|
|
733
|
+
protocolFeeRaw: bigint | undefined;
|
|
734
|
+
/** Normalized fee info with percentage string and bps value */
|
|
735
|
+
feeInfo: FeeInfo | undefined;
|
|
736
|
+
/** Address that receives protocol fees */
|
|
737
|
+
protocolFeeRecipient: Hex | undefined;
|
|
738
|
+
/** Orchestrator contract address (read from escrow) */
|
|
739
|
+
orchestratorAddress: Hex | undefined;
|
|
740
|
+
/** True while loading fee data */
|
|
741
|
+
isLoading: boolean;
|
|
742
|
+
/** True if an error occurred */
|
|
743
|
+
isError: boolean;
|
|
744
|
+
/** Error object if an error occurred */
|
|
745
|
+
error: Error | null;
|
|
746
|
+
/** Refetch fee data */
|
|
747
|
+
refetch: () => void;
|
|
748
|
+
}
|
|
749
|
+
/** Hook parameters for useProtocolFees. */
|
|
750
|
+
interface UseProtocolFeesParams {
|
|
751
|
+
/** The chain ID to read fees from */
|
|
752
|
+
chainId: ChainId;
|
|
753
|
+
/** V3 Escrow contract address (orchestrator is read from this) */
|
|
754
|
+
escrowAddress: Hex;
|
|
755
|
+
/** Whether to enable the query (defaults to true) */
|
|
756
|
+
enabled?: boolean;
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Hook to read protocol fees from the V3 Orchestrator contract.
|
|
760
|
+
*
|
|
761
|
+
* The V3 Orchestrator charges a protocol fee on intent fulfillment.
|
|
762
|
+
* This hook reads:
|
|
763
|
+
* 1. Orchestrator address from the Escrow contract
|
|
764
|
+
* 2. Protocol fee (as bps or 18-decimal precision)
|
|
765
|
+
* 3. Protocol fee recipient address
|
|
766
|
+
*
|
|
767
|
+
* Fee precision is automatically detected and normalized to basis points.
|
|
768
|
+
*
|
|
769
|
+
* Requires a wagmi `WagmiProvider` ancestor in the component tree.
|
|
770
|
+
*
|
|
771
|
+
* @param params - Hook parameters
|
|
772
|
+
* @returns Protocol fee data and loading state
|
|
773
|
+
*
|
|
774
|
+
* @example
|
|
775
|
+
* ```tsx
|
|
776
|
+
* const { feeInfo, isLoading } = useProtocolFees({
|
|
777
|
+
* chainId: 8453,
|
|
778
|
+
* escrowAddress: '0x2f121CDDCA6d652f35e8B3E560f9760898888888',
|
|
779
|
+
* })
|
|
780
|
+
*
|
|
781
|
+
* if (!isLoading && feeInfo) {
|
|
782
|
+
* console.log(`Protocol fee: ${feeInfo.percentage}`) // "0%" or "2%"
|
|
783
|
+
* }
|
|
784
|
+
* ```
|
|
785
|
+
*/
|
|
786
|
+
declare function useProtocolFees({ chainId, escrowAddress, enabled, }: UseProtocolFeesParams): ProtocolFeesResult;
|
|
787
|
+
/**
|
|
788
|
+
* Simplified hook to get just the protocol fee percentage for a chain.
|
|
789
|
+
*
|
|
790
|
+
* @param params - Hook parameters
|
|
791
|
+
* @returns The fee percentage string (e.g., "0%", "2%") or undefined if loading
|
|
792
|
+
*/
|
|
793
|
+
declare function useProtocolFeePercentage(params: UseProtocolFeesParams): string | undefined;
|
|
794
|
+
|
|
795
|
+
/**
|
|
796
|
+
* @fileoverview Hook for fetching user reputation (taker tier).
|
|
797
|
+
*
|
|
798
|
+
* Calculates the user's reputation tier based on:
|
|
799
|
+
* - Fulfilled volume (in USDC, 1:1 with USD)
|
|
800
|
+
* - Lock score (penalty for cancellations)
|
|
801
|
+
* - Cooldown status
|
|
802
|
+
*
|
|
803
|
+
* Uses the IndexerAdapter for data — no direct Ponder queries.
|
|
804
|
+
*
|
|
805
|
+
* @see {@link @provex/utils/reputation} for tier definitions
|
|
806
|
+
* @see {@link useReputationLimits} for applying limits to specific payments
|
|
807
|
+
*/
|
|
808
|
+
|
|
809
|
+
/**
|
|
810
|
+
* Hook to fetch and calculate user reputation tier.
|
|
811
|
+
*
|
|
812
|
+
* @param address - User's wallet address
|
|
813
|
+
* @param chainId - Current chain ID
|
|
814
|
+
* @returns User reputation data and loading state
|
|
815
|
+
*/
|
|
816
|
+
declare function useReputation({ address, chainId, }: {
|
|
817
|
+
address: Hex | undefined;
|
|
818
|
+
chainId: ChainId;
|
|
819
|
+
}): {
|
|
820
|
+
reputation: UserReputation;
|
|
821
|
+
isLoading: boolean;
|
|
822
|
+
error: Error | null;
|
|
823
|
+
refetch: () => void;
|
|
824
|
+
};
|
|
825
|
+
/**
|
|
826
|
+
* Get display info for a tier.
|
|
827
|
+
*/
|
|
828
|
+
declare function getTierDisplayInfo(tier: TakerTier): {
|
|
829
|
+
name: string;
|
|
830
|
+
baseCap: number;
|
|
831
|
+
cooldownHours: number;
|
|
832
|
+
color: string;
|
|
833
|
+
volumeRangeDisplay: string;
|
|
834
|
+
};
|
|
835
|
+
|
|
836
|
+
/**
|
|
837
|
+
* @fileoverview Hook for checking nullifier usage (double-spend prevention).
|
|
838
|
+
*
|
|
839
|
+
* The NullifierRegistry tracks which payment proofs have been used to
|
|
840
|
+
* prevent the same off-chain payment from being used multiple times.
|
|
841
|
+
*
|
|
842
|
+
* @remarks
|
|
843
|
+
* Chain of contract calls to reach NullifierRegistry:
|
|
844
|
+
* 1. V3Escrow → orchestrator()
|
|
845
|
+
* 2. Orchestrator → paymentVerifierRegistry()
|
|
846
|
+
* 3. PaymentVerifierRegistry → getVerifier(paymentMethodId)
|
|
847
|
+
* 4. UnifiedPaymentVerifier → nullifierRegistry()
|
|
848
|
+
*/
|
|
849
|
+
|
|
850
|
+
/**
|
|
851
|
+
* Hook to interact with the NullifierRegistry for checking if a nullifier has been used.
|
|
852
|
+
*
|
|
853
|
+
* The nullifier is derived from paymentMethod and paymentId to prevent double-spending.
|
|
854
|
+
*
|
|
855
|
+
* Requires a wagmi `WagmiProvider` ancestor in the component tree.
|
|
856
|
+
*
|
|
857
|
+
* @param escrowAddress - The V3 escrow contract address
|
|
858
|
+
* @param paymentMethodId - The payment method ID (bytes32 hash)
|
|
859
|
+
* @param chainId - The chain ID
|
|
860
|
+
*/
|
|
861
|
+
declare function useNullifierRegistry({ escrowAddress, paymentMethodId, chainId, }: {
|
|
862
|
+
escrowAddress: Hex | undefined;
|
|
863
|
+
paymentMethodId: Hex | undefined;
|
|
864
|
+
chainId: number;
|
|
865
|
+
}): {
|
|
866
|
+
orchestratorAddress: Hex | undefined;
|
|
867
|
+
paymentVerifierRegistryAddress: Hex | undefined;
|
|
868
|
+
verifierAddress: Hex | undefined;
|
|
869
|
+
nullifierRegistryAddress: Hex | undefined;
|
|
870
|
+
isLoading: boolean;
|
|
871
|
+
checkNullifierUsed: (nullifier: Hex) => Promise<boolean | null>;
|
|
872
|
+
};
|
|
873
|
+
|
|
874
|
+
/**
|
|
875
|
+
* @fileoverview Hook for ERC20 token allowance checking and approval.
|
|
876
|
+
*
|
|
877
|
+
* Handles the common pattern of checking if a spender (escrow contract)
|
|
878
|
+
* has sufficient allowance to transfer tokens, and prompting for approval
|
|
879
|
+
* if needed.
|
|
880
|
+
*
|
|
881
|
+
* @remarks
|
|
882
|
+
* Approval is required before createDeposit or addFunds can transfer
|
|
883
|
+
* tokens to the escrow contract.
|
|
884
|
+
*/
|
|
885
|
+
|
|
886
|
+
declare const useAllowance: ({ token, spender, account, balance, defaultAllowance, onSuccess, onError, onSettled, }: {
|
|
887
|
+
token: TokenInfo;
|
|
888
|
+
spender: Hex;
|
|
889
|
+
/** The account address to check/write allowance for. If undefined, hook returns null allowance and writeApproval is a no-op. */
|
|
890
|
+
account: Hex | undefined;
|
|
891
|
+
balance?: bigint;
|
|
892
|
+
defaultAllowance?: "max" | "balance";
|
|
893
|
+
onSuccess?: (...args: unknown[]) => void;
|
|
894
|
+
onError?: (...args: unknown[]) => void;
|
|
895
|
+
onSettled?: (...args: unknown[]) => void;
|
|
896
|
+
}) => {
|
|
897
|
+
allowance: bigint | null;
|
|
898
|
+
isLoading: boolean;
|
|
899
|
+
isWritingApproval: boolean;
|
|
900
|
+
/** Loading text for the approval button */
|
|
901
|
+
approvalLoadingText: string;
|
|
902
|
+
error: Error | null;
|
|
903
|
+
writeApproval: () => Promise<void>;
|
|
904
|
+
};
|
|
905
|
+
|
|
906
|
+
/**
|
|
907
|
+
* @fileoverview Hook for canceling an active intent.
|
|
908
|
+
*
|
|
909
|
+
* V3: Delegates to ProveXClient.cancelIntent (Orchestrator).
|
|
910
|
+
* V2: Falls back to direct wagmi writeContract (legacy Escrow).
|
|
911
|
+
*/
|
|
912
|
+
|
|
913
|
+
/** Status values for the cancel intent operation. */
|
|
914
|
+
type CancelIntentStatus = 'idle' | 'prompt_wallet_confirm' | 'writing_tx' | 'success' | 'error';
|
|
915
|
+
/**
|
|
916
|
+
* Hook to cancel an intent with automatic v2/v3 version detection.
|
|
917
|
+
*
|
|
918
|
+
* V3 delegates to ProveXClient. V2 uses wagmi directly (legacy).
|
|
919
|
+
*/
|
|
920
|
+
declare const useCancelIntent: ({ onSuccess, onMutate, onError, onSettled, chainId, escrowAddress: providedEscrowAddress, version: explicitVersion, }: {
|
|
921
|
+
onSuccess?: () => void;
|
|
922
|
+
onMutate?: () => void;
|
|
923
|
+
onError?: (error: Error) => void;
|
|
924
|
+
onSettled?: () => void;
|
|
925
|
+
chainId?: ChainId | null | undefined;
|
|
926
|
+
escrowAddress?: Hex | null | undefined;
|
|
927
|
+
version?: Version;
|
|
928
|
+
}) => {
|
|
929
|
+
cancelIntent: (intentHash: Hex) => Promise<void>;
|
|
930
|
+
status: CancelIntentStatus;
|
|
931
|
+
isLoading: boolean;
|
|
932
|
+
version: "v2" | "v3";
|
|
933
|
+
errorMessage: string | null;
|
|
934
|
+
};
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* @fileoverview Hook for releasing funds back to payer.
|
|
938
|
+
*
|
|
939
|
+
* V3: Delegates to ProveXClient.releaseFundsToPayer (Orchestrator).
|
|
940
|
+
* V2: Falls back to direct wagmi writeContract (legacy Escrow).
|
|
941
|
+
*/
|
|
942
|
+
|
|
943
|
+
/** Status values for the release funds operation. */
|
|
944
|
+
type ReleaseFundsStatus = 'idle' | 'prompt_wallet_confirm' | 'writing_tx' | 'success' | 'error';
|
|
945
|
+
/**
|
|
946
|
+
* Hook to release funds back to payer with automatic v2/v3 version detection.
|
|
947
|
+
*
|
|
948
|
+
* V3 delegates to ProveXClient. V2 uses wagmi directly (legacy).
|
|
949
|
+
*/
|
|
950
|
+
declare const useReleaseFundsToPayer: ({ onSuccess, onSettled, chainId, escrowAddress: providedEscrowAddress, version: explicitVersion, }: {
|
|
951
|
+
onSuccess?: () => void;
|
|
952
|
+
onSettled?: () => void;
|
|
953
|
+
chainId?: ChainId | null | undefined;
|
|
954
|
+
escrowAddress?: Hex | null | undefined;
|
|
955
|
+
version?: Version;
|
|
956
|
+
}) => {
|
|
957
|
+
releaseFundsToPayer: (intentHash: Hex) => Promise<void>;
|
|
958
|
+
status: ReleaseFundsStatus;
|
|
959
|
+
isLoading: boolean;
|
|
960
|
+
errorMessage: string | null;
|
|
961
|
+
version: "v2" | "v3";
|
|
962
|
+
};
|
|
963
|
+
|
|
964
|
+
/**
|
|
965
|
+
* Status values for escrow write operations.
|
|
966
|
+
*/
|
|
967
|
+
type V3EscrowStatus = 'idle' | 'prompt_wallet_confirm' | 'writing_tx' | 'confirming' | 'syncing' | 'success' | 'error';
|
|
968
|
+
/** @deprecated Use `CreateDepositRawParams` from `@provex/react/client/types`. */
|
|
969
|
+
type CreateDepositParams = CreateDepositRawParams;
|
|
970
|
+
/**
|
|
971
|
+
* Hook for interacting with v3 Escrow contract.
|
|
972
|
+
*
|
|
973
|
+
* All write methods delegate to ProveXClient. Reads use wagmi for
|
|
974
|
+
* automatic cache management.
|
|
975
|
+
*/
|
|
976
|
+
declare const useV3Escrow: ({ chainId, escrowAddress, onSlowSync, onTransactionConfirmed, onError, }: {
|
|
977
|
+
chainId?: ChainId | null;
|
|
978
|
+
escrowAddress?: Hex | null;
|
|
979
|
+
/** Called when indexer sync is taking longer than expected. */
|
|
980
|
+
onSlowSync?: () => void;
|
|
981
|
+
/** Called after the transaction is confirmed on-chain. */
|
|
982
|
+
onTransactionConfirmed?: (params: {
|
|
983
|
+
hash: Hex;
|
|
984
|
+
chainId: ChainId;
|
|
985
|
+
action: string;
|
|
986
|
+
}) => void;
|
|
987
|
+
/** Called when a write method fails (contract revert, gas issues, etc). Not called on user rejection. */
|
|
988
|
+
onError?: (error: Error) => void;
|
|
989
|
+
}) => {
|
|
990
|
+
status: V3EscrowStatus;
|
|
991
|
+
error: string | null;
|
|
992
|
+
isLoading: boolean;
|
|
993
|
+
escrow: `0x${string}` | null;
|
|
994
|
+
orchestratorAddress: `0x${string}` | undefined;
|
|
995
|
+
depositCounter: bigint | undefined;
|
|
996
|
+
txHash: `0x${string}` | null;
|
|
997
|
+
createDeposit: (params: CreateDepositRawParams) => Promise<`0x${string}` | null>;
|
|
998
|
+
addFunds: (depositId: bigint, amount: bigint) => Promise<`0x${string}` | null>;
|
|
999
|
+
removeFunds: (depositId: bigint, amount: bigint) => Promise<`0x${string}` | null>;
|
|
1000
|
+
withdrawDeposit: (depositId: bigint) => Promise<`0x${string}` | null>;
|
|
1001
|
+
pruneExpiredIntents: (depositId: bigint) => Promise<`0x${string}` | null>;
|
|
1002
|
+
setAcceptingIntents: (depositId: bigint, accepting: boolean) => Promise<`0x${string}` | null>;
|
|
1003
|
+
setRetainOnEmpty: (depositId: bigint, retain: boolean) => Promise<`0x${string}` | null>;
|
|
1004
|
+
setIntentRange: (depositId: bigint, intentAmountRange: {
|
|
1005
|
+
min: bigint;
|
|
1006
|
+
max: bigint;
|
|
1007
|
+
}) => Promise<`0x${string}` | null>;
|
|
1008
|
+
setPaymentMethodActive: (depositId: bigint, paymentMethod: Hex, active: boolean) => Promise<`0x${string}` | null>;
|
|
1009
|
+
setCurrencyMinRate: (params: {
|
|
1010
|
+
depositId: bigint;
|
|
1011
|
+
paymentMethod: Hex;
|
|
1012
|
+
currency: Hex;
|
|
1013
|
+
newMinConversionRate: bigint;
|
|
1014
|
+
}) => Promise<`0x${string}` | null>;
|
|
1015
|
+
addCurrencies: (params: {
|
|
1016
|
+
depositId: bigint;
|
|
1017
|
+
paymentMethod: Hex;
|
|
1018
|
+
currencies: Array<{
|
|
1019
|
+
code: Hex;
|
|
1020
|
+
minConversionRate: bigint;
|
|
1021
|
+
}>;
|
|
1022
|
+
}) => Promise<`0x${string}` | null>;
|
|
1023
|
+
deactivateCurrency: (params: {
|
|
1024
|
+
depositId: bigint;
|
|
1025
|
+
paymentMethod: Hex;
|
|
1026
|
+
currencyCode: Hex;
|
|
1027
|
+
}) => Promise<`0x${string}` | null>;
|
|
1028
|
+
addPaymentMethods: (params: {
|
|
1029
|
+
depositId: bigint;
|
|
1030
|
+
paymentMethods: Hex[];
|
|
1031
|
+
paymentMethodData: Array<{
|
|
1032
|
+
intentGatingService: Hex;
|
|
1033
|
+
payeeDetails: Hex;
|
|
1034
|
+
data: Hex;
|
|
1035
|
+
}>;
|
|
1036
|
+
currencies: Array<Array<{
|
|
1037
|
+
code: Hex;
|
|
1038
|
+
minConversionRate: bigint;
|
|
1039
|
+
}>>;
|
|
1040
|
+
}) => Promise<`0x${string}` | null>;
|
|
1041
|
+
getDeposit: (depositId: bigint) => Promise<unknown>;
|
|
1042
|
+
getAccountDeposits: (account: Hex) => Promise<unknown>;
|
|
1043
|
+
reset: () => void;
|
|
1044
|
+
refetchOrchestrator: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<`0x${string}`, viem.ReadContractErrorType>>;
|
|
1045
|
+
refetchDepositCounter: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<bigint, viem.ReadContractErrorType>>;
|
|
1046
|
+
};
|
|
1047
|
+
|
|
1048
|
+
/**
|
|
1049
|
+
* Phase of the transaction lifecycle.
|
|
1050
|
+
*/
|
|
1051
|
+
type TransactionPhase = 'idle' | 'submitting' | 'confirming' | 'syncing' | 'complete' | 'error';
|
|
1052
|
+
interface UseTransactionWithIndexerOptions {
|
|
1053
|
+
/** Called when transaction is fully indexed */
|
|
1054
|
+
onSuccess?: () => void;
|
|
1055
|
+
/** Called on any error */
|
|
1056
|
+
onError?: (error: Error) => void;
|
|
1057
|
+
/** Called when indexer sync is taking longer than expected. */
|
|
1058
|
+
onSlowSync?: () => void;
|
|
1059
|
+
/** Called after the transaction is confirmed on-chain. */
|
|
1060
|
+
onTransactionConfirmed?: (params: {
|
|
1061
|
+
hash: Hex;
|
|
1062
|
+
chainId: ChainId;
|
|
1063
|
+
action: string;
|
|
1064
|
+
}) => void;
|
|
1065
|
+
/** Called when a transaction-level error message is available. */
|
|
1066
|
+
onTransactionError?: (message: string) => void;
|
|
1067
|
+
/** Indexer adapter. Falls back to ProvexProvider context, then skips sync. */
|
|
1068
|
+
indexer?: IndexerAdapter;
|
|
1069
|
+
}
|
|
1070
|
+
interface TransactionSyncOptions {
|
|
1071
|
+
/** The transaction hash to track */
|
|
1072
|
+
hash: Hex;
|
|
1073
|
+
/** Chain ID for the transaction */
|
|
1074
|
+
chainId: ChainId;
|
|
1075
|
+
/** Action description (e.g., "Deposit created") */
|
|
1076
|
+
action: string;
|
|
1077
|
+
}
|
|
1078
|
+
interface MutationSyncOptions {
|
|
1079
|
+
/** The transaction hash */
|
|
1080
|
+
hash: Hex;
|
|
1081
|
+
/** Deposit local ID for mutation tracking */
|
|
1082
|
+
depositId: bigint;
|
|
1083
|
+
/** Chain ID for the deposit */
|
|
1084
|
+
chainId: ChainId;
|
|
1085
|
+
/** Target status to wait for */
|
|
1086
|
+
status: string;
|
|
1087
|
+
/** Action description */
|
|
1088
|
+
action: string;
|
|
1089
|
+
}
|
|
1090
|
+
/**
|
|
1091
|
+
* Hook for handling the three-phase transaction flow:
|
|
1092
|
+
* 1. Transaction submission (handled by caller)
|
|
1093
|
+
* 2. Transaction confirmation (waiting for mining)
|
|
1094
|
+
* 3. Indexer sync (waiting for indexer to process)
|
|
1095
|
+
*/
|
|
1096
|
+
declare const useTransactionWithIndexer: (options?: UseTransactionWithIndexerOptions) => {
|
|
1097
|
+
phase: TransactionPhase;
|
|
1098
|
+
isLoading: boolean;
|
|
1099
|
+
loadingText: string | undefined;
|
|
1100
|
+
waitForTransaction: ({ hash, chainId, action, }: TransactionSyncOptions) => Promise<void>;
|
|
1101
|
+
waitForMutation: ({ hash, depositId, chainId, status, action, }: MutationSyncOptions) => Promise<void>;
|
|
1102
|
+
reset: () => void;
|
|
1103
|
+
setPhase: React$1.Dispatch<React$1.SetStateAction<TransactionPhase>>;
|
|
1104
|
+
};
|
|
1105
|
+
|
|
1106
|
+
/**
|
|
1107
|
+
* @fileoverview ProveXClient — framework-agnostic protocol client.
|
|
1108
|
+
*
|
|
1109
|
+
* Works in any JavaScript runtime: Node.js, React, Vue, Svelte, serverless.
|
|
1110
|
+
* Every write method supports `.prepare()` for smart accounts and relayers.
|
|
1111
|
+
*
|
|
1112
|
+
* @example
|
|
1113
|
+
* ```ts
|
|
1114
|
+
* import { createProveXClient } from '@provex/react'
|
|
1115
|
+
* import { createPonderAdapter } from '@provex/indexer-client'
|
|
1116
|
+
*
|
|
1117
|
+
* // Full client (reads + writes)
|
|
1118
|
+
* const client = createProveXClient({
|
|
1119
|
+
* chainId: 8453,
|
|
1120
|
+
* apiUrl: 'https://app.provex.com',
|
|
1121
|
+
* wallet: myWalletAdapter,
|
|
1122
|
+
* indexer: createPonderAdapter(),
|
|
1123
|
+
* })
|
|
1124
|
+
*
|
|
1125
|
+
* // Prepare-only mode (no wallet, no indexer)
|
|
1126
|
+
* const client = createProveXClient({ chainId: 8453, apiUrl: 'https://app.provex.com' })
|
|
1127
|
+
* const prepared = await client.addFunds.prepare({ depositId: 1n, amount: 100_000000n })
|
|
1128
|
+
* ```
|
|
1129
|
+
*/
|
|
1130
|
+
|
|
1131
|
+
/**
|
|
1132
|
+
* ProveXClient — the framework-agnostic core of the ProveX SDK.
|
|
1133
|
+
*
|
|
1134
|
+
* Encapsulates all protocol interactions: indexer reads, on-chain reads,
|
|
1135
|
+
* and contract writes. React hooks are thin wrappers around this class.
|
|
1136
|
+
*/
|
|
1137
|
+
declare class ProveXClient {
|
|
1138
|
+
/** The viem Chain object — carries RPC URLs, chain ID, and metadata. */
|
|
1139
|
+
readonly chain: Chain;
|
|
1140
|
+
/** Numeric chain ID (derived from chain.id). */
|
|
1141
|
+
readonly chainId: ChainId;
|
|
1142
|
+
private readonly wallet?;
|
|
1143
|
+
private readonly indexer?;
|
|
1144
|
+
private readonly escrowOverride?;
|
|
1145
|
+
private readonly onTransactionHash?;
|
|
1146
|
+
readonly apiUrl: string;
|
|
1147
|
+
private readonly onSlowSync?;
|
|
1148
|
+
/** Lazily-created public client for RPC calls. */
|
|
1149
|
+
private _publicClient;
|
|
1150
|
+
/** Cached orchestrator address (lazy-loaded). */
|
|
1151
|
+
private cachedOrchestratorAddress;
|
|
1152
|
+
constructor(config: ProveXClientConfig);
|
|
1153
|
+
/** Get the V3 escrow address for this client's chain. */
|
|
1154
|
+
getEscrowAddress(): Hex;
|
|
1155
|
+
/** Get the orchestrator address (cached after first read). */
|
|
1156
|
+
getOrchestratorAddress(): Promise<Hex>;
|
|
1157
|
+
private requireIndexer;
|
|
1158
|
+
getMatchableDeposits(params: {
|
|
1159
|
+
token: Hex;
|
|
1160
|
+
currencyId: Hex;
|
|
1161
|
+
pagination?: PaginationOptions;
|
|
1162
|
+
}): Promise<PaginatedResult<IndexedDeposit>>;
|
|
1163
|
+
getDepositWithVerifiers(params: {
|
|
1164
|
+
escrow: Hex;
|
|
1165
|
+
localId: bigint;
|
|
1166
|
+
}): Promise<IndexedDeposit | null>;
|
|
1167
|
+
getIntent(intentHash: Hex): Promise<IndexedIntent | null>;
|
|
1168
|
+
getPayeeDetailsHash(params: {
|
|
1169
|
+
escrow: Hex;
|
|
1170
|
+
localId: bigint;
|
|
1171
|
+
paymentMethodId: Hex;
|
|
1172
|
+
}): Promise<Hex | null>;
|
|
1173
|
+
getUserReputation(address: Hex): Promise<ReputationData>;
|
|
1174
|
+
getProtocolFees(): Promise<{
|
|
1175
|
+
feeRaw: bigint;
|
|
1176
|
+
feeInfo: FeeInfo;
|
|
1177
|
+
feeRecipient: Hex;
|
|
1178
|
+
}>;
|
|
1179
|
+
getDeposit(depositId: bigint): Promise<unknown>;
|
|
1180
|
+
getAccountDeposits(account: Hex): Promise<unknown>;
|
|
1181
|
+
getDepositCounter(): Promise<bigint>;
|
|
1182
|
+
getAllowance(params: {
|
|
1183
|
+
token: Hex;
|
|
1184
|
+
owner: Hex;
|
|
1185
|
+
spender: Hex;
|
|
1186
|
+
}): Promise<bigint>;
|
|
1187
|
+
checkNullifierUsed(params: {
|
|
1188
|
+
paymentMethodId: Hex;
|
|
1189
|
+
nullifier: Hex;
|
|
1190
|
+
}): Promise<boolean | null>;
|
|
1191
|
+
/** Low-level deposit creation — pass pre-hashed contract params directly. */
|
|
1192
|
+
readonly createDepositRaw: WritableMethod<CreateDepositRawParams>;
|
|
1193
|
+
readonly addFunds: WritableMethod<{
|
|
1194
|
+
depositId: bigint;
|
|
1195
|
+
amount: bigint;
|
|
1196
|
+
}>;
|
|
1197
|
+
readonly removeFunds: WritableMethod<{
|
|
1198
|
+
depositId: bigint;
|
|
1199
|
+
amount: bigint;
|
|
1200
|
+
}>;
|
|
1201
|
+
readonly withdrawDeposit: WritableMethod<{
|
|
1202
|
+
depositId: bigint;
|
|
1203
|
+
}>;
|
|
1204
|
+
readonly pruneExpiredIntents: WritableMethod<{
|
|
1205
|
+
depositId: bigint;
|
|
1206
|
+
}>;
|
|
1207
|
+
readonly setAcceptingIntents: WritableMethod<{
|
|
1208
|
+
depositId: bigint;
|
|
1209
|
+
accepting: boolean;
|
|
1210
|
+
}>;
|
|
1211
|
+
readonly setRetainOnEmpty: WritableMethod<{
|
|
1212
|
+
depositId: bigint;
|
|
1213
|
+
retain: boolean;
|
|
1214
|
+
}>;
|
|
1215
|
+
readonly setIntentRange: WritableMethod<{
|
|
1216
|
+
depositId: bigint;
|
|
1217
|
+
min: bigint;
|
|
1218
|
+
max: bigint;
|
|
1219
|
+
}>;
|
|
1220
|
+
readonly setPaymentMethodActive: WritableMethod<{
|
|
1221
|
+
depositId: bigint;
|
|
1222
|
+
paymentMethod: Hex;
|
|
1223
|
+
active: boolean;
|
|
1224
|
+
}>;
|
|
1225
|
+
readonly setCurrencyMinRate: WritableMethod<{
|
|
1226
|
+
depositId: bigint;
|
|
1227
|
+
paymentMethod: Hex;
|
|
1228
|
+
currency: Hex;
|
|
1229
|
+
rate: bigint;
|
|
1230
|
+
}>;
|
|
1231
|
+
readonly addCurrencies: WritableMethod<{
|
|
1232
|
+
depositId: bigint;
|
|
1233
|
+
paymentMethod: Hex;
|
|
1234
|
+
currencies: Array<{
|
|
1235
|
+
code: Hex;
|
|
1236
|
+
minConversionRate: bigint;
|
|
1237
|
+
}>;
|
|
1238
|
+
}>;
|
|
1239
|
+
readonly deactivateCurrency: WritableMethod<{
|
|
1240
|
+
depositId: bigint;
|
|
1241
|
+
paymentMethod: Hex;
|
|
1242
|
+
currencyCode: Hex;
|
|
1243
|
+
}>;
|
|
1244
|
+
readonly addPaymentMethods: WritableMethod<{
|
|
1245
|
+
depositId: bigint;
|
|
1246
|
+
paymentMethods: Hex[];
|
|
1247
|
+
paymentMethodData: Array<{
|
|
1248
|
+
intentGatingService: Hex;
|
|
1249
|
+
payeeDetails: Hex;
|
|
1250
|
+
data: Hex;
|
|
1251
|
+
}>;
|
|
1252
|
+
currencies: Array<Array<{
|
|
1253
|
+
code: Hex;
|
|
1254
|
+
minConversionRate: bigint;
|
|
1255
|
+
}>>;
|
|
1256
|
+
}>;
|
|
1257
|
+
/**
|
|
1258
|
+
* Create a deposit with human-readable params.
|
|
1259
|
+
*
|
|
1260
|
+
* Handles all encoding internally:
|
|
1261
|
+
* 1. Registers payee details with the API (so buyers can discover them)
|
|
1262
|
+
* 2. Hashes provider keys and currency codes to bytes32
|
|
1263
|
+
* 3. Expands sub-providers (e.g., 'zelle' → zelle-chase, zelle-bofa, zelle-citi)
|
|
1264
|
+
* 4. Encodes gating service witness signers
|
|
1265
|
+
* 5. Submits the on-chain transaction
|
|
1266
|
+
*
|
|
1267
|
+
* @example
|
|
1268
|
+
* ```ts
|
|
1269
|
+
* await client.createDeposit({
|
|
1270
|
+
* token: USDC_ADDRESS,
|
|
1271
|
+
* amount: 1000_000000n,
|
|
1272
|
+
* intentRange: { min: 10_000000n, max: 500_000000n },
|
|
1273
|
+
* paymentMethods: [
|
|
1274
|
+
* { provider: 'venmo', payeeId: '@myvenmo', currencies: [{ code: 'USD', minRate: 0n }] },
|
|
1275
|
+
* ],
|
|
1276
|
+
* retainOnEmpty: true,
|
|
1277
|
+
* })
|
|
1278
|
+
* ```
|
|
1279
|
+
*/
|
|
1280
|
+
createDeposit(params: CreateDepositParams$1): Promise<TransactionResult>;
|
|
1281
|
+
/**
|
|
1282
|
+
* Prepare an unsigned createDeposit transaction (no API call, no wallet).
|
|
1283
|
+
*
|
|
1284
|
+
* Use this for smart accounts, multisig, gasless relayers, or offline signing.
|
|
1285
|
+
* Maker registration is NOT performed — call `registerMaker()` separately
|
|
1286
|
+
* if you need buyers to discover the payee.
|
|
1287
|
+
*/
|
|
1288
|
+
prepareCreateDeposit(params: CreateDepositParams$1): Promise<PreparedTransaction>;
|
|
1289
|
+
/**
|
|
1290
|
+
* Convert human-readable deposit params to raw contract params.
|
|
1291
|
+
* Handles provider expansion, hashing, gating service encoding, and defaults.
|
|
1292
|
+
*/
|
|
1293
|
+
private buildCreateDepositRawParams;
|
|
1294
|
+
readonly cancelIntent: WritableMethod<{
|
|
1295
|
+
intentHash: Hex;
|
|
1296
|
+
}>;
|
|
1297
|
+
readonly releaseFundsToPayer: WritableMethod<{
|
|
1298
|
+
intentHash: Hex;
|
|
1299
|
+
}>;
|
|
1300
|
+
/**
|
|
1301
|
+
* Signal an intent to buy tokens from a deposit (buyer side).
|
|
1302
|
+
*
|
|
1303
|
+
* Handles the full multi-step flow:
|
|
1304
|
+
* 1. Fetches payee details hash from the indexer
|
|
1305
|
+
* 2. Requests a gating service signature from the API
|
|
1306
|
+
* 3. Simulates the transaction
|
|
1307
|
+
* 4. Submits to Orchestrator.signalIntent()
|
|
1308
|
+
* 5. Parses the IntentSignaled event to extract the intent hash
|
|
1309
|
+
*
|
|
1310
|
+
* @returns Transaction result with the on-chain intent hash.
|
|
1311
|
+
* @throws {ProveXError} VALIDATION_ERROR if payee details or gating signature missing.
|
|
1312
|
+
* @throws {ProveXError} API_ERROR if gating service rejects the intent.
|
|
1313
|
+
* @throws {ProveXError} WALLET_REJECTED if user cancels in wallet.
|
|
1314
|
+
*
|
|
1315
|
+
* @example
|
|
1316
|
+
* ```ts
|
|
1317
|
+
* const { hash, intentHash } = await client.signalIntent({
|
|
1318
|
+
* deposit: { escrow: '0x...', localId: 1n },
|
|
1319
|
+
* paymentMethod: providerKeyToContractId('venmo'),
|
|
1320
|
+
* tokenAmount: 100_000000n,
|
|
1321
|
+
* toAddress: wallet.address,
|
|
1322
|
+
* fiatCurrencyCode: tickerToContractId('USD'),
|
|
1323
|
+
* conversionRate: 1_000000000000000000n,
|
|
1324
|
+
* })
|
|
1325
|
+
* ```
|
|
1326
|
+
*/
|
|
1327
|
+
signalIntent(params: SignalIntentParams): Promise<SignalIntentResult>;
|
|
1328
|
+
/**
|
|
1329
|
+
* Request a gating service signature for intent signaling.
|
|
1330
|
+
* The gating service validates the intent and returns a signature
|
|
1331
|
+
* the Orchestrator contract verifies on-chain.
|
|
1332
|
+
*/
|
|
1333
|
+
private requestGatingSignature;
|
|
1334
|
+
readonly approve: WritableMethod<{
|
|
1335
|
+
token: Hex;
|
|
1336
|
+
spender: Hex;
|
|
1337
|
+
amount?: bigint;
|
|
1338
|
+
}>;
|
|
1339
|
+
/** Get payee details for a provider and user ID. */
|
|
1340
|
+
getPayeeInfo(params: {
|
|
1341
|
+
provider: string;
|
|
1342
|
+
userId: string;
|
|
1343
|
+
}): Promise<PayeeDetails | null>;
|
|
1344
|
+
/** Validate a maker's payment identity before registration. */
|
|
1345
|
+
validateMaker(params: MakerRegistrationParams): Promise<boolean>;
|
|
1346
|
+
/** Register a maker's payment identity (e.g., Venmo username). Required before creating deposits. */
|
|
1347
|
+
registerMaker(params: MakerRegistrationParams): Promise<{
|
|
1348
|
+
id: string;
|
|
1349
|
+
} | null>;
|
|
1350
|
+
/**
|
|
1351
|
+
* Submit zkTLS proofs and get a signed attestation for fulfillIntent.
|
|
1352
|
+
* This is the proof verification step — after the buyer makes payment and
|
|
1353
|
+
* generates proofs via the browser extension.
|
|
1354
|
+
*/
|
|
1355
|
+
getAttestation(params: AttestationParams): Promise<AttestationResponse>;
|
|
1356
|
+
/** Make a POST request to the API. */
|
|
1357
|
+
private apiPost;
|
|
1358
|
+
waitForTransactionIndexed(hash: Hex): Promise<void>;
|
|
1359
|
+
/** Get or create a viem PublicClient for this chain. Cached after first use. */
|
|
1360
|
+
getPublicClient(): PublicClient;
|
|
1361
|
+
/** Read from a contract using wallet adapter or public RPC. */
|
|
1362
|
+
private readContract;
|
|
1363
|
+
/** Require a connected wallet, or throw. */
|
|
1364
|
+
private requireWallet;
|
|
1365
|
+
/**
|
|
1366
|
+
* Build a WritableMethod from an ABI definition.
|
|
1367
|
+
* The returned function supports both execute (full lifecycle) and .prepare() (unsigned tx).
|
|
1368
|
+
*/
|
|
1369
|
+
private buildWritableMethod;
|
|
1370
|
+
}
|
|
1371
|
+
/**
|
|
1372
|
+
* Create a ProveXClient instance.
|
|
1373
|
+
*
|
|
1374
|
+
* @example
|
|
1375
|
+
* ```ts
|
|
1376
|
+
* // Full client
|
|
1377
|
+
* const client = createProveXClient({
|
|
1378
|
+
* chainId: 8453,
|
|
1379
|
+
* apiUrl: 'https://app.provex.com',
|
|
1380
|
+
* wallet: myWalletAdapter,
|
|
1381
|
+
* indexer: createPonderAdapter(),
|
|
1382
|
+
* })
|
|
1383
|
+
*
|
|
1384
|
+
* // Prepare-only mode
|
|
1385
|
+
* const client = createProveXClient({ chainId: 8453, apiUrl: 'https://app.provex.com' })
|
|
1386
|
+
* const tx = await client.addFunds.prepare({ depositId: 1n, amount: 100_000000n })
|
|
1387
|
+
* ```
|
|
1388
|
+
*/
|
|
1389
|
+
declare function createProveXClient(config: ProveXClientConfig): ProveXClient;
|
|
1390
|
+
|
|
1391
|
+
/**
|
|
1392
|
+
* @fileoverview React hook that bridges ProvexProvider context to ProveXClient.
|
|
1393
|
+
*
|
|
1394
|
+
* Creates (and memoizes) a ProveXClient instance from the provider's
|
|
1395
|
+
* indexer adapter, config, and an optional wallet adapter.
|
|
1396
|
+
*/
|
|
1397
|
+
|
|
1398
|
+
/**
|
|
1399
|
+
* Get a memoized ProveXClient from the ProvexProvider context.
|
|
1400
|
+
*
|
|
1401
|
+
* @param wallet - Optional wallet adapter for write operations.
|
|
1402
|
+
* Omit for read-only usage or prepare-only mode.
|
|
1403
|
+
*
|
|
1404
|
+
* @example
|
|
1405
|
+
* ```tsx
|
|
1406
|
+
* function MyComponent() {
|
|
1407
|
+
* const client = useProveXClient(myWallet)
|
|
1408
|
+
* const prepared = await client.addFunds.prepare({ depositId: 1n, amount: 100n })
|
|
1409
|
+
* }
|
|
1410
|
+
* ```
|
|
1411
|
+
*/
|
|
1412
|
+
declare function useProveXClient(wallet?: WalletAdapter): ProveXClient;
|
|
1413
|
+
|
|
1414
|
+
/**
|
|
1415
|
+
* @fileoverview Bridge wagmi's wallet to the WalletAdapter interface.
|
|
1416
|
+
*
|
|
1417
|
+
* Creates a memoized WalletAdapter from wagmi's `useWalletClient` and
|
|
1418
|
+
* `useAccount` hooks. Pass the result to `useProveXClient(wallet)` or
|
|
1419
|
+
* directly to any hook that accepts a WalletAdapter.
|
|
1420
|
+
*/
|
|
1421
|
+
|
|
1422
|
+
/**
|
|
1423
|
+
* Create a WalletAdapter from the connected wagmi wallet.
|
|
1424
|
+
*
|
|
1425
|
+
* Returns `null` when no wallet is connected.
|
|
1426
|
+
*
|
|
1427
|
+
* @example
|
|
1428
|
+
* ```tsx
|
|
1429
|
+
* const wallet = useWagmiWallet()
|
|
1430
|
+
* const client = useProveXClient(wallet ?? undefined)
|
|
1431
|
+
* ```
|
|
1432
|
+
*/
|
|
1433
|
+
declare function useWagmiWallet(): WalletAdapter | null;
|
|
1434
|
+
|
|
1435
|
+
/** Intent status values representing the lifecycle state. */
|
|
1436
|
+
declare const intentStatuses: {
|
|
1437
|
+
readonly pending: "pending";
|
|
1438
|
+
readonly signalled: "signalled";
|
|
1439
|
+
readonly fulfilled: "fulfilled";
|
|
1440
|
+
readonly pruned: "pruned";
|
|
1441
|
+
};
|
|
1442
|
+
type IntentStatus = (typeof intentStatuses)[keyof typeof intentStatuses];
|
|
1443
|
+
/** Payee details from the API. */
|
|
1444
|
+
interface PayeeInfo {
|
|
1445
|
+
payeeId?: string;
|
|
1446
|
+
name?: string;
|
|
1447
|
+
platformName?: string;
|
|
1448
|
+
[key: string]: unknown;
|
|
1449
|
+
}
|
|
1450
|
+
/**
|
|
1451
|
+
* Hook to fetch intent details and payee information.
|
|
1452
|
+
*
|
|
1453
|
+
* @param intentHash - The intent hash to look up
|
|
1454
|
+
* @param chainId - The chain ID to query
|
|
1455
|
+
* @returns Intent details, payee info, and loading state
|
|
1456
|
+
*/
|
|
1457
|
+
declare function usePayeeDetails({ intentHash, chainId, }: {
|
|
1458
|
+
intentHash: Hex | null;
|
|
1459
|
+
chainId: ChainId;
|
|
1460
|
+
}): {
|
|
1461
|
+
intentStatus: IntentStatus | null;
|
|
1462
|
+
isFetching: boolean;
|
|
1463
|
+
isValid: boolean;
|
|
1464
|
+
intent: {
|
|
1465
|
+
owner: `0x${string}`;
|
|
1466
|
+
to: `0x${string}`;
|
|
1467
|
+
escrow: `0x${string}`;
|
|
1468
|
+
depositId: bigint;
|
|
1469
|
+
amount: bigint;
|
|
1470
|
+
timestamp: bigint;
|
|
1471
|
+
paymentMethod: `0x${string}`;
|
|
1472
|
+
fiatCurrency: `0x${string}`;
|
|
1473
|
+
conversionRate: bigint;
|
|
1474
|
+
} | null;
|
|
1475
|
+
providerKey: _provex_utils_payment.ProviderKey | null;
|
|
1476
|
+
userId: `0x${string}` | null;
|
|
1477
|
+
payeeDetails: PayeeInfo | null;
|
|
1478
|
+
deposit: IndexedDeposit | null;
|
|
1479
|
+
expiryTime: bigint | null;
|
|
1480
|
+
isV2Intent: boolean;
|
|
1481
|
+
isPruned: boolean;
|
|
1482
|
+
prunedAt: bigint | null;
|
|
1483
|
+
isFulfilled: boolean;
|
|
1484
|
+
refetch: () => void;
|
|
1485
|
+
refetchAll: () => Promise<IntentStatus | null>;
|
|
1486
|
+
};
|
|
1487
|
+
|
|
1488
|
+
/** Configuration for ProvexProvider. */
|
|
1489
|
+
interface ProvexConfig {
|
|
1490
|
+
/** Backend API URL (e.g. "https://app.provex.com") */
|
|
1491
|
+
apiUrl: string;
|
|
1492
|
+
/** The viem Chain object. Import from `viem/chains`. */
|
|
1493
|
+
chain: Chain;
|
|
1494
|
+
/** @deprecated Use `chain.id` — kept for backward compat during migration. */
|
|
1495
|
+
chainId?: ChainId;
|
|
1496
|
+
}
|
|
1497
|
+
/** Buy flow phases. */
|
|
1498
|
+
type BuyPhase = 'browse' | 'committed' | 'proving' | 'complete';
|
|
1499
|
+
/** Theme overrides applied as CSS custom properties on the root element. */
|
|
1500
|
+
interface ProvexTheme {
|
|
1501
|
+
accent?: string;
|
|
1502
|
+
background?: string;
|
|
1503
|
+
backgroundCard?: string;
|
|
1504
|
+
text?: string;
|
|
1505
|
+
textMuted?: string;
|
|
1506
|
+
border?: string;
|
|
1507
|
+
error?: string;
|
|
1508
|
+
radius?: string;
|
|
1509
|
+
font?: string;
|
|
1510
|
+
}
|
|
1511
|
+
/** Options for the useProvexBuy hook. */
|
|
1512
|
+
interface UseProvexBuyOptions {
|
|
1513
|
+
/** Wallet adapter — host app's wallet connection. */
|
|
1514
|
+
wallet: WalletAdapter;
|
|
1515
|
+
/** Called when the user signals intent (USDC reserved). */
|
|
1516
|
+
onIntentSignaled?: (intentHash: string, chainId: number) => void;
|
|
1517
|
+
/** Called when the full flow completes (USDC released). */
|
|
1518
|
+
onComplete?: (intentHash: string, chainId: number) => void;
|
|
1519
|
+
/** Restrict to specific payment methods. */
|
|
1520
|
+
paymentMethods?: ProviderKey[];
|
|
1521
|
+
}
|
|
1522
|
+
/** Return value of the useProvexBuy hook — the full buy-flow state machine. */
|
|
1523
|
+
interface UseProvexBuyReturn {
|
|
1524
|
+
/** Current phase of the buy flow. */
|
|
1525
|
+
phase: BuyPhase;
|
|
1526
|
+
/** Fiat amount entered by the user (string for input binding). */
|
|
1527
|
+
amount: string;
|
|
1528
|
+
/** Set the fiat amount. */
|
|
1529
|
+
setAmount: (value: string) => void;
|
|
1530
|
+
/** Currently selected payment method, or empty string if none. */
|
|
1531
|
+
selectedPaymentMethod: ProviderKey | '';
|
|
1532
|
+
/** Set the selected payment method. */
|
|
1533
|
+
setSelectedPaymentMethod: (method: ProviderKey) => void;
|
|
1534
|
+
/** Payment methods available for the current chain. */
|
|
1535
|
+
availablePaymentMethods: ProviderKey[];
|
|
1536
|
+
/** All deposits matching the current criteria. */
|
|
1537
|
+
deposits: DepositInfo[];
|
|
1538
|
+
/** The best deposit selected for the current amount. */
|
|
1539
|
+
selectedDeposit: DepositInfo | null;
|
|
1540
|
+
/** Manually select a deposit (advanced use). */
|
|
1541
|
+
selectDeposit: (deposit: DepositInfo) => void;
|
|
1542
|
+
/** True while deposits are loading for the first time. */
|
|
1543
|
+
isLoadingDeposits: boolean;
|
|
1544
|
+
/** Best rate for the current amount/payment method (raw 18-decimal). */
|
|
1545
|
+
rate: bigint | null;
|
|
1546
|
+
/** Human-readable rate string (e.g. "1 USDC = $1.01"). */
|
|
1547
|
+
rateDisplay: string | null;
|
|
1548
|
+
/** Token amount the user will receive (base units). */
|
|
1549
|
+
tokenAmount: bigint | null;
|
|
1550
|
+
/** Human-readable token amount (e.g. "99.50"). */
|
|
1551
|
+
tokenAmountDisplay: string | null;
|
|
1552
|
+
/** Token info for the current chain. */
|
|
1553
|
+
token: TokenInfo | null;
|
|
1554
|
+
/** Currency info (e.g. USD). */
|
|
1555
|
+
currency: Currency | null;
|
|
1556
|
+
/** User reputation data. */
|
|
1557
|
+
reputation: UserReputation;
|
|
1558
|
+
/** Reputation-based limits for the selected payment method. */
|
|
1559
|
+
limits: ReputationLimits;
|
|
1560
|
+
/** Protocol fee percentage string (e.g. "0%"), or null if loading. */
|
|
1561
|
+
feePercentage: string | null;
|
|
1562
|
+
/** Seller's payment details (name, handle, platform). */
|
|
1563
|
+
payeeDetails: PayeeInfo | null;
|
|
1564
|
+
/** Seller's display name. */
|
|
1565
|
+
payeeName: string | null;
|
|
1566
|
+
/** Seller's payment handle (e.g. Venmo username, Zelle email). */
|
|
1567
|
+
payeeId: string | null;
|
|
1568
|
+
/** True while payee details are loading. */
|
|
1569
|
+
isPayeeLoading: boolean;
|
|
1570
|
+
/** Intent expiry time. */
|
|
1571
|
+
intentExpiryTime: Date | null;
|
|
1572
|
+
/** Whether the intent has expired (pruned). */
|
|
1573
|
+
isIntentExpired: boolean;
|
|
1574
|
+
/** Indexed intent lifecycle status (signalled, fulfilled, pruned). */
|
|
1575
|
+
indexedIntentStatus: IntentStatus | null;
|
|
1576
|
+
/** Whether the order form can be submitted. */
|
|
1577
|
+
canSubmit: boolean;
|
|
1578
|
+
/** User-facing validation message, or null when valid. */
|
|
1579
|
+
validationMessage: string | null;
|
|
1580
|
+
/** Submit the order (signal intent on-chain). */
|
|
1581
|
+
submitOrder: () => Promise<void>;
|
|
1582
|
+
/** Confirm payment was sent (transitions to proving/complete). */
|
|
1583
|
+
confirmPayment: () => void;
|
|
1584
|
+
/** Reset the flow back to browse. */
|
|
1585
|
+
reset: () => void;
|
|
1586
|
+
/** Intent hash after successful order submission. */
|
|
1587
|
+
intentHash: Hex | null;
|
|
1588
|
+
/** Current status of the signal intent flow. */
|
|
1589
|
+
intentStatus: SignalIntentStatus;
|
|
1590
|
+
/** Error message from the intent flow. */
|
|
1591
|
+
intentError: string | null;
|
|
1592
|
+
/** True while the intent is being submitted. */
|
|
1593
|
+
isSubmitting: boolean;
|
|
1594
|
+
/** Chain ID for the current configuration. */
|
|
1595
|
+
chainId: ChainId;
|
|
1596
|
+
}
|
|
1597
|
+
/** Props for the ProvexBuy widget component (Layer 3). */
|
|
1598
|
+
interface BuyProps {
|
|
1599
|
+
/** Wallet adapter — host app's wallet connection. */
|
|
1600
|
+
wallet: WalletAdapter;
|
|
1601
|
+
/** Called when the user signals intent (USDC reserved). */
|
|
1602
|
+
onIntentSignaled?: (intentHash: string, chainId: number) => void;
|
|
1603
|
+
/** Called when the full flow completes (USDC released). */
|
|
1604
|
+
onComplete?: (intentHash: string, chainId: number) => void;
|
|
1605
|
+
/** Restrict to specific payment methods. */
|
|
1606
|
+
paymentMethods?: ProviderKey[];
|
|
1607
|
+
/** CSS class name for the root container. */
|
|
1608
|
+
className?: string;
|
|
1609
|
+
/** Inline styles for the root container. */
|
|
1610
|
+
style?: React.CSSProperties;
|
|
1611
|
+
/** Theme overrides applied as CSS custom properties. */
|
|
1612
|
+
theme?: ProvexTheme;
|
|
1613
|
+
}
|
|
1614
|
+
/** Common props accepted by all phase components. */
|
|
1615
|
+
interface PhaseComponentProps {
|
|
1616
|
+
/** CSS class name. */
|
|
1617
|
+
className?: string;
|
|
1618
|
+
/** Inline styles. */
|
|
1619
|
+
style?: React.CSSProperties;
|
|
1620
|
+
}
|
|
1621
|
+
/** Props for a phase component with a custom render prop. */
|
|
1622
|
+
interface PhaseRenderProps<TState> extends PhaseComponentProps {
|
|
1623
|
+
/** Custom render function — receives the phase state, returns JSX. */
|
|
1624
|
+
render?: (state: TState) => React.ReactNode;
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
/**
|
|
1628
|
+
* @fileoverview Thin API client for @provex/react.
|
|
1629
|
+
*
|
|
1630
|
+
* Provides typed get/post methods for the Provex backend API.
|
|
1631
|
+
* No external dependencies — uses the Fetch API directly.
|
|
1632
|
+
*/
|
|
1633
|
+
/** API client for making typed requests to the Provex backend. */
|
|
1634
|
+
interface ApiClient {
|
|
1635
|
+
/** Send a GET request and parse the JSON response. */
|
|
1636
|
+
get: <T>(path: string, options?: RequestInit) => Promise<T>;
|
|
1637
|
+
/** Send a POST request with a JSON body and parse the response. */
|
|
1638
|
+
post: <T>(path: string, body: unknown, options?: RequestInit) => Promise<T>;
|
|
1639
|
+
}
|
|
1640
|
+
/** Create an API client that targets the given base URL. */
|
|
1641
|
+
declare function createApiClient(apiUrl: string): ApiClient;
|
|
1642
|
+
|
|
1643
|
+
/** Shape of the context value provided by ProvexProvider. */
|
|
1644
|
+
interface ProvexContextValue {
|
|
1645
|
+
/** User-supplied configuration (apiUrl, chainId). */
|
|
1646
|
+
config: ProvexConfig;
|
|
1647
|
+
/** Data source adapter for indexer queries. */
|
|
1648
|
+
indexer: IndexerAdapter;
|
|
1649
|
+
/** Thin fetch wrapper for the Provex backend API. */
|
|
1650
|
+
apiClient: ApiClient;
|
|
1651
|
+
}
|
|
1652
|
+
/** Props for the ProvexProvider component. */
|
|
1653
|
+
interface ProvexProviderProps {
|
|
1654
|
+
/** Protocol configuration. */
|
|
1655
|
+
config: ProvexConfig;
|
|
1656
|
+
/**
|
|
1657
|
+
* Data source adapter. Implement IndexerAdapter against any backend:
|
|
1658
|
+
* - `createPonderAdapter()` from `@provex/indexer-client` (default for Provex apps)
|
|
1659
|
+
* - Custom REST, Graph, or RPC implementation
|
|
1660
|
+
*/
|
|
1661
|
+
indexer: IndexerAdapter;
|
|
1662
|
+
/** Optional external QueryClient — if omitted, a default one is created. */
|
|
1663
|
+
queryClient?: QueryClient;
|
|
1664
|
+
/** Child components that consume the context. */
|
|
1665
|
+
children: React__default.ReactNode;
|
|
1666
|
+
}
|
|
1667
|
+
/**
|
|
1668
|
+
* ProvexProvider — wrap your app (or a subtree) with this to enable
|
|
1669
|
+
* Provex hooks and components.
|
|
1670
|
+
*
|
|
1671
|
+
* @example
|
|
1672
|
+
* ```tsx
|
|
1673
|
+
* import { createPonderAdapter } from '@provex/indexer-client'
|
|
1674
|
+
*
|
|
1675
|
+
* const indexer = createPonderAdapter()
|
|
1676
|
+
*
|
|
1677
|
+
* <ProvexProvider
|
|
1678
|
+
* indexer={indexer}
|
|
1679
|
+
* config={{ apiUrl: 'https://app.provex.com', chainId: 369 }}
|
|
1680
|
+
* >
|
|
1681
|
+
* <App />
|
|
1682
|
+
* </ProvexProvider>
|
|
1683
|
+
* ```
|
|
1684
|
+
*/
|
|
1685
|
+
declare function ProvexProvider({ config, indexer, queryClient, children, }: ProvexProviderProps): react_jsx_runtime.JSX.Element;
|
|
1686
|
+
/**
|
|
1687
|
+
* useProvex — access the Provex context (config, indexer, apiClient).
|
|
1688
|
+
*
|
|
1689
|
+
* Must be called within a ProvexProvider. Throws if used outside the provider.
|
|
1690
|
+
*/
|
|
1691
|
+
declare function useProvex(): ProvexContextValue;
|
|
1692
|
+
|
|
1693
|
+
/**
|
|
1694
|
+
* @fileoverview useProvexBuy — headless state machine for the buy flow.
|
|
1695
|
+
*
|
|
1696
|
+
* Layer 1 of the 3-layer architecture. Returns all state + actions
|
|
1697
|
+
* with zero rendering. The integrator builds their entire UI.
|
|
1698
|
+
*
|
|
1699
|
+
* @example
|
|
1700
|
+
* ```tsx
|
|
1701
|
+
* function MyBuyPage() {
|
|
1702
|
+
* const buy = useProvexBuy({ wallet })
|
|
1703
|
+
*
|
|
1704
|
+
* return (
|
|
1705
|
+
* <div>
|
|
1706
|
+
* <input value={buy.amount} onChange={e => buy.setAmount(e.target.value)} />
|
|
1707
|
+
* <button disabled={!buy.canSubmit} onClick={buy.submitOrder}>
|
|
1708
|
+
* Buy
|
|
1709
|
+
* </button>
|
|
1710
|
+
* </div>
|
|
1711
|
+
* )
|
|
1712
|
+
* }
|
|
1713
|
+
* ```
|
|
1714
|
+
*/
|
|
1715
|
+
|
|
1716
|
+
/**
|
|
1717
|
+
* useProvexBuy — headless buy-flow state machine.
|
|
1718
|
+
*
|
|
1719
|
+
* Encapsulates all state, derived data, validation, and actions for the
|
|
1720
|
+
* 4-phase buy flow. Returns a flat object that phase components (Layer 2)
|
|
1721
|
+
* or custom UIs (Layer 1) can consume.
|
|
1722
|
+
*
|
|
1723
|
+
* Must be called within a `<ProvexProvider>`.
|
|
1724
|
+
*/
|
|
1725
|
+
declare function useProvexBuy({ wallet, onIntentSignaled, onComplete, paymentMethods: allowedPaymentMethods, }: UseProvexBuyOptions): UseProvexBuyReturn;
|
|
1726
|
+
|
|
1727
|
+
/**
|
|
1728
|
+
* useProvexBuyContext — access the buy-flow state machine from within
|
|
1729
|
+
* a `<ProvexBuyProvider>`.
|
|
1730
|
+
*
|
|
1731
|
+
* Throws if called outside the provider.
|
|
1732
|
+
*/
|
|
1733
|
+
declare function useProvexBuyContext(): UseProvexBuyReturn;
|
|
1734
|
+
/** Props for the ProvexBuyProvider component. */
|
|
1735
|
+
interface ProvexBuyProviderProps extends UseProvexBuyOptions {
|
|
1736
|
+
/** Child components that consume the buy-flow context. */
|
|
1737
|
+
children: React__default.ReactNode;
|
|
1738
|
+
}
|
|
1739
|
+
/**
|
|
1740
|
+
* ProvexBuyProvider — context provider that runs the buy-flow state machine
|
|
1741
|
+
* and makes it available to child phase components via `useProvexBuyContext()`.
|
|
1742
|
+
*/
|
|
1743
|
+
declare function ProvexBuyProvider({ children, ...options }: ProvexBuyProviderProps): react_jsx_runtime.JSX.Element;
|
|
1744
|
+
|
|
1745
|
+
/** State slice exposed to the BrowsePhase render prop. */
|
|
1746
|
+
interface BrowsePhaseState {
|
|
1747
|
+
amount: UseProvexBuyReturn['amount'];
|
|
1748
|
+
setAmount: UseProvexBuyReturn['setAmount'];
|
|
1749
|
+
selectedPaymentMethod: UseProvexBuyReturn['selectedPaymentMethod'];
|
|
1750
|
+
setSelectedPaymentMethod: UseProvexBuyReturn['setSelectedPaymentMethod'];
|
|
1751
|
+
availablePaymentMethods: UseProvexBuyReturn['availablePaymentMethods'];
|
|
1752
|
+
chainId: UseProvexBuyReturn['chainId'];
|
|
1753
|
+
rateDisplay: UseProvexBuyReturn['rateDisplay'];
|
|
1754
|
+
tokenAmountDisplay: UseProvexBuyReturn['tokenAmountDisplay'];
|
|
1755
|
+
token: UseProvexBuyReturn['token'];
|
|
1756
|
+
currency: UseProvexBuyReturn['currency'];
|
|
1757
|
+
canSubmit: UseProvexBuyReturn['canSubmit'];
|
|
1758
|
+
isSubmitting: UseProvexBuyReturn['isSubmitting'];
|
|
1759
|
+
validationMessage: UseProvexBuyReturn['validationMessage'];
|
|
1760
|
+
intentError: UseProvexBuyReturn['intentError'];
|
|
1761
|
+
intentStatus: UseProvexBuyReturn['intentStatus'];
|
|
1762
|
+
isLoadingDeposits: UseProvexBuyReturn['isLoadingDeposits'];
|
|
1763
|
+
deposits: UseProvexBuyReturn['deposits'];
|
|
1764
|
+
submitOrder: UseProvexBuyReturn['submitOrder'];
|
|
1765
|
+
}
|
|
1766
|
+
/**
|
|
1767
|
+
* BrowsePhase — renders the browse/input phase of the buy flow.
|
|
1768
|
+
*
|
|
1769
|
+
* Reads state from ProvexBuyContext. Only renders when phase === 'browse'.
|
|
1770
|
+
*/
|
|
1771
|
+
declare function BrowsePhase({ className, style, render, }: PhaseRenderProps<BrowsePhaseState>): react_jsx_runtime.JSX.Element | null;
|
|
1772
|
+
|
|
1773
|
+
/** State slice exposed to the CommittedPhase render prop. */
|
|
1774
|
+
interface CommittedPhaseState {
|
|
1775
|
+
intentHash: UseProvexBuyReturn['intentHash'];
|
|
1776
|
+
amount: UseProvexBuyReturn['amount'];
|
|
1777
|
+
currency: UseProvexBuyReturn['currency'];
|
|
1778
|
+
selectedPaymentMethod: UseProvexBuyReturn['selectedPaymentMethod'];
|
|
1779
|
+
chainId: UseProvexBuyReturn['chainId'];
|
|
1780
|
+
tokenAmountDisplay: UseProvexBuyReturn['tokenAmountDisplay'];
|
|
1781
|
+
token: UseProvexBuyReturn['token'];
|
|
1782
|
+
confirmPayment: UseProvexBuyReturn['confirmPayment'];
|
|
1783
|
+
payeeDetails: UseProvexBuyReturn['payeeDetails'];
|
|
1784
|
+
payeeName: UseProvexBuyReturn['payeeName'];
|
|
1785
|
+
payeeId: UseProvexBuyReturn['payeeId'];
|
|
1786
|
+
isPayeeLoading: UseProvexBuyReturn['isPayeeLoading'];
|
|
1787
|
+
intentExpiryTime: UseProvexBuyReturn['intentExpiryTime'];
|
|
1788
|
+
}
|
|
1789
|
+
/**
|
|
1790
|
+
* CommittedPhase — renders the committed phase of the buy flow.
|
|
1791
|
+
*
|
|
1792
|
+
* Shows the order summary and payment instructions after the user has
|
|
1793
|
+
* successfully signaled intent on-chain.
|
|
1794
|
+
*/
|
|
1795
|
+
declare function CommittedPhase({ className, style, render, }: PhaseRenderProps<CommittedPhaseState>): react_jsx_runtime.JSX.Element | null;
|
|
1796
|
+
|
|
1797
|
+
/** State slice exposed to the ProvingPhase render prop. */
|
|
1798
|
+
interface ProvingPhaseState {
|
|
1799
|
+
intentHash: UseProvexBuyReturn['intentHash'];
|
|
1800
|
+
intentExpiryTime: UseProvexBuyReturn['intentExpiryTime'];
|
|
1801
|
+
isIntentExpired: UseProvexBuyReturn['isIntentExpired'];
|
|
1802
|
+
indexedIntentStatus: UseProvexBuyReturn['indexedIntentStatus'];
|
|
1803
|
+
}
|
|
1804
|
+
/**
|
|
1805
|
+
* ProvingPhase — renders the proving phase of the buy flow.
|
|
1806
|
+
*
|
|
1807
|
+
* Shows the ZKP proof generation progress after the user confirms payment.
|
|
1808
|
+
*/
|
|
1809
|
+
declare function ProvingPhase({ className, style, render, }: PhaseRenderProps<ProvingPhaseState>): react_jsx_runtime.JSX.Element | null;
|
|
1810
|
+
|
|
1811
|
+
/** State slice exposed to the CompletePhase render prop. */
|
|
1812
|
+
interface CompletePhaseState {
|
|
1813
|
+
intentHash: UseProvexBuyReturn['intentHash'];
|
|
1814
|
+
chainId: UseProvexBuyReturn['chainId'];
|
|
1815
|
+
reset: UseProvexBuyReturn['reset'];
|
|
1816
|
+
}
|
|
1817
|
+
/**
|
|
1818
|
+
* CompletePhase — renders the completion phase of the buy flow.
|
|
1819
|
+
*
|
|
1820
|
+
* Shows a success message and a button to start a new purchase.
|
|
1821
|
+
*/
|
|
1822
|
+
declare function CompletePhase({ className, style, render, }: PhaseRenderProps<CompletePhaseState>): react_jsx_runtime.JSX.Element | null;
|
|
1823
|
+
|
|
1824
|
+
/**
|
|
1825
|
+
* ProvexBuy — Layer 3 buy-flow widget.
|
|
1826
|
+
*
|
|
1827
|
+
* Renders a complete 4-phase buy flow (browse -> committed -> proving -> complete)
|
|
1828
|
+
* using plain HTML elements with `data-provex-*` attributes for CSS targeting.
|
|
1829
|
+
*
|
|
1830
|
+
* No UI framework dependencies. All styling via CSS custom properties and data attributes.
|
|
1831
|
+
*/
|
|
1832
|
+
declare function ProvexBuy({ wallet, onIntentSignaled, onComplete, paymentMethods, className, style, theme, }: BuyProps): react_jsx_runtime.JSX.Element;
|
|
1833
|
+
|
|
1834
|
+
/** Props for the ProvexBuyWagmi component. Same as BuyProps minus `wallet`. */
|
|
1835
|
+
interface ProvexBuyWagmiProps {
|
|
1836
|
+
/** Called when the user signals intent (USDC reserved). */
|
|
1837
|
+
onIntentSignaled?: (intentHash: string, chainId: number) => void;
|
|
1838
|
+
/** Called when the full flow completes (USDC released). */
|
|
1839
|
+
onComplete?: (intentHash: string, chainId: number) => void;
|
|
1840
|
+
/** Restrict to specific payment methods. */
|
|
1841
|
+
paymentMethods?: ProviderKey[];
|
|
1842
|
+
/** CSS class name for the root container. */
|
|
1843
|
+
className?: string;
|
|
1844
|
+
/** Inline styles for the root container. */
|
|
1845
|
+
style?: React__default.CSSProperties;
|
|
1846
|
+
/** Theme overrides applied as CSS custom properties. */
|
|
1847
|
+
theme?: ProvexTheme;
|
|
1848
|
+
}
|
|
1849
|
+
/**
|
|
1850
|
+
* ProvexBuyWagmi — drop-in buy widget for wagmi apps.
|
|
1851
|
+
*
|
|
1852
|
+
* Reads the connected wallet from wagmi context automatically.
|
|
1853
|
+
* No need to create a WalletAdapter manually.
|
|
1854
|
+
*/
|
|
1855
|
+
declare function ProvexBuyWagmi({ onIntentSignaled, onComplete, paymentMethods, className, style, theme, }: ProvexBuyWagmiProps): react_jsx_runtime.JSX.Element;
|
|
1856
|
+
|
|
1857
|
+
export { type ApiClient, type AttestationParams, type AttestationResponse, BrowsePhase, type BrowsePhaseState, type BuyPhase, type BuyProps, type CancelIntentStatus, CommittedPhase, type CommittedPhaseState, CompletePhase, type CompletePhaseState, type CreateDepositParams$1 as CreateDepositParams, type CreateDepositRawParams, type DepositInfo, type DepositPaymentMethod, type IndexedDeposit, type IndexedIntent, type IndexedVerifier, type IndexerAdapter, type IntentStatus, type MakerRegistrationParams, type MutationSyncOptions, type PaginatedResult, type PaginationOptions, type PayeeDetails, type PayeeInfo, type PhaseComponentProps, type PhaseRenderProps, type PreparedTransaction, type ProtocolFeesResult, ProveXClient, type ProveXClientConfig, ProveXError, type ProveXErrorCode, ProvexBuy, ProvexBuyProvider, type ProvexBuyProviderProps, ProvexBuyWagmi, type ProvexBuyWagmiProps, type ProvexConfig, type ProvexContextValue, ProvexProvider, type ProvexProviderProps, type ProvexTheme, ProvingPhase, type ProvingPhaseState, type ReleaseFundsStatus, type ReputationData, type ReputationLimits, type ReputationLimitsParams, type SignalIntentParams, type SignalIntentRawParams, type SignalIntentResult, type SignalIntentStatus, type TransactionPhase, type TransactionResult, type TransactionSyncOptions, type UseProtocolFeesParams, type UseProvexBuyOptions, type UseProvexBuyReturn, type UseTransactionWithIndexerOptions, type CreateDepositParams as V3EscrowCreateDepositParams, type V3EscrowStatus, type WalletAdapter, type WritableMethod, createApiClient, createProveXClient, getRate, getTierDisplayInfo, intentStatuses, useAllowance, useCancelIntent, useDeposits, useNullifierRegistry, usePayeeDetails, useProtocolFeePercentage, useProtocolFees, useProveXClient, useProvex, useProvexBuy, useProvexBuyContext, useReleaseFundsToPayer, useReputation, useReputationLimits, useSignalIntent, useTransactionWithIndexer, useV3Escrow, useWagmiWallet };
|