@explorins/pers-sdk-react-native 1.5.30 → 1.5.32

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 (76) hide show
  1. package/README.md +9 -0
  2. package/dist/hooks/index.d.ts +2 -2
  3. package/dist/hooks/index.d.ts.map +1 -1
  4. package/dist/hooks/index.js +1 -1
  5. package/dist/hooks/useAnalytics.d.ts.map +1 -1
  6. package/dist/hooks/useAnalytics.js +0 -1
  7. package/dist/hooks/useAuth.d.ts +0 -1
  8. package/dist/hooks/useAuth.d.ts.map +1 -1
  9. package/dist/hooks/useAuth.js +5 -18
  10. package/dist/hooks/useBusiness.d.ts.map +1 -1
  11. package/dist/hooks/useBusiness.js +0 -9
  12. package/dist/hooks/useCampaigns.d.ts.map +1 -1
  13. package/dist/hooks/useCampaigns.js +0 -10
  14. package/dist/hooks/useDonations.d.ts.map +1 -1
  15. package/dist/hooks/useDonations.js +0 -1
  16. package/dist/hooks/useFiles.d.ts.map +1 -1
  17. package/dist/hooks/useFiles.js +0 -4
  18. package/dist/hooks/usePurchases.d.ts.map +1 -1
  19. package/dist/hooks/usePurchases.js +0 -3
  20. package/dist/hooks/useRedemptions.d.ts +4 -1
  21. package/dist/hooks/useRedemptions.d.ts.map +1 -1
  22. package/dist/hooks/useRedemptions.js +6 -17
  23. package/dist/hooks/useTenants.d.ts.map +1 -1
  24. package/dist/hooks/useTenants.js +0 -3
  25. package/dist/hooks/useTokens.d.ts.map +1 -1
  26. package/dist/hooks/useTokens.js +0 -6
  27. package/dist/hooks/useTransactionSigner.d.ts +13 -1
  28. package/dist/hooks/useTransactionSigner.d.ts.map +1 -1
  29. package/dist/hooks/useTransactionSigner.js +59 -2
  30. package/dist/hooks/useTransactions.d.ts +4 -1
  31. package/dist/hooks/useTransactions.d.ts.map +1 -1
  32. package/dist/hooks/useTransactions.js +9 -10
  33. package/dist/hooks/useUserStatus.d.ts.map +1 -1
  34. package/dist/hooks/useUserStatus.js +0 -3
  35. package/dist/hooks/useUsers.d.ts.map +1 -1
  36. package/dist/hooks/useUsers.js +0 -7
  37. package/dist/hooks/useWeb3.d.ts +26 -42
  38. package/dist/hooks/useWeb3.d.ts.map +1 -1
  39. package/dist/hooks/useWeb3.js +27 -53
  40. package/dist/index.d.ts +2 -1
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +330 -304
  43. package/dist/index.js.map +1 -1
  44. package/dist/providers/PersSDKProvider.d.ts +1 -3
  45. package/dist/providers/PersSDKProvider.d.ts.map +1 -1
  46. package/dist/providers/PersSDKProvider.js +14 -11
  47. package/dist/providers/react-native-auth-provider.d.ts.map +1 -1
  48. package/dist/providers/react-native-auth-provider.js +4 -0
  49. package/dist/providers/rn-dpop-provider.d.ts +2 -4
  50. package/dist/providers/rn-dpop-provider.d.ts.map +1 -1
  51. package/dist/providers/rn-dpop-provider.js +50 -23
  52. package/dist/storage/rn-secure-storage.d.ts +1 -0
  53. package/dist/storage/rn-secure-storage.d.ts.map +1 -1
  54. package/dist/storage/rn-secure-storage.js +9 -12
  55. package/package.json +2 -2
  56. package/src/hooks/index.ts +10 -2
  57. package/src/hooks/useAnalytics.ts +0 -1
  58. package/src/hooks/useAuth.ts +4 -25
  59. package/src/hooks/useBusiness.ts +0 -9
  60. package/src/hooks/useCampaigns.ts +0 -10
  61. package/src/hooks/useDonations.ts +0 -1
  62. package/src/hooks/useFiles.ts +0 -4
  63. package/src/hooks/usePurchases.ts +0 -3
  64. package/src/hooks/useRedemptions.ts +7 -21
  65. package/src/hooks/useTenants.ts +0 -3
  66. package/src/hooks/useTokens.ts +0 -6
  67. package/src/hooks/useTransactionSigner.ts +74 -4
  68. package/src/hooks/useTransactions.ts +10 -12
  69. package/src/hooks/useUserStatus.ts +0 -3
  70. package/src/hooks/useUsers.ts +0 -7
  71. package/src/hooks/useWeb3.ts +28 -68
  72. package/src/index.ts +4 -0
  73. package/src/providers/PersSDKProvider.tsx +19 -20
  74. package/src/providers/react-native-auth-provider.ts +5 -0
  75. package/src/providers/rn-dpop-provider.ts +85 -45
  76. package/src/storage/rn-secure-storage.ts +13 -13
