@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.
- package/README.md +5 -4
- package/dist/{errors-DlrNXuXZ.d.ts → errors-ac8HvmsP.d.ts} +4 -12
- package/dist/{errors-CadmV001.d.cts → errors-iITqaALF.d.cts} +4 -12
- package/dist/index.cjs +33 -28
- 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 +33 -28
- package/dist/index.js.map +1 -1
- package/dist/starknet/index.cjs +33 -28
- 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 +33 -28
- package/dist/starknet/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -280,11 +280,12 @@ token.balances?.forEach((b: ApiTokenBalance) => {
|
|
|
280
280
|
|
|
281
281
|
```typescript
|
|
282
282
|
// All collections: newest first by default
|
|
283
|
-
const collections = await client.api.
|
|
283
|
+
const collections = await client.api.listCollections();
|
|
284
284
|
|
|
285
|
-
//
|
|
286
|
-
const byVolume = await client.api.
|
|
287
|
-
const
|
|
285
|
+
// Filter, sort and paginate in one query
|
|
286
|
+
const byVolume = await client.api.listCollections({ page: 1, limit: 20, sort: "volume" });
|
|
287
|
+
const featured = await client.api.listCollections({ limit: 18, isFeatured: true, sort: "recent" });
|
|
288
|
+
const myDrops = await client.api.listCollections({ owner: "0x...", service: "drop-collection" });
|
|
288
289
|
|
|
289
290
|
// Sort options: "recent" | "supply" | "floor" | "volume" | "name"
|
|
290
291
|
const collection = await client.api.getCollection(contract);
|
|
@@ -1238,6 +1238,7 @@ interface ApiCollectionsListQuery {
|
|
|
1238
1238
|
sort?: CollectionSort;
|
|
1239
1239
|
isFeatured?: boolean;
|
|
1240
1240
|
hideEmpty?: boolean;
|
|
1241
|
+
standard?: string;
|
|
1241
1242
|
chain?: ChainFilter;
|
|
1242
1243
|
}
|
|
1243
1244
|
interface ApiPricingRule {
|
|
@@ -1296,8 +1297,6 @@ declare class ApiClient {
|
|
|
1296
1297
|
getToken(contract: string, tokenId: string, wait?: boolean): Promise<ApiResponse<ApiToken>>;
|
|
1297
1298
|
getTokensByOwner(address: string, page?: number, limit?: number): Promise<ApiResponse<ApiToken[]>>;
|
|
1298
1299
|
getTokenHistory(contract: string, tokenId: string, page?: number, limit?: number): Promise<ApiResponse<ApiActivity[]>>;
|
|
1299
|
-
getCollections(page?: number, limit?: number, isKnown?: boolean, sort?: CollectionSort, service?: string, chain?: ChainFilter, standard?: string): Promise<ApiResponse<ApiCollection[]>>;
|
|
1300
|
-
getCollectionsByOwner(owner: string, page?: number, limit?: number): Promise<ApiResponse<ApiCollection[]>>;
|
|
1301
1300
|
getCollection(contract: string): Promise<ApiResponse<ApiCollection>>;
|
|
1302
1301
|
getCollectionTokens(contract: string, page?: number, limit?: number, sort?: CollectionTokensSort): Promise<ApiResponse<ApiToken[]>>;
|
|
1303
1302
|
getActivities(query?: ApiActivitiesQuery): Promise<ApiResponse<ApiActivity[]>>;
|
|
@@ -1491,11 +1490,6 @@ declare class ApiClient {
|
|
|
1491
1490
|
confirmRemixOffer(id: string, params: ConfirmRemixOfferParams, siwsToken: string): Promise<ApiResponse<ApiRemixOffer>>;
|
|
1492
1491
|
rejectRemixOffer(id: string, siwsToken: string): Promise<ApiResponse<ApiRemixOffer>>;
|
|
1493
1492
|
extendRemixOffer(id: string, days: number, siwsToken: string): Promise<ApiResponse<ApiRemixOffer>>;
|
|
1494
|
-
getPopCollections(opts?: {
|
|
1495
|
-
page?: number;
|
|
1496
|
-
limit?: number;
|
|
1497
|
-
sort?: CollectionSort;
|
|
1498
|
-
}): Promise<ApiResponse<ApiCollection[]>>;
|
|
1499
1493
|
getPopEligibility(collection: string, wallet: string): Promise<PopClaimStatus>;
|
|
1500
1494
|
getPopEligibilityBatch(collection: string, wallets: string[]): Promise<PopBatchEligibilityItem[]>;
|
|
1501
1495
|
getCoins(opts?: ApiCoinsQuery): Promise<ApiResponse<ApiCoin[]>>;
|
|
@@ -1509,16 +1503,12 @@ declare class ApiClient {
|
|
|
1509
1503
|
image?: string | null;
|
|
1510
1504
|
description?: string | null;
|
|
1511
1505
|
}, siwsToken: string): Promise<ApiResponse<ApiCoin>>;
|
|
1512
|
-
getDropCollections(opts?: {
|
|
1513
|
-
page?: number;
|
|
1514
|
-
limit?: number;
|
|
1515
|
-
sort?: CollectionSort;
|
|
1516
|
-
}): Promise<ApiResponse<ApiCollection[]>>;
|
|
1517
1506
|
getDropMintStatus(collection: string, wallet: string): Promise<DropMintStatus>;
|
|
1518
1507
|
getDropInfo(contract: string): Promise<ApiDropInfo | null>;
|
|
1519
1508
|
getDropState(contract: string): Promise<ApiDropState>;
|
|
1520
1509
|
getTicket(contract: string, tokenId: string): Promise<ApiTierOnchain>;
|
|
1521
1510
|
getTicketCount(contract: string): Promise<number>;
|
|
1511
|
+
getClubMembershipCount(contract: string): Promise<number>;
|
|
1522
1512
|
getClubMembership(contract: string, tokenId: string): Promise<ApiTierOnchain>;
|
|
1523
1513
|
isClubMember(contract: string, tokenId: string, wallet: string): Promise<boolean>;
|
|
1524
1514
|
getIpNftTokenData(contract: string, tokenId: string): Promise<ApiIpNftTokenData | null>;
|
|
@@ -1547,6 +1537,8 @@ declare class ApiClient {
|
|
|
1547
1537
|
data: ApiCollection;
|
|
1548
1538
|
}>;
|
|
1549
1539
|
getSponsorshipOffers(query?: ApiSponsorshipOffersQuery): Promise<ApiResponse<ApiSponsorshipOffer[]>>;
|
|
1540
|
+
getSponsorshipOffer(offerId: string): Promise<ApiSponsorshipOffer | null>;
|
|
1541
|
+
getSponsorshipProposal(proposalId: string): Promise<ApiSponsorshipProposal | null>;
|
|
1550
1542
|
getSponsorshipBids(offerId: string): Promise<ApiSponsorshipBid[]>;
|
|
1551
1543
|
getSponsorshipProposals(query?: ApiSponsorshipProposalsQuery): Promise<ApiResponse<ApiSponsorshipProposal[]>>;
|
|
1552
1544
|
getSponsorshipLicenses(query?: ApiSponsorshipLicensesQuery): Promise<ApiResponse<ApiSponsorshipLicense[]>>;
|
|
@@ -1238,6 +1238,7 @@ interface ApiCollectionsListQuery {
|
|
|
1238
1238
|
sort?: CollectionSort;
|
|
1239
1239
|
isFeatured?: boolean;
|
|
1240
1240
|
hideEmpty?: boolean;
|
|
1241
|
+
standard?: string;
|
|
1241
1242
|
chain?: ChainFilter;
|
|
1242
1243
|
}
|
|
1243
1244
|
interface ApiPricingRule {
|
|
@@ -1296,8 +1297,6 @@ declare class ApiClient {
|
|
|
1296
1297
|
getToken(contract: string, tokenId: string, wait?: boolean): Promise<ApiResponse<ApiToken>>;
|
|
1297
1298
|
getTokensByOwner(address: string, page?: number, limit?: number): Promise<ApiResponse<ApiToken[]>>;
|
|
1298
1299
|
getTokenHistory(contract: string, tokenId: string, page?: number, limit?: number): Promise<ApiResponse<ApiActivity[]>>;
|
|
1299
|
-
getCollections(page?: number, limit?: number, isKnown?: boolean, sort?: CollectionSort, service?: string, chain?: ChainFilter, standard?: string): Promise<ApiResponse<ApiCollection[]>>;
|
|
1300
|
-
getCollectionsByOwner(owner: string, page?: number, limit?: number): Promise<ApiResponse<ApiCollection[]>>;
|
|
1301
1300
|
getCollection(contract: string): Promise<ApiResponse<ApiCollection>>;
|
|
1302
1301
|
getCollectionTokens(contract: string, page?: number, limit?: number, sort?: CollectionTokensSort): Promise<ApiResponse<ApiToken[]>>;
|
|
1303
1302
|
getActivities(query?: ApiActivitiesQuery): Promise<ApiResponse<ApiActivity[]>>;
|
|
@@ -1491,11 +1490,6 @@ declare class ApiClient {
|
|
|
1491
1490
|
confirmRemixOffer(id: string, params: ConfirmRemixOfferParams, siwsToken: string): Promise<ApiResponse<ApiRemixOffer>>;
|
|
1492
1491
|
rejectRemixOffer(id: string, siwsToken: string): Promise<ApiResponse<ApiRemixOffer>>;
|
|
1493
1492
|
extendRemixOffer(id: string, days: number, siwsToken: string): Promise<ApiResponse<ApiRemixOffer>>;
|
|
1494
|
-
getPopCollections(opts?: {
|
|
1495
|
-
page?: number;
|
|
1496
|
-
limit?: number;
|
|
1497
|
-
sort?: CollectionSort;
|
|
1498
|
-
}): Promise<ApiResponse<ApiCollection[]>>;
|
|
1499
1493
|
getPopEligibility(collection: string, wallet: string): Promise<PopClaimStatus>;
|
|
1500
1494
|
getPopEligibilityBatch(collection: string, wallets: string[]): Promise<PopBatchEligibilityItem[]>;
|
|
1501
1495
|
getCoins(opts?: ApiCoinsQuery): Promise<ApiResponse<ApiCoin[]>>;
|
|
@@ -1509,16 +1503,12 @@ declare class ApiClient {
|
|
|
1509
1503
|
image?: string | null;
|
|
1510
1504
|
description?: string | null;
|
|
1511
1505
|
}, siwsToken: string): Promise<ApiResponse<ApiCoin>>;
|
|
1512
|
-
getDropCollections(opts?: {
|
|
1513
|
-
page?: number;
|
|
1514
|
-
limit?: number;
|
|
1515
|
-
sort?: CollectionSort;
|
|
1516
|
-
}): Promise<ApiResponse<ApiCollection[]>>;
|
|
1517
1506
|
getDropMintStatus(collection: string, wallet: string): Promise<DropMintStatus>;
|
|
1518
1507
|
getDropInfo(contract: string): Promise<ApiDropInfo | null>;
|
|
1519
1508
|
getDropState(contract: string): Promise<ApiDropState>;
|
|
1520
1509
|
getTicket(contract: string, tokenId: string): Promise<ApiTierOnchain>;
|
|
1521
1510
|
getTicketCount(contract: string): Promise<number>;
|
|
1511
|
+
getClubMembershipCount(contract: string): Promise<number>;
|
|
1522
1512
|
getClubMembership(contract: string, tokenId: string): Promise<ApiTierOnchain>;
|
|
1523
1513
|
isClubMember(contract: string, tokenId: string, wallet: string): Promise<boolean>;
|
|
1524
1514
|
getIpNftTokenData(contract: string, tokenId: string): Promise<ApiIpNftTokenData | null>;
|
|
@@ -1547,6 +1537,8 @@ declare class ApiClient {
|
|
|
1547
1537
|
data: ApiCollection;
|
|
1548
1538
|
}>;
|
|
1549
1539
|
getSponsorshipOffers(query?: ApiSponsorshipOffersQuery): Promise<ApiResponse<ApiSponsorshipOffer[]>>;
|
|
1540
|
+
getSponsorshipOffer(offerId: string): Promise<ApiSponsorshipOffer | null>;
|
|
1541
|
+
getSponsorshipProposal(proposalId: string): Promise<ApiSponsorshipProposal | null>;
|
|
1550
1542
|
getSponsorshipBids(offerId: string): Promise<ApiSponsorshipBid[]>;
|
|
1551
1543
|
getSponsorshipProposals(query?: ApiSponsorshipProposalsQuery): Promise<ApiResponse<ApiSponsorshipProposal[]>>;
|
|
1552
1544
|
getSponsorshipLicenses(query?: ApiSponsorshipLicensesQuery): Promise<ApiResponse<ApiSponsorshipLicense[]>>;
|
package/dist/index.cjs
CHANGED
|
@@ -239,7 +239,13 @@ var DEFAULT_MAX_DELAY_MS = 5e3;
|
|
|
239
239
|
function sleep(ms) {
|
|
240
240
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
241
241
|
}
|
|
242
|
-
|
|
242
|
+
function isRetryableFor(method, err) {
|
|
243
|
+
if (err instanceof MedialaneApiError && err.status === 429) return true;
|
|
244
|
+
const isRead = method === "GET" || method === "HEAD";
|
|
245
|
+
if (!isRead) return false;
|
|
246
|
+
return err instanceof MedialaneApiError && err.status >= 500 || err instanceof TypeError;
|
|
247
|
+
}
|
|
248
|
+
async function withRetry(fn, opts, method = "GET") {
|
|
243
249
|
const maxAttempts = opts?.maxAttempts ?? DEFAULT_MAX_ATTEMPTS;
|
|
244
250
|
const baseDelayMs = opts?.baseDelayMs ?? DEFAULT_BASE_DELAY_MS;
|
|
245
251
|
const maxDelayMs = opts?.maxDelayMs ?? DEFAULT_MAX_DELAY_MS;
|
|
@@ -249,11 +255,7 @@ async function withRetry(fn, opts) {
|
|
|
249
255
|
return await fn();
|
|
250
256
|
} catch (err) {
|
|
251
257
|
lastError = err;
|
|
252
|
-
if (
|
|
253
|
-
throw err;
|
|
254
|
-
}
|
|
255
|
-
const isRetryable = err instanceof MedialaneApiError && (err.status >= 500 || err.status === 429) || err instanceof TypeError;
|
|
256
|
-
if (!isRetryable || attempt === maxAttempts - 1) {
|
|
258
|
+
if (!isRetryableFor(method, err) || attempt === maxAttempts - 1) {
|
|
257
259
|
throw err;
|
|
258
260
|
}
|
|
259
261
|
const retryAfterMs = err instanceof MedialaneApiError ? err.retryAfterMs : void 0;
|
|
@@ -334,7 +336,7 @@ var ApiClient = class {
|
|
|
334
336
|
);
|
|
335
337
|
}
|
|
336
338
|
return response;
|
|
337
|
-
}, this.retryOptions);
|
|
339
|
+
}, this.retryOptions, (init?.method ?? "GET").toUpperCase());
|
|
338
340
|
if (allowed(res.status)) return null;
|
|
339
341
|
return res.json();
|
|
340
342
|
}
|
|
@@ -402,19 +404,6 @@ var ApiClient = class {
|
|
|
402
404
|
`/v1/tokens/${contract}/${tokenId}/history?page=${page}&limit=${limit}`
|
|
403
405
|
);
|
|
404
406
|
}
|
|
405
|
-
getCollections(page = 1, limit = 20, isKnown, sort, service, chain, standard) {
|
|
406
|
-
const params = new URLSearchParams({ page: String(page), limit: String(limit) });
|
|
407
|
-
if (isKnown !== void 0) params.set("isKnown", String(isKnown));
|
|
408
|
-
if (sort) params.set("sort", sort);
|
|
409
|
-
if (service) params.set("service", service);
|
|
410
|
-
if (chain) params.set("chain", chain);
|
|
411
|
-
if (standard) params.set("standard", standard);
|
|
412
|
-
return this.get(`/v1/collections?${params}`);
|
|
413
|
-
}
|
|
414
|
-
getCollectionsByOwner(owner, page = 1, limit = 50) {
|
|
415
|
-
const params = new URLSearchParams({ owner: this.addr(owner), page: String(page), limit: String(limit) });
|
|
416
|
-
return this.get(`/v1/collections?${params}`);
|
|
417
|
-
}
|
|
418
407
|
getCollection(contract) {
|
|
419
408
|
return this.get(`/v1/collections/${this.addr(contract)}`);
|
|
420
409
|
}
|
|
@@ -758,12 +747,13 @@ var ApiClient = class {
|
|
|
758
747
|
headers: this.bearer(siwsToken)
|
|
759
748
|
});
|
|
760
749
|
}
|
|
761
|
-
getCollectionBySlug(slug) {
|
|
762
|
-
|
|
750
|
+
async getCollectionBySlug(slug) {
|
|
751
|
+
const res = await this.request(
|
|
763
752
|
`/v1/collections/by-slug/${encodeURIComponent(slug.toLowerCase().trim())}`,
|
|
764
753
|
{ method: "GET" },
|
|
765
754
|
{ allow404: true }
|
|
766
755
|
);
|
|
756
|
+
return res?.data ?? null;
|
|
767
757
|
}
|
|
768
758
|
async registerUser(params) {
|
|
769
759
|
return this.post("/v1/users/register", params);
|
|
@@ -885,9 +875,6 @@ var ApiClient = class {
|
|
|
885
875
|
headers: { "Authorization": `Bearer ${siwsToken}` }
|
|
886
876
|
});
|
|
887
877
|
}
|
|
888
|
-
getPopCollections(opts = {}) {
|
|
889
|
-
return this.getCollections(opts.page ?? 1, opts.limit ?? 20, void 0, opts.sort, "pop-protocol");
|
|
890
|
-
}
|
|
891
878
|
async getPopEligibility(collection, wallet) {
|
|
892
879
|
const res = await this.get(
|
|
893
880
|
`/v1/pop/eligibility/${this.addr(collection)}/${this.addr(wallet)}`
|
|
@@ -937,9 +924,6 @@ var ApiClient = class {
|
|
|
937
924
|
headers: this.bearer(siwsToken)
|
|
938
925
|
});
|
|
939
926
|
}
|
|
940
|
-
getDropCollections(opts = {}) {
|
|
941
|
-
return this.getCollections(opts.page ?? 1, opts.limit ?? 20, void 0, opts.sort, "drop-collection");
|
|
942
|
-
}
|
|
943
927
|
async getDropMintStatus(collection, wallet) {
|
|
944
928
|
const res = await this.get(
|
|
945
929
|
`/v1/drop/mint-status/${this.addr(collection)}/${this.addr(wallet)}`
|
|
@@ -966,6 +950,10 @@ var ApiClient = class {
|
|
|
966
950
|
const res = await this.get(`/v1/tickets/${this.addr(contract)}/count`);
|
|
967
951
|
return res.data.count;
|
|
968
952
|
}
|
|
953
|
+
async getClubMembershipCount(contract) {
|
|
954
|
+
const res = await this.get(`/v1/club/${this.addr(contract)}/count`);
|
|
955
|
+
return res.data.count;
|
|
956
|
+
}
|
|
969
957
|
async getClubMembership(contract, tokenId) {
|
|
970
958
|
const res = await this.get(`/v1/club/${this.addr(contract)}/${tokenId}`);
|
|
971
959
|
return res.data;
|
|
@@ -1049,6 +1037,7 @@ var ApiClient = class {
|
|
|
1049
1037
|
if (query.sort) params.set("sort", query.sort);
|
|
1050
1038
|
if (query.isFeatured !== void 0) params.set("isFeatured", String(query.isFeatured));
|
|
1051
1039
|
if (query.hideEmpty !== void 0) params.set("hideEmpty", String(query.hideEmpty));
|
|
1040
|
+
if (query.standard) params.set("standard", query.standard);
|
|
1052
1041
|
if (query.chain) params.set("chain", query.chain);
|
|
1053
1042
|
const qs = params.toString();
|
|
1054
1043
|
return this.get(`/v1/collections${qs ? `?${qs}` : ""}`);
|
|
@@ -1074,6 +1063,22 @@ var ApiClient = class {
|
|
|
1074
1063
|
if (query.open !== void 0) params.set("open", String(query.open));
|
|
1075
1064
|
return this.get(`/v1/sponsorship/offers?${params}`);
|
|
1076
1065
|
}
|
|
1066
|
+
async getSponsorshipOffer(offerId) {
|
|
1067
|
+
const res = await this.request(
|
|
1068
|
+
`/v1/sponsorship/offers/${encodeURIComponent(offerId)}`,
|
|
1069
|
+
{ method: "GET" },
|
|
1070
|
+
{ allow404: true }
|
|
1071
|
+
);
|
|
1072
|
+
return res?.data ?? null;
|
|
1073
|
+
}
|
|
1074
|
+
async getSponsorshipProposal(proposalId) {
|
|
1075
|
+
const res = await this.request(
|
|
1076
|
+
`/v1/sponsorship/proposals/${encodeURIComponent(proposalId)}`,
|
|
1077
|
+
{ method: "GET" },
|
|
1078
|
+
{ allow404: true }
|
|
1079
|
+
);
|
|
1080
|
+
return res?.data ?? null;
|
|
1081
|
+
}
|
|
1077
1082
|
async getSponsorshipBids(offerId) {
|
|
1078
1083
|
const res = await this.get(`/v1/sponsorship/offers/${encodeURIComponent(offerId)}/bids`);
|
|
1079
1084
|
return res.data;
|