@medialane/sdk 0.136.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.
@@ -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
- async function withRetry(fn, opts) {
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 (err instanceof MedialaneApiError && err.status < 500 && err.status !== 429) {
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
  }
@@ -731,12 +720,13 @@ var ApiClient = class {
731
720
  headers: this.bearer(siwsToken)
732
721
  });
733
722
  }
734
- getCollectionBySlug(slug) {
735
- return this.request(
723
+ async getCollectionBySlug(slug) {
724
+ const res = await this.request(
736
725
  `/v1/collections/by-slug/${encodeURIComponent(slug.toLowerCase().trim())}`,
737
726
  { method: "GET" },
738
727
  { allow404: true }
739
728
  );
729
+ return res?.data ?? null;
740
730
  }
741
731
  async registerUser(params) {
742
732
  return this.post("/v1/users/register", params);
@@ -858,9 +848,6 @@ var ApiClient = class {
858
848
  headers: { "Authorization": `Bearer ${siwsToken}` }
859
849
  });
860
850
  }
861
- getPopCollections(opts = {}) {
862
- return this.getCollections(opts.page ?? 1, opts.limit ?? 20, void 0, opts.sort, "pop-protocol");
863
- }
864
851
  async getPopEligibility(collection, wallet) {
865
852
  const res = await this.get(
866
853
  `/v1/pop/eligibility/${this.addr(collection)}/${this.addr(wallet)}`
@@ -910,9 +897,6 @@ var ApiClient = class {
910
897
  headers: this.bearer(siwsToken)
911
898
  });
912
899
  }
913
- getDropCollections(opts = {}) {
914
- return this.getCollections(opts.page ?? 1, opts.limit ?? 20, void 0, opts.sort, "drop-collection");
915
- }
916
900
  async getDropMintStatus(collection, wallet) {
917
901
  const res = await this.get(
918
902
  `/v1/drop/mint-status/${this.addr(collection)}/${this.addr(wallet)}`
@@ -939,6 +923,10 @@ var ApiClient = class {
939
923
  const res = await this.get(`/v1/tickets/${this.addr(contract)}/count`);
940
924
  return res.data.count;
941
925
  }
926
+ async getClubMembershipCount(contract) {
927
+ const res = await this.get(`/v1/club/${this.addr(contract)}/count`);
928
+ return res.data.count;
929
+ }
942
930
  async getClubMembership(contract, tokenId) {
943
931
  const res = await this.get(`/v1/club/${this.addr(contract)}/${tokenId}`);
944
932
  return res.data;
@@ -1022,6 +1010,7 @@ var ApiClient = class {
1022
1010
  if (query.sort) params.set("sort", query.sort);
1023
1011
  if (query.isFeatured !== void 0) params.set("isFeatured", String(query.isFeatured));
1024
1012
  if (query.hideEmpty !== void 0) params.set("hideEmpty", String(query.hideEmpty));
1013
+ if (query.standard) params.set("standard", query.standard);
1025
1014
  if (query.chain) params.set("chain", query.chain);
1026
1015
  const qs = params.toString();
1027
1016
  return this.get(`/v1/collections${qs ? `?${qs}` : ""}`);
@@ -1047,6 +1036,22 @@ var ApiClient = class {
1047
1036
  if (query.open !== void 0) params.set("open", String(query.open));
1048
1037
  return this.get(`/v1/sponsorship/offers?${params}`);
1049
1038
  }
1039
+ async getSponsorshipOffer(offerId) {
1040
+ const res = await this.request(
1041
+ `/v1/sponsorship/offers/${encodeURIComponent(offerId)}`,
1042
+ { method: "GET" },
1043
+ { allow404: true }
1044
+ );
1045
+ return res?.data ?? null;
1046
+ }
1047
+ async getSponsorshipProposal(proposalId) {
1048
+ const res = await this.request(
1049
+ `/v1/sponsorship/proposals/${encodeURIComponent(proposalId)}`,
1050
+ { method: "GET" },
1051
+ { allow404: true }
1052
+ );
1053
+ return res?.data ?? null;
1054
+ }
1050
1055
  async getSponsorshipBids(offerId) {
1051
1056
  const res = await this.get(`/v1/sponsorship/offers/${encodeURIComponent(offerId)}/bids`);
1052
1057
  return res.data;