@rhea-finance/cross-chain-aggregation-dex 2.1.5 → 2.1.6

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.
package/dist/index.mjs CHANGED
@@ -114,12 +114,6 @@ function resolveSourceTxHash(input) {
114
114
  }
115
115
 
116
116
  // src/api/ApiClient.ts
117
- var DEFAULT_RETRY = {
118
- maxRetries: 2,
119
- baseDelayMs: 250,
120
- maxDelayMs: 2e3,
121
- jitter: true
122
- };
123
117
  var ApiClient = class {
124
118
  constructor(config) {
125
119
  this.config = config;
@@ -138,8 +132,7 @@ var ApiClient = class {
138
132
  return this.request("/api/v2/swap/quote", "quote", {
139
133
  ...options,
140
134
  method: "POST",
141
- body,
142
- retryableOperation: true
135
+ body
143
136
  });
144
137
  }
145
138
  build(body, options = {}) {
@@ -168,7 +161,6 @@ var ApiClient = class {
168
161
  return this.request("/api/swap/order-status", "status", {
169
162
  ...options,
170
163
  method: "GET",
171
- retryableOperation: true,
172
164
  query
173
165
  });
174
166
  }
@@ -183,7 +175,6 @@ var ApiClient = class {
183
175
  return this.request("/api/swap/history", "history", {
184
176
  ...options,
185
177
  method: "GET",
186
- retryableOperation: true,
187
178
  query: {
188
179
  sender: params.sender,
189
180
  mode: params.mode,
@@ -211,7 +202,6 @@ var ApiClient = class {
211
202
  return this.request("/get_chain_prices", "tokens", {
212
203
  ...options,
213
204
  method: "GET",
214
- retryableOperation: true,
215
205
  query: { chain: chainId }
216
206
  });
217
207
  }
@@ -219,7 +209,6 @@ var ApiClient = class {
219
209
  return this.request("/api/swap/supported_to_tokens", "tokens", {
220
210
  ...options,
221
211
  method: "GET",
222
- retryableOperation: true,
223
212
  query: { chain: chainId }
224
213
  });
225
214
  }
@@ -229,39 +218,15 @@ var ApiClient = class {
229
218
  options.idempotencyKey,
230
219
  options.authenticationToken
231
220
  );
232
- const retry = this.retryConfig();
233
- let attempt = 1;
234
- for (; ; ) {
235
- this.log({
236
- level: "debug",
237
- event: "api.request",
238
- path,
239
- stage,
240
- attempt
241
- });
242
- try {
243
- return await this.requestOnce(url, path, stage, options, headers, attempt);
244
- } catch (error) {
245
- const sdkError = error instanceof SwapSdkError ? error : new SwapSdkError("HTTP_ERROR", stage, "Network request failed", {
246
- cause: error,
247
- retryable: true
248
- });
249
- const canRetry = options.retryableOperation === true && sdkError.retryable && sdkError.code !== "REQUEST_ABORTED" && attempt <= retry.maxRetries;
250
- if (!canRetry) throw sdkError;
251
- this.log({
252
- level: "warn",
253
- event: "api.retry",
254
- path,
255
- stage,
256
- attempt,
257
- code: sdkError.code
258
- });
259
- await waitForRetry(this.retryDelay(attempt, retry), options.signal, stage);
260
- attempt += 1;
261
- }
262
- }
221
+ this.log({
222
+ level: "debug",
223
+ event: "api.request",
224
+ path,
225
+ stage
226
+ });
227
+ return this.requestOnce(url, path, stage, options, headers);
263
228
  }
264
- async requestOnce(url, path, stage, options, headers, attempt) {
229
+ async requestOnce(url, path, stage, options, headers) {
265
230
  if (options.signal?.aborted) {
266
231
  throw new SwapSdkError("REQUEST_ABORTED", stage, "Request aborted", {
267
232
  cause: options.signal.reason
@@ -298,7 +263,6 @@ var ApiClient = class {
298
263
  event: "api.response",
299
264
  path,
300
265
  stage,
301
- attempt,
302
266
  status: response.status,
303
267
  durationMs: Date.now() - startedAt
304
268
  });
@@ -345,12 +309,7 @@ var ApiClient = class {
345
309
  { cause: error, retryable: timedOut }
346
310
  );
347
311
  }
348
- const details = networkFailureDetails(
349
- error,
350
- options.method,
351
- path,
352
- attempt
353
- );
312
+ const details = networkFailureDetails(error, options.method, path);
354
313
  console.error("SDK network request failed", {
355
314
  ...details,
356
315
  stage
@@ -391,24 +350,6 @@ var ApiClient = class {
391
350
  ...configured
392
351
  };
393
352
  }
394
- retryConfig() {
395
- const configured = { ...DEFAULT_RETRY, ...this.config.retry };
396
- if (!Number.isSafeInteger(configured.maxRetries) || configured.maxRetries < 0 || !Number.isFinite(configured.baseDelayMs) || configured.baseDelayMs < 0 || !Number.isFinite(configured.maxDelayMs) || configured.maxDelayMs < configured.baseDelayMs) {
397
- throw new SwapSdkError(
398
- "INVALID_REQUEST",
399
- "quote",
400
- "Invalid retry configuration"
401
- );
402
- }
403
- return configured;
404
- }
405
- retryDelay(attempt, retry) {
406
- const exponential = Math.min(
407
- retry.maxDelayMs,
408
- retry.baseDelayMs * 2 ** (attempt - 1)
409
- );
410
- return retry.jitter ? Math.min(retry.maxDelayMs, exponential * (0.5 + Math.random())) : exponential;
411
- }
412
353
  log(entry) {
413
354
  try {
414
355
  this.config.logger?.log(entry);
@@ -441,7 +382,7 @@ var ApiClient = class {
441
382
  return typeof value.msg === "string" && value.msg.trim() ? value.msg.trim() : void 0;
442
383
  }
443
384
  };
444
- function networkFailureDetails(error, method, path, attempt) {
385
+ function networkFailureDetails(error, method, path) {
445
386
  const causeName = error instanceof Error && error.name.trim() ? error.name.trim() : "Error";
446
387
  const rawMessage = error instanceof Error && error.message.trim() ? error.message.trim() : String(error);
447
388
  const causeMessage = rawMessage.replace(
@@ -451,36 +392,10 @@ function networkFailureDetails(error, method, path, attempt) {
451
392
  return {
452
393
  method,
453
394
  path,
454
- attempt,
455
395
  causeName,
456
396
  causeMessage
457
397
  };
458
398
  }
459
- function waitForRetry(delayMs, signal, stage) {
460
- return new Promise((resolve, reject) => {
461
- if (signal?.aborted) {
462
- reject(
463
- new SwapSdkError("REQUEST_ABORTED", stage, "Request aborted", {
464
- cause: signal.reason
465
- })
466
- );
467
- return;
468
- }
469
- const onAbort = () => {
470
- clearTimeout(timeout);
471
- reject(
472
- new SwapSdkError("REQUEST_ABORTED", stage, "Request aborted", {
473
- cause: signal?.reason
474
- })
475
- );
476
- };
477
- const timeout = setTimeout(() => {
478
- signal?.removeEventListener("abort", onAbort);
479
- resolve();
480
- }, delayMs);
481
- signal?.addEventListener("abort", onAbort, { once: true });
482
- });
483
- }
484
399
 
485
400
  // src/core/lifecycle.ts
486
401
  var ORDER_STATUS_MAP = {