@explorins/pers-sdk-react-native 2.3.7 → 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 (58) 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/useWeb3.js +4 -4
  11. package/dist/index.js +2400 -487
  12. package/dist/index.js.map +1 -1
  13. package/dist/providers/PersSDKProvider.d.ts +4 -0
  14. package/dist/providers/PersSDKProvider.d.ts.map +1 -1
  15. package/dist/providers/PersSDKProvider.js +14 -0
  16. package/dist/providers/react-native-http-client.d.ts +2 -0
  17. package/dist/providers/react-native-http-client.d.ts.map +1 -1
  18. package/dist/providers/react-native-http-client.js +5 -2
  19. package/dist/storage/rn-secure-storage.d.ts.map +1 -1
  20. package/dist/storage/rn-secure-storage.js +21 -8
  21. package/package.json +3 -3
  22. package/src/__tests__/PersSDKProvider.test.tsx +484 -420
  23. package/src/__tests__/setup.ts +40 -40
  24. package/src/hooks/index.ts +60 -60
  25. package/src/hooks/useAnalytics.ts +327 -327
  26. package/src/hooks/useAuth.ts +265 -265
  27. package/src/hooks/useBookings.ts +191 -191
  28. package/src/hooks/useBusiness.ts +251 -251
  29. package/src/hooks/useCampaigns.ts +500 -500
  30. package/src/hooks/useDonations.ts +66 -66
  31. package/src/hooks/useEvents.ts +372 -372
  32. package/src/hooks/useFiles.ts +155 -155
  33. package/src/hooks/useIPFSUrl.ts +192 -192
  34. package/src/hooks/usePurchases.ts +65 -65
  35. package/src/hooks/useRedemptions.ts +467 -467
  36. package/src/hooks/useTenants.ts +72 -72
  37. package/src/hooks/useTokenBalances.ts +385 -385
  38. package/src/hooks/useTokens.ts +313 -313
  39. package/src/hooks/useTransactionSigner.ts +611 -611
  40. package/src/hooks/useTransactions.ts +299 -299
  41. package/src/hooks/useTriggerSources.ts +301 -301
  42. package/src/hooks/useUserStatus.ts +61 -61
  43. package/src/hooks/useUsers.ts +167 -167
  44. package/src/hooks/useWeb3.ts +355 -355
  45. package/src/index.ts +777 -777
  46. package/src/polyfills/index.ts +160 -160
  47. package/src/polyfills/web3-polyfills.ts +97 -97
  48. package/src/providers/PersSDKProvider.tsx +393 -374
  49. package/src/providers/react-native-auth-provider.ts +110 -110
  50. package/src/providers/react-native-http-client.ts +150 -145
  51. package/src/providers/rn-dpop-provider.ts +190 -190
  52. package/src/storage/async-storage-token-storage.ts +185 -185
  53. package/src/storage/rn-secure-storage.ts +182 -170
  54. package/src/types/react-native-globals.d.ts +45 -45
  55. package/src/utils/index.ts +8 -8
  56. package/src/utils/platform-detection.ts +86 -86
  57. package/dist/index-CzLxqePZ.js +0 -7717
  58. package/dist/index-CzLxqePZ.js.map +0 -1
@@ -1,300 +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
- 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
-
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
+
300
300
  export type TransactionHook = ReturnType<typeof useTransactions>;