Skip to content

Commit ee9accb

Browse files
committed
corrct return value
1 parent 1adebb2 commit ee9accb

File tree

4 files changed

+33
-36
lines changed

4 files changed

+33
-36
lines changed

packages/plugin-nft-collections/src/__tests__/reservoir.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe("ReservoirService", () => {
2222
beforeEach(() => {
2323
cacheManager = new MemoryCacheManager();
2424
rateLimiter = new RateLimiter();
25-
service = new ReservoirService("test-api-key", {
25+
service = new ReservoirService({
2626
cacheManager,
2727
rateLimiter,
2828
});

packages/plugin-nft-collections/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const config = {
2929
batchSize: 20, // Batch size for collection requests
3030
};
3131

32-
async function createNFTCollectionsPlugin(): Promise<Plugin> {
32+
function createNFTCollectionsPlugin(): Plugin {
3333
// Initialize reusable CacheManager if caching is enabled
3434
const cacheManager = config.caching?.enabled
3535
? new MemoryCacheManager({

packages/plugin-nft-collections/src/services/reservoir.ts

+30-33
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import pRetry from "p-retry";
2-
import pQueue from "p-queue";
2+
// import pQueue from "p-queue";
33
import { PerformanceMonitor } from "../utils/performance";
44
import {
55
ErrorHandler,
@@ -23,7 +23,7 @@ interface ReservoirServiceConfig {
2323
export class ReservoirService {
2424
private cacheManager?: MemoryCacheManager;
2525
private rateLimiter?: RateLimiter;
26-
private queue: pQueue;
26+
// private queue: pQueue;
2727
private maxRetries: number;
2828
private batchSize: number;
2929
private performanceMonitor: PerformanceMonitor;
@@ -32,7 +32,8 @@ export class ReservoirService {
3232
constructor(config: ReservoirServiceConfig = {}) {
3333
this.cacheManager = config.cacheManager;
3434
this.rateLimiter = config.rateLimiter;
35-
this.queue = new pQueue({ concurrency: config.maxConcurrent || 5 });
35+
36+
// this.queue = new pQueue({ concurrency: config.maxConcurrent || 5 });
3637
this.maxRetries = config.maxRetries || 3;
3738
this.batchSize = config.batchSize || 20;
3839
this.performanceMonitor = PerformanceMonitor.getInstance();
@@ -73,39 +74,35 @@ export class ReservoirService {
7374
const reservoirApiKey = runtime.getSetting("RESERVOIR_API_KEY");
7475

7576
// Make the request with retries
76-
const result = await this.queue.add(
77-
() =>
78-
pRetry(
79-
async () => {
80-
const response = await fetch(
81-
`https://api.reservoir.tools${endpoint}?${new URLSearchParams(
82-
params
83-
).toString()}`,
84-
{
85-
headers: {
86-
"x-api-key": reservoirApiKey,
87-
},
88-
}
89-
);
90-
91-
if (!response.ok) {
92-
throw new Error(
93-
`Reservoir API error: ${response.status}`
94-
);
95-
}
96-
97-
return response.json();
98-
},
77+
const result = await pRetry(
78+
async () => {
79+
const response = await fetch(
80+
`https://api.reservoir.tools${endpoint}?${new URLSearchParams(
81+
params
82+
).toString()}`,
9983
{
100-
retries: this.maxRetries,
101-
onFailedAttempt: (error) => {
102-
console.error(
103-
`Attempt ${error.attemptNumber} failed. ${error.retriesLeft} retries left.`
104-
);
84+
headers: {
85+
"x-api-key": reservoirApiKey,
10586
},
10687
}
107-
),
108-
{ priority }
88+
);
89+
90+
if (!response.ok) {
91+
throw new Error(
92+
`Reservoir API error: ${response.status}`
93+
);
94+
}
95+
96+
return response.json();
97+
},
98+
{
99+
retries: this.maxRetries,
100+
onFailedAttempt: (error) => {
101+
console.error(
102+
`Attempt ${error.attemptNumber} failed. ${error.retriesLeft} retries left.`
103+
);
104+
},
105+
}
109106
);
110107

111108
// Cache the result

packages/plugin-nft-collections/src/tests/services.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe("NFT Services", () => {
2525
beforeEach(() => {
2626
cacheManager = new MemoryCacheManager();
2727
rateLimiter = new RateLimiter();
28-
service = new ReservoirService("test-api-key", {
28+
service = new ReservoirService({
2929
cacheManager,
3030
rateLimiter,
3131
});

0 commit comments

Comments
 (0)