@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,314 +1,314 @@
1
- import { useCallback } from 'react';
2
- import { usePersSDK } from '../providers/PersSDKProvider';
3
- import type { TokenDTO, TokenMetadataDTO, PaginatedResponseDTO, TokenMetadataFilterOptions, RewardsFilterOptions, StampsFilterOptions } from '@explorins/pers-sdk';
4
-
5
- /**
6
- * React hook for token operations in the PERS SDK
7
- *
8
- * Provides methods for fetching various types of tokens including credit, reward, and status tokens.
9
- * Supports both general token queries and specific contract-based token retrieval.
10
- *
11
- * @returns Token hook with methods for token management
12
- *
13
- * @example
14
- * ```typescript
15
- * function TokensComponent() {
16
- * const { getTokens, getActiveCreditToken, getRewardTokens } = useTokens();
17
- *
18
- * const loadTokens = async () => {
19
- * try {
20
- * const tokens = await getTokens();
21
- * const creditToken = await getActiveCreditToken();
22
- * console.log('Loaded tokens:', tokens);
23
- * console.log('Active credit token:', creditToken);
24
- * } catch (error) {
25
- * console.error('Failed to load tokens:', error);
26
- * }
27
- * };
28
- *
29
- * return <button onClick={loadTokens}>Load Tokens</button>;
30
- * }
31
- * ```
32
- */
33
- export const useTokens = () => {
34
- const { sdk, isInitialized, isAuthenticated } = usePersSDK();
35
-
36
- if (!isAuthenticated && isInitialized) {
37
- console.warn('SDK not authenticated. Some token operations may fail.');
38
- }
39
-
40
- /**
41
- * Retrieves all tokens available to the current user
42
- *
43
- * @returns Promise resolving to array of tokens
44
- * @throws Error if SDK is not initialized
45
- *
46
- * @example
47
- * ```typescript
48
- * const { getTokens } = useTokens();
49
- * const tokens = await getTokens();
50
- * console.log('Available tokens:', tokens);
51
- * ```
52
- */
53
- const getTokens = useCallback(async (): Promise<PaginatedResponseDTO<TokenDTO>> => {
54
- if (!isInitialized || !sdk) {
55
- throw new Error('SDK not initialized. Call initialize() first.');
56
- }
57
-
58
- try {
59
- const result = await sdk.tokens.getTokens();
60
- return result;
61
- } catch (error) {
62
- console.error('Failed to fetch tokens:', error);
63
- throw error;
64
- }
65
- }, [sdk, isInitialized]);
66
-
67
- /**
68
- * Retrieves the currently active credit token
69
- *
70
- * @returns Promise resolving to active credit token
71
- * @throws Error if SDK is not initialized
72
- *
73
- * @example
74
- * ```typescript
75
- * const { getActiveCreditToken } = useTokens();
76
- * const creditToken = await getActiveCreditToken();
77
- * console.log('Active credit token:', creditToken.name);
78
- * ```
79
- */
80
- const getActiveCreditToken = useCallback(async (): Promise<TokenDTO> => {
81
- if (!isInitialized || !sdk) {
82
- throw new Error('SDK not initialized. Call initialize() first.');
83
- }
84
-
85
- try {
86
- const result = await sdk.tokens.getActiveCreditToken();
87
- return result;
88
- } catch (error) {
89
- console.error('Failed to fetch active credit token:', error);
90
- throw error;
91
- }
92
- }, [sdk, isInitialized]);
93
-
94
- /**
95
- * Retrieves all reward tokens available in the system
96
- *
97
- * @returns Promise resolving to array of reward tokens
98
- * @throws Error if SDK is not initialized
99
- *
100
- * @example
101
- * ```typescript
102
- * const { getRewardTokens } = useTokens();
103
- * const rewardTokens = await getRewardTokens();
104
- * console.log('Reward tokens:', rewardTokens);
105
- * ```
106
- */
107
- const getRewardTokens = useCallback(async (): Promise<PaginatedResponseDTO<TokenDTO>> => {
108
- if (!isInitialized || !sdk) {
109
- throw new Error('SDK not initialized. Call initialize() first.');
110
- }
111
-
112
- try {
113
- const result = await sdk.tokens.getRewardTokens();
114
- return result;
115
- } catch (error) {
116
- console.error('Failed to fetch reward tokens:', error);
117
- throw error;
118
- }
119
- }, [sdk, isInitialized]);
120
-
121
- /**
122
- * Retrieves all available token types in the system
123
- *
124
- * @returns Promise resolving to array of token types
125
- * @throws Error if SDK is not initialized
126
- *
127
- * @example
128
- * ```typescript
129
- * const { getTokenTypes } = useTokens();
130
- * const types = await getTokenTypes();
131
- * console.log('Token types:', types);
132
- * ```
133
- */
134
- const getTokenTypes = useCallback(async (): Promise<any> => {
135
- if (!isInitialized || !sdk) {
136
- throw new Error('SDK not initialized. Call initialize() first.');
137
- }
138
-
139
- try {
140
- const result = await sdk.tokens.getTokenTypes();
141
- return result;
142
- } catch (error) {
143
- console.error('Failed to fetch token types:', error);
144
- throw error;
145
- }
146
- }, [sdk, isInitialized]);
147
-
148
- /**
149
- * Retrieves all status tokens (tokens that represent user status/achievements)
150
- *
151
- * @returns Promise resolving to array of status tokens
152
- * @throws Error if SDK is not initialized
153
- *
154
- * @example
155
- * ```typescript
156
- * const { getStatusTokens } = useTokens();
157
- * const statusTokens = await getStatusTokens();
158
- * console.log('Status tokens:', statusTokens);
159
- * ```
160
- */
161
- const getStatusTokens = useCallback(async (): Promise<PaginatedResponseDTO<TokenDTO>> => {
162
- if (!isInitialized || !sdk) {
163
- throw new Error('SDK not initialized. Call initialize() first.');
164
- }
165
-
166
- try {
167
- const result = await sdk.tokens.getStatusTokens();
168
- return result;
169
- } catch (error) {
170
- console.error('Failed to fetch status tokens:', error);
171
- throw error;
172
- }
173
- }, [sdk, isInitialized]);
174
-
175
- /**
176
- * Retrieves a specific token by its contract address and optional token ID
177
- *
178
- * @param contractAddress - The contract address of the token
179
- * @param contractTokenId - Optional specific token ID within the contract
180
- * @returns Promise resolving to the token data
181
- * @throws Error if SDK is not initialized
182
- *
183
- * @example
184
- * ```typescript
185
- * const { getTokenByContract } = useTokens();
186
- * const token = await getTokenByContract('0x123...', 'token-1');
187
- * console.log('Token from contract:', token);
188
- * ```
189
- */
190
- const getTokenByContract = useCallback(async (contractAddress: string, contractTokenId?: string | null): Promise<TokenDTO> => {
191
- if (!isInitialized || !sdk) {
192
- throw new Error('SDK not initialized. Call initialize() first.');
193
- }
194
-
195
- try {
196
- const result = await sdk.tokens.getTokenByContract(contractAddress, contractTokenId);
197
- return result;
198
- } catch (error) {
199
- console.error('Failed to fetch token by contract:', error);
200
- throw error;
201
- }
202
- }, [sdk, isInitialized]);
203
-
204
- /**
205
- * Get all token metadata with filtering and pagination
206
- *
207
- * Retrieves token metadata (rewards/stamps) with server-side filtering.
208
- * Use tokenType: 'ERC1155' for rewards, 'ERC721' for stamps.
209
- *
210
- * @param options - Filter and pagination options
211
- * @returns Promise resolving to paginated token metadata
212
- * @throws Error if SDK is not initialized
213
- *
214
- * @example
215
- * ```typescript
216
- * const { getTokenMetadata } = useTokens();
217
- * const rewards = await getTokenMetadata({
218
- * tokenType: 'ERC1155',
219
- * active: true,
220
- * limit: 10
221
- * });
222
- * ```
223
- */
224
- const getTokenMetadata = useCallback(async (options?: TokenMetadataFilterOptions): Promise<PaginatedResponseDTO<TokenMetadataDTO>> => {
225
- if (!isInitialized || !sdk) {
226
- throw new Error('SDK not initialized. Call initialize() first.');
227
- }
228
-
229
- try {
230
- const result = await sdk.tokens.getTokenMetadata(options);
231
- return result;
232
- } catch (error) {
233
- console.error('Failed to fetch token metadata:', error);
234
- throw error;
235
- }
236
- }, [sdk, isInitialized]);
237
-
238
- /**
239
- * Get rewards (ERC1155 token metadata) with filtering and pagination
240
- *
241
- * Convenience method for fetching reward metadata. Rewards are ERC1155 tokens
242
- * that represent collectible items, vouchers, or other redeemable rewards.
243
- *
244
- * @param options - Filter and pagination options
245
- * @returns Promise resolving to paginated reward metadata
246
- * @throws Error if SDK is not initialized
247
- *
248
- * @example
249
- * ```typescript
250
- * const { getRewards } = useTokens();
251
- * const rewards = await getRewards({ active: true, limit: 10 });
252
- * console.log(`Found ${rewards.pagination.total} rewards`);
253
- * ```
254
- */
255
- const getRewards = useCallback(async (options?: RewardsFilterOptions): Promise<PaginatedResponseDTO<TokenMetadataDTO>> => {
256
- if (!isInitialized || !sdk) {
257
- throw new Error('SDK not initialized. Call initialize() first.');
258
- }
259
-
260
- try {
261
- const result = await sdk.tokens.getRewards(options);
262
- return result;
263
- } catch (error) {
264
- console.error('Failed to fetch rewards:', error);
265
- throw error;
266
- }
267
- }, [sdk, isInitialized]);
268
-
269
- /**
270
- * Get stamps (ERC721 token metadata) with filtering and pagination
271
- *
272
- * Convenience method for fetching stamp metadata. Stamps are ERC721 tokens
273
- * that represent achievements, badges, or collectible status markers.
274
- *
275
- * @param options - Filter and pagination options
276
- * @returns Promise resolving to paginated stamp metadata
277
- * @throws Error if SDK is not initialized
278
- *
279
- * @example
280
- * ```typescript
281
- * const { getStamps } = useTokens();
282
- * const stamps = await getStamps({ active: true, limit: 10 });
283
- * console.log(`Found ${stamps.pagination.total} stamps`);
284
- * ```
285
- */
286
- const getStamps = useCallback(async (options?: StampsFilterOptions): Promise<PaginatedResponseDTO<TokenMetadataDTO>> => {
287
- if (!isInitialized || !sdk) {
288
- throw new Error('SDK not initialized. Call initialize() first.');
289
- }
290
-
291
- try {
292
- const result = await sdk.tokens.getStamps(options);
293
- return result;
294
- } catch (error) {
295
- console.error('Failed to fetch stamps:', error);
296
- throw error;
297
- }
298
- }, [sdk, isInitialized]);
299
-
300
- return {
301
- getTokens,
302
- getActiveCreditToken,
303
- getRewardTokens,
304
- getTokenTypes,
305
- getStatusTokens,
306
- getTokenByContract,
307
- getTokenMetadata,
308
- getRewards,
309
- getStamps,
310
- isAvailable: isInitialized && !!sdk?.tokens,
311
- };
312
- };
313
-
1
+ import { useCallback } from 'react';
2
+ import { usePersSDK } from '../providers/PersSDKProvider';
3
+ import type { TokenDTO, TokenMetadataDTO, PaginatedResponseDTO, TokenMetadataFilterOptions, RewardsFilterOptions, StampsFilterOptions } from '@explorins/pers-sdk';
4
+
5
+ /**
6
+ * React hook for token operations in the PERS SDK
7
+ *
8
+ * Provides methods for fetching various types of tokens including credit, reward, and status tokens.
9
+ * Supports both general token queries and specific contract-based token retrieval.
10
+ *
11
+ * @returns Token hook with methods for token management
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * function TokensComponent() {
16
+ * const { getTokens, getActiveCreditToken, getRewardTokens } = useTokens();
17
+ *
18
+ * const loadTokens = async () => {
19
+ * try {
20
+ * const tokens = await getTokens();
21
+ * const creditToken = await getActiveCreditToken();
22
+ * console.log('Loaded tokens:', tokens);
23
+ * console.log('Active credit token:', creditToken);
24
+ * } catch (error) {
25
+ * console.error('Failed to load tokens:', error);
26
+ * }
27
+ * };
28
+ *
29
+ * return <button onClick={loadTokens}>Load Tokens</button>;
30
+ * }
31
+ * ```
32
+ */
33
+ export const useTokens = () => {
34
+ const { sdk, isInitialized, isAuthenticated } = usePersSDK();
35
+
36
+ if (!isAuthenticated && isInitialized) {
37
+ console.warn('SDK not authenticated. Some token operations may fail.');
38
+ }
39
+
40
+ /**
41
+ * Retrieves all tokens available to the current user
42
+ *
43
+ * @returns Promise resolving to array of tokens
44
+ * @throws Error if SDK is not initialized
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * const { getTokens } = useTokens();
49
+ * const tokens = await getTokens();
50
+ * console.log('Available tokens:', tokens);
51
+ * ```
52
+ */
53
+ const getTokens = useCallback(async (): Promise<PaginatedResponseDTO<TokenDTO>> => {
54
+ if (!isInitialized || !sdk) {
55
+ throw new Error('SDK not initialized. Call initialize() first.');
56
+ }
57
+
58
+ try {
59
+ const result = await sdk.tokens.getTokens();
60
+ return result;
61
+ } catch (error) {
62
+ console.error('Failed to fetch tokens:', error);
63
+ throw error;
64
+ }
65
+ }, [sdk, isInitialized]);
66
+
67
+ /**
68
+ * Retrieves the currently active credit token
69
+ *
70
+ * @returns Promise resolving to active credit token
71
+ * @throws Error if SDK is not initialized
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * const { getActiveCreditToken } = useTokens();
76
+ * const creditToken = await getActiveCreditToken();
77
+ * console.log('Active credit token:', creditToken.name);
78
+ * ```
79
+ */
80
+ const getActiveCreditToken = useCallback(async (): Promise<TokenDTO> => {
81
+ if (!isInitialized || !sdk) {
82
+ throw new Error('SDK not initialized. Call initialize() first.');
83
+ }
84
+
85
+ try {
86
+ const result = await sdk.tokens.getActiveCreditToken();
87
+ return result;
88
+ } catch (error) {
89
+ console.error('Failed to fetch active credit token:', error);
90
+ throw error;
91
+ }
92
+ }, [sdk, isInitialized]);
93
+
94
+ /**
95
+ * Retrieves all reward tokens available in the system
96
+ *
97
+ * @returns Promise resolving to array of reward tokens
98
+ * @throws Error if SDK is not initialized
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * const { getRewardTokens } = useTokens();
103
+ * const rewardTokens = await getRewardTokens();
104
+ * console.log('Reward tokens:', rewardTokens);
105
+ * ```
106
+ */
107
+ const getRewardTokens = useCallback(async (): Promise<PaginatedResponseDTO<TokenDTO>> => {
108
+ if (!isInitialized || !sdk) {
109
+ throw new Error('SDK not initialized. Call initialize() first.');
110
+ }
111
+
112
+ try {
113
+ const result = await sdk.tokens.getRewardTokens();
114
+ return result;
115
+ } catch (error) {
116
+ console.error('Failed to fetch reward tokens:', error);
117
+ throw error;
118
+ }
119
+ }, [sdk, isInitialized]);
120
+
121
+ /**
122
+ * Retrieves all available token types in the system
123
+ *
124
+ * @returns Promise resolving to array of token types
125
+ * @throws Error if SDK is not initialized
126
+ *
127
+ * @example
128
+ * ```typescript
129
+ * const { getTokenTypes } = useTokens();
130
+ * const types = await getTokenTypes();
131
+ * console.log('Token types:', types);
132
+ * ```
133
+ */
134
+ const getTokenTypes = useCallback(async (): Promise<any> => {
135
+ if (!isInitialized || !sdk) {
136
+ throw new Error('SDK not initialized. Call initialize() first.');
137
+ }
138
+
139
+ try {
140
+ const result = await sdk.tokens.getTokenTypes();
141
+ return result;
142
+ } catch (error) {
143
+ console.error('Failed to fetch token types:', error);
144
+ throw error;
145
+ }
146
+ }, [sdk, isInitialized]);
147
+
148
+ /**
149
+ * Retrieves all status tokens (tokens that represent user status/achievements)
150
+ *
151
+ * @returns Promise resolving to array of status tokens
152
+ * @throws Error if SDK is not initialized
153
+ *
154
+ * @example
155
+ * ```typescript
156
+ * const { getStatusTokens } = useTokens();
157
+ * const statusTokens = await getStatusTokens();
158
+ * console.log('Status tokens:', statusTokens);
159
+ * ```
160
+ */
161
+ const getStatusTokens = useCallback(async (): Promise<PaginatedResponseDTO<TokenDTO>> => {
162
+ if (!isInitialized || !sdk) {
163
+ throw new Error('SDK not initialized. Call initialize() first.');
164
+ }
165
+
166
+ try {
167
+ const result = await sdk.tokens.getStatusTokens();
168
+ return result;
169
+ } catch (error) {
170
+ console.error('Failed to fetch status tokens:', error);
171
+ throw error;
172
+ }
173
+ }, [sdk, isInitialized]);
174
+
175
+ /**
176
+ * Retrieves a specific token by its contract address and optional token ID
177
+ *
178
+ * @param contractAddress - The contract address of the token
179
+ * @param contractTokenId - Optional specific token ID within the contract
180
+ * @returns Promise resolving to the token data
181
+ * @throws Error if SDK is not initialized
182
+ *
183
+ * @example
184
+ * ```typescript
185
+ * const { getTokenByContract } = useTokens();
186
+ * const token = await getTokenByContract('0x123...', 'token-1');
187
+ * console.log('Token from contract:', token);
188
+ * ```
189
+ */
190
+ const getTokenByContract = useCallback(async (contractAddress: string, contractTokenId?: string | null): Promise<TokenDTO> => {
191
+ if (!isInitialized || !sdk) {
192
+ throw new Error('SDK not initialized. Call initialize() first.');
193
+ }
194
+
195
+ try {
196
+ const result = await sdk.tokens.getTokenByContract(contractAddress, contractTokenId);
197
+ return result;
198
+ } catch (error) {
199
+ console.error('Failed to fetch token by contract:', error);
200
+ throw error;
201
+ }
202
+ }, [sdk, isInitialized]);
203
+
204
+ /**
205
+ * Get all token metadata with filtering and pagination
206
+ *
207
+ * Retrieves token metadata (rewards/stamps) with server-side filtering.
208
+ * Use tokenType: 'ERC1155' for rewards, 'ERC721' for stamps.
209
+ *
210
+ * @param options - Filter and pagination options
211
+ * @returns Promise resolving to paginated token metadata
212
+ * @throws Error if SDK is not initialized
213
+ *
214
+ * @example
215
+ * ```typescript
216
+ * const { getTokenMetadata } = useTokens();
217
+ * const rewards = await getTokenMetadata({
218
+ * tokenType: 'ERC1155',
219
+ * active: true,
220
+ * limit: 10
221
+ * });
222
+ * ```
223
+ */
224
+ const getTokenMetadata = useCallback(async (options?: TokenMetadataFilterOptions): Promise<PaginatedResponseDTO<TokenMetadataDTO>> => {
225
+ if (!isInitialized || !sdk) {
226
+ throw new Error('SDK not initialized. Call initialize() first.');
227
+ }
228
+
229
+ try {
230
+ const result = await sdk.tokens.getTokenMetadata(options);
231
+ return result;
232
+ } catch (error) {
233
+ console.error('Failed to fetch token metadata:', error);
234
+ throw error;
235
+ }
236
+ }, [sdk, isInitialized]);
237
+
238
+ /**
239
+ * Get rewards (ERC1155 token metadata) with filtering and pagination
240
+ *
241
+ * Convenience method for fetching reward metadata. Rewards are ERC1155 tokens
242
+ * that represent collectible items, vouchers, or other redeemable rewards.
243
+ *
244
+ * @param options - Filter and pagination options
245
+ * @returns Promise resolving to paginated reward metadata
246
+ * @throws Error if SDK is not initialized
247
+ *
248
+ * @example
249
+ * ```typescript
250
+ * const { getRewards } = useTokens();
251
+ * const rewards = await getRewards({ active: true, limit: 10 });
252
+ * console.log(`Found ${rewards.pagination.total} rewards`);
253
+ * ```
254
+ */
255
+ const getRewards = useCallback(async (options?: RewardsFilterOptions): Promise<PaginatedResponseDTO<TokenMetadataDTO>> => {
256
+ if (!isInitialized || !sdk) {
257
+ throw new Error('SDK not initialized. Call initialize() first.');
258
+ }
259
+
260
+ try {
261
+ const result = await sdk.tokens.getRewards(options);
262
+ return result;
263
+ } catch (error) {
264
+ console.error('Failed to fetch rewards:', error);
265
+ throw error;
266
+ }
267
+ }, [sdk, isInitialized]);
268
+
269
+ /**
270
+ * Get stamps (ERC721 token metadata) with filtering and pagination
271
+ *
272
+ * Convenience method for fetching stamp metadata. Stamps are ERC721 tokens
273
+ * that represent achievements, badges, or collectible status markers.
274
+ *
275
+ * @param options - Filter and pagination options
276
+ * @returns Promise resolving to paginated stamp metadata
277
+ * @throws Error if SDK is not initialized
278
+ *
279
+ * @example
280
+ * ```typescript
281
+ * const { getStamps } = useTokens();
282
+ * const stamps = await getStamps({ active: true, limit: 10 });
283
+ * console.log(`Found ${stamps.pagination.total} stamps`);
284
+ * ```
285
+ */
286
+ const getStamps = useCallback(async (options?: StampsFilterOptions): Promise<PaginatedResponseDTO<TokenMetadataDTO>> => {
287
+ if (!isInitialized || !sdk) {
288
+ throw new Error('SDK not initialized. Call initialize() first.');
289
+ }
290
+
291
+ try {
292
+ const result = await sdk.tokens.getStamps(options);
293
+ return result;
294
+ } catch (error) {
295
+ console.error('Failed to fetch stamps:', error);
296
+ throw error;
297
+ }
298
+ }, [sdk, isInitialized]);
299
+
300
+ return {
301
+ getTokens,
302
+ getActiveCreditToken,
303
+ getRewardTokens,
304
+ getTokenTypes,
305
+ getStatusTokens,
306
+ getTokenByContract,
307
+ getTokenMetadata,
308
+ getRewards,
309
+ getStamps,
310
+ isAvailable: isInitialized && !!sdk?.tokens,
311
+ };
312
+ };
313
+
314
314
  export type TokenHook = ReturnType<typeof useTokens>;