@explorins/pers-sdk-react-native 2.3.6 → 2.3.8

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.
Files changed (62) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1266 -1244
  3. package/dist/__tests__/PersSDKProvider.test.js +33 -0
  4. package/dist/hooks/useBusiness.d.ts +2 -2
  5. package/dist/hooks/useBusiness.d.ts.map +1 -1
  6. package/dist/hooks/useBusiness.js +2 -2
  7. package/dist/hooks/useIPFSUrl.d.ts +3 -3
  8. package/dist/hooks/useIPFSUrl.d.ts.map +1 -1
  9. package/dist/hooks/useIPFSUrl.js +7 -7
  10. package/dist/hooks/useTransactions.d.ts.map +1 -1
  11. package/dist/hooks/useTransactions.js +13 -5
  12. package/dist/hooks/useWeb3.js +4 -4
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +2412 -492
  16. package/dist/index.js.map +1 -1
  17. package/dist/providers/PersSDKProvider.d.ts +4 -0
  18. package/dist/providers/PersSDKProvider.d.ts.map +1 -1
  19. package/dist/providers/PersSDKProvider.js +14 -0
  20. package/dist/providers/react-native-http-client.d.ts +2 -0
  21. package/dist/providers/react-native-http-client.d.ts.map +1 -1
  22. package/dist/providers/react-native-http-client.js +5 -2
  23. package/dist/storage/rn-secure-storage.d.ts.map +1 -1
  24. package/dist/storage/rn-secure-storage.js +21 -8
  25. package/package.json +3 -3
  26. package/src/__tests__/PersSDKProvider.test.tsx +484 -420
  27. package/src/__tests__/setup.ts +40 -40
  28. package/src/hooks/index.ts +60 -60
  29. package/src/hooks/useAnalytics.ts +327 -327
  30. package/src/hooks/useAuth.ts +265 -265
  31. package/src/hooks/useBookings.ts +191 -191
  32. package/src/hooks/useBusiness.ts +251 -251
  33. package/src/hooks/useCampaigns.ts +500 -500
  34. package/src/hooks/useDonations.ts +66 -66
  35. package/src/hooks/useEvents.ts +372 -372
  36. package/src/hooks/useFiles.ts +155 -155
  37. package/src/hooks/useIPFSUrl.ts +192 -192
  38. package/src/hooks/usePurchases.ts +65 -65
  39. package/src/hooks/useRedemptions.ts +467 -467
  40. package/src/hooks/useTenants.ts +72 -72
  41. package/src/hooks/useTokenBalances.ts +385 -385
  42. package/src/hooks/useTokens.ts +313 -313
  43. package/src/hooks/useTransactionSigner.ts +611 -611
  44. package/src/hooks/useTransactions.ts +299 -290
  45. package/src/hooks/useTriggerSources.ts +301 -301
  46. package/src/hooks/useUserStatus.ts +61 -61
  47. package/src/hooks/useUsers.ts +167 -167
  48. package/src/hooks/useWeb3.ts +355 -355
  49. package/src/index.ts +777 -774
  50. package/src/polyfills/index.ts +160 -160
  51. package/src/polyfills/web3-polyfills.ts +97 -97
  52. package/src/providers/PersSDKProvider.tsx +393 -374
  53. package/src/providers/react-native-auth-provider.ts +110 -110
  54. package/src/providers/react-native-http-client.ts +150 -145
  55. package/src/providers/rn-dpop-provider.ts +190 -190
  56. package/src/storage/async-storage-token-storage.ts +185 -185
  57. package/src/storage/rn-secure-storage.ts +182 -170
  58. package/src/types/react-native-globals.d.ts +45 -45
  59. package/src/utils/index.ts +8 -8
  60. package/src/utils/platform-detection.ts +86 -86
  61. package/dist/index-CzLxqePZ.js +0 -7717
  62. package/dist/index-CzLxqePZ.js.map +0 -1
