@medialane/sdk 0.70.0 → 0.71.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/evm/index.d.cts +1 -1
- package/dist/evm/index.d.ts +1 -1
- package/dist/index.cjs +111 -10877
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -6
- package/dist/index.d.ts +11 -6
- package/dist/index.js +112 -10809
- package/dist/index.js.map +1 -1
- package/dist/services-B4E-tTin.d.ts +1355 -0
- package/dist/services-D7n-cJYt.d.cts +1355 -0
- package/dist/solana/index.d.cts +1 -1
- package/dist/solana/index.d.ts +1 -1
- package/dist/starknet/index.cjs +105 -121
- package/dist/starknet/index.cjs.map +1 -1
- package/dist/starknet/index.d.cts +8098 -3
- package/dist/starknet/index.d.ts +8098 -3
- package/dist/starknet/index.js +105 -121
- package/dist/starknet/index.js.map +1 -1
- package/dist/stellar/index.d.cts +1 -1
- package/dist/stellar/index.d.ts +1 -1
- package/dist/{types-Du_-QoQ1.d.cts → types-Cdwb6lXp.d.cts} +1 -1
- package/dist/{types-Du_-QoQ1.d.ts → types-Cdwb6lXp.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/index-C6dV4UYm.d.cts +0 -9441
- package/dist/index-DRoaqZ2T.d.ts +0 -9441
package/dist/solana/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PublicKey, Transaction, Connection } from '@solana/web3.js';
|
|
2
|
-
import { V as VenueAdapter, C as Chain, R as RegisterOrderParams, A as AdapterTxResult, O as OrderRef } from '../types-
|
|
2
|
+
import { V as VenueAdapter, C as Chain, R as RegisterOrderParams, A as AdapterTxResult, O as OrderRef } from '../types-Cdwb6lXp.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Anchor wire encoding for the Medialane Solana programs — discriminators,
|
package/dist/solana/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PublicKey, Transaction, Connection } from '@solana/web3.js';
|
|
2
|
-
import { V as VenueAdapter, C as Chain, R as RegisterOrderParams, A as AdapterTxResult, O as OrderRef } from '../types-
|
|
2
|
+
import { V as VenueAdapter, C as Chain, R as RegisterOrderParams, A as AdapterTxResult, O as OrderRef } from '../types-Cdwb6lXp.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Anchor wire encoding for the Medialane Solana programs — discriminators,
|
package/dist/starknet/index.cjs
CHANGED
|
@@ -263,18 +263,26 @@ var ApiClient = class {
|
|
|
263
263
|
addr(a) {
|
|
264
264
|
return normalizeAddress(this.chain, a);
|
|
265
265
|
}
|
|
266
|
-
|
|
266
|
+
/**
|
|
267
|
+
* The one HTTP path for the whole client: base headers (incl. x-api-key),
|
|
268
|
+
* JSON error unwrapping, and `withRetry` (5xx/network only — 4xx never
|
|
269
|
+
* retried). `allow404`/`allow403` turn those statuses into a `null` result
|
|
270
|
+
* instead of a throw, for "profile may not exist" / "not a holder" reads —
|
|
271
|
+
* so no method needs to hand-roll `fetch` to get that behavior.
|
|
272
|
+
*/
|
|
273
|
+
async request(path, init, opts) {
|
|
267
274
|
const url = `${this.baseUrl.replace(/\/$/, "")}${path}`;
|
|
268
275
|
const headers = { ...this.baseHeaders };
|
|
269
276
|
if (!(init?.body instanceof FormData)) {
|
|
270
277
|
headers["Content-Type"] = "application/json";
|
|
271
278
|
}
|
|
279
|
+
const allowed = (status) => opts?.allow404 === true && status === 404 || opts?.allow403 === true && status === 403;
|
|
272
280
|
const res = await withRetry(async () => {
|
|
273
281
|
const response = await fetch(url, {
|
|
274
282
|
...init,
|
|
275
283
|
headers: { ...headers, ...init?.headers }
|
|
276
284
|
});
|
|
277
|
-
if (!response.ok) {
|
|
285
|
+
if (!response.ok && !allowed(response.status)) {
|
|
278
286
|
const text = await response.text().catch(() => response.statusText);
|
|
279
287
|
let message = text;
|
|
280
288
|
try {
|
|
@@ -286,6 +294,7 @@ var ApiClient = class {
|
|
|
286
294
|
}
|
|
287
295
|
return response;
|
|
288
296
|
}, this.retryOptions);
|
|
297
|
+
if (allowed(res.status)) return null;
|
|
289
298
|
return res.json();
|
|
290
299
|
}
|
|
291
300
|
get(path) {
|
|
@@ -300,20 +309,9 @@ var ApiClient = class {
|
|
|
300
309
|
del(path) {
|
|
301
310
|
return this.request(path, { method: "DELETE" });
|
|
302
311
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
if (!res.ok) {
|
|
307
|
-
const text = await res.text().catch(() => res.statusText);
|
|
308
|
-
let message = text;
|
|
309
|
-
try {
|
|
310
|
-
const body = JSON.parse(text);
|
|
311
|
-
if (body.error) message = body.error;
|
|
312
|
-
} catch {
|
|
313
|
-
}
|
|
314
|
-
throw new MedialaneApiError(res.status, message);
|
|
315
|
-
}
|
|
316
|
-
return res.json();
|
|
312
|
+
/** Bearer header for Clerk-JWT-authenticated routes. */
|
|
313
|
+
bearer(clerkToken) {
|
|
314
|
+
return { Authorization: `Bearer ${clerkToken}` };
|
|
317
315
|
}
|
|
318
316
|
// ─── Orders ────────────────────────────────────────────────────────────────
|
|
319
317
|
getOrders(query = {}) {
|
|
@@ -517,17 +515,11 @@ var ApiClient = class {
|
|
|
517
515
|
* Authorization: Bearer (Clerk JWT) simultaneously.
|
|
518
516
|
*/
|
|
519
517
|
async claimCollection(contractAddress, walletAddress, clerkToken) {
|
|
520
|
-
|
|
521
|
-
const res = await fetch(url, {
|
|
518
|
+
return this.request("/v1/collections/claim", {
|
|
522
519
|
method: "POST",
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
"Content-Type": "application/json",
|
|
526
|
-
"Authorization": `Bearer ${clerkToken}`
|
|
527
|
-
},
|
|
528
|
-
body: JSON.stringify({ contractAddress, walletAddress })
|
|
520
|
+
body: JSON.stringify({ contractAddress, walletAddress }),
|
|
521
|
+
headers: this.bearer(clerkToken)
|
|
529
522
|
});
|
|
530
|
-
return this.checkResponse(res);
|
|
531
523
|
}
|
|
532
524
|
/**
|
|
533
525
|
* Path 3: Manual off-chain claim request (email-based).
|
|
@@ -539,106 +531,92 @@ var ApiClient = class {
|
|
|
539
531
|
});
|
|
540
532
|
}
|
|
541
533
|
// ─── Collection Profiles ────────────────────────────────────────────────────
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
534
|
+
getCollectionProfile(contractAddress) {
|
|
535
|
+
return this.request(
|
|
536
|
+
`/v1/collections/${this.addr(contractAddress)}/profile`,
|
|
537
|
+
{ method: "GET" },
|
|
538
|
+
{ allow404: true }
|
|
539
|
+
);
|
|
546
540
|
}
|
|
547
541
|
/**
|
|
548
542
|
* Update collection profile. Requires Clerk JWT for ownership check.
|
|
549
543
|
*/
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
method: "PATCH",
|
|
554
|
-
|
|
555
|
-
"x-api-key": this.baseHeaders["x-api-key"] ?? "",
|
|
556
|
-
"Content-Type": "application/json",
|
|
557
|
-
"Authorization": `Bearer ${clerkToken}`
|
|
558
|
-
},
|
|
559
|
-
body: JSON.stringify(data)
|
|
560
|
-
});
|
|
561
|
-
return this.checkResponse(res);
|
|
544
|
+
updateCollectionProfile(contractAddress, data, clerkToken) {
|
|
545
|
+
return this.request(
|
|
546
|
+
`/v1/collections/${this.addr(contractAddress)}/profile`,
|
|
547
|
+
{ method: "PATCH", body: JSON.stringify(data), headers: this.bearer(clerkToken) }
|
|
548
|
+
);
|
|
562
549
|
}
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
550
|
+
getGatedContent(contractAddress, clerkToken) {
|
|
551
|
+
return this.request(
|
|
552
|
+
`/v1/collections/${this.addr(contractAddress)}/gated-content`,
|
|
553
|
+
{ method: "GET", headers: this.bearer(clerkToken) },
|
|
554
|
+
{ allow404: true, allow403: true }
|
|
555
|
+
);
|
|
569
556
|
}
|
|
570
557
|
// ─── Creator Profiles ───────────────────────────────────────────────────────
|
|
571
558
|
/** List all creators with an approved username. */
|
|
572
|
-
|
|
559
|
+
getCreators(opts = {}) {
|
|
573
560
|
const params = new URLSearchParams();
|
|
574
561
|
if (opts.search) params.set("search", opts.search);
|
|
575
562
|
if (opts.page) params.set("page", String(opts.page));
|
|
576
563
|
if (opts.limit) params.set("limit", String(opts.limit));
|
|
577
|
-
const
|
|
578
|
-
|
|
579
|
-
return this.checkResponse(res);
|
|
564
|
+
const qs = params.toString();
|
|
565
|
+
return this.get(`/v1/creators${qs ? `?${qs}` : ""}`);
|
|
580
566
|
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
567
|
+
getCreatorProfile(walletAddress) {
|
|
568
|
+
return this.request(
|
|
569
|
+
`/v1/creators/${this.addr(walletAddress)}/profile`,
|
|
570
|
+
{ method: "GET" },
|
|
571
|
+
{ allow404: true }
|
|
572
|
+
);
|
|
585
573
|
}
|
|
586
574
|
/** Resolve a username slug to a creator profile (public). */
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
575
|
+
getCreatorByUsername(username) {
|
|
576
|
+
return this.request(
|
|
577
|
+
`/v1/creators/by-username/${encodeURIComponent(username.toLowerCase().trim())}`,
|
|
578
|
+
{ method: "GET" },
|
|
579
|
+
{ allow404: true }
|
|
580
|
+
);
|
|
591
581
|
}
|
|
592
582
|
/**
|
|
593
583
|
* Update creator profile. Requires Clerk JWT; wallet must match authenticated user.
|
|
594
584
|
*/
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
method: "PATCH",
|
|
599
|
-
|
|
600
|
-
"x-api-key": this.baseHeaders["x-api-key"] ?? "",
|
|
601
|
-
"Content-Type": "application/json",
|
|
602
|
-
"Authorization": `Bearer ${clerkToken}`
|
|
603
|
-
},
|
|
604
|
-
body: JSON.stringify(data)
|
|
605
|
-
});
|
|
606
|
-
return this.checkResponse(res);
|
|
585
|
+
updateCreatorProfile(walletAddress, data, clerkToken) {
|
|
586
|
+
return this.request(
|
|
587
|
+
`/v1/creators/${this.addr(walletAddress)}/profile`,
|
|
588
|
+
{ method: "PATCH", body: JSON.stringify(data), headers: this.bearer(clerkToken) }
|
|
589
|
+
);
|
|
607
590
|
}
|
|
608
591
|
// ─── Collection Slug Claims ───────────────────────────────────────────────────
|
|
609
592
|
/** Check if a collection slug is available (public, no auth). */
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
593
|
+
checkCollectionSlugAvailability(slug) {
|
|
594
|
+
return this.get(
|
|
595
|
+
`/v1/collection-slug-claims/check/${encodeURIComponent(slug.toLowerCase().trim())}`
|
|
596
|
+
);
|
|
614
597
|
}
|
|
615
598
|
/** Submit a slug claim for a collection. Requires Clerk JWT — caller must be the collection owner. */
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
const res = await fetch(url, {
|
|
599
|
+
submitCollectionSlugClaim(contractAddress, slug, clerkToken, notifyEmail) {
|
|
600
|
+
return this.request("/v1/collection-slug-claims", {
|
|
619
601
|
method: "POST",
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
"Content-Type": "application/json",
|
|
623
|
-
Authorization: `Bearer ${clerkToken}`
|
|
624
|
-
},
|
|
625
|
-
body: JSON.stringify({ contractAddress, slug, notifyEmail })
|
|
602
|
+
body: JSON.stringify({ contractAddress, slug, notifyEmail }),
|
|
603
|
+
headers: this.bearer(clerkToken)
|
|
626
604
|
});
|
|
627
|
-
return this.checkResponse(res);
|
|
628
605
|
}
|
|
629
606
|
/** Returns all slug claims submitted by the authenticated wallet. Requires Clerk JWT. */
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
headers:
|
|
607
|
+
getMyCollectionSlugClaims(clerkToken) {
|
|
608
|
+
return this.request("/v1/collection-slug-claims/me", {
|
|
609
|
+
method: "GET",
|
|
610
|
+
headers: this.bearer(clerkToken)
|
|
634
611
|
});
|
|
635
|
-
return this.checkResponse(res);
|
|
636
612
|
}
|
|
637
613
|
/** Resolve a collection slug to a full collection. Returns null if not found. */
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
614
|
+
getCollectionBySlug(slug) {
|
|
615
|
+
return this.request(
|
|
616
|
+
`/v1/collections/by-slug/${encodeURIComponent(slug.toLowerCase().trim())}`,
|
|
617
|
+
{ method: "GET" },
|
|
618
|
+
{ allow404: true }
|
|
619
|
+
);
|
|
642
620
|
}
|
|
643
621
|
// ─── User Wallet ─────────────────────────────────────────────────────────────
|
|
644
622
|
/**
|
|
@@ -655,33 +633,28 @@ var ApiClient = class {
|
|
|
655
633
|
return this.post("/v1/users/register", params);
|
|
656
634
|
}
|
|
657
635
|
async upsertMyWallet(clerkToken, options = {}) {
|
|
658
|
-
const url = `${this.baseUrl.replace(/\/$/, "")}/v1/users/me`;
|
|
659
636
|
const body = {
|
|
660
637
|
walletType: options.walletType ?? "UNKNOWN",
|
|
661
638
|
appSource: options.appSource ?? "MEDIALANE_SDK"
|
|
662
639
|
};
|
|
663
640
|
if (options.chain) body.chain = options.chain;
|
|
664
|
-
|
|
641
|
+
return this.request("/v1/users/me", {
|
|
665
642
|
method: "POST",
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
"Authorization": `Bearer ${clerkToken}`
|
|
669
|
-
},
|
|
670
|
-
body: JSON.stringify(body)
|
|
643
|
+
body: JSON.stringify(body),
|
|
644
|
+
headers: this.bearer(clerkToken)
|
|
671
645
|
});
|
|
672
|
-
return this.checkResponse(res);
|
|
673
646
|
}
|
|
674
647
|
/**
|
|
675
648
|
* Get the authenticated user's stored wallet address from the backend DB.
|
|
676
649
|
* Returns null if the user has not completed onboarding yet.
|
|
677
650
|
* Requires Clerk JWT; no tenant API key needed.
|
|
678
651
|
*/
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
652
|
+
getMyWallet(clerkToken) {
|
|
653
|
+
return this.request(
|
|
654
|
+
"/v1/users/me",
|
|
655
|
+
{ method: "GET", headers: this.bearer(clerkToken) },
|
|
656
|
+
{ allow404: true }
|
|
657
|
+
);
|
|
685
658
|
}
|
|
686
659
|
// ─── Remix Licensing ─────────────────────────────────────────────────────────
|
|
687
660
|
/**
|
|
@@ -731,25 +704,23 @@ var ApiClient = class {
|
|
|
731
704
|
* role="creator" — offers where you are the original creator.
|
|
732
705
|
* role="requester" — offers you made.
|
|
733
706
|
*/
|
|
734
|
-
|
|
707
|
+
getRemixOffers(query, clerkToken) {
|
|
735
708
|
const params = new URLSearchParams({ role: query.role });
|
|
736
709
|
if (query.page !== void 0) params.set("page", String(query.page));
|
|
737
710
|
if (query.limit !== void 0) params.set("limit", String(query.limit));
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
headers:
|
|
711
|
+
return this.request(`/v1/remix-offers?${params}`, {
|
|
712
|
+
method: "GET",
|
|
713
|
+
headers: this.bearer(clerkToken)
|
|
741
714
|
});
|
|
742
|
-
return this.checkResponse(res);
|
|
743
715
|
}
|
|
744
716
|
/**
|
|
745
717
|
* Get a single remix offer. Clerk JWT optional (price/currency hidden for non-participants).
|
|
746
718
|
*/
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
return this.checkResponse(res);
|
|
719
|
+
getRemixOffer(id, clerkToken) {
|
|
720
|
+
return this.request(`/v1/remix-offers/${id}`, {
|
|
721
|
+
method: "GET",
|
|
722
|
+
headers: clerkToken ? this.bearer(clerkToken) : void 0
|
|
723
|
+
});
|
|
753
724
|
}
|
|
754
725
|
/**
|
|
755
726
|
* Creator approves a remix offer (authorises the requester to mint). Requires Clerk JWT.
|
|
@@ -10344,8 +10315,21 @@ var ERC1155CollectionService = class {
|
|
|
10344
10315
|
|
|
10345
10316
|
// src/utils/token.ts
|
|
10346
10317
|
function getTokenByAddress(address) {
|
|
10347
|
-
|
|
10348
|
-
|
|
10318
|
+
let target = null;
|
|
10319
|
+
try {
|
|
10320
|
+
target = BigInt(address);
|
|
10321
|
+
} catch {
|
|
10322
|
+
target = null;
|
|
10323
|
+
}
|
|
10324
|
+
return SUPPORTED_TOKENS.find((t) => {
|
|
10325
|
+
if (target !== null) {
|
|
10326
|
+
try {
|
|
10327
|
+
return BigInt(t.address) === target;
|
|
10328
|
+
} catch {
|
|
10329
|
+
}
|
|
10330
|
+
}
|
|
10331
|
+
return t.address.toLowerCase() === address.toLowerCase();
|
|
10332
|
+
});
|
|
10349
10333
|
}
|
|
10350
10334
|
|
|
10351
10335
|
// src/starknet/services/creatorCoin.ts
|