@@ -75,7 +75,6 @@ export const useFiles = () => {
75
75
 
76
76
  try {
77
77
  const result = await sdk.files.getSignedPutUrl(entityId, entityType, fileExtension);
78
- console.log('Signed put URL generated successfully:', result);
79
78
  return result;
80
79
  } catch (error) {
81
80
  console.error('Failed to generate signed put URL:', error);
@@ -110,7 +109,6 @@ export const useFiles = () => {
110
109
 
111
110
  try {
112
111
  const result = await sdk.files.getSignedGetUrl(entityId, entityType, expireSeconds);
113
- console.log('Signed get URL generated successfully:', result);
114
112
  return result;
115
113
  } catch (error) {
116
114
  console.error('Failed to generate signed get URL:', error);
@@ -125,7 +123,6 @@ export const useFiles = () => {
125
123
 
126
124
  try {
127
125
  const result = await sdk.files.getSignedUrl(request);
128
- console.log('Signed URL generated successfully:', result);
129
126
  return result;
130
127
  } catch (error) {
131
128
  console.error('Failed to generate signed URL:', error);
@@ -140,7 +137,6 @@ export const useFiles = () => {
140
137
 
141
138
  try {
142
139
  const result = await sdk.files.optimizeMedia(url, width, height);
143
- console.log('Media optimized successfully:', result);
144
140
  return result;
145
141
  } catch (error) {
146
142
  console.error('Failed to optimize media:', error);
@@ -17,7 +17,6 @@ export const usePurchases = () => {
17
17
 
18
18
  try {
19
19
  const result = await sdk.purchases.createPaymentIntent(amount, currency, receiptEmail, description);
20
- console.log('Payment intent created successfully:', result);
21
20
  return result;
22
21
  } catch (error) {
23
22
  console.error('Failed to create payment intent:', error);
@@ -32,7 +31,6 @@ export const usePurchases = () => {
32
31
 
33
32
  try {
34
33
  const result = await sdk.purchases.getActivePurchaseTokens();
35
- console.log('Active purchase tokens fetched successfully:', result);
36
34
  return result;
37
35
  } catch (error) {
38
36
  console.error('Failed to fetch active purchase tokens:', error);
@@ -50,7 +48,6 @@ export const usePurchases = () => {
50
48
 
51
49
  try {
52
50
  const result = await sdk.purchases.getAllUserPurchases();
53
- console.log('User purchases fetched successfully:', result);
54
51
  return result;
55
52
  } catch (error) {
56
53
  console.error('Failed to fetch user purchases:', error);
@@ -1,6 +1,6 @@
1
1
  import { useCallback } from 'react';
2
2
  import { usePersSDK } from '../providers/PersSDKProvider';
3
- import { SubmissionResult, useTransactionSigner } from './useTransactionSigner';
3
+ import { SubmissionResult, useTransactionSigner, OnStatusUpdateFn } from './useTransactionSigner';
4
4
  import type {
5
5
  RedemptionCreateRequestDTO,
6
6
  RedemptionDTO,
@@ -11,7 +11,7 @@ import type {
11
11
 
12
12
  export const useRedemptions = () => {
13
13
  const { sdk, isInitialized, isAuthenticated } = usePersSDK();
14
- const { signAndSubmitTransactionWithJWT, isSignerAvailable } = useTransactionSigner();
14
+ const { signAndSubmitTransactionWithJWT, isSignerAvailable, currentStatus, statusMessage } = useTransactionSigner();
15
15
 
16
16
  const getActiveRedemptions = useCallback(async (): Promise<RedemptionDTO[]> => {
17
17
  if (!isInitialized || !sdk) {
@@ -20,7 +20,6 @@ export const useRedemptions = () => {
20
20
 
21
21
  try {
22
22
  const result = await sdk.redemptions.getActiveRedemptions();
23
- console.log('Active redemptions fetched successfully:', result);
24
23
  return result;
25
24
  } catch (error) {
26
25
  console.error('Failed to fetch active redemptions:', error);
@@ -39,7 +38,6 @@ export const useRedemptions = () => {
39
38
 
40
39
  try {
41
40
  const result = await sdk.redemptions.getUserRedemptions();
42
- console.log('User redemptions fetched successfully:', result);
43
41
  return result;
44
42
  } catch (error) {
45
43
  console.error('Failed to fetch user redemptions:', error);
@@ -47,7 +45,7 @@ export const useRedemptions = () => {
47
45
  }
48
46
  }, [sdk, isInitialized, isAuthenticated]);
49
47
 
50
- const redeem = useCallback(async (redemptionId: string): Promise<RedemptionRedeemRequestResponseDTO> => {
48
+ const redeem = useCallback(async (redemptionId: string, onStatusUpdate?: OnStatusUpdateFn): Promise<RedemptionRedeemRequestResponseDTO> => {
51
49
  if (!isInitialized || !sdk) {
52
50
  throw new Error('SDK not initialized. Call initialize() first.');
53
51
  }
@@ -56,22 +54,13 @@ export const useRedemptions = () => {
56
54
  }
57
55
 
58
56
  try {
59
- console.log('Redeeming redemption:', redemptionId);
60
57
  const result = await sdk.redemptions.redeem(redemptionId);
61
-
62
- // Check if result has signing fields and sign transaction if required and signer is available
63
- console.log('Redemption processed successfully:', result);
64
-
65
58
 
66
59
  const txToken = result.senderTransaction?.actionable?.authToken;
67
60
  if (txToken && isSignerAvailable) {
68
- console.log('Transaction requires blockchain signing, processing with WebAuthn signer...');
69
-
70
61
  try {
71
- const signingResult: SubmissionResult = await signAndSubmitTransactionWithJWT(txToken);
72
- console.log('Blockchain signing result:', signingResult);
62
+ const signingResult: SubmissionResult = await signAndSubmitTransactionWithJWT(txToken, onStatusUpdate);
73
63
  if (signingResult.success) {
74
- console.log('Transaction signed successfully:', signingResult.transactionHash);
75
64
  // Return enhanced result with signing information
76
65
  return {
77
66
  ...result,
@@ -108,9 +97,7 @@ export const useRedemptions = () => {
108
97
  }
109
98
 
110
99
  try {
111
- console.log('Creating redemption offer with data:', redemptionData);
112
100
  const result = await sdk.redemptions.createRedemption(redemptionData);
113
- console.log('Redemption offer created successfully:', result);
114
101
  return result;
115
102
  } catch (error) {
116
103
  console.error('Failed to create redemption offer:', error);
@@ -125,7 +112,6 @@ export const useRedemptions = () => {
125
112
 
126
113
  try {
127
114
  const result = await sdk.redemptions.getAllRedemptions(active);
128
- console.log('All redemptions fetched successfully:', result);
129
115
  return result;
130
116
  } catch (error) {
131
117
  console.error('Failed to fetch all redemptions:', error);
@@ -140,7 +126,6 @@ export const useRedemptions = () => {
140
126
 
141
127
  try {
142
128
  const result = await sdk.redemptions.getRedemptionTypes();
143
- console.log('Redemption types fetched successfully:', result);
144
129
  return result;
145
130
  } catch (error) {
146
131
  console.error('Failed to fetch redemption types:', error);
@@ -155,7 +140,6 @@ export const useRedemptions = () => {
155
140
 
156
141
  try {
157
142
  const result = await sdk.redemptions.updateRedemption(redemptionId, redemptionData);
158
- console.log('Redemption updated successfully:', result);
159
143
  return result;
160
144
  } catch (error) {
161
145
  console.error('Failed to update redemption:', error);
@@ -170,7 +154,6 @@ export const useRedemptions = () => {
170
154
 
171
155
  try {
172
156
  const result = await sdk.redemptions.toggleRedemptionStatus(redemptionId);
173
- console.log('Redemption status toggled successfully:', result);
174
157
  return result;
175
158
  } catch (error) {
176
159
  console.error('Failed to toggle redemption status:', error);
@@ -188,6 +171,9 @@ export const useRedemptions = () => {
188
171
  updateRedemption,
189
172
  toggleRedemptionStatus,
190
173
  isAvailable: isInitialized && !!sdk?.redemptions,
174
+ // Expose signing status for UI feedback
175
+ signingStatus: currentStatus,
176
+ signingStatusMessage: statusMessage,
191
177
  };
192
178
  };
193
179
 
@@ -26,7 +26,6 @@ export const useTenants = () => {
26
26
 
27
27
  try {
28
28
  const result = await sdk.tenants.getClientConfig();
29
- console.log('Client config fetched successfully:', result);
30
29
  return result;
31
30
  } catch (error) {
32
31
  console.error('Failed to fetch client config:', error);
@@ -41,7 +40,6 @@ export const useTenants = () => {
41
40
 
42
41
  try {
43
42
  const result = await sdk.tenants.getLoginToken();
44
- console.log('Login token fetched successfully');
45
43
  return result;
46
44
  } catch (error) {
47
45
  console.error('Failed to fetch login token:', error);
@@ -56,7 +54,6 @@ export const useTenants = () => {
56
54
 
57
55
  try {
58
56
  const result = await sdk.tenants.getAdmins();
59
- console.log('Admins fetched successfully:', result);
60
57
  return result;
61
58
  } catch (error) {
62
59
  console.error('Failed to fetch admins:', error);
@@ -57,7 +57,6 @@ export const useTokens = () => {
57
57
 
58
58
  try {
59
59
  const result = await sdk.tokens.getTokens();
60
- console.log('Tokens fetched successfully:', result);
61
60
  return result;
62
61
  } catch (error) {
63
62
  console.error('Failed to fetch tokens:', error);
@@ -85,7 +84,6 @@ export const useTokens = () => {
85
84
 
86
85
  try {
87
86
  const result = await sdk.tokens.getActiveCreditToken();
88
- console.log('Active credit token fetched successfully:', result);
89
87
  return result;
90
88
  } catch (error) {
91
89
  console.error('Failed to fetch active credit token:', error);
@@ -113,7 +111,6 @@ export const useTokens = () => {
113
111
 
114
112
  try {
115
113
  const result = await sdk.tokens.getRewardTokens();
116
- console.log('Reward tokens fetched successfully:', result);
117
114
  return result;
118
115
  } catch (error) {
119
116
  console.error('Failed to fetch reward tokens:', error);
@@ -141,7 +138,6 @@ export const useTokens = () => {
141
138
 
142
139
  try {
143
140
  const result = await sdk.tokens.getTokenTypes();
144
- console.log('Token types fetched successfully:', result);
145
141
  return result;
146
142
  } catch (error) {
147
143
  console.error('Failed to fetch token types:', error);
@@ -169,7 +165,6 @@ export const useTokens = () => {
169
165
 
170
166
  try {
171
167
  const result = await sdk.tokens.getStatusTokens();
172
- console.log('Status tokens fetched successfully:', result);
173
168
  return result;
174
169
  } catch (error) {
175
170
  console.error('Failed to fetch status tokens:', error);
@@ -199,7 +194,6 @@ export const useTokens = () => {
199
194
 
200
195
  try {
201
196
  const result = await sdk.tokens.getTokenByContract(contractAddress, contractTokenId);
202
- console.log('Token by contract fetched successfully:', result);
203
197
  return result;
204
198
  } catch (error) {
205
199
  console.error('Failed to fetch token by contract:', error);
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useState, useRef, useEffect } from 'react';
2
2
  // import { usePersSDK } from '../providers/PersSDKProvider';
3
- import { PersSignerConfig } from '@explorins/pers-signer';
3
+ import { PersSignerConfig, SigningStatus, StatusCallback, StatusUpdateData } from '@explorins/pers-signer';
4
4
 
5
5
  // Import actual SDK types from the React Native-specific export
6
6
  type PersSignerSDK = import('@explorins/pers-signer/react-native').PersSignerSDK;
@@ -8,6 +8,16 @@ type SubmissionResult = import('@explorins/pers-signer/react-native').Submission
8
8
  type AuthenticatedUser = import('@explorins/pers-signer/react-native').AuthenticatedUser;
9
9
  type TransactionSigningResult = import('@explorins/pers-signer/react-native').TransactionSigningResult;
10
10
 
11
+ // Re-export signing status types from signer SDK for convenience
12
+ export { SigningStatus };
13
+ export type { StatusUpdateData };
14
+
15
+ /**
16
+ * Simple status callback function type for React Native consumers
17
+ * (Simplified from the signer SDK's object-based StatusCallback interface)
18
+ */
19
+ export type OnStatusUpdateFn = (status: SigningStatus, message: string, data?: StatusUpdateData) => void;
20
+
11
21
 
12
22
  // Dynamic import the signer SDK to avoid build issues with static dependencies
13
23
  let createPersSignerSDK: ((config: PersSignerConfig) => Promise<PersSignerSDK>) | null = null;
@@ -30,11 +40,15 @@ try {
30
40
  * @property {Function} signAndSubmitTransactionWithJWT - Main method to sign and submit transactions
31
41
  * @property {boolean} isSignerInitialized - Whether the signer SDK has been initialized
32
42
  * @property {boolean} isSignerAvailable - Whether signing functionality is fully available
43
+ * @property {SigningStatus | null} currentStatus - Current signing status for UI feedback
44
+ * @property {string | null} statusMessage - Human-readable status message
33
45
  */
34
46
  export interface TransactionSignerHook {
35
- signAndSubmitTransactionWithJWT: (jwt: string) => Promise<SubmissionResult>;
47
+ signAndSubmitTransactionWithJWT: (jwt: string, onStatusUpdate?: OnStatusUpdateFn) => Promise<SubmissionResult>;
36
48
  isSignerInitialized: boolean;
37
49
  isSignerAvailable: boolean;
50
+ currentStatus: SigningStatus | null;
51
+ statusMessage: string | null;
38
52
  }
39
53
 
40
54
  // Constants - TODO: Move to environment config later
@@ -220,6 +234,8 @@ const DEFAULT_ETHERS_PROVIDER = "https://sepolia.infura.io/v3/2781b4b5242343d5b0
220
234
  export const useTransactionSigner = (): TransactionSignerHook => {
221
235
  // const { isInitialized, isAuthenticated, user } = usePersSDK();
222
236
  const [isSignerInitialized, setIsSignerInitialized] = useState(false);
237
+ const [currentStatus, setCurrentStatus] = useState<SigningStatus | null>(null);
238
+ const [statusMessage, setStatusMessage] = useState<string | null>(null);
223
239
  const signerSDKRef = useRef<PersSignerSDK | null>(null);
224
240
 
225
241
  // Auto-initialize signer SDK when PERS SDK is ready
@@ -273,6 +289,7 @@ export const useTransactionSigner = (): TransactionSignerHook => {
273
289
  *
274
290
  * @param {string} jwt - JWT token containing transaction ID and user information
275
291
  * Must include: `transactionId`, `identifierEmail`, `tenantId`
292
+ * @param {StatusCallback} [onStatusUpdate] - Optional callback for real-time status updates
276
293
  * @returns {Promise<SubmissionResult>} Complete transaction result
277
294
  *
278
295
  * @throws {Error} 'Transaction signer not initialized' - Hook not ready
@@ -295,6 +312,15 @@ export const useTransactionSigner = (): TransactionSignerHook => {
295
312
  * ```
296
313
  *
297
314
  * @example
315
+ * **With Status Updates:**
316
+ * ```typescript
317
+ * const result = await signAndSubmitTransactionWithJWT(jwtToken, (status, message) => {
318
+ * console.log(`Status: ${status} - ${message}`);
319
+ * setStatusText(message);
320
+ * });
321
+ * ```
322
+ *
323
+ * @example
298
324
  * **With Error Handling:**
299
325
  * ```typescript
300
326
  * try {
@@ -329,7 +355,7 @@ export const useTransactionSigner = (): TransactionSignerHook => {
329
355
  *
330
356
  * @see {@link SubmissionResult} for detailed result structure
331
357
  */
332
- const signAndSubmitTransactionWithJWT = useCallback(async (jwt: string): Promise<SubmissionResult> => {
358
+ const signAndSubmitTransactionWithJWT = useCallback(async (jwt: string, onStatusUpdate?: OnStatusUpdateFn): Promise<SubmissionResult> => {
333
359
  if (!isSignerInitialized || !signerSDKRef.current) {
334
360
  throw new Error('Transaction signer not initialized');
335
361
  }
@@ -337,14 +363,25 @@ export const useTransactionSigner = (): TransactionSignerHook => {
337
363
  throw new Error('PERS Signer SDK not available. Blockchain signing is not supported.');
338
364
  }
339
365
 
366
+ // Create status callback wrapper that updates both hook state and calls user callback
367
+ const statusCallback: StatusCallback = {
368
+ onStatusUpdate: (status: SigningStatus, message: string, data?: StatusUpdateData) => {
369
+ setCurrentStatus(status);
370
+ setStatusMessage(message);
371
+ onStatusUpdate?.(status, message, data);
372
+ }
373
+ };
374
+
340
375
  try {
341
376
  // Use the actual SDK method that handles the complete sign + submit flow
342
- const submissionResult = await signerSDKRef.current.signAndSubmitPersTransaction(jwt);
377
+ const submissionResult = await signerSDKRef.current.signAndSubmitPersTransaction(jwt, statusCallback);
343
378
 
344
379
  return submissionResult;
345
380
 
346
381
  } catch (error) {
347
382
  console.error('[useTransactionSigner] JWT transaction signing failed:', error);
383
+ setCurrentStatus(SigningStatus.ERROR);
384
+ setStatusMessage(error instanceof Error ? error.message : 'Transaction failed');
348
385
  throw error; // Re-throw to maintain error handling upstream
349
386
  }
350
387
  }, [isSignerInitialized]);
@@ -357,6 +394,7 @@ export const useTransactionSigner = (): TransactionSignerHook => {
357
394
  * from authentication to blockchain submission in a single call.
358
395
  *
359
396
  * @param {string} jwt - JWT token with transaction and user data
397
+ * @param {StatusCallback} [onStatusUpdate] - Optional callback for real-time status updates
360
398
  * @returns {Promise<SubmissionResult>} Transaction result with hash and status
361
399
  */
362
400
  signAndSubmitTransactionWithJWT,
@@ -404,6 +442,38 @@ export const useTransactionSigner = (): TransactionSignerHook => {
404
442
  * ```
405
443
  */
406
444
  isSignerAvailable: isSignerInitialized && !!createPersSignerSDK,
445
+
446
+ /**
447
+ * Current signing status for UI feedback
448
+ *
449
+ * Tracks the current state of the signing process. Use this to show
450
+ * progress indicators or status messages during transaction signing.
451
+ *
452
+ * Possible values: 'initializing', 'authenticating', 'preparing',
453
+ * 'signing', 'submitting', 'completed', 'error', 'expired'
454
+ *
455
+ * @example
456
+ * ```typescript
457
+ * const { currentStatus, statusMessage } = useTransactionSigner();
458
+ *
459
+ * return (
460
+ * <View>
461
+ * {currentStatus && (
462
+ * <Text>Status: {statusMessage}</Text>
463
+ * )}
464
+ * </View>
465
+ * );
466
+ * ```
467
+ */
468
+ currentStatus,
469
+
470
+ /**
471
+ * Human-readable status message
472
+ *
473
+ * Provides a user-friendly description of the current signing status.
474
+ * Updates in real-time as the transaction progresses.
475
+ */
476
+ statusMessage,
407
477
  };
408
478
  };
409
479
 
@@ -1,6 +1,6 @@
1
1
  import { useCallback } from 'react';
2
2
  import { usePersSDK } from '../providers/PersSDKProvider';
3
- import { useTransactionSigner } from './useTransactionSigner';
3
+ import { useTransactionSigner, OnStatusUpdateFn } from './useTransactionSigner';
4
4
  import type {
5
5
  TransactionRequestDTO,
6
6
  TransactionRequestResponseDTO,
@@ -47,7 +47,7 @@ import type {
47
47
  */
48
48
  export const useTransactions = () => {
49
49
  const { sdk, isInitialized, isAuthenticated } = usePersSDK();
50
- const { signAndSubmitTransactionWithJWT, isSignerAvailable } = useTransactionSigner();
50
+ const { signAndSubmitTransactionWithJWT, isSignerAvailable, currentStatus, statusMessage } = useTransactionSigner();
51
51
 
52
52
  if (!isAuthenticated && isInitialized) {
53
53
  console.warn('SDK not authenticated. Some transaction operations may fail.');
@@ -71,11 +71,13 @@ export const useTransactions = () => {
71
71
  * recipient: '0x123...',
72
72
  * tokenId: 'token-123'
73
73
  * };
74
- * const result = await createTransaction(request);
74
+ * const result = await createTransaction(request, (status, message) => {
75
+ * console.log(`Status: ${status} - ${message}`);
76
+ * });
75
77
  * console.log('Transaction created:', result);
76
78
  * ```
77
79
  */
78
- const createTransaction = useCallback(async (request: TransactionRequestDTO): Promise<TransactionRequestResponseDTO> => {
80
+ const createTransaction = useCallback(async (request: TransactionRequestDTO, onStatusUpdate?: OnStatusUpdateFn): Promise<TransactionRequestResponseDTO> => {
79
81
  if (!isInitialized || !sdk) {
80
82
  throw new Error('SDK not initialized. Call initialize() first.');
81
83
  }
@@ -83,13 +85,10 @@ export const useTransactions = () => {
83
85
  try {
84
86
  const result = await sdk.transactions.createTransaction(request);
85
87
 
86
- console.log('Transaction created successfully:', result);
87
-
88
88
  // Check if transaction requires signing (contains actionable authToken)
89
89
  // Type assertion needed as TransactionRequestResponseDTO type may not include all dynamic properties
90
90
  const txToken = result?.actionable?.authToken;
91
91
  if (txToken) {
92
- console.log('[useTransactions] Transaction requires signing, attempting automatic signature...');
93
92
 
94
93
  try {
95
94
  if (!isSignerAvailable) {
@@ -98,7 +97,7 @@ export const useTransactions = () => {
98
97
  }
99
98
 
100
99
  // Automatically sign the transaction using the authToken
101
- const signingResult = await signAndSubmitTransactionWithJWT(txToken);
100
+ const signingResult = await signAndSubmitTransactionWithJWT(txToken, onStatusUpdate);
102
101
 
103
102
  if (signingResult.success) {
104
103
  console.log('[useTransactions] Transaction signed successfully:', signingResult.transactionHash);
@@ -144,7 +143,6 @@ export const useTransactions = () => {
144
143
 
145
144
  try {
146
145
  const result = await sdk.transactions.getTransactionById(transactionId);
147
- console.log('Transaction fetched successfully:', result);
148
146
  return result;
149
147
  } catch (error) {
150
148
  console.error('Failed to fetch transaction:', error);
@@ -174,7 +172,6 @@ export const useTransactions = () => {
174
172
 
175
173
  try {
176
174
  const result = await sdk.transactions.getUserTransactionHistory(role);
177
- console.log('Transaction history fetched successfully:', result);
178
175
  return result;
179
176
  } catch (error) {
180
177
  console.error('Failed to fetch transaction history:', error);
@@ -203,7 +200,6 @@ export const useTransactions = () => {
203
200
 
204
201
  try {
205
202
  const result = await sdk.transactions.getPaginatedTransactions(params);
206
- console.log('Paginated transactions fetched successfully:', result);
207
203
  return result;
208
204
  } catch (error) {
209
205
  console.error('Failed to fetch paginated transactions:', error);
@@ -218,7 +214,6 @@ export const useTransactions = () => {
218
214
 
219
215
  try {
220
216
  const result = await sdk.transactions.exportTransactionsCSV();
221
- console.log('Transactions CSV exported successfully');
222
217
  return result;
223
218
  } catch (error) {
224
219
  console.error('Failed to export transactions CSV:', error);
@@ -234,6 +229,9 @@ export const useTransactions = () => {
234
229
  getPaginatedTransactions,
235
230
  exportTransactionsCSV,
236
231
  isAvailable: isInitialized && !!sdk?.transactions,
232
+ // Expose signing status for UI feedback
233
+ signingStatus: currentStatus,
234
+ signingStatusMessage: statusMessage,
237
235
  };
238
236
  };
239
237
 
@@ -12,7 +12,6 @@ export const useUserStatus = () => {
12
12
 
13
13
  try {
14
14
  const result = await sdk.userStatus.getUserStatusTypes();
15
- console.log('User status types fetched successfully:', result);
16
15
  return result;
17
16
  } catch (error) {
18
17
  console.error('Failed to fetch user status types:', error);
@@ -30,7 +29,6 @@ export const useUserStatus = () => {
30
29
 
31
30
  try {
32
31
  const result = await sdk.userStatus.getEarnedUserStatus();
33
- console.log('Earned user status fetched successfully:', result);
34
32
  return result;
35
33
  } catch (error) {
36
34
  console.error('Failed to fetch earned user status:', error);
@@ -46,7 +44,6 @@ export const useUserStatus = () => {
46
44
 
47
45
  try {
48
46
  const result = await sdk.userStatus.createUserStatusType(userStatusType);
49
- console.log('User status type created successfully:', result);
50
47
  return result;
51
48
  } catch (error) {
52
49
  console.error('Failed to create user status type:', error);
@@ -16,7 +16,6 @@ export const useUsers = () => {
16
16
 
17
17
  try {
18
18
  const result = await sdk.users.getCurrentUser();
19
- console.log('Current user fetched successfully:', result);
20
19
  return result;
21
20
  } catch (error) {
22
21
  console.error('Failed to fetch current user:', error);
@@ -34,7 +33,6 @@ export const useUsers = () => {
34
33
 
35
34
  try {
36
35
  const result = await sdk.users.updateCurrentUser(userData);
37
- console.log('Current user updated successfully:', result);
38
36
  return result;
39
37
  } catch (error) {
40
38
  console.error('Failed to update current user:', error);
@@ -49,7 +47,6 @@ export const useUsers = () => {
49
47
 
50
48
  try {
51
49
  const result = await sdk.users.getUserById(userId);
52
- console.log('User fetched successfully:', result);
53
50
  return result;
54
51
  } catch (error) {
55
52
  console.error('Failed to fetch user:', error);
@@ -64,7 +61,6 @@ export const useUsers = () => {
64
61
 
65
62
  try {
66
63
  const result = await sdk.users.getAllUsersPublic(filter);
67
- console.log('Public users fetched successfully:', result);
68
64
  return result;
69
65
  } catch (error) {
70
66
  console.error('Failed to fetch public users:', error);
@@ -80,7 +76,6 @@ export const useUsers = () => {
80
76
 
81
77
  try {
82
78
  const result = await sdk.users.getAllUsers();
83
- console.log('All users fetched successfully:', result);
84
79
  return result;
85
80
  } catch (error) {
86
81
  console.error('Failed to fetch all users:', error);
@@ -95,7 +90,6 @@ export const useUsers = () => {
95
90
 
96
91
  try {
97
92
  const result = await sdk.users.updateUser(userId, userData);
98
- console.log('User updated successfully:', result);
99
93
  return result;
100
94
  } catch (error) {
101
95
  console.error('Failed to update user:', error);
@@ -110,7 +104,6 @@ export const useUsers = () => {
110
104
 
111
105
  try {
112
106
  const result = await sdk.users.toggleUserStatus(user);
113
- console.log('User status toggled successfully:', result);
114
107
  return result;
115
108
  } catch (error) {
116
109
  console.error('Failed to toggle user status:', error);