@chipi-stack/chipi-react 14.8.0 → 14.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2861 @@
1
+ import { CreateWalletParams, CreateWalletResponse, GetWalletParams, GetWalletResponse, ChainToken, GetTokenBalanceResponse, WalletType, WalletData, SessionKeyData, SessionDataResponse, CreateSessionKeyParams, SessionConfig, Call as Call$1, SpendingPolicyConfig, SpendingPolicyData, MigrateWalletToPasskeyParams, UpdateWalletEncryptionParams, UpdateWalletEncryptionResponse, TransferHookInput, ApproveHookInput, GetTransactionListQuery, PaginatedResponse, Transaction, TransactionStatusResponse, SyncOnChainTransfersParams, SyncOnChainTransfersResponse, CreateSkuPurchaseParams, GetSkuListQuery, Sku, CallAnyContractParams, SignTypedDataParams, RecordSendTransactionParams, GetTokenBalanceParams, AddSessionKeyParams, RevokeSessionKeyParams, GetSessionDataParams, ExecuteWithSessionParams, PaymentRequirement, PaymentPayload } from '@chipi-stack/types';
2
+ import * as _tanstack_react_query from '@tanstack/react-query';
3
+ import { UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
4
+ import { MigrateChipiWalletToShhhParams, MigrationOutcome, Eip191Pubkey, WebAuthnPubkey, JwtAppleSubPubkey, NewOwnerInput, buildProposeAddOwnerCall, TIMELOCK_SECONDS, DEFAULT_OP_EXPIRY_SECONDS, ROLE_OWNER, ROLE_GUARDIAN, OP_ADD_OWNER, OP_REMOVE_OWNER, OP_ROTATE_OWNER, OP_SET_THRESHOLD, ShhhSignerKind, MIN_THRESHOLD_OWNERS } from '@chipi-stack/backend';
5
+ import { Call as Call$2 } from 'starknet';
6
+ import { TypedData, AccountDeploymentData } from '@starknet-io/types-js';
7
+ import { ShieldResult } from '@chipi-stack/core';
8
+
9
+ type CreateWalletInput = {
10
+ params: CreateWalletParams;
11
+ bearerToken: string;
12
+ };
13
+ /**
14
+ * Hook for creating a new wallet.
15
+ *
16
+ * Supports dual-key wrapping: when `usePasskey: true` AND `encryptKey` (PIN) provided,
17
+ * the private key is encrypted twice — once with the passkey-derived key (primary) and
18
+ * once with the PIN (backup). If passkey fails later, PIN recovers the wallet.
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * // Passkey + PIN (recommended)
23
+ * await createWalletAsync({
24
+ * params: {
25
+ * encryptKey: pin, // PIN backup
26
+ * externalUserId: userId,
27
+ * chain: Chain.STARKNET,
28
+ * usePasskey: true, // Creates passkey + dual encryption
29
+ * },
30
+ * bearerToken,
31
+ * });
32
+ *
33
+ * // PIN only (backward compatible)
34
+ * await createWalletAsync({
35
+ * params: {
36
+ * encryptKey: pin,
37
+ * externalUserId: userId,
38
+ * chain: Chain.STARKNET,
39
+ * },
40
+ * bearerToken,
41
+ * });
42
+ * ```
43
+ */
44
+ declare function useCreateWallet(): {
45
+ createWallet: (input: CreateWalletInput) => void;
46
+ createWalletAsync: (input: CreateWalletInput) => Promise<CreateWalletResponse>;
47
+ data: CreateWalletResponse | undefined;
48
+ isLoading: boolean;
49
+ isError: boolean;
50
+ error: Error | null;
51
+ isSuccess: boolean;
52
+ reset: () => void;
53
+ };
54
+
55
+ type GetWalletInput = {
56
+ params?: GetWalletParams;
57
+ getBearerToken?: () => Promise<string | null | undefined>;
58
+ queryOptions?: Omit<UseQueryOptions<GetWalletResponse | null, Error>, "queryKey" | "queryFn">;
59
+ };
60
+ declare function useGetWallet(input?: GetWalletInput): {
61
+ fetchWallet: (newInput: GetWalletInput) => Promise<GetWalletResponse | null>;
62
+ data: GetWalletResponse | null;
63
+ error: Error;
64
+ isError: true;
65
+ isPending: false;
66
+ isLoading: false;
67
+ isLoadingError: false;
68
+ isRefetchError: true;
69
+ isSuccess: false;
70
+ isPlaceholderData: false;
71
+ status: "error";
72
+ dataUpdatedAt: number;
73
+ errorUpdatedAt: number;
74
+ failureCount: number;
75
+ failureReason: Error | null;
76
+ errorUpdateCount: number;
77
+ isFetched: boolean;
78
+ isFetchedAfterMount: boolean;
79
+ isFetching: boolean;
80
+ isInitialLoading: boolean;
81
+ isPaused: boolean;
82
+ isRefetching: boolean;
83
+ isStale: boolean;
84
+ isEnabled: boolean;
85
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<GetWalletResponse | null, Error>>;
86
+ fetchStatus: _tanstack_react_query.FetchStatus;
87
+ promise: Promise<GetWalletResponse | null>;
88
+ } | {
89
+ fetchWallet: (newInput: GetWalletInput) => Promise<GetWalletResponse | null>;
90
+ data: GetWalletResponse | null;
91
+ error: null;
92
+ isError: false;
93
+ isPending: false;
94
+ isLoading: false;
95
+ isLoadingError: false;
96
+ isRefetchError: false;
97
+ isSuccess: true;
98
+ isPlaceholderData: false;
99
+ status: "success";
100
+ dataUpdatedAt: number;
101
+ errorUpdatedAt: number;
102
+ failureCount: number;
103
+ failureReason: Error | null;
104
+ errorUpdateCount: number;
105
+ isFetched: boolean;
106
+ isFetchedAfterMount: boolean;
107
+ isFetching: boolean;
108
+ isInitialLoading: boolean;
109
+ isPaused: boolean;
110
+ isRefetching: boolean;
111
+ isStale: boolean;
112
+ isEnabled: boolean;
113
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<GetWalletResponse | null, Error>>;
114
+ fetchStatus: _tanstack_react_query.FetchStatus;
115
+ promise: Promise<GetWalletResponse | null>;
116
+ } | {
117
+ fetchWallet: (newInput: GetWalletInput) => Promise<GetWalletResponse | null>;
118
+ data: undefined;
119
+ error: Error;
120
+ isError: true;
121
+ isPending: false;
122
+ isLoading: false;
123
+ isLoadingError: true;
124
+ isRefetchError: false;
125
+ isSuccess: false;
126
+ isPlaceholderData: false;
127
+ status: "error";
128
+ dataUpdatedAt: number;
129
+ errorUpdatedAt: number;
130
+ failureCount: number;
131
+ failureReason: Error | null;
132
+ errorUpdateCount: number;
133
+ isFetched: boolean;
134
+ isFetchedAfterMount: boolean;
135
+ isFetching: boolean;
136
+ isInitialLoading: boolean;
137
+ isPaused: boolean;
138
+ isRefetching: boolean;
139
+ isStale: boolean;
140
+ isEnabled: boolean;
141
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<GetWalletResponse | null, Error>>;
142
+ fetchStatus: _tanstack_react_query.FetchStatus;
143
+ promise: Promise<GetWalletResponse | null>;
144
+ } | {
145
+ fetchWallet: (newInput: GetWalletInput) => Promise<GetWalletResponse | null>;
146
+ data: undefined;
147
+ error: null;
148
+ isError: false;
149
+ isPending: true;
150
+ isLoading: true;
151
+ isLoadingError: false;
152
+ isRefetchError: false;
153
+ isSuccess: false;
154
+ isPlaceholderData: false;
155
+ status: "pending";
156
+ dataUpdatedAt: number;
157
+ errorUpdatedAt: number;
158
+ failureCount: number;
159
+ failureReason: Error | null;
160
+ errorUpdateCount: number;
161
+ isFetched: boolean;
162
+ isFetchedAfterMount: boolean;
163
+ isFetching: boolean;
164
+ isInitialLoading: boolean;
165
+ isPaused: boolean;
166
+ isRefetching: boolean;
167
+ isStale: boolean;
168
+ isEnabled: boolean;
169
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<GetWalletResponse | null, Error>>;
170
+ fetchStatus: _tanstack_react_query.FetchStatus;
171
+ promise: Promise<GetWalletResponse | null>;
172
+ } | {
173
+ fetchWallet: (newInput: GetWalletInput) => Promise<GetWalletResponse | null>;
174
+ data: undefined;
175
+ error: null;
176
+ isError: false;
177
+ isPending: true;
178
+ isLoadingError: false;
179
+ isRefetchError: false;
180
+ isSuccess: false;
181
+ isPlaceholderData: false;
182
+ status: "pending";
183
+ dataUpdatedAt: number;
184
+ errorUpdatedAt: number;
185
+ failureCount: number;
186
+ failureReason: Error | null;
187
+ errorUpdateCount: number;
188
+ isFetched: boolean;
189
+ isFetchedAfterMount: boolean;
190
+ isFetching: boolean;
191
+ isLoading: boolean;
192
+ isInitialLoading: boolean;
193
+ isPaused: boolean;
194
+ isRefetching: boolean;
195
+ isStale: boolean;
196
+ isEnabled: boolean;
197
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<GetWalletResponse | null, Error>>;
198
+ fetchStatus: _tanstack_react_query.FetchStatus;
199
+ promise: Promise<GetWalletResponse | null>;
200
+ } | {
201
+ fetchWallet: (newInput: GetWalletInput) => Promise<GetWalletResponse | null>;
202
+ data: GetWalletResponse | null;
203
+ isError: false;
204
+ error: null;
205
+ isPending: false;
206
+ isLoading: false;
207
+ isLoadingError: false;
208
+ isRefetchError: false;
209
+ isSuccess: true;
210
+ isPlaceholderData: true;
211
+ status: "success";
212
+ dataUpdatedAt: number;
213
+ errorUpdatedAt: number;
214
+ failureCount: number;
215
+ failureReason: Error | null;
216
+ errorUpdateCount: number;
217
+ isFetched: boolean;
218
+ isFetchedAfterMount: boolean;
219
+ isFetching: boolean;
220
+ isInitialLoading: boolean;
221
+ isPaused: boolean;
222
+ isRefetching: boolean;
223
+ isStale: boolean;
224
+ isEnabled: boolean;
225
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<GetWalletResponse | null, Error>>;
226
+ fetchStatus: _tanstack_react_query.FetchStatus;
227
+ promise: Promise<GetWalletResponse | null>;
228
+ };
229
+
230
+ /**
231
+ * Configuration for useChipiWallet hook
232
+ */
233
+ interface UseChipiWalletConfig {
234
+ /** External user ID (e.g., from Clerk, Firebase, etc.) */
235
+ externalUserId: string | null | undefined;
236
+ /** Function to get the bearer token for API calls */
237
+ getBearerToken: () => Promise<string | null | undefined>;
238
+ /** Default token for balance display (defaults to USDC) */
239
+ defaultToken?: ChainToken;
240
+ /** Whether to automatically fetch wallet on mount */
241
+ enabled?: boolean;
242
+ }
243
+ /**
244
+ * Extended wallet response with additional computed properties
245
+ */
246
+ interface ChipiWalletData extends GetWalletResponse {
247
+ /** Whether this wallet supports session keys */
248
+ supportsSessionKeys: boolean;
249
+ /** Formatted short address for display */
250
+ shortAddress: string;
251
+ }
252
+ /**
253
+ * Return type for useChipiWallet hook
254
+ */
255
+ interface UseChipiWalletReturn {
256
+ /** The user's wallet data, null if not found, undefined if loading */
257
+ wallet: ChipiWalletData | null | undefined;
258
+ /** Whether the user has a wallet */
259
+ hasWallet: boolean;
260
+ /** Whether the wallet is currently being fetched */
261
+ isLoadingWallet: boolean;
262
+ /** Error from fetching wallet */
263
+ walletError: Error | null;
264
+ /** The wallet's balance for the default token */
265
+ balance: GetTokenBalanceResponse | undefined;
266
+ /** Formatted balance string (e.g., "100.50") */
267
+ formattedBalance: string;
268
+ /** Whether balance is loading */
269
+ isLoadingBalance: boolean;
270
+ /** Create a new wallet */
271
+ createWallet: (params: {
272
+ encryptKey: string;
273
+ walletType?: WalletType;
274
+ }) => Promise<CreateWalletResponse>;
275
+ /** Whether wallet creation is in progress */
276
+ isCreating: boolean;
277
+ /** Data from the last wallet creation */
278
+ createdWallet: CreateWalletResponse | undefined;
279
+ /** Refetch the wallet data */
280
+ refetchWallet: () => Promise<void>;
281
+ /** Refetch the balance */
282
+ refetchBalance: () => Promise<void>;
283
+ /** Refetch both wallet and balance */
284
+ refetchAll: () => Promise<void>;
285
+ }
286
+ /**
287
+ * All-in-one wallet hook for Chipi SDK.
288
+ *
289
+ * Combines wallet fetching, creation, and balance checking into a single hook
290
+ * for simplified wallet management.
291
+ *
292
+ * @example
293
+ * ```tsx
294
+ * import { useAuth } from "@clerk/nextjs";
295
+ * import { useChipiWallet } from "@chipi-stack/nextjs";
296
+ *
297
+ * function WalletComponent() {
298
+ * const { userId, getToken } = useAuth();
299
+ * const {
300
+ * wallet,
301
+ * hasWallet,
302
+ * balance,
303
+ * formattedBalance,
304
+ * createWallet,
305
+ * isCreating,
306
+ * isLoadingWallet,
307
+ * } = useChipiWallet({
308
+ * externalUserId: userId,
309
+ * getBearerToken: getToken,
310
+ * });
311
+ *
312
+ * if (isLoadingWallet) return <div>Loading...</div>;
313
+ *
314
+ * if (!hasWallet) {
315
+ * return (
316
+ * <button
317
+ * onClick={() => createWallet({ encryptKey: "1234" })}
318
+ * disabled={isCreating}
319
+ * >
320
+ * {isCreating ? "Creating..." : "Create Wallet"}
321
+ * </button>
322
+ * );
323
+ * }
324
+ *
325
+ * return (
326
+ * <div>
327
+ * <p>Address: {wallet?.shortAddress}</p>
328
+ * <p>Balance: ${formattedBalance} USDC</p>
329
+ * <p>Session Keys: {wallet?.supportsSessionKeys ? "Yes" : "No"}</p>
330
+ * </div>
331
+ * );
332
+ * }
333
+ * ```
334
+ */
335
+ declare function useChipiWallet(config: UseChipiWalletConfig): UseChipiWalletReturn;
336
+
337
+ /**
338
+ * Wallet data with optional wallet type for session operations
339
+ */
340
+ interface SessionWallet extends WalletData {
341
+ walletType?: WalletType;
342
+ }
343
+ /**
344
+ * Configuration for useChipiSession hook
345
+ */
346
+ interface UseChipiSessionConfig {
347
+ /** Wallet data (must be a CHIPI wallet for session support) */
348
+ wallet: SessionWallet | null | undefined;
349
+ /** Encryption key (user's PIN) for signing operations */
350
+ encryptKey: string;
351
+ /** Function to get the bearer token for API calls */
352
+ getBearerToken: () => Promise<string | null | undefined>;
353
+ /** Previously stored session data (from Clerk metadata, database, etc.) */
354
+ storedSession?: SessionKeyData | null;
355
+ /** Callback fired when a new session is created (for persistence) */
356
+ onSessionCreated?: (session: SessionKeyData) => void | Promise<void>;
357
+ /** Session duration in seconds (default: 6 hours) */
358
+ defaultDurationSeconds?: number;
359
+ /** Default max calls for session registration (default: 1000) */
360
+ defaultMaxCalls?: number;
361
+ /** Whether to auto-check session status on mount */
362
+ autoCheckStatus?: boolean;
363
+ }
364
+ /**
365
+ * Session lifecycle state
366
+ */
367
+ type SessionState = "none" | "created" | "active" | "expired" | "revoked";
368
+ /**
369
+ * Return type for useChipiSession hook
370
+ */
371
+ interface UseChipiSessionReturn {
372
+ /** Current session key data */
373
+ session: SessionKeyData | null;
374
+ /** On-chain session status (from contract query) */
375
+ sessionStatus: SessionDataResponse | undefined;
376
+ /** Current session lifecycle state */
377
+ sessionState: SessionState;
378
+ /** Whether there is an active, usable session */
379
+ hasActiveSession: boolean;
380
+ /** Whether the session has expired */
381
+ isSessionExpired: boolean;
382
+ /** Remaining calls available for the session */
383
+ remainingCalls: number | undefined;
384
+ /** Whether the wallet supports sessions (CHIPI wallet) */
385
+ supportsSession: boolean;
386
+ /** Create a new session keypair locally (does NOT register on-chain) */
387
+ createSession: (config?: Partial<CreateSessionKeyParams>) => Promise<SessionKeyData>;
388
+ /** Register the current session on the blockchain */
389
+ registerSession: (config?: Partial<SessionConfig>) => Promise<string>;
390
+ /** Revoke the current session from the blockchain */
391
+ revokeSession: () => Promise<string>;
392
+ /** Execute calls using the session key (no owner signature needed) */
393
+ executeWithSession: (calls: Call$1[]) => Promise<string>;
394
+ /** Clear the current session from local state */
395
+ clearSession: () => void;
396
+ /** Refresh the on-chain session status */
397
+ refetchStatus: () => Promise<void>;
398
+ /** Set a spending policy for the current session + token pair */
399
+ setSpendingPolicy: (config: Omit<SpendingPolicyConfig, "sessionPublicKey">) => Promise<string>;
400
+ /** Query the spending policy for a token (read-only, no gas) */
401
+ getSpendingPolicy: (token: string) => Promise<SpendingPolicyData>;
402
+ /** Remove a spending policy for a token */
403
+ removeSpendingPolicy: (token: string) => Promise<string>;
404
+ isCreating: boolean;
405
+ isRegistering: boolean;
406
+ isRevoking: boolean;
407
+ isExecuting: boolean;
408
+ isLoadingStatus: boolean;
409
+ isSettingSpendingPolicy: boolean;
410
+ isRemovingSpendingPolicy: boolean;
411
+ error: Error | null;
412
+ }
413
+ /**
414
+ * All-in-one session management hook for Chipi SDK.
415
+ *
416
+ * Combines session creation, registration, execution, and revocation
417
+ * into a single unified API. Session keys enable gasless transactions
418
+ * without requiring the owner's private key for each operation.
419
+ *
420
+ * **Important:** Sessions only work with CHIPI wallets. ARGENT wallets
421
+ * do not support session keys.
422
+ *
423
+ * @example
424
+ * ```tsx
425
+ * import { useAuth } from "@clerk/nextjs";
426
+ * import { useChipiWallet, useChipiSession } from "@chipi-stack/nextjs";
427
+ *
428
+ * function SessionComponent() {
429
+ * const { userId, getToken } = useAuth();
430
+ * const [pin, setPin] = useState("");
431
+ * const { wallet } = useChipiWallet({ externalUserId: userId, getBearerToken: getToken });
432
+ *
433
+ * const {
434
+ * session,
435
+ * hasActiveSession,
436
+ * sessionState,
437
+ * createSession,
438
+ * registerSession,
439
+ * executeWithSession,
440
+ * isCreating,
441
+ * isRegistering,
442
+ * } = useChipiSession({
443
+ * wallet,
444
+ * encryptKey: pin,
445
+ * getBearerToken: getToken,
446
+ * onSessionCreated: async (newSession) => {
447
+ * // Persist to Clerk metadata or database
448
+ * await saveSessionToClerk(newSession);
449
+ * },
450
+ * });
451
+ *
452
+ * const handleSetupSession = async () => {
453
+ * // Step 1: Create session locally
454
+ * await createSession();
455
+ * // Step 2: Register on-chain
456
+ * await registerSession();
457
+ * };
458
+ *
459
+ * const handleTransfer = async () => {
460
+ * // Execute transfer using session (no PIN needed after setup)
461
+ * await executeWithSession([{
462
+ * contractAddress: USDC_ADDRESS,
463
+ * entrypoint: "transfer",
464
+ * calldata: [recipient, amount, "0x0"],
465
+ * }]);
466
+ * };
467
+ *
468
+ * return (
469
+ * <div>
470
+ * <p>Session State: {sessionState}</p>
471
+ * {!hasActiveSession ? (
472
+ * <button onClick={handleSetupSession} disabled={isCreating || isRegistering}>
473
+ * Setup Session
474
+ * </button>
475
+ * ) : (
476
+ * <button onClick={handleTransfer}>
477
+ * Transfer (Gasless)
478
+ * </button>
479
+ * )}
480
+ * </div>
481
+ * );
482
+ * }
483
+ * ```
484
+ */
485
+ declare function useChipiSession(config: UseChipiSessionConfig): UseChipiSessionReturn;
486
+
487
+ type MigrateWalletToPasskeyInput = MigrateWalletToPasskeyParams & {
488
+ bearerToken: string;
489
+ };
490
+ interface MigrateWalletToPasskeyResult {
491
+ success: boolean;
492
+ wallet: WalletData;
493
+ credentialId: string;
494
+ }
495
+ /**
496
+ * Hook for migrating a wallet from encryptKey (PIN) to passkey authentication
497
+ */
498
+ declare function useMigrateWalletToPasskey(): {
499
+ migrateWalletToPasskey: (input: MigrateWalletToPasskeyInput) => void;
500
+ migrateWalletToPasskeyAsync: (input: MigrateWalletToPasskeyInput) => Promise<MigrateWalletToPasskeyResult>;
501
+ data: MigrateWalletToPasskeyResult | undefined;
502
+ isLoading: boolean;
503
+ isError: boolean;
504
+ error: Error | null;
505
+ isSuccess: boolean;
506
+ reset: () => void;
507
+ };
508
+
509
+ type UpdateWalletEncryptionInput = UpdateWalletEncryptionParams & {
510
+ bearerToken: string;
511
+ };
512
+ /**
513
+ * Hook for updating a wallet's encrypted private key.
514
+ * Use when the user changes their passkey or PIN; the client re-encrypts the private key
515
+ * and sends the new ciphertext here.
516
+ */
517
+ declare function useUpdateWalletEncryption(): {
518
+ updateWalletEncryption: (input: UpdateWalletEncryptionInput) => void;
519
+ updateWalletEncryptionAsync: (input: UpdateWalletEncryptionInput) => Promise<UpdateWalletEncryptionResponse>;
520
+ data: UpdateWalletEncryptionResponse | undefined;
521
+ isLoading: boolean;
522
+ isError: boolean;
523
+ error: Error | null;
524
+ isSuccess: boolean;
525
+ reset: () => void;
526
+ };
527
+
528
+ /**
529
+ * Input for the migration mutation.
530
+ *
531
+ * Drops `client` and `bearerToken` from the SDK-level params (the
532
+ * hook reads them from context + the input below) and treats the
533
+ * rest the same as the SDK call. The hook does NOT touch passkey /
534
+ * PIN orchestration — callers are responsible for handing in the
535
+ * already-resolved `encryptKey`. For the dashboard flow this means
536
+ * showing the PIN/passkey prompt yourself and passing the result
537
+ * here.
538
+ */
539
+ type MigrateInput = Omit<MigrateChipiWalletToShhhParams, "client" | "bearerToken"> & {
540
+ bearerToken: string;
541
+ };
542
+ /**
543
+ * Hook for migrating a CHIPI v29 wallet to SHHH V8.4.
544
+ *
545
+ * Wraps the `migrateChipiWalletToShhh` backend SDK function (which
546
+ * itself composes chipi-back's prepare + execute endpoints with
547
+ * client-side V8.4 OE signing). The PIN/passkey unwrap step happens
548
+ * before this hook is called; the migration multicall is signed
549
+ * locally with the resulting STARK key and the cleartext key never
550
+ * leaves the device.
551
+ *
552
+ * Two terminal outcomes the consumer must handle:
553
+ * - `{ kind: "MIGRATED", transactionHash, ... }` — happy path,
554
+ * on-chain tx landed and DB row is patched. If `partial: true`,
555
+ * the on-chain tx succeeded but the chipi-back DB patch failed;
556
+ * the operator runbook's reconciler cron (task #30) will catch
557
+ * up automatically. Dashboard should surface "wallet upgraded;
558
+ * refresh in a moment" copy in both sub-cases.
559
+ * - `{ kind: "ALREADY_MIGRATED", primaryKind, ... }` — chipi-back
560
+ * detected the wallet was already SHHH on chain and patched the
561
+ * DB row on the way out. No on-chain tx fired. Dashboard should
562
+ * surface "this wallet is already on V8.4" and refresh the
563
+ * wallet shape.
564
+ *
565
+ * Throws (surfaces via `error`) on:
566
+ * - STRANDED-state recovery (different signing flow, not in PR A)
567
+ * - UNDEPLOYED wallets (caller should redirect to createWallet)
568
+ * - DEFERRED legacy versions (v28/v33; not yet supported)
569
+ * - Mismatched encryptKey (decryption fails)
570
+ * - chipi-back kill switch off (`CHIPI_MIGRATION_ENABLED` not set)
571
+ *
572
+ * @example
573
+ * ```tsx
574
+ * const { migrateAsync, isLoading, error } = useMigrateWalletToShhh();
575
+ *
576
+ * async function onClickMigrate() {
577
+ * const encryptKey = await promptForPin(); // or passkey unlock
578
+ * const outcome = await migrateAsync({
579
+ * walletId: wallet.id,
580
+ * externalUserId: user.id,
581
+ * wallet: { publicKey: wallet.publicKey, encryptedPrivateKey: wallet.encryptedPrivateKey },
582
+ * encryptKey,
583
+ * bearerToken,
584
+ * });
585
+ * if (outcome.kind === "MIGRATED") {
586
+ * showToast(`Wallet upgraded — tx ${outcome.transactionHash}`);
587
+ * } else {
588
+ * showToast(`Wallet was already on V8.4 (${outcome.primaryKind})`);
589
+ * }
590
+ * }
591
+ * ```
592
+ */
593
+ declare function useMigrateWalletToShhh(): {
594
+ migrate: (input: MigrateInput) => void;
595
+ migrateAsync: (input: MigrateInput) => Promise<MigrationOutcome>;
596
+ data: MigrationOutcome | undefined;
597
+ isLoading: boolean;
598
+ isError: boolean;
599
+ error: Error | null;
600
+ isSuccess: boolean;
601
+ reset: () => void;
602
+ };
603
+
604
+ type TransferInput = {
605
+ params: TransferHookInput;
606
+ bearerToken: string;
607
+ };
608
+ /**
609
+ * Configuration for useTransfer hook.
610
+ */
611
+ interface UseTransferConfig {
612
+ /**
613
+ * Callback to prompt user for PIN when passkey fails.
614
+ * Should show a PIN input dialog and return the PIN, or null to cancel.
615
+ * Only called when usePasskey: true and passkey auth fails.
616
+ */
617
+ onPinRequired?: () => Promise<string | null>;
618
+ }
619
+ /**
620
+ * Hook for transferring tokens.
621
+ *
622
+ * When `usePasskey: true`:
623
+ * 1. Tries passkey authentication first
624
+ * 2. If passkey fails and wallet has `encryptedPrivateKeyBackup`:
625
+ * calls `onPinRequired` to get PIN, uses PIN to decrypt backup
626
+ * 3. If no backup or no `onPinRequired`, throws
627
+ *
628
+ * @example
629
+ * ```tsx
630
+ * const { transferAsync } = useTransfer({
631
+ * onPinRequired: async () => {
632
+ * // Show PIN dialog, return PIN or null to cancel
633
+ * return await showPinDialog();
634
+ * },
635
+ * });
636
+ * ```
637
+ */
638
+ declare function useTransfer(config?: UseTransferConfig): {
639
+ transfer: (input: TransferInput) => void;
640
+ transferAsync: (input: TransferInput) => Promise<string>;
641
+ data: string | undefined;
642
+ isLoading: boolean;
643
+ isError: boolean;
644
+ error: Error | null;
645
+ isSuccess: boolean;
646
+ reset: () => void;
647
+ };
648
+
649
+ type ApproveInput = {
650
+ params: ApproveHookInput;
651
+ bearerToken: string;
652
+ };
653
+ /**
654
+ * Hook for approving token spending
655
+ */
656
+ declare function useApprove(): {
657
+ approve: (params: ApproveInput) => void;
658
+ approveAsync: (params: ApproveInput) => Promise<string>;
659
+ data: string | undefined;
660
+ isLoading: boolean;
661
+ isError: boolean;
662
+ error: Error | null;
663
+ isSuccess: boolean;
664
+ reset: () => void;
665
+ };
666
+
667
+ type TransactionListInput = {
668
+ query: GetTransactionListQuery;
669
+ getBearerToken?: () => Promise<string | null | undefined>;
670
+ queryOptions?: Omit<UseQueryOptions<PaginatedResponse<Transaction>, Error>, "queryKey" | "queryFn">;
671
+ };
672
+ type FetchTransactionListInput = {
673
+ query: GetTransactionListQuery;
674
+ getBearerToken: () => Promise<string | null | undefined>;
675
+ };
676
+ declare function useGetTransactionList(input?: TransactionListInput): {
677
+ fetchTransactionList: (newInput: FetchTransactionListInput) => Promise<PaginatedResponse<Transaction>>;
678
+ data: PaginatedResponse<Transaction>;
679
+ error: Error;
680
+ isError: true;
681
+ isPending: false;
682
+ isLoading: false;
683
+ isLoadingError: false;
684
+ isRefetchError: true;
685
+ isSuccess: false;
686
+ isPlaceholderData: false;
687
+ status: "error";
688
+ dataUpdatedAt: number;
689
+ errorUpdatedAt: number;
690
+ failureCount: number;
691
+ failureReason: Error | null;
692
+ errorUpdateCount: number;
693
+ isFetched: boolean;
694
+ isFetchedAfterMount: boolean;
695
+ isFetching: boolean;
696
+ isInitialLoading: boolean;
697
+ isPaused: boolean;
698
+ isRefetching: boolean;
699
+ isStale: boolean;
700
+ isEnabled: boolean;
701
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<PaginatedResponse<Transaction>, Error>>;
702
+ fetchStatus: _tanstack_react_query.FetchStatus;
703
+ promise: Promise<PaginatedResponse<Transaction>>;
704
+ } | {
705
+ fetchTransactionList: (newInput: FetchTransactionListInput) => Promise<PaginatedResponse<Transaction>>;
706
+ data: PaginatedResponse<Transaction>;
707
+ error: null;
708
+ isError: false;
709
+ isPending: false;
710
+ isLoading: false;
711
+ isLoadingError: false;
712
+ isRefetchError: false;
713
+ isSuccess: true;
714
+ isPlaceholderData: false;
715
+ status: "success";
716
+ dataUpdatedAt: number;
717
+ errorUpdatedAt: number;
718
+ failureCount: number;
719
+ failureReason: Error | null;
720
+ errorUpdateCount: number;
721
+ isFetched: boolean;
722
+ isFetchedAfterMount: boolean;
723
+ isFetching: boolean;
724
+ isInitialLoading: boolean;
725
+ isPaused: boolean;
726
+ isRefetching: boolean;
727
+ isStale: boolean;
728
+ isEnabled: boolean;
729
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<PaginatedResponse<Transaction>, Error>>;
730
+ fetchStatus: _tanstack_react_query.FetchStatus;
731
+ promise: Promise<PaginatedResponse<Transaction>>;
732
+ } | {
733
+ fetchTransactionList: (newInput: FetchTransactionListInput) => Promise<PaginatedResponse<Transaction>>;
734
+ data: undefined;
735
+ error: Error;
736
+ isError: true;
737
+ isPending: false;
738
+ isLoading: false;
739
+ isLoadingError: true;
740
+ isRefetchError: false;
741
+ isSuccess: false;
742
+ isPlaceholderData: false;
743
+ status: "error";
744
+ dataUpdatedAt: number;
745
+ errorUpdatedAt: number;
746
+ failureCount: number;
747
+ failureReason: Error | null;
748
+ errorUpdateCount: number;
749
+ isFetched: boolean;
750
+ isFetchedAfterMount: boolean;
751
+ isFetching: boolean;
752
+ isInitialLoading: boolean;
753
+ isPaused: boolean;
754
+ isRefetching: boolean;
755
+ isStale: boolean;
756
+ isEnabled: boolean;
757
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<PaginatedResponse<Transaction>, Error>>;
758
+ fetchStatus: _tanstack_react_query.FetchStatus;
759
+ promise: Promise<PaginatedResponse<Transaction>>;
760
+ } | {
761
+ fetchTransactionList: (newInput: FetchTransactionListInput) => Promise<PaginatedResponse<Transaction>>;
762
+ data: undefined;
763
+ error: null;
764
+ isError: false;
765
+ isPending: true;
766
+ isLoading: true;
767
+ isLoadingError: false;
768
+ isRefetchError: false;
769
+ isSuccess: false;
770
+ isPlaceholderData: false;
771
+ status: "pending";
772
+ dataUpdatedAt: number;
773
+ errorUpdatedAt: number;
774
+ failureCount: number;
775
+ failureReason: Error | null;
776
+ errorUpdateCount: number;
777
+ isFetched: boolean;
778
+ isFetchedAfterMount: boolean;
779
+ isFetching: boolean;
780
+ isInitialLoading: boolean;
781
+ isPaused: boolean;
782
+ isRefetching: boolean;
783
+ isStale: boolean;
784
+ isEnabled: boolean;
785
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<PaginatedResponse<Transaction>, Error>>;
786
+ fetchStatus: _tanstack_react_query.FetchStatus;
787
+ promise: Promise<PaginatedResponse<Transaction>>;
788
+ } | {
789
+ fetchTransactionList: (newInput: FetchTransactionListInput) => Promise<PaginatedResponse<Transaction>>;
790
+ data: undefined;
791
+ error: null;
792
+ isError: false;
793
+ isPending: true;
794
+ isLoadingError: false;
795
+ isRefetchError: false;
796
+ isSuccess: false;
797
+ isPlaceholderData: false;
798
+ status: "pending";
799
+ dataUpdatedAt: number;
800
+ errorUpdatedAt: number;
801
+ failureCount: number;
802
+ failureReason: Error | null;
803
+ errorUpdateCount: number;
804
+ isFetched: boolean;
805
+ isFetchedAfterMount: boolean;
806
+ isFetching: boolean;
807
+ isLoading: boolean;
808
+ isInitialLoading: boolean;
809
+ isPaused: boolean;
810
+ isRefetching: boolean;
811
+ isStale: boolean;
812
+ isEnabled: boolean;
813
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<PaginatedResponse<Transaction>, Error>>;
814
+ fetchStatus: _tanstack_react_query.FetchStatus;
815
+ promise: Promise<PaginatedResponse<Transaction>>;
816
+ } | {
817
+ fetchTransactionList: (newInput: FetchTransactionListInput) => Promise<PaginatedResponse<Transaction>>;
818
+ data: PaginatedResponse<Transaction>;
819
+ isError: false;
820
+ error: null;
821
+ isPending: false;
822
+ isLoading: false;
823
+ isLoadingError: false;
824
+ isRefetchError: false;
825
+ isSuccess: true;
826
+ isPlaceholderData: true;
827
+ status: "success";
828
+ dataUpdatedAt: number;
829
+ errorUpdatedAt: number;
830
+ failureCount: number;
831
+ failureReason: Error | null;
832
+ errorUpdateCount: number;
833
+ isFetched: boolean;
834
+ isFetchedAfterMount: boolean;
835
+ isFetching: boolean;
836
+ isInitialLoading: boolean;
837
+ isPaused: boolean;
838
+ isRefetching: boolean;
839
+ isStale: boolean;
840
+ isEnabled: boolean;
841
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<PaginatedResponse<Transaction>, Error>>;
842
+ fetchStatus: _tanstack_react_query.FetchStatus;
843
+ promise: Promise<PaginatedResponse<Transaction>>;
844
+ };
845
+
846
+ type GetTransactionInput = {
847
+ hashOrId?: string;
848
+ getBearerToken?: () => Promise<string | null | undefined>;
849
+ queryOptions?: Omit<UseQueryOptions<Transaction, Error>, "queryKey" | "queryFn">;
850
+ };
851
+ type FetchTransactionInput = {
852
+ hashOrId: string;
853
+ getBearerToken: () => Promise<string | null | undefined>;
854
+ };
855
+ declare function useGetTransaction(input?: GetTransactionInput): {
856
+ fetchTransaction: (newInput: FetchTransactionInput) => Promise<Transaction>;
857
+ data: Transaction;
858
+ error: Error;
859
+ isError: true;
860
+ isPending: false;
861
+ isLoading: false;
862
+ isLoadingError: false;
863
+ isRefetchError: true;
864
+ isSuccess: false;
865
+ isPlaceholderData: false;
866
+ status: "error";
867
+ dataUpdatedAt: number;
868
+ errorUpdatedAt: number;
869
+ failureCount: number;
870
+ failureReason: Error | null;
871
+ errorUpdateCount: number;
872
+ isFetched: boolean;
873
+ isFetchedAfterMount: boolean;
874
+ isFetching: boolean;
875
+ isInitialLoading: boolean;
876
+ isPaused: boolean;
877
+ isRefetching: boolean;
878
+ isStale: boolean;
879
+ isEnabled: boolean;
880
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Transaction, Error>>;
881
+ fetchStatus: _tanstack_react_query.FetchStatus;
882
+ promise: Promise<Transaction>;
883
+ } | {
884
+ fetchTransaction: (newInput: FetchTransactionInput) => Promise<Transaction>;
885
+ data: Transaction;
886
+ error: null;
887
+ isError: false;
888
+ isPending: false;
889
+ isLoading: false;
890
+ isLoadingError: false;
891
+ isRefetchError: false;
892
+ isSuccess: true;
893
+ isPlaceholderData: false;
894
+ status: "success";
895
+ dataUpdatedAt: number;
896
+ errorUpdatedAt: number;
897
+ failureCount: number;
898
+ failureReason: Error | null;
899
+ errorUpdateCount: number;
900
+ isFetched: boolean;
901
+ isFetchedAfterMount: boolean;
902
+ isFetching: boolean;
903
+ isInitialLoading: boolean;
904
+ isPaused: boolean;
905
+ isRefetching: boolean;
906
+ isStale: boolean;
907
+ isEnabled: boolean;
908
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Transaction, Error>>;
909
+ fetchStatus: _tanstack_react_query.FetchStatus;
910
+ promise: Promise<Transaction>;
911
+ } | {
912
+ fetchTransaction: (newInput: FetchTransactionInput) => Promise<Transaction>;
913
+ data: undefined;
914
+ error: Error;
915
+ isError: true;
916
+ isPending: false;
917
+ isLoading: false;
918
+ isLoadingError: true;
919
+ isRefetchError: false;
920
+ isSuccess: false;
921
+ isPlaceholderData: false;
922
+ status: "error";
923
+ dataUpdatedAt: number;
924
+ errorUpdatedAt: number;
925
+ failureCount: number;
926
+ failureReason: Error | null;
927
+ errorUpdateCount: number;
928
+ isFetched: boolean;
929
+ isFetchedAfterMount: boolean;
930
+ isFetching: boolean;
931
+ isInitialLoading: boolean;
932
+ isPaused: boolean;
933
+ isRefetching: boolean;
934
+ isStale: boolean;
935
+ isEnabled: boolean;
936
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Transaction, Error>>;
937
+ fetchStatus: _tanstack_react_query.FetchStatus;
938
+ promise: Promise<Transaction>;
939
+ } | {
940
+ fetchTransaction: (newInput: FetchTransactionInput) => Promise<Transaction>;
941
+ data: undefined;
942
+ error: null;
943
+ isError: false;
944
+ isPending: true;
945
+ isLoading: true;
946
+ isLoadingError: false;
947
+ isRefetchError: false;
948
+ isSuccess: false;
949
+ isPlaceholderData: false;
950
+ status: "pending";
951
+ dataUpdatedAt: number;
952
+ errorUpdatedAt: number;
953
+ failureCount: number;
954
+ failureReason: Error | null;
955
+ errorUpdateCount: number;
956
+ isFetched: boolean;
957
+ isFetchedAfterMount: boolean;
958
+ isFetching: boolean;
959
+ isInitialLoading: boolean;
960
+ isPaused: boolean;
961
+ isRefetching: boolean;
962
+ isStale: boolean;
963
+ isEnabled: boolean;
964
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Transaction, Error>>;
965
+ fetchStatus: _tanstack_react_query.FetchStatus;
966
+ promise: Promise<Transaction>;
967
+ } | {
968
+ fetchTransaction: (newInput: FetchTransactionInput) => Promise<Transaction>;
969
+ data: undefined;
970
+ error: null;
971
+ isError: false;
972
+ isPending: true;
973
+ isLoadingError: false;
974
+ isRefetchError: false;
975
+ isSuccess: false;
976
+ isPlaceholderData: false;
977
+ status: "pending";
978
+ dataUpdatedAt: number;
979
+ errorUpdatedAt: number;
980
+ failureCount: number;
981
+ failureReason: Error | null;
982
+ errorUpdateCount: number;
983
+ isFetched: boolean;
984
+ isFetchedAfterMount: boolean;
985
+ isFetching: boolean;
986
+ isLoading: boolean;
987
+ isInitialLoading: boolean;
988
+ isPaused: boolean;
989
+ isRefetching: boolean;
990
+ isStale: boolean;
991
+ isEnabled: boolean;
992
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Transaction, Error>>;
993
+ fetchStatus: _tanstack_react_query.FetchStatus;
994
+ promise: Promise<Transaction>;
995
+ } | {
996
+ fetchTransaction: (newInput: FetchTransactionInput) => Promise<Transaction>;
997
+ data: Transaction;
998
+ isError: false;
999
+ error: null;
1000
+ isPending: false;
1001
+ isLoading: false;
1002
+ isLoadingError: false;
1003
+ isRefetchError: false;
1004
+ isSuccess: true;
1005
+ isPlaceholderData: true;
1006
+ status: "success";
1007
+ dataUpdatedAt: number;
1008
+ errorUpdatedAt: number;
1009
+ failureCount: number;
1010
+ failureReason: Error | null;
1011
+ errorUpdateCount: number;
1012
+ isFetched: boolean;
1013
+ isFetchedAfterMount: boolean;
1014
+ isFetching: boolean;
1015
+ isInitialLoading: boolean;
1016
+ isPaused: boolean;
1017
+ isRefetching: boolean;
1018
+ isStale: boolean;
1019
+ isEnabled: boolean;
1020
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Transaction, Error>>;
1021
+ fetchStatus: _tanstack_react_query.FetchStatus;
1022
+ promise: Promise<Transaction>;
1023
+ };
1024
+
1025
+ type GetTransactionStatusInput = {
1026
+ hash?: string;
1027
+ getBearerToken?: () => Promise<string | null | undefined>;
1028
+ /** Polling interval in ms. Defaults to 3000. Set to false to disable polling. */
1029
+ refetchInterval?: number | false;
1030
+ queryOptions?: Omit<UseQueryOptions<TransactionStatusResponse, Error>, "queryKey" | "queryFn" | "refetchInterval">;
1031
+ };
1032
+ type FetchTransactionStatusInput = {
1033
+ hash: string;
1034
+ getBearerToken: () => Promise<string | null | undefined>;
1035
+ };
1036
+ declare function useGetTransactionStatus(input?: GetTransactionStatusInput): {
1037
+ fetchTransactionStatus: (newInput: FetchTransactionStatusInput) => Promise<TransactionStatusResponse>;
1038
+ data: TransactionStatusResponse;
1039
+ error: Error;
1040
+ isError: true;
1041
+ isPending: false;
1042
+ isLoading: false;
1043
+ isLoadingError: false;
1044
+ isRefetchError: true;
1045
+ isSuccess: false;
1046
+ isPlaceholderData: false;
1047
+ status: "error";
1048
+ dataUpdatedAt: number;
1049
+ errorUpdatedAt: number;
1050
+ failureCount: number;
1051
+ failureReason: Error | null;
1052
+ errorUpdateCount: number;
1053
+ isFetched: boolean;
1054
+ isFetchedAfterMount: boolean;
1055
+ isFetching: boolean;
1056
+ isInitialLoading: boolean;
1057
+ isPaused: boolean;
1058
+ isRefetching: boolean;
1059
+ isStale: boolean;
1060
+ isEnabled: boolean;
1061
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<TransactionStatusResponse, Error>>;
1062
+ fetchStatus: _tanstack_react_query.FetchStatus;
1063
+ promise: Promise<TransactionStatusResponse>;
1064
+ } | {
1065
+ fetchTransactionStatus: (newInput: FetchTransactionStatusInput) => Promise<TransactionStatusResponse>;
1066
+ data: TransactionStatusResponse;
1067
+ error: null;
1068
+ isError: false;
1069
+ isPending: false;
1070
+ isLoading: false;
1071
+ isLoadingError: false;
1072
+ isRefetchError: false;
1073
+ isSuccess: true;
1074
+ isPlaceholderData: false;
1075
+ status: "success";
1076
+ dataUpdatedAt: number;
1077
+ errorUpdatedAt: number;
1078
+ failureCount: number;
1079
+ failureReason: Error | null;
1080
+ errorUpdateCount: number;
1081
+ isFetched: boolean;
1082
+ isFetchedAfterMount: boolean;
1083
+ isFetching: boolean;
1084
+ isInitialLoading: boolean;
1085
+ isPaused: boolean;
1086
+ isRefetching: boolean;
1087
+ isStale: boolean;
1088
+ isEnabled: boolean;
1089
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<TransactionStatusResponse, Error>>;
1090
+ fetchStatus: _tanstack_react_query.FetchStatus;
1091
+ promise: Promise<TransactionStatusResponse>;
1092
+ } | {
1093
+ fetchTransactionStatus: (newInput: FetchTransactionStatusInput) => Promise<TransactionStatusResponse>;
1094
+ data: undefined;
1095
+ error: Error;
1096
+ isError: true;
1097
+ isPending: false;
1098
+ isLoading: false;
1099
+ isLoadingError: true;
1100
+ isRefetchError: false;
1101
+ isSuccess: false;
1102
+ isPlaceholderData: false;
1103
+ status: "error";
1104
+ dataUpdatedAt: number;
1105
+ errorUpdatedAt: number;
1106
+ failureCount: number;
1107
+ failureReason: Error | null;
1108
+ errorUpdateCount: number;
1109
+ isFetched: boolean;
1110
+ isFetchedAfterMount: boolean;
1111
+ isFetching: boolean;
1112
+ isInitialLoading: boolean;
1113
+ isPaused: boolean;
1114
+ isRefetching: boolean;
1115
+ isStale: boolean;
1116
+ isEnabled: boolean;
1117
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<TransactionStatusResponse, Error>>;
1118
+ fetchStatus: _tanstack_react_query.FetchStatus;
1119
+ promise: Promise<TransactionStatusResponse>;
1120
+ } | {
1121
+ fetchTransactionStatus: (newInput: FetchTransactionStatusInput) => Promise<TransactionStatusResponse>;
1122
+ data: undefined;
1123
+ error: null;
1124
+ isError: false;
1125
+ isPending: true;
1126
+ isLoading: true;
1127
+ isLoadingError: false;
1128
+ isRefetchError: false;
1129
+ isSuccess: false;
1130
+ isPlaceholderData: false;
1131
+ status: "pending";
1132
+ dataUpdatedAt: number;
1133
+ errorUpdatedAt: number;
1134
+ failureCount: number;
1135
+ failureReason: Error | null;
1136
+ errorUpdateCount: number;
1137
+ isFetched: boolean;
1138
+ isFetchedAfterMount: boolean;
1139
+ isFetching: boolean;
1140
+ isInitialLoading: boolean;
1141
+ isPaused: boolean;
1142
+ isRefetching: boolean;
1143
+ isStale: boolean;
1144
+ isEnabled: boolean;
1145
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<TransactionStatusResponse, Error>>;
1146
+ fetchStatus: _tanstack_react_query.FetchStatus;
1147
+ promise: Promise<TransactionStatusResponse>;
1148
+ } | {
1149
+ fetchTransactionStatus: (newInput: FetchTransactionStatusInput) => Promise<TransactionStatusResponse>;
1150
+ data: undefined;
1151
+ error: null;
1152
+ isError: false;
1153
+ isPending: true;
1154
+ isLoadingError: false;
1155
+ isRefetchError: false;
1156
+ isSuccess: false;
1157
+ isPlaceholderData: false;
1158
+ status: "pending";
1159
+ dataUpdatedAt: number;
1160
+ errorUpdatedAt: number;
1161
+ failureCount: number;
1162
+ failureReason: Error | null;
1163
+ errorUpdateCount: number;
1164
+ isFetched: boolean;
1165
+ isFetchedAfterMount: boolean;
1166
+ isFetching: boolean;
1167
+ isLoading: boolean;
1168
+ isInitialLoading: boolean;
1169
+ isPaused: boolean;
1170
+ isRefetching: boolean;
1171
+ isStale: boolean;
1172
+ isEnabled: boolean;
1173
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<TransactionStatusResponse, Error>>;
1174
+ fetchStatus: _tanstack_react_query.FetchStatus;
1175
+ promise: Promise<TransactionStatusResponse>;
1176
+ } | {
1177
+ fetchTransactionStatus: (newInput: FetchTransactionStatusInput) => Promise<TransactionStatusResponse>;
1178
+ data: TransactionStatusResponse;
1179
+ isError: false;
1180
+ error: null;
1181
+ isPending: false;
1182
+ isLoading: false;
1183
+ isLoadingError: false;
1184
+ isRefetchError: false;
1185
+ isSuccess: true;
1186
+ isPlaceholderData: true;
1187
+ status: "success";
1188
+ dataUpdatedAt: number;
1189
+ errorUpdatedAt: number;
1190
+ failureCount: number;
1191
+ failureReason: Error | null;
1192
+ errorUpdateCount: number;
1193
+ isFetched: boolean;
1194
+ isFetchedAfterMount: boolean;
1195
+ isFetching: boolean;
1196
+ isInitialLoading: boolean;
1197
+ isPaused: boolean;
1198
+ isRefetching: boolean;
1199
+ isStale: boolean;
1200
+ isEnabled: boolean;
1201
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<TransactionStatusResponse, Error>>;
1202
+ fetchStatus: _tanstack_react_query.FetchStatus;
1203
+ promise: Promise<TransactionStatusResponse>;
1204
+ };
1205
+
1206
+ type SyncOnChainInput = SyncOnChainTransfersParams & {
1207
+ bearerToken: string;
1208
+ };
1209
+ /**
1210
+ * Hook for syncing on-chain transfers from Voyager into the DB.
1211
+ *
1212
+ * Discovers transactions not made through the SDK (e.g., external USDC receives
1213
+ * from Argent X or other wallets). After sync, useGetTransactionList returns
1214
+ * the newly discovered transactions automatically.
1215
+ *
1216
+ * @example
1217
+ * ```tsx
1218
+ * const { syncTransfers, data, isLoading } = useSyncOnChainTransfers();
1219
+ *
1220
+ * // Sync on-chain transfers for a wallet
1221
+ * const result = await syncTransfersAsync({
1222
+ * walletAddress: wallet.publicKey,
1223
+ * bearerToken: await getToken(),
1224
+ * });
1225
+ * console.log(`Synced ${result.synced} new transfers`);
1226
+ * ```
1227
+ */
1228
+ declare function useSyncOnChainTransfers(): {
1229
+ syncTransfers: (input: SyncOnChainInput) => void;
1230
+ syncTransfersAsync: (input: SyncOnChainInput) => Promise<SyncOnChainTransfersResponse>;
1231
+ data: SyncOnChainTransfersResponse | undefined;
1232
+ isLoading: boolean;
1233
+ isError: boolean;
1234
+ error: Error | null;
1235
+ isSuccess: boolean;
1236
+ reset: () => void;
1237
+ };
1238
+
1239
+ type PurchaseSkuInput = {
1240
+ params: CreateSkuPurchaseParams;
1241
+ bearerToken: string;
1242
+ };
1243
+ /**
1244
+ * Hook for purchasing SKUs
1245
+ */
1246
+ declare function usePurchaseSku(): {
1247
+ purchaseSku: (input: PurchaseSkuInput) => void;
1248
+ purchaseSkuAsync: (input: PurchaseSkuInput) => Promise<Transaction>;
1249
+ data: Transaction | undefined;
1250
+ isLoading: boolean;
1251
+ isError: boolean;
1252
+ error: Error | null;
1253
+ isSuccess: boolean;
1254
+ reset: () => void;
1255
+ };
1256
+
1257
+ type GetSkuPurchaseInput = {
1258
+ id: string;
1259
+ getBearerToken?: () => Promise<string | null | undefined>;
1260
+ queryOptions?: Omit<UseQueryOptions<Transaction, Error>, "queryKey" | "queryFn">;
1261
+ };
1262
+ declare function useGetSkuPurchase(input?: GetSkuPurchaseInput): {
1263
+ fetchSkuPurchase: (newInput: GetSkuPurchaseInput) => Promise<Transaction>;
1264
+ data: Transaction;
1265
+ error: Error;
1266
+ isError: true;
1267
+ isPending: false;
1268
+ isLoading: false;
1269
+ isLoadingError: false;
1270
+ isRefetchError: true;
1271
+ isSuccess: false;
1272
+ isPlaceholderData: false;
1273
+ status: "error";
1274
+ dataUpdatedAt: number;
1275
+ errorUpdatedAt: number;
1276
+ failureCount: number;
1277
+ failureReason: Error | null;
1278
+ errorUpdateCount: number;
1279
+ isFetched: boolean;
1280
+ isFetchedAfterMount: boolean;
1281
+ isFetching: boolean;
1282
+ isInitialLoading: boolean;
1283
+ isPaused: boolean;
1284
+ isRefetching: boolean;
1285
+ isStale: boolean;
1286
+ isEnabled: boolean;
1287
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Transaction, Error>>;
1288
+ fetchStatus: _tanstack_react_query.FetchStatus;
1289
+ promise: Promise<Transaction>;
1290
+ } | {
1291
+ fetchSkuPurchase: (newInput: GetSkuPurchaseInput) => Promise<Transaction>;
1292
+ data: Transaction;
1293
+ error: null;
1294
+ isError: false;
1295
+ isPending: false;
1296
+ isLoading: false;
1297
+ isLoadingError: false;
1298
+ isRefetchError: false;
1299
+ isSuccess: true;
1300
+ isPlaceholderData: false;
1301
+ status: "success";
1302
+ dataUpdatedAt: number;
1303
+ errorUpdatedAt: number;
1304
+ failureCount: number;
1305
+ failureReason: Error | null;
1306
+ errorUpdateCount: number;
1307
+ isFetched: boolean;
1308
+ isFetchedAfterMount: boolean;
1309
+ isFetching: boolean;
1310
+ isInitialLoading: boolean;
1311
+ isPaused: boolean;
1312
+ isRefetching: boolean;
1313
+ isStale: boolean;
1314
+ isEnabled: boolean;
1315
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Transaction, Error>>;
1316
+ fetchStatus: _tanstack_react_query.FetchStatus;
1317
+ promise: Promise<Transaction>;
1318
+ } | {
1319
+ fetchSkuPurchase: (newInput: GetSkuPurchaseInput) => Promise<Transaction>;
1320
+ data: undefined;
1321
+ error: Error;
1322
+ isError: true;
1323
+ isPending: false;
1324
+ isLoading: false;
1325
+ isLoadingError: true;
1326
+ isRefetchError: false;
1327
+ isSuccess: false;
1328
+ isPlaceholderData: false;
1329
+ status: "error";
1330
+ dataUpdatedAt: number;
1331
+ errorUpdatedAt: number;
1332
+ failureCount: number;
1333
+ failureReason: Error | null;
1334
+ errorUpdateCount: number;
1335
+ isFetched: boolean;
1336
+ isFetchedAfterMount: boolean;
1337
+ isFetching: boolean;
1338
+ isInitialLoading: boolean;
1339
+ isPaused: boolean;
1340
+ isRefetching: boolean;
1341
+ isStale: boolean;
1342
+ isEnabled: boolean;
1343
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Transaction, Error>>;
1344
+ fetchStatus: _tanstack_react_query.FetchStatus;
1345
+ promise: Promise<Transaction>;
1346
+ } | {
1347
+ fetchSkuPurchase: (newInput: GetSkuPurchaseInput) => Promise<Transaction>;
1348
+ data: undefined;
1349
+ error: null;
1350
+ isError: false;
1351
+ isPending: true;
1352
+ isLoading: true;
1353
+ isLoadingError: false;
1354
+ isRefetchError: false;
1355
+ isSuccess: false;
1356
+ isPlaceholderData: false;
1357
+ status: "pending";
1358
+ dataUpdatedAt: number;
1359
+ errorUpdatedAt: number;
1360
+ failureCount: number;
1361
+ failureReason: Error | null;
1362
+ errorUpdateCount: number;
1363
+ isFetched: boolean;
1364
+ isFetchedAfterMount: boolean;
1365
+ isFetching: boolean;
1366
+ isInitialLoading: boolean;
1367
+ isPaused: boolean;
1368
+ isRefetching: boolean;
1369
+ isStale: boolean;
1370
+ isEnabled: boolean;
1371
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Transaction, Error>>;
1372
+ fetchStatus: _tanstack_react_query.FetchStatus;
1373
+ promise: Promise<Transaction>;
1374
+ } | {
1375
+ fetchSkuPurchase: (newInput: GetSkuPurchaseInput) => Promise<Transaction>;
1376
+ data: undefined;
1377
+ error: null;
1378
+ isError: false;
1379
+ isPending: true;
1380
+ isLoadingError: false;
1381
+ isRefetchError: false;
1382
+ isSuccess: false;
1383
+ isPlaceholderData: false;
1384
+ status: "pending";
1385
+ dataUpdatedAt: number;
1386
+ errorUpdatedAt: number;
1387
+ failureCount: number;
1388
+ failureReason: Error | null;
1389
+ errorUpdateCount: number;
1390
+ isFetched: boolean;
1391
+ isFetchedAfterMount: boolean;
1392
+ isFetching: boolean;
1393
+ isLoading: boolean;
1394
+ isInitialLoading: boolean;
1395
+ isPaused: boolean;
1396
+ isRefetching: boolean;
1397
+ isStale: boolean;
1398
+ isEnabled: boolean;
1399
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Transaction, Error>>;
1400
+ fetchStatus: _tanstack_react_query.FetchStatus;
1401
+ promise: Promise<Transaction>;
1402
+ } | {
1403
+ fetchSkuPurchase: (newInput: GetSkuPurchaseInput) => Promise<Transaction>;
1404
+ data: Transaction;
1405
+ isError: false;
1406
+ error: null;
1407
+ isPending: false;
1408
+ isLoading: false;
1409
+ isLoadingError: false;
1410
+ isRefetchError: false;
1411
+ isSuccess: true;
1412
+ isPlaceholderData: true;
1413
+ status: "success";
1414
+ dataUpdatedAt: number;
1415
+ errorUpdatedAt: number;
1416
+ failureCount: number;
1417
+ failureReason: Error | null;
1418
+ errorUpdateCount: number;
1419
+ isFetched: boolean;
1420
+ isFetchedAfterMount: boolean;
1421
+ isFetching: boolean;
1422
+ isInitialLoading: boolean;
1423
+ isPaused: boolean;
1424
+ isRefetching: boolean;
1425
+ isStale: boolean;
1426
+ isEnabled: boolean;
1427
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Transaction, Error>>;
1428
+ fetchStatus: _tanstack_react_query.FetchStatus;
1429
+ promise: Promise<Transaction>;
1430
+ };
1431
+
1432
+ type SkuListInput = {
1433
+ query: GetSkuListQuery;
1434
+ getBearerToken?: () => Promise<string | null | undefined>;
1435
+ queryOptions?: Omit<UseQueryOptions<PaginatedResponse<Sku>, Error>, "queryKey" | "queryFn">;
1436
+ };
1437
+ declare function useGetSkuList(input?: SkuListInput): {
1438
+ fetchSkuList: (newInput: SkuListInput) => Promise<PaginatedResponse<Sku>>;
1439
+ data: PaginatedResponse<Sku>;
1440
+ error: Error;
1441
+ isError: true;
1442
+ isPending: false;
1443
+ isLoading: false;
1444
+ isLoadingError: false;
1445
+ isRefetchError: true;
1446
+ isSuccess: false;
1447
+ isPlaceholderData: false;
1448
+ status: "error";
1449
+ dataUpdatedAt: number;
1450
+ errorUpdatedAt: number;
1451
+ failureCount: number;
1452
+ failureReason: Error | null;
1453
+ errorUpdateCount: number;
1454
+ isFetched: boolean;
1455
+ isFetchedAfterMount: boolean;
1456
+ isFetching: boolean;
1457
+ isInitialLoading: boolean;
1458
+ isPaused: boolean;
1459
+ isRefetching: boolean;
1460
+ isStale: boolean;
1461
+ isEnabled: boolean;
1462
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<PaginatedResponse<Sku>, Error>>;
1463
+ fetchStatus: _tanstack_react_query.FetchStatus;
1464
+ promise: Promise<PaginatedResponse<Sku>>;
1465
+ } | {
1466
+ fetchSkuList: (newInput: SkuListInput) => Promise<PaginatedResponse<Sku>>;
1467
+ data: PaginatedResponse<Sku>;
1468
+ error: null;
1469
+ isError: false;
1470
+ isPending: false;
1471
+ isLoading: false;
1472
+ isLoadingError: false;
1473
+ isRefetchError: false;
1474
+ isSuccess: true;
1475
+ isPlaceholderData: false;
1476
+ status: "success";
1477
+ dataUpdatedAt: number;
1478
+ errorUpdatedAt: number;
1479
+ failureCount: number;
1480
+ failureReason: Error | null;
1481
+ errorUpdateCount: number;
1482
+ isFetched: boolean;
1483
+ isFetchedAfterMount: boolean;
1484
+ isFetching: boolean;
1485
+ isInitialLoading: boolean;
1486
+ isPaused: boolean;
1487
+ isRefetching: boolean;
1488
+ isStale: boolean;
1489
+ isEnabled: boolean;
1490
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<PaginatedResponse<Sku>, Error>>;
1491
+ fetchStatus: _tanstack_react_query.FetchStatus;
1492
+ promise: Promise<PaginatedResponse<Sku>>;
1493
+ } | {
1494
+ fetchSkuList: (newInput: SkuListInput) => Promise<PaginatedResponse<Sku>>;
1495
+ data: undefined;
1496
+ error: Error;
1497
+ isError: true;
1498
+ isPending: false;
1499
+ isLoading: false;
1500
+ isLoadingError: true;
1501
+ isRefetchError: false;
1502
+ isSuccess: false;
1503
+ isPlaceholderData: false;
1504
+ status: "error";
1505
+ dataUpdatedAt: number;
1506
+ errorUpdatedAt: number;
1507
+ failureCount: number;
1508
+ failureReason: Error | null;
1509
+ errorUpdateCount: number;
1510
+ isFetched: boolean;
1511
+ isFetchedAfterMount: boolean;
1512
+ isFetching: boolean;
1513
+ isInitialLoading: boolean;
1514
+ isPaused: boolean;
1515
+ isRefetching: boolean;
1516
+ isStale: boolean;
1517
+ isEnabled: boolean;
1518
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<PaginatedResponse<Sku>, Error>>;
1519
+ fetchStatus: _tanstack_react_query.FetchStatus;
1520
+ promise: Promise<PaginatedResponse<Sku>>;
1521
+ } | {
1522
+ fetchSkuList: (newInput: SkuListInput) => Promise<PaginatedResponse<Sku>>;
1523
+ data: undefined;
1524
+ error: null;
1525
+ isError: false;
1526
+ isPending: true;
1527
+ isLoading: true;
1528
+ isLoadingError: false;
1529
+ isRefetchError: false;
1530
+ isSuccess: false;
1531
+ isPlaceholderData: false;
1532
+ status: "pending";
1533
+ dataUpdatedAt: number;
1534
+ errorUpdatedAt: number;
1535
+ failureCount: number;
1536
+ failureReason: Error | null;
1537
+ errorUpdateCount: number;
1538
+ isFetched: boolean;
1539
+ isFetchedAfterMount: boolean;
1540
+ isFetching: boolean;
1541
+ isInitialLoading: boolean;
1542
+ isPaused: boolean;
1543
+ isRefetching: boolean;
1544
+ isStale: boolean;
1545
+ isEnabled: boolean;
1546
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<PaginatedResponse<Sku>, Error>>;
1547
+ fetchStatus: _tanstack_react_query.FetchStatus;
1548
+ promise: Promise<PaginatedResponse<Sku>>;
1549
+ } | {
1550
+ fetchSkuList: (newInput: SkuListInput) => Promise<PaginatedResponse<Sku>>;
1551
+ data: undefined;
1552
+ error: null;
1553
+ isError: false;
1554
+ isPending: true;
1555
+ isLoadingError: false;
1556
+ isRefetchError: false;
1557
+ isSuccess: false;
1558
+ isPlaceholderData: false;
1559
+ status: "pending";
1560
+ dataUpdatedAt: number;
1561
+ errorUpdatedAt: number;
1562
+ failureCount: number;
1563
+ failureReason: Error | null;
1564
+ errorUpdateCount: number;
1565
+ isFetched: boolean;
1566
+ isFetchedAfterMount: boolean;
1567
+ isFetching: boolean;
1568
+ isLoading: boolean;
1569
+ isInitialLoading: boolean;
1570
+ isPaused: boolean;
1571
+ isRefetching: boolean;
1572
+ isStale: boolean;
1573
+ isEnabled: boolean;
1574
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<PaginatedResponse<Sku>, Error>>;
1575
+ fetchStatus: _tanstack_react_query.FetchStatus;
1576
+ promise: Promise<PaginatedResponse<Sku>>;
1577
+ } | {
1578
+ fetchSkuList: (newInput: SkuListInput) => Promise<PaginatedResponse<Sku>>;
1579
+ data: PaginatedResponse<Sku>;
1580
+ isError: false;
1581
+ error: null;
1582
+ isPending: false;
1583
+ isLoading: false;
1584
+ isLoadingError: false;
1585
+ isRefetchError: false;
1586
+ isSuccess: true;
1587
+ isPlaceholderData: true;
1588
+ status: "success";
1589
+ dataUpdatedAt: number;
1590
+ errorUpdatedAt: number;
1591
+ failureCount: number;
1592
+ failureReason: Error | null;
1593
+ errorUpdateCount: number;
1594
+ isFetched: boolean;
1595
+ isFetchedAfterMount: boolean;
1596
+ isFetching: boolean;
1597
+ isInitialLoading: boolean;
1598
+ isPaused: boolean;
1599
+ isRefetching: boolean;
1600
+ isStale: boolean;
1601
+ isEnabled: boolean;
1602
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<PaginatedResponse<Sku>, Error>>;
1603
+ fetchStatus: _tanstack_react_query.FetchStatus;
1604
+ promise: Promise<PaginatedResponse<Sku>>;
1605
+ };
1606
+
1607
+ type GetSkuInput = {
1608
+ id: string;
1609
+ getBearerToken?: () => Promise<string | null | undefined>;
1610
+ queryOptions?: Omit<UseQueryOptions<Sku, Error>, "queryKey" | "queryFn">;
1611
+ };
1612
+ declare function useGetSku(input?: GetSkuInput): {
1613
+ fetchSku: (input: GetSkuInput) => Promise<Sku>;
1614
+ data: Sku;
1615
+ error: Error;
1616
+ isError: true;
1617
+ isPending: false;
1618
+ isLoading: false;
1619
+ isLoadingError: false;
1620
+ isRefetchError: true;
1621
+ isSuccess: false;
1622
+ isPlaceholderData: false;
1623
+ status: "error";
1624
+ dataUpdatedAt: number;
1625
+ errorUpdatedAt: number;
1626
+ failureCount: number;
1627
+ failureReason: Error | null;
1628
+ errorUpdateCount: number;
1629
+ isFetched: boolean;
1630
+ isFetchedAfterMount: boolean;
1631
+ isFetching: boolean;
1632
+ isInitialLoading: boolean;
1633
+ isPaused: boolean;
1634
+ isRefetching: boolean;
1635
+ isStale: boolean;
1636
+ isEnabled: boolean;
1637
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Sku, Error>>;
1638
+ fetchStatus: _tanstack_react_query.FetchStatus;
1639
+ promise: Promise<Sku>;
1640
+ } | {
1641
+ fetchSku: (input: GetSkuInput) => Promise<Sku>;
1642
+ data: Sku;
1643
+ error: null;
1644
+ isError: false;
1645
+ isPending: false;
1646
+ isLoading: false;
1647
+ isLoadingError: false;
1648
+ isRefetchError: false;
1649
+ isSuccess: true;
1650
+ isPlaceholderData: false;
1651
+ status: "success";
1652
+ dataUpdatedAt: number;
1653
+ errorUpdatedAt: number;
1654
+ failureCount: number;
1655
+ failureReason: Error | null;
1656
+ errorUpdateCount: number;
1657
+ isFetched: boolean;
1658
+ isFetchedAfterMount: boolean;
1659
+ isFetching: boolean;
1660
+ isInitialLoading: boolean;
1661
+ isPaused: boolean;
1662
+ isRefetching: boolean;
1663
+ isStale: boolean;
1664
+ isEnabled: boolean;
1665
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Sku, Error>>;
1666
+ fetchStatus: _tanstack_react_query.FetchStatus;
1667
+ promise: Promise<Sku>;
1668
+ } | {
1669
+ fetchSku: (input: GetSkuInput) => Promise<Sku>;
1670
+ data: undefined;
1671
+ error: Error;
1672
+ isError: true;
1673
+ isPending: false;
1674
+ isLoading: false;
1675
+ isLoadingError: true;
1676
+ isRefetchError: false;
1677
+ isSuccess: false;
1678
+ isPlaceholderData: false;
1679
+ status: "error";
1680
+ dataUpdatedAt: number;
1681
+ errorUpdatedAt: number;
1682
+ failureCount: number;
1683
+ failureReason: Error | null;
1684
+ errorUpdateCount: number;
1685
+ isFetched: boolean;
1686
+ isFetchedAfterMount: boolean;
1687
+ isFetching: boolean;
1688
+ isInitialLoading: boolean;
1689
+ isPaused: boolean;
1690
+ isRefetching: boolean;
1691
+ isStale: boolean;
1692
+ isEnabled: boolean;
1693
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Sku, Error>>;
1694
+ fetchStatus: _tanstack_react_query.FetchStatus;
1695
+ promise: Promise<Sku>;
1696
+ } | {
1697
+ fetchSku: (input: GetSkuInput) => Promise<Sku>;
1698
+ data: undefined;
1699
+ error: null;
1700
+ isError: false;
1701
+ isPending: true;
1702
+ isLoading: true;
1703
+ isLoadingError: false;
1704
+ isRefetchError: false;
1705
+ isSuccess: false;
1706
+ isPlaceholderData: false;
1707
+ status: "pending";
1708
+ dataUpdatedAt: number;
1709
+ errorUpdatedAt: number;
1710
+ failureCount: number;
1711
+ failureReason: Error | null;
1712
+ errorUpdateCount: number;
1713
+ isFetched: boolean;
1714
+ isFetchedAfterMount: boolean;
1715
+ isFetching: boolean;
1716
+ isInitialLoading: boolean;
1717
+ isPaused: boolean;
1718
+ isRefetching: boolean;
1719
+ isStale: boolean;
1720
+ isEnabled: boolean;
1721
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Sku, Error>>;
1722
+ fetchStatus: _tanstack_react_query.FetchStatus;
1723
+ promise: Promise<Sku>;
1724
+ } | {
1725
+ fetchSku: (input: GetSkuInput) => Promise<Sku>;
1726
+ data: undefined;
1727
+ error: null;
1728
+ isError: false;
1729
+ isPending: true;
1730
+ isLoadingError: false;
1731
+ isRefetchError: false;
1732
+ isSuccess: false;
1733
+ isPlaceholderData: false;
1734
+ status: "pending";
1735
+ dataUpdatedAt: number;
1736
+ errorUpdatedAt: number;
1737
+ failureCount: number;
1738
+ failureReason: Error | null;
1739
+ errorUpdateCount: number;
1740
+ isFetched: boolean;
1741
+ isFetchedAfterMount: boolean;
1742
+ isFetching: boolean;
1743
+ isLoading: boolean;
1744
+ isInitialLoading: boolean;
1745
+ isPaused: boolean;
1746
+ isRefetching: boolean;
1747
+ isStale: boolean;
1748
+ isEnabled: boolean;
1749
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Sku, Error>>;
1750
+ fetchStatus: _tanstack_react_query.FetchStatus;
1751
+ promise: Promise<Sku>;
1752
+ } | {
1753
+ fetchSku: (input: GetSkuInput) => Promise<Sku>;
1754
+ data: Sku;
1755
+ isError: false;
1756
+ error: null;
1757
+ isPending: false;
1758
+ isLoading: false;
1759
+ isLoadingError: false;
1760
+ isRefetchError: false;
1761
+ isSuccess: true;
1762
+ isPlaceholderData: true;
1763
+ status: "success";
1764
+ dataUpdatedAt: number;
1765
+ errorUpdatedAt: number;
1766
+ failureCount: number;
1767
+ failureReason: Error | null;
1768
+ errorUpdateCount: number;
1769
+ isFetched: boolean;
1770
+ isFetchedAfterMount: boolean;
1771
+ isFetching: boolean;
1772
+ isInitialLoading: boolean;
1773
+ isPaused: boolean;
1774
+ isRefetching: boolean;
1775
+ isStale: boolean;
1776
+ isEnabled: boolean;
1777
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Sku, Error>>;
1778
+ fetchStatus: _tanstack_react_query.FetchStatus;
1779
+ promise: Promise<Sku>;
1780
+ };
1781
+
1782
+ type CallAnyContractInput = {
1783
+ params: CallAnyContractParams;
1784
+ bearerToken: string;
1785
+ };
1786
+ /**
1787
+ * Hook for calling any contract method
1788
+ */
1789
+ declare function useCallAnyContract(): {
1790
+ callAnyContract: (params: CallAnyContractInput) => void;
1791
+ callAnyContractAsync: (params: CallAnyContractInput) => Promise<string>;
1792
+ data: string | undefined;
1793
+ isLoading: boolean;
1794
+ isError: boolean;
1795
+ error: Error | null;
1796
+ isSuccess: boolean;
1797
+ reset: () => void;
1798
+ };
1799
+
1800
+ /**
1801
+ * Sign SNIP-12 typed data and get the full signature span (felt strings) —
1802
+ * the shape a dApp's `wallet_signTypedData` expects. Wallet-type aware: SHHH
1803
+ * returns the V2_SNIP12 owner envelope, standard accounts return `[r, s]`.
1804
+ * Purely local (decrypt + sign) — no API call.
1805
+ */
1806
+ declare function useSignTypedData(): {
1807
+ signTypedData: (params: SignTypedDataParams) => void;
1808
+ signTypedDataAsync: (params: SignTypedDataParams) => Promise<string[]>;
1809
+ data: string[] | undefined;
1810
+ isLoading: boolean;
1811
+ isError: boolean;
1812
+ error: Error | null;
1813
+ isSuccess: boolean;
1814
+ reset: () => void;
1815
+ };
1816
+
1817
+ /**
1818
+ * An approval the host (walletv2, the hosted web-wallet, or a harness) must
1819
+ * resolve before the SWO performs a sensitive action. Returning `false`
1820
+ * surfaces a USER_REFUSED_OP error to the dApp. The host renders the UI;
1821
+ * the SWO core stays framework-agnostic.
1822
+ */
1823
+ type ChipiApprovalRequest = {
1824
+ type: "connect";
1825
+ } | {
1826
+ type: "execute";
1827
+ calls: Call$2[];
1828
+ } | {
1829
+ type: "signTypedData";
1830
+ typedData: TypedData;
1831
+ } | {
1832
+ /** dApp-proposed session policy shown at connect time (approve once). */
1833
+ type: "session";
1834
+ policy: ChipiSessionPolicy;
1835
+ };
1836
+ /**
1837
+ * A dApp-proposed session policy. Mirrors the SNIP-163 sessions component the
1838
+ * SHHH/CHIPI accounts enforce on-chain via the 4-felt session signature
1839
+ * `[session_pubkey, r, s, valid_until]`.
1840
+ */
1841
+ interface ChipiSessionPolicy {
1842
+ /** Allowed (contractAddress, entrypoint) pairs the session may call. */
1843
+ allowedCalls: Array<{
1844
+ contractAddress: string;
1845
+ entrypoint: string;
1846
+ }>;
1847
+ /** Unix seconds after which the session is invalid. */
1848
+ validUntil: number;
1849
+ /** Optional per-token spend caps, by token address. */
1850
+ spendCaps?: Array<{
1851
+ token: string;
1852
+ amount: string;
1853
+ }>;
1854
+ }
1855
+ /**
1856
+ * Everything the framework-agnostic SWO needs, supplied by the host layer
1857
+ * (`@chipi-stack/react`'s `useChipiWalletObject`, the hosted web-wallet, etc.).
1858
+ * Keeping these as injected functions is what lets the SWO live in `core`
1859
+ * (depends only on `types`/`starknet`) instead of hard-importing `backend`.
1860
+ */
1861
+ interface ChipiWindowObjectDeps {
1862
+ /** Stable wallet id — MUST be `"chipi"` so the injected key, get-starknet
1863
+ * discovery entry, and starknetkit preset all agree. */
1864
+ id?: string;
1865
+ name?: string;
1866
+ version?: string;
1867
+ icon?: string;
1868
+ /** Starknet chain id felt (e.g. SN_MAIN). */
1869
+ chainId: string;
1870
+ /** Resolve the connected account address(es); `[]` when locked/disconnected. */
1871
+ getAccounts: () => Promise<string[]>;
1872
+ /**
1873
+ * Execute the dApp's calls and return the tx hash. The host implements
1874
+ * session-first routing here: in-policy → 4-felt session sig (silent);
1875
+ * out-of-policy/sensitive → owner envelope (passkey prompt). Both gasless.
1876
+ */
1877
+ executeCalls: (calls: Call$2[]) => Promise<string>;
1878
+ /** Sign SNIP-12 typed data → signature felts (envelope-aware for SHHH). */
1879
+ signTypedData: (typedData: TypedData) => Promise<string[]>;
1880
+ /** Counterfactual deployment data for an undeployed account. */
1881
+ getDeploymentData: () => Promise<AccountDeploymentData>;
1882
+ /** Optional: establish a session from a dApp-proposed policy (approve once). */
1883
+ createSession?: (policy: ChipiSessionPolicy) => Promise<void>;
1884
+ /** Host approval gate. Defaults to auto-approve (harness) when omitted. */
1885
+ requestApproval?: (req: ChipiApprovalRequest) => Promise<boolean>;
1886
+ }
1887
+
1888
+ interface UseChipiWalletObjectConfig {
1889
+ /** The connected Chipi wallet (null when locked / not yet created). */
1890
+ wallet: WalletData | null | undefined;
1891
+ /** Resolve the paymaster bearer token for execution. */
1892
+ getBearerToken: () => Promise<string>;
1893
+ /** Resolve the encryptKey (PIN / passkey-derived). Owner path may prompt;
1894
+ * the host is responsible for any caching that keeps the session path silent. */
1895
+ getEncryptKey: () => Promise<string>;
1896
+ /** Active session (host-managed) — enables session-first routing. */
1897
+ session?: SessionKeyData | null;
1898
+ /** The policy that `session` was registered with — used to decide, client
1899
+ * side, whether a dApp's calls are in-policy (so we don't send a doomed tx). */
1900
+ sessionPolicy?: ChipiSessionPolicy | null;
1901
+ /** Chain id felt; defaults to SN_MAIN. */
1902
+ chainId?: string;
1903
+ /** Host approval gate (connect / execute / signTypedData / session). */
1904
+ requestApproval?: (req: ChipiApprovalRequest) => Promise<boolean>;
1905
+ }
1906
+ /**
1907
+ * Compose the deps for a Chipi `StarknetWindowObject` from the existing SDK
1908
+ * hooks, with **session-first execution routing**:
1909
+ * - an in-policy, unexpired session → `useExecuteWithSession` (4-felt session
1910
+ * sig, no per-tx passkey),
1911
+ * - otherwise the owner path → `useCallAnyContract` (passkey).
1912
+ * Both gasless via the paymaster. Pass `deps` to `createChipiWindowObject` /
1913
+ * `injectChipiWallet`. `createSession(policy)` establishes a session on-chain
1914
+ * from a dApp-proposed policy (the "approve once" flow); the host stores the
1915
+ * returned SessionKeyData and feeds it back via `config.session`.
1916
+ */
1917
+ declare function useChipiWalletObject(config: UseChipiWalletObjectConfig): {
1918
+ deps: ChipiWindowObjectDeps;
1919
+ createSession: (policy: ChipiSessionPolicy) => Promise<SessionKeyData>;
1920
+ };
1921
+
1922
+ type RecordSendTransactionInput = {
1923
+ params: RecordSendTransactionParams;
1924
+ bearerToken: string;
1925
+ };
1926
+ declare function useRecordSendTransaction(): {
1927
+ recordSendTransaction: (input: RecordSendTransactionInput) => void;
1928
+ recordSendTransactionAsync: (input: RecordSendTransactionInput) => Promise<Transaction>;
1929
+ data: Transaction | undefined;
1930
+ isLoading: boolean;
1931
+ isError: boolean;
1932
+ error: Error | null;
1933
+ isSuccess: boolean;
1934
+ reset: () => void;
1935
+ };
1936
+
1937
+ type GetTokenBalanceInput = {
1938
+ params?: GetTokenBalanceParams;
1939
+ getBearerToken?: () => Promise<string | null | undefined>;
1940
+ queryOptions?: Omit<UseQueryOptions<GetTokenBalanceResponse, Error>, "queryKey" | "queryFn">;
1941
+ };
1942
+ declare function useGetTokenBalance(input?: GetTokenBalanceInput): {
1943
+ fetchTokenBalance: (newInput: GetTokenBalanceInput) => Promise<GetTokenBalanceResponse>;
1944
+ data: GetTokenBalanceResponse;
1945
+ error: Error;
1946
+ isError: true;
1947
+ isPending: false;
1948
+ isLoading: false;
1949
+ isLoadingError: false;
1950
+ isRefetchError: true;
1951
+ isSuccess: false;
1952
+ isPlaceholderData: false;
1953
+ status: "error";
1954
+ dataUpdatedAt: number;
1955
+ errorUpdatedAt: number;
1956
+ failureCount: number;
1957
+ failureReason: Error | null;
1958
+ errorUpdateCount: number;
1959
+ isFetched: boolean;
1960
+ isFetchedAfterMount: boolean;
1961
+ isFetching: boolean;
1962
+ isInitialLoading: boolean;
1963
+ isPaused: boolean;
1964
+ isRefetching: boolean;
1965
+ isStale: boolean;
1966
+ isEnabled: boolean;
1967
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<GetTokenBalanceResponse, Error>>;
1968
+ fetchStatus: _tanstack_react_query.FetchStatus;
1969
+ promise: Promise<GetTokenBalanceResponse>;
1970
+ } | {
1971
+ fetchTokenBalance: (newInput: GetTokenBalanceInput) => Promise<GetTokenBalanceResponse>;
1972
+ data: GetTokenBalanceResponse;
1973
+ error: null;
1974
+ isError: false;
1975
+ isPending: false;
1976
+ isLoading: false;
1977
+ isLoadingError: false;
1978
+ isRefetchError: false;
1979
+ isSuccess: true;
1980
+ isPlaceholderData: false;
1981
+ status: "success";
1982
+ dataUpdatedAt: number;
1983
+ errorUpdatedAt: number;
1984
+ failureCount: number;
1985
+ failureReason: Error | null;
1986
+ errorUpdateCount: number;
1987
+ isFetched: boolean;
1988
+ isFetchedAfterMount: boolean;
1989
+ isFetching: boolean;
1990
+ isInitialLoading: boolean;
1991
+ isPaused: boolean;
1992
+ isRefetching: boolean;
1993
+ isStale: boolean;
1994
+ isEnabled: boolean;
1995
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<GetTokenBalanceResponse, Error>>;
1996
+ fetchStatus: _tanstack_react_query.FetchStatus;
1997
+ promise: Promise<GetTokenBalanceResponse>;
1998
+ } | {
1999
+ fetchTokenBalance: (newInput: GetTokenBalanceInput) => Promise<GetTokenBalanceResponse>;
2000
+ data: undefined;
2001
+ error: Error;
2002
+ isError: true;
2003
+ isPending: false;
2004
+ isLoading: false;
2005
+ isLoadingError: true;
2006
+ isRefetchError: false;
2007
+ isSuccess: false;
2008
+ isPlaceholderData: false;
2009
+ status: "error";
2010
+ dataUpdatedAt: number;
2011
+ errorUpdatedAt: number;
2012
+ failureCount: number;
2013
+ failureReason: Error | null;
2014
+ errorUpdateCount: number;
2015
+ isFetched: boolean;
2016
+ isFetchedAfterMount: boolean;
2017
+ isFetching: boolean;
2018
+ isInitialLoading: boolean;
2019
+ isPaused: boolean;
2020
+ isRefetching: boolean;
2021
+ isStale: boolean;
2022
+ isEnabled: boolean;
2023
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<GetTokenBalanceResponse, Error>>;
2024
+ fetchStatus: _tanstack_react_query.FetchStatus;
2025
+ promise: Promise<GetTokenBalanceResponse>;
2026
+ } | {
2027
+ fetchTokenBalance: (newInput: GetTokenBalanceInput) => Promise<GetTokenBalanceResponse>;
2028
+ data: undefined;
2029
+ error: null;
2030
+ isError: false;
2031
+ isPending: true;
2032
+ isLoading: true;
2033
+ isLoadingError: false;
2034
+ isRefetchError: false;
2035
+ isSuccess: false;
2036
+ isPlaceholderData: false;
2037
+ status: "pending";
2038
+ dataUpdatedAt: number;
2039
+ errorUpdatedAt: number;
2040
+ failureCount: number;
2041
+ failureReason: Error | null;
2042
+ errorUpdateCount: number;
2043
+ isFetched: boolean;
2044
+ isFetchedAfterMount: boolean;
2045
+ isFetching: boolean;
2046
+ isInitialLoading: boolean;
2047
+ isPaused: boolean;
2048
+ isRefetching: boolean;
2049
+ isStale: boolean;
2050
+ isEnabled: boolean;
2051
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<GetTokenBalanceResponse, Error>>;
2052
+ fetchStatus: _tanstack_react_query.FetchStatus;
2053
+ promise: Promise<GetTokenBalanceResponse>;
2054
+ } | {
2055
+ fetchTokenBalance: (newInput: GetTokenBalanceInput) => Promise<GetTokenBalanceResponse>;
2056
+ data: undefined;
2057
+ error: null;
2058
+ isError: false;
2059
+ isPending: true;
2060
+ isLoadingError: false;
2061
+ isRefetchError: false;
2062
+ isSuccess: false;
2063
+ isPlaceholderData: false;
2064
+ status: "pending";
2065
+ dataUpdatedAt: number;
2066
+ errorUpdatedAt: number;
2067
+ failureCount: number;
2068
+ failureReason: Error | null;
2069
+ errorUpdateCount: number;
2070
+ isFetched: boolean;
2071
+ isFetchedAfterMount: boolean;
2072
+ isFetching: boolean;
2073
+ isLoading: boolean;
2074
+ isInitialLoading: boolean;
2075
+ isPaused: boolean;
2076
+ isRefetching: boolean;
2077
+ isStale: boolean;
2078
+ isEnabled: boolean;
2079
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<GetTokenBalanceResponse, Error>>;
2080
+ fetchStatus: _tanstack_react_query.FetchStatus;
2081
+ promise: Promise<GetTokenBalanceResponse>;
2082
+ } | {
2083
+ fetchTokenBalance: (newInput: GetTokenBalanceInput) => Promise<GetTokenBalanceResponse>;
2084
+ data: GetTokenBalanceResponse;
2085
+ isError: false;
2086
+ error: null;
2087
+ isPending: false;
2088
+ isLoading: false;
2089
+ isLoadingError: false;
2090
+ isRefetchError: false;
2091
+ isSuccess: true;
2092
+ isPlaceholderData: true;
2093
+ status: "success";
2094
+ dataUpdatedAt: number;
2095
+ errorUpdatedAt: number;
2096
+ failureCount: number;
2097
+ failureReason: Error | null;
2098
+ errorUpdateCount: number;
2099
+ isFetched: boolean;
2100
+ isFetchedAfterMount: boolean;
2101
+ isFetching: boolean;
2102
+ isInitialLoading: boolean;
2103
+ isPaused: boolean;
2104
+ isRefetching: boolean;
2105
+ isStale: boolean;
2106
+ isEnabled: boolean;
2107
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<GetTokenBalanceResponse, Error>>;
2108
+ fetchStatus: _tanstack_react_query.FetchStatus;
2109
+ promise: Promise<GetTokenBalanceResponse>;
2110
+ };
2111
+
2112
+ /**
2113
+ * Hook for creating a session keypair locally.
2114
+ *
2115
+ * This generates session keys but does NOT register them on-chain.
2116
+ * The returned SessionKeyData should be stored by the developer externally
2117
+ * (e.g., in Clerk metadata, database, etc.) - the SDK does NOT persist this.
2118
+ *
2119
+ * After generating, call `useAddSessionKeyToContract` to register the session on-chain.
2120
+ *
2121
+ * @example
2122
+ * ```typescript
2123
+ * const { createSessionKey, data: session } = useCreateSessionKey();
2124
+ *
2125
+ * // Generate session keypair
2126
+ * createSessionKey({
2127
+ * encryptKey: userEncryptKey,
2128
+ * durationSeconds: 21600 // 6 hours (optional, default)
2129
+ * });
2130
+ *
2131
+ * // Store session externally after creation
2132
+ * if (session) {
2133
+ * await saveToClerk(session);
2134
+ * }
2135
+ * ```
2136
+ */
2137
+ declare function useCreateSessionKey(): {
2138
+ createSessionKey: (params: CreateSessionKeyParams) => void;
2139
+ createSessionKeyAsync: (params: CreateSessionKeyParams) => Promise<SessionKeyData>;
2140
+ data: SessionKeyData | undefined;
2141
+ isLoading: boolean;
2142
+ isError: boolean;
2143
+ error: Error | null;
2144
+ isSuccess: boolean;
2145
+ reset: () => void;
2146
+ };
2147
+
2148
+ type AddSessionKeyInput = {
2149
+ params: AddSessionKeyParams;
2150
+ bearerToken: string;
2151
+ };
2152
+ /**
2153
+ * Hook for registering a session key on the smart contract.
2154
+ *
2155
+ * This executes a sponsored transaction (using owner signature) to call
2156
+ * `add_or_update_session_key` on the CHIPI wallet contract.
2157
+ *
2158
+ * The session must be registered before it can be used for transactions.
2159
+ * Only works with CHIPI wallets.
2160
+ *
2161
+ * @example
2162
+ * ```typescript
2163
+ * const { addSessionKeyToContract, isLoading } = useAddSessionKeyToContract();
2164
+ *
2165
+ * // Register session on-chain
2166
+ * addSessionKeyToContract({
2167
+ * params: {
2168
+ * encryptKey: userEncryptKey,
2169
+ * wallet: userWallet,
2170
+ * sessionConfig: {
2171
+ * sessionPublicKey: session.publicKey,
2172
+ * validUntil: session.validUntil,
2173
+ * maxCalls: 1000,
2174
+ * allowedEntrypoints: [] // empty = all allowed
2175
+ * }
2176
+ * },
2177
+ * bearerToken
2178
+ * });
2179
+ * ```
2180
+ */
2181
+ declare function useAddSessionKeyToContract(): {
2182
+ addSessionKeyToContract: (input: AddSessionKeyInput) => void;
2183
+ addSessionKeyToContractAsync: (input: AddSessionKeyInput) => Promise<string>;
2184
+ data: string | undefined;
2185
+ isLoading: boolean;
2186
+ isError: boolean;
2187
+ error: Error | null;
2188
+ isSuccess: boolean;
2189
+ reset: () => void;
2190
+ };
2191
+
2192
+ type RevokeSessionKeyInput = {
2193
+ params: RevokeSessionKeyParams;
2194
+ bearerToken: string;
2195
+ };
2196
+ /**
2197
+ * Hook for revoking a session key from the smart contract.
2198
+ *
2199
+ * This executes a sponsored transaction (using owner signature) to call
2200
+ * `revoke_session_key` on the CHIPI wallet contract.
2201
+ *
2202
+ * After revocation, the session key can no longer be used for transactions.
2203
+ * Only works with CHIPI wallets.
2204
+ *
2205
+ * @example
2206
+ * ```typescript
2207
+ * const { revokeSessionKey, isLoading } = useRevokeSessionKey();
2208
+ *
2209
+ * // Revoke a session
2210
+ * revokeSessionKey({
2211
+ * params: {
2212
+ * encryptKey: userEncryptKey,
2213
+ * wallet: userWallet,
2214
+ * sessionPublicKey: session.publicKey
2215
+ * },
2216
+ * bearerToken
2217
+ * });
2218
+ * ```
2219
+ */
2220
+ declare function useRevokeSessionKey(): {
2221
+ revokeSessionKey: (input: RevokeSessionKeyInput) => void;
2222
+ revokeSessionKeyAsync: (input: RevokeSessionKeyInput) => Promise<string>;
2223
+ data: string | undefined;
2224
+ isLoading: boolean;
2225
+ isError: boolean;
2226
+ error: Error | null;
2227
+ isSuccess: boolean;
2228
+ reset: () => void;
2229
+ };
2230
+
2231
+ /**
2232
+ * Hook for querying session data from the smart contract.
2233
+ *
2234
+ * This is a read-only call that does not require signing or gas.
2235
+ * Returns the on-chain state of a session key including:
2236
+ * - Whether it's active
2237
+ * - When it expires
2238
+ * - Remaining calls
2239
+ * - Allowed entrypoints
2240
+ *
2241
+ * @example
2242
+ * ```typescript
2243
+ * const { data: sessionData, isLoading } = useGetSessionData({
2244
+ * walletAddress: userWallet.publicKey,
2245
+ * sessionPublicKey: session.publicKey
2246
+ * });
2247
+ *
2248
+ * if (sessionData?.isActive) {
2249
+ * console.log(`Session has ${sessionData.remainingCalls} calls remaining`);
2250
+ * }
2251
+ * ```
2252
+ */
2253
+ declare function useGetSessionData(params: GetSessionDataParams | null, options?: {
2254
+ enabled?: boolean;
2255
+ }): {
2256
+ data: SessionDataResponse | undefined;
2257
+ isLoading: boolean;
2258
+ isError: boolean;
2259
+ error: Error | null;
2260
+ isSuccess: boolean;
2261
+ refetch: UseQueryResult<SessionDataResponse, Error>["refetch"];
2262
+ };
2263
+
2264
+ type ExecuteWithSessionInput = {
2265
+ params: ExecuteWithSessionParams;
2266
+ bearerToken: string;
2267
+ };
2268
+ /**
2269
+ * Hook for executing a gasless transaction using a session key.
2270
+ *
2271
+ * This uses the 4-element session signature format instead of owner signature.
2272
+ * The session must be:
2273
+ * 1. Generated via `useCreateSessionKey`
2274
+ * 2. Registered on-chain via `useAddSessionKeyToContract`
2275
+ *
2276
+ * Only works with CHIPI wallets.
2277
+ *
2278
+ * @example
2279
+ * ```typescript
2280
+ * const { executeWithSession, isLoading } = useExecuteWithSession();
2281
+ *
2282
+ * // Execute a transfer using session key (no owner key needed)
2283
+ * executeWithSession({
2284
+ * params: {
2285
+ * encryptKey: userEncryptKey,
2286
+ * wallet: userWallet,
2287
+ * session: sessionKeyData,
2288
+ * calls: [{
2289
+ * contractAddress: USDC_ADDRESS,
2290
+ * entrypoint: 'transfer',
2291
+ * calldata: [recipient, amount, '0x0']
2292
+ * }]
2293
+ * },
2294
+ * bearerToken
2295
+ * });
2296
+ * ```
2297
+ */
2298
+ declare function useExecuteWithSession(): {
2299
+ executeWithSession: (input: ExecuteWithSessionInput) => void;
2300
+ executeWithSessionAsync: (input: ExecuteWithSessionInput) => Promise<string>;
2301
+ data: string | undefined;
2302
+ isLoading: boolean;
2303
+ isError: boolean;
2304
+ error: Error | null;
2305
+ isSuccess: boolean;
2306
+ reset: () => void;
2307
+ };
2308
+
2309
+ /**
2310
+ * Configuration for useX402Payment hook
2311
+ */
2312
+ interface UseX402PaymentConfig {
2313
+ /** Wallet data */
2314
+ wallet: WalletData | null | undefined;
2315
+ /** Encryption key for signing */
2316
+ encryptKey: string;
2317
+ /** Function to get the bearer token for API calls */
2318
+ getBearerToken?: () => Promise<string | null | undefined>;
2319
+ /** Static bearer token string (alternative to getBearerToken) */
2320
+ bearerToken?: string;
2321
+ /** Max amount per payment (USDC, human-readable e.g. "1.00") */
2322
+ maxPaymentAmount?: string;
2323
+ /** Alias for maxPaymentAmount */
2324
+ maxAmount?: string;
2325
+ /** Allowed recipient addresses (whitelist). Empty = allow all. */
2326
+ allowedRecipients?: string[];
2327
+ /** Active session for automatic payments (optional) */
2328
+ session?: SessionKeyData | null;
2329
+ /** Callback on successful payment */
2330
+ onPaymentComplete?: (txHash: string, amount: string) => void | Promise<void>;
2331
+ }
2332
+ /**
2333
+ * Last payment info returned by the hook
2334
+ */
2335
+ interface LastPaymentInfo {
2336
+ txHash: string | null;
2337
+ amount: string | null;
2338
+ timestamp: number;
2339
+ }
2340
+ /**
2341
+ * Return type for useX402Payment hook
2342
+ */
2343
+ interface UseX402PaymentReturn {
2344
+ /** Fetch wrapper that auto-handles 402 payments */
2345
+ x402Fetch: (url: string, init?: Record<string, any>) => Promise<Response>;
2346
+ /** Alias for x402Fetch */
2347
+ payFetch: (url: string, init?: Record<string, any>) => Promise<Response>;
2348
+ /** Manual payment signing (for custom flows) */
2349
+ signPayment: (requirement: PaymentRequirement) => Promise<PaymentPayload>;
2350
+ /** Whether a payment is in progress */
2351
+ isPaying: boolean;
2352
+ /** Last payment transaction hash */
2353
+ lastTxHash: string | null;
2354
+ /** Last payment amount (human-readable USDC) */
2355
+ lastAmount: string | null;
2356
+ /** Last payment info (txHash + amount + timestamp) */
2357
+ lastPayment: LastPaymentInfo | null;
2358
+ /** Total USDC spent in this session (human-readable) */
2359
+ totalSpent: string;
2360
+ /** Error from last payment attempt */
2361
+ error: Error | null;
2362
+ /** Total payments made in this session */
2363
+ paymentCount: number;
2364
+ }
2365
+ /**
2366
+ * React hook for x402 payment protocol support.
2367
+ *
2368
+ * Wraps fetch calls with automatic HTTP 402 payment handling.
2369
+ * When a server returns 402, the hook:
2370
+ * 1. Parses the payment requirement
2371
+ * 2. Validates against configured limits
2372
+ * 3. Signs using the wallet (or session key for automatic payments)
2373
+ * 4. Retries with the X-PAYMENT header
2374
+ *
2375
+ * @example
2376
+ * ```tsx
2377
+ * const { x402Fetch, isPaying, lastTxHash, paymentCount } = useX402Payment({
2378
+ * wallet,
2379
+ * encryptKey: pin,
2380
+ * getBearerToken: getToken,
2381
+ * maxPaymentAmount: "1.00",
2382
+ * onPaymentComplete: (txHash, amount) => {
2383
+ * console.log(`Paid ${amount} USDC, tx: ${txHash}`);
2384
+ * },
2385
+ * });
2386
+ *
2387
+ * // Automatic 402 handling
2388
+ * const response = await x402Fetch("https://api.example.com/premium");
2389
+ * const data = await response.json();
2390
+ * ```
2391
+ */
2392
+ declare function useX402Payment(config: UseX402PaymentConfig): UseX402PaymentReturn;
2393
+
2394
+ /**
2395
+ * SHHH V8.4 envelope builders surfaced as a single hook for React
2396
+ * integrators. Each helper returns the `signature: felt252[]` span
2397
+ * ready to pass to `paymaster_executeSponsoredRaw.calldata`.
2398
+ *
2399
+ * Most helpers take the OE `messageHash` plus kind-specific inputs.
2400
+ * `signWithMetaMask` is the exception: the `messageHash` is already
2401
+ * baked into the user-signed payload upstream, so it takes only the
2402
+ * 65-byte `personal_sign` signature and the registered pubkey.
2403
+ *
2404
+ * The hook is intentionally a thin facade over the
2405
+ * `@chipi-stack/backend` builders: it adds semantic names that map
2406
+ * to the user-facing wallet (`signWithMetaMask` = EIP-191,
2407
+ * `signWithPhantom` = Ed25519, `signWithPasskey` = WebAuthn P-256)
2408
+ * and stable React refs, but does NOT do browser-glue (no
2409
+ * `window.ethereum`, `window.solana`, or `navigator.credentials.get`
2410
+ * calls). Integrators retain full control of the user-prompt step:
2411
+ *
2412
+ * 1. Integrator calls their wallet adapter to get the raw signature
2413
+ * (or assertion / id_token).
2414
+ * 2. Integrator passes that into the matching helper to wrap it into
2415
+ * the V2_SNIP12 envelope.
2416
+ *
2417
+ * Pair with `useGuardianRecovery` or `useThresholdSign` (B6/B7) for
2418
+ * on-chain execution flows that need the recovery/governance builders.
2419
+ */
2420
+ interface UseShhhSignerReturn {
2421
+ /**
2422
+ * STARK ECDSA signer (legacy CHIPI v29 keys, fastest path).
2423
+ * Pure-local: no wallet prompt.
2424
+ */
2425
+ signWithStark: (params: {
2426
+ privateKey: bigint | string;
2427
+ messageHash: bigint;
2428
+ }) => bigint[];
2429
+ /**
2430
+ * Phantom-shape Ed25519 signer (Solana users importing to Starknet).
2431
+ * The 32-byte private key is the Solana keypair's secret material;
2432
+ * the public key is recovered inside the builder.
2433
+ */
2434
+ signWithPhantom: (params: {
2435
+ privateKey: Uint8Array;
2436
+ messageHash: bigint;
2437
+ }) => Promise<bigint[]>;
2438
+ /**
2439
+ * MetaMask-shape EIP-191 (`personal_sign`) signer. The signature
2440
+ * MUST come from a `personal_sign` over the 32-byte big-endian
2441
+ * messageHash; the pubkey was registered at wallet creation time.
2442
+ */
2443
+ signWithMetaMask: (params: {
2444
+ signatureHex: string;
2445
+ pubkey: Eip191Pubkey;
2446
+ }) => bigint[];
2447
+ /**
2448
+ * WebAuthn P-256 signer (passkey). Takes a completed
2449
+ * `navigator.credentials.get()` assertion split into its three
2450
+ * fields (authenticatorData, clientDataJSON, signature DER) plus
2451
+ * the pubkey registered at credential creation time.
2452
+ */
2453
+ signWithPasskey: (params: {
2454
+ authenticatorData: Uint8Array;
2455
+ clientDataJSON: Uint8Array;
2456
+ signatureDer: Uint8Array;
2457
+ pubkey: WebAuthnPubkey;
2458
+ messageHash: bigint;
2459
+ yParity?: 0n | 1n;
2460
+ }) => bigint[];
2461
+ /**
2462
+ * Apple Sign In signer (`JWT_ES256_APPLE_SUB`). Takes the
2463
+ * `id_token` from Apple's OAuth response. The nonce claim MUST
2464
+ * encode `messageHash` (see `messageHashToNonceB64url`).
2465
+ */
2466
+ signWithAppleIdToken: (params: {
2467
+ idToken: string;
2468
+ pubkey: JwtAppleSubPubkey;
2469
+ messageHash: bigint;
2470
+ }) => bigint[];
2471
+ }
2472
+ declare function useShhhSigner(): UseShhhSignerReturn;
2473
+
2474
+ type Call = ReturnType<typeof buildProposeAddOwnerCall>;
2475
+ /**
2476
+ * SHHH V8.4 multi-owner governance + guardian-recovery builders
2477
+ * surfaced as a single React hook. Each helper returns a Starknet
2478
+ * `Call` object (NOT a signature envelope); callers compose those
2479
+ * calls into an OutsideExecution and submit them via the paymaster
2480
+ * adapter, signing the OE with `useShhhSigner`.
2481
+ *
2482
+ * Two top-level flows are intended:
2483
+ *
2484
+ * 1. ADD DEVICE (user has wallet access, wants a second owner)
2485
+ * a. `proposeAddOwner` (owner-signed OE)
2486
+ * b. wait 48h timelock
2487
+ * c. `executeAddOwner` (owner-signed OE, with the opId from 1a)
2488
+ *
2489
+ * 2. RECOVER VIA GUARDIAN (user lost key)
2490
+ * a. `initiateRecovery` (guardian-signed OE)
2491
+ * b. wait 7 days
2492
+ * c. `finalizeRecovery` (anyone can submit, no signature required
2493
+ * beyond Cairo-side state checks)
2494
+ *
2495
+ * Read-only timelock helpers (`isReady`, `secondsRemaining`) take a
2496
+ * `validAfter` timestamp pulled from chain state and a clock reading;
2497
+ * they don't query the chain themselves. Pair this hook with whatever
2498
+ * mechanism your app already uses for on-chain state reads
2499
+ * (`useGetWallet`, RPC, multicall, etc.).
2500
+ *
2501
+ * The full controlled-component `<Recover />` route that wires this
2502
+ * hook into a state machine + UI ships as B6.2.
2503
+ */
2504
+ interface UseGuardianRecoveryReturn {
2505
+ buildProposeAddOwner: (args: {
2506
+ walletAddress: bigint | string;
2507
+ proposer: number;
2508
+ newOwner: NewOwnerInput;
2509
+ }) => Call;
2510
+ buildExecuteAddOwner: (args: {
2511
+ walletAddress: bigint | string;
2512
+ opId: bigint | string;
2513
+ newOwner: NewOwnerInput;
2514
+ }) => Call;
2515
+ buildProposeRemoveOwner: (args: {
2516
+ walletAddress: bigint | string;
2517
+ proposer: number;
2518
+ ownerId: number;
2519
+ }) => Call;
2520
+ buildExecuteRemoveOwner: (args: {
2521
+ walletAddress: bigint | string;
2522
+ opId: bigint | string;
2523
+ ownerId: number;
2524
+ }) => Call;
2525
+ buildProposeRotateOwner: (args: {
2526
+ walletAddress: bigint | string;
2527
+ proposer: number;
2528
+ ownerId: number;
2529
+ newPubkeyBytes: bigint[];
2530
+ }) => Call;
2531
+ buildExecuteRotateOwner: (args: {
2532
+ walletAddress: bigint | string;
2533
+ opId: bigint | string;
2534
+ ownerId: number;
2535
+ newPubkeyBytes: bigint[];
2536
+ }) => Call;
2537
+ buildProposeSetThreshold: (args: {
2538
+ walletAddress: bigint | string;
2539
+ proposer: number;
2540
+ newThreshold: number;
2541
+ }) => Call;
2542
+ buildExecuteSetThreshold: (args: {
2543
+ walletAddress: bigint | string;
2544
+ opId: bigint | string;
2545
+ newThreshold: number;
2546
+ }) => Call;
2547
+ buildCancelPendingOp: (args: {
2548
+ walletAddress: bigint | string;
2549
+ opId: bigint | string;
2550
+ }) => Call;
2551
+ buildInitiateRecovery: (args: {
2552
+ walletAddress: bigint | string;
2553
+ /** owner_id of the guardian that's signing the initiation OE */
2554
+ proposer: number;
2555
+ newOwner: NewOwnerInput;
2556
+ }) => Call;
2557
+ buildCancelRecovery: (args: {
2558
+ walletAddress: bigint | string;
2559
+ ownerId: number;
2560
+ }) => Call;
2561
+ buildFinalizeRecovery: (args: {
2562
+ walletAddress: bigint | string;
2563
+ newOwner: NewOwnerInput;
2564
+ }) => Call;
2565
+ isReady: (validAfterSecs: number | bigint, nowSecs?: number) => boolean;
2566
+ secondsRemaining: (validAfterSecs: number | bigint, nowSecs?: number) => number;
2567
+ TIMELOCK_SECONDS: typeof TIMELOCK_SECONDS;
2568
+ DEFAULT_OP_EXPIRY_SECONDS: typeof DEFAULT_OP_EXPIRY_SECONDS;
2569
+ ROLE_OWNER: typeof ROLE_OWNER;
2570
+ ROLE_GUARDIAN: typeof ROLE_GUARDIAN;
2571
+ OP_ADD_OWNER: typeof OP_ADD_OWNER;
2572
+ OP_REMOVE_OWNER: typeof OP_REMOVE_OWNER;
2573
+ OP_ROTATE_OWNER: typeof OP_ROTATE_OWNER;
2574
+ OP_SET_THRESHOLD: typeof OP_SET_THRESHOLD;
2575
+ }
2576
+ declare function useGuardianRecovery(): UseGuardianRecoveryReturn;
2577
+
2578
+ /**
2579
+ * SHHH V8.4 N-of-M threshold sign coordinator surfaced as a React
2580
+ * hook. Two complementary surfaces:
2581
+ *
2582
+ * 1. **Stateless helpers** — `assemble`, `parse`, and
2583
+ * `estimateGasOverhead` are pure facades over the matching
2584
+ * `@chipi-stack/backend` builders. Use them when you already
2585
+ * have all the inner envelopes in one render and just want to
2586
+ * ship the final V2_THRESHOLD span.
2587
+ *
2588
+ * 2. **Stateful collector** — for UI flows where N owners sign
2589
+ * asynchronously (passkey on phone → MetaMask on laptop, agent
2590
+ * auto-co-signing while a human reviews, etc.) the hook keeps
2591
+ * a queue of collected inner envelopes, exposes a "X of N
2592
+ * signed" state for UI display, validates each new envelope at
2593
+ * add-time (duplicate owner_id detection, structural shape),
2594
+ * and assembles the final span once the threshold is met via
2595
+ * `finalize()`.
2596
+ *
2597
+ * The collector validates each envelope inline using
2598
+ * `assertValidV2Snip12Envelope` from the backend — the same check the
2599
+ * `buildThresholdEnvelope` builder runs at assembly time. That way an
2600
+ * integrator's UI can show "owner 3 envelope rejected: duplicate
2601
+ * owner_id" before submitting the V2_THRESHOLD span on chain, instead
2602
+ * of after the paymaster reverts.
2603
+ *
2604
+ * Threshold governance (`propose_set_threshold` / `execute_set_threshold`)
2605
+ * lives in `useGuardianRecovery` because the multi-owner signing
2606
+ * here and the threshold-change proposals there share the same
2607
+ * Cairo SHHH wallet but are operationally separate flows.
2608
+ */
2609
+ interface UseThresholdSignReturn {
2610
+ /**
2611
+ * Assemble an N-of-M V2_THRESHOLD envelope from a pre-collected
2612
+ * list of inner V2_SNIP12 envelopes. Pure; no internal state used.
2613
+ * Throws on duplicate owner_id, structural mismatch, or negative
2614
+ * felts — same validation the on-chain dispatch would apply.
2615
+ */
2616
+ assemble: (args: {
2617
+ innerEnvelopes: bigint[][];
2618
+ }) => bigint[];
2619
+ /**
2620
+ * Inverse of `assemble`. Re-derives the constituent inner envelopes
2621
+ * from a V2_THRESHOLD span. Useful for UI flows showing "owners X,
2622
+ * Y, Z signed" from a stored envelope without re-walking the
2623
+ * collection state.
2624
+ */
2625
+ parse: (args: {
2626
+ envelope: bigint[];
2627
+ }) => {
2628
+ innerEnvelopes: bigint[][];
2629
+ };
2630
+ /**
2631
+ * Sum the per-kind paymaster gas overhead across the owners that
2632
+ * will participate. Use this to surface "this 2-of-3 mixed-kind
2633
+ * tx will cost X l2_gas to verify" copy in a UI.
2634
+ *
2635
+ * Per [services/gasless/signer-kinds#gas-overhead], a STARK +
2636
+ * EIP-191 pair budgets 2M + 10M = 12M l2_gas for verification on
2637
+ * top of the call's own cost.
2638
+ */
2639
+ estimateGasOverhead: (args: {
2640
+ owners: Array<{
2641
+ signerKind: ShhhSignerKind;
2642
+ }>;
2643
+ }) => number;
2644
+ /**
2645
+ * Live state machine. Re-renders the consuming component when an
2646
+ * envelope is added, removed, or the collection is reset.
2647
+ */
2648
+ state: ThresholdSignState;
2649
+ /**
2650
+ * Add one owner's inner V2_SNIP12 envelope to the collection.
2651
+ * Validates structurally + checks duplicate owner_id against
2652
+ * already-collected envelopes.
2653
+ *
2654
+ * Returns `true` on success, `false` on rejection. On rejection
2655
+ * the failure reason lands on `state.error` for inline UI display;
2656
+ * the collection is NOT mutated. A subsequent successful add
2657
+ * clears `state.error`.
2658
+ *
2659
+ * Idempotent in the sense that a second add of an already-rejected
2660
+ * envelope produces the same error; an already-collected envelope
2661
+ * (same owner_id) is treated as a duplicate.
2662
+ */
2663
+ addEnvelope: (envelope: bigint[]) => boolean;
2664
+ /**
2665
+ * Drop a previously-added envelope by its owner_id. Useful when
2666
+ * an owner signs but the integrator's review UI rejects their
2667
+ * specific tx and needs to ask them to re-sign with corrected
2668
+ * payload.
2669
+ */
2670
+ removeEnvelope: (ownerId: bigint) => void;
2671
+ /** Clear the entire collection (cancel + restart the sign flow). */
2672
+ reset: () => void;
2673
+ /**
2674
+ * Assemble the final V2_THRESHOLD envelope from collected inner
2675
+ * envelopes. Throws if fewer than `threshold` have been collected
2676
+ * (with a clear error so the caller's UI knows to keep prompting).
2677
+ */
2678
+ finalize: () => bigint[];
2679
+ MIN_THRESHOLD_OWNERS: typeof MIN_THRESHOLD_OWNERS;
2680
+ }
2681
+ interface ThresholdSignState {
2682
+ /** Threshold N this flow is collecting toward. */
2683
+ threshold: number;
2684
+ /** Inner envelopes collected so far, in arrival order. */
2685
+ collected: bigint[][];
2686
+ /**
2687
+ * Owner ids that have signed, in arrival order. Pre-derived from
2688
+ * `collected` so the UI doesn't have to re-parse each envelope.
2689
+ */
2690
+ signedOwnerIds: bigint[];
2691
+ /** Has the threshold been met? `collected.length >= threshold`. */
2692
+ isReady: boolean;
2693
+ /**
2694
+ * The most recent validation error from `addEnvelope`, if any.
2695
+ * Cleared on successful add or `reset()`. Use for inline UI error
2696
+ * display ("Owner X already signed", "envelope is malformed").
2697
+ */
2698
+ error: Error | null;
2699
+ }
2700
+ interface UseThresholdSignOptions {
2701
+ /**
2702
+ * Threshold N this flow targets. Must be at least
2703
+ * `MIN_THRESHOLD_OWNERS` (2). Changes to this value after first
2704
+ * render are honored — `isReady` re-evaluates against the new N
2705
+ * without dropping already-collected envelopes (use `reset` if
2706
+ * you need to start over).
2707
+ */
2708
+ threshold: number;
2709
+ }
2710
+ /**
2711
+ * SHHH V8.4 threshold sign coordinator.
2712
+ *
2713
+ * @example Pure assembly (all envelopes ready in one render)
2714
+ *
2715
+ * ```tsx
2716
+ * const t = useThresholdSign({ threshold: 2 });
2717
+ * const envelope = t.assemble({
2718
+ * innerEnvelopes: [starkInner, eip191Inner],
2719
+ * });
2720
+ * await submitThroughPaymaster(envelope);
2721
+ * ```
2722
+ *
2723
+ * @example Async sign flow (owners sign one at a time)
2724
+ *
2725
+ * ```tsx
2726
+ * const t = useThresholdSign({ threshold: 2 });
2727
+ *
2728
+ * // After owner 1 signs:
2729
+ * t.addEnvelope(owner1Envelope);
2730
+ *
2731
+ * // After owner 2 signs:
2732
+ * t.addEnvelope(owner2Envelope);
2733
+ *
2734
+ * // UI shows "Signed by: owner_id_1, owner_id_2" via t.state.signedOwnerIds.
2735
+ * // When t.state.isReady is true, submit:
2736
+ * if (t.state.isReady) {
2737
+ * const envelope = t.finalize();
2738
+ * await submitThroughPaymaster(envelope);
2739
+ * }
2740
+ * ```
2741
+ */
2742
+ declare function useThresholdSign(opts: UseThresholdSignOptions): UseThresholdSignReturn;
2743
+
2744
+ /** Real progress milestones, in execution order (unshield skips "deposit"). */
2745
+ type PrivacyStep = "prepare" | "fund" | "deposit" | "prove" | "finish";
2746
+ interface PrivacyConfig {
2747
+ /** Chipi API base. Default https://api.chipipay.com/v1 */
2748
+ apiBaseUrl?: string;
2749
+ /** Chipi API PUBLIC key (x-api-key; must be privacy-allowlisted). */
2750
+ apiPublicKey: string;
2751
+ /** Fresh user-JWT source, called before every authed request (tokens die
2752
+ * during the multi-minute flow — pass your auth SDK's getToken). */
2753
+ getBearerToken: () => Promise<string | null | undefined>;
2754
+ /** Starknet RPC. Default mainnet cartridge. */
2755
+ rpcUrl?: string;
2756
+ /** Chain id felt. Default SN_MAIN. */
2757
+ chainId?: string;
2758
+ /** Same-origin proxy for the CORS-less sequencer gateway (REQUIRED in
2759
+ * browsers — forward POSTs server-side to alpha-mainnet.starknet.io). */
2760
+ gatewaySubmitUrl?: string;
2761
+ /** Gas tank to sweep leftover fronted STRK back to. */
2762
+ gasTankAddress?: string;
2763
+ }
2764
+ /** The user's derived privacy account — all CLIENT-side, from their anchor. */
2765
+ interface PrivacyKeys {
2766
+ companionAddress: string;
2767
+ companionKey: string;
2768
+ classHash: string;
2769
+ poolKey: bigint;
2770
+ }
2771
+ /**
2772
+ * Derive the user's privacy account from an owner-independent anchor (the
2773
+ * wallet encryptKey bytes / passkey PRF output). Deterministic: same anchor +
2774
+ * seed tag always yields the same account — safe to cache the ADDRESS, never
2775
+ * the keys.
2776
+ */
2777
+ declare function derivePrivacyAccount(p: {
2778
+ anchorSecret: Uint8Array;
2779
+ /** Per-wallet felt (the user's wallet address) — domain-separates pools keys. */
2780
+ seedDomainTag: string;
2781
+ /** Companion account class hash (standard SNIP-6 account). */
2782
+ classHash: string;
2783
+ }): Promise<PrivacyKeys>;
2784
+ interface ShieldHookInput {
2785
+ config: PrivacyConfig;
2786
+ keys: PrivacyKeys;
2787
+ /** Token to shield (contract address). */
2788
+ token: string;
2789
+ /** Amount in the token's base units. */
2790
+ amount: bigint;
2791
+ /** Move `amount` of `token` from the USER'S WALLET into the companion —
2792
+ * the integrator's gasless transfer (e.g. useCallAnyContract). Omit when
2793
+ * the funds are already parked in the companion (retry/recovery). */
2794
+ fundDeposit?: (companionAddress: string, amount: bigint) => Promise<void>;
2795
+ onStep?: (step: PrivacyStep) => void;
2796
+ }
2797
+ /** Shield tokens into the user's private balance. See module doc. */
2798
+ declare function useShield(): {
2799
+ shield: _tanstack_react_query.UseMutateFunction<ShieldResult, Error, ShieldHookInput, unknown>;
2800
+ shieldAsync: _tanstack_react_query.UseMutateAsyncFunction<ShieldResult, Error, ShieldHookInput, unknown>;
2801
+ data: ShieldResult | undefined;
2802
+ isLoading: boolean;
2803
+ isError: boolean;
2804
+ error: Error | null;
2805
+ isSuccess: boolean;
2806
+ reset: () => void;
2807
+ };
2808
+ /** Unshield tokens from the private balance back to the user's wallet. */
2809
+ declare function useUnshield(): {
2810
+ unshield: _tanstack_react_query.UseMutateFunction<ShieldResult, Error, Omit<ShieldHookInput, "fundDeposit"> & {
2811
+ /** Where the withdrawn tokens are DELIVERED (the user's real wallet). */
2812
+ deliverTo: string;
2813
+ }, unknown>;
2814
+ unshieldAsync: _tanstack_react_query.UseMutateAsyncFunction<ShieldResult, Error, Omit<ShieldHookInput, "fundDeposit"> & {
2815
+ /** Where the withdrawn tokens are DELIVERED (the user's real wallet). */
2816
+ deliverTo: string;
2817
+ }, unknown>;
2818
+ data: ShieldResult | undefined;
2819
+ isLoading: boolean;
2820
+ isError: boolean;
2821
+ error: Error | null;
2822
+ isSuccess: boolean;
2823
+ reset: () => void;
2824
+ };
2825
+ /** A recorded shield/unshield event — the integrator's durable ledger row. */
2826
+ interface PrivacyLedgerEvent {
2827
+ direction: "shield" | "unshield";
2828
+ /** Token contract address. */
2829
+ token: string;
2830
+ /** Amount in the token's base units. */
2831
+ amount: bigint;
2832
+ }
2833
+ /**
2834
+ * PURE ledger netting (instant, render-safe): private balance per token as
2835
+ * the net of recorded events, clamped at zero so fee/rounding drift never
2836
+ * shows a negative. This is what a home-screen "private balance" should use.
2837
+ */
2838
+ declare function netPrivateBalance(events: PrivacyLedgerEvent[]): Record<string, bigint>;
2839
+ type PrivateBalanceInput = {
2840
+ /** Instant, from the integrator's recorded events. For passive display. */
2841
+ mode: "ledger";
2842
+ events: PrivacyLedgerEvent[];
2843
+ } | {
2844
+ /** Authoritative on-chain note scan — needs the derived keys (a passkey
2845
+ * gesture on first use). For an explicit "verify on-chain" action. */
2846
+ mode: "onchain";
2847
+ config: PrivacyConfig;
2848
+ keys: PrivacyKeys;
2849
+ /** Restrict the scan to these token addresses. */
2850
+ tokens?: string[];
2851
+ };
2852
+ /** Private balance per token. See {@link PrivateBalanceInput} for the modes. */
2853
+ declare function usePrivateBalance(input: PrivateBalanceInput): {
2854
+ byToken: Record<string, bigint>;
2855
+ isLoading: boolean;
2856
+ isError: boolean;
2857
+ error: Error | null;
2858
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Record<string, bigint>, Error>>;
2859
+ };
2860
+
2861
+ export { derivePrivacyAccount as $, useCallAnyContract as A, useSignTypedData as B, type ChipiWindowObjectDeps as C, useChipiWalletObject as D, useRecordSendTransaction as E, useGetTokenBalance as F, useCreateSessionKey as G, useAddSessionKeyToContract as H, useRevokeSessionKey as I, useGetSessionData as J, useExecuteWithSession as K, useX402Payment as L, type UseX402PaymentConfig as M, type UseX402PaymentReturn as N, useShhhSigner as O, type UseShhhSignerReturn as P, useGuardianRecovery as Q, type UseGuardianRecoveryReturn as R, type SessionState as S, useThresholdSign as T, type UseChipiWalletObjectConfig as U, type UseThresholdSignReturn as V, type UseThresholdSignOptions as W, type ThresholdSignState as X, useShield as Y, useUnshield as Z, usePrivateBalance as _, type ChipiApprovalRequest as a, netPrivateBalance as a0, type PrivacyConfig as a1, type PrivacyKeys as a2, type PrivacyStep as a3, type ShieldHookInput as a4, type PrivacyLedgerEvent as a5, type PrivateBalanceInput as a6, type ChipiSessionPolicy as b, useGetWallet as c, useChipiWallet as d, type UseChipiWalletConfig as e, type UseChipiWalletReturn as f, type ChipiWalletData as g, useChipiSession as h, type UseChipiSessionConfig as i, type UseChipiSessionReturn as j, type SessionWallet as k, useMigrateWalletToPasskey as l, useUpdateWalletEncryption as m, useMigrateWalletToShhh as n, useTransfer as o, type UseTransferConfig as p, useApprove as q, useGetTransactionList as r, useGetTransaction as s, useGetTransactionStatus as t, useCreateWallet as u, useSyncOnChainTransfers as v, usePurchaseSku as w, useGetSkuPurchase as x, useGetSkuList as y, useGetSku as z };