@explorins/pers-sdk-react-native 2.1.3 → 2.1.6

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 (51) hide show
  1. package/README.md +7 -7
  2. package/dist/hooks/index.d.ts +6 -0
  3. package/dist/hooks/index.d.ts.map +1 -1
  4. package/dist/hooks/index.js +1 -0
  5. package/dist/hooks/useAnalytics.d.ts +37 -14
  6. package/dist/hooks/useAnalytics.d.ts.map +1 -1
  7. package/dist/hooks/useAnalytics.js +239 -19
  8. package/dist/hooks/useCampaigns.d.ts +14 -6
  9. package/dist/hooks/useCampaigns.d.ts.map +1 -1
  10. package/dist/hooks/useCampaigns.js +144 -10
  11. package/dist/hooks/useEvents.d.ts +17 -5
  12. package/dist/hooks/useEvents.d.ts.map +1 -1
  13. package/dist/hooks/useEvents.js +17 -5
  14. package/dist/hooks/useRedemptions.d.ts +5 -2
  15. package/dist/hooks/useRedemptions.d.ts.map +1 -1
  16. package/dist/hooks/useRedemptions.js +53 -2
  17. package/dist/hooks/useTokenBalances.d.ts +24 -0
  18. package/dist/hooks/useTokenBalances.d.ts.map +1 -1
  19. package/dist/hooks/useTokenBalances.js +42 -2
  20. package/dist/hooks/useTransactions.d.ts +8 -5
  21. package/dist/hooks/useTransactions.d.ts.map +1 -1
  22. package/dist/hooks/useTransactions.js +70 -27
  23. package/dist/hooks/useTriggerSources.d.ts +76 -0
  24. package/dist/hooks/useTriggerSources.d.ts.map +1 -0
  25. package/dist/hooks/useTriggerSources.js +272 -0
  26. package/dist/hooks/useUsers.d.ts +5 -4
  27. package/dist/hooks/useUsers.d.ts.map +1 -1
  28. package/dist/hooks/useUsers.js +47 -8
  29. package/dist/hooks/useWeb3.d.ts +6 -5
  30. package/dist/hooks/useWeb3.d.ts.map +1 -1
  31. package/dist/hooks/useWeb3.js +23 -10
  32. package/dist/index.d.ts +12 -3
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +5500 -893
  35. package/dist/index.js.map +1 -1
  36. package/dist/providers/PersSDKProvider.d.ts +38 -0
  37. package/dist/providers/PersSDKProvider.d.ts.map +1 -1
  38. package/dist/providers/PersSDKProvider.js +29 -1
  39. package/package.json +3 -2
  40. package/src/hooks/index.ts +17 -1
  41. package/src/hooks/useAnalytics.ts +268 -21
  42. package/src/hooks/useCampaigns.ts +176 -14
  43. package/src/hooks/useEvents.ts +17 -5
  44. package/src/hooks/useRedemptions.ts +66 -3
  45. package/src/hooks/useTokenBalances.ts +60 -2
  46. package/src/hooks/useTransactions.ts +84 -29
  47. package/src/hooks/useTriggerSources.ts +301 -0
  48. package/src/hooks/useUsers.ts +51 -9
  49. package/src/hooks/useWeb3.ts +28 -13
  50. package/src/index.ts +33 -3
  51. package/src/providers/PersSDKProvider.tsx +38 -1
@@ -9,8 +9,10 @@ import type {
9
9
  TokenMetadata,
10
10
  AccountOwnedTokensResult
11
11
  } from '@explorins/pers-sdk/web3';
12
- import type { ChainData } from '@explorins/pers-sdk/web3-chain';
13
- import type { TokenDTO } from '@explorins/pers-shared';
12
+ import type { TokenDTO } from '@explorins/pers-sdk/token';
13
+
14
+ // ChainData type - matches what Web3Manager.getChainDataById returns
15
+ type ChainData = Awaited<ReturnType<Web3Manager['getChainDataById']>>;
14
16
 
15
17
  // Re-export for convenience
16
18
  export type { AccountOwnedTokensResult } from '@explorins/pers-sdk/web3';
@@ -161,27 +163,40 @@ export const useWeb3 = () => {
161
163
  }
162
164
  }, [web3, isInitialized]);
163
165
 
