@medialane/sdk 0.137.0 → 0.138.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/README.md +5 -4
- package/dist/{errors-CC1H8Usc.d.ts → errors-ac8HvmsP.d.ts} +2 -12
- package/dist/{errors-Ca-A70L7.d.cts → errors-iITqaALF.d.cts} +2 -12
- package/dist/index.cjs +14 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +14 -26
- package/dist/index.js.map +1 -1
- package/dist/starknet/index.cjs +14 -26
- package/dist/starknet/index.cjs.map +1 -1
- package/dist/starknet/index.d.cts +2 -2
- package/dist/starknet/index.d.ts +2 -2
- package/dist/starknet/index.js +14 -26
- package/dist/starknet/index.js.map +1 -1
- package/package.json +1 -1
package/dist/starknet/index.cjs
CHANGED
|
@@ -212,7 +212,13 @@ var DEFAULT_MAX_DELAY_MS = 5e3;
|
|
|
212
212
|
function sleep(ms) {
|
|
213
213
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
214
214
|
}
|
|
215
|
-
|
|
215
|
+
function isRetryableFor(method, err) {
|
|
216
|
+
if (err instanceof MedialaneApiError && err.status === 429) return true;
|
|
217
|
+
const isRead = method === "GET" || method === "HEAD";
|
|
218
|
+
if (!isRead) return false;
|
|
219
|
+
return err instanceof MedialaneApiError && err.status >= 500 || err instanceof TypeError;
|
|
220
|
+
}
|
|
221
|
+
async function withRetry(fn, opts, method = "GET") {
|
|
216
222
|
const maxAttempts = opts?.maxAttempts ?? DEFAULT_MAX_ATTEMPTS;
|
|
217
223
|
const baseDelayMs = opts?.baseDelayMs ?? DEFAULT_BASE_DELAY_MS;
|
|
218
224
|
const maxDelayMs = opts?.maxDelayMs ?? DEFAULT_MAX_DELAY_MS;
|
|
@@ -222,11 +228,7 @@ async function withRetry(fn, opts) {
|
|
|
222
228
|
return await fn();
|
|
223
229
|
} catch (err) {
|
|
224
230
|
lastError = err;
|
|
225
|
-
if (
|
|
226
|
-
throw err;
|
|
227
|
-
}
|
|
228
|
-
const isRetryable = err instanceof MedialaneApiError && (err.status >= 500 || err.status === 429) || err instanceof TypeError;
|
|
229
|
-
if (!isRetryable || attempt === maxAttempts - 1) {
|
|
231
|
+
if (!isRetryableFor(method, err) || attempt === maxAttempts - 1) {
|
|
230
232
|
throw err;
|
|
231
233
|
}
|
|
232
234
|
const retryAfterMs = err instanceof MedialaneApiError ? err.retryAfterMs : void 0;
|
|
@@ -307,7 +309,7 @@ var ApiClient = class {
|
|
|
307
309
|
);
|
|
308
310
|
}
|
|
309
311
|
return response;
|
|
310
|
-
}, this.retryOptions);
|
|
312
|
+
}, this.retryOptions, (init?.method ?? "GET").toUpperCase());
|
|
311
313
|
if (allowed(res.status)) return null;
|
|
312
314
|
return res.json();
|
|
313
315
|
}
|
|
@@ -375,19 +377,6 @@ var ApiClient = class {
|
|
|
375
377
|
`/v1/tokens/${contract}/${tokenId}/history?page=${page}&limit=${limit}`
|
|
376
378
|
);
|
|
377
379
|
}
|
|
378
|
-
getCollections(page = 1, limit = 20, isKnown, sort, service, chain, standard) {
|
|
379
|
-
const params = new URLSearchParams({ page: String(page), limit: String(limit) });
|
|
380
|
-
if (isKnown !== void 0) params.set("isKnown", String(isKnown));
|
|
381
|
-
if (sort) params.set("sort", sort);
|
|
382
|
-
if (service) params.set("service", service);
|
|
383
|
-
if (chain) params.set("chain", chain);
|
|
384
|
-
if (standard) params.set("standard", standard);
|
|
385
|
-
return this.get(`/v1/collections?${params}`);
|
|
386
|
-
}
|
|
387
|
-
getCollectionsByOwner(owner, page = 1, limit = 50) {
|
|
388
|
-
const params = new URLSearchParams({ owner: this.addr(owner), page: String(page), limit: String(limit) });
|
|
389
|
-
return this.get(`/v1/collections?${params}`);
|
|
390
|
-
}
|
|
391
380
|
getCollection(contract) {
|
|
392
381
|
return this.get(`/v1/collections/${this.addr(contract)}`);
|
|
393
382
|
}
|
|
@@ -859,9 +848,6 @@ var ApiClient = class {
|
|
|
859
848
|
headers: { "Authorization": `Bearer ${siwsToken}` }
|
|
860
849
|
});
|
|
861
850
|
}
|
|
862
|
-
getPopCollections(opts = {}) {
|
|
863
|
-
return this.getCollections(opts.page ?? 1, opts.limit ?? 20, void 0, opts.sort, "pop-protocol");
|
|
864
|
-
}
|
|
865
851
|
async getPopEligibility(collection, wallet) {
|
|
866
852
|
const res = await this.get(
|
|
867
853
|
`/v1/pop/eligibility/${this.addr(collection)}/${this.addr(wallet)}`
|
|
@@ -911,9 +897,6 @@ var ApiClient = class {
|
|
|
911
897
|
headers: this.bearer(siwsToken)
|
|
912
898
|
});
|
|
913
899
|
}
|
|
914
|
-
getDropCollections(opts = {}) {
|
|
915
|
-
return this.getCollections(opts.page ?? 1, opts.limit ?? 20, void 0, opts.sort, "drop-collection");
|
|
916
|
-
}
|
|
917
900
|
async getDropMintStatus(collection, wallet) {
|
|
918
901
|
const res = await this.get(
|
|
919
902
|
`/v1/drop/mint-status/${this.addr(collection)}/${this.addr(wallet)}`
|
|
@@ -940,6 +923,10 @@ var ApiClient = class {
|
|
|
940
923
|
const res = await this.get(`/v1/tickets/${this.addr(contract)}/count`);
|
|
941
924
|
return res.data.count;
|
|
942
925
|
}
|
|
926
|
+
async getClubMembershipCount(contract) {
|
|
927
|
+
const res = await this.get(`/v1/club/${this.addr(contract)}/count`);
|
|
928
|
+
return res.data.count;
|
|
929
|
+
}
|
|
943
930
|
async getClubMembership(contract, tokenId) {
|
|
944
931
|
const res = await this.get(`/v1/club/${this.addr(contract)}/${tokenId}`);
|
|
945
932
|
return res.data;
|
|
@@ -1023,6 +1010,7 @@ var ApiClient = class {
|
|
|
1023
1010
|
if (query.sort) params.set("sort", query.sort);
|
|
1024
1011
|
if (query.isFeatured !== void 0) params.set("isFeatured", String(query.isFeatured));
|
|
1025
1012
|
if (query.hideEmpty !== void 0) params.set("hideEmpty", String(query.hideEmpty));
|
|
1013
|
+
if (query.standard) params.set("standard", query.standard);
|
|
1026
1014
|
if (query.chain) params.set("chain", query.chain);
|
|
1027
1015
|
const qs = params.toString();
|
|
1028
1016
|
return this.get(`/v1/collections${qs ? `?${qs}` : ""}`);
|