File tree 1 file changed +49
-1
lines changed
packages/plugin-nft-collections/src/services
1 file changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -310,6 +310,54 @@ export class ReservoirService {
310
310
attributes ?: Record < string , string > ;
311
311
} >
312
312
> {
313
- return Promise . resolve ( [ ] ) ;
313
+ try {
314
+ const endpoint = "/users/tokens/v1" ;
315
+ const params = {
316
+ users : owner ,
317
+ limit : 100 , // Configurable limit
318
+ includeAttributes : true ,
319
+ } ;
320
+
321
+ const response = await this . makeRequest < {
322
+ tokens : Array < {
323
+ token : {
324
+ tokenId : string ;
325
+ collection : {
326
+ id : string ;
327
+ name : string ;
328
+ } ;
329
+ image : string ;
330
+ attributes ?: Array < {
331
+ key : string ;
332
+ value : string ;
333
+ } > ;
334
+ } ;
335
+ } > ;
336
+ } > ( endpoint , params , 1 , { } as IAgentRuntime ) ;
337
+
338
+ return response . tokens . map ( ( token ) => ( {
339
+ tokenId : token . token . tokenId ,
340
+ collectionAddress : token . token . collection . id ,
341
+ name : token . token . collection . name ,
342
+ imageUrl : token . token . image ,
343
+ attributes : token . token . attributes
344
+ ? Object . fromEntries (
345
+ token . token . attributes . map ( ( attr ) => [
346
+ attr . key ,
347
+ attr . value ,
348
+ ] )
349
+ )
350
+ : undefined ,
351
+ } ) ) ;
352
+ } catch ( error ) {
353
+ const nftError = NFTErrorFactory . create (
354
+ ErrorType . API ,
355
+ ErrorCode . API_ERROR ,
356
+ `Failed to fetch owned NFTs for owner ${ owner } ` ,
357
+ { owner }
358
+ ) ;
359
+ this . errorHandler . handleError ( nftError ) ;
360
+ return [ ] ;
361
+ }
314
362
}
315
363
}
You can’t perform that action at this time.
0 commit comments