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