@@ -1,291 +1,300 @@
1
- import { useCallback } from 'react';
2
- import { usePersSDK } from '../providers/PersSDKProvider';
3
- import { useTransactionSigner, OnStatusUpdateFn } from './useTransactionSigner';
4
- import type {
5
- TransactionRequestDTO,
6
- TransactionRequestResponseDTO,
7
- TransactionDTO,
8
- TransactionPaginationRequestDTO,
9
- PaginatedResponseDTO,
10
- TransactionIncludeRelation
11
- } from '@explorins/pers-sdk';
12
- import type { TransactionQueryOptions } from '@explorins/pers-sdk/transaction';
13
-
14
- // Re-export for consumers
15
- export type { TransactionQueryOptions } from '@explorins/pers-sdk/transaction';
16
-
17
- /**
18
- * React hook for transaction operations in the PERS SDK
19
- *
20
- * Provides comprehensive transaction management including creation, retrieval, history,
21
- * and administrative operations. Supports pagination and CSV export functionality.
22
- *
23
- * @returns Transaction hook with methods for transaction management
24
- *
25
- * @example
26
- * ```typescript
27
- * function TransactionsComponent() {
28
- * const {
29
- * createTransaction,
30
- * getUserTransactionHistory
31
- * } = useTransactions();
32
- *
33
- * const handleCreateTransaction = async (request) => {
34
- * try {
35
- * const result = await createTransaction(request);
36
- * console.log('Transaction created:', result);
37
- * // Handle signature URL if returned
38
- * } catch (error) {
39
- * console.error('Transaction failed:', error);
40
- * }
41
- * };
42
- *
43
- * return (
44
- * <div>
45
- * <button onClick={() => handleCreateTransaction(transactionRequest)}>
46
- * Create Transaction
47
- * </button>
48
- * </div>
49
- * );
50
- * }
51
- * ```
52
- */
53
- export const useTransactions = () => {
54
- const { sdk, isInitialized, isAuthenticated } = usePersSDK();
55
- const { signAndSubmitTransactionWithJWT, isSignerAvailable, currentStatus, statusMessage } = useTransactionSigner();
56
-
57
- if (!isAuthenticated && isInitialized) {
58
- console.warn('SDK not authenticated. Some transaction operations may fail.');
59
- }
60
-
61
- /**
62
- * Creates a new transaction in the system
63
- *
64
- * Automatically handles signature URLs by opening them in the device's browser.
65
- * The transaction may require user approval through external wallet applications.
66
- *
67
- * @param request - Transaction request data including amount, recipient, etc.
68
- * @returns Promise resolving to transaction response with potential actionable items
69
- * @throws Error if SDK is not initialized
70
- *
71
- * @example
72
- * ```typescript
73
- * const { createTransaction } = useTransactions();
74
- * const request = {
75
- * amount: '100',
76
- * recipient: '0x123...',
77
- * tokenId: 'token-123'
78
- * };
79
- * const result = await createTransaction(request, (status, message) => {
80
- * console.log(`Status: ${status} - ${message}`);
81
- * });
82
- * console.log('Transaction created:', result);
83
- * ```
84
- */
85
- const createTransaction = useCallback(async (request: TransactionRequestDTO, onStatusUpdate?: OnStatusUpdateFn): Promise<TransactionRequestResponseDTO> => {
86
- if (!isInitialized || !sdk) {
87
- throw new Error('SDK not initialized. Call initialize() first.');
88
- }
89
-
90
- try {
91
- const result = await sdk.transactions.createTransaction(request);
92
-
93
- // Check if transaction requires signing (contains actionable authToken)
94
- // Type assertion needed as TransactionRequestResponseDTO type may not include all dynamic properties
95
- const txToken = result?.actionable?.authToken;
96
- if (txToken) {
97
-
98
- try {
99
- if (!isSignerAvailable) {
100
- console.warn('[useTransactions] Transaction signer not available, skipping automatic signing');
101
- return result;
102
- }
103
-
104
- // Automatically sign the transaction using the authToken
105
- const signingResult = await signAndSubmitTransactionWithJWT(txToken, onStatusUpdate);
106
-
107
- if (signingResult.success) {
108
- console.log('[useTransactions] Transaction signed successfully:', signingResult.transactionHash);
109
- // Return the original result - the transaction is now signed and will be processed
110
- return result;
111
- } else {
112
- console.error('[useTransactions] Transaction signing failed:', signingResult.error);
113
- // Don't throw error - return the original result so caller can handle signature URL manually
114
- return result;
115
- }
116
- } catch (signingError) {
117
- console.error('[useTransactions] Blockchain signing error:', signingError);
118
- // Don't throw error - return the original result so caller can handle signature URL manually
119
- return result;
120
- }
121
- }
122
-
123
- return result;
124
- } catch (error) {
125
- console.error('Failed to create transaction:', error);
126
- throw error;
127
- }
128
- }, [sdk, isInitialized, signAndSubmitTransactionWithJWT, isSignerAvailable]);
129
-
130
- /**
131
- * Retrieves a specific transaction by its ID with optional include relations
132
- *
133
- * @param transactionId - Unique identifier of the transaction
134
- * @param include - Optional relations to include (sender, recipient, business) for enriched entity data
135
- * @returns Promise resolving to transaction data or null if not found
136
- * @throws Error if SDK is not initialized
137
- *
138
- * @example
139
- * ```typescript
140
- * const { getTransactionById } = useTransactions();
141
- *
142
- * // Basic retrieval
143
- * const transaction = await getTransactionById('txn-123');
144
- *
145
- * // With enriched sender/recipient data
146
- * const enrichedTx = await getTransactionById('txn-123', ['sender', 'recipient', 'business']);
147
- * console.log('Sender:', enrichedTx?.included?.sender);
148
- * console.log('Business:', enrichedTx?.included?.engagedBusiness?.displayName);
149
- * ```
150
- */
151
- const getTransactionById = useCallback(async (
152
- transactionId: string,
153
- include?: TransactionIncludeRelation[]
154
- ): Promise<TransactionDTO | null> => {
155
- if (!isInitialized || !sdk) {
156
- throw new Error('SDK not initialized. Call initialize() first.');
157
- }
158
-
159
- try {
160
- return await sdk.transactions.getTransactionById(transactionId, include);
161
- } catch (error) {
162
- console.error('Failed to fetch transaction:', error);
163
- throw error;
164
- }
165
- }, [sdk, isInitialized]);
166
-
167
- /**
168
- * Retrieves transaction history for the authenticated user with comprehensive filtering
169
- *
170
- * Supports filtering by role, status, type, business, token, and more.
171
- * Optionally enrich with related entities (sender, recipient, business).
172
- *
173
- * @param options - Query options including filters, pagination, and include relations
174
- * @returns Promise resolving to paginated array of user's transactions
175
- * @throws Error if SDK is not initialized
176
- *
177
- * @example
178
- * ```typescript
179
- * const { getUserTransactionHistory } = useTransactions();
180
- *
181
- * // Simple: Get all transactions
182
- * const allTransactions = await getUserTransactionHistory();
183
- *
184
- * // Filter by role (legacy support)
185
- * const sentTransactions = await getUserTransactionHistory({ role: 'SENDER' });
186
- *
187
- * // Advanced filtering with include relations
188
- * const filtered = await getUserTransactionHistory({
189
- * role: 'SENDER',
190
- * status: 'COMPLETED',
191
- * engagedBusinessId: 'business-123',
192
- * include: ['recipient', 'business'],
193
- * page: 1,
194
- * limit: 20
195
- * });
196
- *
197
- * // Access enriched data
198
- * filtered.data.forEach(tx => {
199
- * console.log('Recipient:', tx.included?.recipient);
200
- * console.log('Business:', tx.included?.engagedBusiness?.displayName);
201
- * });
202
- * ```
203
- */
204
- const getUserTransactionHistory = useCallback(async (
205
- options?: TransactionQueryOptions
206
- ): Promise<PaginatedResponseDTO<TransactionDTO>> => {
207
- if (!isInitialized || !sdk) {
208
- throw new Error('SDK not initialized. Call initialize() first.');
209
- }
210
-
211
- try {
212
- return await sdk.transactions.getUserTransactionHistory(options);
213
- } catch (error) {
214
- console.error('Failed to fetch transaction history:', error);
215
- throw error;
216
- }
217
- }, [sdk, isInitialized]);
218
-
219
- /**
220
- * Admin: Get paginated transactions with optional include relations
221
- *
222
- * @param params - Pagination and filtering parameters
223
- * @param include - Optional relations to include for enriched entity data
224
- * @returns Promise resolving to paginated transaction results
225
- * @throws Error if SDK is not initialized
226
- *
227
- * @example
228
- * ```typescript
229
- * const { getPaginatedTransactions } = useTransactions();
230
- *
231
- * // Basic pagination
232
- * const result = await getPaginatedTransactions({ page: 1, limit: 50 });
233
- *
234
- * // With include relations
235
- * const enrichedResult = await getPaginatedTransactions(
236
- * { page: 1, limit: 50, sortBy: 'createdAt', sortOrder: 'DESC' },
237
- * include: ['sender', 'recipient', 'business']
238
- * });
239
- *
240
- * enrichedResult.data.forEach(tx => {
241
- * console.log('From:', tx.included?.sender);
242
- * console.log('To:', tx.included?.recipient);
243
- * });
244
- * ```
245
- */
246
- const getPaginatedTransactions = useCallback(async (
247
- options: TransactionPaginationRequestDTO & {
248
- include?: TransactionIncludeRelation[];
249
- }
250
- ): Promise<PaginatedResponseDTO<TransactionDTO>> => {
251
- if (!isInitialized || !sdk) {
252
- throw new Error('SDK not initialized. Call initialize() first.');
253
- }
254
-
255
- try {
256
- const result = await sdk.transactions.getPaginatedTransactions(options);
257
- return result;
258
- } catch (error) {
259
- console.error('Failed to fetch paginated transactions:', error);
260
- throw error;
261
- }
262
- }, [sdk, isInitialized]);
263
-
264
- const exportTransactionsCSV = useCallback(async (): Promise<Blob> => {
265
- if (!isInitialized || !sdk) {
266
- throw new Error('SDK not initialized. Call initialize() first.');
267
- }
268
-
269
- try {
270
- const result = await sdk.transactions.exportTransactionsCSV();
271
- return result;
272
- } catch (error) {
273
- console.error('Failed to export transactions CSV:', error);
274
- throw error;
275
- }
276
- }, [sdk, isInitialized]);
277
-
278
- return {
279
- createTransaction,
280
- getTransactionById,
281
- getUserTransactionHistory,
282
- getPaginatedTransactions,
283
- exportTransactionsCSV,
284
- isAvailable: isInitialized && !!sdk?.transactions,
285
- // Expose signing status for UI feedback
286
- signingStatus: currentStatus,
287
- signingStatusMessage: statusMessage,
288
- };
289
- };
290
-
1
+ import { useCallback } from 'react';
2
+ import { usePersSDK } from '../providers/PersSDKProvider';
3
+ import { useTransactionSigner, OnStatusUpdateFn } from './useTransactionSigner';
4
+ import type {
5
+ TransactionRequestDTO,
6
+ TransactionRequestResponseDTO,
7
+ TransactionDTO,
8
+ TransactionPaginationRequestDTO,
9
+ PaginatedResponseDTO,
10
+ TransactionIncludeRelation
11
+ } from '@explorins/pers-sdk';
12
+ import type { TransactionQueryOptions } from '@explorins/pers-sdk/transaction';
13
+ import { needsSubmission } from '@explorins/pers-sdk/transaction';
14
+
15
+ // Re-export for consumers
16
+ export type { TransactionQueryOptions } from '@explorins/pers-sdk/transaction';
17
+
18
+ /**
19
+ * React hook for transaction operations in the PERS SDK
20
+ *
21
+ * Provides comprehensive transaction management including creation, retrieval, history,
22
+ * and administrative operations. Supports pagination and CSV export functionality.
23
+ *
24
+ * @returns Transaction hook with methods for transaction management
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * function TransactionsComponent() {
29
+ * const {
30
+ * createTransaction,
31
+ * getUserTransactionHistory
32
+ * } = useTransactions();
33
+ *
34
+ * const handleCreateTransaction = async (request) => {
35
+ * try {
36
+ * const result = await createTransaction(request);
37
+ * console.log('Transaction created:', result);
38
+ * // Handle signature URL if returned
39
+ * } catch (error) {
40
+ * console.error('Transaction failed:', error);
41
+ * }
42
+ * };
43
+ *
44
+ * return (
45
+ * <div>
46
+ * <button onClick={() => handleCreateTransaction(transactionRequest)}>
47
+ * Create Transaction
48
+ * </button>
49
+ * </div>
50
+ * );
51
+ * }
52
+ * ```
53
+ */
54
+ export const useTransactions = () => {
55
+ const { sdk, isInitialized, isAuthenticated } = usePersSDK();
56
+ const { signAndSubmitTransactionWithJWT, isSignerAvailable, currentStatus, statusMessage } = useTransactionSigner();
57
+
58
+ if (!isAuthenticated && isInitialized) {
59
+ console.warn('SDK not authenticated. Some transaction operations may fail.');
60
+ }
61
+
62
+ /**
63
+ * Creates a new transaction in the system
64
+ *
65
+ * Automatically handles signature URLs by opening them in the device's browser.
66
+ * The transaction may require user approval through external wallet applications.
67
+ *
68
+ * @param request - Transaction request data including amount, recipient, etc.
69
+ * @returns Promise resolving to transaction response with potential actionable items
70
+ * @throws Error if SDK is not initialized
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * const { createTransaction } = useTransactions();
75
+ * const request = {
76
+ * amount: '100',
77
+ * recipient: '0x123...',
78
+ * tokenId: 'token-123'
79
+ * };
80
+ * const result = await createTransaction(request, (status, message) => {
81
+ * console.log(`Status: ${status} - ${message}`);
82
+ * });
83
+ * console.log('Transaction created:', result);
84
+ * ```
85
+ */
86
+ const createTransaction = useCallback(async (request: TransactionRequestDTO, onStatusUpdate?: OnStatusUpdateFn): Promise<TransactionRequestResponseDTO> => {
87
+ if (!isInitialized || !sdk) {
88
+ throw new Error('SDK not initialized. Call initialize() first.');
89
+ }
90
+
91
+ try {
92
+ const result = await sdk.transactions.createTransaction(request);
93
+
94
+ // If backend already signed custodially, return as-is so caller can build QR
95
+ // from result.signatureData directly (no client signing needed)
96
+ if (needsSubmission(result)) {
97
+ return result;
98
+ }
99
+
100
+ // If client signer is unavailable, return as-is so caller can fall back to
101
+ // result.actionable.actionUrl (external signing URL) if present
102
+ if (!isSignerAvailable) {
103
+ console.warn('[useTransactions] Transaction signer not available, returning result for caller to handle');
104
+ return result;
105
+ }
106
+
107
+ // Check if transaction requires client signing (contains actionable authToken)
108
+ // Type assertion needed as TransactionRequestResponseDTO type may not include all dynamic properties
109
+ const txToken = result?.actionable?.authToken;
110
+ if (txToken) {
111
+
112
+ try {
113
+ // Automatically sign the transaction using the authToken
114
+ const signingResult = await signAndSubmitTransactionWithJWT(txToken, onStatusUpdate);
115
+
116
+ if (signingResult.success) {
117
+ console.log('[useTransactions] Transaction signed successfully:', signingResult.transactionHash);
118
+ // Return the original result - the transaction is now signed and will be processed
119
+ return result;
120
+ } else {
121
+ console.error('[useTransactions] Transaction signing failed:', signingResult.error);
122
+ // Don't throw error - return the original result so caller can handle signature URL manually
123
+ return result;
124
+ }
125
+ } catch (signingError) {
126
+ console.error('[useTransactions] Blockchain signing error:', signingError);
127
+ // Don't throw error - return the original result so caller can handle signature URL manually
128
+ return result;
129
+ }
130
+ }
131
+
132
+ return result;
133
+ } catch (error) {
134
+ console.error('Failed to create transaction:', error);
135
+ throw error;
136
+ }
137
+ }, [sdk, isInitialized, signAndSubmitTransactionWithJWT, isSignerAvailable]);
138
+
139
+ /**
140
+ * Retrieves a specific transaction by its ID with optional include relations
141
+ *
142
+ * @param transactionId - Unique identifier of the transaction
143
+ * @param include - Optional relations to include (sender, recipient, business) for enriched entity data
144
+ * @returns Promise resolving to transaction data or null if not found
145
+ * @throws Error if SDK is not initialized
146
+ *
147
+ * @example
148
+ * ```typescript
149
+ * const { getTransactionById } = useTransactions();
150
+ *
151
+ * // Basic retrieval
152
+ * const transaction = await getTransactionById('txn-123');
153
+ *
154
+ * // With enriched sender/recipient data
155
+ * const enrichedTx = await getTransactionById('txn-123', ['sender', 'recipient', 'business']);
156
+ * console.log('Sender:', enrichedTx?.included?.sender);
157
+ * console.log('Business:', enrichedTx?.included?.engagedBusiness?.displayName);
158
+ * ```
159
+ */
160
+ const getTransactionById = useCallback(async (
161
+ transactionId: string,
162
+ include?: TransactionIncludeRelation[]
163
+ ): Promise<TransactionDTO | null> => {
164
+ if (!isInitialized || !sdk) {
165
+ throw new Error('SDK not initialized. Call initialize() first.');
166
+ }
167
+
168
+ try {
169
+ return await sdk.transactions.getTransactionById(transactionId, include);
170
+ } catch (error) {
171
+ console.error('Failed to fetch transaction:', error);
172
+ throw error;
173
+ }
174
+ }, [sdk, isInitialized]);
175
+
176
+ /**
177
+ * Retrieves transaction history for the authenticated user with comprehensive filtering
178
+ *
179
+ * Supports filtering by role, status, type, business, token, and more.
180
+ * Optionally enrich with related entities (sender, recipient, business).
181
+ *
182
+ * @param options - Query options including filters, pagination, and include relations
183
+ * @returns Promise resolving to paginated array of user's transactions
184
+ * @throws Error if SDK is not initialized
185
+ *
186
+ * @example
187
+ * ```typescript
188
+ * const { getUserTransactionHistory } = useTransactions();
189
+ *
190
+ * // Simple: Get all transactions
191
+ * const allTransactions = await getUserTransactionHistory();
192
+ *
193
+ * // Filter by role (legacy support)
194
+ * const sentTransactions = await getUserTransactionHistory({ role: 'SENDER' });
195
+ *
196
+ * // Advanced filtering with include relations
197
+ * const filtered = await getUserTransactionHistory({
198
+ * role: 'SENDER',
199
+ * status: 'COMPLETED',
200
+ * engagedBusinessId: 'business-123',
201
+ * include: ['recipient', 'business'],
202
+ * page: 1,
203
+ * limit: 20
204
+ * });
205
+ *
206
+ * // Access enriched data
207
+ * filtered.data.forEach(tx => {
208
+ * console.log('Recipient:', tx.included?.recipient);
209
+ * console.log('Business:', tx.included?.engagedBusiness?.displayName);
210
+ * });
211
+ * ```
212
+ */
213
+ const getUserTransactionHistory = useCallback(async (
214
+ options?: TransactionQueryOptions
215
+ ): Promise<PaginatedResponseDTO<TransactionDTO>> => {
216
+ if (!isInitialized || !sdk) {
217
+ throw new Error('SDK not initialized. Call initialize() first.');
218
+ }
219
+
220
+ try {
221
+ return await sdk.transactions.getUserTransactionHistory(options);
222
+ } catch (error) {
223
+ console.error('Failed to fetch transaction history:', error);
224
+ throw error;
225
+ }
226
+ }, [sdk, isInitialized]);
227
+
228
+ /**
229
+ * Admin: Get paginated transactions with optional include relations
230
+ *
231
+ * @param params - Pagination and filtering parameters
232
+ * @param include - Optional relations to include for enriched entity data
233
+ * @returns Promise resolving to paginated transaction results
234
+ * @throws Error if SDK is not initialized
235
+ *
236
+ * @example
237
+ * ```typescript
238
+ * const { getPaginatedTransactions } = useTransactions();
239
+ *
240
+ * // Basic pagination
241
+ * const result = await getPaginatedTransactions({ page: 1, limit: 50 });
242
+ *
243
+ * // With include relations
244
+ * const enrichedResult = await getPaginatedTransactions(
245
+ * { page: 1, limit: 50, sortBy: 'createdAt', sortOrder: 'DESC' },
246
+ * include: ['sender', 'recipient', 'business']
247
+ * });
248
+ *
249
+ * enrichedResult.data.forEach(tx => {
250
+ * console.log('From:', tx.included?.sender);
251
+ * console.log('To:', tx.included?.recipient);
252
+ * });
253
+ * ```
254
+ */
255
+ const getPaginatedTransactions = useCallback(async (
256
+ options: TransactionPaginationRequestDTO & {
257
+ include?: TransactionIncludeRelation[];
258
+ }
259
+ ): Promise<PaginatedResponseDTO<TransactionDTO>> => {
260
+ if (!isInitialized || !sdk) {
261
+ throw new Error('SDK not initialized. Call initialize() first.');
262
+ }
263
+
264
+ try {
265
+ const result = await sdk.transactions.getPaginatedTransactions(options);
266
+ return result;
267
+ } catch (error) {
268
+ console.error('Failed to fetch paginated transactions:', error);
269
+ throw error;
270
+ }
271
+ }, [sdk, isInitialized]);
272
+
273
+ const exportTransactionsCSV = useCallback(async (): Promise<Blob> => {
274
+ if (!isInitialized || !sdk) {
275
+ throw new Error('SDK not initialized. Call initialize() first.');
276
+ }
277
+
278
+ try {
279
+ const result = await sdk.transactions.exportTransactionsCSV();
280
+ return result;
281
+ } catch (error) {
282
+ console.error('Failed to export transactions CSV:', error);
283
+ throw error;
284
+ }
285
+ }, [sdk, isInitialized]);
286
+
287
+ return {
288
+ createTransaction,
289
+ getTransactionById,
290
+ getUserTransactionHistory,
291
+ getPaginatedTransactions,
292
+ exportTransactionsCSV,
293
+ isAvailable: isInitialized && !!sdk?.transactions,
294
+ // Expose signing status for UI feedback
295
+ signingStatus: currentStatus,
296
+ signingStatusMessage: statusMessage,
297
+ };
298
+ };
299
+
291
300
  export type TransactionHook = ReturnType<typeof useTransactions>;