@medialane/sdk 0.71.0 → 0.72.0
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.cjs +42 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -3
- package/dist/index.d.ts +16 -3
- package/dist/index.js +37 -7
- package/dist/index.js.map +1 -1
- package/dist/{services-B4E-tTin.d.ts → services-Byw4_DBm.d.ts} +5 -1
- package/dist/{services-D7n-cJYt.d.cts → services-CGbMik_G.d.cts} +5 -1
- package/dist/starknet/index.cjs +16 -6
- package/dist/starknet/index.cjs.map +1 -1
- package/dist/starknet/index.d.cts +1 -1
- package/dist/starknet/index.d.ts +1 -1
- package/dist/starknet/index.js +16 -6
- package/dist/starknet/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { aT as ResolvedConfig, aZ as TxResult, al as CreatePopCollectionParams, a9 as ClaimConditions, ah as CreateDropParams, ao as CreateTicketParams, aG as MintTicketsParams, aj as CreateMembershipParams, aF as MintMembershipsParams, an as CreateSponsorshipOfferParams, aR as ProposeSponsorshipParams, h as ApiClient, aD as MedialaneConfig, aE as MedialaneErrorCode, aL as OrderDetails, aU as ResolvedFeeConfig } from '../services-
|
|
1
|
+
import { aT as ResolvedConfig, aZ as TxResult, al as CreatePopCollectionParams, a9 as ClaimConditions, ah as CreateDropParams, ao as CreateTicketParams, aG as MintTicketsParams, aj as CreateMembershipParams, aF as MintMembershipsParams, an as CreateSponsorshipOfferParams, aR as ProposeSponsorshipParams, h as ApiClient, aD as MedialaneConfig, aE as MedialaneErrorCode, aL as OrderDetails, aU as ResolvedFeeConfig } from '../services-CGbMik_G.cjs';
|
|
2
2
|
import { AccountInterface, Call, ProviderInterface, TypedData, constants } from 'starknet';
|
|
3
3
|
import { V as VenueAdapter, O as OrderRef, A as AdapterTxResult, R as RegisterOrderParams, j as VenueSigner } from '../types-Cdwb6lXp.cjs';
|
|
4
4
|
import 'zod';
|
package/dist/starknet/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { aT as ResolvedConfig, aZ as TxResult, al as CreatePopCollectionParams, a9 as ClaimConditions, ah as CreateDropParams, ao as CreateTicketParams, aG as MintTicketsParams, aj as CreateMembershipParams, aF as MintMembershipsParams, an as CreateSponsorshipOfferParams, aR as ProposeSponsorshipParams, h as ApiClient, aD as MedialaneConfig, aE as MedialaneErrorCode, aL as OrderDetails, aU as ResolvedFeeConfig } from '../services-
|
|
1
|
+
import { aT as ResolvedConfig, aZ as TxResult, al as CreatePopCollectionParams, a9 as ClaimConditions, ah as CreateDropParams, ao as CreateTicketParams, aG as MintTicketsParams, aj as CreateMembershipParams, aF as MintMembershipsParams, an as CreateSponsorshipOfferParams, aR as ProposeSponsorshipParams, h as ApiClient, aD as MedialaneConfig, aE as MedialaneErrorCode, aL as OrderDetails, aU as ResolvedFeeConfig } from '../services-Byw4_DBm.js';
|
|
2
2
|
import { AccountInterface, Call, ProviderInterface, TypedData, constants } from 'starknet';
|
|
3
3
|
import { V as VenueAdapter, O as OrderRef, A as AdapterTxResult, R as RegisterOrderParams, j as VenueSigner } from '../types-Cdwb6lXp.js';
|
|
4
4
|
import 'zod';
|
package/dist/starknet/index.js
CHANGED
|
@@ -218,15 +218,16 @@ async function withRetry(fn, opts) {
|
|
|
218
218
|
return await fn();
|
|
219
219
|
} catch (err) {
|
|
220
220
|
lastError = err;
|
|
221
|
-
if (err instanceof MedialaneApiError && err.status < 500) {
|
|
221
|
+
if (err instanceof MedialaneApiError && err.status < 500 && err.status !== 429) {
|
|
222
222
|
throw err;
|
|
223
223
|
}
|
|
224
|
-
const isRetryable = err instanceof MedialaneApiError && err.status >= 500 || err instanceof TypeError;
|
|
224
|
+
const isRetryable = err instanceof MedialaneApiError && (err.status >= 500 || err.status === 429) || err instanceof TypeError;
|
|
225
225
|
if (!isRetryable || attempt === maxAttempts - 1) {
|
|
226
226
|
throw err;
|
|
227
227
|
}
|
|
228
|
-
const
|
|
229
|
-
const
|
|
228
|
+
const retryAfterMs = err instanceof MedialaneApiError ? err.retryAfterMs : void 0;
|
|
229
|
+
const backoff = baseDelayMs * Math.pow(2, attempt) + Math.random() * baseDelayMs;
|
|
230
|
+
const delay = Math.min(retryAfterMs ?? backoff, maxDelayMs);
|
|
230
231
|
await sleep(delay);
|
|
231
232
|
}
|
|
232
233
|
}
|
|
@@ -243,13 +244,22 @@ function deriveErrorCode(status) {
|
|
|
243
244
|
return "UNKNOWN";
|
|
244
245
|
}
|
|
245
246
|
var MedialaneApiError = class extends Error {
|
|
246
|
-
constructor(status, message) {
|
|
247
|
+
constructor(status, message, retryAfterMs) {
|
|
247
248
|
super(message);
|
|
248
249
|
this.status = status;
|
|
250
|
+
this.retryAfterMs = retryAfterMs;
|
|
249
251
|
this.name = "MedialaneApiError";
|
|
250
252
|
this.code = deriveErrorCode(status);
|
|
251
253
|
}
|
|
252
254
|
};
|
|
255
|
+
function parseRetryAfter(value) {
|
|
256
|
+
if (!value) return void 0;
|
|
257
|
+
const seconds = Number(value);
|
|
258
|
+
if (Number.isFinite(seconds)) return Math.max(0, seconds * 1e3);
|
|
259
|
+
const date = Date.parse(value);
|
|
260
|
+
if (!Number.isNaN(date)) return Math.max(0, date - Date.now());
|
|
261
|
+
return void 0;
|
|
262
|
+
}
|
|
253
263
|
var ApiClient = class {
|
|
254
264
|
constructor(baseUrl, apiKey, retryOptions, chain = "STARKNET") {
|
|
255
265
|
this.baseUrl = baseUrl;
|
|
@@ -288,7 +298,7 @@ var ApiClient = class {
|
|
|
288
298
|
if (body.error) message = body.error;
|
|
289
299
|
} catch {
|
|
290
300
|
}
|
|
291
|
-
throw new MedialaneApiError(response.status, message);
|
|
301
|
+
throw new MedialaneApiError(response.status, message, parseRetryAfter(response.headers.get("retry-after")));
|
|
292
302
|
}
|
|
293
303
|
return response;
|
|
294
304
|
}, this.retryOptions);
|