@explorins/pers-sdk-react-native 2.2.0-beta.1 → 2.2.1

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.
@@ -191,6 +191,99 @@ export const useTokens = () => {
191
191
  throw error;
192
192
  }
193
193
  }, [sdk, isInitialized]);
194
+ /**
195
+ * Get all token metadata with filtering and pagination
196
+ *
197
+ * Retrieves token metadata (rewards/stamps) with server-side filtering.
198
+ * Use tokenType: 'ERC1155' for rewards, 'ERC721' for stamps.
199
+ *
200
+ * @param options - Filter and pagination options
201
+ * @returns Promise resolving to paginated token metadata
202
+ * @throws Error if SDK is not initialized
203
+ *
204
+ * @example
205
+ * ```typescript
206
+ * const { getTokenMetadata } = useTokens();
207
+ * const rewards = await getTokenMetadata({
208
+ * tokenType: 'ERC1155',
209
+ * active: true,
210
+ * limit: 10
211
+ * });
212
+ * ```
213
+ */
214
+ const getTokenMetadata = useCallback(async (options) => {
215
+ if (!isInitialized || !sdk) {
216
+ throw new Error('SDK not initialized. Call initialize() first.');
217
+ }
218
+ try {
219
+ const result = await sdk.tokens.getTokenMetadata(options);
220
+ return result;
221
+ }
222
+ catch (error) {
223
+ console.error('Failed to fetch token metadata:', error);
224
+ throw error;
225
+ }
226
+ }, [sdk, isInitialized]);
227
+ /**
228
+ * Get rewards (ERC1155 token metadata) with filtering and pagination
229
+ *
230
+ * Convenience method for fetching reward metadata. Rewards are ERC1155 tokens
231
+ * that represent collectible items, vouchers, or other redeemable rewards.
232
+ *
233
+ * @param options - Filter and pagination options
234
+ * @returns Promise resolving to paginated reward metadata
235
+ * @throws Error if SDK is not initialized
236
+ *
237
+ * @example
238
+ * ```typescript
239
+ * const { getRewards } = useTokens();
240
+ * const rewards = await getRewards({ active: true, limit: 10 });
241
+ * console.log(`Found ${rewards.pagination.total} rewards`);
242
+ * ```
243
+ */
244
+ const getRewards = useCallback(async (options) => {
245
+ if (!isInitialized || !sdk) {
246
+ throw new Error('SDK not initialized. Call initialize() first.');
247
+ }
248
+ try {
249
+ const result = await sdk.tokens.getRewards(options);
250
+ return result;
251
+ }
252
+ catch (error) {
253
+ console.error('Failed to fetch rewards:', error);
254
+ throw error;
255
+ }
256
+ }, [sdk, isInitialized]);
257
+ /**
258
+ * Get stamps (ERC721 token metadata) with filtering and pagination
259
+ *
260
+ * Convenience method for fetching stamp metadata. Stamps are ERC721 tokens
261
+ * that represent achievements, badges, or collectible status markers.
262
+ *
263
+ * @param options - Filter and pagination options
264
+ * @returns Promise resolving to paginated stamp metadata
265
+ * @throws Error if SDK is not initialized
266
+ *
267
+ * @example
268
+ * ```typescript
269
+ * const { getStamps } = useTokens();
270
+ * const stamps = await getStamps({ active: true, limit: 10 });
271
+ * console.log(`Found ${stamps.pagination.total} stamps`);
272
+ * ```
273
+ */
274
+ const getStamps = useCallback(async (options) => {
275
+ if (!isInitialized || !sdk) {
276
+ throw new Error('SDK not initialized. Call initialize() first.');
277
+ }
278
+ try {
279
+ const result = await sdk.tokens.getStamps(options);
280
+ return result;
281
+ }
282
+ catch (error) {
283
+ console.error('Failed to fetch stamps:', error);
284
+ throw error;
285
+ }
286
+ }, [sdk, isInitialized]);
194
287
  return {
195
288
  getTokens,
196
289
  getActiveCreditToken,
@@ -198,6 +291,9 @@ export const useTokens = () => {
198
291
  getTokenTypes,
199
292
  getStatusTokens,
200
293
  getTokenByContract,
294
+ getTokenMetadata,
295
+ getRewards,
296
+ getStamps,
201
297
  isAvailable: isInitialized && !!sdk?.tokens,
202
298
  };
203
299
  };