@explorins/pers-sdk-react-native 2.1.7 → 2.1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@explorins/pers-sdk-react-native",
3
- "version": "2.1.7",
3
+ "version": "2.1.8",
4
4
  "description": "React Native SDK for PERS Platform - Tourism Loyalty System with Blockchain Transaction Signing and WebAuthn Authentication",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -37,7 +37,7 @@
37
37
  "author": "eXplorins",
38
38
  "license": "MIT",
39
39
  "dependencies": {
40
- "@explorins/pers-sdk": "^2.1.15",
40
+ "@explorins/pers-sdk": "^2.1.16",
41
41
  "@explorins/pers-signer": "^1.0.33",
42
42
  "buffer": "^6.0.3",
43
43
  "ethers": "^6.15.0",
@@ -34,7 +34,11 @@ export interface UseTokenBalancesOptions {
34
34
  availableTokens?: TokenDTO[];
35
35
  /** Whether to automatically load balances on mount/auth/token changes */
36
36
  autoLoad?: boolean;
37
- /** Optional refresh interval in milliseconds (0 = disabled) */
37
+ /**
38
+ * Fallback polling interval in milliseconds (0 = disabled)
39
+ * @deprecated Use wallet events instead (refreshOnWalletEvents). Polling kept as fallback only.
40
+ * @default 0
41
+ */
38
42
  refreshInterval?: number;
39
43
  /**
40
44
  * Auto-refresh balances when wallet events are received (Transfer, Approval, etc.)
@@ -127,18 +131,7 @@ export interface UseTokenBalancesResult {
127
131
  * ```
128
132
  *
129
133
  * @example
130
- * **With Auto-Refresh:**
131
- * ```typescript
132
- * const { tokenBalances, isLoading } = useTokenBalances({
133
- * accountAddress: walletAddress!,
134
- * availableTokens,
135
- * autoLoad: true,
136
- * refreshInterval: 30000 // Refresh every 30 seconds
137
- * });
138
- * ```
139
- *
140
- * @example
141
- * **With Wallet Events (Real-time):**
134
+ * **With Wallet Events (Real-time):
142
135
  * ```typescript
143
136
  * // Auto-refresh on Transfer, Approval, and other blockchain events
144
137
  * const { tokenBalances } = useTokenBalances({
@@ -297,30 +290,19 @@ export function useTokenBalances(options: UseTokenBalancesOptions): UseTokenBala
297
290
  }
298
291
  }, [autoLoad, isAvailable, availableTokens.length, loadBalances]);
299
292
 
300
- // Event-driven refresh: listen for transaction events instead of polling
293
+ // Deprecated: Fallback polling interval (prefer wallet events)
294
+ // Kept for backward compatibility and edge cases where events might not work
301
295
  useEffect(() => {
302
- if (!sdk || refreshInterval <= 0 || !isAvailable) return;
303
-
304
- // Subscribe to transaction domain events
305
- const unsubscribe = sdk.events.subscribe((event) => {
306
- if (event.domain === 'transaction' && event.type === 'transaction_completed') {
307
- console.log('[useTokenBalances] Transaction completed, refreshing balances...');
308
- loadBalances();
309
- }
310
- }, { domains: ['transaction'] });
296
+ if (refreshInterval <= 0 || !isAvailable) return;
311
297
 
312
- // Also set up a fallback polling interval (much longer than before)
313
- // This handles cases where events might be missed
314
- const fallbackInterval = Math.max(refreshInterval, 60000); // Minimum 1 minute
315
298
  const intervalId = setInterval(() => {
316
299
  loadBalances();
317
- }, fallbackInterval);
300
+ }, refreshInterval);
318
301
 
319
302
  return () => {
320
- unsubscribe();
321
303
  clearInterval(intervalId);
322
304
  };
323
- }, [sdk, refreshInterval, isAvailable, loadBalances]);
305
+ }, [refreshInterval, isAvailable, loadBalances]);
324
306
 
325
307
  // Wallet events refresh: listen for real-time blockchain events
326
308
  // Refreshes on ANY wallet domain event (Transfer, TransferSingle, etc.)