@@ -280,12 +280,77 @@ export class ReservoirService {
280
280
transactionHash ?: string ;
281
281
marketplaceUrl : string ;
282
282
} > {
283
- return Promise . resolve ( {
284
- listingId : "" ,
285
- status : "" ,
286
- transactionHash : undefined ,
287
- marketplaceUrl : "" ,
288
- } ) ;
283
+ const endOperation = this . performanceMonitor . startOperation (
284
+ "createListing" ,
285
+ { options }
286
+ ) ;
287
+
288
+ try {
289
+ // Validate required parameters
290
+ if (
291
+ ! options . tokenId ||
292
+ ! options . collectionAddress ||
293
+ ! options . price
294
+ ) {
295
+ throw new Error ( "Missing required listing parameters" ) ;
296
+ }
297
+
298
+ // Default values
299
+ const currency = options . currency || "ETH" ;
300
+ const quantity = options . quantity || 1 ;
301
+ const expirationTime =
302
+ options . expirationTime ||
303
+ Math . floor ( Date . now ( ) / 1000 ) + 30 * 24 * 60 * 60 ; // 30 days from now
304
+
305
+ const listingParams = {
306
+ maker : "" , // Will be set by runtime or current wallet
307
+ token : `${ options . collectionAddress } :${ options . tokenId } ` ,
308
+ quantity : quantity . toString ( ) ,
309
+ price : options . price . toString ( ) ,
310
+ currency,
311
+ expirationTime : expirationTime . toString ( ) ,
312
+ } ;
313
+
314
+ const response = await this . makeRequest < {
315
+ listing : {
316
+ id : string ;
317
+ status : string ;
318
+ transactionHash ?: string ;
319
+ } ;
320
+ } > ( "/listings/v5/create" , listingParams , 1 , { } as IAgentRuntime ) ;
321
+
322
+ const result = {
323
+ listingId : response . listing . id ,
324
+ status : response . listing . status ,
325
+ transactionHash : response . listing . transactionHash ,
326
+ marketplaceUrl : `https://reservoir.market/collections/${ options . collectionAddress } /tokens/${ options . tokenId } ` ,
327
+ } ;
328
+
329
+ endOperation ( ) ;
330
+ return result ;
331
+ } catch ( error ) {
332
+ this . performanceMonitor . recordMetric ( {
333
+ operation : "createListing" ,
334
+ duration : 0 ,
335
+ success : false ,
336
+ metadata : { error : error . message , options } ,
337
+ } ) ;
338
+
339
+ const nftError = NFTErrorFactory . create (
340
+ ErrorType . API ,
341
+ ErrorCode . API_ERROR ,
342
+ "Failed to create NFT listing" ,
343
+ {
344
+ originalError : error ,
345
+ collectionAddress : options . collectionAddress ,
346
+ tokenId : options . tokenId ,
347
+ } ,
348
+ true
349
+ ) ;
350
+ this . errorHandler . handleError ( nftError ) ;
351
+
352
+ throw error ;
353
+ }
289
354
}
290
355
291
356
async cancelListing ( options : {
0 commit comments