164
- const resolveIPFSUrl = useCallback(async (url: string, chainId: number): Promise<string> => {
165
- if (!isInitialized || !web3) {
166
+ /**
167
+ * Resolve IPFS URL to HTTP gateway URL
168
+ *
169
+ * @deprecated Use `sdk.tenant.resolveIPFSUrl()` directly - IPFS is chain-agnostic
170
+ * @param url - IPFS URL to resolve (ipfs://...)
171
+ * @returns Promise resolving to HTTP gateway URL
172
+ */
173
+ const resolveIPFSUrl = useCallback(async (url: string): Promise<string> => {
174
+ if (!isInitialized || !sdk) {
166
175
  throw new Error('SDK not initialized. Call initialize() first.');
167
176
  }
168
177
 
169
178
  try {
170
- const result = await web3.resolveIPFSUrl(url, chainId);
179
+ const result = await sdk.tenants.resolveIPFSUrl(url);
171
180
  return result;
172
181
  } catch (error) {
173
182
  console.error('Failed to resolve IPFS URL:', error);
174
183
  throw error;
175
184
  }
176
- }, [web3, isInitialized]);
185
+ }, [sdk, isInitialized]);
177
186
 
178
- const fetchAndProcessMetadata = useCallback(async (tokenUri: string, chainId: number): Promise<TokenMetadata | null> => {
187
+ /**
188
+ * Fetch and process token metadata from a URI
189
+ *
190
+ * @param tokenUri - Token URI to fetch metadata from
191
+ * @returns Promise resolving to processed metadata or null
192
+ */
193
+ const fetchAndProcessMetadata = useCallback(async (tokenUri: string): Promise<TokenMetadata | null> => {
179
194
  if (!isInitialized || !web3) {
180
195
  throw new Error('SDK not initialized. Call initialize() first.');
181
196
  }
182
197
 
183
198
  try {
184
- const result = await web3.fetchAndProcessMetadata(tokenUri, chainId);
199
+ const result = await web3.fetchAndProcessMetadata(tokenUri);
185
200
  return result;
186
201
  } catch (error) {
187
202
  console.error('Failed to fetch and process metadata:', error);
@@ -189,7 +204,7 @@ export const useWeb3 = () => {
189
204
  }
190
205
  }, [web3, isInitialized]);
191
206
 
192
- const getChainDataById = useCallback(async (chainId: number): Promise<ChainData | null> => {
207
+ const getChainDataById = useCallback(async (chainId: number): Promise<ChainData> => {
193
208
  if (!isInitialized || !web3) {
194
209
  throw new Error('SDK not initialized. Call initialize() first.');
195
210
  }
@@ -255,7 +270,7 @@ export const useWeb3 = () => {
255
270
  *
256
271
  * @param accountAddress - Any valid blockchain address (wallet, contract, etc.)
257
272
  * @param token - Token definition (from getRewardTokens, getStatusTokens, etc.)
258
- * @param maxTokens - Maximum tokens to retrieve (default: 50)
273
+ * @param maxTokens - Maximum tokens to retrieve (default: 100, max: 100)
259
274
  * @returns Promise resolving to result with owned tokens
260
275
  * @throws Error if SDK is not initialized
261
276
  *
@@ -277,7 +292,7 @@ export const useWeb3 = () => {
277
292
  const getAccountOwnedTokensFromContract = useCallback(async (
278
293
  accountAddress: string,
279
294
  token: TokenDTO,
280
- maxTokens: number = 50
295
+ maxTokens: number = 100
281
296
  ): Promise<AccountOwnedTokensResult> => {
282
297
  if (!isInitialized || !web3) {
283
298
  throw new Error('SDK not initialized. Call initialize() first.');
@@ -295,13 +310,13 @@ export const useWeb3 = () => {
295
310
  *
296
311
  * @param accountAddress - Any valid blockchain address (wallet, contract, etc.)
297
312
  * @param token - Token definition
298
- * @param maxTokens - Maximum tokens to retrieve (default: 50)
313
+ * @param maxTokens - Maximum tokens to retrieve (default: 100, max: 100)
299
314
  * @returns TokenCollectionRequest ready for getTokenCollection()
300
315
  */
301
316
  const buildCollectionRequest = useCallback((
302
317
  accountAddress: string,
303
318
  token: TokenDTO,
304
- maxTokens: number = 50
319
+ maxTokens: number = 100
305
320
  ): TokenCollectionRequest => {
306
321
  if (!web3) {
307
322
  throw new Error('SDK not initialized. Call initialize() first.');
package/src/index.ts CHANGED
@@ -262,11 +262,20 @@ export {
262
262
  useFiles,
263
263
  useAnalytics,
264
264
  useDonations,
265
- useEvents
265
+ useEvents,
266
+ useTriggerSources
266
267
  } from './hooks';
267
268
 
268
269
  // Re-export signing status types for convenience
269
- export type { OnStatusUpdateFn, StatusUpdateData, SigningStatusType, TransactionSigningResult, SubmissionResult, AuthenticatedUser } from './hooks';
270
+ export type {
271
+ TransactionSignerHook,
272
+ OnStatusUpdateFn,
273
+ StatusUpdateData,
274
+ SigningStatusType,
275
+ TransactionSigningResult,
276
+ SubmissionResult,
277
+ AuthenticatedUser
278
+ } from './hooks';
270
279
 
271
280
  // Re-export event types for convenience
272
281
  export type { EventsHook, PersEvent, EventHandler, EventFilter, Unsubscribe } from './hooks';
@@ -274,6 +283,21 @@ export type { EventsHook, PersEvent, EventHandler, EventFilter, Unsubscribe } fr
274
283
  // Re-export token balance types for convenience
275
284
  export type { TokenBalanceWithToken, UseTokenBalancesOptions, UseTokenBalancesResult } from './hooks';
276
285
 
286
+ // Re-export campaign types for convenience
287
+ export type { CampaignClaimFilters, CampaignHook } from './hooks';
288
+
289
+ // Re-export redemption types for convenience
290
+ export type { RedemptionRedeemFilters, RedemptionHook } from './hooks';
291
+
292
+ // Re-export transaction types for convenience
293
+ export type { TransactionQueryOptions, TransactionHook } from './hooks';
294
+
295
+ // Re-export trigger source types for convenience
296
+ export type { TriggerSourceQueryOptions, TriggerSourceHook } from './hooks';
297
+
298
+ // Re-export analytics types for convenience
299
+ export type { AnalyticsHook } from './hooks';
300
+
277
301
  // ==============================================================================
278
302
  // PLATFORM ADAPTERS
279
303
  // ==============================================================================
@@ -284,9 +308,15 @@ export type { TokenBalanceWithToken, UseTokenBalancesOptions, UseTokenBalancesRe
284
308
  * Provides platform-specific networking with proper error handling, timeout management,
285
309
  * and React Native compatibility. Automatically handles headers, authentication tokens,
286
310
  * and response parsing.
311
+ *
312
+ * @see {@link ReactNativeHttpClient} - The HTTP client implementation
313
+ * @see {@link HttpClient} - The HTTP client interface
314
+ * @see {@link RequestOptions} - Request configuration options
287
315
  */
288
316
  export {
289
- ReactNativeHttpClient
317
+ ReactNativeHttpClient,
318
+ type HttpClient,
319
+ type RequestOptions
290
320
  } from './providers/react-native-http-client';
291
321
 
292
322
  // ==============================================================================
@@ -24,6 +24,15 @@ import type {
24
24
  // Re-export PersConfig for external use
25
25
  export type { PersConfig } from '@explorins/pers-sdk/core';
26
26
 
27
+ /**
28
+ * Context interface for PERS SDK React Native integration
29
+ *
30
+ * @property sdk - Main SDK instance (null until initialized)
31
+ * @property authProvider - Platform-specific auth provider
32
+ * @property isInitialized - Whether SDK has been initialized
33
+ * @property isAuthenticated - Whether user is currently authenticated
34
+ * @property user - Current user data (null if not authenticated)
35
+ */
27
36
  export interface PersSDKContext {
28
37
  // Main SDK instance
29
38
  sdk: PersSDK | null;
@@ -46,7 +55,35 @@ export interface PersSDKContext {
46
55
  // Create the context
47
56
  const SDKContext = createContext<PersSDKContext | null>(null);
48
57
 
49
- // Provider component
58
+ /**
59
+ * PERS SDK Provider for React Native
60
+ *
61
+ * Wraps your app to provide SDK context to all child components.
62
+ * Handles platform-specific initialization (DPoP, storage, etc.).
63
+ *
64
+ * @param config - SDK configuration (see PersConfig)
65
+ * @param config.apiProjectKey - Your PERS project key (required)
66
+ * @param config.environment - 'staging' | 'production' (default: 'staging')
67
+ * @param config.captureWalletEvents - Enable real-time blockchain events (default: true)
68
+ * @param config.dpop - DPoP configuration for enhanced security
69
+ *
70
+ * @example Basic usage
71
+ * ```tsx
72
+ * <PersSDKProvider config={{ apiProjectKey: 'my-project' }}>
73
+ * <App />
74
+ * </PersSDKProvider>
75
+ * ```
76
+ *
77
+ * @example Disable wallet events
78
+ * ```tsx
79
+ * <PersSDKProvider config={{
80
+ * apiProjectKey: 'my-project',
81
+ * captureWalletEvents: false // Disable auto-connect to blockchain events
82
+ * }}>
83
+ * <App />
84
+ * </PersSDKProvider>
85
+ * ```
86
+ */
50
87
  export const PersSDKProvider: React.FC<{
51
88
  children: ReactNode;
52
89
  config?: PersConfig;